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 |
|---|---|---|---|---|---|---|
483,609 | <p>I am taking a beginning C++ class, and would like to convert letters between hex representations and binary. I can manage to print out the hex numbers using:</p>
<pre><code>for(char c = 'a'; c <= 'z'; c++){
cout << hex << (int)c;
}
</code></pre>
<p>But I can't do the same for binary. There is no... | [
{
"answer_id": 483618,
"author": "workmad3",
"author_id": 16035,
"author_profile": "https://Stackoverflow.com/users/16035",
"pm_score": 3,
"selected": false,
"text": "<p>There isn't a binary io manipulator in C++. You need to perform the coversion by hand, probably by using bitshift oper... | 2009/01/27 | [
"https://Stackoverflow.com/questions/483609",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24391/"
] | I am taking a beginning C++ class, and would like to convert letters between hex representations and binary. I can manage to print out the hex numbers using:
```
for(char c = 'a'; c <= 'z'; c++){
cout << hex << (int)c;
}
```
But I can't do the same for binary. There is no `std::bin` that I can use to convert the... | Like so:
```
for(char c = 'a'; c <= 'z'; c++){
std::bitset<sizeof(char) * CHAR_BIT> binary(c); //sizeof() returns bytes, not bits!
std::cout << "Letter: " << c << "\t";
std::cout << "Hex: " << std::hex << (int)c << "\t";
std::cout << "Binary: " << binary << std::endl;
}
``` |
483,622 | <p>I am writing a Perl module, and I am using carp to throw a non-fatal warning back to the calling program.</p>
<p>The carp warning works fine - I am checking if an input parameter meets a certain condition - if it does not meet the condition, a warning is sent with carp and the module continues on using a default for... | [
{
"answer_id": 483733,
"author": "Tracy Hurley",
"author_id": 31240,
"author_profile": "https://Stackoverflow.com/users/31240",
"pm_score": 5,
"selected": true,
"text": "<p>From this page, <a href=\"http://perldoc.perl.org/perlvar.html\" rel=\"noreferrer\">http://perldoc.perl.org/perlvar... | 2009/01/27 | [
"https://Stackoverflow.com/questions/483622",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40619/"
] | I am writing a Perl module, and I am using carp to throw a non-fatal warning back to the calling program.
The carp warning works fine - I am checking if an input parameter meets a certain condition - if it does not meet the condition, a warning is sent with carp and the module continues on using a default for the para... | From this page, <http://perldoc.perl.org/perlvar.html>, it looks like you want to set the local `$SIG{__WARN__}` to a subroutine that will turn warnings into fatal errors for your test script. The example they give is:
```
local $SIG{__WARN__} = sub { die $_[0] };
eval $proggie;
``` |
483,655 | <p>How can I convert the binary string <code>$x_bin="0001001100101"</code> to its numeric value <code>$x_num=613</code> in Perl?</p>
| [
{
"answer_id": 483668,
"author": "Ed Guiness",
"author_id": 4200,
"author_profile": "https://Stackoverflow.com/users/4200",
"pm_score": 6,
"selected": true,
"text": "<pre><code>sub bin2dec {\n return unpack(\"N\", pack(\"B32\", substr(\"0\" x 32 . shift, -32)));\n}\n</code></pre>\n"
... | 2009/01/27 | [
"https://Stackoverflow.com/questions/483655",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1084/"
] | How can I convert the binary string `$x_bin="0001001100101"` to its numeric value `$x_num=613` in Perl? | ```
sub bin2dec {
return unpack("N", pack("B32", substr("0" x 32 . shift, -32)));
}
``` |
483,656 | <p>Are there any web services which will allow me to provide a file extension and it would return a list of possible MIME types? </p>
<p>For example:</p>
<pre><code>http://mimetype.com/getMime/doc
</code></pre>
<p>Which could return:</p>
<pre><code>application/msword,application/docappl/text,application/vnd.msword,... | [
{
"answer_id": 495044,
"author": "boutta",
"author_id": 15108,
"author_profile": "https://Stackoverflow.com/users/15108",
"pm_score": 1,
"selected": false,
"text": "<p>Sorry that I don't have a webservice for the task on hand, but you could use the <a href=\"http://filext.com/index.php\"... | 2009/01/27 | [
"https://Stackoverflow.com/questions/483656",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/383/"
] | Are there any web services which will allow me to provide a file extension and it would return a list of possible MIME types?
For example:
```
http://mimetype.com/getMime/doc
```
Which could return:
```
application/msword,application/docappl/text,application/vnd.msword,application/vnd.ms-word,application/winword,... | The only thing I could imagine would be parsing the list which comes with the apache server
[mime.types](http://svn.apache.org/repos/asf/httpd/httpd/branches/2.0.x/docs/conf/mime.types). The list is maintained by The Apache Software Foundation and depends on [www.iana.org](http://www.iana.org) |
483,664 | <p>I'm slowly building my application to a working state.</p>
<p>I'm using two functions called <code>setCollection</code> and <code>addToCollection</code>. These functions both accept <code>NSArray</code> as input.</p>
<p>I also have a function called <code>add</code> in which I use both of these functions. When I t... | [
{
"answer_id": 483696,
"author": "e.James",
"author_id": 33686,
"author_profile": "https://Stackoverflow.com/users/33686",
"pm_score": 3,
"selected": false,
"text": "<p>You can declare functions ahead of time as follows:</p>\n\n<pre><code>void setCollection(NSArray * array);\nvoid addToC... | 2009/01/27 | [
"https://Stackoverflow.com/questions/483664",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/59159/"
] | I'm slowly building my application to a working state.
I'm using two functions called `setCollection` and `addToCollection`. These functions both accept `NSArray` as input.
I also have a function called `add` in which I use both of these functions. When I try to compile, Xcode shows an error:
>
> 'setCollection' un... | If your functions are global (not part of a class), you just have to put the declaration before the use, just like eJames suggests.
If your functions actually are methods (part of a class), you have to declare an anonymous category of your class before the implementation and put your method declarations in this interf... |
483,666 | <p>Given a dictionary like so:</p>
<pre><code>my_map = {'a': 1, 'b': 2}
</code></pre>
<p>How can one invert this map to get:</p>
<pre><code>inv_map = {1: 'a', 2: 'b'}
</code></pre>
| [
{
"answer_id": 483680,
"author": "sykora",
"author_id": 53850,
"author_profile": "https://Stackoverflow.com/users/53850",
"pm_score": 6,
"selected": false,
"text": "<p>Try this:</p>\n\n<pre><code>inv_map = dict(zip(my_map.values(), my_map.keys()))\n</code></pre>\n\n<p>(Note that <a href=... | 2009/01/27 | [
"https://Stackoverflow.com/questions/483666",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19212/"
] | Given a dictionary like so:
```
my_map = {'a': 1, 'b': 2}
```
How can one invert this map to get:
```
inv_map = {1: 'a', 2: 'b'}
``` | Python 3+:
```
inv_map = {v: k for k, v in my_map.items()}
```
Python 2:
```
inv_map = {v: k for k, v in my_map.iteritems()}
``` |
483,669 | <p>I want to use a string that I have been using in one aspx.cs file over to another. I know this is easy, but how do I go about doing that?</p>
| [
{
"answer_id": 483679,
"author": "Sergio",
"author_id": 32037,
"author_profile": "https://Stackoverflow.com/users/32037",
"pm_score": 2,
"selected": false,
"text": "<p>You can either send it using a querystring or you can define a session variable to store it.</p>\n\n<p>The best option d... | 2009/01/27 | [
"https://Stackoverflow.com/questions/483669",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/54197/"
] | I want to use a string that I have been using in one aspx.cs file over to another. I know this is easy, but how do I go about doing that? | You can do it in a query string. On your first page:
```
Response.Redirect("Second.aspx?book=codecomplete");
```
and on the second page
```
string book = Request["book"];
```
This method will allow your users to see what you are passing to a second page. Alternatively you can place it in session object. To place ... |
483,672 | <p>The basic idea is to take a string and evaluate it against an XML File (or any LINQed provider)</p>
<p>I found this <a href="http://weblogs.asp.net/scottgu/archive/2008/01/07/dynamic-linq-part-1-using-the-linq-dynamic-query-library.aspx" rel="noreferrer">LINQ Dynamic Query Library</a>. Just had a cursory glance at ... | [
{
"answer_id": 483715,
"author": "Amy B",
"author_id": 8155,
"author_profile": "https://Stackoverflow.com/users/8155",
"pm_score": 0,
"selected": false,
"text": "<p>Much of <a href=\"http://msdn.microsoft.com/en-us/library/system.xml.linq.aspx\" rel=\"nofollow noreferrer\">LinqToXml</a> ... | 2009/01/27 | [
"https://Stackoverflow.com/questions/483672",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1695/"
] | The basic idea is to take a string and evaluate it against an XML File (or any LINQed provider)
I found this [LINQ Dynamic Query Library](http://weblogs.asp.net/scottgu/archive/2008/01/07/dynamic-linq-part-1-using-the-linq-dynamic-query-library.aspx). Just had a cursory glance at the documentation which is a single pa... | It must be possible because [Linqpad](http://www.linqpad.net/) does it!
Looking at the [how it works page](http://www.linqpad.net/HowLINQPadWorks.aspx) is a bit mind bending, and I'm not sure this is something you would want to do with production code unless you really couldn't avoid it.
There is no framework method ... |
483,675 | <p>Whenever I see images in an RSS feed, they are embedded in CDATA, rather than surrounded by tags.</p>
<p>In my feed, I would like the images to show up without doing that.</p>
<p>Whether in the browser, or a feed reader (Bloglines) or through FeedBurner, the following structure does not show images, although it is... | [
{
"answer_id": 483734,
"author": "guerda",
"author_id": 32043,
"author_profile": "https://Stackoverflow.com/users/32043",
"pm_score": -1,
"selected": false,
"text": "<p>It works with a seperate tag, as you said. The problem is the specification of version 2.0. </p>\n\n<p>I know, there ar... | 2009/01/27 | [
"https://Stackoverflow.com/questions/483675",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4241/"
] | Whenever I see images in an RSS feed, they are embedded in CDATA, rather than surrounded by tags.
In my feed, I would like the images to show up without doing that.
Whether in the browser, or a feed reader (Bloglines) or through FeedBurner, the following structure does not show images, although it is valid RSS. Does ... | On Colonol Sponsz' hint, I researched:
There's no image tag for items, only for the channel. So you *have* to do it via the CDATA tag. |
483,678 | <p>After reading this on the question <a href="https://stackoverflow.com/questions/216542/how-do-i-uniquely-identify-computers-visiting-my-web-site#216599">How do I uniquely identify computers visiting my web site?</a>
:</p>
<blockquote>
<p>A possibility is using flash cookies:</p>
<pre><code>Ubiquitous availabilit... | [
{
"answer_id": 483775,
"author": "rmeador",
"author_id": 10861,
"author_profile": "https://Stackoverflow.com/users/10861",
"pm_score": 1,
"selected": false,
"text": "<p>I'm hesitant to answer your question, because it sounds like this is straying dangerously close to Evil... Also, it's ... | 2009/01/27 | [
"https://Stackoverflow.com/questions/483678",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/55283/"
] | After reading this on the question [How do I uniquely identify computers visiting my web site?](https://stackoverflow.com/questions/216542/how-do-i-uniquely-identify-computers-visiting-my-web-site#216599)
:
>
> A possibility is using flash cookies:
>
>
>
> ```
> Ubiquitous availability (95 percent of visitors will... | To build on what *rmeador* said, and to help get you started, you are going to need to know how to use two classes in the FLEX3 API, [SharedObject](http://livedocs.adobe.com/flex/3/langref/) and [ExternalInterface](http://livedocs.adobe.com/flex/3/langref/).
**SharedObject** will allow you to store and retrive data fr... |
483,702 | <p>My string is as follows:</p>
<pre><code>smtp:jblack@test.com;SMTP:jb@test.com;X400:C=US;A= ;P=Test;O=Exchange;S=Jack;G=Black;
</code></pre>
<p>I need back:</p>
<pre><code>smtp:jblack@test.com
SMTP:jb@test.com
X400:C=US;A= ;P=Test;O=Exchange;S=Jack;G=Black;
</code></pre>
<p>The problem is the semi-colons seperate... | [
{
"answer_id": 483724,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 3,
"selected": false,
"text": "<p>EDIT: With the updated information, this answer certainly won't do the trick - but it's still potentially useful, so ... | 2009/01/27 | [
"https://Stackoverflow.com/questions/483702",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | My string is as follows:
```
smtp:jblack@test.com;SMTP:jb@test.com;X400:C=US;A= ;P=Test;O=Exchange;S=Jack;G=Black;
```
I need back:
```
smtp:jblack@test.com
SMTP:jb@test.com
X400:C=US;A= ;P=Test;O=Exchange;S=Jack;G=Black;
```
The problem is the semi-colons seperate the addresses and also part of the X400 address.... | EDIT: With the updated information, this answer certainly won't do the trick - but it's still potentially useful, so I'll leave it here.
Will you always have three parts, and you just want to split on the first two semi-colons?
If so, just use the overload of Split which lets you specify the number of substrings to r... |
483,745 | <p>I have an HTML page with a typical structure:</p>
<pre class="lang-html prettyprint-override"><code><html>
<head>
<script src="..." ></script>
<style>...</style>
</head>
<body>
content
</body>
<script>
var success_callback = function... | [
{
"answer_id": 483755,
"author": "The.Anti.9",
"author_id": 2128,
"author_profile": "https://Stackoverflow.com/users/2128",
"pm_score": 3,
"selected": false,
"text": "<p>You could try doing </p>\n\n<pre><code>document.getElementById(id).innerHTML = ajax_response\n</code></pre>\n"
},
... | 2009/01/27 | [
"https://Stackoverflow.com/questions/483745",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12388/"
] | I have an HTML page with a typical structure:
```html
<html>
<head>
<script src="..." ></script>
<style>...</style>
</head>
<body>
content
</body>
<script>
var success_callback = function(data) {
// REPLACE PAGE CONTENT & STRUCTURE WITH "data"
}
ajax(url, params, success_callback);... | The simplest way is to set the new HTML content using:
```
document.open();
document.write(newContent);
document.close();
``` |
483,787 | <p>Take a look at these two queries:</p>
<pre><code>-- #1
SELECT * FROM my_table
WHERE CONTAINS(my_column, 'monkey')
-- #2
SELECT * FROM my_table
WHERE CONTAINS(my_column, 'a OR monkey') -- "a" is a noise word
</code></pre>
<p>Query #1 returns 20 rows when I run it in Management Studio.<br>
Query #2 returns the sam... | [
{
"answer_id": 483860,
"author": "Andrew Hare",
"author_id": 34211,
"author_profile": "https://Stackoverflow.com/users/34211",
"pm_score": 2,
"selected": false,
"text": "<p>That certainly is strange behavior - but I am wondering why you need to check <code>HasRows</code> if you are going... | 2009/01/27 | [
"https://Stackoverflow.com/questions/483787",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/55847/"
] | Take a look at these two queries:
```
-- #1
SELECT * FROM my_table
WHERE CONTAINS(my_column, 'monkey')
-- #2
SELECT * FROM my_table
WHERE CONTAINS(my_column, 'a OR monkey') -- "a" is a noise word
```
Query #1 returns 20 rows when I run it in Management Studio.
Query #2 returns the same 20 rows, but I also see t... | I'm the original poster of the refernced question (lost login) and never managed to figure it out. In the end I put it down to bad voodoo, sacrificed neatness and went with something like
```
bool readerHasRows=false;
while(reader.reader())
{
readerHasRows=true;
doStuffOverAndOver();
}
if (!readerHasRows)
{
p... |
483,794 | <p>Which is the preferred way to convert an Enum to a String in .NET 3.5?</p>
<ul>
<li>Enum.GetName</li>
<li>Enum.Format</li>
<li>ToString</li>
</ul>
<p>Why should I prefer one of these over the others? Does one perform better?</p>
| [
{
"answer_id": 483799,
"author": "Tamas Czinege",
"author_id": 8954,
"author_profile": "https://Stackoverflow.com/users/8954",
"pm_score": 4,
"selected": false,
"text": "<p><strong><code>Enum.GetName()</code></strong></p>\n\n<p><code>Format()</code> is really just a wrapper around <code>... | 2009/01/27 | [
"https://Stackoverflow.com/questions/483794",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13342/"
] | Which is the preferred way to convert an Enum to a String in .NET 3.5?
* Enum.GetName
* Enum.Format
* ToString
Why should I prefer one of these over the others? Does one perform better? | As of C#6 the best way to get the name of an enum is the new `nameof` operator:
```
nameof(MyEnum.EnumValue);
// Ouputs
> "EnumValue"
```
This works at compile time, with the enum being replaced by the string in the compiled result, which in turn means this is the fastest way possible.
Any use of enum names does i... |
483,797 | <p>I'm trying to compile the following simple DL library example code from <a href="http://tldp.org/HOWTO/Program-Library-HOWTO/dl-libraries.html" rel="noreferrer">Program-Library-HOWTO</a> with g++. This is just an example so I can learn how to use and write shared libraries. The real code for the library I'm develo... | [
{
"answer_id": 483861,
"author": "leiflundgren",
"author_id": 25961,
"author_profile": "https://Stackoverflow.com/users/25961",
"pm_score": 3,
"selected": false,
"text": "<p><code>dlsym</code> returns a pointer to the symbol. (As <code>void*</code> to be generic.)\nIn your case you shoul... | 2009/01/27 | [
"https://Stackoverflow.com/questions/483797",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1288/"
] | I'm trying to compile the following simple DL library example code from [Program-Library-HOWTO](http://tldp.org/HOWTO/Program-Library-HOWTO/dl-libraries.html) with g++. This is just an example so I can learn how to use and write shared libraries. The real code for the library I'm developing will be written in C++.
```... | C allows implicit casts from `void *` to any pointer type (including function pointers); C++ requires explicit casting. As leiflundgren says, you need to cast the return value of `dlsym()` to the function pointer type you need.
Many people find C's function pointer syntax awkward. One common pattern is to typedef the ... |
483,798 | <p>Any idea if it's possible to create a procedure in another database using T-SQL alone, where the name of the database is not known up front and has to be read from a table? Kind of like this example:</p>
<pre><code>Use [MasterDatabase]
Declare @FirstDatabase nvarchar(100)
Select Top 1 @FirstDatabase=[ChildDatabase]... | [
{
"answer_id": 483830,
"author": "Mark Brackett",
"author_id": 2199,
"author_profile": "https://Stackoverflow.com/users/2199",
"pm_score": 0,
"selected": false,
"text": "<p>You could shell out to osql using xp_cmdshell, I suppose.</p>\n"
},
{
"answer_id": 483868,
"author": "C... | 2009/01/27 | [
"https://Stackoverflow.com/questions/483798",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18128/"
] | Any idea if it's possible to create a procedure in another database using T-SQL alone, where the name of the database is not known up front and has to be read from a table? Kind of like this example:
```
Use [MasterDatabase]
Declare @FirstDatabase nvarchar(100)
Select Top 1 @FirstDatabase=[ChildDatabase] From [ChildDa... | It's a pain, but this is what I do. I took this from an example I found on sqlteam, I think - you might have some quoting issues with the way I did the indiscriminate `REPLACE`:
```
DECLARE @sql AS varchar(MAX)
DECLARE @metasql as varchar(MAX)
DECLARE @PrintQuery AS bit
DECLARE @ExecQuery AS bit
SET @PrintQuery = 1
S... |
483,802 | <p>How can I add a newline in the text of a label in WPF such as the following?</p>
<pre><code><Label>Lorem
ipsum</Label>
</code></pre>
| [
{
"answer_id": 483821,
"author": "Szymon Rozga",
"author_id": 7583,
"author_profile": "https://Stackoverflow.com/users/7583",
"pm_score": 8,
"selected": true,
"text": "<pre><code><Label><TextBlock>Lorem<LineBreak/>ipsum</TextBlock></Label>\n</code></pre>\n\n... | 2009/01/27 | [
"https://Stackoverflow.com/questions/483802",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/59119/"
] | How can I add a newline in the text of a label in WPF such as the following?
```
<Label>Lorem
ipsum</Label>
``` | ```
<Label><TextBlock>Lorem<LineBreak/>ipsum</TextBlock></Label>
```
You need to use TextBlock because TextBlock accepts as children a collection of Inline objects. So you are giving the TextBlock element three Inline items: Run Text="Lorem", LineBreak, and Run Text="ipsum".
You can't do the following:
```
<Label>... |
483,813 | <p>I have a Word document with two embedded Excel files (added using Insert -> Object -> Create From File) which I wish to modify using Word VBA. I have got to the point where I am able to open the embedded files for editing (see code below), but am unable to get a handle on the Excel workbook using which I can make th... | [
{
"answer_id": 483912,
"author": "Anindya",
"author_id": 4741,
"author_profile": "https://Stackoverflow.com/users/4741",
"pm_score": 2,
"selected": false,
"text": "<p>I have a solution to my own problem. Any further comments will be appreciated -</p>\n\n<pre><code>Sub TestMacro()\n\n ... | 2009/01/27 | [
"https://Stackoverflow.com/questions/483813",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4741/"
] | I have a Word document with two embedded Excel files (added using Insert -> Object -> Create From File) which I wish to modify using Word VBA. I have got to the point where I am able to open the embedded files for editing (see code below), but am unable to get a handle on the Excel workbook using which I can make the m... | Yikes, don't do what you're suggesting in your comment. You'll probably end up with multiple instances of Excel (check Task Manager and see how many there are after executing your code).
Firstly, add a reference to the Excel object library (Project->References & choose Microsoft Excel Object Library). Now you can decl... |
483,834 | <p>How would I take a <code>Paragraph</code> object and databind them to the TextBlock for use in a DataTemplate?
A plain bind does nothing, just a <code>ToString()</code> of the Paragraph object.</p>
<p>The InLines property would let me add a list of TextRun's that make up the Paragraph manually, but that can't be bo... | [
{
"answer_id": 486080,
"author": "Christian Klauser",
"author_id": 55208,
"author_profile": "https://Stackoverflow.com/users/55208",
"pm_score": 0,
"selected": false,
"text": "<p>You could try to create your own DataTemplate for Paragraph objects that wraps each one in its own FlowDocume... | 2009/01/27 | [
"https://Stackoverflow.com/questions/483834",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/483/"
] | How would I take a `Paragraph` object and databind them to the TextBlock for use in a DataTemplate?
A plain bind does nothing, just a `ToString()` of the Paragraph object.
The InLines property would let me add a list of TextRun's that make up the Paragraph manually, but that can't be bound to and I could really do wit... | Here's an example using a nested ItemsControl. Unfortunately, it will make one TextBlock per Inline instead of putting the whole Paragraph into one TextBlock:
```
<Grid xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:x="http://schem... |
483,849 | <p>I tried running 'diff' against two source directories get a patch file with a 'diff' between the two directories. </p>
<pre><code>diff -rupN flyingsaucer-R8pre2_b/ flyingsaucer-R8pre2/ > a.patch
</code></pre>
<p>The command above does not seem to work, it generates a diff of everything and I get a 13 MB file, ... | [
{
"answer_id": 483871,
"author": "Paul Tomblin",
"author_id": 3333,
"author_profile": "https://Stackoverflow.com/users/3333",
"pm_score": 0,
"selected": false,
"text": "<p>I don't see any reason why it wouldn't work. Try adding \"wb\" to the argument list to ignore whitespace changes. ... | 2009/01/27 | [
"https://Stackoverflow.com/questions/483849",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10522/"
] | I tried running 'diff' against two source directories get a patch file with a 'diff' between the two directories.
```
diff -rupN flyingsaucer-R8pre2_b/ flyingsaucer-R8pre2/ > a.patch
```
The command above does not seem to work, it generates a diff of everything and I get a 13 MB file, when in reality, it should be ... | Should work with any recent version of gnu diff (tested here with gnu diff 2.8.1.)
You might want to add -b (and perhaps -B) to ignore difference in white space which perhaps generate large patch files unnecessarily. |
483,859 | <p>I'm trying to access an OleVariant in a callback that is coming from an ActiveX library.</p>
<p>Here's what the event handler is defined as in the TLB:</p>
<pre><code>procedure(ASender: TObject; var structQSnap: {??structVTIQSnap}OleVariant) of object;
</code></pre>
<p>Here's the definition of structVTIQSnap in t... | [
{
"answer_id": 483914,
"author": "Jk.",
"author_id": 50149,
"author_profile": "https://Stackoverflow.com/users/50149",
"pm_score": 0,
"selected": false,
"text": "<p>try to look what returns in TVarData(structQSnap).VType ? </p>\n\n<p>may be it will work:</p>\n\n<pre><code> var\n symbol... | 2009/01/27 | [
"https://Stackoverflow.com/questions/483859",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35229/"
] | I'm trying to access an OleVariant in a callback that is coming from an ActiveX library.
Here's what the event handler is defined as in the TLB:
```
procedure(ASender: TObject; var structQSnap: {??structVTIQSnap}OleVariant) of object;
```
Here's the definition of structVTIQSnap in the TLB:
```
structVTIQSnap = pac... | I think that Delphi's ActiveX import wizard doesn't know how to handle the structVTIQSnap type (which seems to be a record) properly and just uses the default OleVariant.
Is there a type declaration named structVTIQSnap or similar in the generated ...\_TLB.pas file? Try using that instead of OleVariant, e.g.
```
proce... |
483,864 | <p>Is there a Windows command that will output the size in bytes of a specified file like this?</p>
<pre><code>> filesize test.jpg
65212
</code></pre>
<p>I know that the <a href="https://ss64.com/nt/dir.html" rel="noreferrer"><code>dir</code></a> command outputs this information, but it outputs other information a... | [
{
"answer_id": 483904,
"author": "klyde",
"author_id": 58160,
"author_profile": "https://Stackoverflow.com/users/58160",
"pm_score": 1,
"selected": false,
"text": "<p>In PowerShell you can do:</p>\n\n<pre><code>$imageObj = New-Object System.IO.FileInfo(\"C:\\test.jpg\") \n$imageObj.Le... | 2009/01/27 | [
"https://Stackoverflow.com/questions/483864",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18333/"
] | Is there a Windows command that will output the size in bytes of a specified file like this?
```
> filesize test.jpg
65212
```
I know that the [`dir`](https://ss64.com/nt/dir.html) command outputs this information, but it outputs other information also.
I could easily write such a program, but I would prefer to use... | If you are inside a batch script, you can use argument variable tricks to get the filesize:
filesize.bat:
```
@echo off
echo %~z1
```
This gives results like the ones you suggest in your question.
Type
```
help call
```
at the command prompt for all of the crazy variable manipulation options. Also see [this art... |
483,865 | <p>I have a URL to a PDF and I want to serve up the PDF to my page viewer.</p>
<p>I can successfully (I think) retrieve the PDF file. Then when I do the Response.BinaryWrite() I get a "The file is damaged and could not be repaired" error from the adobe reader.</p>
<p>Here's the code I have: </p>
<pre><code>protecte... | [
{
"answer_id": 483877,
"author": "sduplooy",
"author_id": 31770,
"author_profile": "https://Stackoverflow.com/users/31770",
"pm_score": 0,
"selected": false,
"text": "<p>Try to flush the response after the binary write...</p>\n\n<pre><code>Response.BinaryWrite(output);\nResponse.Flush();... | 2009/01/27 | [
"https://Stackoverflow.com/questions/483865",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11771/"
] | I have a URL to a PDF and I want to serve up the PDF to my page viewer.
I can successfully (I think) retrieve the PDF file. Then when I do the Response.BinaryWrite() I get a "The file is damaged and could not be repaired" error from the adobe reader.
Here's the code I have:
```
protected void Page_Load(object sende... | Apparently, I need to use ReadBytes() For some reason, when reading a PDF from a URL, You don't get all of the bytes that you requested.
```
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack)
{
byte[] output = DoWork("Http://localhost/test.pdf");
Resp... |
483,873 | <p>I'm working on a report in Reporting Services and I can't figure out why I'm having trouble with Non-queried report parameters. </p>
<p>I'm trying to get the current year and have tried: </p>
<pre><code>=YEAR(TODAY())
=DATEPART("yyyy",TODAY())
</code></pre>
<p>I have also tried TODAY instead of TODAY() ... | [
{
"answer_id": 483913,
"author": "Gerrie Schenck",
"author_id": 57036,
"author_profile": "https://Stackoverflow.com/users/57036",
"pm_score": 2,
"selected": false,
"text": "<p>Try:</p>\n\n<pre><code>=Year(Now)\n</code></pre>\n\n<p>I'm not sure if this is what you need, but it worked for ... | 2009/01/27 | [
"https://Stackoverflow.com/questions/483873",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36590/"
] | I'm working on a report in Reporting Services and I can't figure out why I'm having trouble with Non-queried report parameters.
I'm trying to get the current year and have tried:
```
=YEAR(TODAY())
=DATEPART("yyyy",TODAY())
```
I have also tried TODAY instead of TODAY()
All of these seem to break the Ye... | ```
=DateTime.Today.Year
```
should work as well.
Edit: Bruno - i have the same behavior as you are seeing. I created a sample report with a string first parameter with no default value, and a string 2nd parameter with a default of =DateTime.Today.Year. When I have the one with the default as the 2nd parameter in th... |
483,874 | <pre><code>Patient
-------
PatientID
Visit
-----
VisitID
PatientID
HeartRate
VisitDate
</code></pre>
<p>How do I select all of the patients who have a visit, the date of their <strong>first</strong> visit, and their heart rate at that <strong>first</strong> visit?</p>
| [
{
"answer_id": 483883,
"author": "Gonzalo Quero",
"author_id": 40996,
"author_profile": "https://Stackoverflow.com/users/40996",
"pm_score": -1,
"selected": false,
"text": "<pre><code>SELECT TOP(1) PatientID, VisitDate, HeartRate FROM Visit ORDER BY VisitDate ASC\n</code></pre>\n\n<p>Pat... | 2009/01/27 | [
"https://Stackoverflow.com/questions/483874",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26/"
] | ```
Patient
-------
PatientID
Visit
-----
VisitID
PatientID
HeartRate
VisitDate
```
How do I select all of the patients who have a visit, the date of their **first** visit, and their heart rate at that **first** visit? | ```
SELECT
p.PatientID,
v.VisitID,
v.HeartRate,
v.VisitDate
FROM
Patient p
INNER JOIN Visit v ON p.PatientID = v.PatientID
WHERE
v.VisitDate = (
SELECT MIN(VisitDate)
FROM Visit
WHERE PatientId = p.PatientId
)
```
---
EDIT: Alternative version. Same thing. (less obvious, therefore less ... |
483,881 | <p>I have a website which uses TinyMCE textboxes for editing. It works fine except for the toolbar options which open a popup window as it seems to be caught by my url rewriting in the .htaccess file. Each of them show my 404-page. The url rewriting is set up so that all urls (except ajax calls) are sent to an index.ph... | [
{
"answer_id": 483899,
"author": "andyk",
"author_id": 26721,
"author_profile": "https://Stackoverflow.com/users/26721",
"pm_score": 1,
"selected": false,
"text": "<p>try putting an exception in your htaccess for the tinyMCE folder maybe ?</p>\n"
},
{
"answer_id": 483917,
"au... | 2009/01/27 | [
"https://Stackoverflow.com/questions/483881",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4055/"
] | I have a website which uses TinyMCE textboxes for editing. It works fine except for the toolbar options which open a popup window as it seems to be caught by my url rewriting in the .htaccess file. Each of them show my 404-page. The url rewriting is set up so that all urls (except ajax calls) are sent to an index.php f... | As @[andyk](https://stackoverflow.com/questions/483881/how-to-avoid-ruining-tinymce-popups-with-url-rewriting#483899) pointed out, you can use a .htaccess in your TinyMCE folder to override the global settings that are doing the URL rewriting. I've done this in the past myself to resolve the same issue.
If that's not... |
483,890 | <p>I have a resource scheduling issue in Java where things need to be sequenced, but there are restrictions on what resources can be next to each other. A good analogy is a string of "digits", where only certain digits can be next to each other. My solution was recursive, and works fine for small strings, but run tim... | [
{
"answer_id": 483951,
"author": "plinth",
"author_id": 20481,
"author_profile": "https://Stackoverflow.com/users/20481",
"pm_score": 1,
"selected": false,
"text": "<p>Maybe I don't understand this, but wouldn't this be served by having a table of lists that for each digit has a list of ... | 2009/01/27 | [
"https://Stackoverflow.com/questions/483890",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a resource scheduling issue in Java where things need to be sequenced, but there are restrictions on what resources can be next to each other. A good analogy is a string of "digits", where only certain digits can be next to each other. My solution was recursive, and works fine for small strings, but run time is ... | If you just want the number of strings of a certain length, you could just multiply the compatibility matrix with itself a few times, and sum it's values.
>
> *n* = *length of string*
>
> *A* = *compatibility matrix*
>
> *number of possible strings* = sum of *A**n*-1
>
>
>
A few examples:
```
n = 1
| 1 0 0... |
483,892 | <p>I'm developing a Desktop Search Engine in VB9 (VS2008).</p>
<p>Is it normal for a Service to take up 9MB of Memory while the only Thread involved in the Service is sleeping?</p>
<p>The code includes following import statements...</p>
<pre><code>Imports System
Imports System.IO
Imports Microsoft.Win32
Imports Syst... | [
{
"answer_id": 483911,
"author": "Mitchel Sellers",
"author_id": 13279,
"author_profile": "https://Stackoverflow.com/users/13279",
"pm_score": 2,
"selected": false,
"text": "<p>From that I can tell from that memory usage you are using only about 2.3 mb of actual memory, the shared/sharab... | 2009/01/27 | [
"https://Stackoverflow.com/questions/483892",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/57175/"
] | I'm developing a Desktop Search Engine in VB9 (VS2008).
Is it normal for a Service to take up 9MB of Memory while the only Thread involved in the Service is sleeping?
The code includes following import statements...
```
Imports System
Imports System.IO
Imports Microsoft.Win32
Imports System.Threading
```
There are... | From that I can tell from that memory usage you are using only about 2.3 mb of actual memory, the shared/sharable set is essentially a "cached" collection of memory, meaning that the app has earmarked it just incase it needs it.
Your application memory usage is most likely not that bad considering that you do have a n... |
483,898 | <p>I have this code</p>
<pre><code><html>
<head>
<style type="text/css">
.frame {width: 50em; border: 1px solid black}
.frame label {width: 20em; display: block; text-align:right; border: 1px solid green}
.frame label span {width: 20em; display: block; f... | [
{
"answer_id": 483922,
"author": "2ni",
"author_id": 59391,
"author_profile": "https://Stackoverflow.com/users/59391",
"pm_score": 2,
"selected": false,
"text": "<p>px is not an option as I do want to keep the design \"scalable\". I just found out, that it works with \"width: 100%\" for ... | 2009/01/27 | [
"https://Stackoverflow.com/questions/483898",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/59391/"
] | I have this code
```
<html>
<head>
<style type="text/css">
.frame {width: 50em; border: 1px solid black}
.frame label {width: 20em; display: block; text-align:right; border: 1px solid green}
.frame label span {width: 20em; display: block; font-size: .5em; border: 1px soli... | If you don’t declare a width for the `SPAN` element (or `width:100%`), its property `display:block` would already make sure that its width would be the full available width. |
483,900 | <p>I'm looking all over Google to find an example or tutorial about using F# to query an Entity data source.</p>
<p>Honestly I haven't found much. Have any of you had any luck ? </p>
| [
{
"answer_id": 485566,
"author": "Alexandre Brisebois",
"author_id": 18619,
"author_profile": "https://Stackoverflow.com/users/18619",
"pm_score": 3,
"selected": false,
"text": "<p>The following is an example I was able to pieces together from what i found on this <a href=\"http://blogge... | 2009/01/27 | [
"https://Stackoverflow.com/questions/483900",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18619/"
] | I'm looking all over Google to find an example or tutorial about using F# to query an Entity data source.
Honestly I haven't found much. Have any of you had any luck ? | Tons of examples in [here](https://github.com/dotnet/docs/blob/master/docs/fsharp/language-reference/query-expressions.md)
return a record type
```
type T1 = {F1: int32; F2: string}
let q = query {
for t in ctx.SomeTable do
select { F1 = t.F1
F2 = t.F2 }
};
```
return anonymous type, {| ... |}, the... |
483,903 | <p>I have a collection object that implements IList. Inside the collection I have used a List to collect the items.
Inside the PropertyGrid (at runtime), it binds properly and the Collection Editor opens. I can edit, and I can add items properly and I can catch these methods when they are used in the collection class.<... | [
{
"answer_id": 485566,
"author": "Alexandre Brisebois",
"author_id": 18619,
"author_profile": "https://Stackoverflow.com/users/18619",
"pm_score": 3,
"selected": false,
"text": "<p>The following is an example I was able to pieces together from what i found on this <a href=\"http://blogge... | 2009/01/27 | [
"https://Stackoverflow.com/questions/483903",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/55486/"
] | I have a collection object that implements IList. Inside the collection I have used a List to collect the items.
Inside the PropertyGrid (at runtime), it binds properly and the Collection Editor opens. I can edit, and I can add items properly and I can catch these methods when they are used in the collection class.
Ho... | Tons of examples in [here](https://github.com/dotnet/docs/blob/master/docs/fsharp/language-reference/query-expressions.md)
return a record type
```
type T1 = {F1: int32; F2: string}
let q = query {
for t in ctx.SomeTable do
select { F1 = t.F1
F2 = t.F2 }
};
```
return anonymous type, {| ... |}, the... |
483,940 | <p>I have a relatively simple select statement in a VB6 program that I have to maintain. (Suppress your natural tendency to shudder; I inherited the thing, I didn't write it.)</p>
<p>The statement is straightforward (reformatted for clarity):</p>
<pre><code>select distinct
b.ip_address
from
code_table a,
... | [
{
"answer_id": 483994,
"author": "Thorsten",
"author_id": 25320,
"author_profile": "https://Stackoverflow.com/users/25320",
"pm_score": 3,
"selected": true,
"text": "<p>Some random ideas:</p>\n\n<ul>\n<li><p>Are you sure you committed the changes that invalidate the ip-address? Can someo... | 2009/01/27 | [
"https://Stackoverflow.com/questions/483940",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47580/"
] | I have a relatively simple select statement in a VB6 program that I have to maintain. (Suppress your natural tendency to shudder; I inherited the thing, I didn't write it.)
The statement is straightforward (reformatted for clarity):
```
select distinct
b.ip_address
from
code_table a,
location b
where
... | Some random ideas:
* Are you sure you committed the changes that invalidate the ip-address? Can someone else (using another db connection / user) see the changed code\_status?
* Are you sure that the results are not modified after they are returned from the database?
* Are you sure that you are using the "same" databa... |
483,944 | <p>I've been going over and over this in my head, and I can't seem to come up with a good reason why C# closures are mutable. It just seems like a good way to get some unintended consequences if you aren't aware of exactly what's happening.</p>
<p>Maybe someone who is a little more knowledgeable can shed some light on... | [
{
"answer_id": 484053,
"author": "Amy B",
"author_id": 8155,
"author_profile": "https://Stackoverflow.com/users/8155",
"pm_score": 2,
"selected": false,
"text": "<p>Not all closures behave the same. There are <a href=\"http://en.wikipedia.org/wiki/Closure_(computer_science)#Differences_... | 2009/01/27 | [
"https://Stackoverflow.com/questions/483944",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12624/"
] | I've been going over and over this in my head, and I can't seem to come up with a good reason why C# closures are mutable. It just seems like a good way to get some unintended consequences if you aren't aware of exactly what's happening.
Maybe someone who is a little more knowledgeable can shed some light on why the d... | C# and JavaScript, as well as O'Caml and Haskell, and many other languages, have what is known as *lexical closures*. This means that inner functions can access the *names* of local variables in the enclosing functions, not just copies of the *values*. In languages with immutable symbols, of course, such as O'Caml or H... |
483,945 | <p>The following is the usual log function I utilize in alot of my vbscripts which I modify accordingly. I feel it writes too slow. I got 3 questions: </p>
<ol>
<li>Any ideaas on how to optimize this so it writes faster? </li>
<li>Would it be faster to store all text in a string first then run the function OutputTo... | [
{
"answer_id": 483993,
"author": "gkrogers",
"author_id": 54501,
"author_profile": "https://Stackoverflow.com/users/54501",
"pm_score": 0,
"selected": false,
"text": "<p>If you're doing a lot of small writes then refactoring the checks for FolderExists and FileExists out will help a bit.... | 2009/01/27 | [
"https://Stackoverflow.com/questions/483945",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18853/"
] | The following is the usual log function I utilize in alot of my vbscripts which I modify accordingly. I feel it writes too slow. I got 3 questions:
1. Any ideaas on how to optimize this so it writes faster?
2. Would it be faster to store all text in a string first then run the function OutputToLog or would it be fast... | I think you'd want to both create your FSO objects and open your log file outside the the OutputToLog function. It may not save much time, but why create objects, open and close files with every write?
Otherwise if you want to keep the functions as is, doing just one write should be quicker. |
483,952 | <p>I'm trying to figure out how to check if a string matches a regular expression, <strong>but I want to know if the entire string matches just once</strong>. Here's my code but it seems absurdly long</p>
<pre><code>def single_match(test_me, regex)
ret_val = false
test = regex.match(test_me)
if (test.length==1 &... | [
{
"answer_id": 483956,
"author": "Zach Langley",
"author_id": 45230,
"author_profile": "https://Stackoverflow.com/users/45230",
"pm_score": 2,
"selected": false,
"text": "<p>This?</p>\n\n<pre><code>def single_match(str, regex)\n str.match(regex).to_s == str\nend\n</code></pre>\n"
},
... | 2009/01/27 | [
"https://Stackoverflow.com/questions/483952",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8047/"
] | I'm trying to figure out how to check if a string matches a regular expression, **but I want to know if the entire string matches just once**. Here's my code but it seems absurdly long
```
def single_match(test_me, regex)
ret_val = false
test = regex.match(test_me)
if (test.length==1 && test[0].length == test_me... | You don't need to do this, your method can be replaced by using the regular expression of `/^[0-9]*$/`. The `^` tells it match start of a line and `$` tells it match end of the line. So it will match: start of line, 0 to any in range of 0 to 9, and finally end of line.
```
def is_int(test_me)
test_me =~ /^[0-9]*$/
e... |
483,963 | <p>I am using JBoss 4.0.4 GA, which has Tomcat Servlet Container 5.5.
I also have IIS 6.0 redirected to this JBoss. (via IIS tomcat connector, which is used as ISAPI filter in IIS).
All is working OK, configured the workers as described.</p>
<p>Here is a piece of workers.properties file of the connector:</p>
<pre><co... | [
{
"answer_id": 484086,
"author": "Eddie",
"author_id": 57752,
"author_profile": "https://Stackoverflow.com/users/57752",
"pm_score": 0,
"selected": false,
"text": "<p>The socket is probably being closed by IIS. The connection between JBoss and IIS <em>should be</em> irrelevant to the HT... | 2009/01/27 | [
"https://Stackoverflow.com/questions/483963",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/57735/"
] | I am using JBoss 4.0.4 GA, which has Tomcat Servlet Container 5.5.
I also have IIS 6.0 redirected to this JBoss. (via IIS tomcat connector, which is used as ISAPI filter in IIS).
All is working OK, configured the workers as described.
Here is a piece of workers.properties file of the connector:
```
#
# Defining a wor... | I filed a bug in Bugzilla for tomcat IIS redirector, and this is the answer I've got:
>
> *Up until 1.2.27 this was the behaviour of the IIS connector (IIS forces all
> ISAPI extensions to implement their own HTTP keep alive, and the IIS connector
> didn't do this).*
>
>
> *In 1.2.27 there's experimental, build-t... |
483,980 | <p>I'd like to be able to call "getProgram" on objects which have that method, without knowing which class they belong to. I know I should use an interface here, but I'm working with someone else's code and can't redesign the classes I'm working with. I thought BeanUtils.getProperty might help me, but it seems it only ... | [
{
"answer_id": 484005,
"author": "Kevin",
"author_id": 26620,
"author_profile": "https://Stackoverflow.com/users/26620",
"pm_score": 0,
"selected": false,
"text": "<p>See the <a href=\"http://java.sun.com/docs/books/tutorial/reflect/index.html\" rel=\"nofollow noreferrer\">Reflection API... | 2009/01/27 | [
"https://Stackoverflow.com/questions/483980",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44683/"
] | I'd like to be able to call "getProgram" on objects which have that method, without knowing which class they belong to. I know I should use an interface here, but I'm working with someone else's code and can't redesign the classes I'm working with. I thought BeanUtils.getProperty might help me, but it seems it only ret... | Presumably you have a finite number of classes implementing this method, and you can link to them directly. So you don't need reflection. Reflection is evil.
Say you have a set of classes with the method:
```
public class LibA { public Program getProgram() { return program; } ... };
public class LibB { public Program... |
484,036 | <p>I'm using VBScript (ASP Classic) and SQL Server; I'm trying to have a section on the website where you can see a count of products at certain price levels. Something like:</p>
<pre><code>$50 - $100 (4)
$100 - $500 (198)
$500 - $1000 (43)
</code></pre>
<p>For the love of me I cannot figure out a good way to do a q... | [
{
"answer_id": 484079,
"author": "Ray Booysen",
"author_id": 42124,
"author_profile": "https://Stackoverflow.com/users/42124",
"pm_score": 0,
"selected": false,
"text": "<p>You could use union queries</p>\n\n<pre><code>SELECT '100 - 200', COUNT(*) FROM Products\nWHERE Price >= 100 AND... | 2009/01/27 | [
"https://Stackoverflow.com/questions/484036",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40667/"
] | I'm using VBScript (ASP Classic) and SQL Server; I'm trying to have a section on the website where you can see a count of products at certain price levels. Something like:
```
$50 - $100 (4)
$100 - $500 (198)
$500 - $1000 (43)
```
For the love of me I cannot figure out a good way to do a query like this. I mean... I... | The most efficient way of doing this in SQL (I believe) is to use a `sum case` construct:
```
select sum(case when Price >= 50 and Price < 100 then 1 else 0 end) as 50to100,
sum(case when Price >= 100 and Price < 500 then 1 else 0 end) as 100to500,
sum(case when Price >= 500 and Price < 1000 then 1 el... |
484,040 | <p>I have the following problem : I have rows like </p>
<pre><code>ID CODE NAME .........
1 h1100h1 Cool example1 .........
2 h654441 Another cool1 .........
</code></pre>
<p>I would like to swap them retaining all old primary keys and constraints. Of course, I can easily solve this manua... | [
{
"answer_id": 484131,
"author": "SQLMenace",
"author_id": 740,
"author_profile": "https://Stackoverflow.com/users/740",
"pm_score": -1,
"selected": false,
"text": "<p>self join with an update is your only safe bet</p>\n"
},
{
"answer_id": 484787,
"author": "Tom H",
"auth... | 2009/01/27 | [
"https://Stackoverflow.com/questions/484040",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/50395/"
] | I have the following problem : I have rows like
```
ID CODE NAME .........
1 h1100h1 Cool example1 .........
2 h654441 Another cool1 .........
```
I would like to swap them retaining all old primary keys and constraints. Of course, I can easily solve this manually by updating the rows. ... | I haven't tested this, but I think it will work. I'm assuming that id is a single-column Primary Key. If that's not the case then you will need to adjust this code slightly to handle the PK.
```
UPDATE
T1
SET
column_1 = T2.column_1,
column_2 = T2.column_2,
...
FROM
dbo.My_Table T1
INNER JOIN d... |
484,048 | <p>I am trying to ensure that the text in my control derived from TextBox is always formatted as currency.</p>
<p>I have overridden the Text property like this.</p>
<pre><code> public override string Text
{
get
{
return base.Text;
}
set
{
... | [
{
"answer_id": 484057,
"author": "Jason Punyon",
"author_id": 6212,
"author_profile": "https://Stackoverflow.com/users/6212",
"pm_score": 5,
"selected": true,
"text": "<p>Instead of \"C\" put \"{0:c}\"</p>\n\n<p>For more string formatting problems go <a href=\"http://blog.stevex.net/inde... | 2009/01/27 | [
"https://Stackoverflow.com/questions/484048",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/450954/"
] | I am trying to ensure that the text in my control derived from TextBox is always formatted as currency.
I have overridden the Text property like this.
```
public override string Text
{
get
{
return base.Text;
}
set
{
double tempDol... | Instead of "C" put "{0:c}"
For more string formatting problems go [here](http://blog.stevex.net/index.php/string-formatting-in-csharp/) |
484,080 | <p>I know it is commonly used as a lock object, but is that really sufficient reason?
What is the meaning of</p>
<pre><code>object o = new object();
</code></pre>
<p>An non-abstract class is something that represents actual objects. "asdasdf" is a string. What actual instance can there be of "object" class? It doesn'... | [
{
"answer_id": 484097,
"author": "Vojislav Stojkovic",
"author_id": 58099,
"author_profile": "https://Stackoverflow.com/users/58099",
"pm_score": 4,
"selected": false,
"text": "<p>The easiest way to answer that question is to ask another one: is there any reason for the Object class to b... | 2009/01/27 | [
"https://Stackoverflow.com/questions/484080",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11236/"
] | I know it is commonly used as a lock object, but is that really sufficient reason?
What is the meaning of
```
object o = new object();
```
An non-abstract class is something that represents actual objects. "asdasdf" is a string. What actual instance can there be of "object" class? It doesn't make sense, OOP-wise. My... | Sometimes you just need an Object, and nothing else, such as when using a random reference type for things like implementing multithreading locks. Not making object abstract allows use in those situations. The Monitor.Enter and Monitor.Exit classes (which is the basis behind the "lock" keyword in C#) can acquire a lock... |
484,085 | <p>Pretty basic, I'm just curious how others might implement this algorithm and would like to see if there are any clever tricks to optimize the algorithm...I just had to implement this for a project that I am working on.</p>
<p>Given a string in CamelCase, how would you go about "spacifying" it?</p>
<p>e.g. given <s... | [
{
"answer_id": 484112,
"author": "Sean Bright",
"author_id": 21926,
"author_profile": "https://Stackoverflow.com/users/21926",
"pm_score": 4,
"selected": false,
"text": "<p>I can already sense the flames, but I like regex for this kind of stuff.</p>\n\n\n\n<pre class=\"lang-cs prettyprin... | 2009/01/27 | [
"https://Stackoverflow.com/questions/484085",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1638/"
] | Pretty basic, I'm just curious how others might implement this algorithm and would like to see if there are any clever tricks to optimize the algorithm...I just had to implement this for a project that I am working on.
Given a string in CamelCase, how would you go about "spacifying" it?
e.g. given **FooBarGork** I wa... | I can already sense the flames, but I like regex for this kind of stuff.
```cs
public static string UnCamelCase(string str)
{
return Regex.Replace(str, "([a-z])([A-Z])", "$1 $2");
}
```
(This may not be faster than your implementation, but to *me* it is more clear.)
And obviously, this would be even faster (at ... |
484,107 | <p>So, I'm doing a simple scan to get a list of all folders on a hard drive (c:\windows and c:\windows\system32 are considered separate entries). If I wanted to provide a progress bar for this 1-2 minute task, how would I do so? That is, I know how to make the progressbar but am not sure how to determine how much of ... | [
{
"answer_id": 484121,
"author": "Jacek Ławrynowicz",
"author_id": 43399,
"author_profile": "https://Stackoverflow.com/users/43399",
"pm_score": 2,
"selected": false,
"text": "<p>Just don't use it. Try something more appropriate like spinning animation or Kitts style bar: <a href=\"http:... | 2009/01/27 | [
"https://Stackoverflow.com/questions/484107",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18192/"
] | So, I'm doing a simple scan to get a list of all folders on a hard drive (c:\windows and c:\windows\system32 are considered separate entries). If I wanted to provide a progress bar for this 1-2 minute task, how would I do so? That is, I know how to make the progressbar but am not sure how to determine how much of the w... | If you can't recurse the directory structure since that would take as long as performing the task in the first place, the best you can do is guess how many folders there are. Seriously.
Perhaps you can use an algorithm based on past history (e.g. the last time I did this there were 150 directories in total when there... |
484,119 | <p>I've discovered this idiom recently, and I am wondering if there is something I am missing. I've never seen it used. Nearly all Java code I've worked with in the wild favors slurping data into a string or buffer, rather than something like this example (using HttpClient and XML APIs for example):</p>
<pre><code> ... | [
{
"answer_id": 484180,
"author": "kdgregory",
"author_id": 42126,
"author_profile": "https://Stackoverflow.com/users/42126",
"pm_score": 3,
"selected": false,
"text": "<p>In your example you're creating two threads to do the work that could be done by one. And introducing I/O delays into... | 2009/01/27 | [
"https://Stackoverflow.com/questions/484119",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28604/"
] | I've discovered this idiom recently, and I am wondering if there is something I am missing. I've never seen it used. Nearly all Java code I've worked with in the wild favors slurping data into a string or buffer, rather than something like this example (using HttpClient and XML APIs for example):
```
final LSOutpu... | From the [Javadocs](http://docs.oracle.com/javase/7/docs/api/java/io/PipedInputStream.html):
>
> Typically, data is read from a PipedInputStream object by one thread and data is written to the corresponding PipedOutputStream by some other thread. Attempting to use both objects from a single thread is not recommended,... |
484,143 | <p>I have enabled IIS 6's built in HTTP compression for the following types of files:</p>
<pre><code> HcFileExtensions="htm
html
txt
css
js"
HcScriptFileExtensions="asp
dll
exe
aspx
asmx
ascx"
</code></pre>
<p>I am unclear however if it's... | [
{
"answer_id": 487711,
"author": "Simon Johnson",
"author_id": 854,
"author_profile": "https://Stackoverflow.com/users/854",
"pm_score": 1,
"selected": false,
"text": "<p>This <a href=\"http://www.rosshawkins.net/archive/2006/10/08/webresource.axd.aspx\" rel=\"nofollow noreferrer\">artic... | 2009/01/27 | [
"https://Stackoverflow.com/questions/484143",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1989/"
] | I have enabled IIS 6's built in HTTP compression for the following types of files:
```
HcFileExtensions="htm
html
txt
css
js"
HcScriptFileExtensions="asp
dll
exe
aspx
asmx
ascx"
```
I am unclear however if it's appropriate to add the ax... | This [article](http://www.rosshawkins.net/archive/2006/10/08/webresource.axd.aspx) says there a potential problems using compression with the web resources axd extension. The author recommends *excluding* this extension from any compression. |
484,145 | <p>How can you check to see if a user can execute a stored procedure in MS SQL server?</p>
<p>I can see if the user has explicit execute permissions by connecting to the master database and executing:</p>
<pre><code>databasename..sp_helpprotect 'storedProcedureName', 'username'
</code></pre>
<p>however if the user i... | [
{
"answer_id": 484161,
"author": "Cade Roux",
"author_id": 18255,
"author_profile": "https://Stackoverflow.com/users/18255",
"pm_score": 5,
"selected": true,
"text": "<p><a href=\"http://msdn.microsoft.com/en-us/library/ms176097.aspx\" rel=\"nofollow noreferrer\"><code>fn_my_permissions<... | 2009/01/27 | [
"https://Stackoverflow.com/questions/484145",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/918/"
] | How can you check to see if a user can execute a stored procedure in MS SQL server?
I can see if the user has explicit execute permissions by connecting to the master database and executing:
```
databasename..sp_helpprotect 'storedProcedureName', 'username'
```
however if the user is a member of a role that has exe... | [`fn_my_permissions`](http://msdn.microsoft.com/en-us/library/ms176097.aspx) and [`HAS_PERMS_BY_NAME`](http://msdn.microsoft.com/en-us/library/ms189802.aspx) |
484,165 | <p>I have the following statement</p>
<pre><code>SELECT id, descr from mytable
</code></pre>
<p>which returns</p>
<p>1, 'Test1'<br>
4, 'Test4'<br>
6, 'Test6'<br>
8, 'Test8'<br>
22, 'Test22' </p>
<p>Now I want the display to Add a sequential character to the first 4 results...</p>
<p>'A', 1, 'Test1'<br>
'B', 4, '... | [
{
"answer_id": 484181,
"author": "Cade Roux",
"author_id": 18255,
"author_profile": "https://Stackoverflow.com/users/18255",
"pm_score": 3,
"selected": true,
"text": "<pre><code>SELECT CASE WHEN ROWNUMBER < 4\n THEN CHAR(65 + ROWNUMBER - 1)\n ELSE ''\n AS <... | 2009/01/27 | [
"https://Stackoverflow.com/questions/484165",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/59414/"
] | I have the following statement
```
SELECT id, descr from mytable
```
which returns
1, 'Test1'
4, 'Test4'
6, 'Test6'
8, 'Test8'
22, 'Test22'
Now I want the display to Add a sequential character to the first 4 results...
'A', 1, 'Test1'
'B', 4, 'Test4'
'C', 6, 'Test6'
'D', 8, 'Test8'
'',22... | ```
SELECT CASE WHEN ROWNUMBER < 4
THEN CHAR(65 + ROWNUMBER - 1)
ELSE ''
AS <WHATEVER>
,X.id
,X.descr
FROM (
SELECT ROW_NUMBER() OVER (ORDER BY <WHATEVER>) AS ROWNUMBER
,id
,descr
FROM mytable
) AS X
```
This in SQL Server 2005 and up.
In SQL Server ... |
484,169 | <p>Following on from <a href="https://stackoverflow.com/questions/482358/conditionally-selecting-a-version-of-jquery-depending-on-environment">this question</a> (that I asked) and <a href="https://stackoverflow.com/questions/482308/hosted-microsoft-ajax-on-cdn">this question</a> (that Simon asked), is there a CDN that ... | [
{
"answer_id": 484296,
"author": "bdukes",
"author_id": 2688,
"author_profile": "https://Stackoverflow.com/users/2688",
"pm_score": 2,
"selected": false,
"text": "<p>No, I don't believe there is any significant CDN like that. However, see <a href=\"https://stackoverflow.com/questions/48... | 2009/01/27 | [
"https://Stackoverflow.com/questions/484169",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1463/"
] | Following on from [this question](https://stackoverflow.com/questions/482358/conditionally-selecting-a-version-of-jquery-depending-on-environment) (that I asked) and [this question](https://stackoverflow.com/questions/482308/hosted-microsoft-ajax-on-cdn) (that Simon asked), is there a CDN that provides the jQuery scrip... | Yes, Microsoft has a CDN that hosts both jQuery and the vsdoc Intellisense for jQuery. You can learn more at <http://www.asp.net/ajax/cdn/> |
484,170 | <p>I am having trouble with debugging one of the problems that I am having in our website. This is the problem. I have a webpage that contains the photo of an employee and information related to the employee. When the user logins to our website, we are storing the details of the employee in session. I am setting the im... | [
{
"answer_id": 484296,
"author": "bdukes",
"author_id": 2688,
"author_profile": "https://Stackoverflow.com/users/2688",
"pm_score": 2,
"selected": false,
"text": "<p>No, I don't believe there is any significant CDN like that. However, see <a href=\"https://stackoverflow.com/questions/48... | 2009/01/27 | [
"https://Stackoverflow.com/questions/484170",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am having trouble with debugging one of the problems that I am having in our website. This is the problem. I have a webpage that contains the photo of an employee and information related to the employee. When the user logins to our website, we are storing the details of the employee in session. I am setting the image... | Yes, Microsoft has a CDN that hosts both jQuery and the vsdoc Intellisense for jQuery. You can learn more at <http://www.asp.net/ajax/cdn/> |
484,182 | <p>Here's the scenario: I have a multi threaded java web application which is running inside a servlet container.
The application is deployed multiple times inside the servlet container. There are multiple servlet containers
running on different servers.</p>
<p>Perhaps this graph makes it clear:</p>
<pre><code>server... | [
{
"answer_id": 484215,
"author": "Kevin",
"author_id": 26620,
"author_profile": "https://Stackoverflow.com/users/26620",
"pm_score": 2,
"selected": false,
"text": "<p>You've enumerated the possible solutions except the obvious one: <em>remove the dependency on that file</em> </p>\n\n<p>I... | 2009/01/27 | [
"https://Stackoverflow.com/questions/484182",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17428/"
] | Here's the scenario: I have a multi threaded java web application which is running inside a servlet container.
The application is deployed multiple times inside the servlet container. There are multiple servlet containers
running on different servers.
Perhaps this graph makes it clear:
```
server1
+- servlet containe... | If you only need to write the file rarely, how about writing the file under a temporary name and then using rename to make it "visible" to the readers?
This only works reliably with Unix file systems, though. On Windows, you will need to handle the case that some process has the file open (for reading). In this case, ... |
484,192 | <p>Is it possible to open 2 documents from an xQuery and do a join on them?</p>
| [
{
"answer_id": 484531,
"author": "Oliver Hallam",
"author_id": 19995,
"author_profile": "https://Stackoverflow.com/users/19995",
"pm_score": 0,
"selected": false,
"text": "<p>In XQuery if you write something like the following:</p>\n\n\n\n<pre class=\"lang-xquery prettyprint-override\"><... | 2009/01/27 | [
"https://Stackoverflow.com/questions/484192",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45005/"
] | Is it possible to open 2 documents from an xQuery and do a join on them? | **Yes, here is [an example](http://www.w3.org/TR/xquery/#id-example-applications) from the [XQuery spec](http://www.w3.org/TR/xquery).:**
"Joins, which combine data from multiple sources into a single result, are a very important type of query. In this section we will illustrate how several types of joins can be expre... |
484,212 | <p>I have a web service client application that connects to a 3rd party's web service. The 3rd party has updated their web service so now my client app fails with SOAP exceptions. Unfortunately, I can't simply update my app to work with the new web service since some of my users will still be using the old web servic... | [
{
"answer_id": 484243,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 2,
"selected": false,
"text": "<p>Make both sets of generated classes implement a common interface. This is pretty easy with partial types - you don't ... | 2009/01/27 | [
"https://Stackoverflow.com/questions/484212",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26302/"
] | I have a web service client application that connects to a 3rd party's web service. The 3rd party has updated their web service so now my client app fails with SOAP exceptions. Unfortunately, I can't simply update my app to work with the new web service since some of my users will still be using the old web service. So... | Make both sets of generated classes implement a common interface. This is pretty easy with partial types - you don't need to change the generated class at all, just create an appropriate interface and then a file with the same types in as the generated ones, saying that they implement the interface.
You then code to t... |
484,213 | <p>How can I replace <code>\r\n</code> in an <code>std::string</code>?</p>
| [
{
"answer_id": 484306,
"author": "Nemanja Trifunovic",
"author_id": 8899,
"author_profile": "https://Stackoverflow.com/users/8899",
"pm_score": 3,
"selected": false,
"text": "<p>See <a href=\"http://www.boost.org/doc/libs/1_37_0/doc/html/string_algo/usage.html#id3677520\" rel=\"noreferre... | 2009/01/27 | [
"https://Stackoverflow.com/questions/484213",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31207/"
] | How can I replace `\r\n` in an `std::string`? | Use this :
```
while ( str.find ("\r\n") != string::npos )
{
str.erase ( str.find ("\r\n"), 2 );
}
```
more efficient form is :
```
string::size_type pos = 0; // Must initialize
while ( ( pos = str.find ("\r\n",pos) ) != string::npos )
{
str.erase ( pos, 2 );
}
``` |
484,220 | <p>I was trying to write some code that would check if an item has some attributes , and to call them . I tried to do that with getattr , but the modifications wouldn't be permanent . I made a "dummy" class to check upon this .
Here is the code I used for the class :</p>
<pre><code>
class X: ... | [
{
"answer_id": 484227,
"author": "dF.",
"author_id": 3002,
"author_profile": "https://Stackoverflow.com/users/3002",
"pm_score": 4,
"selected": true,
"text": "<p>You need to do something like</p>\n\n<pre><code>class X: \n def __init__(self):\n ... | 2009/01/27 | [
"https://Stackoverflow.com/questions/484220",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31610/"
] | I was trying to write some code that would check if an item has some attributes , and to call them . I tried to do that with getattr , but the modifications wouldn't be permanent . I made a "dummy" class to check upon this .
Here is the code I used for the class :
```
class X: ... | You need to do something like
```
class X:
def __init__(self):
self._value = 90
def _get(self):
return self._value
def _set(self, value):
self._value = value
value = property(_get, _set)
```
Note that the "internal" variable has to have a ... |
484,236 | <p>EDIT: Scotty2012 and David Morton's answers don't work for me so I have put a bounty on this question. I think I need to change the type of the string to something else before passing it in.</p>
<p>I'm not much cop at P/Invoke and I'm struggling with declaring and calling <a href="http://msdn.microsoft.com/en-us/l... | [
{
"answer_id": 484359,
"author": "scottm",
"author_id": 53007,
"author_profile": "https://Stackoverflow.com/users/53007",
"pm_score": 2,
"selected": false,
"text": "<p>I think this should work in C# (I'm not running vista here so I can't check):</p>\n\n<pre><code>[DllImport(\"shell32.dll... | 2009/01/27 | [
"https://Stackoverflow.com/questions/484236",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29411/"
] | EDIT: Scotty2012 and David Morton's answers don't work for me so I have put a bounty on this question. I think I need to change the type of the string to something else before passing it in.
I'm not much cop at P/Invoke and I'm struggling with declaring and calling [SHSetKnownFolderPath](http://msdn.microsoft.com/en-u... | Try this code out. Sorry for the length, but it's all needed to properly PInvoke this particular function. It's a simple console application that includes a definition for both functions and an example usage of SHGetKnownFolderPath.
I went ahead and included the definitions for KNOWN\_FOLDER\_FLAG as well as a few de... |
484,237 | <p>I've written a custom event <code>MyWebErrorEvent</code> derived from <code>WebErrorEvent</code> located in the App_Code folder of my ASP.NET 2.0 Web Site Project. The class <code>MyWebErrorEvent</code> is not contained within a namespace. I've put the following into my web.config file:</p>
<pre><code><configu... | [
{
"answer_id": 486593,
"author": "a7drew",
"author_id": 4239,
"author_profile": "https://Stackoverflow.com/users/4239",
"pm_score": 0,
"selected": false,
"text": "<p>Does your type MyWebErrorEvent use a namespace? </p>\n\n<p>The error message looks like a typical missing namespace issue.... | 2009/01/27 | [
"https://Stackoverflow.com/questions/484237",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24898/"
] | I've written a custom event `MyWebErrorEvent` derived from `WebErrorEvent` located in the App\_Code folder of my ASP.NET 2.0 Web Site Project. The class `MyWebErrorEvent` is not contained within a namespace. I've put the following into my web.config file:
```
<configuration>
<system.web>
<healthMonitoring>
... | (Just guessing here...)
For Web Sites, classes in App\_Code do not get compiled until runtime. Your Web.config is being compiled before MyWebErrorEvent has had a chance to be dynamically compiled. Your best bet is to create a class library separately from the web site and reference the project from your web site. Anot... |
484,242 | <p>Edited for better clarification: </p>
<hr>
<p>Added 1/28/09: I over simplified the code to make it easy to explain, but the select statements are very long and complicated, and the second one is dependent on the first meaning after the first cursor is done and looped through and the inserts are created the second... | [
{
"answer_id": 484954,
"author": "Thomas Jones-Low",
"author_id": 23030,
"author_profile": "https://Stackoverflow.com/users/23030",
"pm_score": 0,
"selected": false,
"text": "<p>So you are going to have the following select statements: </p>\n\n<pre><code>select some_info, other_info from... | 2009/01/27 | [
"https://Stackoverflow.com/questions/484242",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Edited for better clarification:
---
Added 1/28/09: I over simplified the code to make it easy to explain, but the select statements are very long and complicated, and the second one is dependent on the first meaning after the first cursor is done and looped through and the inserts are created the second select actu... | Or Just do:
```
cursor c1 is
select info_a, info_b from table_x where info_g IN (77, 88) UNION ALL
select info-a, info_b from table_y where info_j IN (88, 99);
Begin
For r in c1 loop
insert into fun_table (good_info, boring_info) values (r.info_a, r.info-b);
end loop;
commit;
END;
``` |
484,261 | <p>Well, I guess this day had to come.</p>
<p>My client's website has been compromised and blacklisted by Google. When you load the main page this javascript gets automatically added to the bottom of the document:</p>
<pre><code><script type="text/javascript">var str='google-analytics.com';var str2='6b756c6b617... | [
{
"answer_id": 484283,
"author": "Daniel Schaffer",
"author_id": 2596,
"author_profile": "https://Stackoverflow.com/users/2596",
"pm_score": 4,
"selected": true,
"text": "<p>A rogue HTTP Module (in IIS), or whatever the equivalent is for apache could prepend, append, or perhaps even modi... | 2009/01/27 | [
"https://Stackoverflow.com/questions/484261",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16417/"
] | Well, I guess this day had to come.
My client's website has been compromised and blacklisted by Google. When you load the main page this javascript gets automatically added to the bottom of the document:
```
<script type="text/javascript">var str='google-analytics.com';var str2='6b756c6b61726e696f6f37312e636f6d';str4... | A rogue HTTP Module (in IIS), or whatever the equivalent is for apache could prepend, append, or perhaps even modify content for any HTTP request, even for static files. This would suggest that the server itself has been compromised.
EDIT: If you let us know what type of web server you're using, we'll be able to make ... |
484,270 | <p>I would like to add two events to my items.</p>
<p>One for the "background" of the document: <code>$(document).click(function() {do()});</code></p>
<p>One for the divs in the document: <code>$("div").click(function() {do2()});</code></p>
<p>The problem is that when I click on a <code>div</code>, both functions, <... | [
{
"answer_id": 484340,
"author": "andyk",
"author_id": 26721,
"author_profile": "https://Stackoverflow.com/users/26721",
"pm_score": -1,
"selected": false,
"text": "<p>you could try excluding the <code>div</code>s from the document selector.</p>\n\n<pre><code>$(document:not(div)).click(f... | 2009/01/27 | [
"https://Stackoverflow.com/questions/484270",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I would like to add two events to my items.
One for the "background" of the document: `$(document).click(function() {do()});`
One for the divs in the document: `$("div").click(function() {do2()});`
The problem is that when I click on a `div`, both functions, `do` and `do2` are called.
How can I thus tell to call `d... | The terms you're looking for here are Event Propagation or Event Bubbling.
The event handling in "modern" browsers (which is the model most libraries hook into) works by bubbling up the document tree. What that means is if you have html document structure like this
```
<body>
<div>
<ul>
<li>Fo... |
484,278 | <p>How do I initiate a Windows XP user Log Off from a C# app? The action of my app should produce the same result as clicking "Log Off" in XP start menu -- it's fine if the system asks for a confirmation.</p>
<p>Is there a .Net or an unmanaged API for this?</p>
| [
{
"answer_id": 484303,
"author": "Kev",
"author_id": 419,
"author_profile": "https://Stackoverflow.com/users/419",
"pm_score": 6,
"selected": true,
"text": "<p>You could P/Invoke ExitWindowsEx:</p>\n\n<blockquote>\n <p><a href=\"http://www.pinvoke.net/default.aspx/user32/ExitWindowsEx.h... | 2009/01/27 | [
"https://Stackoverflow.com/questions/484278",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/838/"
] | How do I initiate a Windows XP user Log Off from a C# app? The action of my app should produce the same result as clicking "Log Off" in XP start menu -- it's fine if the system asks for a confirmation.
Is there a .Net or an unmanaged API for this? | You could P/Invoke ExitWindowsEx:
>
> <http://www.pinvoke.net/default.aspx/user32/ExitWindowsEx.html>
>
>
>
Pulling it all together:
```
using System.Runtime.InteropServices;
class Class1
{
[DllImport("user32.dll")]
static extern bool ExitWindowsEx(uint uFlags, uint dwReason);
[STAThread]
static... |
484,288 | <p>I need to add linked buttons in the code-behind based on a DataSet that is populated. How do I do that? Do I create a placeholder? I could be adding none, one, or many different linked buttons. I lalso need to have each linked button call a method in the code-behind. How would I wire that up when I add the butt... | [
{
"answer_id": 484305,
"author": "TStamper",
"author_id": 39809,
"author_profile": "https://Stackoverflow.com/users/39809",
"pm_score": 3,
"selected": true,
"text": "<p>Since you are dynamically created the link buttons you should create a panel or placeholder on your client side so you ... | 2009/01/27 | [
"https://Stackoverflow.com/questions/484288",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/54064/"
] | I need to add linked buttons in the code-behind based on a DataSet that is populated. How do I do that? Do I create a placeholder? I could be adding none, one, or many different linked buttons. I lalso need to have each linked button call a method in the code-behind. How would I wire that up when I add the button?
Tha... | Since you are dynamically created the link buttons you should create a panel or placeholder on your client side so you can append your links to the panel so you would know where they will appear like:
```
<asp:PlaceHolder ID="Linkholder" Runat="server"></asp:PlaceHolder>
```
and in your code behind
```
Priv... |
484,293 | <p>I can't figure out how I can implement an Icon View in the WPF ListView (a view similar to the Windows Explorer). Searching on google I only found informations about implementing the GridView but no clues about the Icon View. I'm not talking about <code>System.Windows.Form.ListView</code> but <code>System.Windows.Co... | [
{
"answer_id": 484950,
"author": "Tanveer Badar",
"author_id": 59081,
"author_profile": "https://Stackoverflow.com/users/59081",
"pm_score": 3,
"selected": false,
"text": "<p>Just off the top of my head, have you tried this?</p>\n\n<pre><code><Style TargetType=\"ListBox\">\n <S... | 2009/01/27 | [
"https://Stackoverflow.com/questions/484293",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/57528/"
] | I can't figure out how I can implement an Icon View in the WPF ListView (a view similar to the Windows Explorer). Searching on google I only found informations about implementing the GridView but no clues about the Icon View. I'm not talking about `System.Windows.Form.ListView` but `System.Windows.Controls.ListView`.
... | Same as Tanveer Badar's answer, but with a WrapPanel instead of a UniformGrid. Set the following in your listbox:
```
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
ScrollViewer.VerticalScrollBarVisibility="Auto"
```
to force the WrapPanel to wrap. |
484,295 | <p>I'm writing a compression library as a little side project, and I'm far enough along (My library can extract any standard gzip file, as well as produce compliant (but certainly not yet optimal) gzip output) that it's time to figure out a meaningful block termination strategy. Currently, I just cut the blocks off af... | [
{
"answer_id": 484799,
"author": "ShuggyCoUk",
"author_id": 12748,
"author_profile": "https://Stackoverflow.com/users/12748",
"pm_score": 3,
"selected": true,
"text": "<p>As a suggestion to get you going.</p>\n\n<p>A speculative look ahead with a buffer of sufficient size for the indicat... | 2009/01/27 | [
"https://Stackoverflow.com/questions/484295",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17784/"
] | I'm writing a compression library as a little side project, and I'm far enough along (My library can extract any standard gzip file, as well as produce compliant (but certainly not yet optimal) gzip output) that it's time to figure out a meaningful block termination strategy. Currently, I just cut the blocks off after ... | As a suggestion to get you going.
A speculative look ahead with a buffer of sufficient size for the indication of superior compression to be worth the change.
This changes the streaming behaviour (more data is required to be input before output occurs) and significantly complicates operations like flush. It is also a... |
484,326 | <p>Let's say I've got a control and I want to prevent it from being edited.</p>
<p>Setting the Enabled property of the control to False will work but the control appearance will change accordingly, usually to a difficult to read black over gray font. When readability is still important, this is a real problem.</p>
<p... | [
{
"answer_id": 484334,
"author": "Orion Adrian",
"author_id": 7756,
"author_profile": "https://Stackoverflow.com/users/7756",
"pm_score": -1,
"selected": false,
"text": "<p>Some controls can be set to ReadOnly which leaves them enabled, but unable to be changed. This may be what you're l... | 2009/01/27 | [
"https://Stackoverflow.com/questions/484326",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47341/"
] | Let's say I've got a control and I want to prevent it from being edited.
Setting the Enabled property of the control to False will work but the control appearance will change accordingly, usually to a difficult to read black over gray font. When readability is still important, this is a real problem.
For a TextBox, t... | There is an argument that interfering with standard Windows behaviour is confusing for the user, but that aside I have seen this done before, although more commonly in C++. You can subclass the control and handle paint messages yourself. When the control's enabled just delegate the drawing to the base class. When the c... |
484,357 | <p>I am attempting to copy the members of a struct containing a mixture of ints, char's and arrays of chars into a byte array to send to a serial line. So far I have</p>
<pre><code>struct msg_on_send
{
char descriptor_msg[5];
int address;
char space;
char cmdmsg[5];
char CR;
char LF;
};
void... | [
{
"answer_id": 484419,
"author": "Quassnoi",
"author_id": 55159,
"author_profile": "https://Stackoverflow.com/users/55159",
"pm_score": 0,
"selected": false,
"text": "<p>Your <code>struct</code> here is just array of bytes, it contains no pointers that point out of it.</p>\n\n<p>Member-t... | 2009/01/27 | [
"https://Stackoverflow.com/questions/484357",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/59427/"
] | I am attempting to copy the members of a struct containing a mixture of ints, char's and arrays of chars into a byte array to send to a serial line. So far I have
```
struct msg_on_send
{
char descriptor_msg[5];
int address;
char space;
char cmdmsg[5];
char CR;
char LF;
};
void switch_output_... | Sorry, I didn't see your comment until just now.
The code below compiles on Linux just fine, so I hope it works for you.
printf() is printing in hex, you will get 2 characters for each byte.
```
#include <stdio.h>
struct msg_on_send
{
char descriptor_msg[5];
int address;
char space;
char cmdmsg[5];
char CR;
cha... |
484,375 | <p>We try and embed a what string within binary objects so that we can see the version number for an executable or shared library that has been deployed. Typically we embed standard CVS Id information in this what string. For example, we might embed:</p>
<pre><code>const char cvsid[] = "@(#)OUR_TEAM_staging_remap_$Rev... | [
{
"answer_id": 484384,
"author": "Serafina Brocious",
"author_id": 4977,
"author_profile": "https://Stackoverflow.com/users/4977",
"pm_score": 2,
"selected": false,
"text": "<p>Typically this doesn't happen because extraneous strings have little cost and can be useful in cases like this,... | 2009/01/27 | [
"https://Stackoverflow.com/questions/484375",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2974/"
] | We try and embed a what string within binary objects so that we can see the version number for an executable or shared library that has been deployed. Typically we embed standard CVS Id information in this what string. For example, we might embed:
```
const char cvsid[] = "@(#)OUR_TEAM_staging_remap_$Revision: 1.30 $ ... | Until recently (I spotted the problem in mid-2005), it was possible to use:
```
static const char sccs[] = "@(#)%W% %E%";
```
or something similar in source code and GCC and most other compilers would not optimize it away. Starting with the release of GCC from about that time (probably GCC 4.0.x, originating from Ap... |
484,376 | <p>Using the .NET framework, I'm trying to replace double slash characters in a string with a single slash, but it seems to be removing an extra character and I don't know why.</p>
<p>I have a string:</p>
<pre><code>http://localhost:4170/RCRSelfRegistration//Default.aspx
</code></pre>
<p>My regex is:</p>
<pre><code... | [
{
"answer_id": 484395,
"author": "Douglas Leeder",
"author_id": 3978,
"author_profile": "https://Stackoverflow.com/users/3978",
"pm_score": 3,
"selected": false,
"text": "<p><code>[^(://|:\\\\\\\\)]</code> doesn't work the way you think it does.</p>\n\n<p><code>[]</code> is a character r... | 2009/01/27 | [
"https://Stackoverflow.com/questions/484376",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9266/"
] | Using the .NET framework, I'm trying to replace double slash characters in a string with a single slash, but it seems to be removing an extra character and I don't know why.
I have a string:
```
http://localhost:4170/RCRSelfRegistration//Default.aspx
```
My regex is:
```
[^(://|:\\\\)](\\\\|//|\\/|/\\)
```
And t... | The first part of your regex "[^(://|:\\)]" matches any character which is not "(:/|\" (as tomalak points out, the negset matches all the characters within it, with no futher processing logic), which includes the "n" immediately before "//default.aspx" - it's not a zero-width assertion.
What you probably want to do is... |
484,381 | <p>I discovered that one of the tables of a legacy db I'm working on has a colum named "Order".
Unfortunately I cannot change the DB structure.<br>
My Fluent NHibernate class looks like</p>
<pre><code> public class SiteMap : AutoMap<Site>
{
public SiteMap() {
WithTable("Sites");
Id(x => x.... | [
{
"answer_id": 484399,
"author": "Ryan Rinaldi",
"author_id": 2278,
"author_profile": "https://Stackoverflow.com/users/2278",
"pm_score": 4,
"selected": true,
"text": "<p>Try putting Order in back ticks: ``Order<code></code>. Since FluentNH is generating HBM files at runtime I imagine t... | 2009/01/27 | [
"https://Stackoverflow.com/questions/484381",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1929/"
] | I discovered that one of the tables of a legacy db I'm working on has a colum named "Order".
Unfortunately I cannot change the DB structure.
My Fluent NHibernate class looks like
```
public class SiteMap : AutoMap<Site>
{
public SiteMap() {
WithTable("Sites");
Id(x => x.ID, "Id")
.W... | Try putting Order in back ticks: ``Order. Since FluentNH is generating HBM files at runtime I imagine that should fix the problem. |
484,389 | <p>I'm creating a staticbox and a staticboxsizer in a vertical sizer. Everything works fine for me, but not on the customer's environment. </p>
<p>Everything in the staticbox is displayed, but labels. snippet below shows how i construct the staticboxsizer. </p>
<pre><code> sbox2 = wx.StaticBox(self, wx.ID_ANY, 'CH... | [
{
"answer_id": 484399,
"author": "Ryan Rinaldi",
"author_id": 2278,
"author_profile": "https://Stackoverflow.com/users/2278",
"pm_score": 4,
"selected": true,
"text": "<p>Try putting Order in back ticks: ``Order<code></code>. Since FluentNH is generating HBM files at runtime I imagine t... | 2009/01/27 | [
"https://Stackoverflow.com/questions/484389",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37491/"
] | I'm creating a staticbox and a staticboxsizer in a vertical sizer. Everything works fine for me, but not on the customer's environment.
Everything in the staticbox is displayed, but labels. snippet below shows how i construct the staticboxsizer.
```
sbox2 = wx.StaticBox(self, wx.ID_ANY, 'CH1 Only')
sboxsize... | Try putting Order in back ticks: ``Order. Since FluentNH is generating HBM files at runtime I imagine that should fix the problem. |
484,392 | <p>I am trying to read data off of a Windows serial port through Java. I have the javax.comm libraries and am able to get some data but not correct data. When I read the port into a byte array and convert it to text I get a series of characters but no real text string. I have tried to specify the byte array as being... | [
{
"answer_id": 484443,
"author": "erickson",
"author_id": 3474,
"author_profile": "https://Stackoverflow.com/users/3474",
"pm_score": 1,
"selected": false,
"text": "<p>It's likely that the connected device doesn't use a text protocol. Many devices use a binary message format that may hav... | 2009/01/27 | [
"https://Stackoverflow.com/questions/484392",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2164/"
] | I am trying to read data off of a Windows serial port through Java. I have the javax.comm libraries and am able to get some data but not correct data. When I read the port into a byte array and convert it to text I get a series of characters but no real text string. I have tried to specify the byte array as being both ... | I can't tell from your code, but it looks like you're using `java.io.InputStream` to read the object. You should use either `java.io.BufferedReader` or `java.io.InputSreamReader`.
There are many ways to do this, but this is what we use:
```
javax.comm.SerialPort port = ...{initialize your serial port}
BufferedReader... |
484,394 | <p>I have a .Net framework 1.1 Windows service that works on one server, but on another the OnStart method is not being called. I have a Trace statement as the first line in the OnStart override and it's not being executed. No exception are thrown and the Windows Service control manager thinks the service has started... | [
{
"answer_id": 484443,
"author": "erickson",
"author_id": 3474,
"author_profile": "https://Stackoverflow.com/users/3474",
"pm_score": 1,
"selected": false,
"text": "<p>It's likely that the connected device doesn't use a text protocol. Many devices use a binary message format that may hav... | 2009/01/27 | [
"https://Stackoverflow.com/questions/484394",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1752/"
] | I have a .Net framework 1.1 Windows service that works on one server, but on another the OnStart method is not being called. I have a Trace statement as the first line in the OnStart override and it's not being executed. No exception are thrown and the Windows Service control manager thinks the service has started corr... | I can't tell from your code, but it looks like you're using `java.io.InputStream` to read the object. You should use either `java.io.BufferedReader` or `java.io.InputSreamReader`.
There are many ways to do this, but this is what we use:
```
javax.comm.SerialPort port = ...{initialize your serial port}
BufferedReader... |
484,397 | <p>I have a select html tag with country calling codes.</p>
<pre><code><select name="countryCallingCode" id="countryCallingCode">
<option value="1"><span class="name">Afghanistan</span><span class="code">+93</span></option>
<option value="2"><span class="name"... | [
{
"answer_id": 484435,
"author": "tonyriddle",
"author_id": 51890,
"author_profile": "https://Stackoverflow.com/users/51890",
"pm_score": 3,
"selected": false,
"text": "<p>I faced this issue once and what I did was format the text in a monospaced font and fill the middle with spaces to s... | 2009/01/27 | [
"https://Stackoverflow.com/questions/484397",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2138/"
] | I have a select html tag with country calling codes.
```
<select name="countryCallingCode" id="countryCallingCode">
<option value="1"><span class="name">Afghanistan</span><span class="code">+93</span></option>
<option value="2"><span class="name">Albania</span><span class="code">+355</span></option>
<optio... | I faced this issue once and what I did was format the text in a monospaced font and fill the middle with spaces to seperate the text and make each row an even number of characters. |
484,457 | <p>Ok I've got a weird one, I have a SharePoint WebPart in WSS 3.0 right now that's querying Yahoo Traffic's REST interface using VB.NET and the HttpWebRequest object. However I kept getting an error message from Yahoo that was saying I'm unauthorized, upon further examination, I noticed it's passing the following URL... | [
{
"answer_id": 484465,
"author": "Grant",
"author_id": 30,
"author_profile": "https://Stackoverflow.com/users/30",
"pm_score": 3,
"selected": false,
"text": "<p>Dynamically Linked Library.</p>\n\n<p>To give you an example, If you have someone else's DLL loaded into you application you ca... | 2009/01/27 | [
"https://Stackoverflow.com/questions/484457",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16868/"
] | Ok I've got a weird one, I have a SharePoint WebPart in WSS 3.0 right now that's querying Yahoo Traffic's REST interface using VB.NET and the HttpWebRequest object. However I kept getting an error message from Yahoo that was saying I'm unauthorized, upon further examination, I noticed it's passing the following URL to ... | A DLL is a dynamic link library. It is a collection of code and/or data, which may be used by several applications (or other libraries/modules).
So for instance common methods to process files, work with GUI components etc. are made available in libraries so several applications may use the same functionality. This n... |
484,462 | <p>Is there a difference in <code>++i</code> and <code>i++</code> in a <code>for</code> loop? Is it simply a syntax thing?</p>
| [
{
"answer_id": 484474,
"author": "Serafina Brocious",
"author_id": 4977,
"author_profile": "https://Stackoverflow.com/users/4977",
"pm_score": 4,
"selected": false,
"text": "<p>One (++i) is preincrement, one (i++) is postincrement. The difference is in what value is immediately returned... | 2009/01/27 | [
"https://Stackoverflow.com/questions/484462",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32484/"
] | Is there a difference in `++i` and `i++` in a `for` loop? Is it simply a syntax thing? | **a++ is known as postfix.**
add 1 to a, returns the old value.
**++a is known as prefix.**
add 1 to a, returns the new value.
C#:
```
string[] items = {"a","b","c","d"};
int i = 0;
foreach (string item in items)
{
Console.WriteLine(++i);
}
Console.WriteLine("");
i = 0;
foreach (string item in items)
{
Co... |
484,463 | <p>Im working on a project in MVC and have enjoyed learning about it. There are a few growing pains but once you figure them out it's not bad. One thing that is really simple in the WebForms world is maintaining the scroll position on a page. All you do is set the MaintainScrollPositionOnPostback property to true. ... | [
{
"answer_id": 484555,
"author": "mapache",
"author_id": 41422,
"author_profile": "https://Stackoverflow.com/users/41422",
"pm_score": 2,
"selected": false,
"text": "<p>My own workaround is using some info in the <code>ViewData</code> to know what area must be shown in the backnavigation... | 2009/01/27 | [
"https://Stackoverflow.com/questions/484463",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47576/"
] | Im working on a project in MVC and have enjoyed learning about it. There are a few growing pains but once you figure them out it's not bad. One thing that is really simple in the WebForms world is maintaining the scroll position on a page. All you do is set the MaintainScrollPositionOnPostback property to true. However... | The way MaintainScrollPositionOnPostback works is that it has a pair of hidden fields:
\_\_SCROLLPOSITIONX and \_\_SCROLLPOSITIONY
On a postback, it sets these,
```js
function WebForm_GetScrollY() {
if (__nonMSDOMBrowser) {
return window.pageYOffset;
}
else {
if (document.documentElement &... |
484,466 | <p>I had this idea of creating a count down timer, like 01:02, on the screen (fullsize).
One thing is that I really don't have a clue on how to start. </p>
<p>I do know basic c/c++, win32 api and a bit of gdi.</p>
<p>Anyone have any pointers on how to start this? My program would be like making the computer into a bi... | [
{
"answer_id": 484530,
"author": "Joe Soul-bringer",
"author_id": 56279,
"author_profile": "https://Stackoverflow.com/users/56279",
"pm_score": 0,
"selected": false,
"text": "<p>Create a timer, have your application respond to the timer event by sending a paint message to itself. Be sure... | 2009/01/27 | [
"https://Stackoverflow.com/questions/484466",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8715/"
] | I had this idea of creating a count down timer, like 01:02, on the screen (fullsize).
One thing is that I really don't have a clue on how to start.
I do know basic c/c++, win32 api and a bit of gdi.
Anyone have any pointers on how to start this? My program would be like making the computer into a big stopwatch (but ... | If you have some experience with windows message processing and the Win32 API, this should get you started.
```
LRESULT WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
RECT r;
char szBuffer[200];
static int count = 120;
int seconds = 0;
int minutes = 0;
... |
484,482 | <p>Is it possible to conditionally set a dependency on a gem at install time? Here's my situation which will hopefully clarify the question.</p>
<p>There is a gem I maintain that depends on the json gem. However, I frequently use jruby which has a port of the json gem that's called json-jruby. To work around this I ha... | [
{
"answer_id": 484530,
"author": "Joe Soul-bringer",
"author_id": 56279,
"author_profile": "https://Stackoverflow.com/users/56279",
"pm_score": 0,
"selected": false,
"text": "<p>Create a timer, have your application respond to the timer event by sending a paint message to itself. Be sure... | 2009/01/27 | [
"https://Stackoverflow.com/questions/484482",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46505/"
] | Is it possible to conditionally set a dependency on a gem at install time? Here's my situation which will hopefully clarify the question.
There is a gem I maintain that depends on the json gem. However, I frequently use jruby which has a port of the json gem that's called json-jruby. To work around this I have to buil... | If you have some experience with windows message processing and the Win32 API, this should get you started.
```
LRESULT WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
RECT r;
char szBuffer[200];
static int count = 120;
int seconds = 0;
int minutes = 0;
... |
484,489 | <p>Say I have a .NET class like so:</p>
<pre><code>public class Person {
public string Name { get; set; }
public int Id { get; set; }
}
</code></pre>
<p>Visual Studio has a nifty refactoring tool called Extract Interface that will extract an <code>IPerson</code> interface, and have <code>Person</code> impleme... | [
{
"answer_id": 484589,
"author": "joel.neely",
"author_id": 3525,
"author_profile": "https://Stackoverflow.com/users/3525",
"pm_score": 4,
"selected": true,
"text": "<p>In a word: reflection.</p>\n\n<p>It's quite feasible to write a bit of code that takes a class object, reflects over it... | 2009/01/27 | [
"https://Stackoverflow.com/questions/484489",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/736/"
] | Say I have a .NET class like so:
```
public class Person {
public string Name { get; set; }
public int Id { get; set; }
}
```
Visual Studio has a nifty refactoring tool called Extract Interface that will extract an `IPerson` interface, and have `Person` implement it. Is there a way to do that programmaticall... | In a word: reflection.
It's quite feasible to write a bit of code that takes a class object, reflects over its public methods, and writes a text file that's the definition of an interface that the class implements.
However, it's a bit more work to decide WHICH methods belong on an interface (e.g. a class may implemen... |
484,499 | <p>I have Apache/SVN running on Windows Server 2003 with authentication via LDAP/Active Directory and a flat-file.</p>
<p>It's working great except that <em>any</em> LDAP user can access everything. I'd like to be able to limit SVN repositories by user or group.</p>
<p>Ideally, I'd get to something like this:</p>
<p... | [
{
"answer_id": 484721,
"author": "Michael Haren",
"author_id": 29,
"author_profile": "https://Stackoverflow.com/users/29",
"pm_score": 4,
"selected": true,
"text": "<p>This was actually a lot easier than I thought it would be. I added this to my location:</p>\n\n<pre><code><Location /... | 2009/01/27 | [
"https://Stackoverflow.com/questions/484499",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29/"
] | I have Apache/SVN running on Windows Server 2003 with authentication via LDAP/Active Directory and a flat-file.
It's working great except that *any* LDAP user can access everything. I'd like to be able to limit SVN repositories by user or group.
Ideally, I'd get to something like this:
```
<Location /svn/repo1>
# ... | This was actually a lot easier than I thought it would be. I added this to my location:
```
<Location /svn>
...
AuthzSVNAccessFile "conf/svn-authz.txt"
</Location
```
In that file, I just specified normal SVN permissions (the system doesn't seem to distinguish between file users and LDAP users at this point):
`... |
484,502 | <p>I am trying to create a "save webpage as bitmap"-function on a website and i have some problems rendering the text in the correct size on the server side.</p>
<p>The fontsize settings for the text on the client is:</p>
<pre><code>.textDiv
{
font-family: Verdana;
font-size:16px;
}
</code></pre>
<p>If i try... | [
{
"answer_id": 484542,
"author": "Nick Berardi",
"author_id": 17,
"author_profile": "https://Stackoverflow.com/users/17",
"pm_score": 0,
"selected": false,
"text": "<p>I am slightly confused because you are using two different units of measure in your question. I will try to explain bot... | 2009/01/27 | [
"https://Stackoverflow.com/questions/484502",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am trying to create a "save webpage as bitmap"-function on a website and i have some problems rendering the text in the correct size on the server side.
The fontsize settings for the text on the client is:
```
.textDiv
{
font-family: Verdana;
font-size:16px;
}
```
If i try to render this on the server wit... | Actually, the docs say "em-size", not "em-point" ("The em-size, in points, of the new font"). It's asking you to specify the size in points. There are 72 points per inch. You need to figure out the DPI of the user's screen and the DPI of the canvas you're drawing on and multiply the 16px size by the difference in that ... |
484,511 | <ol>
<li>I have a method that uses a connection (e.g. a method that downloads a page).</li>
<li>I have to execute this method multiple times (e.g. download 1000 pages).</li>
<li>Doing it the synchronous and sequential way takes a long time.</li>
<li>I have limited resources ( 8 max threads and/or 50 max simultaneous co... | [
{
"answer_id": 484534,
"author": "Kev",
"author_id": 419,
"author_profile": "https://Stackoverflow.com/users/419",
"pm_score": 2,
"selected": false,
"text": "<p>You could use the .NET <a href=\"http://msdn.microsoft.com/en-us/library/system.threading.threadpool.aspx\" rel=\"nofollow nore... | 2009/01/27 | [
"https://Stackoverflow.com/questions/484511",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48465/"
] | 1. I have a method that uses a connection (e.g. a method that downloads a page).
2. I have to execute this method multiple times (e.g. download 1000 pages).
3. Doing it the synchronous and sequential way takes a long time.
4. I have limited resources ( 8 max threads and/or 50 max simultaneous connections )
5. I want to... | Can you give more information why Parallel Linq won't work?
My point of view, your task is best suit with PLinq. If you run on 8 cores machine, PLinq will split to 8 tasks, and queue all remaining tasks for you.
Here is draft code,
```
PagesToDownload.AsParallel().ForAll(DownloadMethodWithLimitConnections);
```
I ... |
484,514 | <p>Trying to figure out an equation to get the current group a page would be in if they were grouped like below.</p>
<p>Variables:</p>
<pre><code>PageSize = 5
PageIndex = 21
GroupSize = 5
TotalItems = 1000
CurrentPage = PageIndex + 1
</code></pre>
<p>Find:</p>
<pre><code>**CurrentGroup = ?**
</code></pre>
<p>If th... | [
{
"answer_id": 484574,
"author": "Borzio",
"author_id": 36215,
"author_profile": "https://Stackoverflow.com/users/36215",
"pm_score": 1,
"selected": false,
"text": "<p>I think this is what you were asking -- </p>\n\n<p>Assumes integer math:</p>\n\n<pre><code> page = ( item / ItemsPerPage... | 2009/01/27 | [
"https://Stackoverflow.com/questions/484514",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/57905/"
] | Trying to figure out an equation to get the current group a page would be in if they were grouped like below.
Variables:
```
PageSize = 5
PageIndex = 21
GroupSize = 5
TotalItems = 1000
CurrentPage = PageIndex + 1
```
Find:
```
**CurrentGroup = ?**
```
If there are 1000 items and you have a group size of 5 then t... | Formula
```
1+floor((CurrentPage-1)/GroupSize)
```
Test
```
1 -> 1
..
5 -> 1
6 -> 2
..
9 -> 2
..
22 -> 5
``` |
484,537 | <p>So here is the deal. I want to call a class and pass a value to it so it can be used inside that class in all the various functions ect. ect. How would I go about doing that?</p>
<p>Thanks,
Sam</p>
| [
{
"answer_id": 484552,
"author": "Tomalak",
"author_id": 18771,
"author_profile": "https://Stackoverflow.com/users/18771",
"pm_score": 7,
"selected": true,
"text": "<blockquote>\n <p>I want to call a class and pass a value to it so it can be used inside that class</p>\n</blockquote>\n\n... | 2009/01/27 | [
"https://Stackoverflow.com/questions/484537",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | So here is the deal. I want to call a class and pass a value to it so it can be used inside that class in all the various functions ect. ect. How would I go about doing that?
Thanks,
Sam | >
> I want to call a class and pass a value to it so it can be used inside that class
>
>
>
The concept is called "constructor".
As the other answers point out, you should use [the unified constructor syntax](http://php.net/manual/en/language.oop5.decon.php) (`__construct()`) as of PHP 5. Here is an example of ho... |
484,550 | <p>I'm working on a facebook app and there's something I'm just not understanding about how their authorization system works.</p>
<p>Our basic setup is this</p>
<p>canvas URL = domain.com/facebook</p>
<p>This is a simple page with an FBML Iframe element that points to domain.com/facebook/app which is an HTML page th... | [
{
"answer_id": 484552,
"author": "Tomalak",
"author_id": 18771,
"author_profile": "https://Stackoverflow.com/users/18771",
"pm_score": 7,
"selected": true,
"text": "<blockquote>\n <p>I want to call a class and pass a value to it so it can be used inside that class</p>\n</blockquote>\n\n... | 2009/01/27 | [
"https://Stackoverflow.com/questions/484550",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8815/"
] | I'm working on a facebook app and there's something I'm just not understanding about how their authorization system works.
Our basic setup is this
canvas URL = domain.com/facebook
This is a simple page with an FBML Iframe element that points to domain.com/facebook/app which is an HTML page that serves up a Flash App... | >
> I want to call a class and pass a value to it so it can be used inside that class
>
>
>
The concept is called "constructor".
As the other answers point out, you should use [the unified constructor syntax](http://php.net/manual/en/language.oop5.decon.php) (`__construct()`) as of PHP 5. Here is an example of ho... |
484,560 | <p>I've found a nasty VBS way to do this, but I'm looking for a native PoSh procedure to edit the properties of a .LNK file. The goal is to reach out to remote machines, duplicate an existing shortcut with most of the correct properties, and edit a couple of them.</p>
<p>If it would just be easier to write a new shor... | [
{
"answer_id": 486366,
"author": "Marco Shaw",
"author_id": 26478,
"author_profile": "https://Stackoverflow.com/users/26478",
"pm_score": 2,
"selected": false,
"text": "<p>I don't think there's a native way.</p>\n\n<p>There is this DOS util: <a href=\"http://www.optimumx.com/download/Sho... | 2009/01/27 | [
"https://Stackoverflow.com/questions/484560",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44831/"
] | I've found a nasty VBS way to do this, but I'm looking for a native PoSh procedure to edit the properties of a .LNK file. The goal is to reach out to remote machines, duplicate an existing shortcut with most of the correct properties, and edit a couple of them.
If it would just be easier to write a new shortcut file, ... | ```
Copy-Item $sourcepath $destination ## Get the lnk we want to use as a template
$shell = New-Object -COM WScript.Shell
$shortcut = $shell.CreateShortcut($destination) ## Open the lnk
$shortcut.TargetPath = "C:\path\to\new\exe.exe" ## Make changes
$shortcut.Description = "Our new link" ## This is the "Comment" fi... |
484,562 | <p>Consider below code:</p>
<pre><code>public IEnumerable <Country> ListPopulation()
{
foreach(var continent in Continents)
{
var ids = context.continentTable
.where(y=>y.Name == continent.name)
.select(x=>x.countryId);
}
return GetPopulation(... | [
{
"answer_id": 484580,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 3,
"selected": false,
"text": "<p>Well, the main problem has nothing to do with using \"var\". You've got a foreach loop with the variable declared ins... | 2009/01/27 | [
"https://Stackoverflow.com/questions/484562",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Consider below code:
```
public IEnumerable <Country> ListPopulation()
{
foreach(var continent in Continents)
{
var ids = context.continentTable
.where(y=>y.Name == continent.name)
.select(x=>x.countryId);
}
return GetPopulation(ids);// ids is not availab... | Well, the main problem has nothing to do with using "var". You've got a foreach loop with the variable declared inside it, and then you're trying to return from *outside* the loop using that variable. What would you expect the value to be?
If you're trying to select *all* the countries, why don't you just do this:
``... |
484,571 | <p>I have a method which never returns a null object. I want to make it clear so that users of my API don't have to write code like this:</p>
<pre><code>if(Getxyz() != null)
{
// do stuff
}
</code></pre>
<p>How can I show this intent?</p>
| [
{
"answer_id": 484582,
"author": "Jason Jackson",
"author_id": 13103,
"author_profile": "https://Stackoverflow.com/users/13103",
"pm_score": 3,
"selected": false,
"text": "<p>Unless you are using a type based on System.ValueType, I think you are out of luck. Its probably best to documen... | 2009/01/27 | [
"https://Stackoverflow.com/questions/484571",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30917/"
] | I have a method which never returns a null object. I want to make it clear so that users of my API don't have to write code like this:
```
if(Getxyz() != null)
{
// do stuff
}
```
How can I show this intent? | Unfortunately there is no way built in to C#
You can document this fact, but this won't be automatically checked.
If you are using resharper, then it can be set up to check this properly when the method is marked with a [NotNull] attribute.
Otherwise you can use the [Microsoft Contracts][1] library and add something... |
484,573 | <p>I'm looking for an algorithm that rotates an image by some degrees (input).</p>
<pre><code>public Image rotateImage(Image image, int degrees)
</code></pre>
<p>(Image instances could be replaced with int[] containing each pixel RGB values,
My problem is that i need to implement it for a JavaME MIDP 2.0 project so i... | [
{
"answer_id": 484605,
"author": "basszero",
"author_id": 287,
"author_profile": "https://Stackoverflow.com/users/287",
"pm_score": -1,
"selected": false,
"text": "<p>Graphics2D and AffineTransform will help you do exactly what you want. Specifically, Graphics2D.drawImage(Image, AffineTr... | 2009/01/27 | [
"https://Stackoverflow.com/questions/484573",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49209/"
] | I'm looking for an algorithm that rotates an image by some degrees (input).
```
public Image rotateImage(Image image, int degrees)
```
(Image instances could be replaced with int[] containing each pixel RGB values,
My problem is that i need to implement it for a JavaME MIDP 2.0 project so i must use code runnable on... | One of the best pages describing image rotation algorithms I've found on the internet is tied to Dan Bloomberg's *excellent* leptonica library. While the leptonica library itself is written in C and won't help you, his page on image rotation algorithms:
<http://www.leptonica.org/rotation.html>
is definitely worth a r... |
484,592 | <p>Is there is any reason to make the permissions on an overridden C++ virtual function different from the base class? Is there any danger in doing so?</p>
<p>For example:</p>
<pre><code>class base {
public:
virtual int foo(double) = 0;
}
class child : public base {
private:
virtual int foo(... | [
{
"answer_id": 484608,
"author": "Andrew Grant",
"author_id": 1043,
"author_profile": "https://Stackoverflow.com/users/1043",
"pm_score": 3,
"selected": false,
"text": "<p>There's no technical problem, but you will end up with a situation where the publicly available functions will depen... | 2009/01/27 | [
"https://Stackoverflow.com/questions/484592",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/57590/"
] | Is there is any reason to make the permissions on an overridden C++ virtual function different from the base class? Is there any danger in doing so?
For example:
```
class base {
public:
virtual int foo(double) = 0;
}
class child : public base {
private:
virtual int foo(double);
}
```
The [... | The problem is that the Base class methods are its way of declaring its interface. It is, in essence saying, "These are the things you can do to objects of this class."
When in a Derived class you make something the Base had declared as public private, you are taking something away. Now, even though a Derived object "... |
484,614 | <p>This is the code I have that HTML Validator is giving me an error on:</p>
<pre><code><input type="text" id="search" name="keywords" />
<input type="submit" value="Search" name="Submit" />
</code></pre>
<p><strong>Here is a screen shot of error in HTML Validator</strong> (<a href="https://i.stack.imgur.... | [
{
"answer_id": 484643,
"author": "TJ L",
"author_id": 12605,
"author_profile": "https://Stackoverflow.com/users/12605",
"pm_score": 0,
"selected": false,
"text": "<p>I believe the problem is that the inputs are in a <code><li></code> element, which by default is not a <a href=\"htt... | 2009/01/27 | [
"https://Stackoverflow.com/questions/484614",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26130/"
] | This is the code I have that HTML Validator is giving me an error on:
```
<input type="text" id="search" name="keywords" />
<input type="submit" value="Search" name="Submit" />
```
**Here is a screen shot of error in HTML Validator** ([full size](https://i.stack.imgur.com/1B67V.png)):
![Screen shot of error in HTML... | In HTML4 / XHTML1, you can't put inline content directly into a `form` element. HTML5, on the other hand, lifts that requirement.
Thus, if the validation error bothers you (there are worse things...), add a `p` or `div` element around the last two `input`s. |
484,615 | <p>I have a single Rails 2.2.2 app that I want to 'share' with multiple clients. Each client has his own domain name and database. The purpose is to allow one Rails app to 'host' many websites.</p>
<p>I am using Apache as a front end to a mongrel cluster, as the web server. To enable Rails to know which request is for... | [
{
"answer_id": 484634,
"author": "Spikolynn",
"author_id": 58142,
"author_profile": "https://Stackoverflow.com/users/58142",
"pm_score": 0,
"selected": false,
"text": "<p>Cookies are domain-dependent, so you should use a different technique - a single server issuing cookies/creating sess... | 2009/01/27 | [
"https://Stackoverflow.com/questions/484615",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44317/"
] | I have a single Rails 2.2.2 app that I want to 'share' with multiple clients. Each client has his own domain name and database. The purpose is to allow one Rails app to 'host' many websites.
I am using Apache as a front end to a mongrel cluster, as the web server. To enable Rails to know which request is for which cli... | Well, I 'solved' the problem by eliminating the shared mongrel\_cluster, and giving each domain it's own mongrel instance.
I was hoping that I could save some server resources by sharing a single mongrel cluster, but to do so, I'll need to figure out how to solve this cookie problem.
By the way, I found a partial sol... |
484,631 | <p>I'm just starting to play with MVC, and something isn't clicking with me. I understand how to make a simple input form, and use a submit button to post the form set up like this:</p>
<pre><code><form runat="server" method="post" action="/Home/CreateNew" >
</code></pre>
<p>But what happens if you're whole app... | [
{
"answer_id": 484771,
"author": "Craig Stuntz",
"author_id": 7714,
"author_profile": "https://Stackoverflow.com/users/7714",
"pm_score": 3,
"selected": true,
"text": "<p>You should not put one form around the whole page. Put your multiple input forms where you need them. You can get rid... | 2009/01/27 | [
"https://Stackoverflow.com/questions/484631",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23935/"
] | I'm just starting to play with MVC, and something isn't clicking with me. I understand how to make a simple input form, and use a submit button to post the form set up like this:
```
<form runat="server" method="post" action="/Home/CreateNew" >
```
But what happens if you're whole app is inside one form tag, and you... | You should not put one form around the whole page. Put your multiple input forms where you need them. You can get rid of the runat = "server" also. You won't need that in MVC.
Much of the Ajax Control Toolkit is just not going to work in MVC, since MVC does not have ViewState. [There is a client-only version, which do... |
484,644 | <p>If I do a form post w/ a non asp.net control in webforms, how can I get the id of the control that triggered the event from the sender object?</p>
<p>Currently I'm adding a simple form post to my drop down list w/ jQuery and want a method to capture the specific control on the server side ...</p>
<pre><code>$(docu... | [
{
"answer_id": 484648,
"author": "MSN",
"author_id": 6210,
"author_profile": "https://Stackoverflow.com/users/6210",
"pm_score": 5,
"selected": false,
"text": "<p>Yes, but you don't incur the cost of global variables until you stop working in the code that uses global variables and start... | 2009/01/27 | [
"https://Stackoverflow.com/questions/484644",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2701/"
] | If I do a form post w/ a non asp.net control in webforms, how can I get the id of the control that triggered the event from the sender object?
Currently I'm adding a simple form post to my drop down list w/ jQuery and want a method to capture the specific control on the server side ...
```
$(document).ready(function(... | The problem with global variables is that since every function has access to these, it becomes increasingly hard to figure out which functions actually read and write these variables.
To understand how the application works, you pretty much have to take into account every function which modifies the global state. Tha... |
484,678 | <p>I have the following Rails definition:</p>
<pre><code>Class Book
string title
has_many readings
has_many users, :through => :readings
Class Reader
int rating
belongs_to :book
belongs_to :user
Class User
has_many readings
has_many books, through => :readings
</code></pre>
<p>No I want to que... | [
{
"answer_id": 484683,
"author": "user54650",
"author_id": 54650,
"author_profile": "https://Stackoverflow.com/users/54650",
"pm_score": 1,
"selected": false,
"text": "<p>The border line is side-effects.</p>\n\n<p>If an encapsulated function does everything you want with 0 unexpected sid... | 2009/01/27 | [
"https://Stackoverflow.com/questions/484678",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/59460/"
] | I have the following Rails definition:
```
Class Book
string title
has_many readings
has_many users, :through => :readings
Class Reader
int rating
belongs_to :book
belongs_to :user
Class User
has_many readings
has_many books, through => :readings
```
No I want to query like this:
Give me all readi... | I've written a *lot* of code in my career. Certainly not as much as many folks here, but a lot of code nonetheless. During that time, I've learned one thing that's proved true time and time again: When you get sloppy, when you ignore the details, *defects creep in.*
Defects cost time and money to repair. You can eithe... |
484,690 | <p>I've noticed that a OpenGL app I've been working on has significant performance difference when run on Linux vs WindowsXP. </p>
<p>Granted, there are a lot of textures and shadow buffers but I would estimate that the app runs about 10x <strong>slower</strong> on Windows XP. </p>
<p>Any ideas? </p>
<p>Any suggesti... | [
{
"answer_id": 484797,
"author": "basszero",
"author_id": 287,
"author_profile": "https://Stackoverflow.com/users/287",
"pm_score": 0,
"selected": false,
"text": "<p>QuadroFX 1500 isn't exactly the newest card. Find out what the linux box has and compare hardware specs. On my projects (d... | 2009/01/27 | [
"https://Stackoverflow.com/questions/484690",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29505/"
] | I've noticed that a OpenGL app I've been working on has significant performance difference when run on Linux vs WindowsXP.
Granted, there are a lot of textures and shadow buffers but I would estimate that the app runs about 10x **slower** on Windows XP.
Any ideas?
Any suggestions for porting the code to DirectX? ... | As DrJokepu mentioned in the comments, it's possible XP is employing software rendering, implying a driver installation issue. You can verify this by querying GL\_VENDOR and GL\_RENDERER:
```
printf( "%s\n", (const char*)glGetString( GL_VENDOR ) );
printf( "%s\n", (const char*)glGetString( GL_RENDERER ) );
```
The v... |
484,700 | <p>I know java has the SimpleDateFormat which seems fairly powerful, but you need to know the format ahead of time to use it correctly.<br>
TCL's clock scan function seems to be the easiest and most powerful I've seen.</p>
<p>e.g. clock scan "1/08/2009 12:33:01 AM" will work just as well as<br>
clock scan "8-Jan-... | [
{
"answer_id": 484710,
"author": "earino",
"author_id": 45403,
"author_profile": "https://Stackoverflow.com/users/45403",
"pm_score": 2,
"selected": false,
"text": "<p>Perl's Date::Parse module (I don't know that it can be considered builtin to the language, but it's a CPAN module so tha... | 2009/01/27 | [
"https://Stackoverflow.com/questions/484700",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/50640/"
] | I know java has the SimpleDateFormat which seems fairly powerful, but you need to know the format ahead of time to use it correctly.
TCL's clock scan function seems to be the easiest and most powerful I've seen.
e.g. clock scan "1/08/2009 12:33:01 AM" will work just as well as
clock scan "8-Jan-2009 12:33:01"
... | Python doesn't have a library built in, but the excellent [dateutil](http://labix.org/python-dateutil) library provides a parse() method that's pretty accommodating.
From simple (assuming today is 9/25):
```
>>> parse("Thu Sep 25 2003")
datetime.datetime(2003, 9, 25, 0, 0)
>>> parse("Sep 25 2003")
datetime.datetime(... |
484,707 | <p>Let's say I have an array in C++:</p>
<pre><code>double* velocity = new double[100];
</code></pre>
<p>Using the GDB command line, I can view this array with the command:</p>
<pre><code>> print *velocity @ 100
</code></pre>
<p>and it will print a nicely-formatted list of all the double values inside the array.... | [
{
"answer_id": 485030,
"author": "Stefan Arentz",
"author_id": 56837,
"author_profile": "https://Stackoverflow.com/users/56837",
"pm_score": -1,
"selected": false,
"text": "<p>No unfortunately the GUI is limited and you will need to blend in a good mix of GDB magic to get things done.</p... | 2009/01/27 | [
"https://Stackoverflow.com/questions/484707",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53905/"
] | Let's say I have an array in C++:
```
double* velocity = new double[100];
```
Using the GDB command line, I can view this array with the command:
```
> print *velocity @ 100
```
and it will print a nicely-formatted list of all the double values inside the array.
However, when using the Xcode debugger, the most i... | You can use gdb syntax as expressions:
1. Use Run/Show/Expressions... menu to show the expressions window
2. Enter `'*velocity @ 100'` at the bottom of the window (Expression:) |
484,709 | <p>Why is the following code (in cocoa) not working?</p>
<pre><code>NSString *extension = [fileName pathExtension];
NSString *wantedExtension = @"mp3";
if(extension == wantedExtension){
//work
}
</code></pre>
<p>in Xcode this just runs without warnings or errors but doesn't do what I think it SHOULD do.</p>
| [
{
"answer_id": 484728,
"author": "Paul Tomblin",
"author_id": 3333,
"author_profile": "https://Stackoverflow.com/users/3333",
"pm_score": 6,
"selected": true,
"text": "<p>Shouldn't that be</p>\n\n<pre><code>if ([extension isEqualToString:wantedExtension]) {\n...\n}\n</code></pre>\n\n<p>\... | 2009/01/27 | [
"https://Stackoverflow.com/questions/484709",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/59159/"
] | Why is the following code (in cocoa) not working?
```
NSString *extension = [fileName pathExtension];
NSString *wantedExtension = @"mp3";
if(extension == wantedExtension){
//work
}
```
in Xcode this just runs without warnings or errors but doesn't do what I think it SHOULD do. | Shouldn't that be
```
if ([extension isEqualToString:wantedExtension]) {
...
}
```
"==" compares the pointers. isEqual: and isEqualToString: compare the strings, although isEqualToString is better if you know both extension and wantedExtension are NSString (which you do in this case).
Actually, if you're an old C++... |
484,717 | <h2>Goal</h2>
<p>I would like to be able to both host and connect to a vanilla sockets server via WCF, within the hosting framework I am devising. I want to be able to use WCF to codify the transport and protocol communications that have to be manually managed by sockets programmers today. This would allow me the ul... | [
{
"answer_id": 3861589,
"author": "janasainik",
"author_id": 462563,
"author_profile": "https://Stackoverflow.com/users/462563",
"pm_score": 1,
"selected": false,
"text": "<p>I am not aware of custom transport channels. I think as per my experiance, it may not possible to make the WcfTes... | 2009/01/27 | [
"https://Stackoverflow.com/questions/484717",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/54289/"
] | Goal
----
I would like to be able to both host and connect to a vanilla sockets server via WCF, within the hosting framework I am devising. I want to be able to use WCF to codify the transport and protocol communications that have to be manually managed by sockets programmers today. This would allow me the ultimate in... | It is possible to create custom transports in WCF. It's quite involved though!
Roman Kiss has built a Null Transport that allows you to consume and host the services from within the same process without the overhead of marshalling the data through one of the built in transports. His CodePlex article is available at:
... |
484,719 | <p>When one wants to refer to some part of a webpage with the "<code>http://example.com/#foo</code>" method, should one use</p>
<pre><code><h1><a name="foo"/>Foo Title</h1>
</code></pre>
<p>or</p>
<pre><code><h1 id="foo">Foo Title</h1>
</code></pre>
<p>They both work, but are they equa... | [
{
"answer_id": 484729,
"author": "Alex Fort",
"author_id": 12624,
"author_profile": "https://Stackoverflow.com/users/12624",
"pm_score": -1,
"selected": false,
"text": "<p>The whole \"named anchor\" concept uses the name attribute, by definition. You should just stick to using the name, ... | 2009/01/27 | [
"https://Stackoverflow.com/questions/484719",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2238/"
] | When one wants to refer to some part of a webpage with the "`http://example.com/#foo`" method, should one use
```
<h1><a name="foo"/>Foo Title</h1>
```
or
```
<h1 id="foo">Foo Title</h1>
```
They both work, but are they equal, or do they have semantic differences? | According to the HTML 5 specification, [5.9.8 Navigating to a fragment identifier](http://www.w3.org/html/wg/drafts/html/master/browsers.html#scroll-to-fragid):
>
> For HTML documents (and the text/html MIME type), the following processing model must be followed to determine what the indicated part of the document is... |