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 |
|---|---|---|---|---|---|---|
339,476 | <p>How do I raise an event from a user control that was created dynamically?</p>
<p>Here's the code that I'm trying where Bind is a public EventHandler</p>
<pre><code>protected indDemographics IndDemographics;
protected UserControl uc;
override protected void OnInit(EventArgs e)
{
uc = (UserControl)LoadControl("i... | [
{
"answer_id": 339520,
"author": "ctacke",
"author_id": 13154,
"author_profile": "https://Stackoverflow.com/users/13154",
"pm_score": 1,
"selected": false,
"text": "<p>I see it (IndDemographics) declared but never actually created, so I'd expect it to be null with just this code.</p>\n"
... | 2008/12/04 | [
"https://Stackoverflow.com/questions/339476",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4888/"
] | How do I raise an event from a user control that was created dynamically?
Here's the code that I'm trying where Bind is a public EventHandler
```
protected indDemographics IndDemographics;
protected UserControl uc;
override protected void OnInit(EventArgs e)
{
uc = (UserControl)LoadControl("indDemographics.ascx")... | First off, you'll need to make sure that you have the event defined in your usercontrol's code.
for example:
```
public class MyUserControl
Inherits UserControl
Public Event Bind(sender as object, e as EventArgs)
public sub SomeFunction()
RaiseEvent Bind(me, new EventArgS())
End Sub
End Class
```
Aft... |
339,483 | <p>I need to repeatedly remove the first line from a huge text file using a bash script.</p>
<p>Right now I am using <code>sed -i -e "1d" $FILE</code> - but it takes around a minute to do the deletion.</p>
<p>Is there a more efficient way to accomplish this?</p>
| [
{
"answer_id": 339519,
"author": "paxdiablo",
"author_id": 14860,
"author_profile": "https://Stackoverflow.com/users/14860",
"pm_score": 4,
"selected": false,
"text": "<p>No, that's about as efficient as you're going to get. You could write a C program which could do the job a little fas... | 2008/12/04 | [
"https://Stackoverflow.com/questions/339483",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3764/"
] | I need to repeatedly remove the first line from a huge text file using a bash script.
Right now I am using `sed -i -e "1d" $FILE` - but it takes around a minute to do the deletion.
Is there a more efficient way to accomplish this? | Try [tail](http://man7.org/linux/man-pages/man1/tail.1.html):
```
tail -n +2 "$FILE"
```
`-n x`: Just print the last `x` lines. `tail -n 5` would give you the last 5 lines of the input. The `+` sign kind of inverts the argument and make `tail` print anything but the first `x-1` lines. `tail -n +1` would print the wh... |
339,496 | <p>I've been trying to deal with some delimited text files that have non standard delimiters (not comma/quote or tab delimited). The delimiters are random ASCII characters that don't show up often between the delimiters. After searching around, I've seem to have only found no solutions in .NET will suit my needs and ... | [
{
"answer_id": 339501,
"author": "Ian P",
"author_id": 10853,
"author_profile": "https://Stackoverflow.com/users/10853",
"pm_score": -1,
"selected": false,
"text": "<p>While this doesn't help address the large input issue, a possible solution to the parsing issue might include a custom p... | 2008/12/04 | [
"https://Stackoverflow.com/questions/339496",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1469014/"
] | I've been trying to deal with some delimited text files that have non standard delimiters (not comma/quote or tab delimited). The delimiters are random ASCII characters that don't show up often between the delimiters. After searching around, I've seem to have only found no solutions in .NET will suit my needs and the c... | Use the [File Helpers API](http://filehelpers.sourceforge.net/). It's .NET and open source. It's extremely high performance using compiled IL code to set fields on strongly typed objects, and supports streaming.
It supports all sorts of file types and custom delimiters; I've used it to read files larger than 4GB.
If ... |
339,508 | <p>reference, OpenCv\samples\c\lkdemo.c </p>
<p>Anybody know what does the following snippet of codes does ?</p>
<p>Code extracted from lkdemo.c</p>
<pre><code> for( i = k = 0; i < count; i++ )
{
if( add_remove_pt )
{
double dx = pt.x - points[1][i].... | [
{
"answer_id": 339573,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "<p>Q1:</p>\n\n<p>Perhaps it would help if I refactor the code:</p>\n\n<pre><code>if( status[i] ) {\n points[1][k++] = point... | 2008/12/04 | [
"https://Stackoverflow.com/questions/339508",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43076/"
] | reference, OpenCv\samples\c\lkdemo.c
Anybody know what does the following snippet of codes does ?
Code extracted from lkdemo.c
```
for( i = k = 0; i < count; i++ )
{
if( add_remove_pt )
{
double dx = pt.x - points[1][i].x;
double d... | Q1:
Perhaps it would help if I refactor the code:
```
if( status[i] ) {
points[1][k++] = points[1][i]; // <---- Q1
cvCircle( image, cvPointFrom32f(points[1][i]), 3, CV_RGB(0,255,0), -1, 8,0);
}
```
So in the line for question 1, i always increments (it's incremented by the loop) but k only increments when ... |
339,510 | <p>I have a html div layered on top of an interactive flash movie, but when the mouse moves over the div, it can't interact with the flash (the view changes as the mouse moves or is clicked). Is there a way to have the flash recieve the mouse movements and clicks but leaving the html visible?</p>
<p>I can't modify the... | [
{
"answer_id": 339547,
"author": "Dan Herbert",
"author_id": 392,
"author_profile": "https://Stackoverflow.com/users/392",
"pm_score": 2,
"selected": false,
"text": "<p>Try something like this:</p>\n\n<pre><code><object> \n <param name=\"wmode\" value=\"transparent\" /> \n... | 2008/12/04 | [
"https://Stackoverflow.com/questions/339510",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43077/"
] | I have a html div layered on top of an interactive flash movie, but when the mouse moves over the div, it can't interact with the flash (the view changes as the mouse moves or is clicked). Is there a way to have the flash recieve the mouse movements and clicks but leaving the html visible?
I can't modify the flash SWF... | Try something like this:
```
<object>
<param name="wmode" value="transparent" />
<embed src="example.swf" wmode="transparent"></embed>
</object>
```
The main things to note are the `<param />` tag with the transparent attribute, and the `wmode="transparent"` in the embed tag. You'll also need to run the ... |
339,515 | <p>I'm a developer who builds mainly single page client side web applications where state in maintained on the client-side. Lately some of the applications have become very complex with very rich domain models on the client-side and increasingly complicated UI interactions.</p>
<p>As we've gone along we've implemented... | [
{
"answer_id": 339547,
"author": "Dan Herbert",
"author_id": 392,
"author_profile": "https://Stackoverflow.com/users/392",
"pm_score": 2,
"selected": false,
"text": "<p>Try something like this:</p>\n\n<pre><code><object> \n <param name=\"wmode\" value=\"transparent\" /> \n... | 2008/12/04 | [
"https://Stackoverflow.com/questions/339515",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37196/"
] | I'm a developer who builds mainly single page client side web applications where state in maintained on the client-side. Lately some of the applications have become very complex with very rich domain models on the client-side and increasingly complicated UI interactions.
As we've gone along we've implemented some very... | Try something like this:
```
<object>
<param name="wmode" value="transparent" />
<embed src="example.swf" wmode="transparent"></embed>
</object>
```
The main things to note are the `<param />` tag with the transparent attribute, and the `wmode="transparent"` in the embed tag. You'll also need to run the ... |
339,537 | <p>When reading lines from a text file using python, the end-line character often needs to be truncated before processing the text, as in the following example:</p>
<pre><code>f = open("myFile.txt", "r")
for line in f:
line = line[:-1]
# do something with line
</code></pre>
<p>Is there an elegant way or idiom... | [
{
"answer_id": 339574,
"author": "Adam Rosenfield",
"author_id": 9530,
"author_profile": "https://Stackoverflow.com/users/9530",
"pm_score": 3,
"selected": false,
"text": "<p>What's wrong with your code? I find it to be quite elegant and simple. The only problem is that if the file doe... | 2008/12/04 | [
"https://Stackoverflow.com/questions/339537",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6225/"
] | When reading lines from a text file using python, the end-line character often needs to be truncated before processing the text, as in the following example:
```
f = open("myFile.txt", "r")
for line in f:
line = line[:-1]
# do something with line
```
Is there an elegant way or idiom for retrieving text lines... | The *idiomatic* way to do this in Python is to use **rstrip('\n')**:
```
for line in open('myfile.txt'): # opened in text-mode; all EOLs are converted to '\n'
line = line.rstrip('\n')
process(line)
```
Each of the other alternatives has a gotcha:
* **file('...').read().splitlines()** has to load the whole ... |
339,549 | <p>INPUT</p>
<pre><code><logs>
<logentry revision="648">
<author>nshmyrev</author>
<date>2008-09-21T19:43:10.819236Z</date>
<paths>
<path action="M">/trunk/po/ru.pi</path>
</paths>
<msg>2008-09-21 Nickolay V. Shmyrev nshmyrev@yandex.ru * ru.po: Updat... | [
{
"answer_id": 339553,
"author": "acrosman",
"author_id": 24215,
"author_profile": "https://Stackoverflow.com/users/24215",
"pm_score": 1,
"selected": false,
"text": "<p>For large projects I generally write a script that checks out the project, removes any extra files (I generally remove... | 2008/12/04 | [
"https://Stackoverflow.com/questions/339549",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | INPUT
```
<logs>
<logentry revision="648">
<author>nshmyrev</author>
<date>2008-09-21T19:43:10.819236Z</date>
<paths>
<path action="M">/trunk/po/ru.pi</path>
</paths>
<msg>2008-09-21 Nickolay V. Shmyrev nshmyrev@yandex.ru * ru.po: Updated Russian translation.</msg>
</logentry>
<logentry revision="647">
<author>cki... | Instead of checking out the project, *svn export* it. That gets rid of any svn metadata. Beyond that, I've gotta agree with acrosman's suggestion: build a script or purge files by hand.
I don't know about NetBeans and how much it auto-generates stuff that you may have included in svn, but in our projects we *svn ignor... |
339,559 | <p>I'm following <a href="http://www.stanford.edu/class/cs193p/cgi-bin/index.php" rel="nofollow noreferrer">iPhone dev courses</a> from Stanford Open-University, and I've been blocked for 2 days on <a href="http://cs193p.stanford.edu/downloads/Assignment3.pdf" rel="nofollow noreferrer">assignment3</a>, maybe someone ca... | [
{
"answer_id": 339590,
"author": "Alex",
"author_id": 16974,
"author_profile": "https://Stackoverflow.com/users/16974",
"pm_score": 1,
"selected": false,
"text": "<p>Found my own answer, I missed a setPolygon method in my CustomView to link both... stupid...</p>\n\n<p>in <em>CustomView.h... | 2008/12/04 | [
"https://Stackoverflow.com/questions/339559",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16974/"
] | I'm following [iPhone dev courses](http://www.stanford.edu/class/cs193p/cgi-bin/index.php) from Stanford Open-University, and I've been blocked for 2 days on [assignment3](http://cs193p.stanford.edu/downloads/Assignment3.pdf), maybe someone can help me here?
The tasks are:
1. Create a custom UIView subclass that will... | And after you figure it out, it might not hurt to touch up on some objective-c basics:
<http://www.cocoacast.com/?q=node/103> |
339,560 | <p>I'm working on some upgrades to an internal web analytics system we provide for our clients (in the absence of a preferred vendor or Google Analytics), and I'm working on the following query:</p>
<pre><code>select
path as EntryPage,
count(Path) as [Count]
from
(
/* Sub-query 1 */
sel... | [
{
"answer_id": 339572,
"author": "dkretz",
"author_id": 31641,
"author_profile": "https://Stackoverflow.com/users/31641",
"pm_score": 3,
"selected": true,
"text": "<p>For starters,</p>\n\n<pre><code> where pv1.Domain = isnull(@Domain, pv1.Domain) \n</code></pre>\n\n<p>won't SARG. You ... | 2008/12/04 | [
"https://Stackoverflow.com/questions/339560",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34942/"
] | I'm working on some upgrades to an internal web analytics system we provide for our clients (in the absence of a preferred vendor or Google Analytics), and I'm working on the following query:
```
select
path as EntryPage,
count(Path) as [Count]
from
(
/* Sub-query 1 */
select
... | For starters,
```
where pv1.Domain = isnull(@Domain, pv1.Domain)
```
won't SARG. You can't optimize a match on a function, as I remember. |
339,582 | <p>I'm trying to write a (sh -bourne shell) script that processes lines as they are written to a file. I'm attempting to do this by feeding the output of <code>tail -f</code> into a <code>while read</code> loop. This tactic seems to be proper based on my research in Google as well as <a href="https://stackoverflow.com/... | [
{
"answer_id": 339604,
"author": "Robert Gamble",
"author_id": 25222,
"author_profile": "https://Stackoverflow.com/users/25222",
"pm_score": 0,
"selected": false,
"text": "<p>I don't know about HP-UX <code>tail</code> but GNU <code>tail</code> has the <code>--follow=name</code> option wh... | 2008/12/04 | [
"https://Stackoverflow.com/questions/339582",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1588/"
] | I'm trying to write a (sh -bourne shell) script that processes lines as they are written to a file. I'm attempting to do this by feeding the output of `tail -f` into a `while read` loop. This tactic seems to be proper based on my research in Google as well as [this question](https://stackoverflow.com/questions/157163/h... | If you want to break out, when your file does not exist any more, just do it:
```
test -f file || break
```
Placing this in your loop, should break out.
The remaining problem is, how to break the read line, as this is blocking.
This could you do by applying a timeout, like read -t 5 line. Then every 5 second the... |
339,613 | <p>Following on from <a href="https://stackoverflow.com/questions/333072/how-do-i-use-use-frozen-capistrano">my question on using frozen Capistrano a couple of days back</a> I'm still having issues running Capistrano frozen in my vendor folder.</p>
<p>When I try and run my frozen version of cap </p>
<pre><code>ruby -... | [
{
"answer_id": 339617,
"author": "Joe Van Dyk",
"author_id": 17076,
"author_profile": "https://Stackoverflow.com/users/17076",
"pm_score": 0,
"selected": false,
"text": "<p>If you want to completely avoid the system-installed gems (which isn't a bad idea if you don't have control over th... | 2008/12/04 | [
"https://Stackoverflow.com/questions/339613",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16779/"
] | Following on from [my question on using frozen Capistrano a couple of days back](https://stackoverflow.com/questions/333072/how-do-i-use-use-frozen-capistrano) I'm still having issues running Capistrano frozen in my vendor folder.
When I try and run my frozen version of cap
```
ruby -r rubygems ./vendor/gems/capistr... | In the end I decided not to freeze Capistrano and dependancies to my vendor gems directory as they weren't gems used by my application - they were used to deploy my application.
Instead I locally installed them on my hosting account and all worked fine. |
339,616 | <p>With Php when does an included file get included? Is it during a preprocessing stage or is it during script evaluation?</p>
<p>Right now I have several scripts that share the same header and footer code, which do input validation and exception handling. Like this:</p>
<pre><code>/* validate input */
...
/* process... | [
{
"answer_id": 339626,
"author": "too much php",
"author_id": 28835,
"author_profile": "https://Stackoverflow.com/users/28835",
"pm_score": 1,
"selected": false,
"text": "<p>include/require are executed in sequence like 'echo' or other statements.</p>\n"
},
{
"answer_id": 339629,... | 2008/12/04 | [
"https://Stackoverflow.com/questions/339616",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15124/"
] | With Php when does an included file get included? Is it during a preprocessing stage or is it during script evaluation?
Right now I have several scripts that share the same header and footer code, which do input validation and exception handling. Like this:
```
/* validate input */
...
/* process/do task */
...
/* ha... | [PHP.net: include](http://fi.php.net/include/) gives a basic example:
```
vars.php
<?php
$color = 'green';
$fruit = 'apple';
?>
test.php
<?php
echo "A $color $fruit"; // A
include 'vars.php';
echo "A $color $fruit"; // A green apple
?>
```
so include happens when its executed in code.
Edit: fixed url. |
339,620 | <p>WPF doesn't provide the ability to have a window that allows resize but doesn't have maximize or minimize buttons. I'd like to able to make such a window so I can have resizable dialog boxes.</p>
<p>I'm aware the solution will mean using pinvoke but I'm not sure what to call and how. A search of pinvoke.net didn't ... | [
{
"answer_id": 339635,
"author": "Matt Hamilton",
"author_id": 615,
"author_profile": "https://Stackoverflow.com/users/615",
"pm_score": 8,
"selected": true,
"text": "<p>I've stolen some code I found on the MSDN forums and made an extension method on the Window class, like this:</p>\n\n<... | 2008/12/04 | [
"https://Stackoverflow.com/questions/339620",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/483/"
] | WPF doesn't provide the ability to have a window that allows resize but doesn't have maximize or minimize buttons. I'd like to able to make such a window so I can have resizable dialog boxes.
I'm aware the solution will mean using pinvoke but I'm not sure what to call and how. A search of pinvoke.net didn't turn up an... | I've stolen some code I found on the MSDN forums and made an extension method on the Window class, like this:
```
internal static class WindowExtensions
{
// from winuser.h
private const int GWL_STYLE = -16,
WS_MAXIMIZEBOX = 0x10000,
WS_MINIMIZEBOX = 0x20000;
... |
339,654 | <p>When the view property of a UIViewController is accessed, it first checks to see if it's got an existing view, and returns that. If not, it loads its nib or calls -loadView. </p>
<p>When a controller receives a -didReceiveMemoryWarning message, the default behavior is to remove that cached view (assuming it's not i... | [
{
"answer_id": 340176,
"author": "Louis Gerbarg",
"author_id": 30506,
"author_profile": "https://Stackoverflow.com/users/30506",
"pm_score": 0,
"selected": false,
"text": "<p>You could use <a href=\"http://developer.apple.com/documentation/Cocoa/Reference/ObjCRuntimeRef/Reference/referen... | 2008/12/04 | [
"https://Stackoverflow.com/questions/339654",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6694/"
] | When the view property of a UIViewController is accessed, it first checks to see if it's got an existing view, and returns that. If not, it loads its nib or calls -loadView.
When a controller receives a -didReceiveMemoryWarning message, the default behavior is to remove that cached view (assuming it's not in use at t... | I think in your situation it's best to do something like:
```
- (void)setView:(UIView *)view
{
if (!view)
{
// Clean up code here
}
[super setView:view];
}
``` |
339,663 | <p>I'm having a problem getting access to a database which lives on a remote server. </p>
<p>I have a ASP.NET 2.0 webpage that is trying to connect to a database.<br>
The database is accessed via a virtual folder (which I set up in IIS).<br>
The virtual folder points at a remote share which contains the database. <... | [
{
"answer_id": 339707,
"author": "Samiksha",
"author_id": 29515,
"author_profile": "https://Stackoverflow.com/users/29515",
"pm_score": 0,
"selected": false,
"text": "<p>make sure the two servers have internal access to each other and also specify the ip & port of db server in your c... | 2008/12/04 | [
"https://Stackoverflow.com/questions/339663",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/242/"
] | I'm having a problem getting access to a database which lives on a remote server.
I have a ASP.NET 2.0 webpage that is trying to connect to a database.
The database is accessed via a virtual folder (which I set up in IIS).
The virtual folder points at a remote share which contains the database.
The virtual fo... | **UPDATE**
First up, thank you to everyone who submitted answers.
However, we ended up *not* using the 'connect to remote database via virtual folder' method because the complexity of the permissions needed to get this to work was causing us more problems than it was worth. We put the UNC path back into the connect... |
339,667 | <p>I have an application web.xml with the following entry:</p>
<pre><code><error-page>
<error-code>404</error-code>
<location>/system_files/error/p_notfound.jsp</location>
</error-page>
</code></pre>
<p>However, when this page is displayed, Japanese characters are garbled. ... | [
{
"answer_id": 339697,
"author": "user19371",
"author_id": 19371,
"author_profile": "https://Stackoverflow.com/users/19371",
"pm_score": 1,
"selected": false,
"text": "<p>My understanding is that Microsoft will provide backwards compatibility and/or a migration strategy to the new WF, so... | 2008/12/04 | [
"https://Stackoverflow.com/questions/339667",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43096/"
] | I have an application web.xml with the following entry:
```
<error-page>
<error-code>404</error-code>
<location>/system_files/error/p_notfound.jsp</location>
</error-page>
```
However, when this page is displayed, Japanese characters are garbled.
The same page (p\_notfound.jsp) displays properly if display... | Haiving just launched a project which .NET 3.5 and workflow I'd say that the current release of WF is **good enough** to use and run with. It has helped us to get a product out quickly (we have the usual feature creep and requirements changing weekly). However, I have a list of complaints with it:
* The workflow desig... |
339,699 | <p>I read about Java's type erasure <a href="https://docs.oracle.com/javase/tutorial/java/generics/erasure.html" rel="noreferrer">on Oracle's website</a>.</p>
<p><strong>When does type erasure occur?</strong> At compile time or runtime? When the class is loaded? When the class is instantiated?</p>
<p>A lot of sites (... | [
{
"answer_id": 339702,
"author": "Eugene Yokota",
"author_id": 3827,
"author_profile": "https://Stackoverflow.com/users/3827",
"pm_score": 4,
"selected": false,
"text": "<p><a href=\"https://www.oracle.com/technetwork/java/javase/generics-tutorial-159168.pdf\" rel=\"noreferrer\">Generics... | 2008/12/04 | [
"https://Stackoverflow.com/questions/339699",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I read about Java's type erasure [on Oracle's website](https://docs.oracle.com/javase/tutorial/java/generics/erasure.html).
**When does type erasure occur?** At compile time or runtime? When the class is loaded? When the class is instantiated?
A lot of sites (including the official tutorial mentioned above) say type ... | Type erasure applies to the *use* of generics. There's definitely metadata in the class file to say whether or not a method/type *is* generic, and what the constraints are etc. But when generics are *used*, they're converted into compile-time checks and execution-time casts. So this code:
```
List<String> list = new A... |
339,706 | <p>DocumentsController#common_query can handle multiple different request styles.</p>
<p>i.e. all docs in batch 4 or all docs tagged "happy"</p>
<p>I want a single route to make em pretty, so:</p>
<p>/documents/common_query?batch=4</p>
<p>/documents/common_query?tag=happy</p>
<p>become:</p>
<p>/documents/batch/4<... | [
{
"answer_id": 339869,
"author": "Daniel Lucraft",
"author_id": 11951,
"author_profile": "https://Stackoverflow.com/users/11951",
"pm_score": 1,
"selected": true,
"text": "<p>As a single route:</p>\n\n<pre><code>ActionController::Routing::Routes.draw do |map|\n map.connect \"documents/:... | 2008/12/04 | [
"https://Stackoverflow.com/questions/339706",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37378/"
] | DocumentsController#common\_query can handle multiple different request styles.
i.e. all docs in batch 4 or all docs tagged "happy"
I want a single route to make em pretty, so:
/documents/common\_query?batch=4
/documents/common\_query?tag=happy
become:
/documents/batch/4
/documents/tag/happy
So the end result i... | As a single route:
```
ActionController::Routing::Routes.draw do |map|
map.connect "documents/:type/:id", :controller => "documents_controller",
:action => "common_query"
end
```
Then `params[:type]` will either be `"batch"` or `"tag"`, and `params[:id]` either `"4"` or `"happy"`. You will have to m... |
339,710 | <p>In my LOB apps I usually wind up with containers that contain a bunch of different textblocks and textboxes for users to enter data. Normally I need to apply a certain margin or vertical/horizontal alignment to each control.</p>
<p>Let's say I have Grid on my form that looks like this (a lot of markup was eliminate... | [
{
"answer_id": 339883,
"author": "Excel Kobayashi",
"author_id": 42911,
"author_profile": "https://Stackoverflow.com/users/42911",
"pm_score": 0,
"selected": false,
"text": "<p>You could use #4 but then explicitly override those properties on the Grid itself.</p>\n"
},
{
"answer_... | 2008/12/04 | [
"https://Stackoverflow.com/questions/339710",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17744/"
] | In my LOB apps I usually wind up with containers that contain a bunch of different textblocks and textboxes for users to enter data. Normally I need to apply a certain margin or vertical/horizontal alignment to each control.
Let's say I have Grid on my form that looks like this (a lot of markup was eliminated for brev... | Here is a solution that I came up with using an Attached Property:
[Coding Context Article](http://codingcontext.wordpress.com/2008/12/11/solution-styling-a-large-amount-of-controls/) |
339,714 | <p>So I am trying to accomplish something like this:</p>
<pre><code>SELECT * FROM table WHERE status_id IN (1,3,4);
</code></pre>
<p>using Zend_Db_Select... can't find how to do it :( Is it at all possible?</p>
| [
{
"answer_id": 339718,
"author": "xelurg",
"author_id": 35520,
"author_profile": "https://Stackoverflow.com/users/35520",
"pm_score": 3,
"selected": false,
"text": "<p>apparently it is super simple... stupid me:</p>\n\n<pre><code>$select->where('status_id IN(1,3,4)');\n</code></pre>\n... | 2008/12/04 | [
"https://Stackoverflow.com/questions/339714",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35520/"
] | So I am trying to accomplish something like this:
```
SELECT * FROM table WHERE status_id IN (1,3,4);
```
using Zend\_Db\_Select... can't find how to do it :( Is it at all possible? | you can also use it like this:
```
$data = array(1,3,4);
$select->where('status_id IN(?)', $data);
```
you dont need to implode array, and it's safer |
339,719 | <p>From the haskell report:</p>
<blockquote>
<p>The quot, rem, div, and mod class
methods satisfy these laws if y is
non-zero:</p>
<pre><code>(x `quot` y)*y + (x `rem` y) == x
(x `div` y)*y + (x `mod` y) == x
</code></pre>
<p><code>quot</code> is integer division truncated
toward zero, while the result ... | [
{
"answer_id": 339760,
"author": "namin",
"author_id": 34596,
"author_profile": "https://Stackoverflow.com/users/34596",
"pm_score": 3,
"selected": false,
"text": "<p>A simple example where it would matter is testing if an integer is even or odd.</p>\n\n<pre><code>let buggyOdd x = x `rem... | 2008/12/04 | [
"https://Stackoverflow.com/questions/339719",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/486/"
] | From the haskell report:
>
> The quot, rem, div, and mod class
> methods satisfy these laws if y is
> non-zero:
>
>
>
> ```
> (x `quot` y)*y + (x `rem` y) == x
> (x `div` y)*y + (x `mod` y) == x
>
> ```
>
> `quot` is integer division truncated
> toward zero, while the result of `div`
> is truncated toward n... | Many languages have a "mod" or "%" operator that gives the remainder after division with truncation towards 0; for example C, C++, and Java, and probably C#, would say:
```
(-11)/5 = -2
(-11)%5 = -1
5*((-11)/5) + (-11)%5 = 5*(-2) + (-1) = -11.
```
Haskell's `quot` and `rem` are intended to imitate this behaviour. I ... |
339,763 | <p>I want to do preliminary check if entered string looks like <a href="http://en.wikipedia.org/wiki/Vehicle_identification_number" rel="noreferrer">Vehicle Identification Number (VIN)</a>. I know what it consists of 17 letters and digits, but letters I, O and Q are not allowed inside VIN, so I use this regular express... | [
{
"answer_id": 339775,
"author": "VonC",
"author_id": 6309,
"author_profile": "https://Stackoverflow.com/users/6309",
"pm_score": 3,
"selected": false,
"text": "<p>Not a direct answer but just an obvious remark:</p>\n<p>If for some reason Character class subtraction is not supported, you... | 2008/12/04 | [
"https://Stackoverflow.com/questions/339763",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11256/"
] | I want to do preliminary check if entered string looks like [Vehicle Identification Number (VIN)](http://en.wikipedia.org/wiki/Vehicle_identification_number). I know what it consists of 17 letters and digits, but letters I, O and Q are not allowed inside VIN, so I use this regular expression:
```
^[0-9A-Z-[IOQ]]{17}$ ... | The RegularExpressionValidator also supports client-side validation using JavaScript, where the JavaScript Regex engine is used. The difference you see is the difference between the JavaScript and the .NET regex implementation.
You can disable client-side validation and thus force the validator to use the .NET regex en... |
339,792 | <p>I'm trying to get a class memeber variable list at run time. I know this probably using typeof and reflections. but can't find an example. Please someone shed light for me.</p>
<p>Here is pseudo code example:</p>
<pre><code>Class Test01
{
public string str01;
public string str02;
public int myint01;
}
</code><... | [
{
"answer_id": 339798,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 4,
"selected": true,
"text": "<p>If you're after public <em>fields</em> just use <a href=\"http://msdn.microsoft.com/en-us/library/system.type.getfield... | 2008/12/04 | [
"https://Stackoverflow.com/questions/339792",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36674/"
] | I'm trying to get a class memeber variable list at run time. I know this probably using typeof and reflections. but can't find an example. Please someone shed light for me.
Here is pseudo code example:
```
Class Test01
{
public string str01;
public string str02;
public int myint01;
}
```
I want something like t... | If you're after public *fields* just use [`tt.GetType().GetFields()`](http://msdn.microsoft.com/en-us/library/system.type.getfields.aspx)
If you need other members, use [GetProperties()](http://msdn.microsoft.com/en-us/library/system.type.getproperties.aspx), [GetMethods()](http://msdn.microsoft.com/en-us/library/syst... |
339,802 | <p>We are working with Tomcat + Axis2 + POJO for web service implementation, and we encountered some issues with POJO and Axis2 that are a showstopper for us.
It seems that Axis2 and POJO implementation of SOAP parsing ignores the names of the XML elements and just assign values to the arguments according to the order ... | [
{
"answer_id": 339834,
"author": "kgiannakakis",
"author_id": 24054,
"author_profile": "https://Stackoverflow.com/users/24054",
"pm_score": 2,
"selected": false,
"text": "<p>Straight from Axis2 Web site, <a href=\"http://ws.apache.org/axis2/1_4_1/jaxws-guide.html\" rel=\"nofollow norefer... | 2008/12/04 | [
"https://Stackoverflow.com/questions/339802",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24640/"
] | We are working with Tomcat + Axis2 + POJO for web service implementation, and we encountered some issues with POJO and Axis2 that are a showstopper for us.
It seems that Axis2 and POJO implementation of SOAP parsing ignores the names of the XML elements and just assign values to the arguments according to the order of ... | Straight from Axis2 Web site, [this](http://ws.apache.org/axis2/1_4_1/jaxws-guide.html) is a tutorial covering Axis2 and Jax-Ws. You get the above error probably because the axis2-jaxws-1.3.jar is missing. Check your classpath.
You can of course use CXF with Tomcat and my personal opinion is that you would be better o... |
339,829 | <p>Is there a built in Javascript function to turn the text string of a month into the numerical equivalent? </p>
<p>Ex.
I have the name of the month "December" and I want a function to return "12".</p>
| [
{
"answer_id": 339839,
"author": "kgiannakakis",
"author_id": 24054,
"author_profile": "https://Stackoverflow.com/users/24054",
"pm_score": 1,
"selected": false,
"text": "<p>I recommend jQuery's <a href=\"http://docs.jquery.com/UI/Datepicker/%24.datepicker.parseDate#formatvaluesettings\"... | 2008/12/04 | [
"https://Stackoverflow.com/questions/339829",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29297/"
] | Is there a built in Javascript function to turn the text string of a month into the numerical equivalent?
Ex.
I have the name of the month "December" and I want a function to return "12". | You can append some dummy day and year to the month name and then use the [Date](http://www.cev.washington.edu/lc/CLWEBCLB/jst/js_datetime.html) constructor:
```
var month = (new Date("December 1, 1970").getMonth() + 1);
``` |
339,856 | <p>I need to use a datetime.strptime on the text which looks like follows.</p>
<p>"Some Random text of undetermined length Jan 28, 1986"</p>
<p>how do i do this?</p>
| [
{
"answer_id": 339884,
"author": "gimel",
"author_id": 6491,
"author_profile": "https://Stackoverflow.com/users/6491",
"pm_score": 3,
"selected": true,
"text": "<p>Using the ending 3 words, no need for regexps (using the <code>time</code> module):</p>\n\n<pre><code>>>> import ti... | 2008/12/04 | [
"https://Stackoverflow.com/questions/339856",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2220518/"
] | I need to use a datetime.strptime on the text which looks like follows.
"Some Random text of undetermined length Jan 28, 1986"
how do i do this? | Using the ending 3 words, no need for regexps (using the `time` module):
```
>>> import time
>>> a="Some Random text of undetermined length Jan 28, 1986"
>>> datetuple = a.rsplit(" ",3)[-3:]
>>> datetuple
['Jan', '28,', '1986']
>>> time.strptime(' '.join(datetuple),"%b %d, %Y")
time.struct_time(tm_year=1986, tm_mon=1,... |
339,861 | <p>We need to send email which contains Pound (currency) symbols in ColdFusion. Before sending email, we are dumping the data into a html file for preview. </p>
<ol>
<li>How to send a email with utf-8 encoding in ColdFusion</li>
<li>How to save a file with utf-8 encoding in ColdFusion</li>
</ol>
| [
{
"answer_id": 339865,
"author": "Alterlife",
"author_id": 36848,
"author_profile": "https://Stackoverflow.com/users/36848",
"pm_score": 0,
"selected": false,
"text": "<p>Try adding <code><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" /></code> in the <code>... | 2008/12/04 | [
"https://Stackoverflow.com/questions/339861",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43056/"
] | We need to send email which contains Pound (currency) symbols in ColdFusion. Before sending email, we are dumping the data into a html file for preview.
1. How to send a email with utf-8 encoding in ColdFusion
2. How to save a file with utf-8 encoding in ColdFusion | E-Mails are sent in the encoding that is specified in the ColdFusion Administrator. For ColdFusion MX (6.0) and up this is UTF-8 by default.
You can explicitly mention the encoding like this, but it should not be necessary.
```
<cfmail type="text/html; Charset=UTF-8" ...><!--- body ---></cfmail>
```
For the HTML fi... |
339,887 | <p>I'm developing my application (on Linux) and sadly it sometimes hangs. I can use <code>Ctrl+C</code> to send sigint, but my program is ignoring sigint because it's too far gone. So I have to do the process-killing-dance:</p>
<pre><code>Ctrl+Z
$ ps aux | grep process_name
$ kill -9 pid
</code></pre>
<p>Is there a w... | [
{
"answer_id": 339905,
"author": "Vinko Vrsalovic",
"author_id": 5190,
"author_profile": "https://Stackoverflow.com/users/5190",
"pm_score": 2,
"selected": false,
"text": "<p>Given that there's no bound key for SIGKILL, what you can do is to create an alias to save some typing, if SIGQUI... | 2008/12/04 | [
"https://Stackoverflow.com/questions/339887",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11951/"
] | I'm developing my application (on Linux) and sadly it sometimes hangs. I can use `Ctrl+C` to send sigint, but my program is ignoring sigint because it's too far gone. So I have to do the process-killing-dance:
```
Ctrl+Z
$ ps aux | grep process_name
$ kill -9 pid
```
Is there a way to configure bash to send the kill... | I don't think there is any key you can use to send a SIGKILL.
Will SIGQUIT do instead? If you are not catching that, the default is to core dump the process. By default this is ^\. You can see this by running:
```
$ stty -a
```
in a terminal. It should say:
```
quit = ^\
``` |
339,902 | <p>Suppose you are implementing a publication database and creating migrations to represent different publications. Each publication has a "year" associated with it.</p>
<p><code>t.column :year, ???</code></p>
<p>Would this year be best represented as an integer, date, or datetime?</p>
| [
{
"answer_id": 339958,
"author": "mat",
"author_id": 42083,
"author_profile": "https://Stackoverflow.com/users/42083",
"pm_score": 0,
"selected": false,
"text": "<p>Well, if you only care about the <strong>year</strong>, an integer will do just right. If you're not certain that you will ... | 2008/12/04 | [
"https://Stackoverflow.com/questions/339902",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39584/"
] | Suppose you are implementing a publication database and creating migrations to represent different publications. Each publication has a "year" associated with it.
`t.column :year, ???`
Would this year be best represented as an integer, date, or datetime? | I would recommend just going with Rails conventions and doing a `Date` data type. This way, if you ever *do* need the month and day, you can retrieve it. Plus, it's simple to do:
```
YourModel.date.year # => "1999"
``` |
339,910 | <p>in context of SQL Server 2005, I have a table for which the primary key is a uniqueidentifier (GUID), with a default value generated by the newid() function. I want to write a stored procedure that inserts a new record into the table. How do I get the record's PK value? for an identity-declared field, this is easy -... | [
{
"answer_id": 339918,
"author": "Paul Nearney",
"author_id": 24071,
"author_profile": "https://Stackoverflow.com/users/24071",
"pm_score": 3,
"selected": true,
"text": "<p>I would generate a new Guid prior to inserting the record, and explicitly use this new Guid as the PK for the recor... | 2008/12/04 | [
"https://Stackoverflow.com/questions/339910",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11464/"
] | in context of SQL Server 2005, I have a table for which the primary key is a uniqueidentifier (GUID), with a default value generated by the newid() function. I want to write a stored procedure that inserts a new record into the table. How do I get the record's PK value? for an identity-declared field, this is easy - I ... | I would generate a new Guid prior to inserting the record, and explicitly use this new Guid as the PK for the record. You then use that guid after the insert, knowing that it refers to the row you have just inserted, e.g.
```
DECLARE @newGuid uniqueidentifier
SET @newGuid = newid()
INSERT INTO myTable(id, stringval)
... |
339,912 | <p>I have class with internal property:</p>
<pre><code>internal virtual StateEnum EnrolmentState
{
get { ..getter logic }
set { ..setter logic }
}
</code></pre>
<p>However I want to be able to access to this property outside of the assembly so I created method that simply returns this property:</p>
<pre><c... | [
{
"answer_id": 339925,
"author": "Erik Hellström",
"author_id": 2795,
"author_profile": "https://Stackoverflow.com/users/2795",
"pm_score": 0,
"selected": false,
"text": "<p>This sounds like you should reconsider your choice of design. Internal is used to avoid what you are trying to do,... | 2008/12/04 | [
"https://Stackoverflow.com/questions/339912",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29511/"
] | I have class with internal property:
```
internal virtual StateEnum EnrolmentState
{
get { ..getter logic }
set { ..setter logic }
}
```
However I want to be able to access to this property outside of the assembly so I created method that simply returns this property:
```
public StateEnum GetCurrentState(... | Why is the property internal in the first place? If you want to have public access to it, make it public. I assume you have some control over this, as otherwise you wouldn't be able to add a public method to access it in the first place.
If you only want selected other assemblies to be able to access it, `InternalsVis... |
339,923 | <p>In an HTML table, the <code>cellpadding</code> and <code>cellspacing</code> can be set like this:</p>
<pre class="lang-html prettyprint-override"><code><table cellspacing="1" cellpadding="1">
</code></pre>
<p>How can the same be accomplished using CSS?</p>
| [
{
"answer_id": 339964,
"author": "mat",
"author_id": 42083,
"author_profile": "https://Stackoverflow.com/users/42083",
"pm_score": 6,
"selected": false,
"text": "<p>Also, if you want <code>cellspacing=\"0\"</code>, don't forget to add <code>border-collapse: collapse</code> in your <code>... | 2008/12/04 | [
"https://Stackoverflow.com/questions/339923",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1065/"
] | In an HTML table, the `cellpadding` and `cellspacing` can be set like this:
```html
<table cellspacing="1" cellpadding="1">
```
How can the same be accomplished using CSS? | **Basics**
For controlling "cellpadding" in CSS, you can simply use `padding` on table cells. E.g. for 10px of "cellpadding":
```css
td {
padding: 10px;
}
```
For "cellspacing", you can apply the `border-spacing` CSS property to your table. E.g. for 10px of "cellspacing":
```css
table {
border-spacing: 1... |
339,926 | <p>I'm making a web application and I got the design for it from a sub-contracted design company. The design is pretty nice, I like it, but I've stumbled across one thing I'm not sure how to implement nicely.</p>
<p>The thing is - they've redesigned the looks of buttons to match the page style. So now I have two image... | [
{
"answer_id": 339950,
"author": "David A Gibson",
"author_id": 982,
"author_profile": "https://Stackoverflow.com/users/982",
"pm_score": 2,
"selected": true,
"text": "<p>As far as I was aware the CSS Pseudo-classes are for links ONLY in IE. This may have changed in IE8 but I'm not aware... | 2008/12/04 | [
"https://Stackoverflow.com/questions/339926",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41360/"
] | I'm making a web application and I got the design for it from a sub-contracted design company. The design is pretty nice, I like it, but I've stumbled across one thing I'm not sure how to implement nicely.
The thing is - they've redesigned the looks of buttons to match the page style. So now I have two images - button... | As far as I was aware the CSS Pseudo-classes are for links ONLY in IE. This may have changed in IE8 but I'm not aware of it. So basically I don;t think there is an elegant way of implementing it via CSS.
That's not a useful answer so I'll also add that I would implement it using images and client-side script which isn... |
339,931 | <p>Javascript client side application.</p>
<p>Trying to eliminate memory leaks leads to ugly (to say the least) code.</p>
<p>I am trying to clean up in window.unload instead on messing up all the code trying to avoid them.</p>
<p>We use mostly <code>element.onevent=function(){..};</code> pattern, that results in clo... | [
{
"answer_id": 339940,
"author": "Vilx-",
"author_id": 41360,
"author_profile": "https://Stackoverflow.com/users/41360",
"pm_score": 0,
"selected": false,
"text": "<p>I'm not sure what you mean with cleanup as JavaScript has an automatic memory management. But anyway, as I understand, af... | 2008/12/04 | [
"https://Stackoverflow.com/questions/339931",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28207/"
] | Javascript client side application.
Trying to eliminate memory leaks leads to ugly (to say the least) code.
I am trying to clean up in window.unload instead on messing up all the code trying to avoid them.
We use mostly `element.onevent=function(){..};` pattern, that results in closure (mostly wanted) and memory lea... | The best solution is for you to roll out your own method that manages event handling. Therefore, when attaching an event handler, your method can keep track of all the added events. On unload, it can unregister all the handlers.
I know you said you don't use libraries, but you can use their code as inspiration. Ext-js... |
339,935 | <p>For example:</p>
<p>script.js:</p>
<pre><code>function functionFromScriptJS() {
alert('inside functionFromScriptJS');
}
</code></pre>
<p>iframe.html:</p>
<pre><code><html>
<head>
<script language="Javascript" src="script.js"></script>
</head>
<body>
<iframe>
<b... | [
{
"answer_id": 339965,
"author": "Ryan Cook",
"author_id": 43029,
"author_profile": "https://Stackoverflow.com/users/43029",
"pm_score": 3,
"selected": true,
"text": "<p>Iframes do not support inline content. you must use the src attribute to reference a different file. The inner text of... | 2008/12/04 | [
"https://Stackoverflow.com/questions/339935",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/578/"
] | For example:
script.js:
```
function functionFromScriptJS() {
alert('inside functionFromScriptJS');
}
```
iframe.html:
```
<html>
<head>
<script language="Javascript" src="script.js"></script>
</head>
<body>
<iframe>
<body>
<script language="JavaScript">
functionFromScriptJS();
</script>
... | Iframes do not support inline content. you must use the src attribute to reference a different file. The inner text of the `<iframe>` tag will be displayed to browsers that do not support iframes.
Example:
```
<iframe src="someFile.html" width="100%" height="300px">
<p>Your browser does not support iframes.</p>
</i... |
339,939 | <h2>My Situation</h2>
<ul>
<li>I have a N rectangles</li>
<li>The rectangles all have the same shape (for example 2 inches wide x 1 inch tall) - Let's refer to this size as Sw and Sh for the width and height</li>
<li>I want to position these rectangles in a grid such that the rects completely on top and next to each o... | [
{
"answer_id": 339953,
"author": "Vilx-",
"author_id": 41360,
"author_profile": "https://Stackoverflow.com/users/41360",
"pm_score": 0,
"selected": false,
"text": "<p>If the number of rectangles was unlimited, you would need to find the LCD (Least Common Denominator) of Sw and Sh. Then y... | 2008/12/04 | [
"https://Stackoverflow.com/questions/339939",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13477/"
] | My Situation
------------
* I have a N rectangles
* The rectangles all have the same shape (for example 2 inches wide x 1 inch tall) - Let's refer to this size as Sw and Sh for the width and height
* I want to position these rectangles in a grid such that the rects completely on top and next to each other - like what ... | Building on Will Dean's response, find the derivative of his formula (with respect to nCols):
-N\*Sh / nCols + Sw
Then set it to 0 and solve for nCols, which gives:
nCols = sqrt(N \* Sh / Sw)
Round that and you should have the optimum number of columns:
cols = round(sqrt(N \* Sh / Sw))
rows = ceil(N / cols) |
339,961 | <p>I need the perfect algorithm or C# function to calculate the difference (distance) between 2 decimal numbers.</p>
<p>For example the difference between:<br />
<strong>100</strong> and <strong>25</strong> is <strong>75</strong><br />
<strong>100</strong> and <strong>-25</strong> is <strong>125</strong><br />
<strong... | [
{
"answer_id": 339979,
"author": "terjetyl",
"author_id": 29519,
"author_profile": "https://Stackoverflow.com/users/29519",
"pm_score": 8,
"selected": true,
"text": "<p>You can do it like this</p>\n\n<pre><code>public decimal FindDifference(decimal nr1, decimal nr2)\n{\n return Math.Abs... | 2008/12/04 | [
"https://Stackoverflow.com/questions/339961",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18631/"
] | I need the perfect algorithm or C# function to calculate the difference (distance) between 2 decimal numbers.
For example the difference between:
**100** and **25** is **75**
**100** and **-25** is **125**
**-100** and **-115** is **15**
**-500** and **100** is **600**
Is there a C# function or a very ele... | You can do it like this
```
public decimal FindDifference(decimal nr1, decimal nr2)
{
return Math.Abs(nr1 - nr2);
}
``` |
339,962 | <p>What I am trying to do when the user is in a textbox (in silverlight 2.0):</p>
<ul>
<li>When user presses the decimal point
(.) <strong>on the numeric pad</strong>, I want to
have it replaced by the correct
decimal separator (which is comma
(,) in a lot of countries)</li>
</ul>
<p>I can track that the user typed a... | [
{
"answer_id": 340012,
"author": "NikolaiDante",
"author_id": 39643,
"author_profile": "https://Stackoverflow.com/users/39643",
"pm_score": 0,
"selected": false,
"text": "<p>You could do your changes in _LostFocus wether it's changing the dot to a comma, or applying the correct culture t... | 2008/12/04 | [
"https://Stackoverflow.com/questions/339962",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17709/"
] | What I am trying to do when the user is in a textbox (in silverlight 2.0):
* When user presses the decimal point
(.) **on the numeric pad**, I want to
have it replaced by the correct
decimal separator (which is comma
(,) in a lot of countries)
I can track that the user typed a decimal point by checking in the keydown... | Using Alterlife's answer as a hint for replacing contents, I have the following working hack... But I don't like it :-(.
* It means that the Text property is
set twice, once to the wrong value
and then replaced by the right value
* It only works for text boxes
* It feels like a hack that someday
might just stop workin... |
339,963 | <p>I'm trying to use System.Transaction.TransactionScope to create a transaction to call a few stored procedures but it doesn't seem to clean up after itself. Once the transaction is finished (commited or not and the transaction scope object is disposed) subsequent connections to the database open up with the read comm... | [
{
"answer_id": 340045,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 0,
"selected": false,
"text": "<p>You should also see a reset (<code>sp_reset_connection</code>) between uses of the same connection in the pool; wi... | 2008/12/04 | [
"https://Stackoverflow.com/questions/339963",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6084/"
] | I'm trying to use System.Transaction.TransactionScope to create a transaction to call a few stored procedures but it doesn't seem to clean up after itself. Once the transaction is finished (commited or not and the transaction scope object is disposed) subsequent connections to the database open up with the read commit ... | Use [TransactionOptions.IsolationLevel](http://msdn.microsoft.com/en-us/library/system.transactions.transactionoptions.isolationlevel.aspx)
By [default, it's serializable](http://msdn.microsoft.com/en-us/library/system.transactions.isolationlevel.aspx)
```
TransactionOptions transactionoptions1 = new TransactionOptio... |
340,020 | <p>I'm using this query to get all employees of {clients with name starting with lowercase "a"}:</p>
<pre><code>SELECT * FROM employees
WHERE client_id IN (SELECT id FROM clients WHERE name LIKE 'a%')
</code></pre>
<p>Column <code>employees.client_id</code> is an int, with <code>INDEX client_id (index_id)</code>. ... | [
{
"answer_id": 340029,
"author": "cagcowboy",
"author_id": 19629,
"author_profile": "https://Stackoverflow.com/users/19629",
"pm_score": 5,
"selected": true,
"text": "<pre><code>SELECT employees.*\nFROM employees, clients\nWHERE employees.client_id = clients.id\nAND clients.name LI... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340020",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19746/"
] | I'm using this query to get all employees of {clients with name starting with lowercase "a"}:
```
SELECT * FROM employees
WHERE client_id IN (SELECT id FROM clients WHERE name LIKE 'a%')
```
Column `employees.client_id` is an int, with `INDEX client_id (index_id)`. The subquery should IMHO return a list of id-s, ... | ```
SELECT employees.*
FROM employees, clients
WHERE employees.client_id = clients.id
AND clients.name LIKE 'a%';
```
Should be more quicker, since the optimiser can choose the most efficient plan. In writing it your way with a sub-query, you're forcing it to do the steps in a certain order rather than letting ... |
340,043 | <p>I have a problem and i would like to learn the correct way to solve this. </p>
<p>I have a Data Objeckt</p>
<pre><code>class LinkHolder {
public string Text;
public string Link;
}
</code></pre>
<p>I would like to present to the user a RadioButton list that uses the LinkHolder.Text value as descriptive tex... | [
{
"answer_id": 340087,
"author": "terjetyl",
"author_id": 29519,
"author_profile": "https://Stackoverflow.com/users/29519",
"pm_score": 0,
"selected": false,
"text": "<p>Your method should work. I think you should use accessors in your class though</p>\n\n<pre><code>class LinkHolder {\n ... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340043",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40274/"
] | I have a problem and i would like to learn the correct way to solve this.
I have a Data Objeckt
```
class LinkHolder {
public string Text;
public string Link;
}
```
I would like to present to the user a RadioButton list that uses the LinkHolder.Text value as descriptive text.
Then on the postback, i would ... | You need to set DataTextField and DataValueField on your RadioButtonList.
Then the correct values should show up.
You can try to cast the selectedItem into a LinkHolder. |
340,046 | <p>We have enableviewstate property for all the server controls in ASP.net.
We know that its going to have the member datas and values in viewstate across postbacks</p>
<p>What is the actual example for this?</p>
| [
{
"answer_id": 340059,
"author": "Paul Nearney",
"author_id": 24071,
"author_profile": "https://Stackoverflow.com/users/24071",
"pm_score": 0,
"selected": false,
"text": "<p>I don't entirely understand the question, but <a href=\"http://msdn.microsoft.com/en-us/library/ms972976.aspx\" re... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340046",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22162/"
] | We have enableviewstate property for all the server controls in ASP.net.
We know that its going to have the member datas and values in viewstate across postbacks
What is the actual example for this? | Viewstate's purpose in ASP.NET is indeed to persist state across postbacks, where state is the property values of the controls that make up a Web Form's control hierarchy. But it's necessary to distinguish between the different types of state.
Anything that you assign declaratively to a control at design-time **doesn... |
340,049 | <p>When I call GetForegroundWindow from c# I am getting the explorer parent process ID (I see this from process explorer) and not the process ID of the app that is in the foreground.</p>
<p>Why is this and how do get the right process ID?</p>
<p>Malcolm</p>
| [
{
"answer_id": 340078,
"author": "Will Dean",
"author_id": 987,
"author_profile": "https://Stackoverflow.com/users/987",
"pm_score": 0,
"selected": false,
"text": "<p>Not sure what's happening here, but have you tried running your app as Administrator? There are now lots of restrictions... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340049",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40568/"
] | When I call GetForegroundWindow from c# I am getting the explorer parent process ID (I see this from process explorer) and not the process ID of the app that is in the foreground.
Why is this and how do get the right process ID?
Malcolm | The API function GetForegroundWindow gets you a handle to the top window, not the process ID.
So what other functions do you use to get the process ID from the window handle you get from GetForegroundWindow?
This will get you the WINDOW HANDLE of the foreground window:
```
[DllImport("user32", SetLastError = tru... |
340,090 | <p>I have a C# method that projects the value of a number from an interval to a target interval.<br>
<strong>For example:</strong> we have an interval of -1000 and 9000 and a value of 5000; if we want to project this value to an interval of 0..100 we get 60.</p>
<p>Here is the method: </p>
<pre><code>/// <summary&... | [
{
"answer_id": 340097,
"author": "leppie",
"author_id": 15541,
"author_profile": "https://Stackoverflow.com/users/15541",
"pm_score": 2,
"selected": false,
"text": "<p>The answers is: Do NOT use decimal for fast operations. </p>\n\n<p>Is there any reason why float or double does not work... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340090",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18631/"
] | I have a C# method that projects the value of a number from an interval to a target interval.
**For example:** we have an interval of -1000 and 9000 and a value of 5000; if we want to project this value to an interval of 0..100 we get 60.
Here is the method:
```
/// <summary>
/// Projects a value to an interval... | Just maths. What you're "projecting" is a normalisation of ranges A-B and A'-B' such that:
ratio r = (x-A) / (B-A) = (y-A') / (B'-A')
which using your terms is:
(val-min) / (max-min) = (returnValue-intervalBottom) / (intervalTop-intervalBottom)
which solves for returnValue as:
```
returnValue = ((intervalTop-inte... |
340,093 | <p>I'm trying to make a proxy object in IronPython, which should dynamically present underlying structure. The proxy itself shouldn't have any functions and properties, I'm trying to catch all the calls in the runtime. Catching the function calls is easy, I just need to define <strong>getattr</strong>() function for my... | [
{
"answer_id": 340097,
"author": "leppie",
"author_id": 15541,
"author_profile": "https://Stackoverflow.com/users/15541",
"pm_score": 2,
"selected": false,
"text": "<p>The answers is: Do NOT use decimal for fast operations. </p>\n\n<p>Is there any reason why float or double does not work... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340093",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43152/"
] | I'm trying to make a proxy object in IronPython, which should dynamically present underlying structure. The proxy itself shouldn't have any functions and properties, I'm trying to catch all the calls in the runtime. Catching the function calls is easy, I just need to define **getattr**() function for my object, and che... | Just maths. What you're "projecting" is a normalisation of ranges A-B and A'-B' such that:
ratio r = (x-A) / (B-A) = (y-A') / (B'-A')
which using your terms is:
(val-min) / (max-min) = (returnValue-intervalBottom) / (intervalTop-intervalBottom)
which solves for returnValue as:
```
returnValue = ((intervalTop-inte... |
340,104 | <p>So I've got some scripts I've written which set up a Google map on my page. These scripts are in included in the <code><head></code> of my page, and use jQuery to build the map with markers generated from a list of addresses on the page.</p>
<p>However, I have some exact co-ordinate data for each address whic... | [
{
"answer_id": 340116,
"author": "Aleris",
"author_id": 20417,
"author_profile": "https://Stackoverflow.com/users/20417",
"pm_score": 0,
"selected": false,
"text": "<p>If the information should not be visible to the user, it should not stay in the document. The data can stay in a script ... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340104",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31582/"
] | So I've got some scripts I've written which set up a Google map on my page. These scripts are in included in the `<head>` of my page, and use jQuery to build the map with markers generated from a list of addresses on the page.
However, I have some exact co-ordinate data for each address which the javascript requires t... | I would not reccomend using style to hide something, it will show up in browsers without (or with disabled) css suppor and look strange.
You could store it in a javascript variable or add a form with hidden values like this
(inside an unused form to be sure it validates):
```
<form action="#" method="get" id="myHidde... |
340,111 | <pre><code><document.write("<SCR"+"IPT TYPE='text/javascript' SRC='"+"http"+(window.location.protocol.indexOf('https:')==0?'s':'')+"://"+gDomain+"/"+gDcsId+"/wtid.js"+"'><\/SCR"+"IPT>");
</code></pre>
<p>I need to escape the string above in order to add the whole thing to a StringBuilder but so far I mu... | [
{
"answer_id": 340130,
"author": "Ian G",
"author_id": 31765,
"author_profile": "https://Stackoverflow.com/users/31765",
"pm_score": 0,
"selected": false,
"text": "<p>I think you are mixing up what is <code>JavaScript</code> and what is <code>C#</code>. Can you please tell us the string ... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340111",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42108/"
] | ```
<document.write("<SCR"+"IPT TYPE='text/javascript' SRC='"+"http"+(window.location.protocol.indexOf('https:')==0?'s':'')+"://"+gDomain+"/"+gDcsId+"/wtid.js"+"'><\/SCR"+"IPT>");
```
I need to escape the string above in order to add the whole thing to a StringBuilder but so far I must be missing something because st... | ```
string x = @"<document.write(""<SCR""+""IPT TYPE=""'text/javascript' SRC='""+""http""+(window.location.protocol.indexOf('https:')==0?'s':'')+""://""+gDomain+""/""+gDcsId+""/wtid.js""+""'><\/SCR""+""IPT>"");";
```
The @ prefix makes escaping simpler. You just have to turn each " into "".
You will find your progra... |
340,115 | <p>I have a question related to how relative paths are interpreted in various environments .
If I have a C code to be compiled on linux using Makefile and gcc , and if some source file has :</p>
<pre><code>fopen(“../../xyz.ctl”, ”r”);
</code></pre>
<p>where should this file be located. Or in other words,
if I have <... | [
{
"answer_id": 340171,
"author": "Aaron Digulla",
"author_id": 34088,
"author_profile": "https://Stackoverflow.com/users/34088",
"pm_score": 1,
"selected": false,
"text": "<p>The path in code compiled by any Unix tool is relative to the path in which the final executable is executed.</p>... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340115",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2759376/"
] | I have a question related to how relative paths are interpreted in various environments .
If I have a C code to be compiled on linux using Makefile and gcc , and if some source file has :
```
fopen(“../../xyz.ctl”, ”r”);
```
where should this file be located. Or in other words,
if I have
```
fopen(“xyz.ctl” , ”r”... | Your Makefile invokes gcc which compiles your code containing fopen().
fopen() is called when you execute the newly compiled code. The path is relative to your current working directory when you launched the program. |
340,138 | <p>I have the odd problem that I am not able to open the properties of my .NET projects in Visual Studio. If I try to open it by clicking on the Properties tree node in the Solution Explorer I get the following message:</p>
<blockquote>
<p>There is no editor available for '....csproj'. Make sure the application for ... | [
{
"answer_id": 340321,
"author": "Cameron MacFarland",
"author_id": 3820,
"author_profile": "https://Stackoverflow.com/users/3820",
"pm_score": 1,
"selected": false,
"text": "<p>Do you have SQL Server installed? If so are you accidentally opening the project with the VS2005 shell that's ... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340138",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9470/"
] | I have the odd problem that I am not able to open the properties of my .NET projects in Visual Studio. If I try to open it by clicking on the Properties tree node in the Solution Explorer I get the following message:
>
> There is no editor available for '....csproj'. Make sure the application for the file type (.cspr... | Repair installation doesn't worked as I mentioned in my question. The problem was solved by using the command line with
```
devenv /ResetSkipPkgs
```
BUT after that I had to reset some of my Resharper settings. |
340,139 | <p>I have a set of conditions in my where clause like</p>
<pre><code>WHERE
d.attribute3 = 'abcd*'
AND x.STATUS != 'P'
AND x.STATUS != 'J'
AND x.STATUS != 'X'
AND x.STATUS != 'S'
AND x.STATUS != 'D'
AND CURRENT_TIMESTAMP - 1 < x.CREATION_TIMESTAMP
</code></pre>
<p>Which of these conditions will be executed ... | [
{
"answer_id": 340148,
"author": "Greg",
"author_id": 24181,
"author_profile": "https://Stackoverflow.com/users/24181",
"pm_score": 3,
"selected": false,
"text": "<p>The database will decide what order to execute the conditions in.</p>\n\n<p>Normally (but not always) it will use an index... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340139",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16488/"
] | I have a set of conditions in my where clause like
```
WHERE
d.attribute3 = 'abcd*'
AND x.STATUS != 'P'
AND x.STATUS != 'J'
AND x.STATUS != 'X'
AND x.STATUS != 'S'
AND x.STATUS != 'D'
AND CURRENT_TIMESTAMP - 1 < x.CREATION_TIMESTAMP
```
Which of these conditions will be executed first? I am using oracle.
Wi... | Are you **sure** you "don't have the authority" to see an execution plan? What about using AUTOTRACE?
```
SQL> set autotrace on
SQL> select * from emp
2 join dept on dept.deptno = emp.deptno
3 where emp.ename like 'K%'
4 and dept.loc like 'l%'
5 /
no rows selected
Execution Plan
-------------------------... |
340,145 | <p>How can I add the reboot action to a vdproj?</p>
<p>I need an <a href="http://en.wikipedia.org/wiki/Windows_Installer" rel="nofollow noreferrer">MSI</a> file which restart the PC at the end of the installation.</p>
| [
{
"answer_id": 340181,
"author": "leppie",
"author_id": 15541,
"author_profile": "https://Stackoverflow.com/users/15541",
"pm_score": 0,
"selected": false,
"text": "<p>If you need to reboot, Windows Installer should detect it automatically. If you want to reboot as you are too lazy to st... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340145",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15485/"
] | How can I add the reboot action to a vdproj?
I need an [MSI](http://en.wikipedia.org/wiki/Windows_Installer) file which restart the PC at the end of the installation. | Just add the "REBOOT" property with the value "Force" which will prompt the user to reboot once setup is complete, or automatically reboot if there is no user interface.
If you cannot do this in the vdjproj then just use Orca to edit the Property table of the MSI once the setup is built.
If you want to force a reboot... |
340,192 | <p>I have a problem with a oneway web method that open a moss site (probably because in a oneway webmethod the context is null)</p>
<p>Is possible to rewrite this code to remove the null reference exception? (without the oneway attribute i don't have the exception)</p>
<pre><code>[SoapDocumentMethod(OneWay = true)]
... | [
{
"answer_id": 355627,
"author": "tartafe",
"author_id": 43162,
"author_profile": "https://Stackoverflow.com/users/43162",
"pm_score": 2,
"selected": true,
"text": "<p>i have found a workaround to solve my problem.Create new HttpContext. The question now is:\nis it the right solution or ... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340192",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43162/"
] | I have a problem with a oneway web method that open a moss site (probably because in a oneway webmethod the context is null)
Is possible to rewrite this code to remove the null reference exception? (without the oneway attribute i don't have the exception)
```
[SoapDocumentMethod(OneWay = true)]
[WebMethod(Des... | i have found a workaround to solve my problem.Create new HttpContext. The question now is:
is it the right solution or there are implications that i don't consider?
the method that i use to change the context is this:
```
//Call this before call new SPSite()
private static void ChangeContext(string webUrl)
{... |
340,194 | <p>how to validate letters and whitespaces using Zend Framework ?</p>
| [
{
"answer_id": 340300,
"author": "Irmantas",
"author_id": 43182,
"author_profile": "https://Stackoverflow.com/users/43182",
"pm_score": 0,
"selected": false,
"text": "<p>i think Zend_Validate_Regex is best for this situation</p>\n"
},
{
"answer_id": 341114,
"author": "dcousin... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340194",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | how to validate letters and whitespaces using Zend Framework ? | The Zend Framework does have a [Zend\_Validate\_Alpha](http://framework.zend.com/manual/en/zend.validate.set.html#zend.validate.set.alpha) (as well as an [alphanumeric version](http://framework.zend.com/manual/en/zend.validate.set.html#zend.validate.set.alnum)).
Normally it doesn't allow white space, but if you pass a... |
340,204 | <p>Can a macro be written in Scheme (with <code>define-syntax</code>, for example) which will take expressions like this:</p>
<pre><code>(op a b c d e f g h i j)
</code></pre>
<p>And yield expressions like this as output?</p>
<pre><code>(op (op (op (op (op (op (op (op (op a b) c) d) e) f) g) h) i) j)
</code></pre>
... | [
{
"answer_id": 340294,
"author": "namin",
"author_id": 34596,
"author_profile": "https://Stackoverflow.com/users/34596",
"pm_score": 4,
"selected": true,
"text": "<pre><code>(define bop list)\n\n(define-syntax op\n (syntax-rules ()\n ((op a b) (bop a b))\n ((op a b c ...) (op (bop... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340204",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15055/"
] | Can a macro be written in Scheme (with `define-syntax`, for example) which will take expressions like this:
```
(op a b c d e f g h i j)
```
And yield expressions like this as output?
```
(op (op (op (op (op (op (op (op (op a b) c) d) e) f) g) h) i) j)
```
Of course, for arbitrary lengths. I can't think of a way... | ```
(define bop list)
(define-syntax op
(syntax-rules ()
((op a b) (bop a b))
((op a b c ...) (op (bop a b) c ...))))
```
For example, `(op 1 2 3 4)` expands to `(bop (bop (bop 1 2) 3) 4)` and evaluates to `(((1 2) 3) 4)`. |
340,209 | <p>I'm writing a Java game and I want to implement a power meter for how hard you are going to shoot something. </p>
<p>I need to write a function that takes a int between 0 - 100, and based on how high that number is, it will return a color between Green (0 on the power scale) and Red (100 on the power scale).</p>
... | [
{
"answer_id": 340214,
"author": "Paul Dixon",
"author_id": 6521,
"author_profile": "https://Stackoverflow.com/users/6521",
"pm_score": 9,
"selected": true,
"text": "<p>This should work - just linearly scale the red and green values. Assuming your max red/green/blue value is <code>255</c... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340209",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2635/"
] | I'm writing a Java game and I want to implement a power meter for how hard you are going to shoot something.
I need to write a function that takes a int between 0 - 100, and based on how high that number is, it will return a color between Green (0 on the power scale) and Red (100 on the power scale).
Similar to how ... | This should work - just linearly scale the red and green values. Assuming your max red/green/blue value is `255`, and `n` is in range `0 .. 100`
```
R = (255 * n) / 100
G = (255 * (100 - n)) / 100
B = 0
```
*(Amended for integer maths, tip of the hat to Ferrucio)*
Another way to do would be to use a [HSV colour mo... |
340,217 | <p>I have two tables with the following columns:</p>
<p>table1:</p>
<pre><code>id, agent_name, ticket_id, category, date_logged
</code></pre>
<p>table2:</p>
<pre><code>id, agent_name, department, admin_status
</code></pre>
<p>What I'm trying to achieve is to Select all rows from table1 where an agents department i... | [
{
"answer_id": 340231,
"author": "Arvo",
"author_id": 35777,
"author_profile": "https://Stackoverflow.com/users/35777",
"pm_score": 0,
"selected": false,
"text": "<p>Although I cannot exactly understand, what you need and how are tables related, I'd try someting similar:</p>\n\n<pre><cod... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340217",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42428/"
] | I have two tables with the following columns:
table1:
```
id, agent_name, ticket_id, category, date_logged
```
table2:
```
id, agent_name, department, admin_status
```
What I'm trying to achieve is to Select all rows from table1 where an agents department is equal to that of table2.
I've tried a few different j... | I don't quite understand your question...
Only table2 have a department, the only thing they have in common is agent\_name.
I do suspect what you really mean is: that you want all rows from Table1 where the agent is from a certain department, is that what you want? In that case, something like this should do it (haven... |
340,223 | <p>I have checked the whole site and googled on the net but was unable to find a simple solution to this problem.</p>
<p>I have a datatable which has about 20 columns and 10K rows. I need to remove the duplicate rows in this datatable based on 4 key columns. Doesn't .Net have a function which does this? The function c... | [
{
"answer_id": 340235,
"author": "Samiksha",
"author_id": 29515,
"author_profile": "https://Stackoverflow.com/users/29515",
"pm_score": 0,
"selected": false,
"text": "<p>Use a query instead of functions:</p>\n\n<pre><code>DELETE FROM table1 AS tb1 INNER JOIN \n(SELECT id, COUNT(id) AS cn... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340223",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24105/"
] | I have checked the whole site and googled on the net but was unable to find a simple solution to this problem.
I have a datatable which has about 20 columns and 10K rows. I need to remove the duplicate rows in this datatable based on 4 key columns. Doesn't .Net have a function which does this? The function closest to ... | You can use Linq to Datasets. Check [this](http://msdn.microsoft.com/en-us/library/bb669119.aspx). Something like this:
```
// Fill the DataSet.
DataSet ds = new DataSet();
ds.Locale = CultureInfo.InvariantCulture;
FillDataSet(ds);
List<DataRow> rows = new List<DataRow>();
DataTable contact = ds.Tables["Contact"];
... |
340,232 | <p>With my jquery I'm trying to make the transition from a message to a loading function easy on the eyes by animate the opasity of the message out, inserting the loading.gif and animating the opacity back in. It fails.</p>
<pre><code>$('#powerSearchSubmitButton').click(function(ev) {
startLoad();
return false... | [
{
"answer_id": 340310,
"author": "millenomi",
"author_id": 6061,
"author_profile": "https://Stackoverflow.com/users/6061",
"pm_score": 0,
"selected": false,
"text": "<p>Apply the animation to a container instead, or use the .css() method to set the opacity (inline styles might interfere ... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340232",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11333/"
] | With my jquery I'm trying to make the transition from a message to a loading function easy on the eyes by animate the opasity of the message out, inserting the loading.gif and animating the opacity back in. It fails.
```
$('#powerSearchSubmitButton').click(function(ev) {
startLoad();
return false;
});
function... | Try this:
```
$(this).fadeOut(500, function() {
$(this).html("<img src='content/pics/loadingBig.gif' alt='loading'/>");
});
$(this).fadeIn(500);
``` |
340,237 | <p>I've cached a value using the ASP.NET Cache, with the following code:</p>
<pre><code>Cache.Insert("TEST_VALUE", 150, null, Cache.NoAbsoluteExpiration, TimeSpan.FromSeconds(120));
</code></pre>
<p>As I understand it, this should mean that if nothing accesses that object for 120 seconds, it will expire and return nu... | [
{
"answer_id": 337910,
"author": "Joseph Ferris",
"author_id": 15906,
"author_profile": "https://Stackoverflow.com/users/15906",
"pm_score": 1,
"selected": false,
"text": "<p>That is a correct assumption on your part. Where are you doing the caching?</p>\n\n<p>The reason that I ask is t... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340237",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43140/"
] | I've cached a value using the ASP.NET Cache, with the following code:
```
Cache.Insert("TEST_VALUE", 150, null, Cache.NoAbsoluteExpiration, TimeSpan.FromSeconds(120));
```
As I understand it, this should mean that if nothing accesses that object for 120 seconds, it will expire and return null.
However, if after 10 ... | OK, I think I've figured it out, but I'm not sure exactly why this is:
I did as you both suggested - there was definitely nothing reading from the cache, so I wrote a callback which wrote the removal time to a log file and subscribed it to the expiry event. I also wrote the time each item was added to the cache into t... |
340,270 | <p>I'm doing some really simple math and saving the result to a MS SQL2008 DB.</p>
<p>I'm <em>averaging</em> out the some numbers, which are byte values between 1<->5. I wish to record probably 2 decimal places only. I don't care about rounding for the 2nd decimal place (eg. a 1.155 == 1.5 or 1.6 .. i'm not too pha... | [
{
"answer_id": 340276,
"author": "Dmitry Khalatov",
"author_id": 18174,
"author_profile": "https://Stackoverflow.com/users/18174",
"pm_score": 0,
"selected": false,
"text": "<p>Decimal - it is the simplest, however any of mentined will do the job</p>\n"
},
{
"answer_id": 340296,
... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340270",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30674/"
] | I'm doing some really simple math and saving the result to a MS SQL2008 DB.
I'm *averaging* out the some numbers, which are byte values between 1<->5. I wish to record probably 2 decimal places only. I don't care about rounding for the 2nd decimal place (eg. a 1.155 == 1.5 or 1.6 .. i'm not too phased).
So .. should ... | What you need is the DECIMAL datatype:
```
declare @val decimal(10,2)
select @val = 10.155
select @val
```
When you input values, you can either rely on the built in rounding, or explicitly decide which rounding you want:
```
select val = round(10.155, 2, 0) -- rounded
select val = round(10.155, 2, 1) -- truncated
... |
340,271 | <p>The bugzilla (perl-based) system has a feature to login automatically by using a http server environment variable. If you fill in the right ID or username, you are automatically logged in.</p>
<p>My server runs Joomla (PHP-based) and has all the information about who is logged in. It runs bugzilla within a sub-fram... | [
{
"answer_id": 340276,
"author": "Dmitry Khalatov",
"author_id": 18174,
"author_profile": "https://Stackoverflow.com/users/18174",
"pm_score": 0,
"selected": false,
"text": "<p>Decimal - it is the simplest, however any of mentined will do the job</p>\n"
},
{
"answer_id": 340296,
... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340271",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26387/"
] | The bugzilla (perl-based) system has a feature to login automatically by using a http server environment variable. If you fill in the right ID or username, you are automatically logged in.
My server runs Joomla (PHP-based) and has all the information about who is logged in. It runs bugzilla within a sub-frame.
So, ho... | What you need is the DECIMAL datatype:
```
declare @val decimal(10,2)
select @val = 10.155
select @val
```
When you input values, you can either rely on the built in rounding, or explicitly decide which rounding you want:
```
select val = round(10.155, 2, 0) -- rounded
select val = round(10.155, 2, 1) -- truncated
... |
340,274 | <p>I'm creating a zip file using the class FastZip from SharpZipLib and once I after I close the program, I cannot delete the file because:</p>
<p>"Cannot delete zip.zip: It is being used by another person or program. Close any programs that might be using the file and try again."</p>
<p>The code that is generating t... | [
{
"answer_id": 340287,
"author": "Lasse V. Karlsen",
"author_id": 267,
"author_profile": "https://Stackoverflow.com/users/267",
"pm_score": 2,
"selected": true,
"text": "<p>Perhaps antivirus is busy checking the file? If not, then get a program that can tell you which programs have files... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340274",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36532/"
] | I'm creating a zip file using the class FastZip from SharpZipLib and once I after I close the program, I cannot delete the file because:
"Cannot delete zip.zip: It is being used by another person or program. Close any programs that might be using the file and try again."
The code that is generating the file is simply... | Perhaps antivirus is busy checking the file? If not, then get a program that can tell you which programs have files open.
You can look at:
* [Unlocker](http://www.emptyloop.com/unlocker/)
* [IARSN TaskInfo](http://www.iarsn.com/) |
340,275 | <p>In my child window I have </p>
<pre><code>$('#opfile').addOption("someval",sometext");
</code></pre>
<p>Problem is #opfile is an a parent window I cant get it to communicate</p>
<p>I tried</p>
<p>window.opener.$('#opfile').addOption("someval",sometext");</p>
<p>but no luck any ideas?</p>
<p>Update</p>
<p>Emba... | [
{
"answer_id": 340320,
"author": "rajesh pillai",
"author_id": 34644,
"author_profile": "https://Stackoverflow.com/users/34644",
"pm_score": 3,
"selected": true,
"text": "<p>This may be helpful.</p>\n\n<p><a href=\"http://www.sfpeter.com/2008/03/13/communication-between-browser-windows-w... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340275",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11394/"
] | In my child window I have
```
$('#opfile').addOption("someval",sometext");
```
Problem is #opfile is an a parent window I cant get it to communicate
I tried
window.opener.$('#opfile').addOption("someval",sometext");
but no luck any ideas?
Update
Embarssing but I got the above to work might have been caching so... | This may be helpful.
[Communication between browser windows](http://www.sfpeter.com/2008/03/13/communication-between-browser-windows-with-jquery-my-new-plugin/)
Though this is not directly related to the select box example, but the concepts may be applied here.
I'll watch this space, if anyone has a better solution. |
340,282 | <p>Can someone explain to me why this code prints 14? I was just asked by another student and couldn't figure it out.</p>
<pre><code>int i = 5;
i = ++i + ++i;
cout<<i;
</code></pre>
| [
{
"answer_id": 340299,
"author": "Gonzalo Quero",
"author_id": 40996,
"author_profile": "https://Stackoverflow.com/users/40996",
"pm_score": -1,
"selected": false,
"text": "<p>Because the prefix increment has precedence:</p>\n\n<pre><code>int i = 5;\ni = i+1; // First ++i, i is now 6\ni ... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340282",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2450/"
] | Can someone explain to me why this code prints 14? I was just asked by another student and couldn't figure it out.
```
int i = 5;
i = ++i + ++i;
cout<<i;
``` | The order of side effects is undefined in C++. Additionally, modifying a variable twice in a single expression has no defined behavior (See the [C++ standard](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1905.pdf), §5.0.4, physical page 87 / logical page 73).
Solution: Don't use side effects in complex exp... |
340,283 | <p>Please consider the following <code>fork()</code>/<code>SIGCHLD</code> pseudo-code.</p>
<pre><code> // main program excerpt
for (;;) {
if ( is_time_to_make_babies ) {
pid = fork();
if (pid == -1) {
/* fail */
} else if (pid == 0) {
/* child stuff */
... | [
{
"answer_id": 340312,
"author": "Darron",
"author_id": 22704,
"author_profile": "https://Stackoverflow.com/users/22704",
"pm_score": -1,
"selected": false,
"text": "<p>In addition to the existing \"children\" add a new data structure \"early deaths\". This will keep the contents of chi... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340283",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Please consider the following `fork()`/`SIGCHLD` pseudo-code.
```
// main program excerpt
for (;;) {
if ( is_time_to_make_babies ) {
pid = fork();
if (pid == -1) {
/* fail */
} else if (pid == 0) {
/* child stuff */
print "child started"
exit... | Simplest solution would be to block SIGCHLD signal before `fork()` with `sigprocmask()` and unblock it in parent code after you have processed the pid.
If child died, signal handler for SIGCHLD will be called after you unblock the signal. It is a critical section concept - in your case critical section starts before `... |
340,286 | <p>I keep getting this NPE in my application and I can't seem to get rid of it because it is not showing up in any of my source code. As you can see from the stacktrace it is not happening in my code but in the Swing plaf. Has any of you had this problem and maybe figured out what is happening here?</p>
<pre><code> ... | [
{
"answer_id": 340340,
"author": "bruno conde",
"author_id": 31136,
"author_profile": "https://Stackoverflow.com/users/31136",
"pm_score": 2,
"selected": false,
"text": "<p>I never had this particular problem but when I get these kind of \"hidden\" errors I always end up looking the orig... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340286",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3379/"
] | I keep getting this NPE in my application and I can't seem to get rid of it because it is not showing up in any of my source code. As you can see from the stacktrace it is not happening in my code but in the Swing plaf. Has any of you had this problem and maybe figured out what is happening here?
```
11:28:23,273 [... | I managed to get around the problem!
The thing is that I add a `ListSelectionListener` to my `JTable`; in the `valueChanged` method of my listener I then call `scrollRectToVisible` and then `updateUI`, which then results in my exception.
What I did was to add `invokeLater` around the `updateUI` call and **no more exc... |
340,341 | <p>When I call the connect function of the Paramiko <code>SSHClient</code> class, it outputs some log data about establishing the connection, which I would like to suppress.</p>
<p>Is there a way to do this either through Paramiko itself, or Python in general?</p>
| [
{
"answer_id": 340815,
"author": "M. Utku ALTINKAYA",
"author_id": 40948,
"author_profile": "https://Stackoverflow.com/users/40948",
"pm_score": 0,
"selected": false,
"text": "<p>I don't know what Paramiko is, and there must be a log level setting for sure, but if you are desperate and l... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340341",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42820/"
] | When I call the connect function of the Paramiko `SSHClient` class, it outputs some log data about establishing the connection, which I would like to suppress.
Is there a way to do this either through Paramiko itself, or Python in general? | Paramiko doesn't output anything by default. You probably have a call to the logging module, setting a loglevel that's inherited when paramiko sets up it's own logging.
If you want to get at the paramiko logger to override the settings:
```
logger = paramiko.util.logging.getLogger()
```
There's also a convenience f... |
340,354 | <p>I had two domains for ex. domain1 and domain2, I am opening domain2/index.aspx page as popup from domain1/default.aspx page. While closing domain2 page i need to reload the domain1 page, i had given the javascript code as "Opener.Location.Reload();". I am getting <strong>Permission denied</strong> javascript error. ... | [
{
"answer_id": 340417,
"author": "Timothy Khouri",
"author_id": 11917,
"author_profile": "https://Stackoverflow.com/users/11917",
"pm_score": 2,
"selected": false,
"text": "<p>Certain properties and actions are specifically blocked in cross-domain scenarios. What you <em>might</em> be ab... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340354",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I had two domains for ex. domain1 and domain2, I am opening domain2/index.aspx page as popup from domain1/default.aspx page. While closing domain2 page i need to reload the domain1 page, i had given the javascript code as "Opener.Location.Reload();". I am getting **Permission denied** javascript error. Any ideas about ... | I found that setting a parentUrl variable in the popup window (gotten from a query string)
and then using :
```
window.opener.location.href = parentUrl;
```
works.
I don't know why, I think it's magic, but it works (tested on IE, chrome and Firefox).
You cannot read the value of window.opener.location.href, but you... |
340,356 | <p>When I call CreateProcess in Windows, the new process doesn't seem to inherit the console of the calling process. I made a test program that runs "ruby xtest", xtest being a script that writes "hello" to standard output. I ran this test program from Emacs, and get no output. I also tried the following code callin... | [
{
"answer_id": 552413,
"author": "MSN",
"author_id": 6210,
"author_profile": "https://Stackoverflow.com/users/6210",
"pm_score": 1,
"selected": false,
"text": "<p>I've done this by passing in pipes for <code>hStdInput</code>, <code>hStdOutput</code>, and <code>hStdError</code> and manual... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340356",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | When I call CreateProcess in Windows, the new process doesn't seem to inherit the console of the calling process. I made a test program that runs "ruby xtest", xtest being a script that writes "hello" to standard output. I ran this test program from Emacs, and get no output. I also tried the following code calling GetS... | I know, this thread is rather old, however, I just ran into the same problem.
Just as for the TS, the console handle was inherited and working fine under Cygwin, but not on a Windows console. Instead, the output on stdout was neither shown, nor any error was reported. Inherited Pipe handles worked still fine.
I took ... |
340,359 | <p>like whether it is pentium or AMD etc. </p>
| [
{
"answer_id": 340434,
"author": "gimel",
"author_id": 6491,
"author_profile": "https://Stackoverflow.com/users/6491",
"pm_score": 2,
"selected": false,
"text": "<p>The <a href=\"http://msdn.microsoft.com/en-us/library/system.management.aspx\" rel=\"nofollow noreferrer\">System.Managemen... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340359",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38807/"
] | like whether it is pentium or AMD etc. | **Please note that this is from VS2003:**
```
using(ManagementObjectSearcher win32Proc = new ManagementObjectSearcher("select * from Win32_Processor"),
win32CompSys = new ManagementObjectSearcher("select * from Win32_ComputerSystem"),
win32Memory = new ManagementObjectSearcher("select * from Win32... |
340,366 | <p>I need to update a record in a database with the following fields </p>
<pre><code>[ID] int (AutoIncr. PK)
[ScorerID] int
[Score] int
[DateCreated] smalldatetime
</code></pre>
<p>If a record exists for todays date (only the date portion should be checked, not the time) and a given scorer, I'd like to update the sco... | [
{
"answer_id": 340384,
"author": "Timothy Khouri",
"author_id": 11917,
"author_profile": "https://Stackoverflow.com/users/11917",
"pm_score": 5,
"selected": true,
"text": "<pre><code>IF EXISTS (SELECT NULL FROM MyTable WHERE ScorerID = @Blah AND CONVERT(VARCHAR, DateCreated, 101) = CONVE... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340366",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16440/"
] | I need to update a record in a database with the following fields
```
[ID] int (AutoIncr. PK)
[ScorerID] int
[Score] int
[DateCreated] smalldatetime
```
If a record exists for todays date (only the date portion should be checked, not the time) and a given scorer, I'd like to update the score value for this guy and ... | ```
IF EXISTS (SELECT NULL FROM MyTable WHERE ScorerID = @Blah AND CONVERT(VARCHAR, DateCreated, 101) = CONVERT(VARCHAR, GETDATE(), 101))
UPDATE MyTable SET blah blah blah
ELSE
INSERT INTO MyTable blah blah blah
``` |
340,368 | <p>In Visual Studio 2005, is there an easy way to automatically increment the assembly/file build numbers after a successful build?</p>
<p>Emphasis on <strong><em>easy</em></strong>. I would like to track my build version, without having to set up CruiseControl or some similar tool.</p>
| [
{
"answer_id": 340397,
"author": "Louis Haußknecht",
"author_id": 42832,
"author_profile": "https://Stackoverflow.com/users/42832",
"pm_score": 0,
"selected": false,
"text": "<p>What about writing a little macro, which increments the version?</p>\n\n<p>Or what about this VS <a href=\"htt... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340368",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22114/"
] | In Visual Studio 2005, is there an easy way to automatically increment the assembly/file build numbers after a successful build?
Emphasis on ***easy***. I would like to track my build version, without having to set up CruiseControl or some similar tool. | You can use this project and include it your .proj file
This url might be of use [Updating Porj build number](https://web.archive.org/web/20100515233947/http://geekswithblogs.net:80/narent/archive/2006/02/15/69532.aspx)
This didn't fit my needs and I took to adding this as a build.proj which works a treat
```
<?xml ... |
340,376 | <p>I was wondering if it's possible to calculate the average of some numbers if I have this:</p>
<pre><code>int currentCount = 12;
float currentScore = 6.1123 (this is a range of 1 <-> 10).
</code></pre>
<p>Now, if I receive another score (let's say 4.5), can I recalculate the average so it would be something... | [
{
"answer_id": 340387,
"author": "John with waffle",
"author_id": 279,
"author_profile": "https://Stackoverflow.com/users/279",
"pm_score": 4,
"selected": false,
"text": "<p>I like to store the sum and the count. It avoids an extra multiply each time.</p>\n\n<pre><code>current_sum += in... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340376",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30674/"
] | I was wondering if it's possible to calculate the average of some numbers if I have this:
```
int currentCount = 12;
float currentScore = 6.1123 (this is a range of 1 <-> 10).
```
Now, if I receive another score (let's say 4.5), can I recalculate the average so it would be something like:
```
int currentCount now... | The following formulas allow you to track averages just from stored average and count, as you requested.
```
currentScore = (currentScore * currentCount + newValue) / (currentCount + 1)
currentCount = currentCount + 1
```
This relies on the fact that your average is currently your sum divided by the count. So you si... |
340,383 | <pre><code>function a () {
return "foo";
}
a.b = function () {
return "bar";
}
function c () { };
c.prototype = a;
var d = new c();
d.b(); // returns "bar"
d(); // throws exception, d is not a function
</code></pre>
<p>Is there some way for <code>d</code> to be a function, and yet still inherit properties f... | [
{
"answer_id": 340838,
"author": "Eugene Lazutkin",
"author_id": 26394,
"author_profile": "https://Stackoverflow.com/users/26394",
"pm_score": 3,
"selected": false,
"text": "<p>Short answer: not possible.</p>\n\n<p>This line of your code:</p>\n\n<pre><code>var d = new c();\n</code></pre>... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340383",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31662/"
] | ```
function a () {
return "foo";
}
a.b = function () {
return "bar";
}
function c () { };
c.prototype = a;
var d = new c();
d.b(); // returns "bar"
d(); // throws exception, d is not a function
```
Is there some way for `d` to be a function, and yet still inherit properties from `a`? | Based on a [discussion on meta](https://meta.stackoverflow.com/questions/356167/why-was-this-edit-rejected-with-a-seeming-unrelated-generic-response/356168?noredirect=1#comment511249_356168) [about a similar question](https://stackoverflow.com/questions/37625164/object-createfunction-prototype-create-function-which-inh... |
340,400 | <p>I have a plain text file looking like this:</p>
<pre><code>"some
text
containing
line
breaks"
</code></pre>
<p>I'm trying to talk <code>excel 2004 (Mac, v.11.5)</code> into opening this file correctly. I'd expect to see only one cell (A1) containing all of the above (without the quotes)...</p>
<p>But ... | [
{
"answer_id": 340449,
"author": "Alterlife",
"author_id": 36848,
"author_profile": "https://Stackoverflow.com/users/36848",
"pm_score": 0,
"selected": false,
"text": "<p>Is it just one file? If so, don\\'t import it. Just copy paste the content of your text file into the first cell (hit... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340400",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23350/"
] | I have a plain text file looking like this:
```
"some
text
containing
line
breaks"
```
I'm trying to talk `excel 2004 (Mac, v.11.5)` into opening this file correctly. I'd expect to see only one cell (A1) containing all of the above (without the quotes)...
But alas, I can't make it happen, because Excel ... | Looks like I just found the solution myself. I need to save the initial file as ".csv". Excel honors the line breaks properly with CSV files. Opening those via applescript works as well.
Thanks again to those who responded.
Max |
340,403 | <p>Consider the following table structure...</p>
<pre><code>Appointment
-----------
ID integer
Description nvarchar
StatusID smallint
Status
------
ID smallint
DisplayText nvarchar
</code></pre>
<p>Now, for good or for evil, we want this situation to map to a class that looks like this</p>
<pre><code>class Appointm... | [
{
"answer_id": 340409,
"author": "chrismeek",
"author_id": 21532,
"author_profile": "https://Stackoverflow.com/users/21532",
"pm_score": 2,
"selected": false,
"text": "<p>The obvious answer is to create a Status entity and make the appointment class have a reference to that and map it in... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340403",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21532/"
] | Consider the following table structure...
```
Appointment
-----------
ID integer
Description nvarchar
StatusID smallint
Status
------
ID smallint
DisplayText nvarchar
```
Now, for good or for evil, we want this situation to map to a class that looks like this
```
class Appointment
{
public int ID {g;s;}
... | The obvious answer is to create a Status entity and make the appointment class have a reference to that and map it in the normal way. |
340,413 | <p>How do type casting happen without loss of data inside the compiler?</p>
<p>For example:</p>
<pre><code> int i = 10;
UINT k = (UINT) k;
float fl = 10.123;
UINT ufl = (UINT) fl; // data loss here?
char *p = "Stackoverflow Rocks";
unsigned char *up = (unsigned char *) p;
</code></pre>
<p>How does the compil... | [
{
"answer_id": 340439,
"author": "MSalters",
"author_id": 15416,
"author_profile": "https://Stackoverflow.com/users/15416",
"pm_score": 3,
"selected": false,
"text": "<p>\"Type\" in C and C++ is a property assigned to variables when they're handled in the compiler. The property doesn't e... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340413",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38038/"
] | How do type casting happen without loss of data inside the compiler?
For example:
```
int i = 10;
UINT k = (UINT) k;
float fl = 10.123;
UINT ufl = (UINT) fl; // data loss here?
char *p = "Stackoverflow Rocks";
unsigned char *up = (unsigned char *) p;
```
How does the compiler handle this type of typecastin... | Well, first note that a cast is an *explicit request to convert a value of one type to a value of another type*. A cast will also always produce a new object, which is a temporary returned by the cast operator. Casting to a reference type, however, will not create a new object. The object referenced by the value is rei... |
340,415 | <p>I have a <code>JSP</code> page which contains an <code>HTML</code> <code><select></code> populated with all countries loaded from a database. Say for example, on "create user" all the country values are loaded in the select menu and I select 5 countries. Those 5 values are loaded into database for that particu... | [
{
"answer_id": 340502,
"author": "kgiannakakis",
"author_id": 24054,
"author_profile": "https://Stackoverflow.com/users/24054",
"pm_score": 2,
"selected": false,
"text": "<p>I am not sure if I understand the question correctly, but here is a multiple selection list:</p>\n\n<pre><code><... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340415",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a `JSP` page which contains an `HTML` `<select>` populated with all countries loaded from a database. Say for example, on "create user" all the country values are loaded in the select menu and I select 5 countries. Those 5 values are loaded into database for that particular user.
Now when I click on "modify use... | I am not sure if I understand the question correctly, but here is a multiple selection list:
```
<select multiple="multiple">
<option value ="UK">UK</option>
<option value ="France" selected="selected">France</option>
<option value ="Germany">Germany</option>
<option value ="Italy" selected="selected">Italy</o... |
340,425 | <p>I'm asking myself if it is possible to check if in ADO.NET the current transaction can be rolled back.</p>
<p>The msdn suggests the following implementation:</p>
<pre><code>private static void ExecuteSqlTransaction(string connectionString)
{
using (SqlConnection connection = new SqlConnection(connectionString)... | [
{
"answer_id": 340522,
"author": "user19371",
"author_id": 19371,
"author_profile": "https://Stackoverflow.com/users/19371",
"pm_score": 1,
"selected": false,
"text": "<p>A lot of this complexity is handled by using a TransactionScope object in a \"using\" statement - check it out on <a ... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340425",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24756/"
] | I'm asking myself if it is possible to check if in ADO.NET the current transaction can be rolled back.
The msdn suggests the following implementation:
```
private static void ExecuteSqlTransaction(string connectionString)
{
using (SqlConnection connection = new SqlConnection(connectionString))
{
conne... | A lot of this complexity is handled by using a TransactionScope object in a "using" statement - check it out on [MSDN](http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx). One caveat is that a TransactionScope will automatically "scale up" to use a distributed transaction when it is deeme... |
340,437 | <p>Whilst trawling through some old code I came across something similar to the following:</p>
<pre><code>class Base
{
public:
virtual int Func();
...
};
class Derived : public Base
{
public:
int Func(); // Missing 'virtual' qualifier
...
};
</code></pre>
<p>The code compiles fine (MS VS2008) with no... | [
{
"answer_id": 340446,
"author": "Blair Conrad",
"author_id": 1199,
"author_profile": "https://Stackoverflow.com/users/1199",
"pm_score": 4,
"selected": true,
"text": "<p>The <code>virtual</code> will be carried down to all overriding functions in derived classes. The only real benefit t... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340437",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9236/"
] | Whilst trawling through some old code I came across something similar to the following:
```
class Base
{
public:
virtual int Func();
...
};
class Derived : public Base
{
public:
int Func(); // Missing 'virtual' qualifier
...
};
```
The code compiles fine (MS VS2008) with no warnings (level 4) and it... | The `virtual` will be carried down to all overriding functions in derived classes. The only real benefit to adding the keyword is to signify your intent a casual observer of the Derived class definition will immediately know that `Func` is virtual.
Even classes that extend Derived will have virtual Func methods.
Refe... |
340,461 | <p>I am wondering how to tell NHibernate to resolve dependencies on my POCO domain objects.</p>
<p>I figured out that methods like CalculateOrderTax should be in the Domain object because they encode domain specific business rules. But once I have two of those I am violating SRP. </p>
<p>It would be no problem to ext... | [
{
"answer_id": 340761,
"author": "Garry Shutler",
"author_id": 6369,
"author_profile": "https://Stackoverflow.com/users/6369",
"pm_score": 1,
"selected": false,
"text": "<p>As no-one seems to be able to answer your question at the moment I thought I'd suggest restructuring your code to r... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340461",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21699/"
] | I am wondering how to tell NHibernate to resolve dependencies on my POCO domain objects.
I figured out that methods like CalculateOrderTax should be in the Domain object because they encode domain specific business rules. But once I have two of those I am violating SRP.
It would be no problem to extract those method... | I've been using interceptors for similar tasks:
An interceptor that modifies loaded entities:
```
public class MyInterceptor : EmptyInterceptor
{
public override bool OnLoad(object entity, object id, object[] state, string[] propertyNames, IType[] types)
{
return InjectDependencies(entity as MyEntity)... |
340,491 | <p>This code:</p>
<pre><code>db = "C:\Dokumente und Einstellungen\hom\Anwendungsdaten\BayWotch4\Neuer Ordner\baywotch.db5"
TextExportFile = "C:\Dokumente und Einstellungen\hom\Anwendungsdaten\BayWotch4\Neuer Ordner\Exp.txt"
Set cn = CreateObject("ADODB.Connection")
Set rs = CreateObject("ADODB.Recordset")
cn.Open _
... | [
{
"answer_id": 340496,
"author": "kokos",
"author_id": 1065,
"author_profile": "https://Stackoverflow.com/users/1065",
"pm_score": 0,
"selected": false,
"text": "<p>Wouldn't a normal string be enough? It's overkill to serialize / deserialize an entire XDoc instance in my opinion. Of cour... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340491",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1246613/"
] | This code:
```
db = "C:\Dokumente und Einstellungen\hom\Anwendungsdaten\BayWotch4\Neuer Ordner\baywotch.db5"
TextExportFile = "C:\Dokumente und Einstellungen\hom\Anwendungsdaten\BayWotch4\Neuer Ordner\Exp.txt"
Set cn = CreateObject("ADODB.Connection")
Set rs = CreateObject("ADODB.Recordset")
cn.Open _
"Provider =... | You might consider using something like a WCF service and streaming the xml up using the GZipStream. I am doing something similar to this and it is working pretty well. |
340,507 | <p>I have a Customer class.</p>
<pre><code>public class Customer
{
private string _id;
private string _name;
// some more properties follow
</code></pre>
<p>I am inheriting the EqualityComparer form MyEqualityComparer(of Customer).<br>
This I am intending to use in LINQ queries.<br>
MyEqualityComparer is... | [
{
"answer_id": 340523,
"author": "liggett78",
"author_id": 19762,
"author_profile": "https://Stackoverflow.com/users/19762",
"pm_score": 2,
"selected": false,
"text": "<p>You should see it from the perspective of possible \"collisions\", e.g. when two different objects get the same hash ... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340507",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41968/"
] | I have a Customer class.
```
public class Customer
{
private string _id;
private string _name;
// some more properties follow
```
I am inheriting the EqualityComparer form MyEqualityComparer(of Customer).
This I am intending to use in LINQ queries.
MyEqualityComparer is intended for partial check ... | See [this question on hashcodes](https://stackoverflow.com/questions/263400) for a pretty simple way to return one hashcode based on multiple fields.
Having said that, I wouldn't derive from `EqualityComparer<T>` myself - I'd just implement `IEqualityComparer<T>` directly. I'm not sure what value `EqualityComparer<T>`... |
340,520 | <p>A few months ago, I have programmed an ASP.NET GridView with a custom "Delete" LinkButton and Client-Side JavaScript Confirmation according to this msdn article:</p>
<p><a href="http://msdn.microsoft.com/en-us/library/bb428868.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/bb428868.aspx</a>... | [
{
"answer_id": 340747,
"author": "Samiksha",
"author_id": 29515,
"author_profile": "https://Stackoverflow.com/users/29515",
"pm_score": 1,
"selected": false,
"text": "<p>Try this :</p>\n\n<pre><code><asp:LinkButton ID=\"DeleteButton\" runat=\"server\" CausesValidation=\"False\"\n C... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340520",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | A few months ago, I have programmed an ASP.NET GridView with a custom "Delete" LinkButton and Client-Side JavaScript Confirmation according to this msdn article:
<http://msdn.microsoft.com/en-us/library/bb428868.aspx> (published in April 2007)
or e.g. [Javascript before asp:ButtonField click](https://stackoverflow.co... | Try this :
```
<asp:LinkButton ID="DeleteButton" runat="server" CausesValidation="False"
CommandName="Delete" Text="Delete"
OnClientClick="return confirm('Delete Id : '<%# (string)Eval('id')%>')" >
</asp:LinkButton>
``` |
340,521 | <p>I'm writing a service that will only get calls from the local host. Performance is important so I thought I'd try the <a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.netnamedpipebinding.aspx" rel="noreferrer">NetNamedPipeBinding</a> instead of <a href="http://msdn.microsoft.com/en-us/library/sys... | [
{
"answer_id": 340869,
"author": "Chris Porter",
"author_id": 13495,
"author_profile": "https://Stackoverflow.com/users/13495",
"pm_score": 4,
"selected": false,
"text": "<p>I haven't used NetNamedPipes in WCF but I spent more time than I cared to learning the timeout values for NetTcp. ... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340521",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2114/"
] | I'm writing a service that will only get calls from the local host. Performance is important so I thought I'd try the [NetNamedPipeBinding](http://msdn.microsoft.com/en-us/library/system.servicemodel.netnamedpipebinding.aspx) instead of [NetTcpBinding](http://msdn.microsoft.com/en-us/library/system.servicemodel.nettcpb... | My experience is that, when using NetNamedPipes, the "ReceiveTimout" on the binding functions like an "Inactivity Timeout" rather than a receive timout. Note that this different than how a NetTCPBinding works. With TCP, it really is a receive timeout and there's a separate inactivity timeout you can configure via relia... |
340,525 | <p>I'm trying to learn about Expression trees, and I've created a method that takes an</p>
<pre><code>Expression<Func<bool>>
</code></pre>
<p>and executes it if it satisfies some conditions - see the code below.</p>
<pre><code> private static void TryCommand(Expression<Func<bool>> exp... | [
{
"answer_id": 340566,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 2,
"selected": true,
"text": "<p>The target of the method call is an instance of MyClass, but the delegate itself isn't the method call. It's something... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340525",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32413/"
] | I'm trying to learn about Expression trees, and I've created a method that takes an
```
Expression<Func<bool>>
```
and executes it if it satisfies some conditions - see the code below.
```
private static void TryCommand(Expression<Func<bool>> expression)
{
var methodCallExpression = exp... | The target of the method call is an instance of MyClass, but the delegate itself isn't the method call. It's something which will perform the method call when it's executed.
If you look at func.Target, you'll see it's a [System.Runtime.CompilerServices.ExecutionScope](http://msdn.microsoft.com/en-us/library/system.run... |
340,528 | <p>If both get and set are compulsory in C# automatic properties, why do I have to bother specifying "get; set;" at all?</p>
| [
{
"answer_id": 340531,
"author": "Brian Genisio",
"author_id": 36687,
"author_profile": "https://Stackoverflow.com/users/36687",
"pm_score": 6,
"selected": false,
"text": "<p>Because you might want a read-only property:</p>\n\n<pre><code>public int Foo { get; private set; }\n</code></pre... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340528",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38522/"
] | If both get and set are compulsory in C# automatic properties, why do I have to bother specifying "get; set;" at all? | **ERROR: A property or indexer may not be passed as an out or ref parameter**
If you didn't specify `{get; set;}` then the compiler wouldn't know if it's a field or a property.
This is important becasue while they "look" identical the compiler treats them differently. e.g. Calling "InitAnInt" on the property raises an... |
340,543 | <p>I have a problem creating a regular expression for the following task:</p>
<p>Suppose we have HTML-like text of the kind:</p>
<pre><code><x>...<y>a</y>...<y>b</y>...</x>
</code></pre>
<p>I want to get a collection of values inside <code><y></y></code> tags located i... | [
{
"answer_id": 340556,
"author": "Bill the Lizard",
"author_id": 1288,
"author_profile": "https://Stackoverflow.com/users/1288",
"pm_score": 3,
"selected": false,
"text": "<p>This is a job for an <a href=\"http://htmlparsing.icenine.ca/\" rel=\"nofollow noreferrer\">HTML/XML parser</a>. ... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340543",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a problem creating a regular expression for the following task:
Suppose we have HTML-like text of the kind:
```
<x>...<y>a</y>...<y>b</y>...</x>
```
I want to get a collection of values inside `<y></y>` tags located inside a given `<x>` tag, so the result of the above example would be a collection of two ele... | This is a job for an [HTML/XML parser](http://htmlparsing.icenine.ca/). You *could* do it with regular expressions, but it would be very messy. There are examples in the page I linked to. |
340,546 | <p>It is advised to use override instead of new key word in C#. Why that rule?</p>
| [
{
"answer_id": 340554,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 5,
"selected": true,
"text": "<p>\"new\" means you've got two completely different methods as far as the CLR is concerned - they happen to have the sam... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340546",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38807/"
] | It is advised to use override instead of new key word in C#. Why that rule? | "new" means you've got two completely different methods as far as the CLR is concerned - they happen to have the same name, but they're unrelated in terms of inheritance. That means that if you run:
```
Base b = new Derived();
Derived d = new Derived();
b.MyMethod(); // Calls Base.MyMethod
d.MyMethod(); // Calls Deriv... |
340,548 | <p>I'm writing some tests in Perl which have a fair amount of set up. This setup all lives in a module that the test scripts <code>use</code>. I want to be able to print some diagnostics from the module, and intended to use the <code>diag</code> function from <code>Test::More</code>. Problem is, when you <code>use Test... | [
{
"answer_id": 340554,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 5,
"selected": true,
"text": "<p>\"new\" means you've got two completely different methods as far as the CLR is concerned - they happen to have the sam... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340548",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6402/"
] | I'm writing some tests in Perl which have a fair amount of set up. This setup all lives in a module that the test scripts `use`. I want to be able to print some diagnostics from the module, and intended to use the `diag` function from `Test::More`. Problem is, when you `use Test::More`, it writes the plan so I get
> ... | "new" means you've got two completely different methods as far as the CLR is concerned - they happen to have the same name, but they're unrelated in terms of inheritance. That means that if you run:
```
Base b = new Derived();
Derived d = new Derived();
b.MyMethod(); // Calls Base.MyMethod
d.MyMethod(); // Calls Deriv... |
340,553 | <p>What is the best way to send HTTP requests from Windows Powershell?</p>
| [
{
"answer_id": 340570,
"author": "Thomas Bratt",
"author_id": 15985,
"author_profile": "https://Stackoverflow.com/users/15985",
"pm_score": 6,
"selected": true,
"text": "<p>Found one way:</p>\n\n<pre><code>$page = (New-Object System.Net.WebClient).DownloadString(\"http://localhost/\")\n<... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340553",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15985/"
] | What is the best way to send HTTP requests from Windows Powershell? | Found one way:
```
$page = (New-Object System.Net.WebClient).DownloadString("http://localhost/")
```
Thanks to Steven Murawski for his comment:
>
> The best way really depends on what
> task you are trying to accomplish as
> the two answers below have noted.
> **WebClient** is the simplest, but
> **HttpWebRequ... |
340,562 | <p>In Java (And in general) is there a way to make a class so public that it's methods etc... are accessible from little classes all around that don't even instantiate it? Ha, what I mean is... If I have a daddy class that has a method <code>draw()</code> and it instantiates a baby class called Hand and one called Deck... | [
{
"answer_id": 340577,
"author": "Loki",
"author_id": 39057,
"author_profile": "https://Stackoverflow.com/users/39057",
"pm_score": 1,
"selected": false,
"text": "<p>You can:</p>\n\n<ul>\n<li>Pass the object reference through the constructor. Or by getters and setters. Or directly to the... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340562",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29182/"
] | In Java (And in general) is there a way to make a class so public that it's methods etc... are accessible from little classes all around that don't even instantiate it? Ha, what I mean is... If I have a daddy class that has a method `draw()` and it instantiates a baby class called Hand and one called Deck, and then dec... | When the Daddy class instantiates the Baby classes, it (Daddy) could pass a reference to itself to the Baby constructor, giving Baby access to all of its public methods.
```
class Daddy {
public foo(){...}
public createBaby(){
Baby baby = new Baby(this);
// baby now has a reference to Daddy
... |
340,568 | <p>I'm trying to find an zip compression and encryption component with <a href="http://www.networkworld.com/careers/2004/0315manonline.html" rel="noreferrer">encryption suitable for use by the US Federal Government</a>, so I can't use Zip 2.0 encryption, it has to be AES or the like. I've already found <a href="http:/... | [
{
"answer_id": 340579,
"author": "Matt Briggs",
"author_id": 10771,
"author_profile": "https://Stackoverflow.com/users/10771",
"pm_score": 3,
"selected": false,
"text": "<p>If money is a big issue, you could take an open source library like this <a href=\"http://www.codeplex.com/DotNetZi... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340568",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33264/"
] | I'm trying to find an zip compression and encryption component with [encryption suitable for use by the US Federal Government](http://www.networkworld.com/careers/2004/0315manonline.html), so I can't use Zip 2.0 encryption, it has to be AES or the like. I've already found [SharpZipLib](http://www.icsharpcode.net/OpenSo... | How much would you be willing to pay for AES in DotNetZip?
;)
DotNetZip supports AES Encryption, with 128 or 256-bit keys.
<http://www.codeplex.com/DotNetZip>
Example code:
```
using (ZipFile zip = new ZipFile())
{
zip.AddFile("ReadMe.txt"); // no password for this entry
// use a password for subsequ... |
340,601 | <p>I have made a toolbar that I want to enable from a systray application written in C#, the actual toolbar enabling is done from a C++ part using [DLLImport].</p>
<p>Current I use:</p>
<pre><code>SHLoadInProc(__uuidof(MyBandLoader))
</code></pre>
<p>but this fails on vista (SHLoadInProc is not implemented any more)... | [
{
"answer_id": 343604,
"author": "Eirik Nygaard",
"author_id": 43205,
"author_profile": "https://Stackoverflow.com/users/43205",
"pm_score": 0,
"selected": false,
"text": "<p>I have used that one, but it only tells you have to make a toolbar, not how to enable it from another program.</p... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340601",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43205/"
] | I have made a toolbar that I want to enable from a systray application written in C#, the actual toolbar enabling is done from a C++ part using [DLLImport].
Current I use:
```
SHLoadInProc(__uuidof(MyBandLoader))
```
but this fails on vista (SHLoadInProc is not implemented any more), and on Windows XP SP2 with IE6 ... | On Vista there's a new poorly-documented interface called ITrayDeskBand.
Create an instance of this via CoCreateInstance, and then call ShowDeskBand([CLSID of your toolbar]) on the returned pointer (in C++ - I'm not sure how you create all the relevant bits for PInvoke in C# - might be easier to write a simple C++ dl... |
340,608 | <p>So I was thinking about creating a dynamic sql question, meaning that i want the amount of parameters to be dynamic.</p>
<p>Having looked at this: <a href="https://stackoverflow.com/questions/337704/parameterizing-a-sql-in-clause#337725">Parameterize an SQL IN clause</a> i was thinking that using like '%x%' is SLOW... | [
{
"answer_id": 340630,
"author": "Sergiu Damian",
"author_id": 41345,
"author_profile": "https://Stackoverflow.com/users/41345",
"pm_score": 1,
"selected": false,
"text": "<p>I hear that SQL Server 2008 has a feature called Table Parameters, so you can pass a Table as a parameter to a Fu... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340608",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39106/"
] | So I was thinking about creating a dynamic sql question, meaning that i want the amount of parameters to be dynamic.
Having looked at this: [Parameterize an SQL IN clause](https://stackoverflow.com/questions/337704/parameterizing-a-sql-in-clause#337725) i was thinking that using like '%x%' is SLOW and not good.
What ... | It looks like SQL 2008 is an option, so passing a table parameter is probably your best bet. Another possible solution for those who can't move to 2008 yet, is to write a table-valued UDF that generates a table from a delimited string. Then you can do something like this:
```
SELECT DISTINCT
CN.user_id
FROM
... |
340,610 | <p>It is not possible to fire an event in C# that has no handlers attached to it. So before each call it is necessary to check if the event is null.</p>
<pre><code>if ( MyEvent != null ) {
MyEvent( param1, param2 );
}
</code></pre>
<p>I would like to keep my code as clean as possible and get rid of those null check... | [
{
"answer_id": 340618,
"author": "Dinah",
"author_id": 356,
"author_profile": "https://Stackoverflow.com/users/356",
"pm_score": 8,
"selected": true,
"text": "<p>I saw this on another post and have shamelessly stolen it and used it in much of my code ever since:</p>\n\n<pre><code>public ... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340610",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35440/"
] | It is not possible to fire an event in C# that has no handlers attached to it. So before each call it is necessary to check if the event is null.
```
if ( MyEvent != null ) {
MyEvent( param1, param2 );
}
```
I would like to keep my code as clean as possible and get rid of those null checks. I don't think it will a... | I saw this on another post and have shamelessly stolen it and used it in much of my code ever since:
```
public delegate void MyClickHandler(object sender, string myValue);
public event MyClickHandler Click = delegate {}; // add empty delegate!
//Let you do this:
public void DoSomething() {
Click(this, "foo");
}
... |
340,627 | <p>I need to parse Visual Studio automatically generated XML documentation to create a report. I decided to use XSLT but I'm very new to it and need help.
Common template is:</p>
<pre><code><doc>
<members>
<member name="F:MyNamespace">
<summary>Some text</summary>
</mem... | [
{
"answer_id": 340666,
"author": "AnthonyWJones",
"author_id": 17516,
"author_profile": "https://Stackoverflow.com/users/17516",
"pm_score": 0,
"selected": false,
"text": "<p>These functions are from XPath 2.0 in XSLT 2.0. .NET XSLT is at 1.0 and your xsl namespace reflects that.</p>\n"... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340627",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41956/"
] | I need to parse Visual Studio automatically generated XML documentation to create a report. I decided to use XSLT but I'm very new to it and need help.
Common template is:
```
<doc>
<members>
<member name="F:MyNamespace">
<summary>Some text</summary>
</member>
</members>
</doc>
```
I want to isola... | **In case you're performing the transformation with Visual Studio X**, where X is not greater than 2008, this would be processed by an [**XSLT 1.0**](http://www.w3.org/TR/xslt) processor (.NET's [**`XslCompiledTransform`**](http://msdn.microsoft.com/en-us/library/system.xml.xsl.xslcompiledtransform.aspx) or [**`XslTran... |
340,645 | <p>Let's say I have a simple chunck of XML:-</p>
<pre><code><root>
<item forename="Fred" surname="Flintstone" />
<item forename="Barney" surname="Rubble" />
</root>
</code></pre>
<p>Having fetched this XML in Silverlight I would like to bind it with <a href="http://en.wikipedia.org/wiki/... | [
{
"answer_id": 340751,
"author": "David Padbury",
"author_id": 26401,
"author_profile": "https://Stackoverflow.com/users/26401",
"pm_score": 0,
"selected": false,
"text": "<p>As far as I'm aware the Silverlight Binding lacks the XPath properties found in WPF so there is no nice way to bi... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340645",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17516/"
] | Let's say I have a simple chunck of XML:-
```
<root>
<item forename="Fred" surname="Flintstone" />
<item forename="Barney" surname="Rubble" />
</root>
```
Having fetched this XML in Silverlight I would like to bind it with [XAML](http://en.wikipedia.org/wiki/Extensible_Application_Markup_Language) of this ilke... | See *[Binding to Anonymous types in Silverlight](http://grahammurray.wordpress.com/2010/05/30/binding-to-anonymous-types-in-silverlight/)* for information. |
340,658 | <p>I'm using AS3 (Flash) to <strong>read SVG files</strong> and <strong>display</strong> them.
The problem is correctly displaying a <strong>linear/radial gradient.</strong></p>
<p>Following is an example of a simple <strong>linear gradient</strong> from <strong>Red</strong> to <strong>Blue</strong>, in SVG.</p>
<pre><... | [
{
"answer_id": 344585,
"author": "Robin Rodricks",
"author_id": 41021,
"author_profile": "https://Stackoverflow.com/users/41021",
"pm_score": 0,
"selected": false,
"text": "<h2>SVG rendering engine!</h2>\n\n<p>Maybe there are some answers <a href=\"https://stackoverflow.com/questions/589... | 2008/12/04 | [
"https://Stackoverflow.com/questions/340658",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41021/"
] | I'm using AS3 (Flash) to **read SVG files** and **display** them.
The problem is correctly displaying a **linear/radial gradient.**
Following is an example of a simple **linear gradient** from **Red** to **Blue**, in SVG.
```
<linearGradient id="GRADIENT_1" gradientUnits="userSpaceOnUse"
x1="107.3938" y1="515.5684" x... | How to draw a linear gradient using the 2 gradient points
---------------------------------------------------------
1. **x1,y1 and x2,y2** are the 2 points on the **screen coordinate space**, that the gradient is to be drawn from, to.
2. Use the **transformation matrix** supplied by SVG to **offset the x1,y1 and x2,y2... |