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 |
|---|---|---|---|---|---|---|
554,709 | <p>Evening all,</p>
<p>I've written a transfer application that needs to perform an update, then update a date corresponding to that update. I.e.</p>
<pre><code>string content = string.Empty;
IIvdManager manager;
DateTime configDate;
if (table == Tables.Asset)
{
content = WebService.GetTblAsset(companyId);
m... | [
{
"answer_id": 554718,
"author": "cjk",
"author_id": 52201,
"author_profile": "https://Stackoverflow.com/users/52201",
"pm_score": 0,
"selected": false,
"text": "<p>It sounds as simple as you need to do this:</p>\n\n<pre><code>manager.Date = configDate;\n</code></pre>\n\n<p>Which means I... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554709",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44269/"
] | Evening all,
I've written a transfer application that needs to perform an update, then update a date corresponding to that update. I.e.
```
string content = string.Empty;
IIvdManager manager;
DateTime configDate;
if (table == Tables.Asset)
{
content = WebService.GetTblAsset(companyId);
manager = ivdData.Inst... | Have you considered the state pattern?
Subclass your table (the table variable) and add a virtual method (Update() perhaps?) that you then override in each specific table type. This will completely remove the else ifs as it will just become:
```
table.Update();
```
Pass down any objects you need to this call and th... |
554,725 | <p>I have a html file need to refresh every 10 seconds, so I have this line in html :</p>
<pre><code>meta http-equiv="Refresh" content="10; url=Default.aspx"
</code></pre>
<p>In my C# code I have this :</p>
<pre><code>public partial class _Default : System.Web.UI.Page<Br>
{
public static List<String> A... | [
{
"answer_id": 554739,
"author": "M4N",
"author_id": 19635,
"author_profile": "https://Stackoverflow.com/users/19635",
"pm_score": 2,
"selected": true,
"text": "<p>Use this:</p>\n\n<pre><code><meta http-equiv=\"Refresh\"\n content=\"<%= Refresh_In_Seconds %>; url=Default.as... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554725",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32834/"
] | I have a html file need to refresh every 10 seconds, so I have this line in html :
```
meta http-equiv="Refresh" content="10; url=Default.aspx"
```
In my C# code I have this :
```
public partial class _Default : System.Web.UI.Page<Br>
{
public static List<String> Active_User_List=
new List<String>(), User_L... | Use this:
```
<meta http-equiv="Refresh"
content="<%= Refresh_In_Seconds %>; url=Default.aspx" />
``` |
554,729 | <p>How do I improve the performance of the following situation?</p>
<p>I have an application that accepts multiple connections across a network. The application is written in C# and accepts Socket connections. Every five minutes, the application needs to perform a function call that updates the application and reports... | [
{
"answer_id": 554752,
"author": "cjk",
"author_id": 52201,
"author_profile": "https://Stackoverflow.com/users/52201",
"pm_score": 2,
"selected": true,
"text": "<p>Have you tried compiling in release mode to see if there is much difference in speed?</p>\n"
},
{
"answer_id": 55475... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554729",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/67110/"
] | How do I improve the performance of the following situation?
I have an application that accepts multiple connections across a network. The application is written in C# and accepts Socket connections. Every five minutes, the application needs to perform a function call that updates the application and reports informati... | Have you tried compiling in release mode to see if there is much difference in speed? |
554,731 | <p>I need some help understanding the ADO.NET Entity Framework.</p>
<p>I'm trying to represent and manipulate hierarchical data in a WPF TreeView control with the ADO.NET Entity Framework.</p>
<p><a href="http://img14.imageshack.us/img14/7158/thingpi1.gif" rel="nofollow noreferrer">ADO.NET Entity Framework Object wit... | [
{
"answer_id": 567103,
"author": "Andrew Peters",
"author_id": 608,
"author_profile": "https://Stackoverflow.com/users/608",
"pm_score": 1,
"selected": false,
"text": "<p>I haven't had a detailed look at the code but the first thing to consider is that you shouldn't need to call DeleteOb... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554731",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/83/"
] | I need some help understanding the ADO.NET Entity Framework.
I'm trying to represent and manipulate hierarchical data in a WPF TreeView control with the ADO.NET Entity Framework.
[ADO.NET Entity Framework Object with parent and children http://img14.imageshack.us/img14/7158/thingpi1.gif](http://img14.imageshack.us/im... | Why are you loading the parent again when adding a new child, when you already have the object? While this is no problem for the database, it will introduce inconsistencies on the object level. You can just use the existing parent like this:
```
Private Sub ButtonAddThing_Click(...)
Dim NewThing As New Thing
N... |
554,737 | <p>I am looking for some info on using and configuring windsor to provide a dynamic proxy to intercept calls to an instance of another class. </p>
<p>My class represents a resource that should be retained as a long lived instance by the container for performance reasons. However, sometimes this resource can transiti... | [
{
"answer_id": 555287,
"author": "Mauricio Scheffer",
"author_id": 21239,
"author_profile": "https://Stackoverflow.com/users/21239",
"pm_score": 3,
"selected": true,
"text": "<p>This question is more about renewing a singleton component than interception. The problem of renewing singleto... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554737",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47207/"
] | I am looking for some info on using and configuring windsor to provide a dynamic proxy to intercept calls to an instance of another class.
My class represents a resource that should be retained as a long lived instance by the container for performance reasons. However, sometimes this resource can transition into unun... | This question is more about renewing a singleton component than interception. The problem of renewing singletons is answered in [this question](https://stackoverflow.com/questions/85183).
Bottom line: it's not as easy as it seems, there are **many** pitfalls with this approach.
Maybe the problem lies in this compone... |
554,742 | <p>Is there a way to reevaluate a variable's definition upon each use? For example:</p>
<pre><code>MAP_FILES = $(shell find $(TMP) -name "*.map")
all: generate_map_files work_with_map_files
generate_map_files:
./map-builder
work\_with\_map_files: $(MAP_FILES)
./map-user
%.map:
./map-edit $@
</code></pre>
... | [
{
"answer_id": 554796,
"author": "Tom Alsberg",
"author_id": 66034,
"author_profile": "https://Stackoverflow.com/users/66034",
"pm_score": 1,
"selected": false,
"text": "<p>In general this is not possible in Makefiles, because to determine what targets to make and in what order, <code>ma... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554742",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Is there a way to reevaluate a variable's definition upon each use? For example:
```
MAP_FILES = $(shell find $(TMP) -name "*.map")
all: generate_map_files work_with_map_files
generate_map_files:
./map-builder
work\_with\_map_files: $(MAP_FILES)
./map-user
%.map:
./map-edit $@
```
So, MAP\_FILES will be... | You might try doing a recursive make, something like
```
MAP_FILES = $(shell find $(TMP) -name "*.map")
all: generate_map_files
generate_map_files:
./map-builder; $(MAKE) work_with_map_files
work\_with\_map_files: $(MAP_FILES)
./map-user
%.map:
./map-edit $@
``` |
554,750 | <p>Performance is key: Is it better to cascade deletes/updates inside of the Database or let Hibernate/JPA take care of it?</p>
<p>Will this effect the ability to query for the data if cascades are inside of the DBMS?</p>
<p>I am using HSQLDB if that matters.</p>
| [
{
"answer_id": 555097,
"author": "ShuggyCoUk",
"author_id": 12748,
"author_profile": "https://Stackoverflow.com/users/12748",
"pm_score": 0,
"selected": false,
"text": "<ol>\n<li>Correctness is key</li>\n</ol>\n\n<p>That said in this instance correctness and performance will almost certa... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554750",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33863/"
] | Performance is key: Is it better to cascade deletes/updates inside of the Database or let Hibernate/JPA take care of it?
Will this effect the ability to query for the data if cascades are inside of the DBMS?
I am using HSQLDB if that matters. | In the case of cascading updates, you simply cannot do it in application space if you have foreign key constraints in the database.
Example: say you have a lookup table for US states, with a primary key of the two-letter abbreviation. Then you have a table for mailing addresses that references it. Someone tells you th... |
554,755 | <p>Is there a rails plugin that will do alphabetical pagination/navigation?</p>
<p>I have a very large data set and would prefer something that gave users a more direct navigation cue in addition to 1..2...3...4...5 pagination.</p>
<p>I could code it myself but was wondering if there was a decent plugin out there alr... | [
{
"answer_id": 554883,
"author": "Denis Hennessy",
"author_id": 35958,
"author_profile": "https://Stackoverflow.com/users/35958",
"pm_score": 1,
"selected": false,
"text": "<p>I implemented something like that a while ago (based on the popular will_paginate plugin):\n<a href=\"http://www... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554755",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6805/"
] | Is there a rails plugin that will do alphabetical pagination/navigation?
I have a very large data set and would prefer something that gave users a more direct navigation cue in addition to 1..2...3...4...5 pagination.
I could code it myself but was wondering if there was a decent plugin out there already that would d... | Why can you not have the alphabet for which you want to see the results to, passed as a parameter? And then paginate on the results? That is,
```
# show results of params[:alphabet] alphabet
@results = fetch_results(params[:alphabet])
# Use Will Paginate to fetch results internally and give a condition that
# fetch... |
554,760 | <p>I know PHP is usually used for web development, where there <em>is</em> no standard input, but PHP claims to be usable as a general-purpose scripting language, if you do follow it's funky web-based conventions. I know that PHP prints to <code>stdout</code> (or whatever you want to call it) with <code>print</code> an... | [
{
"answer_id": 554772,
"author": "Greg",
"author_id": 24181,
"author_profile": "https://Stackoverflow.com/users/24181",
"pm_score": 3,
"selected": false,
"text": "<p>You can use <a href=\"http://www.php.net/fopen\" rel=\"noreferrer\"><code>fopen()</code></a> on <code>php://stdin</code>:<... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554760",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/60777/"
] | I know PHP is usually used for web development, where there *is* no standard input, but PHP claims to be usable as a general-purpose scripting language, if you do follow it's funky web-based conventions. I know that PHP prints to `stdout` (or whatever you want to call it) with `print` and `echo`, which is simple enough... | It is possible to read the `stdin` by creating a file handle to `php://stdin` and then read from it with `fgets()` for a line for example (or, as you already stated, `fgetc()` for a single character):
```
<?php
$f = fopen( 'php://stdin', 'r' );
while( $line = fgets( $f ) ) {
echo $line;
}
fclose( $f );
?>
``` |
554,761 | <p>Let's say that I'm developing an application to track boxing results. Is the best way to track these to have two tables, like so:</p>
<pre><code>Boxers
======
id
name
Matches
=======
id
match_number
boxer_id
opponent_id
result
</code></pre>
<p>... and then have two records for each match, one for the winner, and ... | [
{
"answer_id": 554784,
"author": "Sampson",
"author_id": 54680,
"author_profile": "https://Stackoverflow.com/users/54680",
"pm_score": 2,
"selected": false,
"text": "<p>Store the <code>winner_id</code> in the same record.<br/>\nThis allows you to show upcoming fights, unlike solutions th... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554761",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/722/"
] | Let's say that I'm developing an application to track boxing results. Is the best way to track these to have two tables, like so:
```
Boxers
======
id
name
Matches
=======
id
match_number
boxer_id
opponent_id
result
```
... and then have two records for each match, one for the winner, and one for the loser, somethi... | Well, for a fully normalized, I'd go with:
Boxers - as cited.
Matches:
```
id / match_number (Don't think these need to be distinct anymore)
winner (FK-Boxers; Nullable, for for matches scheduled, but not decided yet)
```
Opponents:
```
id (meaningless PK value. Optional.
you could use the other two fi... |
554,769 | <p>Assume I have a user defined Java class called Foo such as:</p>
<pre><code>public class Foo
{
private String aField;
@Override
public String toString()
{
return aField;
}
}
</code></pre>
<p>And a Collection such as:</p>
<pre><code>List<Foo> aList;
</code></pre>
<p>What I am ... | [
{
"answer_id": 554777,
"author": "Yuval Adam",
"author_id": 24545,
"author_profile": "https://Stackoverflow.com/users/24545",
"pm_score": 5,
"selected": true,
"text": "<p>Use the API <code>sort(List list, Comparator c)</code>which specifies a comparator, and implement is as you wish.</p>... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554769",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/64301/"
] | Assume I have a user defined Java class called Foo such as:
```
public class Foo
{
private String aField;
@Override
public String toString()
{
return aField;
}
}
```
And a Collection such as:
```
List<Foo> aList;
```
What I am looking to do is to sort the List alphabetically based ... | Use the API `sort(List list, Comparator c)`which specifies a comparator, and implement is as you wish.
Alternatively, if you do not specifically need a List, use a [`SortedSet`](http://java.sun.com/javase/6/docs/api/java/util/SortedSet.html), same goes with the comparator. |
554,783 | <p>I created an XPCOM object in C++ for a FireFox extension. I'm using a worker thread to listen for an event and when it happens, I need to do stuff on the main thread. Obviously, I can't just sit and wait in JavaScript on the main thread because you need to be able to use the browser (my event happens very rarely).</... | [
{
"answer_id": 554777,
"author": "Yuval Adam",
"author_id": 24545,
"author_profile": "https://Stackoverflow.com/users/24545",
"pm_score": 5,
"selected": true,
"text": "<p>Use the API <code>sort(List list, Comparator c)</code>which specifies a comparator, and implement is as you wish.</p>... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554783",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26482/"
] | I created an XPCOM object in C++ for a FireFox extension. I'm using a worker thread to listen for an event and when it happens, I need to do stuff on the main thread. Obviously, I can't just sit and wait in JavaScript on the main thread because you need to be able to use the browser (my event happens very rarely).
I t... | Use the API `sort(List list, Comparator c)`which specifies a comparator, and implement is as you wish.
Alternatively, if you do not specifically need a List, use a [`SortedSet`](http://java.sun.com/javase/6/docs/api/java/util/SortedSet.html), same goes with the comparator. |
554,790 | <p>I am trying to work out if there is built-in support for binding complex types to form elements.</p>
<p>To use a common hypothetical situation:
I have a Product entity that belongs to a Category - the models look something like this:</p>
<pre><code>public class Product
{
public int ID { get; set; }
public ... | [
{
"answer_id": 554955,
"author": "Fritz H",
"author_id": 67139,
"author_profile": "https://Stackoverflow.com/users/67139",
"pm_score": 1,
"selected": false,
"text": "<p>The closest I think that it will come is overriding the <code>ToString()</code> method in the class to output meaningfu... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554790",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/67114/"
] | I am trying to work out if there is built-in support for binding complex types to form elements.
To use a common hypothetical situation:
I have a Product entity that belongs to a Category - the models look something like this:
```
public class Product
{
public int ID { get; set; }
public string Description { ... | I haven't yet tried the DefaultModelBinder for complex types, but you could always use [MvcContrib](http://www.codeplex.com/MVCContrib)'s CastleBind (borrowed from the [Castle Project](http://castleproject.org/)) which gives you complex type binding easily, including arrays.
See <http://blogger.forgottenskies.com/?p=2... |
554,815 | <p>I recently read <a href="http://vim.wikia.com/wiki/Indenting_source_code" rel="noreferrer">this article</a> related to indenting source files in Vim . However , I would like to be able to custom indent some of them . Is there a way to specify which binary runs when I press = ? </p>
| [
{
"answer_id": 554823,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 4,
"selected": true,
"text": "<p>From the help:</p>\n\n<pre>\n={motion} Filter {motion} lines through the external program\n given ... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554815",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31610/"
] | I recently read [this article](http://vim.wikia.com/wiki/Indenting_source_code) related to indenting source files in Vim . However , I would like to be able to custom indent some of them . Is there a way to specify which binary runs when I press = ? | From the help:
```
={motion} Filter {motion} lines through the external program
given with the 'equalprg' option. When the 'equalprg'
option is empty (this is the default), use the
internal formatting function |C-indenting|. But when
'indentexpr'... |
554,816 | <p>What's the easiest way to build an applet that has a view with components that are bound to model data and update when the model is updated?</p>
<p>Ideally as little code as possible, preferable none/declarative :)</p>
<p>If a component type is needed for explanation, please consider a JLabel whose text is bound t... | [
{
"answer_id": 554823,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 4,
"selected": true,
"text": "<p>From the help:</p>\n\n<pre>\n={motion} Filter {motion} lines through the external program\n given ... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554816",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2362/"
] | What's the easiest way to build an applet that has a view with components that are bound to model data and update when the model is updated?
Ideally as little code as possible, preferable none/declarative :)
If a component type is needed for explanation, please consider a JLabel whose text is bound to a bean with a S... | From the help:
```
={motion} Filter {motion} lines through the external program
given with the 'equalprg' option. When the 'equalprg'
option is empty (this is the default), use the
internal formatting function |C-indenting|. But when
'indentexpr'... |
554,817 | <p>My dom looks like this:</p>
<pre><code><div class="profile">
<a href="#"><img src="/img1.gif" /></a> <b>100</b>
<a href="#"><img src="/img2.gif" /></a>
</div>
</code></pre>
<p>Ok so I have many of these elements on my page, so using jQuery I... | [
{
"answer_id": 554850,
"author": "user65952",
"author_id": 65952,
"author_profile": "https://Stackoverflow.com/users/65952",
"pm_score": 2,
"selected": false,
"text": "<pre><code>$(\".profile a\").live(\"click\", function(e) {\n var temp = $(\"img\", this);\n var temp2 = temp.attr(\"sr... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554817",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/67033/"
] | My dom looks like this:
```
<div class="profile">
<a href="#"><img src="/img1.gif" /></a> <b>100</b>
<a href="#"><img src="/img2.gif" /></a>
</div>
```
Ok so I have many of these elements on my page, so using jQuery I bind all the events like this:
```
$(".profile").live('click', myCallback);
var myC... | ```
$(".profile a").live("click", function(e) {
var temp = $("img", this);
var temp2 = temp.attr("src").split('.');
temp.attr("src", temp2[0] + "_on" + temp2[1]);
// Ajax goes here.
e.preventDefault();
});
```
You had it so that the div was the one being clicked, and not the links inside of the div. This... |
554,819 | <p>I have a problem in VS2005. When I try to search files with the regular expressions option I just get an error message stating </p>
<pre><code>Unknown argument for ':' operator. Complete Regular Expression required in search string.
</code></pre>
<p>The pattern that i'm trying to use is valid, and works in other ... | [
{
"answer_id": 554833,
"author": "James Curran",
"author_id": 12725,
"author_profile": "https://Stackoverflow.com/users/12725",
"pm_score": 0,
"selected": false,
"text": "<p>try:\n<code>< asp\\:textbox.+?(type=\"text\"|size=|autocomplete=|class=|value=)</code></p>\n\n<p>(blank between... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554819",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/56753/"
] | I have a problem in VS2005. When I try to search files with the regular expressions option I just get an error message stating
```
Unknown argument for ':' operator. Complete Regular Expression required in search string.
```
The pattern that i'm trying to use is valid, and works in other text editors it is:
```
<a... | This is working :
```
\<asp\:textbox.+?(type=\"text\"|size=|autocomplete=|class=|value=)
```
But I think there is a mistake in **.+?** part. Wtihout it I can get matches for that :
```
// <asp:textboxtype="text"
``` |
554,899 | <p>Are there any good resources for starting Flex 3 UI programming in ActionScript? I am having some issues with the following if anyone has any ideas. It gets the right size, but my buttons are not showing up. Anyone have any ideas?</p>
<pre><code>package
{
import flash.display.*;
import mx.controls.Butt... | [
{
"answer_id": 555153,
"author": "Michael Brewer-Davis",
"author_id": 56044,
"author_profile": "https://Stackoverflow.com/users/56044",
"pm_score": 2,
"selected": true,
"text": "<p>For a true Flex application, I think you need to start with a top level <code>mx.core.Application</code> (o... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554899",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23528/"
] | Are there any good resources for starting Flex 3 UI programming in ActionScript? I am having some issues with the following if anyone has any ideas. It gets the right size, but my buttons are not showing up. Anyone have any ideas?
```
package
{
import flash.display.*;
import mx.controls.Button;
import mx... | For a true Flex application, I think you need to start with a top level `mx.core.Application` (often defined in MXML rather than ActionScript), to which you would add `mx.core.UIComponent`s. I think your `PhotoUploader` would be a good example of a custom UIComponent.
The [Flex help/tutorial](http://livedocs.adobe.com... |
554,909 | <p>I'm creating a website where I need to show the top 5 records from an RSS feed, and these need to be sorted by date and time.</p>
<p>The date fields in the RSS feed are in the following format:
"Mon, 16 Feb 2009 16:02:44 GMT"</p>
<p>I'm having big problems getting the records to sort correctly - I've tried lots of... | [
{
"answer_id": 555536,
"author": "Dimitre Novatchev",
"author_id": 36305,
"author_profile": "https://Stackoverflow.com/users/36305",
"pm_score": 4,
"selected": true,
"text": "<p><strong>The following transformation</strong>:</p>\n\n<pre><code><xsl:stylesheet version=\"1.0\"\n xmlns:xs... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554909",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/123137/"
] | I'm creating a website where I need to show the top 5 records from an RSS feed, and these need to be sorted by date and time.
The date fields in the RSS feed are in the following format:
"Mon, 16 Feb 2009 16:02:44 GMT"
I'm having big problems getting the records to sort correctly - I've tried lots of different code e... | **The following transformation**:
```
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:variable name="vrtfMonths">
<m name="Jan" num="01"/>
<m name="Feb" num="02"/>
<m name="Mar" num="03"/>
<m name="Apr" num=... |
554,922 | <p>I have a route table similar to this</p>
<pre><code>// Allow browsing categories by name, instead of by ID.
routes.MapRoute("Categories", "Categories/{action}/{name}",
new { controller = "Categories", action = "Index", name = "" }
);
// All other pages use the default route.
routes.MapRoute("Default", "{contro... | [
{
"answer_id": 554993,
"author": "jrockway",
"author_id": 8457,
"author_profile": "https://Stackoverflow.com/users/8457",
"pm_score": 1,
"selected": false,
"text": "<p>Yes, people are building actual \"Enterprise\" applications with Scala (and Clojure). Just do it.</p>\n\n<p>Of course, ... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554922",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22093/"
] | I have a route table similar to this
```
// Allow browsing categories by name, instead of by ID.
routes.MapRoute("Categories", "Categories/{action}/{name}",
new { controller = "Categories", action = "Index", name = "" }
);
// All other pages use the default route.
routes.MapRoute("Default", "{controller}/{action}... | I have used Scala on our existing Java infrastructure to query and manipulate large xml documents. Was not possible using the standard Java xml libraries or not as easily.
I was tempted to use it for portfolio performance calculations, but had already finished the Java version. A Scala version would have been easier t... |
554,948 | <p>I have the following class structure (abbreviated for sake of time, names changed) in my application. When I was writing the code I felt that the similarities between Action1 and Action2 should warrant some sort of generalization. I've provided the UML Class diagram with the relevant parts (except for the interfaces... | [
{
"answer_id": 554984,
"author": "Shog9",
"author_id": 811,
"author_profile": "https://Stackoverflow.com/users/811",
"pm_score": 3,
"selected": true,
"text": "<p><a href=\"http://msdn.microsoft.com/en-us/library/ms997507.aspx\" rel=\"nofollow\">Layered windows</a> (<code>WS_EX_LAYERED</c... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554948",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/67110/"
] | I have the following class structure (abbreviated for sake of time, names changed) in my application. When I was writing the code I felt that the similarities between Action1 and Action2 should warrant some sort of generalization. I've provided the UML Class diagram with the relevant parts (except for the interfaces, w... | [Layered windows](http://msdn.microsoft.com/en-us/library/ms997507.aspx) (`WS_EX_LAYERED`) should do the job, keeping in mind that you must use [`UpdateLayeredWindow()`](http://msdn.microsoft.com/en-us/library/ms633556(VS.85).aspx) and a somewhat unusual bitmap format (32-bit, pre-multiplied alpha) to specify per-pixel... |
554,949 | <p>I understand the difference between LET and LET* (parallel versus sequential binding), and as a theoretical matter it makes perfect sense. But is there any case where you've ever actually needed LET? In all of my Lisp code that I've looked at recently, you could replace every LET with LET* with no change.</p>
<p>... | [
{
"answer_id": 554994,
"author": "David Thornley",
"author_id": 14148,
"author_profile": "https://Stackoverflow.com/users/14148",
"pm_score": 4,
"selected": false,
"text": "<p>In LISP, there's often a desire to use the weakest possible constructs. Some style guides will tell you to use ... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554949",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53607/"
] | I understand the difference between LET and LET\* (parallel versus sequential binding), and as a theoretical matter it makes perfect sense. But is there any case where you've ever actually needed LET? In all of my Lisp code that I've looked at recently, you could replace every LET with LET\* with no change.
Edit: OK, ... | `LET` itself is not a real primitive in a *Functional Programming Language*, since it can replaced with `LAMBDA`. Like this:
```
(let ((a1 b1) (a2 b2) ... (an bn))
(some-code a1 a2 ... an))
```
is similar to
```
((lambda (a1 a2 ... an)
(some-code a1 a2 ... an))
b1 b2 ... bn)
```
But
```
(let* ((a1 b1) (a2 ... |
554,957 | <p>In Python, is there a better way to <strong>parameterise strings into regular expressions</strong> than doing it manually like this:</p>
<pre><code>test = 'flobalob'
names = ['a', 'b', 'c']
for name in names:
regexp = "%s" % (name)
print regexp, re.search(regexp, test)
</code></pre>
<p><em>This noddy examp... | [
{
"answer_id": 554989,
"author": "paprika",
"author_id": 61815,
"author_profile": "https://Stackoverflow.com/users/61815",
"pm_score": 4,
"selected": true,
"text": "<p>Well, as you build a regexp from a string, I see no other way. But you could <em>parameterise the string itself</em> wi... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554957",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42974/"
] | In Python, is there a better way to **parameterise strings into regular expressions** than doing it manually like this:
```
test = 'flobalob'
names = ['a', 'b', 'c']
for name in names:
regexp = "%s" % (name)
print regexp, re.search(regexp, test)
```
*This noddy example tries to match each name in turn. I kno... | Well, as you build a regexp from a string, I see no other way. But you could *parameterise the string itself* with a dictionary:
```
d = {'bar': 'a', 'foo': 'b'}
regexp = '%(foo)s|%(bar)s' % d
```
Or, depending on the problem, you could use list comprehensions:
```
vlist = ['a', 'b', 'c']
regexp = '|'.join([s for s... |
554,961 | <p>If I have a loop that requests my data from my form:</p>
<pre><code>for ($i=0;$i < count($_POST['checkbx']);$i++) {
// calculate the file from the checkbx
$filename = $_POST['checkbx'][$i];
$clearfilename = substr($filename, strrpos ($filename, "/") + 1);
echo "'".$filename."',";
}
</code>... | [
{
"answer_id": 554970,
"author": "Darryl Hein",
"author_id": 5441,
"author_profile": "https://Stackoverflow.com/users/5441",
"pm_score": 0,
"selected": false,
"text": "<p>Probably like this:</p>\n\n<pre><code>for ($i=0;$i < count($_POST['checkbx']);$i++) {\n// calculate the file from ... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554961",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | If I have a loop that requests my data from my form:
```
for ($i=0;$i < count($_POST['checkbx']);$i++) {
// calculate the file from the checkbx
$filename = $_POST['checkbx'][$i];
$clearfilename = substr($filename, strrpos ($filename, "/") + 1);
echo "'".$filename."',";
}
```
How do I add that ... | Even smaller:
```
$files = array();
foreach($_POST['checkbx'] as $file)
{
$files[] = basename($file);
}
```
If you aren't absolutely sure that `$_POST['checkbx']` exists and is an array you should prolly do:
```
$files = array();
if (is_array(@$_POST['checkbx']))
{
foreach($_POST['checkbx'] as $file)
{
... |
554,963 | <p>I am having a problem which is probably related to the Spring / class loader relationship.</p>
<p>I will apologise for the verbosity of the question now.</p>
<p>I have a number of legacy java applications which were originally written and intended to run within a dedicated JVM. We decided upon examination of the r... | [
{
"answer_id": 555015,
"author": "duffymo",
"author_id": 37213,
"author_profile": "https://Stackoverflow.com/users/37213",
"pm_score": 0,
"selected": false,
"text": "<p>Actually, I think it is. The first constructor argument you pass to the Jakarta object is of type abc.def.mdd.msg.alar... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554963",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am having a problem which is probably related to the Spring / class loader relationship.
I will apologise for the verbosity of the question now.
I have a number of legacy java applications which were originally written and intended to run within a dedicated JVM. We decided upon examination of the resource usage tha... | From the error message, it sounds like Spring is attempting to instantiate the object with this constructor:
```
public M2000AlarmChannel(String host, int port, String username, String password, MDDComponent componenet)
```
Looks like Spring is confused on which constructor to use, possibly because both constructors... |
554,969 | <p>I'm looking at the following apple example source code:</p>
<pre><code> /*
Cache the formatter. Normally you would use one of the date formatter styles (such as NSDateFormatterShortStyle), but here we want a specific format that excludes seconds.
*/
static NSDateFormatter *dateFormatter = nil;
if (dateFormatte... | [
{
"answer_id": 555000,
"author": "Jim Puls",
"author_id": 6010,
"author_profile": "https://Stackoverflow.com/users/6010",
"pm_score": 4,
"selected": false,
"text": "<p>\"<code>static</code>\" functionally means \"don't evaluate the stuff on the right side of the equals sign every time th... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554969",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/67141/"
] | I'm looking at the following apple example source code:
```
/*
Cache the formatter. Normally you would use one of the date formatter styles (such as NSDateFormatterShortStyle), but here we want a specific format that excludes seconds.
*/
static NSDateFormatter *dateFormatter = nil;
if (dateFormatter == nil) {
... | Static variables retain their assigned values over repeated calls to the function. They're basically like global values that are only "visible" to that function.
The initializer statement is only executed once however.
This code initializes dateFormatter to nil the first time the function is used. On every subsequent... |
554,974 | <p>I have the following code in C# and I am trying to find out why I am not able to access from a subclass that is from type list the elements of a class address. This is the code</p>
<pre><code>MemberList list = MemberDB.GetMembers("sql", m_page,
m_RecordPerPage, out count, _state);
/***************************... | [
{
"answer_id": 555014,
"author": "Chris Ballance",
"author_id": 1551,
"author_profile": "https://Stackoverflow.com/users/1551",
"pm_score": 0,
"selected": false,
"text": "<p>When referencing a public or protected method or property on the base class, be sure to prefix it with <code>base.... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554974",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/67144/"
] | I have the following code in C# and I am trying to find out why I am not able to access from a subclass that is from type list the elements of a class address. This is the code
```
MemberList list = MemberDB.GetMembers("sql", m_page,
m_RecordPerPage, out count, _state);
/*******************************/
public ... | I think your problem may be coming from being confused about the inheritance hierarchy of your *MemberList* class. It isn't actually a subclass of member at all, it is a subclass of List(Of T). When you replace the *T* with some class name all you are saying is that the list should be a list of that type, but the list ... |
554,996 | <p>I'm using Flash CS3 and ActionScript 2. I have a MovieClip symbol (identified as "MySymbol") that contains a dynamic text block with the identifier "innerText". The symbol is marked as "Export for ActionScript" using the following "MySymbol.as" file:</p>
<pre>
class MySymbol extends MovieClip
{
function S... | [
{
"answer_id": 555069,
"author": "euge1979",
"author_id": 62713,
"author_profile": "https://Stackoverflow.com/users/62713",
"pm_score": 3,
"selected": true,
"text": "<p>You are getting a compiler error because \"innerText\" is not available to the class at compile time (i.e. it's availab... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554996",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/65595/"
] | I'm using Flash CS3 and ActionScript 2. I have a MovieClip symbol (identified as "MySymbol") that contains a dynamic text block with the identifier "innerText". The symbol is marked as "Export for ActionScript" using the following "MySymbol.as" file:
```
class MySymbol extends MovieClip
{
function SetText(tex... | You are getting a compiler error because "innerText" is not available to the class at compile time (i.e. it's available at *runtime*).
A quick fix is to use
```
this['innerText'].text = text;
```
instead of
```
innerText.text = text;
``` |
554,997 | <p>Is it possible to cancel a <code>UIView</code> animation while it is in progress? Or would I have to drop to the CA level?</p>
<p>i.e. I've done something like this (maybe setting an end animation action too):</p>
<pre><code>[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:duration];
[UIView... | [
{
"answer_id": 840841,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "<p>I have the same problem; the APIs don't have anything to cancel some specific animation. The </p>\n\n<p><code>+ (void)setAn... | 2009/02/16 | [
"https://Stackoverflow.com/questions/554997",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32136/"
] | Is it possible to cancel a `UIView` animation while it is in progress? Or would I have to drop to the CA level?
i.e. I've done something like this (maybe setting an end animation action too):
```
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:duration];
[UIView setAnimationCurve: UIViewAnimat... | The way I do it is to create a new animation to your end point. Set a very short duration and make sure you use the `+setAnimationBeginsFromCurrentState:` method to start from the current state. When you set it to YES, the current animation is cut short. Looks something like this:
```
[UIView beginAnimations:nil conte... |
555,009 | <p>Using Python, I am trying to solve <a href="http://projecteuler.net/index.php?section=problems&id=4" rel="nofollow noreferrer">problem #4</a> of the <a href="http://projecteuler.net/" rel="nofollow noreferrer">Project Euler</a> problems. Can someone please tell me what I am doing incorrectly? The problem is to ... | [
{
"answer_id": 555020,
"author": "David Z",
"author_id": 56541,
"author_profile": "https://Stackoverflow.com/users/56541",
"pm_score": 3,
"selected": false,
"text": "<p>Try computing x from the product of z and y rather than checking every number from 1 to a million. Think about it: if y... | 2009/02/16 | [
"https://Stackoverflow.com/questions/555009",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47204/"
] | Using Python, I am trying to solve [problem #4](http://projecteuler.net/index.php?section=problems&id=4) of the [Project Euler](http://projecteuler.net/) problems. Can someone please tell me what I am doing incorrectly? The problem is to **Find the largest palindrome made from the product of two 3-digit numbers**. Here... | Try computing x from the product of z and y rather than checking every number from 1 to a million. Think about it: if you were asked to calculate 500\*240, which is more efficient - multiplying them, or counting up from 1 until you find the right answer? |
555,013 | <p>Is it possible to have a structure nested within a structure in Clojure? Consider the following code:</p>
<pre><code>(defstruct rect :height :width)
(defstruct color-rect :color (struct rect))
(defn
#^{:doc "Echoes the details of the rect passed to it"}
echo-rect
[r]
(println (:color r))
(println (:height r)... | [
{
"answer_id": 555094,
"author": "Mo.",
"author_id": 1870,
"author_profile": "https://Stackoverflow.com/users/1870",
"pm_score": 1,
"selected": false,
"text": "<p>I am really new to clojure, so I might be wrong. But I think, you can't do something like</p>\n\n<pre><code>(defstruct color-... | 2009/02/16 | [
"https://Stackoverflow.com/questions/555013",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2820/"
] | Is it possible to have a structure nested within a structure in Clojure? Consider the following code:
```
(defstruct rect :height :width)
(defstruct color-rect :color (struct rect))
(defn
#^{:doc "Echoes the details of the rect passed to it"}
echo-rect
[r]
(println (:color r))
(println (:height r))
(println (:... | I would agree with other posters in that struct maps don't really support inheritance. However, if you want to just make a new struct that uses the keys of another, this will work:
```
; Create the rect struct
(defstruct rect :height :width)
; Create the color-rect using all the keys from rect, with color added on
(d... |
555,016 | <p>I need to disable JQuery tabs programmatically. The tabs are inside an update panel (Ajax) and the update panel is in an ASP.NET page.
Code:</p>
<pre><code><link type="text/css" rel="stylesheet" href="http://ui.jquery.com/testing/themes/base/ui.all.css" />
<script type="text/javascript" src="http://code.... | [
{
"answer_id": 555028,
"author": "Chris Ballance",
"author_id": 1551,
"author_profile": "https://Stackoverflow.com/users/1551",
"pm_score": 3,
"selected": false,
"text": "<p>Sounds like you need a button that has a <strong>client-side</strong> action instead of one that posts back.</p>\n... | 2009/02/16 | [
"https://Stackoverflow.com/questions/555016",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/63150/"
] | I need to disable JQuery tabs programmatically. The tabs are inside an update panel (Ajax) and the update panel is in an ASP.NET page.
Code:
```
<link type="text/css" rel="stylesheet" href="http://ui.jquery.com/testing/themes/base/ui.all.css" />
<script type="text/javascript" src="http://code.jquery.com/jquery-lates... | I've use following way and for me work 100% properly:
the first i create a function and write my jquery function in to the function in the my page:
```
<script>
function myFunction(params) {
$.my_jquery(params...)
......
}
</script>
```
then i used this code in event handler of my control(fo... |
555,022 | <p>In Silverlight 2, using C# on ASP.NET, you can pass a set of Initialization Parameters by assigning the Silverlight object's InitiParams with a string that's a series of comma separated key/value pairs.</p>
<p>I've seen other systems that have a similar mechanism for passing around collections of key/value pairs as... | [
{
"answer_id": 555067,
"author": "Randolpho",
"author_id": 12716,
"author_profile": "https://Stackoverflow.com/users/12716",
"pm_score": 3,
"selected": true,
"text": "<p>Unfortunately, after a quick Googling I don't think the parsing mechanism for InitParams follows any sort of encoding ... | 2009/02/16 | [
"https://Stackoverflow.com/questions/555022",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1463/"
] | In Silverlight 2, using C# on ASP.NET, you can pass a set of Initialization Parameters by assigning the Silverlight object's InitiParams with a string that's a series of comma separated key/value pairs.
I've seen other systems that have a similar mechanism for passing around collections of key/value pairs as a single ... | Unfortunately, after a quick Googling I don't think the parsing mechanism for InitParams follows any sort of encoding scheme. It'd actually be better if it were a URL Query String fragment, which has a fairly standard encoding and rules and is comma friendly.
So I think your only option is to use a different delimete... |
555,031 | <p>I'm taking an existing JS library I wrote up some time ago, and trying to organize it under a common namespace...Here is an example of the technique I am trying to use:</p>
<pre><code>var NameSpace = new function ()
{
var privateMember = [];
function privateMethod() {};
return
{
P... | [
{
"answer_id": 555063,
"author": "TomHastjarjanto",
"author_id": 53170,
"author_profile": "https://Stackoverflow.com/users/53170",
"pm_score": 4,
"selected": true,
"text": "<pre><code>var NameSpace= function ()\n{\n var privateMember = new Array();\n\n function privateMethod() { };... | 2009/02/16 | [
"https://Stackoverflow.com/questions/555031",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1965/"
] | I'm taking an existing JS library I wrote up some time ago, and trying to organize it under a common namespace...Here is an example of the technique I am trying to use:
```
var NameSpace = new function ()
{
var privateMember = [];
function privateMethod() {};
return
{
PublicMethod1 : ... | ```
var NameSpace= function ()
{
var privateMember = new Array();
function privateMethod() { };
return {
PublicMethod1 : function(arg, arg2)
{
// etc
},
PublicMethod2 : function ()
{
// etc
},
PublicMethod3 ... |
555,038 | <p>Using this code:</p>
<pre><code>#include <fstream>
#include <boost/archive/text_oarchive.hpp>
using namespace std;
int main()
{
std::ofstream ofs("c:\test");
boost::archive::text_oarchive oa(ofs);
}
</code></pre>
<p>I'm getting an unhandled exception at runtime on executing the boost archive... | [
{
"answer_id": 555080,
"author": "paxdiablo",
"author_id": 14860,
"author_profile": "https://Stackoverflow.com/users/14860",
"pm_score": 2,
"selected": false,
"text": "<p>You need to catch the exception and then examine its exception_code to see what the root cause is.</p>\n"
},
{
... | 2009/02/16 | [
"https://Stackoverflow.com/questions/555038",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18909/"
] | Using this code:
```
#include <fstream>
#include <boost/archive/text_oarchive.hpp>
using namespace std;
int main()
{
std::ofstream ofs("c:\test");
boost::archive::text_oarchive oa(ofs);
}
```
I'm getting an unhandled exception at runtime on executing the boost archive line:
```
boost::exception_detail::... | The following line is in error:
```
std::ofstream ofs("c:\test");
```
The compiler would've spit out a warning (at least) if your file was called `jest`; but `'\t'` -- being the escape for inserting a tab, your error goes by uncaught. In short, the file will not be created. You can test this with:
```
if (ofs.good... |
555,043 | <p>I'm writing my third app, and I already have an app in the App Store, but I still don't get this App ID business.</p>
<p>I created the App IDs for my first two applications like this:</p>
<pre>XXXXXXXXXX.me.cbg.FirstApp
YYYYYYYYYY.me.cbg.SecondApp</pre>
<p>but then Apple introduced the App ID wizard, which I used... | [
{
"answer_id": 555085,
"author": "Andrew Grant",
"author_id": 1043,
"author_profile": "https://Stackoverflow.com/users/1043",
"pm_score": 5,
"selected": true,
"text": "<p>Both are \"proper\", it's mostly a question of the tradeoff between ease of management and allowing more granular man... | 2009/02/16 | [
"https://Stackoverflow.com/questions/555043",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2119/"
] | I'm writing my third app, and I already have an app in the App Store, but I still don't get this App ID business.
I created the App IDs for my first two applications like this:
```
XXXXXXXXXX.me.cbg.FirstApp
YYYYYYYYYY.me.cbg.SecondApp
```
but then Apple introduced the App ID wizard, which I used to create the App I... | Both are "proper", it's mostly a question of the tradeoff between ease of management and allowing more granular management of certificates.
There two technical difference:
1. Applications with IDs that are
identical save from the top level
(e.g. com.mycompany.aaa and
com.mycompany.bbb) are able to
access each others ... |
555,045 | <p>What is NHibernate HQL's Equivalent to T-SQL's TOP Keyword?</p>
<p>Also what is the non-HQL way for saying give me the first 15 of a class?</p>
| [
{
"answer_id": 555065,
"author": "mookid8000",
"author_id": 6560,
"author_profile": "https://Stackoverflow.com/users/6560",
"pm_score": 6,
"selected": true,
"text": "<p>It's actually pretty easy in HQL:</p>\n\n<pre><code>var top15 = session.CreateQuery(\"from SomeEntity\")\n ... | 2009/02/16 | [
"https://Stackoverflow.com/questions/555045",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36590/"
] | What is NHibernate HQL's Equivalent to T-SQL's TOP Keyword?
Also what is the non-HQL way for saying give me the first 15 of a class? | It's actually pretty easy in HQL:
```
var top15 = session.CreateQuery("from SomeEntity")
.SetFirstResult(0)
.SetMaxResults(15)
.List<SomeEntity>();
```
Don't know how to do this using the criteria API though. |
555,047 | <p>How do I get 'anotherColumnName' in LINQ?</p>
<pre><code>SELECT thisColumnName as anotherColumnName FROM TableName
</code></pre>
<p>I have the following which obviously gives me 'thisColumnName' not 'anotherColumnName'</p>
<pre><code> var query = from names in _context.TableName
select names;
... | [
{
"answer_id": 555049,
"author": "Ian P",
"author_id": 10853,
"author_profile": "https://Stackoverflow.com/users/10853",
"pm_score": 4,
"selected": true,
"text": "<p>Use an anonymous type:</p>\n\n<pre><code>var query = (from name in _context.Table\n select new { anotherColumnN... | 2009/02/16 | [
"https://Stackoverflow.com/questions/555047",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6268/"
] | How do I get 'anotherColumnName' in LINQ?
```
SELECT thisColumnName as anotherColumnName FROM TableName
```
I have the following which obviously gives me 'thisColumnName' not 'anotherColumnName'
```
var query = from names in _context.TableName
select names;
return query.ToList();
``` | Use an anonymous type:
```
var query = (from name in _context.Table
select new { anotherColumnName = name.ColumnName });
```
Good luck! |
555,073 | <p>I have an operation contract (below) that I want to allow GET and POST requests against. How can I tell WCF to accept both types of requests for a single OperationContract?</p>
<pre><code>[OperationContract,
WebInvoke(Method="POST",
BodyStyle = WebMessageBodyStyle.Bare,
RequestFormat = WebMessageFormat.Xml... | [
{
"answer_id": 555078,
"author": "Ian P",
"author_id": 10853,
"author_profile": "https://Stackoverflow.com/users/10853",
"pm_score": -1,
"selected": false,
"text": "<p>Not using WebInvoke will do the trick.</p>\n\n<p>That may not be the answer you're looking for, though.</p>\n"
},
{
... | 2009/02/16 | [
"https://Stackoverflow.com/questions/555073",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3957/"
] | I have an operation contract (below) that I want to allow GET and POST requests against. How can I tell WCF to accept both types of requests for a single OperationContract?
```
[OperationContract,
WebInvoke(Method="POST",
BodyStyle = WebMessageBodyStyle.Bare,
RequestFormat = WebMessageFormat.Xml,
ResponseF... | This post over on the [MSDN Forums by Carlos Figueira](http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/ad5bb2f0-058c-47ae-bcf3-8f5c4727a70e/) has a solution. I'll go with this for now but if anyone else has any cleaner solutions let me know.
```
[OperationContract,
WebInvoke(Method="POST",
BodyStyle = Web... |
555,100 | <p>Customer X has asked for ways to improve the startup time of a Java process he uses. The problem is, it is not run through a jar file, but rather 'jnlp' (which I am assuming indicates it is a java webstart application)</p>
<pre><code>StartUserWorx.jnlp
</code></pre>
<p>Is there a way to convert this to a JAR file ... | [
{
"answer_id": 555082,
"author": "CJM",
"author_id": 6898,
"author_profile": "https://Stackoverflow.com/users/6898",
"pm_score": 2,
"selected": false,
"text": "<p>Honestly? Use <a href=\"http://www.truecrypt.org/\" rel=\"nofollow noreferrer\">TrueCrypt</a> or <a href=\"http://keepass.inf... | 2009/02/17 | [
"https://Stackoverflow.com/questions/555100",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42223/"
] | Customer X has asked for ways to improve the startup time of a Java process he uses. The problem is, it is not run through a jar file, but rather 'jnlp' (which I am assuming indicates it is a java webstart application)
```
StartUserWorx.jnlp
```
Is there a way to convert this to a JAR file and then have the user inv... | There is a project called [sqlite-crypt](http://sqlite-crypt.com/documentation.htm). Which should be your best bet. sqlite db with all data on disk encrypted. |
555,108 | <p>I have a c++ class, let's say it's called c, and I want to use the implicit copy constructor in one of the methods, like this:</p>
<pre><code>c c::do_something() {
c copy = this; //I want implicit copy constructor here!
copy.something_else();
//........//
return copy;
}
</code></pre>
<p>However, gcc retur... | [
{
"answer_id": 555113,
"author": "tliff",
"author_id": 65502,
"author_profile": "https://Stackoverflow.com/users/65502",
"pm_score": 6,
"selected": true,
"text": "<p><em>this</em> is a pointer to an object so it should be</p>\n\n<pre><code>c copy = *this;\n</code></pre>\n"
},
{
"... | 2009/02/17 | [
"https://Stackoverflow.com/questions/555108",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a c++ class, let's say it's called c, and I want to use the implicit copy constructor in one of the methods, like this:
```
c c::do_something() {
c copy = this; //I want implicit copy constructor here!
copy.something_else();
//........//
return copy;
}
```
However, gcc returns this error:
>
> error... | *this* is a pointer to an object so it should be
```
c copy = *this;
``` |
555,139 | <p>Last time I tried setting up name based virtual hosting on my development machine I just gave up and mapped websites to different ports. This time, I'm trying to do it right :)!</p>
<p>I've properly registered DNS entries and sending two different headers to the server:</p>
<pre><code>Host: dev.site1.com
Host: dev... | [
{
"answer_id": 555134,
"author": "Rex M",
"author_id": 67,
"author_profile": "https://Stackoverflow.com/users/67",
"pm_score": 3,
"selected": false,
"text": "<p>Be prepared for abstractions. Lots and lots of abstractions ;)</p>\n"
},
{
"answer_id": 555150,
"author": "Fritz H"... | 2009/02/17 | [
"https://Stackoverflow.com/questions/555139",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44041/"
] | Last time I tried setting up name based virtual hosting on my development machine I just gave up and mapped websites to different ports. This time, I'm trying to do it right :)!
I've properly registered DNS entries and sending two different headers to the server:
```
Host: dev.site1.com
Host: dev.site2.com
```
Howe... | I would suggest the following books:
* [Java Enterprise in a nutshell, O'Reilly](https://rads.stackoverflow.com/amzn/click/com/0596101422)
* [Effective Enterprise Java](https://rads.stackoverflow.com/amzn/click/com/0321130006)
* [Java Enterprise best practices, O'Reilly](https://rads.stackoverflow.com/amzn/click/com/0... |
555,156 | <p>I would like to set the <code>Body</code> of an <code>AppointmentItem</code> to a string of RTF that contains an embedded image. Setting <code>Microsoft.Office.Interop.Outlook.AppointmentItem.Body</code> results in the RTF appearing as-is in the appointment. </p>
<p>I have tried using <a href="http://www.dimastr.... | [
{
"answer_id": 4578195,
"author": "Omer",
"author_id": 260079,
"author_profile": "https://Stackoverflow.com/users/260079",
"pm_score": 2,
"selected": false,
"text": "<p>The only way I know is to access the AppointmentItem's GetInspector property, and use it to fetch the underlying WordEd... | 2009/02/17 | [
"https://Stackoverflow.com/questions/555156",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1177/"
] | I would like to set the `Body` of an `AppointmentItem` to a string of RTF that contains an embedded image. Setting `Microsoft.Office.Interop.Outlook.AppointmentItem.Body` results in the RTF appearing as-is in the appointment.
I have tried using [Redemption](http://www.dimastr.com/redemption/) which wraps the appointm... | The only way I know is to access the AppointmentItem's GetInspector property, and use it to fetch the underlying WordEditor used to parse the RTF format, something like:
```
var doc = appointment.GetInspector.WordEditor as Microsoft.Office.Interop.Word.Document;
```
and then format the document using doc.Content acc... |
555,169 | <p>In MySQL you can quite simply read a file with <code>SELECT load_file('foo.txt')</code> and write to a file with <code>SELECT 'text' INTO DUMPFILE 'foo.txt'</code>.</p>
<p>I am looking for a way to do this in MSSQL 2000 without using any external tools, just with queries or stored procedures.</p>
| [
{
"answer_id": 555216,
"author": "volatilsis",
"author_id": 45789,
"author_profile": "https://Stackoverflow.com/users/45789",
"pm_score": 2,
"selected": false,
"text": "<p>There are a few ways you can do this.</p>\n\n<p>using xp_cmdshell:</p>\n\n<pre><code>declare @writetofile varchar(10... | 2009/02/17 | [
"https://Stackoverflow.com/questions/555169",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/66760/"
] | In MySQL you can quite simply read a file with `SELECT load_file('foo.txt')` and write to a file with `SELECT 'text' INTO DUMPFILE 'foo.txt'`.
I am looking for a way to do this in MSSQL 2000 without using any external tools, just with queries or stored procedures. | For input, you can use the text file ODBC driver:
```
select * from OpenRowset('MSDASQL',
'Driver={Microsoft Text Driver (*.txt;
*.csv)};DefaultDir=c:\;','select * from [FileName.csv]')
```
Assuming the output file already exists, you can use Jet to write to it:
```
INSERT INTO
OPENROWSET('Microsoft.Jet.OLEDB.4.0',... |
555,171 | <p>I have a function that exports values into a CSV file, but the "comments" field has commas in it and it messes up the columns when you open it in a spreadsheet program.</p>
<p>Is there a way around exporting it properly?</p>
<pre><code>//this exports only names and comments into a CSV file
function exportNamesComm... | [
{
"answer_id": 555173,
"author": "Ryan Emerle",
"author_id": 62195,
"author_profile": "https://Stackoverflow.com/users/62195",
"pm_score": 2,
"selected": false,
"text": "<p>You'll want to wrap the entry in a qualifier; typically quotes.</p>\n\n<pre><code>\"col1\", \"col2,,,\", \"col3\"\n... | 2009/02/17 | [
"https://Stackoverflow.com/questions/555171",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26130/"
] | I have a function that exports values into a CSV file, but the "comments" field has commas in it and it messes up the columns when you open it in a spreadsheet program.
Is there a way around exporting it properly?
```
//this exports only names and comments into a CSV file
function exportNamesCommentsCSV($table, $colu... | What you need to do is enclose values in quotes, like so:
```
"value","value","value"
```
This will correctly handle commas in the values, and numeric values will also still work fine.
To put a quote in the value, however, you need to put two quotes together. E.g. representing this string:
```
Bobby says, "Hi!"
`... |
555,191 | <p>Is there such a thing as an atomic test-and-set, semaphore, or lock in Javascript?</p>
<p>I have javascript invoking async background processes via a custom protocol (the background process literally runs in a separate process, unrelated to the browser). I believe I'm running into a race condition; the background p... | [
{
"answer_id": 555226,
"author": "perrohunter",
"author_id": 53991,
"author_profile": "https://Stackoverflow.com/users/53991",
"pm_score": 2,
"selected": false,
"text": "<p>Maybe you could implement a basic integer semaphore, just add the variable into the DOM and lock/unlock it and make... | 2009/02/17 | [
"https://Stackoverflow.com/questions/555191",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13055/"
] | Is there such a thing as an atomic test-and-set, semaphore, or lock in Javascript?
I have javascript invoking async background processes via a custom protocol (the background process literally runs in a separate process, unrelated to the browser). I believe I'm running into a race condition; the background process ret... | JavaScript has no locking semantics because JS is not a multi threaded language. Multiple threads can only operate concurrently in completely distinct contexts -- eg. HTML5 Worker threads, or in things like multiple instances of JavaScriptCore API's context object (I assume SpiderMonkey has a similar concept). They can... |
555,197 | <p>I'm using an <a href="https://msdn.microsoft.com/en-us/library/06s37a7f.aspx" rel="noreferrer">Or</a> statement in my case expression.</p>
<p>Even though I have a value within this range, it didn't find a match. Why not?</p>
<p><strong>Example Code</strong>:</p>
<pre><code>Select Case 2
Case 0
' Some ... | [
{
"answer_id": 555199,
"author": "achinda99",
"author_id": 60824,
"author_profile": "https://Stackoverflow.com/users/60824",
"pm_score": 2,
"selected": false,
"text": "<p>This will allow you to perform \"something\" in the case of 0, \"something else\" in the case of 1, \"hit\" in the ca... | 2009/02/17 | [
"https://Stackoverflow.com/questions/555197",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27765/"
] | I'm using an [Or](https://msdn.microsoft.com/en-us/library/06s37a7f.aspx) statement in my case expression.
Even though I have a value within this range, it didn't find a match. Why not?
**Example Code**:
```
Select Case 2
Case 0
' Some logic
Case 1
' Some other logic
Case 2 Or 3
... | Use the comma operator to delimit case statements
```
Select Case 2
Case 0,1,2,3
Console.WriteLine("hit")
End Select
``` |
555,241 | <p>I'am unclear as to what the roles and responsibility of the factory class is. I know enough that the factory class should be resposible for the creation of domain objects (aggregate root) along with its associated entities and value objects.</p>
<p>But what is not clear to me is where the factory "layer" lies with... | [
{
"answer_id": 555356,
"author": "Charlie Martin",
"author_id": 35092,
"author_profile": "https://Stackoverflow.com/users/35092",
"pm_score": 2,
"selected": false,
"text": "<p>The DDD guys and I might argue about this, but basically the idea of that "factory" class is to issue ... | 2009/02/17 | [
"https://Stackoverflow.com/questions/555241",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'am unclear as to what the roles and responsibility of the factory class is. I know enough that the factory class should be resposible for the creation of domain objects (aggregate root) along with its associated entities and value objects.
But what is not clear to me is where the factory "layer" lies with a DDD arch... | >
> But what is not clear to me is where
> the factory "layer" lies with a DDD
> architecture? Should the factory be
> calling directly into the repository
> to get its data or the service
> library?
>
>
>
The factory should be the one-stop shop to construct domain objects. Any other part of the code that nee... |
555,246 | <p>I have two tables in a SQLite DB, INVITEM and SHOPITEM. Their shared attribute is ItemId and I want to perform an INNER JOIN. Here's the query:</p>
<pre><code> SELECT INVITEM.CharId AS CharId,
INVITEM.ItemId AS ItemId
FROM (INVITEM as INVITEM
INNER JOIN SHOPITEM AS SHOPITEM
ON S... | [
{
"answer_id": 555253,
"author": "geofftnz",
"author_id": 20122,
"author_profile": "https://Stackoverflow.com/users/20122",
"pm_score": 2,
"selected": true,
"text": "<p>I would steer clear of allowing the user to write SQL clauses directly. This is the source of SQL Injection vulnerabili... | 2009/02/17 | [
"https://Stackoverflow.com/questions/555246",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39301/"
] | I have two tables in a SQLite DB, INVITEM and SHOPITEM. Their shared attribute is ItemId and I want to perform an INNER JOIN. Here's the query:
```
SELECT INVITEM.CharId AS CharId,
INVITEM.ItemId AS ItemId
FROM (INVITEM as INVITEM
INNER JOIN SHOPITEM AS SHOPITEM
ON SHOPITEM.ItemId... | I would steer clear of allowing the user to write SQL clauses directly. This is the source of SQL Injection vulnerabilities.
If you need the query to be flexible, try parsing the user's input and adding the appropriate where clause.
Here is some C# code to show the general idea
```
// from user input
string user_col... |
555,252 | <p>The default behavior of a WPF <code>ContextMenu</code> is to display it when the user right-clicks. I want the <code>ContextMenu</code> to show when the user left-clicks. It seems like this should be a simple property on <code>ContextMenu</code>, but it is not.</p>
<p>I rigged it, so that I handle the <code>LeftM... | [
{
"answer_id": 563359,
"author": "Caleb Vear",
"author_id": 67731,
"author_profile": "https://Stackoverflow.com/users/67731",
"pm_score": 4,
"selected": true,
"text": "<p>What I would suggest doing is making a new static class with attached DependencyProperty. Call the class LeftClickCo... | 2009/02/17 | [
"https://Stackoverflow.com/questions/555252",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/60465/"
] | The default behavior of a WPF `ContextMenu` is to display it when the user right-clicks. I want the `ContextMenu` to show when the user left-clicks. It seems like this should be a simple property on `ContextMenu`, but it is not.
I rigged it, so that I handle the `LeftMouseButtonDown` event in the code-behind and then ... | What I would suggest doing is making a new static class with attached DependencyProperty. Call the class LeftClickContextMenu and the property Enabled (just ideas). When your registering the DependencyProperty add an on changed callback. Then in the property changed callback if Enabled is set to true then add a handler... |
555,265 | <p>I have a VB.NET program where I'm using a WebBrowser control to simulate a timesheet form. For data entry, I'm using a DateTimePicker control that sits on top of the WebBrowser control, which I have programmed to move on top of the cell of the table in the WebBrowser control when the WebBrowser control is clicked on... | [
{
"answer_id": 555321,
"author": "JeffK",
"author_id": 5420,
"author_profile": "https://Stackoverflow.com/users/5420",
"pm_score": 2,
"selected": false,
"text": "<p>I think you're looking for the <a href=\"http://msdn.microsoft.com/en-us/library/wtzka3b5.aspx\" rel=\"nofollow noreferrer\... | 2009/02/17 | [
"https://Stackoverflow.com/questions/555265",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a VB.NET program where I'm using a WebBrowser control to simulate a timesheet form. For data entry, I'm using a DateTimePicker control that sits on top of the WebBrowser control, which I have programmed to move on top of the cell of the table in the WebBrowser control when the WebBrowser control is clicked on. (... | I think you're looking for the [Control.Invalidate](http://msdn.microsoft.com/en-us/library/wtzka3b5.aspx) method.
But after re-reading your question, I'm not really sure. Maybe you're trying to have the DateTimePicker get clipped by the borders of the WebBrowser control... In that case, you need to make sure that you... |
555,296 | <p>I have the following SQL result set (as result of a join FWIW):</p>
<pre><code>A,C
B,E
C,A
D,A
</code></pre>
<p>Every value represents a node. So the total set of nodes involved is A,B,C,D,E. Every row describes a directed edge.</p>
<pre><code>A -> C
B -> E
C -> A
D -> A
</code></pre>
<p>Of course th... | [
{
"answer_id": 555310,
"author": "cletus",
"author_id": 18393,
"author_profile": "https://Stackoverflow.com/users/18393",
"pm_score": 2,
"selected": true,
"text": "<p>Imagine a table Nodes with columns Node1 and Node2.</p>\n\n<pre><code>SELECT node1, node2\nFROM nodes n\nWHERE EXISTS (SE... | 2009/02/17 | [
"https://Stackoverflow.com/questions/555296",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33165/"
] | I have the following SQL result set (as result of a join FWIW):
```
A,C
B,E
C,A
D,A
```
Every value represents a node. So the total set of nodes involved is A,B,C,D,E. Every row describes a directed edge.
```
A -> C
B -> E
C -> A
D -> A
```
Of course this can be simplified to
```
A <-> C
B -> E
D -> A
```
Now ... | Imagine a table Nodes with columns Node1 and Node2.
```
SELECT node1, node2
FROM nodes n
WHERE EXISTS (SELECT 1 FROM nodes WHERE node1 = n.node2 AND node2 = n.node1)
```
Of course you'll want to make sure its appropriate indexed, namely:
```
(node1, node2)
```
and
```
(node2, node1)
```
This will still get you... |
555,298 | <p>Is it possible to dynamically define methods in Objective-C like we would in Ruby?</p>
<pre><code>[:failure, :error, :success].each do |method|
define_method method do
self.state = method
end
end
</code></pre>
| [
{
"answer_id": 555360,
"author": "Charlie Martin",
"author_id": 35092,
"author_profile": "https://Stackoverflow.com/users/35092",
"pm_score": 0,
"selected": false,
"text": "<p>I don't beleive it's possible, because Objective C is, after all, a compiled language. Your \"define method\" w... | 2009/02/17 | [
"https://Stackoverflow.com/questions/555298",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/67184/"
] | Is it possible to dynamically define methods in Objective-C like we would in Ruby?
```
[:failure, :error, :success].each do |method|
define_method method do
self.state = method
end
end
``` | Actually it is possible to do this, although it's not supported by the obj-c syntax, the obj-c runtime provides functions that can do it. The one you want is `class_addMethod`, but off the top of my head i cannot remember the exact specifics of how. All the runtime methods are documented at [developer.apple.com](http:/... |
555,315 | <p>how do i define the success and failure function of an ajax $.post?</p>
| [
{
"answer_id": 555317,
"author": "Jere.Jones",
"author_id": 19476,
"author_profile": "https://Stackoverflow.com/users/19476",
"pm_score": 8,
"selected": true,
"text": "<p>The documentation is here: <a href=\"http://docs.jquery.com/Ajax/jQuery.ajax\" rel=\"noreferrer\">http://docs.jquery.... | 2009/02/17 | [
"https://Stackoverflow.com/questions/555315",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49632/"
] | how do i define the success and failure function of an ajax $.post? | The documentation is here: <http://docs.jquery.com/Ajax/jQuery.ajax>
But, to summarize, the ajax call takes a bunch of options. the ones you are looking for are error and success.
You would call it like this:
```
$.ajax({
url: 'mypage.html',
success: function(){
alert('success');
},
error: function(){
... |
555,320 | <p>Is there a way without looping all the IEnumerable to get back the data inside the object (that inherited BindingList)?</p>
<pre><code>MyListObject--> Transformed with Linq --> Back the data inside MyListObject
</code></pre>
<p>I know that I can do .ToList but it doesn't do what I would like.</p>
<p>Any ide... | [
{
"answer_id": 555387,
"author": "cstick",
"author_id": 2735,
"author_profile": "https://Stackoverflow.com/users/2735",
"pm_score": 1,
"selected": false,
"text": "<p>Most lists accept a range of objects in the constructor. Will that work?</p>\n\n<pre><code>Dim objects = 'Linq statement ... | 2009/02/17 | [
"https://Stackoverflow.com/questions/555320",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13913/"
] | Is there a way without looping all the IEnumerable to get back the data inside the object (that inherited BindingList)?
```
MyListObject--> Transformed with Linq --> Back the data inside MyListObject
```
I know that I can do .ToList but it doesn't do what I would like.
Any idea? Thank :) | I'm not sure exactly what your requirements are, especially the bit about `ToList` not doing what you need.
Unfortunately, `BindingList<T>` only accepts an `IList<T>` parameter in its constructor and not an `IEnumerable<T>`.
However, if you implement a pass-through constructor on your custom collection (or if it alre... |
555,330 | <p>I have to deal with a library that consists of many templated classes, which are of course all implemented in header files. Now I'm trying to find a way to reduce the unbearably long compile times that come from the fact that I pretty much have to include the whole library in each and one of my compilation units.</p... | [
{
"answer_id": 555349,
"author": "Logan Capaldo",
"author_id": 61289,
"author_profile": "https://Stackoverflow.com/users/61289",
"pm_score": 5,
"selected": false,
"text": "<p>You can't forward declare \"parts\" of classes like that. Even if you could, you'd still need to instantiate the ... | 2009/02/17 | [
"https://Stackoverflow.com/questions/555330",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have to deal with a library that consists of many templated classes, which are of course all implemented in header files. Now I'm trying to find a way to reduce the unbearably long compile times that come from the fact that I pretty much have to include the whole library in each and one of my compilation units.
Is u... | You can't forward declare "parts" of classes like that. Even if you could, you'd still need to instantiate the code somewhere so you could link against it. There are ways to handle it, you could make yourself a little library with instantiations of common containers (e.g. vector) and link them in. Then you'd only ever ... |
555,331 | <p>So I have this table, with 3 columns: ID (unique key), PositionID, and SupervisorID. PositionID and SupervisorID are both foreign keys to a Positions table.</p>
<p>What I haven't been able to figure out is a decently nice way of getting <em>inherited</em> subordinates. So for example:</p>
<hr>
<p><strong>ID</st... | [
{
"answer_id": 555346,
"author": "paxdiablo",
"author_id": 14860,
"author_profile": "https://Stackoverflow.com/users/14860",
"pm_score": 1,
"selected": false,
"text": "<p>You can do this to a certain depth with standard SQL (and probably any depth with various SQL enhancements) but the S... | 2009/02/17 | [
"https://Stackoverflow.com/questions/555331",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | So I have this table, with 3 columns: ID (unique key), PositionID, and SupervisorID. PositionID and SupervisorID are both foreign keys to a Positions table.
What I haven't been able to figure out is a decently nice way of getting *inherited* subordinates. So for example:
---
**ID** **PositionID** **SupervisorID**
`... | Recursive Common Table Expressions:
<http://msdn.microsoft.com/en-us/library/ms186243.aspx> |
555,344 | <p>How can I match one or more parenthetical expressions appearing at the end of string?</p>
<p>Input:</p>
<pre><code>'hello (i) (m:foo)'
</code></pre>
<p>Desired output:</p>
<pre><code>['i', 'm:foo']
</code></pre>
<p>Intended for a python script. Paren marks cannot appear inside of each other (<a href="http://i89... | [
{
"answer_id": 555370,
"author": "too much php",
"author_id": 28835,
"author_profile": "https://Stackoverflow.com/users/28835",
"pm_score": 3,
"selected": false,
"text": "<p>You don't <em>need</em> to use regex:</p>\n\n<pre><code>def splitter(input):\n return [ s.rstrip(\" \\t)\") for... | 2009/02/17 | [
"https://Stackoverflow.com/questions/555344",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41613/"
] | How can I match one or more parenthetical expressions appearing at the end of string?
Input:
```
'hello (i) (m:foo)'
```
Desired output:
```
['i', 'm:foo']
```
Intended for a python script. Paren marks cannot appear inside of each other ([no nesting](http://i89.photobucket.com/albums/k220/kipper_308/fran_web.jpg... | ```
paren_pattern = re.compile(r"\(([^()]*)\)(?=(?:\s*\([^()]*\))*\s*$)")
def getParens(s):
return paren_pattern.findall(s)
```
or even shorter:
```
getParens = re.compile(r"\(([^()]*)\)(?=(?:\s*\([^()]*\))*\s*$)").findall
```
explaination:
```
\( # opening paren
([^()]*) # co... |
555,369 | <p>Is there a way to create a service using C# able to check if this client is Open?</p>
<p>I need to work a way to automate that checking.</p>
| [
{
"answer_id": 555399,
"author": "Infamy",
"author_id": 66270,
"author_profile": "https://Stackoverflow.com/users/66270",
"pm_score": 3,
"selected": true,
"text": "<p>If the window is open (does not need to be in focus) You could use FindWindow window call from the user32.dll to check on... | 2009/02/17 | [
"https://Stackoverflow.com/questions/555369",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/65554/"
] | Is there a way to create a service using C# able to check if this client is Open?
I need to work a way to automate that checking. | If the window is open (does not need to be in focus) You could use FindWindow window call from the user32.dll to check on the window. Cut up the code below and place in the correct places (for the using, define of the dllimport, and the actual code). This will tell you if the window is open, there is a LOT more you can... |
555,376 | <p>I am having problems with the greps in Emacs. </p>
<p>a) grep doesnt seem to understand the .[ch] for searching .c and .h files. This is a default option provided by Emacs with the <strong>lgrep</strong> command. The example is searching for the word "global" in .c/.h files.</p>
<pre><code>grep -i -nH "global" *.[... | [
{
"answer_id": 555459,
"author": "jcrossley3",
"author_id": 66451,
"author_profile": "https://Stackoverflow.com/users/66451",
"pm_score": 1,
"selected": false,
"text": "<p>I usually just use <code>M-x grep</code> and alter the command line args when prompted if I need to. But I just tri... | 2009/02/17 | [
"https://Stackoverflow.com/questions/555376",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2386/"
] | I am having problems with the greps in Emacs.
a) grep doesnt seem to understand the .[ch] for searching .c and .h files. This is a default option provided by Emacs with the **lgrep** command. The example is searching for the word "global" in .c/.h files.
```
grep -i -nH "global" *.[ch]
grep: *.[ch]: No such file or ... | Well, there is always [Ack](http://petdance.com/ack/) and [Ack.el](http://repo.or.cz/w/ShellArchive.git?a=blob_plain;hb=HEAD;f=ack.el) |
555,391 | <p>I have a string that is:</p>
<pre>!"#$%&'()*+,-./0123456789:;?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]\^_`abcdefghijklmnopqrstuvwxyz{|}~¡¢£¤¥¦§¨©ª« ®¯°±²³´µ¶•¸¹º»¼½¾¿ÀÁÂÃÄÅàáâäèçéêëìíîïôö÷òóõùúý</pre>
<p>I post that to service and used Htmlencode, then I get a result:</p>
<pre>!#$%&amp;'()* ,-./0123456789:;&lt;=&... | [
{
"answer_id": 555418,
"author": "Tom",
"author_id": 40620,
"author_profile": "https://Stackoverflow.com/users/40620",
"pm_score": 3,
"selected": false,
"text": "<p>Your string is not ASCII, so you are either using a string to represent binary data, or you're not maintaining awareness of... | 2009/02/17 | [
"https://Stackoverflow.com/questions/555391",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51578/"
] | I have a string that is:
```
!"#$%&'()*+,-./0123456789:;?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]\^_`abcdefghijklmnopqrstuvwxyz{|}~¡¢£¤¥¦§¨©ª« ®¯°±²³´µ¶•¸¹º»¼½¾¿ÀÁÂÃÄÅàáâäèçéêëìíîïôö÷òóõùúý
```
I post that to service and used Htmlencode, then I get a result:
```
!#$%&'()* ,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWX... | Your string is not ASCII, so you are either using a string to represent binary data, or you're not maintaining awareness of multi-byte encoding. In any case, the simplest way to deal with any Internet-based technology (HTTP, SMTP, POP, IMAP) is to encode it as 7-bit clean. One common way is to base64-encode your data, ... |
555,408 | <p>I know that it's more performant to use '' delimited strings rather than ""...</p>
<p>but I was wondering if there's any performance improvemente doing this</p>
<pre><code>
$a = array( 'table' => 'myTable', 'order' => 'myOrder' );
$table = $a['table']
</code></pre>
<p>instead of </p>
<pre><code>
$a = array( tab... | [
{
"answer_id": 555414,
"author": "carbin",
"author_id": 66613,
"author_profile": "https://Stackoverflow.com/users/66613",
"pm_score": 4,
"selected": true,
"text": "<p>Yes. In your second example the PHP processor checks if \"table\" is defined as a constant before defaulting it back to a... | 2009/02/17 | [
"https://Stackoverflow.com/questions/555408",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47633/"
] | I know that it's more performant to use '' delimited strings rather than ""...
but I was wondering if there's any performance improvemente doing this
```
$a = array( 'table' => 'myTable', 'order' => 'myOrder' );
$table = $a['table']
```
instead of
```
$a = array( table => 'myTable', order => 'myOrder' );
$tab... | Yes. In your second example the PHP processor checks if "table" is defined as a constant before defaulting it back to an array key, so it is making one more check than it needs to. This can also create problems.
Consider this:
```
const table = 'text';
$a = array( table => 'myTable', order => 'myOrder' );
$table = ... |
555,415 | <p>I want to use CURL library but I don't want to install it in a hard way</p>
<p>I just want to do something like this</p>
<pre><code>require_once('curl.php');
</code></pre>
<p>I am not sure if this possible or not? and where can I found this CURL class?</p>
<p>thanks</p>
| [
{
"answer_id": 555436,
"author": "Cody Caughlan",
"author_id": 25398,
"author_profile": "https://Stackoverflow.com/users/25398",
"pm_score": 4,
"selected": true,
"text": "<p>PHP requires that its built with the cURL library, see:</p>\n\n<p><a href=\"http://www.php.net/manual/en/curl.inst... | 2009/02/17 | [
"https://Stackoverflow.com/questions/555415",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/459737/"
] | I want to use CURL library but I don't want to install it in a hard way
I just want to do something like this
```
require_once('curl.php');
```
I am not sure if this possible or not? and where can I found this CURL class?
thanks | PHP requires that its built with the cURL library, see:
<http://www.php.net/manual/en/curl.installation.php>
So you would install libcurl-devel for your system and then compile PHP with
```
--with-curl
```
And maybe
```
--with-curl=/path/to
```
If you installed it in a non-standard location. |
555,422 | <p>i start out by querying an exchange server 2003 with: </p>
<pre><code>POSH>get-wmiobject -class Exchange_mailbox -namespace Root\MicrosoftExchangeV2 -server srv02
</code></pre>
<p>to get the users. One of the properties available is the mailboxguid. so for testing, I run </p>
<pre><code>POSH> get-qaduser... | [
{
"answer_id": 555436,
"author": "Cody Caughlan",
"author_id": 25398,
"author_profile": "https://Stackoverflow.com/users/25398",
"pm_score": 4,
"selected": true,
"text": "<p>PHP requires that its built with the cURL library, see:</p>\n\n<p><a href=\"http://www.php.net/manual/en/curl.inst... | 2009/02/17 | [
"https://Stackoverflow.com/questions/555422",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18853/"
] | i start out by querying an exchange server 2003 with:
```
POSH>get-wmiobject -class Exchange_mailbox -namespace Root\MicrosoftExchangeV2 -server srv02
```
to get the users. One of the properties available is the mailboxguid. so for testing, I run
```
POSH> get-qaduser -identity <mailboxguid>
```
however it do... | PHP requires that its built with the cURL library, see:
<http://www.php.net/manual/en/curl.installation.php>
So you would install libcurl-devel for your system and then compile PHP with
```
--with-curl
```
And maybe
```
--with-curl=/path/to
```
If you installed it in a non-standard location. |
555,425 | <p>I'm trying to build a "New Customer" form, so I'm using the default model binder to build my Customer object:</p>
<pre><code>public ActionResult New(Customer customer) { ... }
</code></pre>
<p>The only problem is I have a few properties on the Customer object that aren't required. When I leave these fields blank, ... | [
{
"answer_id": 555499,
"author": "Chad Moran",
"author_id": 25416,
"author_profile": "https://Stackoverflow.com/users/25416",
"pm_score": 4,
"selected": true,
"text": "<p>I'm not 100% but making them nullable should work.</p>\n"
},
{
"answer_id": 13061316,
"author": "Akkadoyo... | 2009/02/17 | [
"https://Stackoverflow.com/questions/555425",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31516/"
] | I'm trying to build a "New Customer" form, so I'm using the default model binder to build my Customer object:
```
public ActionResult New(Customer customer) { ... }
```
The only problem is I have a few properties on the Customer object that aren't required. When I leave these fields blank, ASP.NET MVC automatically ... | I'm not 100% but making them nullable should work. |
555,427 | <p>Some commands in Solaris (such as iostat) report disk related information using disk names such as sd0 or sdd2. Is there a consistent way to map these names back to the standard /dev/dsk/c?t?d?s? disk names in Solaris?</p>
<p>Edit: As Amit points out, <b>iostat -n</b> produces device names such as eg c0t0d0s0 inste... | [
{
"answer_id": 555440,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "<p>Try using the '-n' switch. For eg. 'iostat -n'</p>\n"
},
{
"answer_id": 583169,
"author": "Community",
"aut... | 2009/02/17 | [
"https://Stackoverflow.com/questions/555427",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2075002/"
] | Some commands in Solaris (such as iostat) report disk related information using disk names such as sd0 or sdd2. Is there a consistent way to map these names back to the standard /dev/dsk/c?t?d?s? disk names in Solaris?
Edit: As Amit points out, **iostat -n** produces device names such as eg c0t0d0s0 instead of sd0. Bu... | Following Amit's idea to answer my own question, this is what I have come up with:
```
iostat -x|tail -n +3|awk '{print $1}'>/tmp/f0.txt.$$
iostat -nx|tail -n +3|awk '{print "/dev/dsk/"$11}'>/tmp/f1.txt.$$
paste -d= /tmp/f[01].txt.$$
rm /tmp/f[01].txt.$$
```
Running this on a Solaris 10 server gives the following ou... |
555,462 | <p>Is it possible to cast an object to the type returned from <code>GetType()</code>? I'd like a generic method that can accept an object (for anonymous types) but then return an object cast as the anonymous type. I've been thinking of using the LCG DynamicMethod to build a method on a container class, but I can't exac... | [
{
"answer_id": 555501,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 5,
"selected": true,
"text": "<p>Your intent is very unclear; however, one option is generics and <code>MakeGenericMethod</code> in particular. What... | 2009/02/17 | [
"https://Stackoverflow.com/questions/555462",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Is it possible to cast an object to the type returned from `GetType()`? I'd like a generic method that can accept an object (for anonymous types) but then return an object cast as the anonymous type. I've been thinking of using the LCG DynamicMethod to build a method on a container class, but I can't exactly figure out... | Your intent is very unclear; however, one option is generics and `MakeGenericMethod` in particular. What do you want to do with this? For example:
```
static class Program
{
static void Main()
{
object obj = 123.45;
typeof(Program).GetMethod("DoSomething")
.MakeGenericMethod(obj.Get... |
555,468 | <p>I'm trying to insert a new event into Google Calendar, which I can do fine by the following:</p>
<pre><code>$sname = Zend_Gdata_Calendar::AUTH_SERVICE_NAME; // predefined service name for calendar
$client = Zend_Gdata_ClientLogin::getHttpClient($userName,$password,$sname);
$service = new Zend_Gdata_Calendar($client... | [
{
"answer_id": 563656,
"author": "davearchie",
"author_id": 27429,
"author_profile": "https://Stackoverflow.com/users/27429",
"pm_score": 3,
"selected": true,
"text": "<p>Found the issue:\nThe URI above doesn't work:\n\"<a href=\"http://www.google.com/calendar/feeds/\" rel=\"nofollow nor... | 2009/02/17 | [
"https://Stackoverflow.com/questions/555468",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27429/"
] | I'm trying to insert a new event into Google Calendar, which I can do fine by the following:
```
$sname = Zend_Gdata_Calendar::AUTH_SERVICE_NAME; // predefined service name for calendar
$client = Zend_Gdata_ClientLogin::getHttpClient($userName,$password,$sname);
$service = new Zend_Gdata_Calendar($client);
$event = $... | Found the issue:
The URI above doesn't work:
"<http://www.google.com/calendar/feeds/>**default**/something@somethingelse.com/private/full";
should not have the default section there.
Also, the @ sign should be replaced by encoding. So it should be:
"<http://www.google.com/calendar/feeds/something%40somethingelse.com/... |
555,470 | <p>Most emacs modes include some sort of prefix to activate their features. For example, when using <em>GUD</em> "next" is "C-c C-n". Of these modes, many provide special buffers where one can use a single key to activate some functionality (just 'n' or 'p' to read next/previous mail in <em>GNUS</em> for example).</p>
... | [
{
"answer_id": 558012,
"author": "huaiyuan",
"author_id": 16240,
"author_profile": "https://Stackoverflow.com/users/16240",
"pm_score": 1,
"selected": false,
"text": "<p>The mode-specific (modal?) part of key-bindings in Emacs is realized by the various local maps that overshadow the uni... | 2009/02/17 | [
"https://Stackoverflow.com/questions/555470",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/66871/"
] | Most emacs modes include some sort of prefix to activate their features. For example, when using *GUD* "next" is "C-c C-n". Of these modes, many provide special buffers where one can use a single key to activate some functionality (just 'n' or 'p' to read next/previous mail in *GNUS* for example).
Not all modes provid... | I agree with Joe Casadonte's answer that the way to go is to define your own minor (or major) mode.
That being said, your question is interesting.
Here's a solution that prompts you for a key sequence and it takes the prefix keystrokes and promotes that keymap to the top level.
e.g. Assume the following keymap:
```... |
555,471 | <p>What is the difference between</p>
<pre><code>private void DoSomething(int value) {
value++;
}
</code></pre>
<p>and</p>
<pre><code>private int DoSomething(int value) {
return value++;
}
</code></pre>
<p>when used as either</p>
<pre><code>DoSomething(value);
</code></pre>
<p>versus</p>
<pre><code>value ... | [
{
"answer_id": 555481,
"author": "Rex M",
"author_id": 67,
"author_profile": "https://Stackoverflow.com/users/67",
"pm_score": 7,
"selected": true,
"text": "<p>You are talking about the difference between <strong>passing by reference</strong> and <strong>passing by value</strong>, which ... | 2009/02/17 | [
"https://Stackoverflow.com/questions/555471",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/56876/"
] | What is the difference between
```
private void DoSomething(int value) {
value++;
}
```
and
```
private int DoSomething(int value) {
return value++;
}
```
when used as either
```
DoSomething(value);
```
versus
```
value = DoSomething(value);
``` | You are talking about the difference between **passing by reference** and **passing by value**, which is conceptually similar to the idea of **value types vs reference types**.
If you pass a **value type** into the method, you have to use the second example; otherwise you are just incrementing an integer that exists i... |
555,497 | <p><strong>One-line summary:</strong> What is the best practice for unhooking event handlers created in the constructor of a UserControl in Silverlight2?</p>
<p><strong>Background:</strong>
I am currently building a line-of-business application in Silverlight2. As Silverlight is a browser plugin, there is no concept o... | [
{
"answer_id": 556067,
"author": "G. Ghez",
"author_id": 67276,
"author_profile": "https://Stackoverflow.com/users/67276",
"pm_score": 1,
"selected": false,
"text": "<p>Events are automatically unbinded when the garbage collector goes through your object. </p>\n\n<p>But you can explicitl... | 2009/02/17 | [
"https://Stackoverflow.com/questions/555497",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20122/"
] | **One-line summary:** What is the best practice for unhooking event handlers created in the constructor of a UserControl in Silverlight2?
**Background:**
I am currently building a line-of-business application in Silverlight2. As Silverlight is a browser plugin, there is no concept of a Window - everything is done with... | A destructor, more commonly known to C# programmers as Finalizers, is not necessary in this case. Assuming that ViewModel\_LoadCompleted is a member function, it contains a pointer to "this" which you are giving to the ViewModel object which is fully contained by "this". The garbage collector should intelligently ignor... |
555,503 | <pre><code>public static String asHex (byte buf[]) {
StringBuffer strbuf = new StringBuffer(buf.length * 2);
int i;
for (i = 0; i < buf.length; i++) {
if (((int) buf[i] & 0xff) < 0x10)
strbuf.append("0");
strbuf.append(Long.toString((int) buf[i] & 0xff, 16));
... | [
{
"answer_id": 555513,
"author": "Zach Scrivena",
"author_id": 20029,
"author_profile": "https://Stackoverflow.com/users/20029",
"pm_score": 1,
"selected": false,
"text": "<p>To get a hexadecimal string representation of a byte array, you could use <a href=\"http://java.sun.com/javase/6/... | 2009/02/17 | [
"https://Stackoverflow.com/questions/555503",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | ```
public static String asHex (byte buf[]) {
StringBuffer strbuf = new StringBuffer(buf.length * 2);
int i;
for (i = 0; i < buf.length; i++) {
if (((int) buf[i] & 0xff) < 0x10)
strbuf.append("0");
strbuf.append(Long.toString((int) buf[i] & 0xff, 16));
}
return strbuf.... | Here's a complete program which includes the `asBytes()` function which is what I assume you were looking for, the opposite to `asHex()`:
```
public class Temp {
public static String asHex (byte buf[]) {
StringBuffer strbuf = new StringBuffer(buf.length * 2);
int i;
for (i = 0; i < buf.leng... |
555,526 | <p>I've recently noticed some behaviour with the Visual Studio Designer (C#) that I don't understand and was wondering if someone could clarify...</p>
<p>One some of my Windows Forms, the first line of the designer generated code reads;</p>
<pre><code>this.components = new System.ComponentModel.Container();
</code></... | [
{
"answer_id": 555566,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 1,
"selected": false,
"text": "<p>Interesting glitch! It does indeed sound like a bug in one version of the designer / templating. Of course, if you... | 2009/02/17 | [
"https://Stackoverflow.com/questions/555526",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5019/"
] | I've recently noticed some behaviour with the Visual Studio Designer (C#) that I don't understand and was wondering if someone could clarify...
One some of my Windows Forms, the first line of the designer generated code reads;
```
this.components = new System.ComponentModel.Container();
```
When this is the case, t... | This is reproducible behavior. When you create a new form, it starts out with a skeleton that includes the this.components constructor call. When you then add a component (say a Timer) and remove it again, the designer regenerates the code, now without the constructor call. That isn't a bug.
Fwiw, the skeleton code is... |
555,580 | <p>Following is the scenario i need to solve. I have struck with two solutions.</p>
<p>I need to maintain a cache of data fetched from database to be shown on a Swing GUI.
Whenever my JVM memory exceeds 70% of its allocated memory, i need to warn user regarding excessive usage. And once JVM memory usage exceeds 80%, t... | [
{
"answer_id": 555591,
"author": "Yoni Roit",
"author_id": 34161,
"author_profile": "https://Stackoverflow.com/users/34161",
"pm_score": 2,
"selected": false,
"text": "<p>I've only used the first method for similar task and it was OK.</p>\n\n<p>One thing you should note, for both methods... | 2009/02/17 | [
"https://Stackoverflow.com/questions/555580",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/62247/"
] | Following is the scenario i need to solve. I have struck with two solutions.
I need to maintain a cache of data fetched from database to be shown on a Swing GUI.
Whenever my JVM memory exceeds 70% of its allocated memory, i need to warn user regarding excessive usage. And once JVM memory usage exceeds 80%, then i have... | Just a side note: `Runtime.freeMemory()` doesn't state the amount of memory that's left of allocating, it's just the amount of memory that's free within the currently allocated memory (which is initially smaller than the maximum memory the VM is configured to use), but grows over time.
When starting a VM, the max memo... |
555,581 | <p>I want to add logging or tracing to my C# application but I don't want the overhead of formatting the string or calculating values to be logged if the log verbosity level is set so low that the message will not be logged.</p>
<p>In C++, you can use the preprocessor to define macros that will prevent code from being... | [
{
"answer_id": 555590,
"author": "shahkalpesh",
"author_id": 23574,
"author_profile": "https://Stackoverflow.com/users/23574",
"pm_score": 0,
"selected": false,
"text": "<p>For your comment</p>\n\n<p>\"because I can't make that big ugly call look like my simple VLOG() call in C++ \" - Yo... | 2009/02/17 | [
"https://Stackoverflow.com/questions/555581",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37835/"
] | I want to add logging or tracing to my C# application but I don't want the overhead of formatting the string or calculating values to be logged if the log verbosity level is set so low that the message will not be logged.
In C++, you can use the preprocessor to define macros that will prevent code from being executed ... | Two of these answers (Andrew Arnott's and Brian's) did answer part of my question. The ConditionalAttribute that is applied to the Trace and Debug class methods causes all calls to the methods to be removed if TRACE or DEBUG are #undef'd, including the expensive parameter evaluation. Thanks!
For the second part, wheth... |
555,596 | <p>A newbie question from me, please.</p>
<p>I have a large data set that I <strong>prefer</strong> to be submitted as an object instead of an array; e.g.</p>
<pre><code>foo = bar = baz = {};
$.ajax({
url: "index",
type: "post",
data: { foo: foo, bar: bar, baz: baz },
dataType: "json"
});
</code></pre... | [
{
"answer_id": 555608,
"author": "krosenvold",
"author_id": 23691,
"author_profile": "https://Stackoverflow.com/users/23691",
"pm_score": 3,
"selected": true,
"text": "<p>No. Everything that is submitted via HTTP is basically a string or an array of strings. You <em>can</em> use <a href=... | 2009/02/17 | [
"https://Stackoverflow.com/questions/555596",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11011/"
] | A newbie question from me, please.
I have a large data set that I **prefer** to be submitted as an object instead of an array; e.g.
```
foo = bar = baz = {};
$.ajax({
url: "index",
type: "post",
data: { foo: foo, bar: bar, baz: baz },
dataType: "json"
});
```
Upon submit, Firebug tells me that I hav... | No. Everything that is submitted via HTTP is basically a string or an array of strings. You *can* use [JSON](http://www.json.org/) to convert each object into a string representation, which may be what you want. |
555,612 | <p>when doing</p>
<pre><code>#include <string>
class MyString : public std::string
{
public:
MyString() {}
};
</code></pre>
<p>But the usage below:</p>
<pre><code>MyString s = "Happy day";
MyString s("Happy Day");
MyString s = (MyString)"Happy day";
</code></pre>
<p>neither of them works.</p>
<p>It... | [
{
"answer_id": 555624,
"author": "Charlie Martin",
"author_id": 35092,
"author_profile": "https://Stackoverflow.com/users/35092",
"pm_score": 1,
"selected": false,
"text": "<p>You're defining a ctor MyString that takes no arguments. If overrides the other ctors, so there's no ctor takin... | 2009/02/17 | [
"https://Stackoverflow.com/questions/555612",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/52415/"
] | when doing
```
#include <string>
class MyString : public std::string
{
public:
MyString() {}
};
```
But the usage below:
```
MyString s = "Happy day";
MyString s("Happy Day");
MyString s = (MyString)"Happy day";
```
neither of them works.
It seems that there's something to do with constructors/operator... | You need to define some constructors for the different types that you want to be able to convert into your strings. These constructors can basically just hand the parameters through to the underlying `std::string`.
If you don't manually create them, the compiler creates a default- and a copy-constructor for you:
```
... |
555,616 | <p>I'm trying to display an image using a PHP script. Basically so the php script is passed on the full path to the image, and it then displays that image in the browser. I've checked to make sure the image exists, it is being read correctly, etc, however in the browser i just see the broken image box (e.g the small re... | [
{
"answer_id": 555644,
"author": "Matt",
"author_id": 49452,
"author_profile": "https://Stackoverflow.com/users/49452",
"pm_score": 2,
"selected": false,
"text": "<p>Striving for simplicity...</p>\n\n<pre><code><?php\nheader('Content-type:' . mime_content_type($file));\nreadfile($file... | 2009/02/17 | [
"https://Stackoverflow.com/questions/555616",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49153/"
] | I'm trying to display an image using a PHP script. Basically so the php script is passed on the full path to the image, and it then displays that image in the browser. I've checked to make sure the image exists, it is being read correctly, etc, however in the browser i just see the broken image box (e.g the small red c... | I found the answer, i had some extra whitespace after the `?>` tag which was causing the header to not work. grrrrrrr |
555,622 | <p>Using this SQL on SQL Server 2005</p>
<pre><code>SELECT CONSTRAINT_NAME
FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE
WHERE TABLE_NAME = @TableName
AND COLUMN_NAME=@ColumnName
</code></pre>
<p>I get the Primary Keys AND the Foreign Keys.</p>
<p>How can I get only Foreign Keys?
How can I see if a Constraint is a Pr... | [
{
"answer_id": 555643,
"author": "paxdiablo",
"author_id": 14860,
"author_profile": "https://Stackoverflow.com/users/14860",
"pm_score": 0,
"selected": false,
"text": "<p>It depends on your DBMS but a constraint should have the target table and column somewhere.</p>\n\n<p>If it's a forei... | 2009/02/17 | [
"https://Stackoverflow.com/questions/555622",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26754/"
] | Using this SQL on SQL Server 2005
```
SELECT CONSTRAINT_NAME
FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE
WHERE TABLE_NAME = @TableName
AND COLUMN_NAME=@ColumnName
```
I get the Primary Keys AND the Foreign Keys.
How can I get only Foreign Keys?
How can I see if a Constraint is a Primary or a Foreign Key?
Thanks | I used the following SQL with SQL Server 2005 to get the Constraint Names by Primary Key:
```
SELECT Constraint_Name
FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS
WHERE UNIQUE_CONSTRAINT_NAME =
(SELECT CONSTRAINT_NAME
FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE
WHERE TABLE_NAME = @TableName AND COLUMN_N... |
555,623 | <p>I have done xml parsing same as SeismicXML example. But now it gives me memory leak problem.</p>
<p>When i tested SeismicXML with instruments, it also give same memory leak.</p>
<p>In SeismicXML, EarthQuake example is there, it contains all the string and array which come from xml parsing. SO 'Leak' instruments sh... | [
{
"answer_id": 555643,
"author": "paxdiablo",
"author_id": 14860,
"author_profile": "https://Stackoverflow.com/users/14860",
"pm_score": 0,
"selected": false,
"text": "<p>It depends on your DBMS but a constraint should have the target table and column somewhere.</p>\n\n<p>If it's a forei... | 2009/02/17 | [
"https://Stackoverflow.com/questions/555623",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have done xml parsing same as SeismicXML example. But now it gives me memory leak problem.
When i tested SeismicXML with instruments, it also give same memory leak.
In SeismicXML, EarthQuake example is there, it contains all the string and array which come from xml parsing. SO 'Leak' instruments showing all this st... | I used the following SQL with SQL Server 2005 to get the Constraint Names by Primary Key:
```
SELECT Constraint_Name
FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS
WHERE UNIQUE_CONSTRAINT_NAME =
(SELECT CONSTRAINT_NAME
FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE
WHERE TABLE_NAME = @TableName AND COLUMN_N... |
555,669 | <p>Is there any helper method (Other than <a href="http://wiki.rubyonrails.org/rails/pages/Breadcrumbs" rel="nofollow noreferrer">default rails breadcrumb</a>) that generates bread crumb navigation dynamically for a particular page without having to pass trivial parameters in RESTful application? That is, something tha... | [
{
"answer_id": 555683,
"author": "Chirantan",
"author_id": 45942,
"author_profile": "https://Stackoverflow.com/users/45942",
"pm_score": 4,
"selected": true,
"text": "<p>Developed a simple hack. The method however assumes that there exists a method 'name' for every model object correspon... | 2009/02/17 | [
"https://Stackoverflow.com/questions/555669",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45942/"
] | Is there any helper method (Other than [default rails breadcrumb](http://wiki.rubyonrails.org/rails/pages/Breadcrumbs)) that generates bread crumb navigation dynamically for a particular page without having to pass trivial parameters in RESTful application? That is, something that figures out automatically where the us... | Developed a simple hack. The method however assumes that there exists a method 'name' for every model object corresponding to each resource in the RESTful url. Whatever that the method 'name' returns is shown as breadcrumb name. If it is not found, it is shown as it is without making it link to anything. Separator used... |
555,681 | <p>This is quite straightforward - gcc fails to to compile this sample code (c++).</p>
<pre><code>class myclass {
struct mystruct {
myclass something;
int something_else;
};
};
</code></pre>
<p>It tells me, that</p>
<blockquote>
<p>Field 'something' has incomplete type.</p>
</blockquote>
<... | [
{
"answer_id": 555688,
"author": "sharptooth",
"author_id": 57428,
"author_profile": "https://Stackoverflow.com/users/57428",
"pm_score": 3,
"selected": true,
"text": "<p>You can't put an object into itself. Perhaps you wanted a pointer to myclass.</p>\n"
},
{
"answer_id": 555689... | 2009/02/17 | [
"https://Stackoverflow.com/questions/555681",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | This is quite straightforward - gcc fails to to compile this sample code (c++).
```
class myclass {
struct mystruct {
myclass something;
int something_else;
};
};
```
It tells me, that
>
> Field 'something' has incomplete type.
>
>
>
I probably miss something trivial, because I'm quite ... | You can't put an object into itself. Perhaps you wanted a pointer to myclass. |
555,684 | <p>How do you initialize and Uninitialize a multidimensional character array in C++?</p>
| [
{
"answer_id": 555707,
"author": "dirkgently",
"author_id": 66692,
"author_profile": "https://Stackoverflow.com/users/66692",
"pm_score": 2,
"selected": false,
"text": "<p>Read the <a href=\"http://www.parashift.com/c++-faq-lite/freestore-mgmt.html#faq-16.16\" rel=\"nofollow noreferrer\"... | 2009/02/17 | [
"https://Stackoverflow.com/questions/555684",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | How do you initialize and Uninitialize a multidimensional character array in C++? | Read the [**FAQ**](http://www.parashift.com/c++-faq-lite/freestore-mgmt.html#faq-16.16) -- you'll find everything you need there!
**Creation:**
Statically allocated:
```
char mda[ dim1_size ][ dim2_size ]...[ dimn_size ];
```
Dynamically allocated: Nested `new[]` calls.
**Initialization:**
Nested for loops; as ... |
555,693 | <p>I have a requirement in the project such that we have to stop a specific service say "x" in a remote machine (which is on the same LAN), change the registry key remotely and start the service again.</p>
<p>I tried the command <code>sc \server stop service</code>, but I got the error:</p>
<blockquote>
<p>[S... | [
{
"answer_id": 555710,
"author": "sharptooth",
"author_id": 57428,
"author_profile": "https://Stackoverflow.com/users/57428",
"pm_score": 0,
"selected": false,
"text": "<p>Use OpenCSManager, then OpenService, then StartService.</p>\n"
},
{
"answer_id": 555719,
"author": "gaho... | 2009/02/17 | [
"https://Stackoverflow.com/questions/555693",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a requirement in the project such that we have to stop a specific service say "x" in a remote machine (which is on the same LAN), change the registry key remotely and start the service again.
I tried the command `sc \server stop service`, but I got the error:
>
> [SC] GetServiceKeyName FAILED 1060:
>
>
> Th... | Also keep in mind that the "service name" argument expected by the "sc" command line tool doesn't always equate to the name you see within the services control panel applet (which is the service "display name").
For example, the service that as appears "Adobe Acrobat Update Service" in my services control panel applet... |
555,705 | <p>Is there a way to do character translation / transliteration (kind of like the <a href="https://perldoc.perl.org/functions/tr" rel="nofollow noreferrer"><code>tr</code></a> command) using <strong>Python</strong>?</p>
<p>Some examples in Perl would be:</p>
<pre class="lang-perl prettyprint-override"><code>my $string ... | [
{
"answer_id": 555724,
"author": "Richard Levasseur",
"author_id": 36805,
"author_profile": "https://Stackoverflow.com/users/36805",
"pm_score": 7,
"selected": true,
"text": "<p>See <a href=\"http://docs.python.org/library/stdtypes.html#str.translate\" rel=\"noreferrer\"><code>string.tra... | 2009/02/17 | [
"https://Stackoverflow.com/questions/555705",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42303/"
] | Is there a way to do character translation / transliteration (kind of like the [`tr`](https://perldoc.perl.org/functions/tr) command) using **Python**?
Some examples in Perl would be:
```perl
my $string = "some fields";
$string =~ tr/dies/eaid/;
print $string; # domi failed
$string = 'the cat sat on the mat.';
$str... | See [`string.translate`](http://docs.python.org/library/stdtypes.html#str.translate)
```
import string
"abc".translate(string.maketrans("abc", "def")) # => "def"
```
Note the doc's comments about subtleties in the translation of unicode strings.
And for Python 3, you can use directly:
```py
str.translate(str.maket... |
555,711 | <p>Is there a site where I can find the symbols used in a particular library and its version.
For e.g. I m trying to compile some code on AIX using gcc, and it throws me a lot of undefined symbol errors
For example, here is an output:</p>
<pre><code>ld: 0711-317 ERROR: Undefined symbol: .__fixdfdi
ld: 0711-317 ERROR: ... | [
{
"answer_id": 555756,
"author": "Gordon Thompson",
"author_id": 21299,
"author_profile": "https://Stackoverflow.com/users/21299",
"pm_score": 1,
"selected": false,
"text": "<p>It's been a long time since I compiled anything on AIX (thankfully) and I do feel your pain having spent a good... | 2009/02/17 | [
"https://Stackoverflow.com/questions/555711",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Is there a site where I can find the symbols used in a particular library and its version.
For e.g. I m trying to compile some code on AIX using gcc, and it throws me a lot of undefined symbol errors
For example, here is an output:
```
ld: 0711-317 ERROR: Undefined symbol: .__fixdfdi
ld: 0711-317 ERROR: Undefined symb... | It's been a long time since I compiled anything on AIX (thankfully) and I do feel your pain having spent a good year or so trying to get our company's JNI and other software libraries built on AIX.
I do seem to remember that GCC never worked particularly well as it always came up with similar errors. Is there any opti... |
555,744 | <p>There is an array of size n (numbers are between 0 and n - 3) and only 2 numbers are repeated. Elements are placed randomly in the array.</p>
<p>E.g. in {2, 3, 6, 1, 5, 4, 0, 3, 5} n=9, and repeated numbers are 3 and 5.</p>
<p>What is the best way to find the repeated numbers?</p>
<p>P.S. [You should not use so... | [
{
"answer_id": 555749,
"author": "Steve Rowe",
"author_id": 40744,
"author_profile": "https://Stackoverflow.com/users/40744",
"pm_score": 1,
"selected": false,
"text": "<p>Sorting the array would seem to be the best solution. A simple sort would then make the search trivial and would ta... | 2009/02/17 | [
"https://Stackoverflow.com/questions/555744",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29405/"
] | There is an array of size n (numbers are between 0 and n - 3) and only 2 numbers are repeated. Elements are placed randomly in the array.
E.g. in {2, 3, 6, 1, 5, 4, 0, 3, 5} n=9, and repeated numbers are 3 and 5.
What is the best way to find the repeated numbers?
P.S. [You should not use sorting] | There is a **O(n) solution** if you know what the possible domain of input is. For example if your input array contains numbers between 0 to 100, consider the following code.
```
bool flags[100];
for(int i = 0; i < 100; i++)
flags[i] = false;
for(int i = 0; i < input_size; i++)
if(flags[input_array[i]])
... |
555,750 | <p>I have a the following dictionary:</p>
<pre><code>IDictionary<int, IList<MyClass>> myDictionary
</code></pre>
<p>and I am wanting to get all the values in the dictionary as an IList....</p>
<hr>
<p>Just to add a bit of a background as to how I've gotten into this situation....</p>
<p>I have a metho... | [
{
"answer_id": 555783,
"author": "John Leidegren",
"author_id": 58961,
"author_profile": "https://Stackoverflow.com/users/58961",
"pm_score": 7,
"selected": true,
"text": "<p>Because of how a dictionary (or hash table) is maintained this is what you would do. Internally the implementatio... | 2009/02/17 | [
"https://Stackoverflow.com/questions/555750",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39532/"
] | I have a the following dictionary:
```
IDictionary<int, IList<MyClass>> myDictionary
```
and I am wanting to get all the values in the dictionary as an IList....
---
Just to add a bit of a background as to how I've gotten into this situation....
I have a method that gets me a list of MyClass. I then have another... | Because of how a dictionary (or hash table) is maintained this is what you would do. Internally the implementation contains keys, buckets (for collision handling) and values. You might be able to retrieve the internal value list but you're better of with something like this:
```
IDictionary<int, IList<MyClass>> dict;... |
555,752 | <p>I'm building (c#) sql select commands strings on the fly using LIKE %somestring% conditions. In my search strings I want to be able to handle any character found on a standard PC (US) keyboard (including ~ ! @ # % etc., alt-special chars not required but would be nice to have). I know that single quotes need to be d... | [
{
"answer_id": 555775,
"author": "Anton Gogolev",
"author_id": 60188,
"author_profile": "https://Stackoverflow.com/users/60188",
"pm_score": 3,
"selected": false,
"text": "<p>No fixes required:</p>\n\n<pre><code>SqlCommand cmd = new SqlCommand(\"select * from Foo where Bar like @p\", con... | 2009/02/17 | [
"https://Stackoverflow.com/questions/555752",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28343/"
] | I'm building (c#) sql select commands strings on the fly using LIKE %somestring% conditions. In my search strings I want to be able to handle any character found on a standard PC (US) keyboard (including ~ ! @ # % etc., alt-special chars not required but would be nice to have). I know that single quotes need to be doub... | No fixes required:
```
SqlCommand cmd = new SqlCommand("select * from Foo where Bar like @p", connection);
SqlParameter p = new SqlParameter();
param.ParameterName = "@p";
param.Value = pattern;
cmd.Parameters.Add(param);
``` |
555,773 | <p>I have a wcf service that needs to implement callbacks and be hosted on IIS 6.0. Since IIS 6.0 doesn't support the net.tcp binding, I decided to use a custom binding because the service is accessed by different clients in different timezones and, using custom binding, I can set the allowed clock skew time to values ... | [
{
"answer_id": 559794,
"author": "Andy White",
"author_id": 60096,
"author_profile": "https://Stackoverflow.com/users/60096",
"pm_score": 1,
"selected": false,
"text": "<p>Can you show the part of the config where you're defining the customBinding? Maybe you just didn't paste that part ... | 2009/02/17 | [
"https://Stackoverflow.com/questions/555773",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/67240/"
] | I have a wcf service that needs to implement callbacks and be hosted on IIS 6.0. Since IIS 6.0 doesn't support the net.tcp binding, I decided to use a custom binding because the service is accessed by different clients in different timezones and, using custom binding, I can set the allowed clock skew time to values oth... | Can you show the part of the config where you're defining the customBinding? Maybe you just didn't paste that part in, but when you define a custom binding, you have to specify an encoding and a transport at minimum - something like this:
```
<bindings>
<customBinding>
<binding name="MyCustomTextTcpBinding... |
555,774 | <p>In my C++ project, I've chosen to use a C library. In my zeal to have a well-abstracted and simple design, I've ended up doing a bit of a kludge. Part of my design requirement is that I can easily support multiple APIs and libraries for a given task (due, primarily, to my requirement for cross-platform support). So,... | [
{
"answer_id": 555784,
"author": "ChrisW",
"author_id": 49942,
"author_profile": "https://Stackoverflow.com/users/49942",
"pm_score": 3,
"selected": true,
"text": "<p>You can justify that choice: your justification is that the C library only supports one callback instance.</p>\n\n<blockq... | 2009/02/17 | [
"https://Stackoverflow.com/questions/555774",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33345/"
] | In my C++ project, I've chosen to use a C library. In my zeal to have a well-abstracted and simple design, I've ended up doing a bit of a kludge. Part of my design requirement is that I can easily support multiple APIs and libraries for a given task (due, primarily, to my requirement for cross-platform support). So, I ... | You can justify that choice: your justification is that the C library only supports one callback instance.
>
> Singletons scare me: It's not clear how to correctly destroy a singleton, and inheritance just complicates matters. I'll take another look at this approach.
>
>
>
Here's how I'd do it.
**LibrarySupportC... |
555,776 | <p>How to list all the files which match a certain pattern inside a user specified directory? This should work recursively inside the sub folders of the selected directory. I also need a convenient way(like tree control) of listing them.</p>
| [
{
"answer_id": 555891,
"author": "Adam Ralph",
"author_id": 49241,
"author_profile": "https://Stackoverflow.com/users/49241",
"pm_score": 1,
"selected": false,
"text": "<p>As a general pointer, take a look at Application.FileSearch, recursive functions, Userforms and the 'Microsoft TreeV... | 2009/02/17 | [
"https://Stackoverflow.com/questions/555776",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13440/"
] | How to list all the files which match a certain pattern inside a user specified directory? This should work recursively inside the sub folders of the selected directory. I also need a convenient way(like tree control) of listing them. | It appears that a couple answers talk about recursion, and one about regex. Here's some code that puts the two topics together. I grabbed the code from <http://vba-tutorial.com>
```
Sub FindPatternMatchedFiles()
Dim objFSO As Object
Set objFSO = CreateObject("Scripting.FileSystemObject")
Dim objRegExp As... |
555,793 | <p>Basically what I am trying to do is make my drawing job easier.</p>
<p>Back in the days of VB6 there was something called Scalewidth and Scaleheight and I could set them to custom values. Ex. 100. </p>
<p>Then when I needed to draw a point at the center of the available space i would just draw it at 50,50.</p>
<p... | [
{
"answer_id": 555878,
"author": "schnaader",
"author_id": 34065,
"author_profile": "https://Stackoverflow.com/users/34065",
"pm_score": 2,
"selected": true,
"text": "<p>I don't know if there's a way to achieve this in .NET, but you could easily implement this yourself:</p>\n\n<pre><code... | 2009/02/17 | [
"https://Stackoverflow.com/questions/555793",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33052/"
] | Basically what I am trying to do is make my drawing job easier.
Back in the days of VB6 there was something called Scalewidth and Scaleheight and I could set them to custom values. Ex. 100.
Then when I needed to draw a point at the center of the available space i would just draw it at 50,50.
Is there any way in .Ne... | I don't know if there's a way to achieve this in .NET, but you could easily implement this yourself:
```
// Unscaled coordinates = x, y; canvas size = w, h;
// Scaled coordinates = sx, sy; Scalewidth, Scaleheight = sw, sh;
x = (sx / sw) * w;
y = (sy / sh) * h;
// Or the other way round
sx = (x / w) * sw;
sy = (y / h)... |
555,795 | <p>I am using the code given <a href="http://java.sun.com/developer/technicalArticles/GUI/swing/wizard/" rel="nofollow noreferrer">here</a> to create my own wizard application. </p>
<p>The basic motive of moving from 1 screen to other is achieved with this. But now I am stuck at a point. The problem is... suppose I ha... | [
{
"answer_id": 555904,
"author": "David Grant",
"author_id": 40581,
"author_profile": "https://Stackoverflow.com/users/40581",
"pm_score": 2,
"selected": false,
"text": "<p>You should store the state of your wizard in the <code>WizardModel</code>, and add getters and setters (i.e. like a... | 2009/02/17 | [
"https://Stackoverflow.com/questions/555795",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/57499/"
] | I am using the code given [here](http://java.sun.com/developer/technicalArticles/GUI/swing/wizard/) to create my own wizard application.
The basic motive of moving from 1 screen to other is achieved with this. But now I am stuck at a point. The problem is... suppose I have entered some value on screen1 and then I mov... | You should store the state of your wizard in the `WizardModel`, and add getters and setters (i.e. like a JavaBean) appropriately. For example:
```
public class WizardModel {
...
private String host;
public void setHost(String host) {
this.host = host;
}
public String getHost() {
return h... |
555,796 | <p>I wrote a fairly complex method that yield-returns <code>IEnumerable<string></code>, but when I inspected the compiler output in Reflector, I didn't understand a specific part of the compiler-generated implementation of <code>IEnumerator</code>:</p>
<pre><code>void IDisposable.Dispose()
{
switch (this.<... | [
{
"answer_id": 555808,
"author": "John Leidegren",
"author_id": 58961,
"author_profile": "https://Stackoverflow.com/users/58961",
"pm_score": 1,
"selected": false,
"text": "<p>I could argue that the C# compiler is stupid, (it's probably is a little bit stupid). It's also quite possible t... | 2009/02/17 | [
"https://Stackoverflow.com/questions/555796",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41283/"
] | I wrote a fairly complex method that yield-returns `IEnumerable<string>`, but when I inspected the compiler output in Reflector, I didn't understand a specific part of the compiler-generated implementation of `IEnumerator`:
```
void IDisposable.Dispose()
{
switch (this.<>1__state)
{
case 1:
cas... | That is simply reflector struggling to keep up with the IL that has been generated (since iterator blocks don't have to relate to "normal" C# as long as they are valid IL). In particular, the `ret` is after the `finally` block. |
555,799 | <p>I am accessing a httpwebrequest that returns a pdf file as the response. I am reading that response into a memory stream, and later on converting to a file. The problem is, is that hundreds of files are being created. Not sure why, I've tried many ways, and all do the same...
This is the first method which returns t... | [
{
"answer_id": 555809,
"author": "krosenvold",
"author_id": 23691,
"author_profile": "https://Stackoverflow.com/users/23691",
"pm_score": 0,
"selected": false,
"text": "<p>I would suggest that you are receiving more requests from your client than you think. Check your webserver access lo... | 2009/02/17 | [
"https://Stackoverflow.com/questions/555799",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25361/"
] | I am accessing a httpwebrequest that returns a pdf file as the response. I am reading that response into a memory stream, and later on converting to a file. The problem is, is that hundreds of files are being created. Not sure why, I've tried many ways, and all do the same...
This is the first method which returns the ... | It's not at all clear why you'd get multiple files, but you should be able to get *some* information based on the filenames - each one would correspond to a value of `newFile`.
I note that you're not closing your file stream, by the way. Using [`File.WriteAllBytes`](http://msdn.microsoft.com/en-us/library/system.io.fi... |
555,807 | <p>What type of errors could my code still contain even if I have 100% code coverage? I'm looking for concrete examples or links to concrete examples of such errors. </p>
| [
{
"answer_id": 555822,
"author": "John Leidegren",
"author_id": 58961,
"author_profile": "https://Stackoverflow.com/users/58961",
"pm_score": 4,
"selected": false,
"text": "<p>Code coverage doesn't mean that your code is bug free in any way. It's an estimate on how well you're test cases... | 2009/02/17 | [
"https://Stackoverflow.com/questions/555807",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8280/"
] | What type of errors could my code still contain even if I have 100% code coverage? I'm looking for concrete examples or links to concrete examples of such errors. | Having 100% code coverage is not that great as one may think of it. Consider a trival example:
```
double Foo(double a, double b)
{
return a / b;
}
```
Even a single unit test will raise code coverage of this method to 100%, but the said unit test will not tell us what code is working and what code is not. This ... |
555,846 | <p>I am new to iPhone development. I am building an app by using Xcode but now would like to disable a button. How is this possible?</p>
| [
{
"answer_id": 555865,
"author": "Alex Wayne",
"author_id": 62076,
"author_profile": "https://Stackoverflow.com/users/62076",
"pm_score": 6,
"selected": true,
"text": "<pre><code>myButton.enabled = NO;\n</code></pre>\n"
},
{
"answer_id": 555866,
"author": "Andrew Grant",
... | 2009/02/17 | [
"https://Stackoverflow.com/questions/555846",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/58554/"
] | I am new to iPhone development. I am building an app by using Xcode but now would like to disable a button. How is this possible? | ```
myButton.enabled = NO;
``` |
555,847 | <p>I need to validate an IP range that is in format 000000000 to 255255255 without any delimiters between the 3 groups of numbers.
Each of the three groups that the final IP consists of should be 000 (yes, 0 padded) to 255.</p>
<p>As this is my 1st stackoverflow entry, please be lenient if I did not follow etiquette ... | [
{
"answer_id": 555855,
"author": "unwind",
"author_id": 28169,
"author_profile": "https://Stackoverflow.com/users/28169",
"pm_score": 1,
"selected": false,
"text": "<p>This is a pretty common question. <a href=\"http://www.regular-expressions.info/examples.html\" rel=\"nofollow noreferre... | 2009/02/17 | [
"https://Stackoverflow.com/questions/555847",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/67249/"
] | I need to validate an IP range that is in format 000000000 to 255255255 without any delimiters between the 3 groups of numbers.
Each of the three groups that the final IP consists of should be 000 (yes, 0 padded) to 255.
As this is my 1st stackoverflow entry, please be lenient if I did not follow etiquette correctly. | ```
^([01]\d{2}|2[0-4]\d|25[0-5]){3}$
```
Which breaks down in the following parts:
1. 000-199
2. 200-249
3. 250-255
If you decide you want 4 octets instead of 3, just change the last `{3}` to `{4}`. Also, you should be aware of IPv6 too. |
555,871 | <p>I have heard and read that a string can not be changed (immutable?). That should be correct I guess. But I have also heard that two strings with the same contents share the same memory-space (or what you call it). Is this correct?</p>
<p>And if so, does that mean that if I create a List with thousands of strings, i... | [
{
"answer_id": 555882,
"author": "Teun D",
"author_id": 64963,
"author_profile": "https://Stackoverflow.com/users/64963",
"pm_score": 3,
"selected": false,
"text": "<p>This is more or less true. It is called \"string interning\". String literals will be present in memory only once and ev... | 2009/02/17 | [
"https://Stackoverflow.com/questions/555871",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39321/"
] | I have heard and read that a string can not be changed (immutable?). That should be correct I guess. But I have also heard that two strings with the same contents share the same memory-space (or what you call it). Is this correct?
And if so, does that mean that if I create a List with thousands of strings, it wouldn't... | EDIT: In the answer below I've referred to the intern pool as being AppDomain-specific; I'm pretty sure that's what I've observed before, but the MSDN docs for [String.Intern](http://msdn.microsoft.com/en-us/library/system.string.intern.aspx) suggest that there's a single intern pool for the whole process, making this ... |