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 |
|---|---|---|---|---|---|---|
236,354 | <p>I am a beginner in c++ and I have a small problem:</p>
<p>my code displays a simple menu to the user providing three options:</p>
<pre><code>cout << "\nQuadratic equation: a*X^2 + b*X + c = 0 main menu: ";
cout << "\n <r> Give new coefficients";
cout << "\n <c> Calculate equations... | [
{
"answer_id": 236366,
"author": "Martin York",
"author_id": 14065,
"author_profile": "https://Stackoverflow.com/users/14065",
"pm_score": 1,
"selected": false,
"text": "<p>Change this line:</p>\n\n<pre><code>cout<<\"Enter choice : \" << std::endl;\n // ^^^... | 2008/10/25 | [
"https://Stackoverflow.com/questions/236354",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am a beginner in c++ and I have a small problem:
my code displays a simple menu to the user providing three options:
```
cout << "\nQuadratic equation: a*X^2 + b*X + c = 0 main menu: ";
cout << "\n <r> Give new coefficients";
cout << "\n <c> Calculate equations solutions";
cout << "\n <t> Terminate the progra... | To get past the "cbbb" being accepted as 'c', you'll have to read in a line using getline() instead. Then you can check that only one character was entered, and then check which character that was.
If you use cin to read a char, it will only read the first character available in the input stream. |
236,359 | <p>I know most of the ins and outs of Python's approach to private variables/members/functions/...</p>
<p>However, I can't make my mind up on how to distinguish between methods for external use or subclassing use.</p>
<p>Consider the following example:</p>
<pre><code>class EventMixin(object):
def subscribe(self,... | [
{
"answer_id": 236402,
"author": "bobince",
"author_id": 18936,
"author_profile": "https://Stackoverflow.com/users/18936",
"pm_score": 2,
"selected": false,
"text": "<pre><code>use no underscores for the external API,\none underscore for the subclassable API,\nand two underscores for the... | 2008/10/25 | [
"https://Stackoverflow.com/questions/236359",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2900/"
] | I know most of the ins and outs of Python's approach to private variables/members/functions/...
However, I can't make my mind up on how to distinguish between methods for external use or subclassing use.
Consider the following example:
```
class EventMixin(object):
def subscribe(self, **kwargs):
'''kwarg... | ```
use no underscores for the external API,
one underscore for the subclassable API,
and two underscores for the private/internal API
```
This is a reasonable and relatively common way of doing it, yes. The double-underline-for-actually-private (as opposed to ‘protected’ in C++ terms) is in practice pretty rare. You... |
236,362 | <p>I have a web application that makes heavy use of the Session state to store information about the current user, their personal settings, record their session history and so on. </p>
<p>I have found myself retrieving this session information in my business layer, like so:</p>
<pre><code>((UserSession)HttpContext.Cu... | [
{
"answer_id": 236377,
"author": "mohammedn",
"author_id": 29268,
"author_profile": "https://Stackoverflow.com/users/29268",
"pm_score": -1,
"selected": false,
"text": "<p>I guess you need to create a webservice or RESTfull service. The service will return an XML file representing your u... | 2008/10/25 | [
"https://Stackoverflow.com/questions/236362",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27805/"
] | I have a web application that makes heavy use of the Session state to store information about the current user, their personal settings, record their session history and so on.
I have found myself retrieving this session information in my business layer, like so:
```
((UserSession)HttpContext.Current.Session["UserSe... | Assuming that the business layer is a separate DLL, I would never add a reference to `System.Web` and in consequence I would never use the `Session` object directly. This would lead to a different design of the business layer and of the exposed interfaces to a client (either web or winforms).
That said, as a quick wo... |
236,381 | <p>I have a web application that requires a server based component to periodically access POP3 email boxes and retrieve emails. The service then needs to process the emails which will involve:</p>
<ul>
<li>Validating the email against some business rules (does it contain a valid reference in the subject line, which us... | [
{
"answer_id": 236393,
"author": "Joachim Kerschbaumer",
"author_id": 20227,
"author_profile": "https://Stackoverflow.com/users/20227",
"pm_score": 1,
"selected": false,
"text": "<p>There are several POP3 client implementations around at codeproject.com. I have not evaluated them, but ma... | 2008/10/25 | [
"https://Stackoverflow.com/questions/236381",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27805/"
] | I have a web application that requires a server based component to periodically access POP3 email boxes and retrieve emails. The service then needs to process the emails which will involve:
* Validating the email against some business rules (does it contain a valid reference in the subject line, which user sent the ma... | I am one of the main developers of [OpenPop.NET](http://sourceforge.net/projects/hpop/). I just fell over this review, and had to come with some comments regarding the current state of OpenPop.NET as the review seems outdated with the development.
OpenPop.NET is back into active development. SSL has been introduced a ... |
236,387 | <p>I'm not sure if the title is very clear, but basically what I have to do is read a line of text from a file and split it up into 8 different string variables. Each line will have the same 8 chunks in the same order (title, author, price, etc). So for each line of text, I want to end up with 8 strings.</p>
<p>The fi... | [
{
"answer_id": 236389,
"author": "Ken Gentle",
"author_id": 8709,
"author_profile": "https://Stackoverflow.com/users/8709",
"pm_score": 1,
"selected": false,
"text": "<p>Would a regular expression with capture groups work for you? You can certainly make parts of the expression optional.... | 2008/10/25 | [
"https://Stackoverflow.com/questions/236387",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31429/"
] | I'm not sure if the title is very clear, but basically what I have to do is read a line of text from a file and split it up into 8 different string variables. Each line will have the same 8 chunks in the same order (title, author, price, etc). So for each line of text, I want to end up with 8 strings.
The first proble... | The best way is to not use a StringTokenizer at all, but use String's [split](http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html#split(java.lang.String)) method. It returns an array of Strings, and you can get the length from that.
For each line in your file you can do the following:
```
String[] tokens = ... |
236,406 | <p>Is one more preferred, or performs better over the other?</p>
| [
{
"answer_id": 236411,
"author": "Robert Gamble",
"author_id": 25222,
"author_profile": "https://Stackoverflow.com/users/25222",
"pm_score": 8,
"selected": true,
"text": "<p><a href=\"http://php.net/is_int\" rel=\"noreferrer\"><code>is_int()</code></a> returns true if the argument is an ... | 2008/10/25 | [
"https://Stackoverflow.com/questions/236406",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Is one more preferred, or performs better over the other? | [`is_int()`](http://php.net/is_int) returns true if the argument is an integer type, [`ctype_digit()`](http://www.php.net/ctype_digit) takes a string argument and returns true if all the characters in the string are digits.
**Example:**
```
┌──────────┬───────────┬────────────────┐
│ │ is_int: │ ctype_dig... |
236,412 | <p>I have a web application that comprises the following:</p>
<ul>
<li>A web project (with a web.config file containing a connection string - but no data access code in the web project)</li>
<li>A data access project that uses LINQ-SQL classes to provide entities to the web project UI (this project has a settings file... | [
{
"answer_id": 236426,
"author": "endian",
"author_id": 25462,
"author_profile": "https://Stackoverflow.com/users/25462",
"pm_score": 0,
"selected": false,
"text": "<p>How about defining a ConnectionFactory object, that takes an enum as a parameter and returns a fully-formed connection o... | 2008/10/25 | [
"https://Stackoverflow.com/questions/236412",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27805/"
] | I have a web application that comprises the following:
* A web project (with a web.config file containing a connection string - but no data access code in the web project)
* A data access project that uses LINQ-SQL classes to provide entities to the web project UI (this project has a settings file and an app.config - ... | I've never had a problem with the *Data Access Layer* (DAL) being able to use the connection strings from my `web.config` file. Usually I just copy the connection strings section from the DAL and paste it into the `web.config`. I'm using the DBML designer to create the data context.
If this won't work for you, you can... |
236,436 | <p>I made previously a question:
<a href="https://stackoverflow.com/questions/236354/error-handling-when-taking-user-input">error handling when taking user input</a></p>
<p>and I made the suggested changes:</p>
<pre><code>char displayMainMenu()
{
char mainMenuChoice;
cout << "\nQuadratic equation: a*X^2 + b*X +... | [
{
"answer_id": 236461,
"author": "Bill the Lizard",
"author_id": 1288,
"author_profile": "https://Stackoverflow.com/users/1288",
"pm_score": 2,
"selected": false,
"text": "<p>In your <code>displayMainMenu()</code> function, instead of reading in a <code>char</code>, read in a string. Th... | 2008/10/25 | [
"https://Stackoverflow.com/questions/236436",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I made previously a question:
[error handling when taking user input](https://stackoverflow.com/questions/236354/error-handling-when-taking-user-input)
and I made the suggested changes:
```
char displayMainMenu()
{
char mainMenuChoice;
cout << "\nQuadratic equation: a*X^2 + b*X + c = 0 main menu: ";
cout << "\n <r> ... | In your `displayMainMenu()` function, instead of reading in a `char`, read in a string. Throw out (with a warning) any input that is greater than one character in length.
You can use
```
char str[101]
std::cin.getline(str, 101);
```
in place of
```
cin >> mainMenuChoice;
```
in order to read the string. |
236,463 | <p>When I type the following code in Emacs ruby-mode, the "#{foo}" is fontified in a different color than the enclosing string. How do I do this in my own Emacs mode? I tried to decipher the ruby-mode source code but couldn't understand it in a reasonable amount of time.</p>
<pre><code>"a #{foo} a"
</code></pre>
| [
{
"answer_id": 236592,
"author": "bmdhacks",
"author_id": 14032,
"author_profile": "https://Stackoverflow.com/users/14032",
"pm_score": 1,
"selected": false,
"text": "<p>Search for where ruby-mode.el sets <code>font-lock-syntactic-keywords</code>:</p>\n\n<pre><code>(setq ruby-font-lock-s... | 2008/10/25 | [
"https://Stackoverflow.com/questions/236463",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | When I type the following code in Emacs ruby-mode, the "#{foo}" is fontified in a different color than the enclosing string. How do I do this in my own Emacs mode? I tried to decipher the ruby-mode source code but couldn't understand it in a reasonable amount of time.
```
"a #{foo} a"
``` | Finally figured it out. The answer is that the "override" parameter in a fontification rule should be set to t, which means that the given face will override the string face. See the documentation for the variable "font-lock-keywords" for details. Here's an example:
```el
(define-derived-mode temp-mode fundamental-mod... |
236,530 | <p>I'd like to do the same in C#. Is there anyway of using properties in C# with parameters in the same way I've done with the parameter 'Key' in this VB.NET example?</p>
<blockquote>
<pre><code>Private Shared m_Dictionary As IDictionary(Of String, Object) = New Dictionary(Of String, Object)
</code></pre>
</blockquote... | [
{
"answer_id": 236539,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 5,
"selected": true,
"text": "<blockquote>\n <p>Is there anyway of using properties in C# with parameters</p>\n</blockquote>\n\n<p>No. You only can... | 2008/10/25 | [
"https://Stackoverflow.com/questions/236530",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31434/"
] | I'd like to do the same in C#. Is there anyway of using properties in C# with parameters in the same way I've done with the parameter 'Key' in this VB.NET example?
>
>
> ```
> Private Shared m_Dictionary As IDictionary(Of String, Object) = New Dictionary(Of String, Object)
>
> ```
>
>
```
Public Shared Property ... | >
> Is there anyway of using properties in C# with parameters
>
>
>
No. You only can provide the *default* property in C# with an argument, to model indexed access (as in a dictionary):
```
public T this[string key] {
get { return m_Dictionary[key]; }
set { m_Dictionary[key] = value; }
}
```
Other prope... |
236,533 | <p>I want to be able to selectively copy a list of files and preserve their directory structure. The problem is that there are quite a few files that their path exceeds 256 character. How is this problem usually handled?</p>
<p>Edit:
I should make it clear that I only want to selectively copy files, not folders. I ... | [
{
"answer_id": 236536,
"author": "Tomalak",
"author_id": 18771,
"author_profile": "https://Stackoverflow.com/users/18771",
"pm_score": 3,
"selected": true,
"text": "<p>I wrote a VBscript that checks path length and calls <code>subst</code>, as soon as a certain threshold is reached. The... | 2008/10/25 | [
"https://Stackoverflow.com/questions/236533",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1469014/"
] | I want to be able to selectively copy a list of files and preserve their directory structure. The problem is that there are quite a few files that their path exceeds 256 character. How is this problem usually handled?
Edit:
I should make it clear that I only want to selectively copy files, not folders. I don't think r... | I wrote a VBscript that checks path length and calls `subst`, as soon as a certain threshold is reached. These calls are stacked on each other so that in the middle of a recursion, this layout exists:
```
C:\a\very\long\path
subst K: "C:\a\very\long\path"
K:\another\very\long\path
subst L: "K:\another\very\long\path"... |
236,538 | <p>How do I get the directory where the rakefile.rb is located?</p>
<p>I want to use this as my root directory to locate everything off.</p>
| [
{
"answer_id": 236554,
"author": "TonyLa",
"author_id": 1295,
"author_profile": "https://Stackoverflow.com/users/1295",
"pm_score": 2,
"selected": false,
"text": "<p>If this is a RoR app your Rakefile.rb should be in your RAILS_ROOT directory. So in any script you can specify file locat... | 2008/10/25 | [
"https://Stackoverflow.com/questions/236538",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11755/"
] | How do I get the directory where the rakefile.rb is located?
I want to use this as my root directory to locate everything off. | use `__FILE__` to get the file name then you can get the directory from there:
in `test.rb`
```
puts __FILE__
```
output:
```
/users/foo/test.rb
```
`__FILE__` resolves to the full path of the file it is in.
Use this to get the dir name:
```
File.dirname(__FILE__)
``` |
236,555 | <p>I built an application which displays the records from database in the window and checks the the database for new records every couple of seconds. The problem is that the window blinks each time I check for new records and I want to fix it. I have tried to compare the old datatable with the new one and refresh only ... | [
{
"answer_id": 236577,
"author": "Dave Markle",
"author_id": 24995,
"author_profile": "https://Stackoverflow.com/users/24995",
"pm_score": 3,
"selected": true,
"text": "<p>First off, it's important to recognize that what you're comparing in your code is the <em>references</em> of the dat... | 2008/10/25 | [
"https://Stackoverflow.com/questions/236555",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22996/"
] | I built an application which displays the records from database in the window and checks the the database for new records every couple of seconds. The problem is that the window blinks each time I check for new records and I want to fix it. I have tried to compare the old datatable with the new one and refresh only if ... | First off, it's important to recognize that what you're comparing in your code is the *references* of the datatables, not the *contents* of the datatables. In order to determine if both datatables have the same contents, you're going to have to loop through all of the rows and columns and see if they're equal:
```
//T... |
236,575 | <p>Given an EmployeeId, how can I construct a Linq to Sql query to find all of the ancestors of the employee? Each EmployeeId has an associated SupervisorId (see below).</p>
<p>For example, a query of the ancestors for EmployeeId 6 (Frank Black) should return Jane Doe, Bob Smith, Joe Bloggs, and Head Honcho.</p>
<p>... | [
{
"answer_id": 236577,
"author": "Dave Markle",
"author_id": 24995,
"author_profile": "https://Stackoverflow.com/users/24995",
"pm_score": 3,
"selected": true,
"text": "<p>First off, it's important to recognize that what you're comparing in your code is the <em>references</em> of the dat... | 2008/10/25 | [
"https://Stackoverflow.com/questions/236575",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24358/"
] | Given an EmployeeId, how can I construct a Linq to Sql query to find all of the ancestors of the employee? Each EmployeeId has an associated SupervisorId (see below).
For example, a query of the ancestors for EmployeeId 6 (Frank Black) should return Jane Doe, Bob Smith, Joe Bloggs, and Head Honcho.
If necessary, I ca... | First off, it's important to recognize that what you're comparing in your code is the *references* of the datatables, not the *contents* of the datatables. In order to determine if both datatables have the same contents, you're going to have to loop through all of the rows and columns and see if they're equal:
```
//T... |
236,593 | <p>How to do svn update of multiple files located across different directories ? </p>
<p>For committing multiple files from different directories, we can put them all up in a text file and give that file as an argument to svn commit and it will happily commit all those files. But <b>update</b> ?</p>
<p><b>EDIT:</b> M... | [
{
"answer_id": 236600,
"author": "Mr Fooz",
"author_id": 25050,
"author_profile": "https://Stackoverflow.com/users/25050",
"pm_score": 1,
"selected": false,
"text": "<p>If you don't mind creating a separate file with a canned list of directories, you could make it a shell script or .bat ... | 2008/10/25 | [
"https://Stackoverflow.com/questions/236593",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27474/"
] | How to do svn update of multiple files located across different directories ?
For committing multiple files from different directories, we can put them all up in a text file and give that file as an argument to svn commit and it will happily commit all those files. But **update** ?
**EDIT:** Mr. Fooz's answer is def... | Given that there are valid reasons for selectively updating from a repository when there are a lot of downstream changes available, my question would be whether you're trying to do this on a UNIX/Linux/etc. system or Windows. If Windows, I don't know how to do an equivalent of the following:
```
svn update `cat list_o... |
236,599 | <p>I am using C# 2.0 with Nunit Test. I have some object that needs to be serialized. These objects are quite complex (inheritance at different levels and contains a lot of objects, events and delegates).</p>
<p>How can I create a Unit Test to be sure that my object is safely serializable?</p>
| [
{
"answer_id": 236602,
"author": "Patrick Desjardins",
"author_id": 13913,
"author_profile": "https://Stackoverflow.com/users/13913",
"pm_score": 5,
"selected": true,
"text": "<p>I have this in some unit test here at job:</p>\n\n<pre><code>MyComplexObject dto = new MyComplexObject();\nMe... | 2008/10/25 | [
"https://Stackoverflow.com/questions/236599",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21386/"
] | I am using C# 2.0 with Nunit Test. I have some object that needs to be serialized. These objects are quite complex (inheritance at different levels and contains a lot of objects, events and delegates).
How can I create a Unit Test to be sure that my object is safely serializable? | I have this in some unit test here at job:
```
MyComplexObject dto = new MyComplexObject();
MemoryStream mem = new MemoryStream();
BinaryFormatter b = new BinaryFormatter();
try
{
b.Serialize(mem, dto);
}
catch (Exception ex)
{
Assert.Fail(ex.Message);
}
```
Might help you... maybe other method can be better... |
236,624 | <p>For instance in the snippet below - how do I access the h1 element knowing the ID of parent element (header-inner div)?</p>
<pre><code><div id='header-inner'>
<div class='titlewrapper'>
<h1 class='title'>
Some text I want to change
</h1>
</div>
</div>... | [
{
"answer_id": 236655,
"author": "Shog9",
"author_id": 811,
"author_profile": "https://Stackoverflow.com/users/811",
"pm_score": 6,
"selected": true,
"text": "<pre><code>function findFirstDescendant(parent, tagname)\n{\n parent = document.getElementById(parent);\n var descendants = p... | 2008/10/25 | [
"https://Stackoverflow.com/questions/236624",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1311500/"
] | For instance in the snippet below - how do I access the h1 element knowing the ID of parent element (header-inner div)?
```
<div id='header-inner'>
<div class='titlewrapper'>
<h1 class='title'>
Some text I want to change
</h1>
</div>
</div>
```
Thanks! | ```
function findFirstDescendant(parent, tagname)
{
parent = document.getElementById(parent);
var descendants = parent.getElementsByTagName(tagname);
if ( descendants.length )
return descendants[0];
return null;
}
var header = findFirstDescendant("header-inner", "h1");
```
Finds the element with th... |
236,629 | <p>I may be in the minority here, but I very much enjoy <a href="https://perldoc.perl.org/perlform" rel="nofollow noreferrer">Perl's formats</a>. I especially like being able to wrap a long piece of text within a column ("~~ ^<<<<<<<<<<<<<<<<" type stuff). Ar... | [
{
"answer_id": 236651,
"author": "dsm",
"author_id": 7780,
"author_profile": "https://Stackoverflow.com/users/7780",
"pm_score": 2,
"selected": false,
"text": "<p>There is the <a href=\"http://gigamonkeys.com/book/a-few-format-recipes.html\" rel=\"nofollow noreferrer\">Lisp <code>(format... | 2008/10/25 | [
"https://Stackoverflow.com/questions/236629",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5922/"
] | I may be in the minority here, but I very much enjoy [Perl's formats](https://perldoc.perl.org/perlform). I especially like being able to wrap a long piece of text within a column ("~~ ^<<<<<<<<<<<<<<<<" type stuff). Are there any other programming languages that have similar features, or libraries that implement simil... | [FormatR](http://formatr.rubyforge.org/) provides Perl-like formats for Ruby.
Here is an example from the documentation:
```
require "formatr"
include FormatR
top_ex = <<DOT
Piggy Locations for @<< @#, @###
month, day, year
Number: location toe size
-----------------------------... |
236,632 | <p>Please help me with a sanity check. Assuming a many-to-many relationship:</p>
<p><a href="http://www.codingthewheel.com/pics/many_to_many.gif" rel="nofollow noreferrer">Post, PostTagAssoc, Tag http://www.codingthewheel.com/pics/many_to_many.gif</a></p>
<p>What's the most succinct way (using LINQ to SQL) to get a r... | [
{
"answer_id": 236680,
"author": "James Curran",
"author_id": 12725,
"author_profile": "https://Stackoverflow.com/users/12725",
"pm_score": 4,
"selected": true,
"text": "<pre><code> from pta in db.PostTagAssoc\n group pta by pta.PostID into t\n select new {PostID = t.Key, TagCount=t.Coun... | 2008/10/25 | [
"https://Stackoverflow.com/questions/236632",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Please help me with a sanity check. Assuming a many-to-many relationship:
[Post, PostTagAssoc, Tag http://www.codingthewheel.com/pics/many\_to\_many.gif](http://www.codingthewheel.com/pics/many_to_many.gif)
What's the most succinct way (using LINQ to SQL) to get a result set showing, for **each** tag (or post), the a... | ```
from pta in db.PostTagAssoc
group pta by pta.PostID into t
select new {PostID = t.Key, TagCount=t.Count()}
``` |
236,644 | <p>I created the setup project for the application and I can see that the later modifications of the configuration file (Application.exe.config) don't affect the application execution.</p>
<p>I am developing an application with the database file included and I want to enable users to move the database file and modify ... | [
{
"answer_id": 236657,
"author": "Alexandre Brisebois",
"author_id": 18619,
"author_profile": "https://Stackoverflow.com/users/18619",
"pm_score": 0,
"selected": false,
"text": "<p>did you make sure to remove the settings default values? These are compiled and fetched from the dll and no... | 2008/10/25 | [
"https://Stackoverflow.com/questions/236644",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22996/"
] | I created the setup project for the application and I can see that the later modifications of the configuration file (Application.exe.config) don't affect the application execution.
I am developing an application with the database file included and I want to enable users to move the database file and modify connection... | It should work, provided that you use the exact same connection string setting in your DB access DLL's Settings.settings file and in your application's config file.
An example that works well for me:
```
<connectionStrings>
<add name="YourApp.Properties.Settings.DatabaseConnectionString"
connectionString="Data S... |
236,668 | <p>I have been slowly learning SQL the last few weeks. I've picked up all of the relational algebra and the basics of how relational databases work. What I'm trying to do now is learn how it's implemented.</p>
<p>A stumbling block I've come across in this, is foreign keys in MySQL. I can't seem to find much about the ... | [
{
"answer_id": 236677,
"author": "DOK",
"author_id": 27637,
"author_profile": "https://Stackoverflow.com/users/27637",
"pm_score": 3,
"selected": false,
"text": "<p><a href=\"http://dev.mysql.com/doc/refman/5.0/en/innodb-foreign-key-constraints.html\" rel=\"nofollow noreferrer\">This</a>... | 2008/10/25 | [
"https://Stackoverflow.com/questions/236668",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1063/"
] | I have been slowly learning SQL the last few weeks. I've picked up all of the relational algebra and the basics of how relational databases work. What I'm trying to do now is learn how it's implemented.
A stumbling block I've come across in this, is foreign keys in MySQL. I can't seem to find much about the other than... | Assuming your categories and users table already exist and contain cID and uID respectively as primary keys, this should work:
```
CREATE TABLE `posts` (
`pID` bigint(20) NOT NULL auto_increment,
`content` text NOT NULL,
`time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`uID` bigint(20) NOT NULL,
`wikiptr` bigint(2... |
236,675 | <p>How to cancel a keypress event in a textbox after pressing the return key.</p>
| [
{
"answer_id": 236687,
"author": "lacop",
"author_id": 894,
"author_profile": "https://Stackoverflow.com/users/894",
"pm_score": 3,
"selected": true,
"text": "<p>Set the Handled property of KeyPressEventArgs handler parameter to true.</p>\n\n<p>Example from msdn:</p>\n\n<pre><code>privat... | 2008/10/25 | [
"https://Stackoverflow.com/questions/236675",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26087/"
] | How to cancel a keypress event in a textbox after pressing the return key. | Set the Handled property of KeyPressEventArgs handler parameter to true.
Example from msdn:
```
private void keypressed(Object o, KeyPressEventArgs e)
{
if (e.KeyChar == (char)Keys.Return)
{
e.Handled = true;
}
}
```
See <http://msdn.microsoft.com/en-us/library/system.windows.forms.keypressevent... |
236,676 | <p>I have an IList of type Breadcrumb which is just a lightweight class that has NavigationTitle, NavigationUrl and IsCurrent properties. It is cached on the webserver. I have a method that builds out the current breadcrumb trail up until the first Breadcrumb that has IsCurrent set to true... using the code below. Its ... | [
{
"answer_id": 236701,
"author": "James Curran",
"author_id": 12725,
"author_profile": "https://Stackoverflow.com/users/12725",
"pm_score": 1,
"selected": false,
"text": "<p>First of all, that code doesn't work. I'm gonna guess that some of those places where you used \"crumbs\" you mea... | 2008/10/25 | [
"https://Stackoverflow.com/questions/236676",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6350/"
] | I have an IList of type Breadcrumb which is just a lightweight class that has NavigationTitle, NavigationUrl and IsCurrent properties. It is cached on the webserver. I have a method that builds out the current breadcrumb trail up until the first Breadcrumb that has IsCurrent set to true... using the code below. Its ver... | I'm typing this as I think, so that it shows a train of thought as well as just an answer.
* Your source is just cachedCrumbs
* You want to add the first crumb which *does* have IsCurrent set, but nothing afterwards
* TakeWhile sounds like the way to go, but getting the "previous value had IsCurrent" is a bit of a pai... |
236,692 | <p>I have a device that supports 4-color graphics (much like CGA in the old days).</p>
<p>I wanted to use <a href="http://www.pythonware.com/products/pil/" rel="noreferrer">PIL</a> to read the image and convert it using my 4-color palette (of red, green, yellow, black), but I can't figure out if it's even possible at ... | [
{
"answer_id": 237193,
"author": "tzot",
"author_id": 6899,
"author_profile": "https://Stackoverflow.com/users/6899",
"pm_score": 5,
"selected": true,
"text": "<p>First: your four colour palette (black, green, red, yellow) has <em>no</em> blue component. So, you have to accept that your ... | 2008/10/25 | [
"https://Stackoverflow.com/questions/236692",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2900/"
] | I have a device that supports 4-color graphics (much like CGA in the old days).
I wanted to use [PIL](http://www.pythonware.com/products/pil/) to read the image and convert it using my 4-color palette (of red, green, yellow, black), but I can't figure out if it's even possible at all. I found some mailing list archive... | First: your four colour palette (black, green, red, yellow) has *no* blue component. So, you have to accept that your output image will hardly approximate the input image, unless there is no blue component to start with.
Try this code:
```
import Image
def estimate_color(c, bit, c_error):
c_new= c - c_error
... |
236,713 | <p>Please help, I am stuck here ---</p>
<pre><code>irb> a = "line of text\n line two\n line three"
irb> system("cat > test_file << #{a}")
cat: of: No such file or directory
cat: text: No such file or directory
=> false
</code></pre>
| [
{
"answer_id": 236727,
"author": "Ivan",
"author_id": 16957,
"author_profile": "https://Stackoverflow.com/users/16957",
"pm_score": 3,
"selected": true,
"text": "<p>You need to quote the interpolated parameter:</p>\n\n<pre><code>system(\"cat > test_file << \\\"#{a}\\\"\")\n</cod... | 2008/10/25 | [
"https://Stackoverflow.com/questions/236713",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31347/"
] | Please help, I am stuck here ---
```
irb> a = "line of text\n line two\n line three"
irb> system("cat > test_file << #{a}")
cat: of: No such file or directory
cat: text: No such file or directory
=> false
``` | You need to quote the interpolated parameter:
```
system("cat > test_file << \"#{a}\"")
```
And, cat is expecting a filename, not some text to append to test\_file, so, this would work as I think you intended:
```
system("echo \"#{a}\" >> test_file")
```
If you want to do this in pure Ruby let me know and I'll gi... |
236,715 | <p>I am using Ruby on Rails.</p>
<p>I want to create a filter field on a page such that whenever the input field's value changes I filter a list shown below via ajax. (Exaclty like the Users search works in Stackoverflow)</p>
<p>For now, I made it run with a form_remote_tag containing a text_field_tag and a submit_ta... | [
{
"answer_id": 236721,
"author": "Ricardo Acras",
"author_id": 19224,
"author_profile": "https://Stackoverflow.com/users/19224",
"pm_score": 3,
"selected": true,
"text": "<p>Use <strong>observe_field</strong> helper with a single input, like the code bellow:</p>\n\n<pre><code><%= text... | 2008/10/25 | [
"https://Stackoverflow.com/questions/236715",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2534/"
] | I am using Ruby on Rails.
I want to create a filter field on a page such that whenever the input field's value changes I filter a list shown below via ajax. (Exaclty like the Users search works in Stackoverflow)
For now, I made it run with a form\_remote\_tag containing a text\_field\_tag and a submit\_tag, and it fi... | Use **observe\_field** helper with a single input, like the code bellow:
```
<%= text_field_tag 'filter' %>
<%= observe_field 'filter',
:url => {:controller => 'your_controller', :action => 'filter'},
:frequency => 1.2,
:update => 'results',
:with => "'typed_filter=' + $('filter').value" %>
```
And ... |
236,737 | <p>Perl and PHP do this with backticks. For example,</p>
<pre><code>$output = `ls`;
</code></pre>
<p>Returns a directory listing. A similar function, <code>system("foo")</code>, returns the operating system return code for the given command foo. I'm talking about a variant that returns whatever foo prints to stdout.<... | [
{
"answer_id": 236740,
"author": "dreeves",
"author_id": 4234,
"author_profile": "https://Stackoverflow.com/users/4234",
"pm_score": 3,
"selected": true,
"text": "<p>Perl:</p>\n\n<pre><code>$output = `foo`;\n</code></pre>\n\n<p>ADDED: This is really a multi-way tie. The above is also va... | 2008/10/25 | [
"https://Stackoverflow.com/questions/236737",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4234/"
] | Perl and PHP do this with backticks. For example,
```
$output = `ls`;
```
Returns a directory listing. A similar function, `system("foo")`, returns the operating system return code for the given command foo. I'm talking about a variant that returns whatever foo prints to stdout.
How do other languages do this? Is t... | Perl:
```
$output = `foo`;
```
ADDED: This is really a multi-way tie. The above is also valid PHP, and Ruby, for example, uses the same backtick notation as well. |
236,749 | <p>I have a bunch of ASP.NET web pages (that have a standard layout) that are product documentation. I want to create some sort of combination page that will pull all of the other page content in and concatenate them into one long page.</p>
<p>IFrames won't work because I don't know the size of each page. I could ha... | [
{
"answer_id": 236767,
"author": "chakrit",
"author_id": 3055,
"author_profile": "https://Stackoverflow.com/users/3055",
"pm_score": 0,
"selected": false,
"text": "<p>What does your pages look like?</p>\n\n<p>I assume it's just plain HTMLs and have a consistent pattern across all pages, ... | 2008/10/25 | [
"https://Stackoverflow.com/questions/236749",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7442/"
] | I have a bunch of ASP.NET web pages (that have a standard layout) that are product documentation. I want to create some sort of combination page that will pull all of the other page content in and concatenate them into one long page.
IFrames won't work because I don't know the size of each page. I could have the combi... | Are your "Documentation Pages" static html or .aspx's also...
if its just static content, you could do the following
```
//assume that the array of page names has come from the DB.
protected void Page_Load(object sender, EventArgs e)
{
string[] pages = new string [] { "~/Default.html",
"~/Default2.h... |
236,778 | <p>I have a table named Info of this schema:</p>
<pre><code>int objectId;
int time;
int x, y;
</code></pre>
<p>There is a lot of redundant data in the system - that is, <code>objectId</code> is not UNIQUE. For each <code>objectId</code> there can be multiple entries of <code>time, x, y</code>.</p>
<p>I want to retri... | [
{
"answer_id": 236786,
"author": "Eoin Campbell",
"author_id": 30155,
"author_profile": "https://Stackoverflow.com/users/30155",
"pm_score": 3,
"selected": false,
"text": "<pre><code>SELECT A.time, A.objectID, B.X, B.Y\nFROM\n(\n SELECT max(time) as time, objectID \n FROM table\n G... | 2008/10/25 | [
"https://Stackoverflow.com/questions/236778",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/338/"
] | I have a table named Info of this schema:
```
int objectId;
int time;
int x, y;
```
There is a lot of redundant data in the system - that is, `objectId` is not UNIQUE. For each `objectId` there can be multiple entries of `time, x, y`.
I want to retrieve a list of the latest position of each object. I started out wi... | One way is using a subquery.
```
select distinct a.objectID, a.time, a.x, a.y
from Info a,
(select objectID, max(time) time from Info group by objectID) b
where a.objectID = b.objectID and a.time = b.time
```
EDIT: Added DISTINCT to prevent duplicate rows if one objectId has multiple records with the same... |
236,792 | <p>I take care of critical app in my project. It does stuff related to parsing business msgs (legacy standard), processing them and then storing some results in a DB (another apps picks that up). After more then a year of my work (I've other apps to look after as well) the app is finally stable. I've introduced strict ... | [
{
"answer_id": 237077,
"author": "Head Geek",
"author_id": 12193,
"author_profile": "https://Stackoverflow.com/users/12193",
"pm_score": 0,
"selected": false,
"text": "<p>That <em>does</em> sound like a fun challenge. :-)</p>\n\n<p>Your \"initial plan\" sounds like a good one: factor out... | 2008/10/25 | [
"https://Stackoverflow.com/questions/236792",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3579/"
] | I take care of critical app in my project. It does stuff related to parsing business msgs (legacy standard), processing them and then storing some results in a DB (another apps picks that up). After more then a year of my work (I've other apps to look after as well) the app is finally stable. I've introduced strict TDD... | I would advise you **not** to inherit your specific message handling classes from base classes that contain the common code like this:
```
CommonHandler
^ ^
| | = inheritance
MsgAHandler
^ ^
... |
236,795 | <p>I have a PHP class that creates a PNG image on the fly and sends it to browser. PHP manual says that I need to make sure that <em>imagedestroy</em> function is called at end to release the memory. Now, if I weren't using a class, I would have some code like this:</p>
<pre><code>function shutdown_func()
{
globa... | [
{
"answer_id": 236811,
"author": "Henrik Paul",
"author_id": 2238,
"author_profile": "https://Stackoverflow.com/users/2238",
"pm_score": 0,
"selected": false,
"text": "<p>I think one big thing that you have missed is that all the memory PHP has allocated during script execution is freed ... | 2008/10/25 | [
"https://Stackoverflow.com/questions/236795",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14690/"
] | I have a PHP class that creates a PNG image on the fly and sends it to browser. PHP manual says that I need to make sure that *imagedestroy* function is called at end to release the memory. Now, if I weren't using a class, I would have some code like this:
```
function shutdown_func()
{
global $img;
if ($img)... | I just tested with Apache, PHP being used as Apache module. I created an endless loop like this:
```
<?php
class X
{
function __destruct()
{
$fp = fopen("/var/www/htdocs/dtor.txt", "w+");
fputs($fp, "Destroyed\n");
fclose($fp);
}
};
$obj = new X();
while (true) {
// do nothing
... |
236,801 | <p>That's basically the question, is there a "right" way to implement <code>operator<<</code> ?
Reading <a href="http://bytes.com/forum/thread170304.html" rel="noreferrer">this</a> I can see that something like:</p>
<pre><code>friend bool operator<<(obj const& lhs, obj const& rhs);
</code></pre>
<... | [
{
"answer_id": 236806,
"author": "Magnus Hoff",
"author_id": 2971,
"author_profile": "https://Stackoverflow.com/users/2971",
"pm_score": 6,
"selected": false,
"text": "<p>You can not do it as a member function, because the implicit <code>this</code> parameter is the left hand side of the... | 2008/10/25 | [
"https://Stackoverflow.com/questions/236801",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/161/"
] | That's basically the question, is there a "right" way to implement `operator<<` ?
Reading [this](http://bytes.com/forum/thread170304.html) I can see that something like:
```
friend bool operator<<(obj const& lhs, obj const& rhs);
```
is preferred to something like
```
ostream& operator<<(obj const& rhs);
```
But... | The problem here is in your interpretation of the article you [link](http://bytes.com/forum/thread170304.html).
### Equality
This article is about somebody that is having problems correctly defining the bool relationship operators.
The operator:
* Equality == and !=
* Relationship < > <= >=
These operators should ... |
236,810 | <p>I'm trying to extract an uploaded zip file and store its contents in the database, one entry per file. The rubyzip library has nearly no useful documentation.</p>
<p>There is an assets table that has key :string (file name) and data :binary (file contents).</p>
<p>I'm using the rubyzip library, and have made it a... | [
{
"answer_id": 236827,
"author": "Ivan",
"author_id": 16957,
"author_profile": "https://Stackoverflow.com/users/16957",
"pm_score": 3,
"selected": false,
"text": "<p>It would seem that you can either use the read_local_entry method like this:</p>\n\n<pre><code>asset.data = entry.read_loc... | 2008/10/25 | [
"https://Stackoverflow.com/questions/236810",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2884/"
] | I'm trying to extract an uploaded zip file and store its contents in the database, one entry per file. The rubyzip library has nearly no useful documentation.
There is an assets table that has key :string (file name) and data :binary (file contents).
I'm using the rubyzip library, and have made it as far as this:
``... | Found an even more simple way:
```
asset.data = entry.get_input_stream.read
``` |
236,859 | <p>Any python libs for parsing Bind zone files?
Basically something that will aid in adding/removing zones and records.
This needs to work even if someone modifies the zone file by hand so overwriting the zone files every time is not a solution. </p>
| [
{
"answer_id": 237236,
"author": "Michael Gundlach",
"author_id": 4105,
"author_profile": "https://Stackoverflow.com/users/4105",
"pm_score": 0,
"selected": false,
"text": "<p>See answer above about bicop.</p>\n\n<p>As an aside, the Python Package Index at <a href=\"http://pypi.python.or... | 2008/10/25 | [
"https://Stackoverflow.com/questions/236859",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9789/"
] | Any python libs for parsing Bind zone files?
Basically something that will aid in adding/removing zones and records.
This needs to work even if someone modifies the zone file by hand so overwriting the zone files every time is not a solution. | I was unable to use bicop for classical zone files like these:
```
$TTL 86400
@ IN SOA ns1.first-ns.de. postmaster.robot.first-ns.de. (
2006040800 ; serial
14400 ; refresh
1800 ; retry
604800 ; expire
86400 ) ; minimum
@
IN NS ns1.first-n... |
236,861 | <p>I have a method that creates a MessageDigest (a hash) from a file, and I need to do this to a lot of files (>= 100,000). How big should I make the buffer used to read from the files to maximize performance?</p>
<p>Most everyone is familiar with the basic code (which I'll repeat here just in case):</p>
<pre><code>M... | [
{
"answer_id": 236877,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 5,
"selected": false,
"text": "<p>Yes, it's probably dependent on various things - but I doubt it will make very much difference. I tend to opt for 16K... | 2008/10/25 | [
"https://Stackoverflow.com/questions/236861",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11889/"
] | I have a method that creates a MessageDigest (a hash) from a file, and I need to do this to a lot of files (>= 100,000). How big should I make the buffer used to read from the files to maximize performance?
Most everyone is familiar with the basic code (which I'll repeat here just in case):
```
MessageDigest md = Mes... | Optimum buffer size is related to a number of things: file system block size, CPU cache size and cache latency.
Most file systems are configured to use block sizes of 4096 or 8192. In theory, if you configure your buffer size so you are reading a few bytes more than the disk block, the operations with the file system ... |
236,878 | <p>this is a question that when programming I always wonder: What to use when we are writing code: </p>
<pre><code>var myFiles = Directory.GetFiles(fullPath);
</code></pre>
<p>or</p>
<pre><code>string[] myFiles = Directory.GetFiles(fullPath);
</code></pre>
<p><strong><em>var</em></strong> is new and is a <em>Implic... | [
{
"answer_id": 236886,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 5,
"selected": false,
"text": "<p>You'll get a huge variety of opinions on this one - from \"use var everywhere\" to \"only use var with anonymous type... | 2008/10/25 | [
"https://Stackoverflow.com/questions/236878",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28004/"
] | this is a question that when programming I always wonder: What to use when we are writing code:
```
var myFiles = Directory.GetFiles(fullPath);
```
or
```
string[] myFiles = Directory.GetFiles(fullPath);
```
***var*** is new and is a *Implicitly Typed Local Variables*, so we can only use locally and it has rules... | Beyond the obvious use of `var` with LINQ, I also use it to abbreviate hairy variable declarations for readability, e.g.:
```
var d = new Dictionary<string, Dictionary<string, Queue<SomeClass>>>();
```
In general, I get a kind of comfort (for want of a better word) from static typing that makes me reluctant to give ... |
236,972 | <p>Based on this question <a href="https://stackoverflow.com/questions/19746/views-in-seperate-assemblies-in-aspnet-mvc">here</a> and using code found <a href="http://www.codeproject.com/KB/aspnet/ASP2UserControlLibrary.aspx" rel="nofollow noreferrer">here</a> I'm trying to load views that are embedded resources in a s... | [
{
"answer_id": 238131,
"author": "Brad Wilson",
"author_id": 1554,
"author_profile": "https://Stackoverflow.com/users/1554",
"pm_score": 2,
"selected": false,
"text": "<p>The built-in WebFormsViewEngine uses VirtualPathProviders, so if you write a VPP and register it, you won't need to m... | 2008/10/25 | [
"https://Stackoverflow.com/questions/236972",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2285/"
] | Based on this question [here](https://stackoverflow.com/questions/19746/views-in-seperate-assemblies-in-aspnet-mvc) and using code found [here](http://www.codeproject.com/KB/aspnet/ASP2UserControlLibrary.aspx) I'm trying to load views that are embedded resources in a separate DLL project, and the original question's au... | 1. You must register your `VirtualPathProvider` within the `Global.asax` `Application_Start` handler.
2. You must call the view in your DLL using the special path like so: `return View("~/Plugin/YOURDLL.dll/FULLNAME_YOUR_VIEW.aspx");`
Here's an article with downloadable code sample that demonstrates this:
<http://www... |
236,979 | <p>I'm creating a CSS editor and am trying to create a regular expression that can get data from a CSS document. This regex works if I have one property but I can't get it to work for all properties. I'm using preg/perl syntax in PHP.</p>
<h3>Regex</h3>
<pre><code>(?<selector>[A-Za-z]+[\s]*)[\s]*{[\s]*((?<pr... | [
{
"answer_id": 236984,
"author": "Tanktalus",
"author_id": 23512,
"author_profile": "https://Stackoverflow.com/users/23512",
"pm_score": 5,
"selected": true,
"text": "<p>That just seems too convoluted for a single regular expression. Well, I'm sure that with the right extentions, an adv... | 2008/10/25 | [
"https://Stackoverflow.com/questions/236979",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2025/"
] | I'm creating a CSS editor and am trying to create a regular expression that can get data from a CSS document. This regex works if I have one property but I can't get it to work for all properties. I'm using preg/perl syntax in PHP.
### Regex
```
(?<selector>[A-Za-z]+[\s]*)[\s]*{[\s]*((?<properties>[A-Za-z0-9-_]+)[\s]... | That just seems too convoluted for a single regular expression. Well, I'm sure that with the right extentions, an advanced user could create the right regex. But then you'd need an even more advanced user to debug it.
Instead, I'd suggest using a regex to pull out the pieces, and then tokenising each piece separately.... |
237,006 | <p>I installed SQL Server 2005 sometime ago and forgot the administrator password I set during setup. How can I connect to SQL server now?</p>
<p><strong>EDIT:</strong> I think I only allowed Sql Server Authentication. Login with integrated security also does not work.</p>
| [
{
"answer_id": 237008,
"author": "Lasse V. Karlsen",
"author_id": 267,
"author_profile": "https://Stackoverflow.com/users/267",
"pm_score": 0,
"selected": false,
"text": "<p>Unless you set it up to only accept SQL Server authentication, you can log on with integrated security using the a... | 2008/10/25 | [
"https://Stackoverflow.com/questions/237006",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I installed SQL Server 2005 sometime ago and forgot the administrator password I set during setup. How can I connect to SQL server now?
**EDIT:** I think I only allowed Sql Server Authentication. Login with integrated security also does not work. | Try running the following commands at the command prompt (assuming your Server name is **SQLEXPRESS**):
```
osql -E -S .\SQLEXPRESS
exec sp_password @new='changeme', @loginame='sa'
go
alter login sa enable
go
exit
```
Once you have completed these steps, try to login with username **sa** and password **changeme**. |
237,027 | <p>Here's my problem: I have a virtual method defined in a .h file that I want to call in a class that inherits from the base class. Sadly though, the method in the derived class doesn't get called. Is there a better way to implement what I'm trying to do?</p>
<pre><code>#ifndef ofxBASE_SND_OBJ
#define ofxBASE_SND_OBJ... | [
{
"answer_id": 237033,
"author": "Rob Walker",
"author_id": 3631,
"author_profile": "https://Stackoverflow.com/users/3631",
"pm_score": 3,
"selected": false,
"text": "<p>You need to pass the instance to createFilter as a <strong>pointer</strong> (or reference) to the object. You are <a ... | 2008/10/25 | [
"https://Stackoverflow.com/questions/237027",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/66105/"
] | Here's my problem: I have a virtual method defined in a .h file that I want to call in a class that inherits from the base class. Sadly though, the method in the derived class doesn't get called. Is there a better way to implement what I'm trying to do?
```
#ifndef ofxBASE_SND_OBJ
#define ofxBASE_SND_OBJ
#include "of... | Change this line:
```
string ofxSndObj::createFilter(ofxBaseSndObj obj)
```
to
```
string ofxSndObj::createFilter(ofxBaseSndObj& obj)
```
What you are doing is passing by value (passing a copy).
This means you are copying the object to the function. Because the function does not know what type you are actually p... |
237,041 | <p>Does anyone know what will be in .NET 4.0?</p>
<p>I found <a href="https://mef.svn.codeplex.com/svn/src/ComponentModel/System/Tuple.cs" rel="nofollow noreferrer">tuples on codeplex</a>:</p>
<pre><code>....
// NOTE : this is a TEMPORARY and a very minimalistic implementation of Tuple'2,
// as defined in http://dev... | [
{
"answer_id": 237046,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 2,
"selected": false,
"text": "<p><a href=\"http://blogs.msdn.com/pfxteam/archive/2008/10/10/8994927.aspx\" rel=\"nofollow noreferrer\">Parallel Extens... | 2008/10/25 | [
"https://Stackoverflow.com/questions/237041",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29788/"
] | Does anyone know what will be in .NET 4.0?
I found [tuples on codeplex](https://mef.svn.codeplex.com/svn/src/ComponentModel/System/Tuple.cs):
```
....
// NOTE : this is a TEMPORARY and a very minimalistic implementation of Tuple'2,
// as defined in http://devdiv/sites/docs/NetFX4/CLR/Specs/Base Class Libraries/Tuple... | [Parallel Extensions](http://blogs.msdn.com/pfxteam/archive/2008/10/10/8994927.aspx)
[WCF/WF improvements](http://blogs.msdn.com/wenlong/archive/2008/09/07/net-4-0-wf-wcf-and-oslo.aspx)
I expect BigInteger will be back, too. I'd really like to see a bunch of the F# immutable collections become part of ".NET proper" t... |
237,044 | <p>I'm trying to compile code from F# to use in Silverlight. I compile with:</p>
<p>--noframework --cliroot "C:\program Files\Microsoft Silverlight\2.0.31005.0" --standalone</p>
<p>This generates a standalone assembly that references the SL framework. But when I try to add a reference to the generated assembly, I ge... | [
{
"answer_id": 245116,
"author": "MichaelGG",
"author_id": 27012,
"author_profile": "https://Stackoverflow.com/users/27012",
"pm_score": 4,
"selected": true,
"text": "<p><strong>Answer!</strong></p>\n\n<p>Apparently the problem is that when you add a reference to the bin\\Release or bin\... | 2008/10/25 | [
"https://Stackoverflow.com/questions/237044",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27012/"
] | I'm trying to compile code from F# to use in Silverlight. I compile with:
--noframework --cliroot "C:\program Files\Microsoft Silverlight\2.0.31005.0" --standalone
This generates a standalone assembly that references the SL framework. But when I try to add a reference to the generated assembly, I get this error:
>
... | **Answer!**
Apparently the problem is that when you add a reference to the bin\Release or bin\Debug, Visual Studio (or the Silverlight project system) decides to try to reference the project. This fails for whatever reason.
If you copy the F# output DLL to another location, then the reference goes through just fine. ... |
237,058 | <p>A string will be made up of certain symbols (ax,bx,dx,c,acc for example) and numbers.</p>
<p>ex:
ax 5 5
dx 3 acc
c ax bx</p>
<p>I want to replace one or all of the symbols (randomly) with another symbol of the same set. ie, replace one of {ax,bx,dx,c,acc} with one of {ax,bx,dx,c,acc}.</p>
<p>replacement example:
... | [
{
"answer_id": 237088,
"author": "postfuturist",
"author_id": 1892,
"author_profile": "https://Stackoverflow.com/users/1892",
"pm_score": 1,
"selected": false,
"text": "<p>To answer the first question: no.</p>\n\n<p>Since you are doing a random replace, regex will not help you, nothing a... | 2008/10/25 | [
"https://Stackoverflow.com/questions/237058",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27677/"
] | A string will be made up of certain symbols (ax,bx,dx,c,acc for example) and numbers.
ex:
ax 5 5
dx 3 acc
c ax bx
I want to replace one or all of the symbols (randomly) with another symbol of the same set. ie, replace one of {ax,bx,dx,c,acc} with one of {ax,bx,dx,c,acc}.
replacement example:
acc 5 5
dx 3 acc
c ax bx... | I think this is the most clean solution for replacing a certain set of symbols from a string containing a superset of them.
appendreplacement is the key to this method.
one important caveat: do not include any unescped dollar characters ($) in your elements list. escape them by using "\$"
eventually use
.replaceall... |
237,061 | <p>I have several strings in the rough form:</p>
<pre><code>[some text] [some number] [some more text]
</code></pre>
<p>I want to extract the text in [some number] using the Java Regex classes.</p>
<p>I know roughly what regular expression I want to use (though all suggestions are welcome). What I'm really intereste... | [
{
"answer_id": 237068,
"author": "Allain Lalonde",
"author_id": 2443,
"author_profile": "https://Stackoverflow.com/users/2443",
"pm_score": 10,
"selected": true,
"text": "<p>Full example:</p>\n\n<pre><code>private static final Pattern p = Pattern.compile(\"^([a-zA-Z]+)([0-9]+)(.*)\");\np... | 2008/10/25 | [
"https://Stackoverflow.com/questions/237061",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3488/"
] | I have several strings in the rough form:
```
[some text] [some number] [some more text]
```
I want to extract the text in [some number] using the Java Regex classes.
I know roughly what regular expression I want to use (though all suggestions are welcome). What I'm really interested in are the Java calls to take t... | Full example:
```
private static final Pattern p = Pattern.compile("^([a-zA-Z]+)([0-9]+)(.*)");
public static void main(String[] args) {
// create matcher for pattern p and given string
Matcher m = p.matcher("Testing123Testing");
// if an occurrence if a pattern was found in a given string...
if (m.fi... |
237,063 | <p>I've created a one-line batch file to run SqlMetal to regenerate a LINQ to SQL DataContext for my database; this works great. </p>
<p><em>Refresh_DataContext.bat</em>:</p>
<pre><code>"C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin\sqlmetal.exe"
/server:.\sqlexpress /database:MyDatabaseName
/code:"%~... | [
{
"answer_id": 237227,
"author": "Dave Markle",
"author_id": 24995,
"author_profile": "https://Stackoverflow.com/users/24995",
"pm_score": 2,
"selected": false,
"text": "<p>What you seem to be looking for can be found under \"Pre-build event command line\" under your project's properties... | 2008/10/25 | [
"https://Stackoverflow.com/questions/237063",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/239663/"
] | I've created a one-line batch file to run SqlMetal to regenerate a LINQ to SQL DataContext for my database; this works great.
*Refresh\_DataContext.bat*:
```
"C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin\sqlmetal.exe"
/server:.\sqlexpress /database:MyDatabaseName
/code:"%~dp0\DataContext.vb" /contex... | Doh! Of course. Web Application projects have pre- and post- build events; Web Site projects don't. |
237,064 | <p>i am trying to compile this very simple piece of code</p>
<pre><code>class myList
{
public:
std::vector<std::string> vec;
class Items
{
public:
void Add(std::string str)
{
myList::vec.push_back(str);
};
}items;
};
int main()
{
myList newList;
ne... | [
{
"answer_id": 237072,
"author": "richq",
"author_id": 4596,
"author_profile": "https://Stackoverflow.com/users/4596",
"pm_score": 5,
"selected": true,
"text": "<p>Add a couple of constructors and a pointer to the parent class.</p>\n\n<pre><code>#include <string>\n#include <vect... | 2008/10/25 | [
"https://Stackoverflow.com/questions/237064",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28954/"
] | i am trying to compile this very simple piece of code
```
class myList
{
public:
std::vector<std::string> vec;
class Items
{
public:
void Add(std::string str)
{
myList::vec.push_back(str);
};
}items;
};
int main()
{
myList newList;
newList.items.Add("A")... | Add a couple of constructors and a pointer to the parent class.
```
#include <string>
#include <vector>
class myList
{
public:
std::vector<std::string> vec;
myList(): items(this) {} // Added
class Items
{
public:
Items(myList *ml): self(ml) {} // Added
void Add(std::string str)
... |
237,079 | <p>What's the best cross-platform way to get file creation and modification dates/times, that works on both Linux and Windows?</p>
| [
{
"answer_id": 237082,
"author": "Martin Beckett",
"author_id": 10897,
"author_profile": "https://Stackoverflow.com/users/10897",
"pm_score": 6,
"selected": false,
"text": "<p><a href=\"https://docs.python.org/2/library/stat.html#module-stat\" rel=\"nofollow noreferrer\">os.stat</a></p>\... | 2008/10/25 | [
"https://Stackoverflow.com/questions/237079",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/305/"
] | What's the best cross-platform way to get file creation and modification dates/times, that works on both Linux and Windows? | In Python 3.4 and above, you can use the object oriented [pathlib module](https://docs.python.org/3/library/pathlib.html) interface which includes wrappers for much of the os module. Here is an example of getting the file stats.
```
>>> import pathlib
>>> fname = pathlib.Path('test.py')
>>> assert fname.exists(), f'No... |
237,085 | <p>It's possible to write <a href="http://en.wikipedia.org/wiki/Markdown" rel="noreferrer">Markdown</a> content with invalid syntax. Invalid means that the <a href="http://www.deveiate.org/projects/BlueCloth" rel="noreferrer">BlueCloth</a> library fails to parse the content and throws an exception. The <code>markdown</... | [
{
"answer_id": 237200,
"author": "Damir Zekić",
"author_id": 401510,
"author_profile": "https://Stackoverflow.com/users/401510",
"pm_score": 4,
"selected": true,
"text": "<p>You should write your own validation method in which you would initialize BlueCloth object, and try to call <code>... | 2008/10/25 | [
"https://Stackoverflow.com/questions/237085",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20467/"
] | It's possible to write [Markdown](http://en.wikipedia.org/wiki/Markdown) content with invalid syntax. Invalid means that the [BlueCloth](http://www.deveiate.org/projects/BlueCloth) library fails to parse the content and throws an exception. The `markdown` helper in Rails doesn't catch any BlueCloth exceptions and becau... | You should write your own validation method in which you would initialize BlueCloth object, and try to call `to_html` method catching any exception. If you catch an exception, validation fails, otherwise it should be ok.
In your model:
```
protected:
def validate
bc = BlueCloth.new(your_markdown_string_attribute)
... |
237,104 | <p>What is the most concise and efficient way to find out if a JavaScript array contains a value?</p>
<p>This is the only way I know to do it:</p>
<pre><code>function contains(a, obj) {
for (var i = 0; i < a.length; i++) {
if (a[i] === obj) {
return true;
}
}
return false;
}
<... | [
{
"answer_id": 237142,
"author": "Andru Luvisi",
"author_id": 5922,
"author_profile": "https://Stackoverflow.com/users/5922",
"pm_score": 4,
"selected": false,
"text": "<p>If you are using JavaScript 1.6 or later (Firefox 1.5 or later) you can use <a href=\"https://developer.mozilla.org/... | 2008/10/25 | [
"https://Stackoverflow.com/questions/237104",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/208/"
] | What is the most concise and efficient way to find out if a JavaScript array contains a value?
This is the only way I know to do it:
```
function contains(a, obj) {
for (var i = 0; i < a.length; i++) {
if (a[i] === obj) {
return true;
}
}
return false;
}
```
Is there a better... | Modern browsers have [`Array#includes`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/includes#browser_compatibility), which does *exactly* that and [is widely supported](https://kangax.github.io/compat-table/es2016plus/#test-Array.prototype.includes) by everyone except IE:
```... |
237,106 | <p>I have a legacy DLL written in C that contains a function that returns a string, and I need to access this function from Delphi. The only info I have about the DLL is the VB declare for accessing the function:</p>
<p>Public Declare Function DecryptStr Lib "strlib" (Str As String) As String </p>
<p>I've tried the f... | [
{
"answer_id": 237246,
"author": "CesarB",
"author_id": 28258,
"author_profile": "https://Stackoverflow.com/users/28258",
"pm_score": 2,
"selected": false,
"text": "<p>I'm guessing here, but are you sure it's cdecl? If the VB declare isn't mentioning it, I'd assume it's in fact a STDCALL... | 2008/10/25 | [
"https://Stackoverflow.com/questions/237106",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31510/"
] | I have a legacy DLL written in C that contains a function that returns a string, and I need to access this function from Delphi. The only info I have about the DLL is the VB declare for accessing the function:
Public Declare Function DecryptStr Lib "strlib" (Str As String) As String
I've tried the following without ... | Consider rewriting your test code as follows:
```
var
p1, p2 : pchar;
begin
GetMem( p1, 255 ); // initialize
GetMem( p2, 255 );
StrPLCopy( p2, 'some string to decrypt', 255 ); // prevent buffer overrun
StrPLCopy( p1, DecryptStr( p2 ), 255); // make a copy since dll will free its internal buffer
end;
```
If... |
237,112 | <p>Working on a project where a sequential set of methods must be run every <code>x</code> seconds. Right now I have the methods contained within another "parent method", and just sequentially call them right after another.</p>
<pre><code>class DoTheseThings()
{
DoThis();
NowDoThat();
NowDoThis();
Mor... | [
{
"answer_id": 237122,
"author": "nyxtom",
"author_id": 19753,
"author_profile": "https://Stackoverflow.com/users/19753",
"pm_score": 0,
"selected": false,
"text": "<p>What would be the reason that an error was occuring?</p>\n\n<p>If this were a resource issue, such as access to somethin... | 2008/10/25 | [
"https://Stackoverflow.com/questions/237112",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25300/"
] | Working on a project where a sequential set of methods must be run every `x` seconds. Right now I have the methods contained within another "parent method", and just sequentially call them right after another.
```
class DoTheseThings()
{
DoThis();
NowDoThat();
NowDoThis();
MoreWork();
AndImSpent();... | ```
Action[] work=new Action[]{new Action(DoThis), new Action(NowDoThat),
new Action(NowDoThis), new Action(MoreWork), new Action(AndImSpent)};
int current =0;
while(current!=work.Length)
{
try
{
work[current]();
current++;
}
catch(Exception ex)
{
// log the error or wha... |
237,123 | <p>I'm just learning to work with partial classes in VB.NET and VS2008. Specifically, I'm trying to extend a LINQ to SQL class that was automatically created by SqlMetal. </p>
<p>The automatically generated class looks like this:</p>
<pre><code>Partial Public Class DataContext
Inherits System.Data.Linq.DataContex... | [
{
"answer_id": 237127,
"author": "Aaron Powell",
"author_id": 11388,
"author_profile": "https://Stackoverflow.com/users/11388",
"pm_score": 3,
"selected": true,
"text": "<p>Unless VB.NET generates different stuff in its LINQ to SQL files from C# the classes of the DB tables aren't within... | 2008/10/25 | [
"https://Stackoverflow.com/questions/237123",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/239663/"
] | I'm just learning to work with partial classes in VB.NET and VS2008. Specifically, I'm trying to extend a LINQ to SQL class that was automatically created by SqlMetal.
The automatically generated class looks like this:
```
Partial Public Class DataContext
Inherits System.Data.Linq.DataContext
...
<Table(Name:... | Unless VB.NET generates different stuff in its LINQ to SQL files from C# the classes of the DB tables aren't within the DataContext class, just beside it.
So you have the class **MyNamespace.DataContext.Concession** when the other half of the partial class is realy **MyNamespace.Concession** |
237,131 | <p>I have a <code>JPanel</code> extension that I've written and would like to be able to use it in the NetBeans designer. The component is simply adds some custom painting and continues to function as a container to be customised on each use. </p>
<p>I have properties to expose in addition to the standard <code>JPan... | [
{
"answer_id": 237866,
"author": "Rastislav Komara",
"author_id": 22068,
"author_profile": "https://Stackoverflow.com/users/22068",
"pm_score": 0,
"selected": false,
"text": "<p><a href=\"http://www.netbeans.org\" rel=\"nofollow noreferrer\">http://www.netbeans.org</a> search for Matisse... | 2008/10/25 | [
"https://Stackoverflow.com/questions/237131",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1867/"
] | I have a `JPanel` extension that I've written and would like to be able to use it in the NetBeans designer. The component is simply adds some custom painting and continues to function as a container to be customised on each use.
I have properties to expose in addition to the standard `JPanel` ones and have a custom `... | I made JPanel component in NetBeans with overridden paint method:
```
@Override
public void paint(Graphics g) {
super.paint(g);
Graphics2D g2 = (Graphics2D) g;
...
//draw elements
...
}
```
It has some custom properties accessible through NetBeans properties window.
```
public int getResol... |
237,140 | <p>I was re-reading Effective Java (2nd edition) item 18, <a href="http://my.safaribooksonline.com/9780137150021/ch04lev1sec6" rel="nofollow noreferrer">prefer interfaces to abstract classes</a>. In that item Josh Bloch provides an example of a skeletal implementation of the <code>Map.Entry<K,V></code> interface... | [
{
"answer_id": 237194,
"author": "Alan",
"author_id": 17205,
"author_profile": "https://Stackoverflow.com/users/17205",
"pm_score": 0,
"selected": false,
"text": "<p>One reason that <code>AbstractMapEntry#getKey</code> and <code>getValue</code> are abstract (i.e. unimplemented) is that <... | 2008/10/25 | [
"https://Stackoverflow.com/questions/237140",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8217/"
] | I was re-reading Effective Java (2nd edition) item 18, [prefer interfaces to abstract classes](http://my.safaribooksonline.com/9780137150021/ch04lev1sec6). In that item Josh Bloch provides an example of a skeletal implementation of the `Map.Entry<K,V>` interface:
```
// Skeletal Implementation
public abstract class Ab... | 1. I would say it helps emphasize what the concrete class is intended to deal with, instead of just leaving it up to the compiler to tell you (or you having to compare both to see what is missing). Kind of self-documenting code. But it certainly isn't necessary, it is more of a style thing, as far as I can see.
2. Ther... |
237,145 | <p>I have a radio button on my Windows Form. How can I determine if the CheckChanged event occurred due to a user clicking or selecting the radio button vs programatically setting the event with </p>
<pre><code>this.radioButtonAdd.Checked = true;
</code></pre>
<p>I would like some code to take a different action depe... | [
{
"answer_id": 237153,
"author": "Andru Luvisi",
"author_id": 5922,
"author_profile": "https://Stackoverflow.com/users/5922",
"pm_score": 2,
"selected": false,
"text": "<p>If there is a built-in method, then I am not aware of it.</p>\n\n<p>One way to handle it is by setting a global flag... | 2008/10/25 | [
"https://Stackoverflow.com/questions/237145",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1496/"
] | I have a radio button on my Windows Form. How can I determine if the CheckChanged event occurred due to a user clicking or selecting the radio button vs programatically setting the event with
```
this.radioButtonAdd.Checked = true;
```
I would like some code to take a different action depending on if the user click... | I think I found a pretty good answer.
All Windows Forms controls have a property called "Tag". its value can be any object.
So if I want to ingore any programatic changes I can do the following:
```
radioButton.Tag = "ignore"
radioButton.Checked = true
```
then in the event handler:
```
private void radioButton_C... |
237,159 | <p>I normally use the following idiom to check if a String can be converted to an integer.</p>
<pre><code>public boolean isInteger( String input ) {
try {
Integer.parseInt( input );
return true;
}
catch( Exception e ) {
return false;
}
}
</code></pre>
<p>Is it just me, or does ... | [
{
"answer_id": 237161,
"author": "Kristian",
"author_id": 11429,
"author_profile": "https://Stackoverflow.com/users/11429",
"pm_score": 2,
"selected": false,
"text": "<p>How about:</p>\n\n<pre><code>return Pattern.matches(\"-?\\\\d+\", input);\n</code></pre>\n"
},
{
"answer_id": ... | 2008/10/25 | [
"https://Stackoverflow.com/questions/237159",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1288/"
] | I normally use the following idiom to check if a String can be converted to an integer.
```
public boolean isInteger( String input ) {
try {
Integer.parseInt( input );
return true;
}
catch( Exception e ) {
return false;
}
}
```
Is it just me, or does this seem a bit hackish? W... | If you are not concerned with potential overflow problems this function will perform about 20-30 times faster than using `Integer.parseInt()`.
```
public static boolean isInteger(String str) {
if (str == null) {
return false;
}
int length = str.length();
if (length == 0) {
return false;... |
237,201 | <p>I'm trying to perform a simple LINQ query on the Columns property of a DataTable:</p>
<pre><code>from c in myDataTable.Columns.AsQueryable()
select c.ColumnName
</code></pre>
<p>However, what I get is this:</p>
<blockquote>
<p>Could not find an implementation of the query pattern for source type 'System.Lin... | [
{
"answer_id": 237224,
"author": "Dave Markle",
"author_id": 24995,
"author_profile": "https://Stackoverflow.com/users/24995",
"pm_score": 8,
"selected": true,
"text": "<p>How about:</p>\n\n<pre><code>var x = from c in dt.Columns.Cast<DataColumn>()\n select c.ColumnName;\n</... | 2008/10/25 | [
"https://Stackoverflow.com/questions/237201",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31516/"
] | I'm trying to perform a simple LINQ query on the Columns property of a DataTable:
```
from c in myDataTable.Columns.AsQueryable()
select c.ColumnName
```
However, what I get is this:
>
> Could not find an implementation of the query pattern for source type 'System.Linq.IQueryable'. 'Select' not found. Consider... | How about:
```
var x = from c in dt.Columns.Cast<DataColumn>()
select c.ColumnName;
``` |
237,220 | <p>I'm looking for an algorithm that places tick marks on an axis, given a range to display, a width to display it in, and a function to measure a string width for a tick mark.</p>
<p>For example, given that I need to display between 1e-6 and 5e-6 and a width to display in pixels, the algorithm would determine that I ... | [
{
"answer_id": 239058,
"author": "mindvirus",
"author_id": 31455,
"author_profile": "https://Stackoverflow.com/users/31455",
"pm_score": 2,
"selected": false,
"text": "<p>Take the longest of the segments about zero (or the whole graph, if zero is not in the range) - for example, if you h... | 2008/10/25 | [
"https://Stackoverflow.com/questions/237220",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1490/"
] | I'm looking for an algorithm that places tick marks on an axis, given a range to display, a width to display it in, and a function to measure a string width for a tick mark.
For example, given that I need to display between 1e-6 and 5e-6 and a width to display in pixels, the algorithm would determine that I should put... | As I didn't like any of the solutions I've found so far, I implemented my own. It's in C# but it can be easily translated into any other language.
It basically chooses from a list of possible steps the smallest one that displays all values, **without leaving any value exactly in the edge**, lets you easily select whic... |
237,222 | <p>This code:</p>
<pre><code>public class WidgetPlatform
{
public Widget LeftmostWidget { get; set; }
public Widget RightmostWidget { get; set; }
public String GetWidgetNames()
{
return LeftmostWidget.Name + " " + RightmostWidget.Name;
}
}
</code></pre>
<p>doesn't contain any repetition w... | [
{
"answer_id": 237248,
"author": "Eoin Campbell",
"author_id": 30155,
"author_profile": "https://Stackoverflow.com/users/30155",
"pm_score": 3,
"selected": false,
"text": "<p>Whats wrong with Constructors ?</p>\n\n<pre><code>public class WidgetPlatform\n{\n public Widget LeftmostWidge... | 2008/10/25 | [
"https://Stackoverflow.com/questions/237222",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30761/"
] | This code:
```
public class WidgetPlatform
{
public Widget LeftmostWidget { get; set; }
public Widget RightmostWidget { get; set; }
public String GetWidgetNames()
{
return LeftmostWidget.Name + " " + RightmostWidget.Name;
}
}
```
doesn't contain any repetition worth worrying about, but i... | Whats wrong with Constructors ?
```
public class WidgetPlatform
{
public Widget LeftmostWidget { get; set; }
public Widget RightmostWidget { get; set; }
public WidgetPlatform()
{
this.LeftMostWidget = new Widget();
this.RightMostWidget = new Widget();
}
public WidgetPlatform(W... |
237,235 | <p>In my django application I am using a template to construct email body, one of the parameters is url, note there are two parametes separated by ampersand in the url.</p>
<pre><code>t = loader.get_template("sometemplate")
c = Context({
'foo': 'bar',
'url': 'http://127.0.0.1/test?a=1&b=2',
})
print t.render... | [
{
"answer_id": 237243,
"author": "Jonny Buchanan",
"author_id": 6760,
"author_profile": "https://Stackoverflow.com/users/6760",
"pm_score": 6,
"selected": true,
"text": "<p>To turn it off for a single variable, use <code>mark_safe</code>:</p>\n\n<pre><code>from django.utils.safestring im... | 2008/10/26 | [
"https://Stackoverflow.com/questions/237235",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26592/"
] | In my django application I am using a template to construct email body, one of the parameters is url, note there are two parametes separated by ampersand in the url.
```
t = loader.get_template("sometemplate")
c = Context({
'foo': 'bar',
'url': 'http://127.0.0.1/test?a=1&b=2',
})
print t.render(c)
```
After re... | To turn it off for a single variable, use `mark_safe`:
```
from django.utils.safestring import mark_safe
t = loader.get_template("sometemplate")
c = Context({
'foo': 'bar',
'url': mark_safe('http://127.0.0.1/test?a=1&b=2'),
})
print t.render(c)
```
Alternatively, to totally turn autoescaping off from your Pyt... |
237,254 | <p>The <a href="http://docs.jquery.com/Events/bind#typedatafn" rel="noreferrer">jQuery documentation</a> says the library has built-in support for the following events: blur, focus, load, resize, scroll, unload, click, dblclick, mousedown, mouseup, mousemove, mouseover, mouseout, mouseenter, mouseleave, change, select,... | [
{
"answer_id": 237303,
"author": "dansays",
"author_id": 1923,
"author_profile": "https://Stackoverflow.com/users/1923",
"pm_score": 4,
"selected": false,
"text": "<p>Various clipboard events are available in Javascript, though support is spotty. QuicksMode.org has a <a href=\"http://www... | 2008/10/26 | [
"https://Stackoverflow.com/questions/237254",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11577/"
] | The [jQuery documentation](http://docs.jquery.com/Events/bind#typedatafn) says the library has built-in support for the following events: blur, focus, load, resize, scroll, unload, click, dblclick, mousedown, mouseup, mousemove, mouseover, mouseout, mouseenter, mouseleave, change, select, submit, keydown, keypress, key... | You can add and remove events of any kind by using the [`.on()`](http://api.jquery.com/on/) and [`off()`](http://api.jquery.com/off) methods
Try this, for instance
```
jQuery(document).on('paste', function(e){ alert('pasting!') });
```
jQuery is actually quite indifferent to whether the event type you assign is sup... |
237,268 | <p>Doing like so:</p>
<p><code>Shell ("C:\Program Files\Internet Explorer\iexplore.exe -embedding http://www.websiteurl.com")</code></p>
<p>Doesn't work how I need it as I essentially need it to be able to redirect and prompt a user to download a file. Any ideas?</p>
| [
{
"answer_id": 237271,
"author": "Dave Markle",
"author_id": 24995,
"author_profile": "https://Stackoverflow.com/users/24995",
"pm_score": 1,
"selected": false,
"text": "<p>There are a couple of things you could do. </p>\n\n<ul>\n<li><p>Use an external program like <code>wget</code> to ... | 2008/10/26 | [
"https://Stackoverflow.com/questions/237268",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Doing like so:
`Shell ("C:\Program Files\Internet Explorer\iexplore.exe -embedding http://www.websiteurl.com")`
Doesn't work how I need it as I essentially need it to be able to redirect and prompt a user to download a file. Any ideas? | Internet Explorer exposes a COM accessible interface you can use. If you really have to. I'd recommend against it - its comparatively slow, error-prone, cumbersome and resource-intensive.
What solves your problem more elegantly is using `WinHTTPRequest`. In your Project, reference "Microsoft WinHTTP Services, version... |
237,269 | <p>I am thinking of running this custom targets to find out more about my project build status
- jalopy
- jdepend
- cvs tagdiff report
- custom task for NoUnit
- generate UML diagram. ESS-Model</p>
<p>What are your views?</p>
| [
{
"answer_id": 240701,
"author": "jim",
"author_id": 27628,
"author_profile": "https://Stackoverflow.com/users/27628",
"pm_score": 1,
"selected": false,
"text": "<p>I think that it's a great idea and use it myself. That way I'll never forget to run it.</p>\n\n<p>I also keep the reports ... | 2008/10/26 | [
"https://Stackoverflow.com/questions/237269",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am thinking of running this custom targets to find out more about my project build status
- jalopy
- jdepend
- cvs tagdiff report
- custom task for NoUnit
- generate UML diagram. ESS-Model
What are your views? | I think that it's a great idea and use it myself. That way I'll never forget to run it.
I also keep the reports for a decent amount of time and eventually create a spreadsheet of "progress".
In your main ant task - call another task to do "whatever"
and
JDepend.xml ...
```
<target name="statsAll">
<!-- master f... |
237,275 | <p>I'm constructing a method to take in an ArrayList(presumably full of objects) and then list all the fields(and their values) for each object in the ArrayList.</p>
<p>Currently my code is as follows:</p>
<pre><code>public static void ListArrayListMembers(ArrayList list)
{
foreach (Object obj in list)
... | [
{
"answer_id": 237278,
"author": "Dave Markle",
"author_id": 24995,
"author_profile": "https://Stackoverflow.com/users/24995",
"pm_score": 6,
"selected": true,
"text": "<pre><code>foreach (Object obj in list) {\n Type type = obj.GetType();\n\n foreach (var f in type.GetFields().Whe... | 2008/10/26 | [
"https://Stackoverflow.com/questions/237275",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2153/"
] | I'm constructing a method to take in an ArrayList(presumably full of objects) and then list all the fields(and their values) for each object in the ArrayList.
Currently my code is as follows:
```
public static void ListArrayListMembers(ArrayList list)
{
foreach (Object obj in list)
{
T... | ```
foreach (Object obj in list) {
Type type = obj.GetType();
foreach (var f in type.GetFields().Where(f => f.IsPublic)) {
Console.WriteLine(
String.Format("Name: {0} Value: {1}", f.Name, f.GetValue(obj));
}
}
```
Note that this code requires .NET 3.5 to wor... |
237,282 | <p>At work, we have one of those nasty communal urinals. There is no flush handle. Rather, it has a motion sensor that sometimes triggers when you stand in front of it and sometimes doesn't. When it triggers, a tank fills, which when full is used to flush the urinal.</p>
<p>In my many trips before this nastraption, I ... | [
{
"answer_id": 237286,
"author": "Peter Wone",
"author_id": 1715673,
"author_profile": "https://Stackoverflow.com/users/1715673",
"pm_score": 1,
"selected": false,
"text": "<p>I would trigger on sense but use a slow fill in the hope that by the time it actually flushes, someone else has ... | 2008/10/26 | [
"https://Stackoverflow.com/questions/237282",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11577/"
] | At work, we have one of those nasty communal urinals. There is no flush handle. Rather, it has a motion sensor that sometimes triggers when you stand in front of it and sometimes doesn't. When it triggers, a tank fills, which when full is used to flush the urinal.
In my many trips before this nastraption, I have ponde... | ```
OnUserEnter()
{
if (UsersDetected == 0)
{
FirstDetectionTime = Now();
}
UsersDetected++;
CurrentlyInUse = true;
}
OnUserExit()
{
CurrentlyInUse = false;
if (UsersDetected >= MaxUsersBetweenFlushes ||
Now() - FirstDetectionTime > StinkInterval)
{
Flush();
}
}
OnTimer()
{... |
237,289 | <p>I'm looking for a way to configure the color used for line numbering (as in: <code>:set nu</code>) in Vim. The default on most platforms seems to be yellow (which is also used for some highlighted tokens). I would <em>like</em> to color the line numbers a dim gray; somewhere in the vicinity of <code>#555</code>. ... | [
{
"answer_id": 237293,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 8,
"selected": true,
"text": "<p>Try:</p>\n\n<pre><code>help hl-LineNr\n</code></pre>\n\n<p>I found this through:</p>\n\n<pre><code>help 'number'\n</cod... | 2008/10/26 | [
"https://Stackoverflow.com/questions/237289",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9815/"
] | I'm looking for a way to configure the color used for line numbering (as in: `:set nu`) in Vim. The default on most platforms seems to be yellow (which is also used for some highlighted tokens). I would *like* to color the line numbers a dim gray; somewhere in the vicinity of `#555`. I'm not picky though, any subdued c... | Try:
```
help hl-LineNr
```
I found this through:
```
help 'number'
```
which is the way to get help on the `'number'` option, instead of the `:number` command.
To actually change the displayed colour:
```
:highlight LineNr ctermfg=grey
```
This would change the foreground colour for LineNr on a character ter... |
237,310 | <p>I'm currently displaying a UIViewController like this:</p>
<pre><code>[[self navigationController] presentModalViewController:modalViewController animated:YES];
</code></pre>
<p>and hiding it like this:</p>
<pre><code>[self.navigationController dismissModalViewControllerAnimated:YES];
</code></pre>
<p>The animat... | [
{
"answer_id": 237355,
"author": "Ben Gottlieb",
"author_id": 6694,
"author_profile": "https://Stackoverflow.com/users/6694",
"pm_score": 7,
"selected": true,
"text": "<p>Marcus Zarra posted a great solution to this on the SDK mailing list:</p>\n\n<pre><code>UIViewController *controller ... | 2008/10/26 | [
"https://Stackoverflow.com/questions/237310",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22471/"
] | I'm currently displaying a UIViewController like this:
```
[[self navigationController] presentModalViewController:modalViewController animated:YES];
```
and hiding it like this:
```
[self.navigationController dismissModalViewControllerAnimated:YES];
```
The animation is "slide up from the bottom"... then slide b... | Marcus Zarra posted a great solution to this on the SDK mailing list:
```
UIViewController *controller = [[[MyViewController alloc] init] autorelease];
UIViewAnimationTransition trans = UIViewAnimationTransitionCurlUp;
[UIView beginAnimations: nil context: nil];
[UIView setAnimationTransition: trans forView: [self win... |
237,322 | <p>You'd think it would be easy, but keep reading. I can change many of the styles associated with a resizable JQuery Dialog, but not the handles. The code below isolates the problem. Why does the handle disappear entirely? There must be some logic I'm interfering with in ui.resizable.js, but I don't see it.</p>
... | [
{
"answer_id": 237393,
"author": "scunliffe",
"author_id": 6144,
"author_profile": "https://Stackoverflow.com/users/6144",
"pm_score": 0,
"selected": false,
"text": "<p>I believe the background of the resizeable borders are set as images, which in CSS stacking is on top of backgrounds. ... | 2008/10/26 | [
"https://Stackoverflow.com/questions/237322",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9328/"
] | You'd think it would be easy, but keep reading. I can change many of the styles associated with a resizable JQuery Dialog, but not the handles. The code below isolates the problem. Why does the handle disappear entirely? There must be some logic I'm interfering with in ui.resizable.js, but I don't see it.
```
<script ... | I was able to get it to work. I couldn't find the line of code my css was in conflict with, but when I added positioning and size related css, things worked. There must be some logic that says, "use the default css unless the programmer has supplied his own". So, while I thought I was appending info, I was somehow swap... |
237,326 | <p>In particular, would it be possible to have <strong>code similar to this c++ code executed at compile time in c#</strong>?</p>
<pre><code>template <int N>
struct Factorial
{
enum { value = N * Factorial<N - 1>::value };
};
template <>
struct Factorial<0>
{
enum { value = 1 };
};
... | [
{
"answer_id": 237329,
"author": "Brian",
"author_id": 19299,
"author_profile": "https://Stackoverflow.com/users/19299",
"pm_score": 3,
"selected": false,
"text": "<p>No, metaprogramming is not possible in C#.</p>\n"
},
{
"answer_id": 237513,
"author": "JaredPar",
"author... | 2008/10/26 | [
"https://Stackoverflow.com/questions/237326",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3153/"
] | In particular, would it be possible to have **code similar to this c++ code executed at compile time in c#**?
```
template <int N>
struct Factorial
{
enum { value = N * Factorial<N - 1>::value };
};
template <>
struct Factorial<0>
{
enum { value = 1 };
};
// Factorial<4>::value == 24
// Factorial<0>::value... | No, metaprogramming of this complexity is not supported directly by the C# language. However, like [@littlegeek](https://stackoverflow.com/questions/237326/is-metaprogramming-possible-in-c#237644) said, the [Text Template Transformation Toolkit](http://www.hanselman.com/blog/T4TextTemplateTransformationToolkitCodeGener... |
237,327 | <p>The UPSERT operation either updates or inserts a row in a table, depending if the table already has a row that matches the data:</p>
<pre><code>if table t has a row exists that has key X:
update t set mystuff... where mykey=X
else
insert into t mystuff...
</code></pre>
<p>Since Oracle doesn't have a specif... | [
{
"answer_id": 237328,
"author": "Mark Harrison",
"author_id": 116,
"author_profile": "https://Stackoverflow.com/users/116",
"pm_score": 8,
"selected": false,
"text": "<p>The <a href=\"http://docs.oracle.com/cd/B28359_01/server.111/b28286/statements_9016.htm#SQLRF01606\" rel=\"noreferrer... | 2008/10/26 | [
"https://Stackoverflow.com/questions/237327",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/116/"
] | The UPSERT operation either updates or inserts a row in a table, depending if the table already has a row that matches the data:
```
if table t has a row exists that has key X:
update t set mystuff... where mykey=X
else
insert into t mystuff...
```
Since Oracle doesn't have a specific UPSERT statement, what'... | An alternative to MERGE (the "old fashioned way"):
```
begin
insert into t (mykey, mystuff)
values ('X', 123);
exception
when dup_val_on_index then
update t
set mystuff = 123
where mykey = 'X';
end;
``` |
237,350 | <p>I am trying to call a setTimeout from within a setInterval callback:</p>
<pre><code>function callback()
{
//assign myVar
var myVar = document.getElementById("givenID");
//...
//now wait 2 secs then call some code that uses myVAr
setTimeout("myVar.innerHTML = 'TEST'", 2000);
}
setInterval("callback()... | [
{
"answer_id": 237375,
"author": "Michael Gundlach",
"author_id": 4105,
"author_profile": "https://Stackoverflow.com/users/4105",
"pm_score": 1,
"selected": false,
"text": "<p>Run it in Firefox and check Tools | Error Console. if setTimeout fails it may tell you why there.</p>\n\n<p>Als... | 2008/10/26 | [
"https://Stackoverflow.com/questions/237350",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1311500/"
] | I am trying to call a setTimeout from within a setInterval callback:
```
function callback()
{
//assign myVar
var myVar = document.getElementById("givenID");
//...
//now wait 2 secs then call some code that uses myVAr
setTimeout("myVar.innerHTML = 'TEST'", 2000);
}
setInterval("callback();", 10000);
`... | This is a perfect candidate for closures:
```
setInterval(
function ()
{
var myVar = document.getElementById("givenID");
setTimeout(
function()
{
// myVar is available because the inner closure
// gets the outer closures scope
myVar.i... |
237,367 | <p>When I connect to a MySQL database using PDO, the way I need to connect is:</p>
<pre><code>$pdoConnection = new PDO("mysql:host=hostname;dbname=databasename",user,password);
</code></pre>
<p>But, for PostgreSQL, the DSN is more standard (IMO):</p>
<pre><code>$pdoConnection = new PDO("pgsql:host=hostname;dbname=da... | [
{
"answer_id": 1314757,
"author": "Wez Furlong",
"author_id": 149111,
"author_profile": "https://Stackoverflow.com/users/149111",
"pm_score": 7,
"selected": false,
"text": "<p>As the person that implemented both, I can tell you that the reason is that by passing the string through as-is ... | 2008/10/26 | [
"https://Stackoverflow.com/questions/237367",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23089/"
] | When I connect to a MySQL database using PDO, the way I need to connect is:
```
$pdoConnection = new PDO("mysql:host=hostname;dbname=databasename",user,password);
```
But, for PostgreSQL, the DSN is more standard (IMO):
```
$pdoConnection = new PDO("pgsql:host=hostname;dbname=databasename;user=username;password=the... | As the person that implemented both, I can tell you that the reason is that by passing the string through as-is to postgres (and ODBC) the PDO driver code for those databases does not need to be updated as the underlying library adds new features.
Since MySQL does not have its own connection string parsing code, we in... |
237,370 | <p>In some code I've inherited, I see frequent use of <code>size_t</code> with the <code>std</code> namespace qualifier. For example:</p>
<pre><code>std::size_t n = sizeof( long );
</code></pre>
<p>It compiles and runs fine, of course. But it seems like bad practice to me (perhaps carried over from C?).</p>
<p>Isn... | [
{
"answer_id": 237374,
"author": "Brian R. Bondy",
"author_id": 3153,
"author_profile": "https://Stackoverflow.com/users/3153",
"pm_score": 2,
"selected": false,
"text": "<p>Sometimes other libraries will define their own size_t. For example boost. std::size_t specifies that you defini... | 2008/10/26 | [
"https://Stackoverflow.com/questions/237370",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10559/"
] | In some code I've inherited, I see frequent use of `size_t` with the `std` namespace qualifier. For example:
```
std::size_t n = sizeof( long );
```
It compiles and runs fine, of course. But it seems like bad practice to me (perhaps carried over from C?).
Isn't it true that `size_t` is built into C++ and therefore ... | There seems to be confusion among the stackoverflow crowd concerning this
`::size_t` is defined in the backward compatibility header `stddef.h` . It's been part of `ANSI/ISO C` and `ISO C++` since their very beginning. Every C++ implementation has to ship with `stddef.h` (compatibility) and `cstddef` where only the la... |
237,377 | <p>Is there a better way to do this?</p>
<pre><code>string[] s = {"zero", "one", "two", "three", "four", "five"};
var x =
s
.Select((a,i) => new {Value = a, Index = i})
.Where(b => b.Value.StartsWith("t"))
.Select(c => c.Index);
</code></pre>
<p>i.e. I'm looking for a more efficient or more elegant way to ... | [
{
"answer_id": 237379,
"author": "Mark S. Rasmussen",
"author_id": 12469,
"author_profile": "https://Stackoverflow.com/users/12469",
"pm_score": 3,
"selected": false,
"text": "<p>Seems fine to me. You might save a couple characters by changing the select to:</p>\n\n<pre><code>.Select((Va... | 2008/10/26 | [
"https://Stackoverflow.com/questions/237377",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1463/"
] | Is there a better way to do this?
```
string[] s = {"zero", "one", "two", "three", "four", "five"};
var x =
s
.Select((a,i) => new {Value = a, Index = i})
.Where(b => b.Value.StartsWith("t"))
.Select(c => c.Index);
```
i.e. I'm looking for a more efficient or more elegant way to get the positions of the items matc... | You could easily add your own extension method:
```
public static IEnumerable<int> IndexesWhere<T>(this IEnumerable<T> source, Func<T, bool> predicate)
{
int index=0;
foreach (T element in source)
{
if (predicate(element))
{
yield return index;
}
index++;
}
}... |
237,383 | <p>Is possible to insert a line break where the cursor is in Vim without entering into insert mode? Here's an example (<code>[x]</code> means cursor is on <code>x</code>):</p>
<pre><code>if (some_condition) {[ ]return; }
</code></pre>
<p>Occasionally, I might want to enter some more code. So I'd press <kbd>i</kbd> to... | [
{
"answer_id": 237384,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 8,
"selected": true,
"text": "<p>For the example you've given, you could use <kbd>r</kbd><kbd>Enter</kbd> to replace a single character (the space) with... | 2008/10/26 | [
"https://Stackoverflow.com/questions/237383",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1103052/"
] | Is possible to insert a line break where the cursor is in Vim without entering into insert mode? Here's an example (`[x]` means cursor is on `x`):
```
if (some_condition) {[ ]return; }
```
Occasionally, I might want to enter some more code. So I'd press `i` to get into insert mode, press `Enter` to insert the line b... | For the example you've given, you could use `r``Enter` to replace a single character (the space) with Enter. Then, `f``space``.` to move forward to the next space and repeat the last command.
Depending on your autoindent settings, the above may or may not indent the return statement properly. If not, then use `s``Ente... |
237,405 | <p>Can someone explain this in a practical way? Sample represents usage for one, low-traffic Rails site using Nginx and 3 Mongrel clusters. I ask because I am aiming to learn about page caching, wondering if these figures have significant meaning to that process. Thank you. Great site!</p>
<pre><code>me@vps:~$ fre... | [
{
"answer_id": 237528,
"author": "Cameron Booth",
"author_id": 14873,
"author_profile": "https://Stackoverflow.com/users/14873",
"pm_score": 1,
"selected": false,
"text": "<p>by my reading of this, you have used almost all your memory, have 6 M free, and are going into about 10% of your ... | 2008/10/26 | [
"https://Stackoverflow.com/questions/237405",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31347/"
] | Can someone explain this in a practical way? Sample represents usage for one, low-traffic Rails site using Nginx and 3 Mongrel clusters. I ask because I am aiming to learn about page caching, wondering if these figures have significant meaning to that process. Thank you. Great site!
```
me@vps:~$ free -m
... | Physical memory is all used up. Why? Because it's there, the system should be using it.
You'll note also that the system is using 113M of swap space. Bad? Good? It depends.
See also that there's 103M of cached disk; this means that the system has decided that it's better to cache 103M of disk and swap out these 113M... |
237,408 | <p>I have a local Git repository I've been developing under for a few days: it has eighteen commits so far. Tonight, I created a private Github repository I was hoping to push it to; however, when I did so, it only ended up pushing eight of the eighteen commits to Github. I deleted the Github repo and retried, with the... | [
{
"answer_id": 237409,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 1,
"selected": false,
"text": "<p>I suppose the first thing I would do would be to run <code>git fsck</code> on your local repository to make sure that ... | 2008/10/26 | [
"https://Stackoverflow.com/questions/237408",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23498/"
] | I have a local Git repository I've been developing under for a few days: it has eighteen commits so far. Tonight, I created a private Github repository I was hoping to push it to; however, when I did so, it only ended up pushing eight of the eighteen commits to Github. I deleted the Github repo and retried, with the sa... | I took a look at the repository in question and here's what was going on:
* At some point, rpj had performed `git checkout [commit id]`. This pointed HEAD at a loose commit rather than a recognized branch. I believe this is the "dangling HEAD" problem that CesarB is referring to.
* Not realizing this problem, he went ... |
237,415 | <p>I'm attempting to use LINQ to insert a record into a child table and I'm
receiving a "Specified cast is not valid" error that has something to do w/
the keys involved. The stack trace is:</p>
<blockquote>
<p>Message: Specified cast is not valid.</p>
<p>Type: System.InvalidCastException
Source: System.Da... | [
{
"answer_id": 237426,
"author": "FlySwat",
"author_id": 1965,
"author_profile": "https://Stackoverflow.com/users/1965",
"pm_score": 0,
"selected": false,
"text": "<pre><code>ResponseCode rc = new ResponseCode()\n {\n SurveyQuestionName = \"Q11\",\n Code = 3,\n Descr... | 2008/10/26 | [
"https://Stackoverflow.com/questions/237415",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm attempting to use LINQ to insert a record into a child table and I'm
receiving a "Specified cast is not valid" error that has something to do w/
the keys involved. The stack trace is:
>
> Message: Specified cast is not valid.
>
>
> Type: System.InvalidCastException
> Source: System.Data.Linq TargetSite:
> B... | Post up the schema of the parent table.
if you look here, some other people have had your problem.
<http://forums.microsoft.com/msdn/ShowPost.aspx?PostID=3493504&SiteID=1>
It appears that Linq2SQL has trouble mapping some foreign keys to some primary keys. One guy had a resolution, but I think you are already mapping... |
237,423 | <p>I have written this generator code but it returns 'can't convert nil into String' when I call m.directory inside the manifest. Anyone know what had happened?</p>
<pre><code>class AuthGenerator < Rails::Generator::NamedBase
attr_reader :user_class_name
def initialize(runtime_args, runtime_options={})
@use... | [
{
"answer_id": 238252,
"author": "Ian Terrell",
"author_id": 9269,
"author_profile": "https://Stackoverflow.com/users/9269",
"pm_score": 1,
"selected": false,
"text": "<p>Where is it choking? Please post the full error. You can see the source of the <code>directory</code> method <a hre... | 2008/10/26 | [
"https://Stackoverflow.com/questions/237423",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16371/"
] | I have written this generator code but it returns 'can't convert nil into String' when I call m.directory inside the manifest. Anyone know what had happened?
```
class AuthGenerator < Rails::Generator::NamedBase
attr_reader :user_class_name
def initialize(runtime_args, runtime_options={})
@user_class_name="Use... | Where is it choking? Please post the full error. You can see the source of the `directory` method [here](http://api.rubyonrails.org/classes/Rails/Generator/Commands/Create.html#M001866).
Plus, you probably just want
```
m.directory File.join('app/models')
```
Having an app/models/user directory for your generated ... |
237,432 | <p>I have a base class with a property which (the get method) I want to overwrite in the subclass. My first thought was something like:</p>
<pre><code>class Foo(object):
def _get_age(self):
return 11
age = property(_get_age)
class Bar(Foo):
def _get_age(self):
return 44
</code></pre>
<p... | [
{
"answer_id": 237445,
"author": "Federico A. Ramponi",
"author_id": 18770,
"author_profile": "https://Stackoverflow.com/users/18770",
"pm_score": 2,
"selected": false,
"text": "<p>I agree with your solution, which seems an on-the-fly template method. \n<a href=\"http://www.artima.com/fo... | 2008/10/26 | [
"https://Stackoverflow.com/questions/237432",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/720/"
] | I have a base class with a property which (the get method) I want to overwrite in the subclass. My first thought was something like:
```
class Foo(object):
def _get_age(self):
return 11
age = property(_get_age)
class Bar(Foo):
def _get_age(self):
return 44
```
This does not work (subcla... | I simply prefer to repeat the `property()` as well as you will repeat the `@classmethod` decorator when overriding a class method.
While this seems very verbose, at least for Python standards, you may notice:
1) for read only properties, `property` can be used as a decorator:
```
class Foo(object):
@property
... |
237,440 | <p>I have a problem whereby I want to display a view differently (a different master page), depending on where it came from, but don't know where to start...</p>
<p>I have several routes which catch various different types of urls that contain different structures.</p>
<p>In the code snippet below, I have a product r... | [
{
"answer_id": 239021,
"author": "jonnii",
"author_id": 4590,
"author_profile": "https://Stackoverflow.com/users/4590",
"pm_score": 2,
"selected": true,
"text": "<p>In your partners controller why don't you set a cookie that indicates which partner you want to show, and then redirects to... | 2008/10/26 | [
"https://Stackoverflow.com/questions/237440",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31532/"
] | I have a problem whereby I want to display a view differently (a different master page), depending on where it came from, but don't know where to start...
I have several routes which catch various different types of urls that contain different structures.
In the code snippet below, I have a product route, and then I ... | In your partners controller why don't you set a cookie that indicates which partner you want to show, and then redirects to the wildcard section of the route. That way you can show the same partner layout for all subsequent page views.
I don't know if this is what you're looking for, but it might be an option. |
237,464 | <p>Many languages have a facility to check to see if an Object is of a certain type (including parent subclasses), implemented with 'is' and used like this:</p>
<pre><code>if(obj is MyType)
</code></pre>
<p>Or slightly more tediously you can in other languages check by using the 'as' keyword to do a soft typecast and... | [
{
"answer_id": 237467,
"author": "nickf",
"author_id": 9021,
"author_profile": "https://Stackoverflow.com/users/9021",
"pm_score": 5,
"selected": true,
"text": "<pre><code>if (objectReference instanceof type){\n //Your code goes here\n}\n</code></pre>\n\n<p>More info <a href=\"http://... | 2008/10/26 | [
"https://Stackoverflow.com/questions/237464",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Many languages have a facility to check to see if an Object is of a certain type (including parent subclasses), implemented with 'is' and used like this:
```
if(obj is MyType)
```
Or slightly more tediously you can in other languages check by using the 'as' keyword to do a soft typecast and seeing if the result null... | ```
if (objectReference instanceof type){
//Your code goes here
}
```
More info [here](http://www.java2s.com/Tutorial/Java/0060__Operators/TheinstanceofKeyword.htm). |
237,539 | <p>My current setup binds the <code>Text</code> property of my <code>TextBox</code> to a certain <code>Uri</code> object. I'd love to use WPF's inbuilt validation to detect invalid URIs, and proceed from there. But this doesn't seem to be working?</p>
<p>I would imagine that it would throw an exception if I entered, e... | [
{
"answer_id": 247937,
"author": "decasteljau",
"author_id": 12082,
"author_profile": "https://Stackoverflow.com/users/12082",
"pm_score": 1,
"selected": false,
"text": "<p>You can try create our own ValidationRule (inherit from ValidationRule). In this class, override Validate(...) and... | 2008/10/26 | [
"https://Stackoverflow.com/questions/237539",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3191/"
] | My current setup binds the `Text` property of my `TextBox` to a certain `Uri` object. I'd love to use WPF's inbuilt validation to detect invalid URIs, and proceed from there. But this doesn't seem to be working?
I would imagine that it would throw an exception if I entered, e.g., "aaaa" as a URI. Thus, triggering my c... | You can try create our own ValidationRule (inherit from ValidationRule). In this class, override Validate(...) and try create an URI object and catch the exceptions. In the catch, just set the e.Message to exception message.
(I am not too sure what is your binding source. Is it a URI object or a string?) |
237,542 | <p>I'm using GCC; __FILE__ returns the current source file's entire path and name: <code>/path/to/file.cpp</code>. Is there a way to get just the file's name <code>file.cpp</code> (without its path) at compile time? Is it possible to do this in a portable way? Can template meta programming be applied to strings?</p>
<... | [
{
"answer_id": 237556,
"author": "Head Geek",
"author_id": 12193,
"author_profile": "https://Stackoverflow.com/users/12193",
"pm_score": 2,
"selected": false,
"text": "<p>You might be able to do it with template metaprogramming, but there's no built-in way to do it.</p>\n\n<p>EDIT: Hm, c... | 2008/10/26 | [
"https://Stackoverflow.com/questions/237542",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3175/"
] | I'm using GCC; \_\_FILE\_\_ returns the current source file's entire path and name: `/path/to/file.cpp`. Is there a way to get just the file's name `file.cpp` (without its path) at compile time? Is it possible to do this in a portable way? Can template meta programming be applied to strings?
I am using this in an erro... | If you're using a `make` program, you should be able to munge the filename beforehand and pass it as a macro to `gcc` to be used in your program. For example, in your `makefile`, change the line:
```
file.o: file.c
gcc -c -o file.o src/file.c
```
to:
```
file.o: src/file.c
gcc "-DMYFILE=\"`basename $<`\"" -... |
237,553 | <p>Google chrome doesn't behave the same as other browsers when encountering this nugget:</p>
<pre><code><?php
while (true) {
echo "<script type='text/javascript'>\n";
echo "alert('hello');\n";
echo "</script>";
flush();
sleep(5);
}
?>
</code></pre>
<p>It seems that it's waiting... | [
{
"answer_id": 237616,
"author": "Peter Burns",
"author_id": 101,
"author_profile": "https://Stackoverflow.com/users/101",
"pm_score": 1,
"selected": false,
"text": "<p>I wish I had access to Chrome at the moment to test out some ideas. Have you tried adding some HTML after <code></sc... | 2008/10/26 | [
"https://Stackoverflow.com/questions/237553",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2443/"
] | Google chrome doesn't behave the same as other browsers when encountering this nugget:
```
<?php
while (true) {
echo "<script type='text/javascript'>\n";
echo "alert('hello');\n";
echo "</script>";
flush();
sleep(5);
}
?>
```
It seems that it's waiting for the connection to terminate before doin... | Some browsers require a certain number of bytes to be downloaded before rendering available data. I remember the last time I tried to do what you're doing I ended up having to dump something like 300 spaces to be sure the browser would bother with it. |
237,561 | <p>Edit: This code is fine. I found a logic bug somewhere that doesn't exist in my pseudo code. I was blaming it on my lack of Java experience.</p>
<p>In the <strong>pseudo code</strong> below, I'm trying to parse the XML shown. A silly example maybe but my code was too large/specific for anyone to get any real val... | [
{
"answer_id": 237596,
"author": "Andru Luvisi",
"author_id": 5922,
"author_profile": "https://Stackoverflow.com/users/5922",
"pm_score": 2,
"selected": true,
"text": "<p>The code looks fine to me. I say set breakpoints at the start of each function and watch it in the debugger or add s... | 2008/10/26 | [
"https://Stackoverflow.com/questions/237561",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22917/"
] | Edit: This code is fine. I found a logic bug somewhere that doesn't exist in my pseudo code. I was blaming it on my lack of Java experience.
In the **pseudo code** below, I'm trying to parse the XML shown. A silly example maybe but my code was too large/specific for anyone to get any real value out of seeing it and le... | The code looks fine to me. I say set breakpoints at the start of each function and watch it in the debugger or add some print statements. My gut tells me that either `characters()` is not being called or `setColor()` and `setAge()` don't work correctly, but that's just a guess. |
237,621 | <p>I'm new with Objective-C, so there probably is a simple solution to this.</p>
<p>I want a number to increment, but each iteration to be show on a label. (for example, it shows 1, 2, 3, 4, 5... displayed apart by an amount of time).</p>
<p>I tried:</p>
<pre><code>#import "testNums.h"
@implementation testNums
- (I... | [
{
"answer_id": 237629,
"author": "jtbandes",
"author_id": 23649,
"author_profile": "https://Stackoverflow.com/users/23649",
"pm_score": 2,
"selected": false,
"text": "<p>Yes, because that is what you told it to do. The graphics will not actually update until the main run loop is free to ... | 2008/10/26 | [
"https://Stackoverflow.com/questions/237621",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31549/"
] | I'm new with Objective-C, so there probably is a simple solution to this.
I want a number to increment, but each iteration to be show on a label. (for example, it shows 1, 2, 3, 4, 5... displayed apart by an amount of time).
I tried:
```
#import "testNums.h"
@implementation testNums
- (IBAction)start:(id)sender {
... | To allow the run loop to run between messages, use an `NSTimer` or delayed perform. Here's the latter:
```
- (IBAction) start:(id)sender {
[self performSelector:@selector(updateTextFieldWithNumber:) withObject:[NSNumber numberWithInt:0] afterDelay:1.0];
}
- (void) updateTextFieldWithNumber:(NSNumber *)num {
i... |
237,631 | <p>I have two PHP files that I need to link. How can I link the files together using PHP? The effect I want is to have the user click a button, some information is proccessed on the page, and then the result is displayed in a different page, depending on the button the user clicked.Thanks</p>
| [
{
"answer_id": 237637,
"author": "jtbandes",
"author_id": 23649,
"author_profile": "https://Stackoverflow.com/users/23649",
"pm_score": 3,
"selected": false,
"text": "<p>It sounds like you might want an HTML form:</p>\n\n<pre><code><form method=\"post\" action=\"other_file.php\">\n... | 2008/10/26 | [
"https://Stackoverflow.com/questions/237631",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24391/"
] | I have two PHP files that I need to link. How can I link the files together using PHP? The effect I want is to have the user click a button, some information is proccessed on the page, and then the result is displayed in a different page, depending on the button the user clicked.Thanks | I've interpreted your question differently to the others.
It sounds to me like you want to create a page with two buttons on it and execute one of your two existing PHP files, depending on which button was pressed.
If that's right, then here's a simple skeleton to achieve that. In this example, page\_1.php and page\_... |
237,675 | <p>Here's what I am trying to do:</p>
<p>Select text from a webpage I pulled up using my web browser control.After clicking a button while this text is still selected I would like a message box to pop-up displaying the text that was highlighted by the user. How do I get this functionality to work in my wpf application... | [
{
"answer_id": 237710,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 2,
"selected": false,
"text": "<p>Well, for starters it would be a lot simpler to use <a href=\"http://msdn.microsoft.com/en-us/library/system.windo... | 2008/10/26 | [
"https://Stackoverflow.com/questions/237675",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Here's what I am trying to do:
Select text from a webpage I pulled up using my web browser control.After clicking a button while this text is still selected I would like a message box to pop-up displaying the text that was highlighted by the user. How do I get this functionality to work in my wpf application?
I think... | Well, for starters it would be a lot simpler to use [`WebBrowser`](http://msdn.microsoft.com/en-us/library/system.windows.forms.webbrowser.aspx) than mshtml (note that you can still host `WebBrowser` in WPF) - this will certainly let you do simple things a lot easier:
```
webBook.Document.Title = "foo";
```
However,... |
237,691 | <p>I been waiting for sometime now to bring my Asp.net Preview 4 project up to snuff, totally skipping Preview 5 just because I knew I would have some issues.</p>
<p>Anyhow, here is the question and dilemma.</p>
<p>I have a few areas on the site which I have an ajax update type panel that renders content from a view ... | [
{
"answer_id": 238855,
"author": "Eilon",
"author_id": 31668,
"author_profile": "https://Stackoverflow.com/users/31668",
"pm_score": 0,
"selected": false,
"text": "<p>I believe that calling someFormElement.onsubmit() simply invokes the event handlers registered for that event. To properl... | 2008/10/26 | [
"https://Stackoverflow.com/questions/237691",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22093/"
] | I been waiting for sometime now to bring my Asp.net Preview 4 project up to snuff, totally skipping Preview 5 just because I knew I would have some issues.
Anyhow, here is the question and dilemma.
I have a few areas on the site which I have an ajax update type panel that renders content from a view using this techni... | Having some irritating problems relating to this issue. Hope someone here can help me out.
```
var event = new Object();
function refreshInformation(){
document.forms['MyForm'].onsubmit({preventDefault: function(){} });
}
```
This is my current code, it works fine for updating the the form. Problem is the "var even... |
237,703 | <p>In cmd.exe, I can execute the command "copy c:\hello.txt c:\hello2.txt" and it worked fine.
But in my C program, I ran this piece of code and got the following error:</p>
<pre><code>#include <iostream>
using namespace std;
int main()
{
system("copy c:\hello.txt c:\hello2.txt");
system("pause");
... | [
{
"answer_id": 237706,
"author": "paxdiablo",
"author_id": 14860,
"author_profile": "https://Stackoverflow.com/users/14860",
"pm_score": 5,
"selected": true,
"text": "<p>Inside C strings (and quite a few other languages that use the same escaping rules), <code>\\</code> should be <code>\... | 2008/10/26 | [
"https://Stackoverflow.com/questions/237703",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | In cmd.exe, I can execute the command "copy c:\hello.txt c:\hello2.txt" and it worked fine.
But in my C program, I ran this piece of code and got the following error:
```
#include <iostream>
using namespace std;
int main()
{
system("copy c:\hello.txt c:\hello2.txt");
system("pause");
return 0;
}
```
O... | Inside C strings (and quite a few other languages that use the same escaping rules), `\` should be `\\` since it's the escape character. It allows you to enter, in normal text, non-printable characters such as:
* the tab character `\t`.
* the carriage-return character `\r`.
* the newline character `\n`.
* others which... |
237,716 | <p>std::next_permutation (and std::prev_permutation) permute all values in the range <code>[first, last)</code> given for a total of n! permutations (assuming that all elements are unique).</p>
<p>is it possible to write a function like this:</p>
<pre><code>template<class Iter>
bool next_permutation(Iter first,... | [
{
"answer_id": 237743,
"author": "Jacob Krall",
"author_id": 3140,
"author_profile": "https://Stackoverflow.com/users/3140",
"pm_score": 1,
"selected": false,
"text": "<p>Source code for a Java combination generator is at <strong><a href=\"http://www.merriampark.com/comb.htm\" rel=\"nofo... | 2008/10/26 | [
"https://Stackoverflow.com/questions/237716",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5963/"
] | std::next\_permutation (and std::prev\_permutation) permute all values in the range `[first, last)` given for a total of n! permutations (assuming that all elements are unique).
is it possible to write a function like this:
```
template<class Iter>
bool next_permutation(Iter first, Iter last, Iter choice_last);
```
... | To iterate over nPk permutations, I've used the `for_each_permutation()` algorithm presented in [this old CUJ article](http://www.ddj.com/cpp/184401912) before. It uses a nice algorithm from Knuth which rotates the elements in situ, leaving them in the original order at the end. Therefore, it meets your no external mem... |
237,733 | <p>I've been a bad programmer because I am doing a copy and paste. An example is that everytime i connect to a database and retrieve a recordset, I will copy the previous code and edit, copy the code that sets the datagridview and edit. I am aware of the phrase code reuse, but I have not actually used it. How can i uti... | [
{
"answer_id": 237738,
"author": "Paige Ruten",
"author_id": 813,
"author_profile": "https://Stackoverflow.com/users/813",
"pm_score": 2,
"selected": false,
"text": "<p>Put the code into a routine and call the routine whenever you want that code to be executed.</p>\n"
},
{
"answe... | 2008/10/26 | [
"https://Stackoverflow.com/questions/237733",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26087/"
] | I've been a bad programmer because I am doing a copy and paste. An example is that everytime i connect to a database and retrieve a recordset, I will copy the previous code and edit, copy the code that sets the datagridview and edit. I am aware of the phrase code reuse, but I have not actually used it. How can i utiliz... | Depending on the size of the project can change the answer.
For a **smaller** project I would recommend setting up a DatabaseHelper class that does all your DB access. It would just be a wrapper around opening/closing connections and execution of the DB code. Then at a higher level you can just write the DBCommands th... |
237,745 | <p>Does any one know of some kind of Comparator factory in Java, with a </p>
<pre><code>public Comparator getComparatorForClass(Class clazz) {}
</code></pre>
<p>It would return Comparators for stuff like String, Double, Integer but would have a</p>
<pre><code>public void addComparatorForClass(Class clazz, Comparator... | [
{
"answer_id": 237752,
"author": "ngn",
"author_id": 23109,
"author_profile": "https://Stackoverflow.com/users/23109",
"pm_score": 4,
"selected": false,
"text": "<p>Instead of:</p>\n\n<pre><code>factory.getComparatorForClass(x.getClass()).compare(x, y)\n</code></pre>\n\n<p>you could simp... | 2008/10/26 | [
"https://Stackoverflow.com/questions/237745",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Does any one know of some kind of Comparator factory in Java, with a
```
public Comparator getComparatorForClass(Class clazz) {}
```
It would return Comparators for stuff like String, Double, Integer but would have a
```
public void addComparatorForClass(Class clazz, Comparator comparator) {}
```
For arbitrary t... | Instead of:
```
factory.getComparatorForClass(x.getClass()).compare(x, y)
```
you could simply implement `Comparable` and write:
```
x.compareTo(y)
```
String, the primitive wrappers, and standard collections already implement `Comparable`. |
237,757 | <p>I have a php script that is executing an executable that writes to a serial port.
However, everytime it runs <pre>system("c:\Untitled1.exe")</pre>
it just opens up a cmd window and freezes.</p>
<p>Anybody know how to fix this? Or if there is an easier way to get PHP to write to the serial port directly? (I've alrea... | [
{
"answer_id": 237797,
"author": "lacop",
"author_id": 894,
"author_profile": "https://Stackoverflow.com/users/894",
"pm_score": 0,
"selected": false,
"text": "<p>AFAIK <code>system()</code> call blocks the execution until the program finishes. Maybe using <code>popen()</code>, <code>fre... | 2008/10/26 | [
"https://Stackoverflow.com/questions/237757",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a php script that is executing an executable that writes to a serial port.
However, everytime it runs
```
system("c:\Untitled1.exe")
```
it just opens up a cmd window and freezes.
Anybody know how to fix this? Or if there is an easier way to get PHP to write to the serial port directly? (I've already tried th... | What happens when you run "Untitled1.exe" - does it work outside of the php environment?
I would advise persevering with the loaded extension method - it's a much better way of implementing this.
If both methods aren't working then maybe the problem is somewhere else - related to permissions or configuration. |
237,763 | <p>I have a CSV file that has a column that contains strings that look like integers. That is they should be dealt with as strings, but since they are numbers they appear to be imported as integers (dropping off the leading zeroes).</p>
<p>Example Data:</p>
<ul>
<li>0000000000079</li>
<li>0000999000012</li>
<li>0001... | [
{
"answer_id": 237771,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 0,
"selected": false,
"text": "<p>Have you tried using this <a href=\"http://www.codeproject.com/KB/database/CsvReader.aspx\" rel=\"nofollow norefer... | 2008/10/26 | [
"https://Stackoverflow.com/questions/237763",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25719/"
] | I have a CSV file that has a column that contains strings that look like integers. That is they should be dealt with as strings, but since they are numbers they appear to be imported as integers (dropping off the leading zeroes).
Example Data:
* 0000000000079
* 0000999000012
* 0001002000005
* 0004100000007
The probl... | Try to use GetString() method in the reader when you need to read the column as string:
```
string myStringValue = reader.GetString(0);
``` |
237,804 | <p><a href="http://en.wikipedia.org/wiki/C%2B%2B11" rel="noreferrer">C++11</a> introduces <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2378.pdf" rel="noreferrer">user-defined literals</a> which will allow the introduction of new literal syntax based on existing literals (<code>int</code>, <code>hex... | [
{
"answer_id": 237812,
"author": "fizzer",
"author_id": 18167,
"author_profile": "https://Stackoverflow.com/users/18167",
"pm_score": 2,
"selected": false,
"text": "<p>I have never needed or wanted this feature (but this could be the <a href=\"http://www.paulgraham.com/avg.html\" rel=\"n... | 2008/10/26 | [
"https://Stackoverflow.com/questions/237804",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3848/"
] | [C++11](http://en.wikipedia.org/wiki/C%2B%2B11) introduces [user-defined literals](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2378.pdf) which will allow the introduction of new literal syntax based on existing literals (`int`, `hex`, `string`, `float`) so that any type will be able to have a literal prese... | Here's a case where there is an advantage to using user-defined literals instead of a constructor call:
```
#include <bitset>
#include <iostream>
template<char... Bits>
struct checkbits
{
static const bool valid = false;
};
template<char High, char... Bits>
struct checkbits<High, Bits...>
{
static ... |
237,807 | <p>.NET's <code>SslStream</code> class does not send the <code>close_notify</code> alert before closing the connection.</p>
<p>How can I send the <code>close_notify</code> alert manually?</p>
| [
{
"answer_id": 238144,
"author": "Shachar",
"author_id": 13897,
"author_profile": "https://Stackoverflow.com/users/13897",
"pm_score": 2,
"selected": false,
"text": "<p>It's a bug in .NET's usage of the underlying security API. Note another question by me about being unable to select a s... | 2008/10/26 | [
"https://Stackoverflow.com/questions/237807",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | .NET's `SslStream` class does not send the `close_notify` alert before closing the connection.
How can I send the `close_notify` alert manually? | Thanks for this question. It pointed me into the right direction, that there is a bug in .Net, which I do not very often think about.
I bumped into this problem during writing of my implementation of FTPS server and Filezilla (or GnuTLS probably) client was complaining "GnuTLS error -110 in gnutls\_record\_recv: The T... |
237,816 | <p>Say each row in a table has data pertaining to one particular user. The user has a password to access the system.</p>
<p>How do I encrypt a column of data using InnoDB so that no one other than the user who's data it is can read the data ? I was thinking of something like using one of the MySQL encryption functions... | [
{
"answer_id": 237839,
"author": "Damir Zekić",
"author_id": 401510,
"author_profile": "https://Stackoverflow.com/users/401510",
"pm_score": 3,
"selected": false,
"text": "<p>I don't know if there is much sense in encrypting data with user's password hash, <em>especially</em> if you keep... | 2008/10/26 | [
"https://Stackoverflow.com/questions/237816",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31574/"
] | Say each row in a table has data pertaining to one particular user. The user has a password to access the system.
How do I encrypt a column of data using InnoDB so that no one other than the user who's data it is can read the data ? I was thinking of something like using one of the MySQL encryption functions (say AES)... | I don't know if there is much sense in encrypting data with user's password hash, *especially* if you keep hash itself in the database. In that case anyone who can access the encrypted data can also access the password hash and decrypt the data.
Another approach would be to encrypt the data with the application-specif... |
237,832 | <p>I'm seeing a very strange issue with a .NET webservice being consumed by Flex.</p>
<p>I have a very simple class with nothing other than properties with [XmlAttribute('xxx')] attributes.</p>
<pre><code>public class OrderAddress
{
public OrderAddress() {}
[XmlAttribute("firstName")]
public string First... | [
{
"answer_id": 237868,
"author": "Ray Lu",
"author_id": 11413,
"author_profile": "https://Stackoverflow.com/users/11413",
"pm_score": 0,
"selected": false,
"text": "<p>Elements centric XML is more interoperable format in XML serialization. \nThis is the reason that the new WCF DataContra... | 2008/10/26 | [
"https://Stackoverflow.com/questions/237832",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16940/"
] | I'm seeing a very strange issue with a .NET webservice being consumed by Flex.
I have a very simple class with nothing other than properties with [XmlAttribute('xxx')] attributes.
```
public class OrderAddress
{
public OrderAddress() {}
[XmlAttribute("firstName")]
public string FirstName { get; set; }
... | After three days' struggling, finally I figured out this XML attribute was the cause of my problem. Slightly different from yours, my class has an array of objects in addition to the XML attribute. Flex was able to generate proxies, and even got attribute correctly (it was treated as a property), but it failed to deser... |