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 |
|---|---|---|---|---|---|---|
302,835 | <p>can someone give a scons config file which allows the following structure</p>
<pre><code>toplevel/
/src - .cc files
/include .h files
</code></pre>
<p>at top level I want the o and final exe.</p>
| [
{
"answer_id": 302964,
"author": "Andrew Beyer",
"author_id": 38691,
"author_profile": "https://Stackoverflow.com/users/38691",
"pm_score": 3,
"selected": false,
"text": "<p>This question: <a href=\"https://stackoverflow.com/questions/279860/how-do-i-get-projects-to-place-their-build-out... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302835",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37370/"
] | can someone give a scons config file which allows the following structure
```
toplevel/
/src - .cc files
/include .h files
```
at top level I want the o and final exe. | ```
env=Environment(CPPPATH='/usr/include/glib-2.0/:/usr/lib/glib-2.0/include:include',
CPPDEFINES=[],
LIBS=['glib-2.0'])
if ARGUMENTS.get('debug', 0):
env.Append(CCFLAGS = ' -g')
env.Program('template', Glob('src/*.cc'))
```
Worked a treat. Thanks. |
302,837 | <p>Parsing a text file in vb.net and need to locate the latitude and longitude in these two sections of text. The patter is 6 digits space 7 digits (364800 0953600). The samples are from two different map files and have slightly differing formats.</p>
<pre><code>I 2H02 364800 0953600 ' SEC72 ... | [
{
"answer_id": 302856,
"author": "Dillie-O",
"author_id": 71,
"author_profile": "https://Stackoverflow.com/users/71",
"pm_score": 0,
"selected": false,
"text": "<p>Do a simple group capture. It appears your RegEx formula will be simple enough to handle both scenarios (be a little lose on... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302837",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38349/"
] | Parsing a text file in vb.net and need to locate the latitude and longitude in these two sections of text. The patter is 6 digits space 7 digits (364800 0953600). The samples are from two different map files and have slightly differing formats.
```
I 2H02 364800 0953600 ' SEC72 ... | ```
Dim matches As MatchCollection
Dim regex As New Regex("\d{6} \d{7}")
matches = regex.Matches(your_text_string)
``` |
302,839 | <p>I have a user control that I load into a <code>MainWindow</code> at runtime. I cannot get a handle on the containing window from the <code>UserControl</code>. </p>
<p>I have tried <code>this.Parent</code>, but it's always null. Does anyone know how to get a handle to the containing window from a user control in WPF... | [
{
"answer_id": 302953,
"author": "Jobi Joy",
"author_id": 8091,
"author_profile": "https://Stackoverflow.com/users/8091",
"pm_score": 4,
"selected": false,
"text": "<p>Use VisualTreeHelper.GetParent or the recursive function below to find the parent window.</p>\n<pre class=\"lang-cs pret... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302839",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39038/"
] | I have a user control that I load into a `MainWindow` at runtime. I cannot get a handle on the containing window from the `UserControl`.
I have tried `this.Parent`, but it's always null. Does anyone know how to get a handle to the containing window from a user control in WPF?
Here is how the control is loaded:
```
... | Try using the following:
```
Window parentWindow = Window.GetWindow(userControlReference);
```
The `GetWindow` method will walk the VisualTree for you and locate the window that is hosting your control.
You should run this code after the control has loaded (and not in the Window constructor) to prevent the `GetWind... |
302,897 | <p>I am making a mp3 id3tag editor, and a regex is not matching.
Could anyone help me please?
my code:</p>
<pre><code>arquivo = "[coletanea] album [CD #] [faixa] [artista] musica.mp3"
r = New Regex("^\[(?<1>[^\]]+?)\]\s*(?<2>[\w\s]+)\s*\[CD\s*(?<3>\d+)\]\s*\[(?<4>\d+)\]\s*\[(?<5>[^\]]+)\... | [
{
"answer_id": 302929,
"author": "Vinko Vrsalovic",
"author_id": 5190,
"author_profile": "https://Stackoverflow.com/users/5190",
"pm_score": 2,
"selected": false,
"text": "<p>That's because your string will never match the regexp you are using.</p>\n\n<p>The regexp expects a number inste... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302897",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am making a mp3 id3tag editor, and a regex is not matching.
Could anyone help me please?
my code:
```
arquivo = "[coletanea] album [CD #] [faixa] [artista] musica.mp3"
r = New Regex("^\[(?<1>[^\]]+?)\]\s*(?<2>[\w\s]+)\s*\[CD\s*(?<3>\d+)\]\s*\[(?<4>\d+)\]\s*\[(?<5>[^\]]+)\]\s*(?<6>.+)", RegexOptions.Compiled)
m = r.... | That's because your string will never match the regexp you are using.
The regexp expects a number instead of # and a number instead of 'faixa'
Try this, for example:
```
"[coletanea] album [CD 20] [89] [artista] musica.mp3"
```
If you wish to allow for any character instead of just numbers, replace \d for . in the... |
302,912 | <p>I'm aware there is an AssociationChanged event, however, this event fires after the association is made. There is no AssociationChanging event. So, if I want to throw an exception for some validation reason, how do I do this and get back to my original value? </p>
<p>Also, I would like to default values for my en... | [
{
"answer_id": 1301480,
"author": "ADB",
"author_id": 3610,
"author_profile": "https://Stackoverflow.com/users/3610",
"pm_score": 0,
"selected": false,
"text": "<p>Concerning your first question, I would simply implement the changes to the associations as business logic. For example, if ... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302912",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm aware there is an AssociationChanged event, however, this event fires after the association is made. There is no AssociationChanging event. So, if I want to throw an exception for some validation reason, how do I do this and get back to my original value?
Also, I would like to default values for my entity based o... | This is in reply to a comment I left. Hopefully this answers your question, Shimmy. Just comment, and I will shorten it or remove it if it doesn't answer your question.
You will need both INotifyPropertyChanging and INotifyPropertyChanged interfaces to be implemented on your class (unless it is something like an entit... |
302,943 | <p>I am looking to do the following (see pseudo code); I want to select 4 rows for each gd.id (7, 11 or 9). I've incorrectly use limit because that only brings up 4 rows in total. Anyone have an idea on how to change this query to accomplish my goal? </p>
<pre><code>SELECT gd.gid, gd.aid, li.ads, li.til
FROM gd
JOI... | [
{
"answer_id": 303384,
"author": "Bill Karwin",
"author_id": 20860,
"author_profile": "https://Stackoverflow.com/users/20860",
"pm_score": 3,
"selected": false,
"text": "<p>Okay I'm posting this second answer now that I understand the relationship between your tables.</p>\n\n<pre><code>C... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302943",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am looking to do the following (see pseudo code); I want to select 4 rows for each gd.id (7, 11 or 9). I've incorrectly use limit because that only brings up 4 rows in total. Anyone have an idea on how to change this query to accomplish my goal?
```
SELECT gd.gid, gd.aid, li.ads, li.til
FROM gd
JOIN li ON li.a_id =... | Okay I'm posting this second answer now that I understand the relationship between your tables.
```
CREATE TABLE gd (
aid INT AUTO_INCREMENT PRIMARY KEY,
gid INT
);
INSERT INTO gd (gid) VALUES
(7), (7), (7), -- fewer than four rows
(9), (9), (9), (9), -- exactly four rows
(11), (11)... |
302,955 | <p>I am currently trying to make a <code>navigation-menu</code> where an <code>active-class</code> is applied to the anchors whose <code>href</code> attributes that match the current URL, so I can style that anchor in a way that makes it stand out from the rest of the menu.</p>
<p>This is my mark-up:</p>
<pre><code>&... | [
{
"answer_id": 302971,
"author": "jrutter",
"author_id": 28454,
"author_profile": "https://Stackoverflow.com/users/28454",
"pm_score": 1,
"selected": false,
"text": "<p>Give this code a shot, its something I put together for the company that I work for.</p>\n\n<pre><code>// highlight tab... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302955",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24218/"
] | I am currently trying to make a `navigation-menu` where an `active-class` is applied to the anchors whose `href` attributes that match the current URL, so I can style that anchor in a way that makes it stand out from the rest of the menu.
This is my mark-up:
```
<div id="sidebar">
<h2>Navigation menu</h2>
<h2 cl... | This should do want you want: **mark the matching link, and failing that, mark your default one.**
```
function markActiveLink() {
//Look through all the links in the sidebar
$("div#sidebar a").filter(function() {
//Take the current URL and split it into chunks at each slash
var currentURL = windo... |
302,956 | <p>I have two classes that are associated with a one-to-one mapping:</p>
<pre><code><class name="Employee" table="Employees">
...
<one-to-one name="Address" class="AddressInfo">
...
</class>
</code></pre>
<p>I would like to use a criteria expression to get only Employees where the the associat... | [
{
"answer_id": 320863,
"author": "ChrisAnnODell",
"author_id": 1758,
"author_profile": "https://Stackoverflow.com/users/1758",
"pm_score": 4,
"selected": true,
"text": "<p>Have you tried creating an alias for the Address property and checking if the ID/primary key of the Address is not n... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302956",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10475/"
] | I have two classes that are associated with a one-to-one mapping:
```
<class name="Employee" table="Employees">
...
<one-to-one name="Address" class="AddressInfo">
...
</class>
```
I would like to use a criteria expression to get only Employees where the the associated Address class is not null, something like... | Have you tried creating an alias for the Address property and checking if the ID/primary key of the Address is not null?
Something like:
```
IList employeesWithAddresses = sess.CreateCriteria(typeof(Employee))
.CreateCriteria("Address", "address").Add( Expression.IsNotNull("Id") )
.List();
``` |
302,958 | <p>I have a crosstab query that uses a dynamic date function to result in the column headers and therefore the field names. Ex: ForecastPeriod:DateAdd("m",[Period],[StartDate])
This means that every time I run the crosstab query, I could end up with different field names.
I need to take the results of this crosstab and... | [
{
"answer_id": 304973,
"author": "Fionnuala",
"author_id": 2548,
"author_profile": "https://Stackoverflow.com/users/2548",
"pm_score": 1,
"selected": false,
"text": "<p>It is possible to use your own headings for the crosstab, for example:</p>\n\n<pre><code>ColHead:\"Month\" & DateDi... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302958",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a crosstab query that uses a dynamic date function to result in the column headers and therefore the field names. Ex: ForecastPeriod:DateAdd("m",[Period],[StartDate])
This means that every time I run the crosstab query, I could end up with different field names.
I need to take the results of this crosstab and co... | VBA to create a table mirroring the columns of a query:
```
Dim db As DAO.Database
Dim tdf As DAO.TableDef
Dim qdf As DAO.QueryDef
Dim fld As DAO.Field
Dim SourceField As DAO.Field
Set db = CurrentDb
'Create a new tabledef
Set tdf = New DAO.TableDef
'Reference existing, saved querydef
Set qdf = db.QueryDefs("Query1... |
302,968 | <p>Is there an equivalent to Apache's VirtualHost for IIS? We want to be able to run multiple websites from one IP and address them with different DNS names.</p>
<p>i.e. I have </p>
<pre><code>www.dom1.com
www.dom2.com
www.dom3.com
</code></pre>
<p>that all point to <code>123.123.10.1</code>. Apache would just be ... | [
{
"answer_id": 302992,
"author": "ahockley",
"author_id": 8209,
"author_profile": "https://Stackoverflow.com/users/8209",
"pm_score": 4,
"selected": true,
"text": "<p>You want to use <a href=\"http://www.visualwin.com/host-header/\" rel=\"noreferrer\">Host Headers in IIS</a> - that link ... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302968",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6486/"
] | Is there an equivalent to Apache's VirtualHost for IIS? We want to be able to run multiple websites from one IP and address them with different DNS names.
i.e. I have
```
www.dom1.com
www.dom2.com
www.dom3.com
```
that all point to `123.123.10.1`. Apache would just be running on port 80 and just use virtualhost to... | You want to use [Host Headers in IIS](http://www.visualwin.com/host-header/) - that link will lead to a nice how-to page. |
302,969 | <p>What kind of scenarios can XSL processing instructions be used or applied? When is it good or bad to use them?</p>
<p>Clean slate here, I don't have a good handle on this particular element.</p>
<p>Example from w3schools:</p>
<p><xsl:processing-instruction name="process-name">
<!-- Content:template --&... | [
{
"answer_id": 303114,
"author": "Edward Z. Yang",
"author_id": 23845,
"author_profile": "https://Stackoverflow.com/users/23845",
"pm_score": 0,
"selected": false,
"text": "<p>Processing instructions let you insert things like <?php ?> or <?xml ?> into the output code. I myself hav... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302969",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26625/"
] | What kind of scenarios can XSL processing instructions be used or applied? When is it good or bad to use them?
Clean slate here, I don't have a good handle on this particular element.
Example from w3schools:
<xsl:processing-instruction name="process-name">
<!-- Content:template -->
</xsl:processing-instruction> | It's very simple: you'd use `<xsl:processing-instruction>` if you needed to output a processing instruction in your output XML. If you have no need for PI's in your output, then you don't need the processing-instruction element.
As to why you might need a PI in your output, that depends entirely on what your output w... |
302,993 | <p>I've seen a couple of web pages say that <code>a = b || 'blah'</code> should assign <code>'blah'</code> to <code>a</code> if <code>b</code> is <code>undefined</code> or <code>null</code>. But if I type that into Firebug or use it in code, it complains that <code>b</code> is not defined, at the list on FF3/win. Any... | [
{
"answer_id": 303007,
"author": "Orion Edwards",
"author_id": 234,
"author_profile": "https://Stackoverflow.com/users/234",
"pm_score": 3,
"selected": false,
"text": "<p>If b existed, and was false, null, etc, then it works in the way that you would expect. All you'll need to do is on t... | 2008/11/19 | [
"https://Stackoverflow.com/questions/302993",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16777/"
] | I've seen a couple of web pages say that `a = b || 'blah'` should assign `'blah'` to `a` if `b` is `undefined` or `null`. But if I type that into Firebug or use it in code, it complains that `b` is not defined, at the list on FF3/win. Any hints?
Edit: I'm looking for the case where `b` may not exist at all. For exampl... | I think you're looking for this:
```
var a = typeof b == 'undefined' ? 'blah' : b;
``` |
303,004 | <p>Looking at this LINQ demo:</p>
<p><a href="http://www.microsoft.com/emea/msdn/spotlight/sessionh.aspx?videoid=716" rel="nofollow noreferrer">LINQ Framework Overview</a></p>
<p>When going in debug mode, the output have colors in it. I'm using the same ObjectDumper class and I only have the black/white console windo... | [
{
"answer_id": 303652,
"author": "Rockcoder",
"author_id": 5290,
"author_profile": "https://Stackoverflow.com/users/5290",
"pm_score": 0,
"selected": false,
"text": "<p>You can set colors of the console text and/or background in the properties if that's what you're looking for... \nJust ... | 2008/11/19 | [
"https://Stackoverflow.com/questions/303004",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17766/"
] | Looking at this LINQ demo:
[LINQ Framework Overview](http://www.microsoft.com/emea/msdn/spotlight/sessionh.aspx?videoid=716)
When going in debug mode, the output have colors in it. I'm using the same ObjectDumper class and I only have the black/white console window.
How can I have the same results in the console win... | What about :
```
Console.ForegroundColor = ConsoleColor.Yellow;
Console.BackgroundColor = ConsoleColor.DarkRed;
Console.WriteLine("Test");
``` |
303,006 | <p>I've just started looking into M-V-VM for a WPF application. Everything makes sense so far besides this particular issue...</p>
<p>I have a ViewModel I'll call Search. This ViewModel binds to a datagrid and lists results of items. Now, I have a command that needs to bring up <strong>another view</strong>, the it... | [
{
"answer_id": 303274,
"author": "Preet Sangha",
"author_id": 30225,
"author_profile": "https://Stackoverflow.com/users/30225",
"pm_score": 0,
"selected": false,
"text": "<p>We use a variant on this pattern, Here we have controllers that represent the VM, so the datacontext of the View i... | 2008/11/19 | [
"https://Stackoverflow.com/questions/303006",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29676/"
] | I've just started looking into M-V-VM for a WPF application. Everything makes sense so far besides this particular issue...
I have a ViewModel I'll call Search. This ViewModel binds to a datagrid and lists results of items. Now, I have a command that needs to bring up **another view**, the item's details.
Putting the... | Views should never be instantiated anywhere "below" the UI layer. VMs exist below that realm, therefore this is not the place to put that logic (as you've already realized).
There will almost always be some UI level event that will indicate the need to create the view. In your example, it might be a row (double) click... |
303,013 | <p>VS.net creates a template when you create a WCF project.</p>
<p>It adds a class to the iService1.cs file:</p>
<pre><code>// Use a data contract as illustrated in the sample below to
// add composite types to service operations.
[DataContract]
public class CompositeType
{
bool boolValue = true;
string strin... | [
{
"answer_id": 303023,
"author": "Guy Starbuck",
"author_id": 2194,
"author_profile": "https://Stackoverflow.com/users/2194",
"pm_score": 7,
"selected": true,
"text": "<p>The DataContract is just a formal definition of a type that can be understood on both sides of the service boundary.<... | 2008/11/19 | [
"https://Stackoverflow.com/questions/303013",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39677/"
] | VS.net creates a template when you create a WCF project.
It adds a class to the iService1.cs file:
```
// Use a data contract as illustrated in the sample below to
// add composite types to service operations.
[DataContract]
public class CompositeType
{
bool boolValue = true;
string stringValue = "Hello ";
... | The DataContract is just a formal definition of a type that can be understood on both sides of the service boundary.
If you return, as in your example, a "MyUserCollection" object, the consumers of your service will need to reference the innards of your service/system, which is a violation of the SOA tenet of explicit... |
303,026 | <p>I have a simple html page with a div. I am using jQuery to load the contents of an aspx app into the "content" div. Code looks like this:</p>
<pre><code><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<s... | [
{
"answer_id": 303049,
"author": "calebt",
"author_id": 7525,
"author_profile": "https://Stackoverflow.com/users/7525",
"pm_score": 1,
"selected": false,
"text": "<p>Seems like a common problem: <a href=\"http://andreineculau.wordpress.com/2006/09/29/ajax-ondemand-javascript-or-dynamic-s... | 2008/11/19 | [
"https://Stackoverflow.com/questions/303026",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5234/"
] | I have a simple html page with a div. I am using jQuery to load the contents of an aspx app into the "content" div. Code looks like this:
```
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script type="text/javascript" src="htt... | Is the code that is not executing rendered out as script blocks, I understand the libraries loaded but any script blocks or inline javascript will not execute when loaded dynamically like that. You have to come up witha solution that will evaluate the script blocks returned for any of it to be valid. I'll see if I can ... |
303,045 | <p>I often access shared network folders in Powershell to grab files etc. But if the share requires a username/password, Powershell does not prompt me for these, unlike Windows Explorer. If I connect to the folder first in Windows Explorer, Powershell will then allow me to connect. </p>
<p>How can I authenticate mysel... | [
{
"answer_id": 303229,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 6,
"selected": false,
"text": "<p>This is not a PowerShell-specific answer, but you could authenticate against the share using \"NET USE\" first:</p>\n\n<pre... | 2008/11/19 | [
"https://Stackoverflow.com/questions/303045",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5769/"
] | I often access shared network folders in Powershell to grab files etc. But if the share requires a username/password, Powershell does not prompt me for these, unlike Windows Explorer. If I connect to the folder first in Windows Explorer, Powershell will then allow me to connect.
How can I authenticate myself in Power... | At first glance one really wants to use [`New-PSDrive`](http://technet.microsoft.com/en-us/library/ee176915.aspx) supplying it credentials.
```
> New-PSDrive -Name P -PSProvider FileSystem -Root \\server\share -Credential domain\user
```
### Fails!
```
New-PSDrive : Cannot retrieve the dynamic parameters for the c... |
303,053 | <p>I am working on a Perl script to read CSV file and do some calculations.
CSV file has only two columns, something like below.</p>
<pre><code>One Two
1.00 44.000
3.00 55.000
</code></pre>
<p>Now this CSV file is very big ,can be from 10 MB to 2GB.</p>
<p>Currently I am taking CSV file of size 700 MB. I tried to o... | [
{
"answer_id": 303061,
"author": "S.Lott",
"author_id": 10661,
"author_profile": "https://Stackoverflow.com/users/10661",
"pm_score": 5,
"selected": true,
"text": "<p>In *nix, you can use the tail command.</p>\n\n<pre><code>tail -1000 yourfile | perl ...\n</code></pre>\n\n<p>That will wr... | 2008/11/19 | [
"https://Stackoverflow.com/questions/303053",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33411/"
] | I am working on a Perl script to read CSV file and do some calculations.
CSV file has only two columns, something like below.
```
One Two
1.00 44.000
3.00 55.000
```
Now this CSV file is very big ,can be from 10 MB to 2GB.
Currently I am taking CSV file of size 700 MB. I tried to open this file in notepad, excel bu... | In \*nix, you can use the tail command.
```
tail -1000 yourfile | perl ...
```
That will write only the last 1000 lines to the perl program.
On Windows, there are [gnuwin32](http://sourceforge.net/project/showfiles.php?group_id=163416) and [unxutils](http://sourceforge.net/projects/unxutils) packages both have `tai... |
303,054 | <p>According to the adobe flex docs: <a href="http://livedocs.adobe.com/flex/3/html/help.html?content=controls_15.html" rel="nofollow noreferrer">http://livedocs.adobe.com/flex/3/html/help.html?content=controls_15.html</a></p>
<p>Using an image multiple times</p>
<p>You can use the same image multiple times in your a... | [
{
"answer_id": 303279,
"author": "Ryan Guill",
"author_id": 7186,
"author_profile": "https://Stackoverflow.com/users/7186",
"pm_score": 2,
"selected": false,
"text": "<p>The best way to load an image a single time and then reuse that image multiple times in a flex application is to embed... | 2008/11/19 | [
"https://Stackoverflow.com/questions/303054",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39075/"
] | According to the adobe flex docs: <http://livedocs.adobe.com/flex/3/html/help.html?content=controls_15.html>
Using an image multiple times
You can use the same image multiple times in your application by using the normal image import syntax each time. Flex only loads the image once, and then references the loaded ima... | The best way to load an image a single time and then reuse that image multiple times in a flex application is to embed the image and tie it to a class representation, then just reference that class from then on.
Example:
```
[Embed(source="myImage.jpg")]
[Bindable]
public var myImageClass:Class;
```
HTH |
303,066 | <p>I recently migrated an ASP site from my dev machine to a live server. All the pages except my FAQ page works just fine, but my FAQ brings up:</p>
<pre><code>XML Parsing Error: no element found
Location: http://geniusupdate.com/GSHelp/faq.aspx
Line Number 1, Column 1:
</code></pre>
<p>The only changes I have made ... | [
{
"answer_id": 303077,
"author": "Chris Ballance",
"author_id": 1551,
"author_profile": "https://Stackoverflow.com/users/1551",
"pm_score": 1,
"selected": false,
"text": "<p>no xml declaration in the beginning</p>\n\n<p><?xml version=\"1.0\"?></p>\n"
},
{
"answer_id": 30307... | 2008/11/19 | [
"https://Stackoverflow.com/questions/303066",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25515/"
] | I recently migrated an ASP site from my dev machine to a live server. All the pages except my FAQ page works just fine, but my FAQ brings up:
```
XML Parsing Error: no element found
Location: http://geniusupdate.com/GSHelp/faq.aspx
Line Number 1, Column 1:
```
The only changes I have made were changing the connectio... | This is a very old thread, but I found this while googling for the same problem and wanted to contribute a definitive answer for anyone else who searches for this in the future.
I got this error when an exception was thrown while the page directives were being parsed. I updated aspx files from source control, and the ... |
303,096 | <p>I'm trying TripleDES Encryption with ECB mode. My code looks like that:</p>
<pre><code>public static string EncryptDES(string InputText)
{
byte[] key = new byte[] { 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46,... | [
{
"answer_id": 303110,
"author": "Quintin Robinson",
"author_id": 12707,
"author_profile": "https://Stackoverflow.com/users/12707",
"pm_score": 0,
"selected": false,
"text": "<p>It sounds like your encryption method is using a different key/salt combo than the decryption method and it ca... | 2008/11/19 | [
"https://Stackoverflow.com/questions/303096",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10968/"
] | I'm trying TripleDES Encryption with ECB mode. My code looks like that:
```
public static string EncryptDES(string InputText)
{
byte[] key = new byte[] { 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48 };... | My bad !
I found my problem
Instead of using `alg.CreateEncryptor()` I was using `alg.CreateDecyptor()`.
A copy paste issue. :(
Thanks for help, guys |
303,109 | <p>I recently ran across some 3rd party C# code which does the following:</p>
<pre><code>public int RecvByteDataFromPrinter(ref byte[] byteData)
{
byte[] recvdata = new byte[1024];
///...fills recvdata array...
byteData = recvdata;
return SUCCESS;
}
</code></pre>
<p>What does the line "<code>... | [
{
"answer_id": 303134,
"author": "Paul Kapustin",
"author_id": 38325,
"author_profile": "https://Stackoverflow.com/users/38325",
"pm_score": 4,
"selected": true,
"text": "<p>Yes, because of ref - it does modify the reference passed.\nStick around? you mean - not destroyed? Yes, it will n... | 2008/11/19 | [
"https://Stackoverflow.com/questions/303109",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31828/"
] | I recently ran across some 3rd party C# code which does the following:
```
public int RecvByteDataFromPrinter(ref byte[] byteData)
{
byte[] recvdata = new byte[1024];
///...fills recvdata array...
byteData = recvdata;
return SUCCESS;
}
```
What does the line "`byteData = recvdata`" actually ... | Yes, because of ref - it does modify the reference passed.
Stick around? you mean - not destroyed? Yes, it will not be GC'd because of a new reference. The old array (passed) might be GC'd though after this assignment if no more references...
Array.Copy will actually copy elements, then you don't need "ref", but this ... |
303,113 | <p>I've scoured the groovy doc and haven't found an analogue, but things there are organized a bit haphazardly. I'm switching from beanshell to groovy and was using the source("fileloc") method in beanshell to inline-include other, utility beanshell scripts for reuse. Is there a standard function to do this in groovy o... | [
{
"answer_id": 303208,
"author": "feoh",
"author_id": 32514,
"author_profile": "https://Stackoverflow.com/users/32514",
"pm_score": 1,
"selected": false,
"text": "<p>The reason you're not finding this is because Groovy is compiled. Your Groovy code gets compiled into Java bytecode that ... | 2008/11/19 | [
"https://Stackoverflow.com/questions/303113",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8720/"
] | I've scoured the groovy doc and haven't found an analogue, but things there are organized a bit haphazardly. I'm switching from beanshell to groovy and was using the source("fileloc") method in beanshell to inline-include other, utility beanshell scripts for reuse. Is there a standard function to do this in groovy or a... | You can assemble all the parts of your scripts into a String, then have a GroovyShell object evaluate your script. I picked this up from Venkat Subramanium's DSL examples.
```
part1 = new File("part1.groovy").text
part2 = new File("part2.groovy").text
script = """
println "starting execution"
${part1}
${part2}
printl... |
303,149 | <p>Parameterized Queries in .Net always look like this in the examples:</p>
<pre><code>SqlCommand comm = new SqlCommand(@"
SELECT *
FROM Products
WHERE Category_ID = @categoryid
",
conn);
comm.Parameters.Add("@categoryid", SqlDbType.Int);
comm.Parameters["@categoryid"].Value = CategoryID;
</code></pr... | [
{
"answer_id": 303175,
"author": "TcKs",
"author_id": 20382,
"author_profile": "https://Stackoverflow.com/users/20382",
"pm_score": 4,
"selected": false,
"text": "<p>You need "%" in value of sql parameter.</p>\n<pre><code>SqlCommand comm = new SqlCommand("SELECT * FROM Pro... | 2008/11/19 | [
"https://Stackoverflow.com/questions/303149",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8435/"
] | Parameterized Queries in .Net always look like this in the examples:
```
SqlCommand comm = new SqlCommand(@"
SELECT *
FROM Products
WHERE Category_ID = @categoryid
",
conn);
comm.Parameters.Add("@categoryid", SqlDbType.Int);
comm.Parameters["@categoryid"].Value = CategoryID;
```
But I'm running int... | Let's say that you have your category ids in an integer array and Name is a string. The trick is to create the command text to allow you to enter all of your category ids as individual parameters and construct the fuzzy match for name. To do the former, we use a loop to construct a sequence of parameter names @p0 throu... |
303,167 | <p>I have an object in SQL (A) that has a many to many relationships with another object (B). I'm currently building an API layer DLL that will allow the user to assign objects of type B into type A. Right now the user would retrieve a list of entries of type A and a list of entries of type B using different LINQ data ... | [
{
"answer_id": 303183,
"author": "Chad Moran",
"author_id": 25416,
"author_profile": "https://Stackoverflow.com/users/25416",
"pm_score": 0,
"selected": false,
"text": "<p>I ran into this same issue, I couldn't come up with an elegant solution. But the only solution I found was to either... | 2008/11/19 | [
"https://Stackoverflow.com/questions/303167",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2191/"
] | I have an object in SQL (A) that has a many to many relationships with another object (B). I'm currently building an API layer DLL that will allow the user to assign objects of type B into type A. Right now the user would retrieve a list of entries of type A and a list of entries of type B using different LINQ data con... | I actually found a different sort of solution and now i feel kind of stupid for even asking the question. What I did inside the Service.Outputs.Add() method was really the problem:
```
public void Add(Output output)
{
OutputCollectionItem oci = new OutputCollectionItem();
oci.item = output;
this.OutputColl... |
303,174 | <p>I just got burned by the <a href="http://cygwin.com/ml/cygwin-xfree-announce/2008-11/msg00000.html" rel="nofollow noreferrer">Cygwin X11R7.4 update</a> and I find the official mailing lists hostile and clunky. So I thought I'd ask here.</p>
<p>If you have survived the upgrade (or at least made progress on fixing t... | [
{
"answer_id": 303183,
"author": "Chad Moran",
"author_id": 25416,
"author_profile": "https://Stackoverflow.com/users/25416",
"pm_score": 0,
"selected": false,
"text": "<p>I ran into this same issue, I couldn't come up with an elegant solution. But the only solution I found was to either... | 2008/11/19 | [
"https://Stackoverflow.com/questions/303174",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1438/"
] | I just got burned by the [Cygwin X11R7.4 update](http://cygwin.com/ml/cygwin-xfree-announce/2008-11/msg00000.html) and I find the official mailing lists hostile and clunky. So I thought I'd ask here.
If you have survived the upgrade (or at least made progress on fixing things), what steps did you take to make things w... | I actually found a different sort of solution and now i feel kind of stupid for even asking the question. What I did inside the Service.Outputs.Add() method was really the problem:
```
public void Add(Output output)
{
OutputCollectionItem oci = new OutputCollectionItem();
oci.item = output;
this.OutputColl... |
303,179 | <p>When designing a lookup table (enum) in SqlServer 2005, if you know the number of entries will never get very high, should you use tinyint instead of int? I'm most concerned about performance, particularly efficiency of indexes.</p>
<p>Let's say you have these representative tables:</p>
<pre><code>Person
------
P... | [
{
"answer_id": 303191,
"author": "Craig",
"author_id": 27294,
"author_profile": "https://Stackoverflow.com/users/27294",
"pm_score": 1,
"selected": false,
"text": "<p>I doubt that using smallint instead of int is going to have much performance benefit except in rare edge cases. You can e... | 2008/11/19 | [
"https://Stackoverflow.com/questions/303179",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1219/"
] | When designing a lookup table (enum) in SqlServer 2005, if you know the number of entries will never get very high, should you use tinyint instead of int? I'm most concerned about performance, particularly efficiency of indexes.
Let's say you have these representative tables:
```
Person
------
PersonId int (PK)
Pers... | The narrower a table (or index node entry) is, the more records (or index nodes) can fit on a single IO page, and the fewer physical (and logical) reads IO operations are required for any query. Also, the more index nodes there are on a single page, the fewer levels there may be in the index, from root to leaf level, a... |
303,180 | <p>Good afternoon,</p>
<p>I have a web query in <code>Excel 2002</code> going against a web page that returns a date column. The dates are returned as <code>DD/MM/YYYY</code>, as I would like to show them in my spreadsheet. My machine running Excel has its regional settings set to en-GB, and the only language set un... | [
{
"answer_id": 303222,
"author": "Tomalak",
"author_id": 18771,
"author_profile": "https://Stackoverflow.com/users/18771",
"pm_score": 0,
"selected": false,
"text": "<p>Maybe you are lucky and Excel understands either the HTML <code>lang</code> attribute or <code><meta http-equiv=\"co... | 2008/11/19 | [
"https://Stackoverflow.com/questions/303180",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7311/"
] | Good afternoon,
I have a web query in `Excel 2002` going against a web page that returns a date column. The dates are returned as `DD/MM/YYYY`, as I would like to show them in my spreadsheet. My machine running Excel has its regional settings set to en-GB, and the only language set under Internet Options is UK English... | Can you modify the "web query"?
The universal date format is the better way for Office products to recognise dates/times. I've had similar problems working with GB to US dates and found that coding your dates into this format saves you a lot of trouble.
```
Universal Date format is : "yyyy-mm-dd hh:mm:ss"
``` |
303,181 | <ol>
<li>Why is operator '&' defined for bool?, and operator '&&' is not? </li>
<li>How exactly does this 1) bool? & bool? and 2) bool? and bool work?</li>
</ol>
<p>Any other "interesting" operator semantics on Nullable? Any overloaded operators for generic T?</p>
| [
{
"answer_id": 303193,
"author": "TcKs",
"author_id": 20382,
"author_profile": "https://Stackoverflow.com/users/20382",
"pm_score": 1,
"selected": false,
"text": "<p>Operator \"&\" is bitwise operator, ¨whereas \"&&\" is logical operator.\nThe logcial \"AND\" operator can not... | 2008/11/19 | [
"https://Stackoverflow.com/questions/303181",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38325/"
] | 1. Why is operator '&' defined for bool?, and operator '&&' is not?
2. How exactly does this 1) bool? & bool? and 2) bool? and bool work?
Any other "interesting" operator semantics on Nullable? Any overloaded operators for generic T? | Operators on `Nullable<T>` are "lifted" operators. What this means is: if T has the operator, T? will have the "lifted" counterpart.
&& and || aren't really operators in the same sense as & and | - for example, they can't be overloaded - from the ECMA spec 14.2.2 Operator overloading:
>
> The overloadable binary ope... |
303,197 | <p>I've created an instance of a SamlAssertion, and added the the authorization statement and attribute statments to it, and now I want to print out the XML so I can do an HTTP post, but not all of the assertion is being outputed. What am I missing (I'm sure it's something bone-headed)?</p>
<p>Here is the code I'm us... | [
{
"answer_id": 318507,
"author": "Brad Patton",
"author_id": 27989,
"author_profile": "https://Stackoverflow.com/users/27989",
"pm_score": 0,
"selected": false,
"text": "<p>I am not sure if this is directly related to your case but this might be useful information related to re-serializi... | 2008/11/19 | [
"https://Stackoverflow.com/questions/303197",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28660/"
] | I've created an instance of a SamlAssertion, and added the the authorization statement and attribute statments to it, and now I want to print out the XML so I can do an HTTP post, but not all of the assertion is being outputed. What am I missing (I'm sure it's something bone-headed)?
Here is the code I'm using:
```
/... | If I had one advice to give you in this case it would be: always use `using` statements when working with [IDisposable](http://msdn.microsoft.com/en-us/library/system.idisposable.aspx) objects such as streams. In addition to automatically flushing streams it would also free resources in case of exception:
```
// Add t... |
303,200 | <p>I am getting an 'access is denied' error when I attempt to delete a folder that is not empty. I used the following command in my attempt: <code>os.remove("/folder_name")</code>. </p>
<p>What is the most effective way of removing/deleting a folder/directory that is not empty?</p>
| [
{
"answer_id": 303225,
"author": "ddaa",
"author_id": 11549,
"author_profile": "https://Stackoverflow.com/users/11549",
"pm_score": 12,
"selected": true,
"text": "<pre><code>import shutil\n\nshutil.rmtree('/folder_name')\n</code></pre>\n\n<p><a href=\"http://docs.python.org/library/shuti... | 2008/11/19 | [
"https://Stackoverflow.com/questions/303200",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37804/"
] | I am getting an 'access is denied' error when I attempt to delete a folder that is not empty. I used the following command in my attempt: `os.remove("/folder_name")`.
What is the most effective way of removing/deleting a folder/directory that is not empty? | ```
import shutil
shutil.rmtree('/folder_name')
```
[Standard Library Reference: shutil.rmtree](http://docs.python.org/library/shutil.html#shutil.rmtree).
By design, `rmtree` fails on folder trees containing read-only files. If you want the folder to be deleted regardless of whether it contains read-only files, the... |
303,214 | <p>How can I create a method that has optional parameters in it in Visual Basic?</p>
| [
{
"answer_id": 303230,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 7,
"selected": true,
"text": "<p>Use the <code>Optional</code> keyword and supply a default value. Optional parameters must be the last parameters de... | 2008/11/19 | [
"https://Stackoverflow.com/questions/303214",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4575/"
] | How can I create a method that has optional parameters in it in Visual Basic? | Use the `Optional` keyword and supply a default value. Optional parameters must be the last parameters defined, to avoid creating ambiguous functions.
```vb
Sub MyMethod(ByVal Param1 As String, Optional ByVal FlagArgument As Boolean = True)
If FlagArgument Then
'Do something special
Console.WriteLi... |
303,216 | <p>I'm trying to use a <code>break</code> statement in a <code>for</code> loop, but since I'm also using strict subs in my Perl code, I'm getting an error saying:</p>
<blockquote>
<p>Bareword "break" not allowed while
"strict subs" in use at ./final.pl
line 154.</p>
</blockquote>
<p>Is there a workaround for th... | [
{
"answer_id": 303231,
"author": "Zain Rizvi",
"author_id": 21539,
"author_profile": "https://Stackoverflow.com/users/21539",
"pm_score": 10,
"selected": true,
"text": "<p>Oh, I found it. You use <a href=\"http://perldoc.perl.org/functions/last.html\" rel=\"noreferrer\">last</a> instead... | 2008/11/19 | [
"https://Stackoverflow.com/questions/303216",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21539/"
] | I'm trying to use a `break` statement in a `for` loop, but since I'm also using strict subs in my Perl code, I'm getting an error saying:
>
> Bareword "break" not allowed while
> "strict subs" in use at ./final.pl
> line 154.
>
>
>
Is there a workaround for this (besides disabling strict subs)?
My code is form... | Oh, I found it. You use [last](http://perldoc.perl.org/functions/last.html) instead of [break](https://perldoc.perl.org/functions/break.html)
```
for my $entry (@array){
if ($string eq "text"){
last;
}
}
``` |
303,218 | <p>I was wondering if there was a way to bind an ArrayList (or any kind of List, for that matter) to a PreparedStatement which will eventually be used to access an Oracle database. I found:</p>
<p><a href="https://stackoverflow.com/questions/178479/alternatives-for-java-sql-preparedstatement-in-clause-issue">Prepared... | [
{
"answer_id": 303280,
"author": "Paul Tomblin",
"author_id": 3333,
"author_profile": "https://Stackoverflow.com/users/3333",
"pm_score": 0,
"selected": false,
"text": "<p>Well, judging by the answer to that one, especially the comments to my wrong answer in that question, you can't.</p>... | 2008/11/19 | [
"https://Stackoverflow.com/questions/303218",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8026/"
] | I was wondering if there was a way to bind an ArrayList (or any kind of List, for that matter) to a PreparedStatement which will eventually be used to access an Oracle database. I found:
[PreparedStatement IN clause alternatives?](https://stackoverflow.com/questions/178479/alternatives-for-java-sql-preparedstatement-i... | You can't bind a List to a single parameter in a prepared statement.
Generate SQL with the a parameter marker for each element in the list, for example:
```
SELECT NAME FROM ITEM WHERE ID IN (?, ?, ?, ?)
```
Even though you'll generate a new statement for each query, I'd still recommend using a `PreparedStatement`.... |
303,243 | <p>I have a large number of 2D points and I want to quickly get those that lie in a certain rectangle.
Let's say a '.' is any point and 'X' is a point I want to find inside a rectangle which has 'T' as TopLeft and 'B' as BottomRight points:</p>
<pre><code>. . . . . .
. T-----+ .
. | X X | .
. +-----B .
. . . . . .
</c... | [
{
"answer_id": 303265,
"author": "vfilby",
"author_id": 24279,
"author_profile": "https://Stackoverflow.com/users/24279",
"pm_score": 4,
"selected": true,
"text": "<p>You could store the points in a spatial index using quad or r-trees. Then given the rectangle you could find all the nod... | 2008/11/19 | [
"https://Stackoverflow.com/questions/303243",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27596/"
] | I have a large number of 2D points and I want to quickly get those that lie in a certain rectangle.
Let's say a '.' is any point and 'X' is a point I want to find inside a rectangle which has 'T' as TopLeft and 'B' as BottomRight points:
```
. . . . . .
. T-----+ .
. | X X | .
. +-----B .
. . . . . .
```
I have trie... | You could store the points in a spatial index using quad or r-trees. Then given the rectangle you could find all the nodes of the tree that overlap it, you would then have to compare each point in this subset to see if it falls in the rectangle.
In essence, the spatial tree helps you prune the search space.
You might... |
303,248 | <p>What is the proper way to load a <code>ListBox</code> in C# .NET 2.0 Winforms?</p>
<p>I thought I could just bind it to a <code>DataTable</code>. No such luck.<br>
I thought I could bind it with a <code>Dictionary</code>. No luck. </p>
<p>Do I have to write an class called <code>KeyValuePair</code>, and then use ... | [
{
"answer_id": 303268,
"author": "Jason Sundram",
"author_id": 2683,
"author_profile": "https://Stackoverflow.com/users/2683",
"pm_score": 3,
"selected": false,
"text": "<p>Lets assume your data type is called MyDataType. Implement ToString() on that datatype to determine the display tex... | 2008/11/19 | [
"https://Stackoverflow.com/questions/303248",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36590/"
] | What is the proper way to load a `ListBox` in C# .NET 2.0 Winforms?
I thought I could just bind it to a `DataTable`. No such luck.
I thought I could bind it with a `Dictionary`. No luck.
Do I have to write an class called `KeyValuePair`, and then use `List<KeyValuePair>` just to be able to load this thing with ob... | Simple code example. Say you have a `Person` class with 3 properties. `FirstName`, `LastName` and `Age`. Say you want to bind your listbox to a collection of `Person` objects. You want the display to show the first name, but the value to be the age. Here's how you would do it:
```
List<Person> people = new List<Person... |
303,284 | <p>Soo... F# no longer has IEnumerable.map_with_type... which is the way people <em>were</em> mapping over collections. How do I do that now?</p>
<pre><code>let urlPat = "href\\s*=\\s*(?:(?:\\\"(?<url>[^\\\"]*)\\\")|(?<url>[^\\s]* ))";;
let urlRegex = new Regex(urlPat)
let matches =
urlRegex.Matches(h... | [
{
"answer_id": 303471,
"author": "Chris Smith",
"author_id": 322,
"author_profile": "https://Stackoverflow.com/users/322",
"pm_score": 2,
"selected": false,
"text": "<p>Is Seq.cast what you are looking for?</p>\n"
},
{
"answer_id": 304225,
"author": "Tomas Petricek",
"aut... | 2008/11/19 | [
"https://Stackoverflow.com/questions/303284",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9401/"
] | Soo... F# no longer has IEnumerable.map\_with\_type... which is the way people *were* mapping over collections. How do I do that now?
```
let urlPat = "href\\s*=\\s*(?:(?:\\\"(?<url>[^\\\"]*)\\\")|(?<url>[^\\s]* ))";;
let urlRegex = new Regex(urlPat)
let matches =
urlRegex.Matches(http("http://www.google.com"))
... | you would write the last line like this:
```
let urls = Seq.map matchToUrl (Seq.cast matches);;
```
And this can be written in a nicer way using pipelining operator:
```
let urls = matches|> Seq.cast |> Seq.map matchToUrl;;
```
F# automatically figures out what is the right target type (because it knows what `mat... |
303,287 | <p>I have a series of Extension methods to help with null-checking on IDataRecord objects, which I'm currently implementing like this:</p>
<pre><code>public static int? GetNullableInt32(this IDataRecord dr, int ordinal)
{
int? nullInt = null;
return dr.IsDBNull(ordinal) ? nullInt : dr.GetInt32(ordinal);
}
pub... | [
{
"answer_id": 303310,
"author": "TcKs",
"author_id": 20382,
"author_profile": "https://Stackoverflow.com/users/20382",
"pm_score": -1,
"selected": false,
"text": "<p>I do it this way:</p>\n\n<pre><code>DataRow record = GetSomeRecord();\nint? someNumber = record[15] as int?\nGuid? someUI... | 2008/11/19 | [
"https://Stackoverflow.com/questions/303287",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1249/"
] | I have a series of Extension methods to help with null-checking on IDataRecord objects, which I'm currently implementing like this:
```
public static int? GetNullableInt32(this IDataRecord dr, int ordinal)
{
int? nullInt = null;
return dr.IsDBNull(ordinal) ? nullInt : dr.GetInt32(ordinal);
}
public static int... | You can just declare your method like this:
```
public static T GetNullable<T>(this IDataRecord dr, int ordinal)
{
return dr.IsDBNull(ordinal) ? default(T) : (T) dr.GetValue(ordinal);
}
```
This way, if T is a nullable int or any other nullable value type, it will in fact return null. If it's a regular datatype,... |
303,314 | <p>Does anyone know of a CSS Adapter for the LinkButton control for ASP.Net 2?</p>
<p><strong>Update:</strong></p>
<p>We are trying to use CSS Buttons. We are using this approach: <a href="http://www.oscaralexander.com/tutorials/how-to-make-sexy-buttons-with-css.html" rel="nofollow noreferrer">http://www.oscaralexand... | [
{
"answer_id": 303317,
"author": "Quintin Robinson",
"author_id": 12707,
"author_profile": "https://Stackoverflow.com/users/12707",
"pm_score": 0,
"selected": false,
"text": "<p>I don't think the output from the LinkButton control could be more CSS friendly.. it is a pure HTML Anchor.</p... | 2008/11/19 | [
"https://Stackoverflow.com/questions/303314",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25020/"
] | Does anyone know of a CSS Adapter for the LinkButton control for ASP.Net 2?
**Update:**
We are trying to use CSS Buttons. We are using this approach: <http://www.oscaralexander.com/tutorials/how-to-make-sexy-buttons-with-css.html> For that we need to render the tags which the link button doesn't do.
**Possible Solut... | Possible Solution using Adapter
We created an adapter for the linkbutton. Then changed the RenderContents as follows:
```
protected override void Render(HtmlTextWriter writer) {
LinkButton linkButton = this.Control;
linkButton.Text = String.Concat("<span>", linkButton.Text, "</span>");
base.Render(wr... |
303,336 | <p>I have made some changes to a site and need to re-host it as the current host is ceasing to exist. My client has received the following from the current host:</p>
<p>"The best thing to tell them is that, due to the fact that we are withdrawing our service completely, we would look to fully transfer the web site ad... | [
{
"answer_id": 303348,
"author": "Owen",
"author_id": 4853,
"author_profile": "https://Stackoverflow.com/users/4853",
"pm_score": 2,
"selected": false,
"text": "<p>an IPSTAG is a .uk only designation of the domain's registrar. basically, the webhost is asking you to transfer the domain n... | 2008/11/19 | [
"https://Stackoverflow.com/questions/303336",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16684/"
] | I have made some changes to a site and need to re-host it as the current host is ceasing to exist. My client has received the following from the current host:
"The best thing to tell them is that, due to the fact that we are withdrawing our service completely, we would look to fully transfer the web site address acros... | an IPSTAG is a .uk only designation of the domain's registrar. basically, the webhost is asking you to transfer the domain name registration away from them to a new provider.
i would suggest you (or your client) find a new registrar, get their IPSTAG, and then send that to your old host, who will then be able to initi... |
303,338 | <p>We have a need to leverage client side resources for lists containing tasks.</p>
<p>The client needs to:</p>
<ul>
<li>be notified of updates to the list</li>
<li>be able to re-order/filter the list (requesting an update from the server with tasks that the client does not know of/have in cache)</li>
</ul>
<p>The p... | [
{
"answer_id": 303348,
"author": "Owen",
"author_id": 4853,
"author_profile": "https://Stackoverflow.com/users/4853",
"pm_score": 2,
"selected": false,
"text": "<p>an IPSTAG is a .uk only designation of the domain's registrar. basically, the webhost is asking you to transfer the domain n... | 2008/11/19 | [
"https://Stackoverflow.com/questions/303338",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37193/"
] | We have a need to leverage client side resources for lists containing tasks.
The client needs to:
* be notified of updates to the list
* be able to re-order/filter the list (requesting an update from the server with tasks that the client does not know of/have in cache)
The problem comes on initial load or large list... | an IPSTAG is a .uk only designation of the domain's registrar. basically, the webhost is asking you to transfer the domain name registration away from them to a new provider.
i would suggest you (or your client) find a new registrar, get their IPSTAG, and then send that to your old host, who will then be able to initi... |
303,339 | <p>I am coding a feature in a program where users can edit documents stored in a database, it saves the document to a temporary folder then uses Process.Start to launch the document into the editing application, let's say Microsoft Word for example.</p>
<p>Then my app needs to wait until they've closed the called proc... | [
{
"answer_id": 303346,
"author": "Ian Jacobs",
"author_id": 22818,
"author_profile": "https://Stackoverflow.com/users/22818",
"pm_score": 0,
"selected": false,
"text": "<p>I'm not sure about the starting a new process, but have you considered this logic for waiting until exit:</p>\n\n<p>... | 2008/11/19 | [
"https://Stackoverflow.com/questions/303339",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8939/"
] | I am coding a feature in a program where users can edit documents stored in a database, it saves the document to a temporary folder then uses Process.Start to launch the document into the editing application, let's say Microsoft Word for example.
Then my app needs to wait until they've closed the called process and re... | After further research and coming across a number of posts mentioning the unreliability of WaitForExit and the process' Exited event, I've come up with a completely different solution: I start the process and don't bother waiting for it, just pop up a modal dialog in which the user can click on update to update the tem... |
303,343 | <pre><code>public Int64 ReturnDifferenceA()
{
User[] arrayList;
Int64 firstTicks;
IList<User> userList;
Int64 secondTicks;
System.Diagnostics.Stopwatch watch;
userList = Enumerable
.Range(0, 1000)
.Select(currentItem => new User()).ToList();
arrayList = userList.ToAr... | [
{
"answer_id": 303359,
"author": "Karl",
"author_id": 36093,
"author_profile": "https://Stackoverflow.com/users/36093",
"pm_score": 3,
"selected": false,
"text": "<p>You are running in a high level language with a runtime environment that does a lot of caching and performance optimizatio... | 2008/11/19 | [
"https://Stackoverflow.com/questions/303343",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21691/"
] | ```
public Int64 ReturnDifferenceA()
{
User[] arrayList;
Int64 firstTicks;
IList<User> userList;
Int64 secondTicks;
System.Diagnostics.Stopwatch watch;
userList = Enumerable
.Range(0, 1000)
.Select(currentItem => new User()).ToList();
arrayList = userList.ToArray();
watch ... | by the way, using IEnumerable.Count() on an Array is hundreds of times slower than Array.Length... Although this doesn't answer the question at all. |
303,397 | <p>I have designed a xml schema to parse an incoming xml document. The receive location gets xml documents from 2 feeds, one of them has misspelled a node in the document, "Roookie" instead of "Rookie", Is there a way to have my existing xsd parse this document?</p>
| [
{
"answer_id": 303403,
"author": "Mitchel Sellers",
"author_id": 13279,
"author_profile": "https://Stackoverflow.com/users/13279",
"pm_score": 0,
"selected": false,
"text": "<p>You would need to replace the elements in the document or modify the xsd to work with the new document format.<... | 2008/11/19 | [
"https://Stackoverflow.com/questions/303397",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1443363/"
] | I have designed a xml schema to parse an incoming xml document. The receive location gets xml documents from 2 feeds, one of them has misspelled a node in the document, "Roookie" instead of "Rookie", Is there a way to have my existing xsd parse this document? | You could probably preprocess the wrong XML file, like with this simple XSL stylesheet:
```
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="no"/>
<xsl:template match="Roookie">
<Rookie>
<xs... |
303,404 | <p>If I have records:</p>
<pre>
Row Date, LocationID, Account
1 Jan 1, 2008 1 1000
2 Jan 2, 2008 1 1000
3 Jan 3, 2008 2 1001
4 Jan 3, 2008 1 1001
5 Jan 3, 2008 3 1001
6 Jan 4, 2008 3 1002
</pre>
<p>I need to get the row (<code... | [
{
"answer_id": 303421,
"author": "Tony Andrews",
"author_id": 18747,
"author_profile": "https://Stackoverflow.com/users/18747",
"pm_score": 0,
"selected": false,
"text": "<p>Try something like:</p>\n\n<pre><code>select *\nfrom mytable t1\nwhere date = (select max(date) from mytable t2\n ... | 2008/11/19 | [
"https://Stackoverflow.com/questions/303404",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9266/"
] | If I have records:
```
Row Date, LocationID, Account
1 Jan 1, 2008 1 1000
2 Jan 2, 2008 1 1000
3 Jan 3, 2008 2 1001
4 Jan 3, 2008 1 1001
5 Jan 3, 2008 3 1001
6 Jan 4, 2008 3 1002
```
I need to get the row (`date`, `locatinid... | I think this would work:
```
SELECT t1.*
FROM table t1
JOIN (SELECT MAX(Date), LocationID
FROM table
GROUP BY Date, LocationID) t2 on t1.Date = t2.Date and t1.LocationID = t2.LocationID
``` |
303,417 | <p>I found that SQL stored procedures are very interesting and useful. I have written stored procedures but i want to write well crafted, good performance tuned and concise SPs for any sort of requirement and also would love to learn about any tricks or good practices for stored procedures. How do i move from the begin... | [
{
"answer_id": 303462,
"author": "Cade Roux",
"author_id": 18255,
"author_profile": "https://Stackoverflow.com/users/18255",
"pm_score": 4,
"selected": false,
"text": "<p>The only trick I always try to use is: Always include an example usage in a comment near the top. This is also usefu... | 2008/11/19 | [
"https://Stackoverflow.com/questions/303417",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3113/"
] | I found that SQL stored procedures are very interesting and useful. I have written stored procedures but i want to write well crafted, good performance tuned and concise SPs for any sort of requirement and also would love to learn about any tricks or good practices for stored procedures. How do i move from the beginner... | Here are my stored procedure error-handling guidelines.
* Call each stored procedure using its fully qualified name to improve performance: that's the server name, database name, schema (owner) name, and procedure name.
* In the script that creates each stored procedure, explicitly specify which roles are allowed to e... |
303,440 | <p>I'm working on a idea where my a:link have one state (blue, no underline etc) with a a:hover being white. I want my <strong>visited links to have the same state</strong> as <code>a:link</code> and <code>a:hover</code>. Is this possible? supported in most common browsers?</p>
| [
{
"answer_id": 303447,
"author": "Marc Charbonneau",
"author_id": 35136,
"author_profile": "https://Stackoverflow.com/users/35136",
"pm_score": 1,
"selected": false,
"text": "<p>Here's how you can style the a tags (normal and visited) and style the hover separately.</p>\n\n<pre><code>a\n... | 2008/11/19 | [
"https://Stackoverflow.com/questions/303440",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm working on a idea where my a:link have one state (blue, no underline etc) with a a:hover being white. I want my **visited links to have the same state** as `a:link` and `a:hover`. Is this possible? supported in most common browsers? | ```
a, a:link, a:hover, a:visited, a:active {text-decoration: none; color: blue;}
```
should work on all CSS-enabled browsers, although this is a [bad idea](http://www.useit.com/alertbox/20040503.html) (currently offline, [Google Cache](http://209.85.129.132/search?q=cache:WLLZPIH8XjoJ:www.useit.com/alertbox/20040503... |
303,460 | <p>Greetings!</p>
<p>I'm creating a User Control that will display data in a GridView control. We are using n-tier architecture and the data in question is retrieved from our database and returned to us as a ReadOnlyCollection. OurNewObject is a class containing several properties and an empty constructor that takes... | [
{
"answer_id": 303506,
"author": "Mitchel Sellers",
"author_id": 13279,
"author_profile": "https://Stackoverflow.com/users/13279",
"pm_score": 1,
"selected": true,
"text": "<p>I believe the issue is missing two attributes.</p>\n\n<p>First on your GetTopUsers() Method add this attribute</... | 2008/11/19 | [
"https://Stackoverflow.com/questions/303460",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27870/"
] | Greetings!
I'm creating a User Control that will display data in a GridView control. We are using n-tier architecture and the data in question is retrieved from our database and returned to us as a ReadOnlyCollection. OurNewObject is a class containing several properties and an empty constructor that takes no paramete... | I believe the issue is missing two attributes.
First on your GetTopUsers() Method add this attribute
```
[System.ComponentModel.DataObjectMethodAttribute
(System.ComponentModel.DataObjectMethodType.Select, true)]
```
Then on the actual OurNewObject class add this attribute
```
[System.ComponentModel.DataObject... |
303,488 | <p>In through <code>php_info()</code> where the WSDL cache is held (<code>/tmp</code>), but I don't necessarily know if it is safe to delete all files starting with WSDL. </p>
<p>Yes, I <em>should</em> be able to just delete everything from <code>/tmp</code>, but I don't know what else this could effect if I delete an... | [
{
"answer_id": 303514,
"author": "Owen",
"author_id": 4853,
"author_profile": "https://Stackoverflow.com/users/4853",
"pm_score": 9,
"selected": true,
"text": "<p>You can safely delete the WSDL cache files. If you wish to prevent future caching, use:</p>\n\n<pre><code>ini_set(\"soap.wsdl... | 2008/11/19 | [
"https://Stackoverflow.com/questions/303488",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8880/"
] | In through `php_info()` where the WSDL cache is held (`/tmp`), but I don't necessarily know if it is safe to delete all files starting with WSDL.
Yes, I *should* be able to just delete everything from `/tmp`, but I don't know what else this could effect if I delete any all WSDL files. | You can safely delete the WSDL cache files. If you wish to prevent future caching, use:
```
ini_set("soap.wsdl_cache_enabled", 0);
```
or dynamically:
```
$client = new SoapClient('http://somewhere.com/?wsdl', array('cache_wsdl' => WSDL_CACHE_NONE) );
``` |
303,502 | <p>I ran across this and was wondering if someone could explain why this works in VB.NET when I would expect it should fail, just like it does in C#</p>
<pre><code>//The C# Version
struct Person {
public string name;
}
...
Person someone = null; //Nope! Can't do that!!
Person? someoneElse = null; //No problem, ju... | [
{
"answer_id": 303518,
"author": "BFree",
"author_id": 15861,
"author_profile": "https://Stackoverflow.com/users/15861",
"pm_score": 6,
"selected": true,
"text": "<p>If I remember correctly, 'Nothing' in VB means \"the default value\". For a value type, that's the default value, for a re... | 2008/11/19 | [
"https://Stackoverflow.com/questions/303502",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17091/"
] | I ran across this and was wondering if someone could explain why this works in VB.NET when I would expect it should fail, just like it does in C#
```
//The C# Version
struct Person {
public string name;
}
...
Person someone = null; //Nope! Can't do that!!
Person? someoneElse = null; //No problem, just like expect... | If I remember correctly, 'Nothing' in VB means "the default value". For a value type, that's the default value, for a reference type, that would be null. Thus, assigning nothing to a struct, is no problem at all. |
303,510 | <p>My XML (<strong>a.xhtml</strong>) starts like this</p>
<pre><code><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
...
</code></pre>
<p>My code starts like this</p>
<pre><code>use XML::XPath;
use XML::XPath::XMLParser;
my $xp = XML... | [
{
"answer_id": 303607,
"author": "Kornel",
"author_id": 27009,
"author_profile": "https://Stackoverflow.com/users/27009",
"pm_score": 1,
"selected": false,
"text": "<p>Usually it's done by setting up local <a href=\"http://en.wikipedia.org/wiki/XML_Catalog\" rel=\"nofollow noreferrer\">X... | 2008/11/19 | [
"https://Stackoverflow.com/questions/303510",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24349/"
] | My XML (**a.xhtml**) starts like this
```
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
...
```
My code starts like this
```
use XML::XPath;
use XML::XPath::XMLParser;
my $xp = XML::XPath->new(filename => "a.xhtml");
my $nodeset = $xp-... | XML::XPath is based on XML::Parser. There is an option in XML::Parser to NOT use LWP to resolve external entities (such as DTDs). And XML::XPath lets you pass an XML::Parser objetc, to use as the parser.
So you can write this:
```
my $p = XML::Parser->new( NoLWP => 1);
my $xp= XML::XPath->new( parser => $p, filename ... |
303,511 | <p>I'm setting up CruiseControl.NET and during the build I want to modify my version.txt file and have it checked in. When I do this, CruiseControl.NET doesn't know this checkin was done by the build and so the next time it checks sources, it sees there were modifications and rebuilds again (I have IfModificationExist... | [
{
"answer_id": 303549,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>I'm not using Subversion, i'm using TFS.</p>\n\n<p>Version.txt contains \"1.0.5.3\" which is the current build number. Whe... | 2008/11/19 | [
"https://Stackoverflow.com/questions/303511",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm setting up CruiseControl.NET and during the build I want to modify my version.txt file and have it checked in. When I do this, CruiseControl.NET doesn't know this checkin was done by the build and so the next time it checks sources, it sees there were modifications and rebuilds again (I have IfModificationExists se... | You can use exclusionFilters in the project to exclude the version.txt file from triggering a build.
```
<sourcecontrol type="filtered">
<sourceControlProvider type="svn">
...
</sourceControlProvider>
<exclusionFilters>
<pathFilter>
<pattern>**/Version.txt</pattern>
... |
303,512 | <p>It seems like Groovy was forgotten in this thread so I'll just ask the same question for Groovy.</p>
<ul>
<li>Try to limit answers to Groovy core</li>
<li>One feature per answer</li>
<li>Give an example and short description of the feature, not just a link to documentation</li>
<li>Label the feature using bold titl... | [
{
"answer_id": 303561,
"author": "Robert Fischer",
"author_id": 27561,
"author_profile": "https://Stackoverflow.com/users/27561",
"pm_score": 5,
"selected": false,
"text": "<p>Using hashes as pseudo-objects.</p>\n\n<pre><code>def x = [foo:1, bar:{-> println \"Hello, world!\"}]\nx.foo\... | 2008/11/19 | [
"https://Stackoverflow.com/questions/303512",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | It seems like Groovy was forgotten in this thread so I'll just ask the same question for Groovy.
* Try to limit answers to Groovy core
* One feature per answer
* Give an example and short description of the feature, not just a link to documentation
* Label the feature using bold title as the first line
See also:
1. ... | **Using the spread-dot operator**
```
def animals = ['ant', 'buffalo', 'canary', 'dog']
assert animals.size() == 4
assert animals*.size() == [3, 7, 6, 3]
```
This is a shortcut for `animals.collect { it.size() }`. |
303,541 | <p>I am trying to create some HTML which shows me if my server is available from the internet, green light OK red light unavailable. This I can do for a remote site but not for my home, my router seems to prevent me from returning to home via my static IP address. I want to create some HTML so that I see how I look fro... | [
{
"answer_id": 303577,
"author": "ddaa",
"author_id": 11549,
"author_profile": "https://Stackoverflow.com/users/11549",
"pm_score": 1,
"selected": false,
"text": "<p>You are attacking the problem on the wrong angle.</p>\n\n<p>Any code in a page is going to be executed client side, by def... | 2008/11/19 | [
"https://Stackoverflow.com/questions/303541",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am trying to create some HTML which shows me if my server is available from the internet, green light OK red light unavailable. This I can do for a remote site but not for my home, my router seems to prevent me from returning to home via my static IP address. I want to create some HTML so that I see how I look from m... | You are attacking the problem on the wrong angle.
Any code in a page is going to be executed client side, by definition.
If you need something executed somewhere else, you need an external server at that other place. That can be a very simple http server that you could query with XMLHttpRequest on you page, or someth... |
303,548 | <p>I have the following xml that's sent to me from a web service. I'm using .NET to deserialize it, but I'm getting an exception saying that its formatted wrong. <code>There is an error in XML document (2, 2)</code> Now, if I understand that correctly, it's not liking that it's finding the first <code><error></... | [
{
"answer_id": 303560,
"author": "mendicant",
"author_id": 1800,
"author_profile": "https://Stackoverflow.com/users/1800",
"pm_score": 0,
"selected": false,
"text": "<p>There is an error in XML document (2, 2) looks to me like it would be the m in <messages>.</p>\n\n<p>Perhaps you ... | 2008/11/19 | [
"https://Stackoverflow.com/questions/303548",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13611/"
] | I have the following xml that's sent to me from a web service. I'm using .NET to deserialize it, but I'm getting an exception saying that its formatted wrong. `There is an error in XML document (2, 2)` Now, if I understand that correctly, it's not liking that it's finding the first `<error>` node.
```
<?xml version="1... | This class works for me:
```
<XmlRoot(Namespace:="http://www.w3.org/1999/xml", ElementName:="messages")> _
Public Class cResponseMessage
<XmlElement> _
Public Property [error] As String
Get
Set(ByVal value As String)
End Property
<XmlElement> _
Public Property message As String
... |
303,554 | <p>I have a hidden field that i want to bind to either a function on the page's code behind. I don't quite recall the exact syntax and i can't find the answer via Google. Is the code below correct? Thank.</p>
<pre><code>print("<asp:HiddenField ID="dummy" Value='<%#Getdummy() %>' runat="server" />");
</code... | [
{
"answer_id": 303612,
"author": "shahkalpesh",
"author_id": 23574,
"author_profile": "https://Stackoverflow.com/users/23574",
"pm_score": 0,
"selected": false,
"text": "<p>If you have the hidden field with runat=server, you could write code to assign value in the code behind (rather tha... | 2008/11/19 | [
"https://Stackoverflow.com/questions/303554",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28647/"
] | I have a hidden field that i want to bind to either a function on the page's code behind. I don't quite recall the exact syntax and i can't find the answer via Google. Is the code below correct? Thank.
```
print("<asp:HiddenField ID="dummy" Value='<%#Getdummy() %>' runat="server" />");
``` | The code you've put looks pretty good ...
The two step process is ... add the hidden field to the markup
```
<asp:HiddenField ID="hdnId" runat="server" Value='<%# GetValue() %>'/>
```
Then create the specified method signature ...
```
protected string GetValue()
{
return "something";
}
```
Hope this helps ... |
303,555 | <p>Suppose I have two classes with the same interface:</p>
<pre><code>interface ISomeInterface
{
int foo{get; set;}
int bar{get; set;}
}
class SomeClass : ISomeInterface {}
class SomeOtherClass : ISomeInterface {}
</code></pre>
<p>Suppose I have an instance of ISomeInterface that represents a SomeClass. I... | [
{
"answer_id": 303563,
"author": "Joel Martinez",
"author_id": 5416,
"author_profile": "https://Stackoverflow.com/users/5416",
"pm_score": 2,
"selected": false,
"text": "<p>Reflection ... loop through every property, and set it on the corresponding property on the other object.</p>\n"
... | 2008/11/19 | [
"https://Stackoverflow.com/questions/303555",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2147/"
] | Suppose I have two classes with the same interface:
```
interface ISomeInterface
{
int foo{get; set;}
int bar{get; set;}
}
class SomeClass : ISomeInterface {}
class SomeOtherClass : ISomeInterface {}
```
Suppose I have an instance of ISomeInterface that represents a SomeClass. Is there an easy way to copy... | "Would you be able to give me an example of how I can do that (or at least point me towards the right methods to be using)? I don't seem to be able to find them on MSDN" – Jason Baker
Jason, something like the following:
```
var props = typeof(Foo)
.GetProperties(BindingFlags.Public | BindingFlags.Instanc... |
303,562 | <p>I'm trying to write a macro that would allow me to do something like: <code>FORMAT(a << "b" << c << d)</code>, and the result would be a string -- the same as creating an ostringstream, inserting <code>a...d</code>, and returning <code>.str()</code>. Something like:</p>
<pre><code>string f(){
o... | [
{
"answer_id": 303620,
"author": "coppro",
"author_id": 16855,
"author_profile": "https://Stackoverflow.com/users/16855",
"pm_score": 2,
"selected": false,
"text": "<p>The problem you are having is related to the fact that <code>operator << (ostream&, char*)</code> is not a mem... | 2008/11/19 | [
"https://Stackoverflow.com/questions/303562",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39132/"
] | I'm trying to write a macro that would allow me to do something like: `FORMAT(a << "b" << c << d)`, and the result would be a string -- the same as creating an ostringstream, inserting `a...d`, and returning `.str()`. Something like:
```
string f(){
ostringstream o;
o << a << "b" << c << d;
return o.str()
}
... | You've all pretty much nailed this already. But it's a little challenging to follow. So let me take a stab at summarizing what you've said...
---
That difficulties here are that:
* We are playing with a temporary `ostringstream` object, so taking addresses is contra-indicated.
* Because it's a temporary, we cannot t... |
303,591 | <p>Range intersection is a simple, but non-trivial problem.</p>
<p>Its has been answered twice already:</p>
<ul>
<li><a href="https://stackoverflow.com/questions/224878/find-number-range-intersection">Find number range intersection</a></li>
<li><a href="https://stackoverflow.com/questions/143552/comparing-date-ranges... | [
{
"answer_id": 303644,
"author": "Paul Tomblin",
"author_id": 3333,
"author_profile": "https://Stackoverflow.com/users/3333",
"pm_score": 0,
"selected": false,
"text": "<p>Just as a quad tree works for a set of 2d points, a simple binary tree should work for this case. Build a tree with... | 2008/11/19 | [
"https://Stackoverflow.com/questions/303591",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21838/"
] | Range intersection is a simple, but non-trivial problem.
Its has been answered twice already:
* [Find number range intersection](https://stackoverflow.com/questions/224878/find-number-range-intersection)
* [Comparing date ranges](https://stackoverflow.com/questions/143552/comparing-date-ranges)
The first solutions i... | The standard approach is to use an [interval tree](http://en.wikipedia.org/wiki/Interval_tree#With_an_Interval).
>
> In computer science, an interval tree is a tree data structure to hold intervals. Specifically, it allows one to efficiently find all intervals that overlap with any given interval or point. It is ofte... |
303,611 | <p>I originally used WebRequest and WebResponse to sent Http Post Messages. Always I got a response of "OK". The message I post is an XML signed with a certificate in the xml.</p>
<p>The composition is this:
C# service that is sending to a https website.
HTTPS Website on another place that I cant say.
HTTPS Local Web... | [
{
"answer_id": 303681,
"author": "Oppositional",
"author_id": 2029,
"author_profile": "https://Stackoverflow.com/users/2029",
"pm_score": 3,
"selected": true,
"text": "<p>If you are <em>not</em> recieving a 503 error when navigating to the URL in your browser, but <em>do</em> recieve it ... | 2008/11/19 | [
"https://Stackoverflow.com/questions/303611",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12924/"
] | I originally used WebRequest and WebResponse to sent Http Post Messages. Always I got a response of "OK". The message I post is an XML signed with a certificate in the xml.
The composition is this:
C# service that is sending to a https website.
HTTPS Website on another place that I cant say.
HTTPS Local Website local... | If you are *not* recieving a 503 error when navigating to the URL in your browser, but *do* recieve it when requesting the resource when using HttpWebRequest, the first thing I would recommend is that you specify a value for the **UserAgent** when making the request.
You may also want to use [Fiddler2](http://www.fidd... |
303,615 | <p>A lot of programs log things into a text file in a format something like this:</p>
<p>11/19/2008 13:29:01 DEBUG Opening connection to localhost.</p>
<p>11/19/2008 13:29:01 DEBUG Sending login message for user 'ADMIN'.</p>
<p>11/19/2008 13:29:03 DEBUG Received login response 'OK' for user 'ADMIN'.</p>
<p>...</p>
... | [
{
"answer_id": 303653,
"author": "Robert Wagner",
"author_id": 10784,
"author_profile": "https://Stackoverflow.com/users/10784",
"pm_score": 2,
"selected": true,
"text": "<p>I'm not sure of any products that do that, but you could use <a href=\"http://www.ondotnet.com/pub/a/dotnet/2003/0... | 2008/11/19 | [
"https://Stackoverflow.com/questions/303615",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16387/"
] | A lot of programs log things into a text file in a format something like this:
11/19/2008 13:29:01 DEBUG Opening connection to localhost.
11/19/2008 13:29:01 DEBUG Sending login message for user 'ADMIN'.
11/19/2008 13:29:03 DEBUG Received login response 'OK' for user 'ADMIN'.
...
However, I prefer something more s... | I'm not sure of any products that do that, but you could use [log4net](http://www.ondotnet.com/pub/a/dotnet/2003/06/16/log4net.html) and write your own [appender](http://logging.apache.org/log4net/release/features.html) (output handler). |
303,625 | <p>I've followed the ADAM Step by Step Guide from Microsoft and setup an ADAM instance on my local machine. I'm attempting to authenticate using the "Mary Baker" account, but every time I get a COM exception on the <code>if (entry.Guid != null)</code> line below. The exception states that there's an unknown user name... | [
{
"answer_id": 304239,
"author": "Josh Kelley",
"author_id": 25507,
"author_profile": "https://Stackoverflow.com/users/25507",
"pm_score": 0,
"selected": false,
"text": "<p>I haven't used ADAM or System.DirectoryServices, but I do have experience with LDAP and AD; hopefully the following... | 2008/11/19 | [
"https://Stackoverflow.com/questions/303625",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26218/"
] | I've followed the ADAM Step by Step Guide from Microsoft and setup an ADAM instance on my local machine. I'm attempting to authenticate using the "Mary Baker" account, but every time I get a COM exception on the `if (entry.Guid != null)` line below. The exception states that there's an unknown user name or bad password... | ADAM stores the unique identifier for a user in the `displayName` attribute of the `user` class. They need to be unique in the ADAM instance for the user to authenticate. If two users both had their `displayName` attribute set to 'jsmith' then neither user could authenticate in ADAM.
Use the ldp utility to query the `... |
303,639 | <p>I'm terrible with regex, but I've had a try and a Google (and even looked in reddit's source) and I'm still stuck so here goes:</p>
<p>My aim is to match the following 'codes' and replace them with the HTML tags. It's just the regex I'm stuck with.</p>
<pre><code>**bold text**
_italic text_
~hyperlink~
</code></pr... | [
{
"answer_id": 303647,
"author": "Owen",
"author_id": 4853,
"author_profile": "https://Stackoverflow.com/users/4853",
"pm_score": 3,
"selected": true,
"text": "<p>use:</p>\n\n<pre><code>\\*\\*(.[^*]*)\\*\\*\n</code></pre>\n\n<p>explanation:</p>\n\n<pre><code>\\*\\* // match two *'s\... | 2008/11/19 | [
"https://Stackoverflow.com/questions/303639",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2025/"
] | I'm terrible with regex, but I've had a try and a Google (and even looked in reddit's source) and I'm still stuck so here goes:
My aim is to match the following 'codes' and replace them with the HTML tags. It's just the regex I'm stuck with.
```
**bold text**
_italic text_
~hyperlink~
```
Here's my attempts at the ... | use:
```
\*\*(.[^*]*)\*\*
```
explanation:
```
\*\* // match two *'s
(. // match any character
[^*] // that is not a *
*) // continuation of any character
\*\* // match two *'s
```
in a character class "[ ]" "^" is only significant if it's the first character. so `(.*)` matches anythi... |
303,642 | <p>I have written a new custom component derived from TLabel. The component adds some custom drawing to component, but nothing else. When component is painted, everything works fine. But when the redraw is needed (like dragging another window over the component), "label part" works fine but my custom drawing is not pro... | [
{
"answer_id": 303899,
"author": "Jim McKeeth",
"author_id": 255,
"author_profile": "https://Stackoverflow.com/users/255",
"pm_score": 1,
"selected": false,
"text": "<p>I am guessing there is something wrong in your MyCustomPaint because the rest is coded correctly. Here is my implement... | 2008/11/19 | [
"https://Stackoverflow.com/questions/303642",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7735/"
] | I have written a new custom component derived from TLabel. The component adds some custom drawing to component, but nothing else. When component is painted, everything works fine. But when the redraw is needed (like dragging another window over the component), "label part" works fine but my custom drawing is not proper... | SOLVED:
The problem is (redundant) use of FloodFill. If the Canvas is not fully visible floodfill causes artifacts. I removed the floodfill and now it works as needed. |
303,656 | <p>Our application is an Xbap running in full trust. I have a function similar to this:</p>
<pre><code>private void ShowPage(Page page)
{
NavigationWindow mainWindow = Application.Current.MainWindow as NavigationWindow;
mainWindow.Navigate(page);
}
</code></pre>
<p>This works great for browsing inside an ex... | [
{
"answer_id": 310022,
"author": "Shaun Bowe",
"author_id": 1514,
"author_profile": "https://Stackoverflow.com/users/1514",
"pm_score": 3,
"selected": true,
"text": "<p>Apparently WPF is a little new for StackOverflow. Here is the function I came up with in case anyone else stumbles acro... | 2008/11/19 | [
"https://Stackoverflow.com/questions/303656",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1514/"
] | Our application is an Xbap running in full trust. I have a function similar to this:
```
private void ShowPage(Page page)
{
NavigationWindow mainWindow = Application.Current.MainWindow as NavigationWindow;
mainWindow.Navigate(page);
}
```
This works great for browsing inside an existing window. I would lik... | Apparently WPF is a little new for StackOverflow. Here is the function I came up with in case anyone else stumbles across this.
```
private void ShowPage(Page page)
{
NavigationWindow popup = new NavigationWindow();
popup.Height = 400;
popup.Width = 600;
popup.Show();
popup.Navigate(page);
}
```... |
303,664 | <p>I am new to Python, and I'm working on writing some database code using the <code>cx_Oracle</code> module. In the <a href="http://cx-oracle.sourceforge.net/html/module.html" rel="nofollow noreferrer">cx_Oracle documentation</a> they have a code example like this:</p>
<pre><code>import sys
import cx_Oracle
connect... | [
{
"answer_id": 303673,
"author": "Matthew Christensen",
"author_id": 2123,
"author_profile": "https://Stackoverflow.com/users/2123",
"pm_score": 3,
"selected": false,
"text": "<p><a href=\"http://www.python.org/doc/2.5.2/tut/node7.html#SECTION007300000000000000000\" rel=\"nofollow norefe... | 2008/11/19 | [
"https://Stackoverflow.com/questions/303664",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31319/"
] | I am new to Python, and I'm working on writing some database code using the `cx_Oracle` module. In the [cx\_Oracle documentation](http://cx-oracle.sourceforge.net/html/module.html) they have a code example like this:
```
import sys
import cx_Oracle
connection = cx_Oracle.Connection("user/pw@tns")
cursor = connection.... | ```
error, = exc.args
```
This is a case of [sequence unpacking](http://docs.python.org/tutorial/datastructures.html#tuples-and-sequences).
A more readable way to write the same, and the style I personally favor, is:
```
[error] = exc.args
```
There are two bits required to understand the previous example:
1. Wh... |
303,668 | <p>Hey I usually run into a situation where I will create a class that should only be instantiated by one or a few classes. In this case I would make its constructor private and make it a friend class to the objects that should be able to instantiate it. For example (in C++):</p>
<pre><code>class CFoo
{
friend cla... | [
{
"answer_id": 303680,
"author": "g .",
"author_id": 6944,
"author_profile": "https://Stackoverflow.com/users/6944",
"pm_score": 1,
"selected": false,
"text": "<p>In C# depending on how the class is used, you could define one class within the scope of the other.</p>\n\n<pre><code>public ... | 2008/11/19 | [
"https://Stackoverflow.com/questions/303668",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13115/"
] | Hey I usually run into a situation where I will create a class that should only be instantiated by one or a few classes. In this case I would make its constructor private and make it a friend class to the objects that should be able to instantiate it. For example (in C++):
```
class CFoo
{
friend class CFoo;
... | The goal here seems to be that you cannot have a CFoo until you have a working CBar.
You could achieve the same with C# by having a private constructor for CFoo and then making a static method in CFoo that takes a CBar argument and calls said constructor and returns the new CFoo.
This would be something like the Syst... |
303,679 | <p>I would like to search my table having a column of first names and a column of last names. I currently accept a search term from a field and compare it against both columns, one at a time with </p>
<pre><code> select * from table where first_name like '%$search_term%' or
last_name like '%$search_term%';
</... | [
{
"answer_id": 303730,
"author": "Jack",
"author_id": 24998,
"author_profile": "https://Stackoverflow.com/users/24998",
"pm_score": 3,
"selected": false,
"text": "<pre><code>SELECT *,concat_ws(' ',first_name,last_name) AS whole_name FROM users HAVING whole_name LIKE '%$search_term%'\n</c... | 2008/11/19 | [
"https://Stackoverflow.com/questions/303679",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1149/"
] | I would like to search my table having a column of first names and a column of last names. I currently accept a search term from a field and compare it against both columns, one at a time with
```
select * from table where first_name like '%$search_term%' or
last_name like '%$search_term%';
```
This works ... | What you have should work but can be reduced to:
```
select * from table where concat_ws(' ',first_name,last_name)
like '%$search_term%';
```
Can you provide an example name and search term where this doesn't work? |
303,699 | <p>I have a text area and a function to do syntax highlighting on it. Right now it reads the entire RichTextBox. How would I get a string variable containing the current line? Below is the code i currently have.</p>
<pre><code>Private Sub HighLight()
Dim rm As System.Text.RegularExpressions.MatchCollection
Dim... | [
{
"answer_id": 303729,
"author": "JamesSugrue",
"author_id": 1075,
"author_profile": "https://Stackoverflow.com/users/1075",
"pm_score": 3,
"selected": true,
"text": "<p>Not tried it but:</p>\n\n<pre><code>rtbMain.Lines(lineNumber)\n</code></pre>\n\n<p>if not assign the Lines property to... | 2008/11/19 | [
"https://Stackoverflow.com/questions/303699",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39143/"
] | I have a text area and a function to do syntax highlighting on it. Right now it reads the entire RichTextBox. How would I get a string variable containing the current line? Below is the code i currently have.
```
Private Sub HighLight()
Dim rm As System.Text.RegularExpressions.MatchCollection
Dim m As System.T... | Not tried it but:
```
rtbMain.Lines(lineNumber)
```
if not assign the Lines property to an array and access the array element. |
303,700 | <p>Ok here's what I'm trying to do I want to write a class that inherits everything from the class ListItem</p>
<pre><code>class RealListItem : ListItem
{
public string anExtraStringINeed;
}
</code></pre>
<p>For some reason or another .net is treating all the members like they are private when I try to do this so... | [
{
"answer_id": 303717,
"author": "Charles Bretana",
"author_id": 32632,
"author_profile": "https://Stackoverflow.com/users/32632",
"pm_score": 4,
"selected": true,
"text": "<p>The System.Web.UI.Controls.ListItem class is \"sealed\"... That means you cannot inherit from it... </p>\n"
},... | 2008/11/19 | [
"https://Stackoverflow.com/questions/303700",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Ok here's what I'm trying to do I want to write a class that inherits everything from the class ListItem
```
class RealListItem : ListItem
{
public string anExtraStringINeed;
}
```
For some reason or another .net is treating all the members like they are private when I try to do this so my class is worthless.
I... | The System.Web.UI.Controls.ListItem class is "sealed"... That means you cannot inherit from it... |
303,712 | <p>In a Java application (JRE 1.5.0_12) on Windows XP, I call a native method:</p>
<pre><code>public native int attachImage( ... );
</code></pre>
<p>... which lives in a Visual C++ 6.0 .dll. It displays an application-modal window. Problem is, the application's tray icon doesn't respond to mouseclicks while this wind... | [
{
"answer_id": 303753,
"author": "James Van Huis",
"author_id": 31828,
"author_profile": "https://Stackoverflow.com/users/31828",
"pm_score": 2,
"selected": true,
"text": "<p>What GUI package are you using?</p>\n\n<p>You should be able to implement this without resorting to JNI calls.</p... | 2008/11/19 | [
"https://Stackoverflow.com/questions/303712",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35142/"
] | In a Java application (JRE 1.5.0\_12) on Windows XP, I call a native method:
```
public native int attachImage( ... );
```
... which lives in a Visual C++ 6.0 .dll. It displays an application-modal window. Problem is, the application's tray icon doesn't respond to mouseclicks while this window has focus. This is an ... | What GUI package are you using?
You should be able to implement this without resorting to JNI calls.
For instance, in SWT, you can open an application modal shell like this:
```
Shell shell = new Shell(display,SWT.APPLICATION_MODAL);
```
For swing, this would be:
```
dialog.setModalityType(Dialog.ModalityType.APP... |
303,720 | <p>I'm looking for something like <code>alert()</code>, but that doesn't "pause" the script.</p>
<p>I want to display an alert and allow the next command, a form <code>submit()</code>, to continue. So the page will be changing after the alert is displayed, but it won't wait till the user has clicked OK.</p>
<p>Is the... | [
{
"answer_id": 303735,
"author": "Aaron Powell",
"author_id": 11388,
"author_profile": "https://Stackoverflow.com/users/11388",
"pm_score": 7,
"selected": true,
"text": "<p>You could do the alert in a setTimeout (which a very short timeout) as setTimeout is asynchronous:</p>\n\n<pre><cod... | 2008/11/19 | [
"https://Stackoverflow.com/questions/303720",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5441/"
] | I'm looking for something like `alert()`, but that doesn't "pause" the script.
I want to display an alert and allow the next command, a form `submit()`, to continue. So the page will be changing after the alert is displayed, but it won't wait till the user has clicked OK.
Is there something like this or is it just on... | You could do the alert in a setTimeout (which a very short timeout) as setTimeout is asynchronous:
```
setTimeout("alert('hello world');", 1);
```
Or to do it properly you really show use a method rather than a string into your setTimeout:
```
setTimeout(function() { alert('hello world'); }, 1);
```
Otherwise you... |
303,726 | <p>I'm just playing around and I'm trying to grab information from websites. Unfortunately, with the following code:</p>
<pre><code>import sys
import socket
import re
from urlparse import urlsplit
url = urlsplit(sys.argv[1])
sock = socket.socket()
sock.connect((url[0] + '://' + url[1],80))
path = url[2]
if not path... | [
{
"answer_id": 303747,
"author": "Piotr Lesnicki",
"author_id": 38796,
"author_profile": "https://Stackoverflow.com/users/38796",
"pm_score": 1,
"selected": false,
"text": "<p>you forgot to resolve the hostname:</p>\n\n<pre><code>addr = socket.gethostbyname(url[1])\n...\nsock.connect((ad... | 2008/11/19 | [
"https://Stackoverflow.com/questions/303726",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2128/"
] | I'm just playing around and I'm trying to grab information from websites. Unfortunately, with the following code:
```
import sys
import socket
import re
from urlparse import urlsplit
url = urlsplit(sys.argv[1])
sock = socket.socket()
sock.connect((url[0] + '://' + url[1],80))
path = url[2]
if not path:
path = '/... | Please please please please please please please don't do this.
urllib and urllib2 are your friends.
Read [the "missing" urllib2 manual](http://www.voidspace.org.uk/python/articles/urllib2.shtml) if you are having trouble with it. |
303,745 | <p>This is probably a beginner question, but how do you set a recordset to a string variable? </p>
<p>Here is my code: </p>
<pre><code>Function getOffice (strname, uname)
strEmail = uname
WScript.Echo "email: " & strEmail
Dim objRoot : Set objRoot = GetObject("LDAP://RootDSE")
Dim objDomain : Set objDomain = G... | [
{
"answer_id": 303754,
"author": "BQ.",
"author_id": 4632,
"author_profile": "https://Stackoverflow.com/users/4632",
"pm_score": 0,
"selected": false,
"text": "<pre><code>Cstr(objRS.Fields(0))\n</code></pre>\n"
},
{
"answer_id": 303756,
"author": "EBGreen",
"author_id": 1... | 2008/11/19 | [
"https://Stackoverflow.com/questions/303745",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18853/"
] | This is probably a beginner question, but how do you set a recordset to a string variable?
Here is my code:
```
Function getOffice (strname, uname)
strEmail = uname
WScript.Echo "email: " & strEmail
Dim objRoot : Set objRoot = GetObject("LDAP://RootDSE")
Dim objDomain : Set objDomain = GetObject("LDAP://" & objR... | Set is only used for objects, it cannot be used on simple variables like strings.
Try this: (it also makes sure the recordset is not empty)
```
If objRS.RecordCount <> 0 Then
getOffice = CStr(objRS.Fields(0))
Else
getOffice = ""
End If
``` |
303,767 | <p>I need to grab the height of the window and the scrolling offset in jQuery, but I haven't had any luck finding this in the jQuery docs or Google.</p>
<p>I'm 90% certain there's a way to access height and scrollTop for an element (presumably including the window), but I just can't find the specific reference.</p>
| [
{
"answer_id": 303778,
"author": "Joey V.",
"author_id": 34462,
"author_profile": "https://Stackoverflow.com/users/34462",
"pm_score": 3,
"selected": false,
"text": "<pre><code>$(window).height()\n\n$(window).width()\n</code></pre>\n\n<p>There is also a plugin to jquery to determine elem... | 2008/11/19 | [
"https://Stackoverflow.com/questions/303767",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38666/"
] | I need to grab the height of the window and the scrolling offset in jQuery, but I haven't had any luck finding this in the jQuery docs or Google.
I'm 90% certain there's a way to access height and scrollTop for an element (presumably including the window), but I just can't find the specific reference. | From jQuery Docs:
```
const height = $(window).height();
const scrollTop = $(window).scrollTop();
```
<http://api.jquery.com/scrollTop/>
<http://api.jquery.com/height/> |
303,827 | <p>How do you access a MySQL relation using RoR?</p>
| [
{
"answer_id": 304134,
"author": "Toby Hede",
"author_id": 14971,
"author_profile": "https://Stackoverflow.com/users/14971",
"pm_score": 1,
"selected": false,
"text": "<p>Your question doesn't really make sense. </p>\n\n<p>Rails works with ActiveRecord which handles all sorts of complex ... | 2008/11/19 | [
"https://Stackoverflow.com/questions/303827",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39155/"
] | How do you access a MySQL relation using RoR? | Toby is right. You need to learn about table relationships using ActiveRecord.
**The gist**. You need to put the following codes in your models. Here is an example.
In User model:
```
has_many :addresses
```
In the Address model:
```
belongs_to :user
```
This is for a one to many relationship.
This [guide](ht... |
303,829 | <p>In Ruby we have the 'bang' method <code>capitalize!</code> which has the strange behavior of returning a <code>nil</code> if no changes to the string were made.</p>
<p>That means I can't chain this commands with other since it effectively destroys the chain if it returns <code>nil</code>.</p>
<p>What im trying to ... | [
{
"answer_id": 303851,
"author": "HanClinto",
"author_id": 26933,
"author_profile": "https://Stackoverflow.com/users/26933",
"pm_score": 5,
"selected": true,
"text": "<p>Use <a href=\"http://ruby-doc.org/core/classes/String.html#M000810\" rel=\"noreferrer\">.capitalize</a> (without the b... | 2008/11/19 | [
"https://Stackoverflow.com/questions/303829",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14587/"
] | In Ruby we have the 'bang' method `capitalize!` which has the strange behavior of returning a `nil` if no changes to the string were made.
That means I can't chain this commands with other since it effectively destroys the chain if it returns `nil`.
What im trying to do is something like this:
```
fname = fullname[... | Use [.capitalize](http://ruby-doc.org/core/classes/String.html#M000810) (without the bang) -- unless you actually need it to change the source. |
303,830 | <p>I have a body of text that I have to scan and each line contains at least 2 and sometimes four parts of information. The problem is that each line can be 1 out of 15-20 different actions.</p>
<p>in ruby the current code looks somewhat like this:</p>
<pre>
text.split("\n").each do |line| #around 20 times..
......... | [
{
"answer_id": 303903,
"author": "call me Steve",
"author_id": 24334,
"author_profile": "https://Stackoverflow.com/users/24334",
"pm_score": 4,
"selected": true,
"text": "<p>I would suggest </p>\n\n<ul>\n<li><a href=\"http://spirit.sourceforge.net/\" rel=\"nofollow noreferrer\">Boost Spi... | 2008/11/19 | [
"https://Stackoverflow.com/questions/303830",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39110/"
] | I have a body of text that I have to scan and each line contains at least 2 and sometimes four parts of information. The problem is that each line can be 1 out of 15-20 different actions.
in ruby the current code looks somewhat like this:
```
text.split("\n").each do |line| #around 20 times..
..............
... | I would suggest
* [Boost Spirit](http://spirit.sourceforge.net/) or
* [Antlr](http://www.antlr.org/) if the grammar is complex;
* [Xpressive](http://www.boost.org/doc/libs/1_37_0/doc/html/xpressive.html) if it's a little simpler,
* [Tokenizer](http://www.boost.org/doc/libs/1_37_0/libs/tokenizer/index.html) and handma... |
303,838 | <p>I am in the process of setting up CruiseControl.NET. The problem I am having is that I am running CC as a console application and when my build completes successfully and executes (using exec) it launches it within the CruiseControl DOS prompt. I am just using simple batch files to launch my app but having it run wi... | [
{
"answer_id": 303844,
"author": "e.James",
"author_id": 33686,
"author_profile": "https://Stackoverflow.com/users/33686",
"pm_score": 9,
"selected": true,
"text": "<p>I think this works:</p>\n\n<pre><code>start cmd.exe\n</code></pre>\n"
},
{
"answer_id": 303869,
"author": "B... | 2008/11/19 | [
"https://Stackoverflow.com/questions/303838",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25946/"
] | I am in the process of setting up CruiseControl.NET. The problem I am having is that I am running CC as a console application and when my build completes successfully and executes (using exec) it launches it within the CruiseControl DOS prompt. I am just using simple batch files to launch my app but having it run withi... | I think this works:
```
start cmd.exe
``` |
303,841 | <p>I am getting this warning:</p>
<pre><code>Use of uninitialized value in eval \"string\" at myscript.pl line 57.
</code></pre>
<p>When I run this code:</p>
<pre><code>eval;
{
`$client -f $confFile -i $inputFile -o $outputFile`;
};
if( $@ )
{
# error handling here ...
}
</code></pre>
<p>What is ca... | [
{
"answer_id": 303855,
"author": "Svante",
"author_id": 31615,
"author_profile": "https://Stackoverflow.com/users/31615",
"pm_score": 4,
"selected": true,
"text": "<p>There is a semicolon after <code>eval</code>.</p>\n"
},
{
"answer_id": 303990,
"author": "Leon Timmermans",
... | 2008/11/19 | [
"https://Stackoverflow.com/questions/303841",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39153/"
] | I am getting this warning:
```
Use of uninitialized value in eval \"string\" at myscript.pl line 57.
```
When I run this code:
```
eval;
{
`$client -f $confFile -i $inputFile -o $outputFile`;
};
if( $@ )
{
# error handling here ...
}
```
What is causing the error?
How can I fix the underlying ca... | There is a semicolon after `eval`. |
303,913 | <pre><code>File fil = new File("Tall.txt");
FileReader inputFil = new FileReader(fil);
BufferedReader in = new BufferedReader(inputFil);
int [] tall = new int [100];
String s =in.readLine();
while(s!=null)
{
int i = 0;
tall[i] = Integer.parseInt(s); //this is line 19
System.out.println(tall[i]);
s = ... | [
{
"answer_id": 303921,
"author": "erickson",
"author_id": 3474,
"author_profile": "https://Stackoverflow.com/users/3474",
"pm_score": 3,
"selected": false,
"text": "<p>You must have an empty line in your file.</p>\n\n<p>You may want to wrap your parseInt calls in a \"try\" block:</p>\n\n... | 2008/11/20 | [
"https://Stackoverflow.com/questions/303913",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37161/"
] | ```
File fil = new File("Tall.txt");
FileReader inputFil = new FileReader(fil);
BufferedReader in = new BufferedReader(inputFil);
int [] tall = new int [100];
String s =in.readLine();
while(s!=null)
{
int i = 0;
tall[i] = Integer.parseInt(s); //this is line 19
System.out.println(tall[i]);
s = in.read... | You might want to do something like this (if you're in java 5 & up)
```
Scanner scanner = new Scanner(new File("tall.txt"));
int [] tall = new int [100];
int i = 0;
while(scanner.hasNextInt()){
tall[i++] = scanner.nextInt();
}
``` |
303,916 | <p>I'm trying to wrap my head around the best way to use IoC within my application for dependency injection, however I have a little issue.</p>
<p>I am using a loose implementation of the MVP pattern with a WPF app. Essentially, a presenter class is instantiated, and a view and task (e.g. IEmployeeView and IEmployeeTa... | [
{
"answer_id": 303921,
"author": "erickson",
"author_id": 3474,
"author_profile": "https://Stackoverflow.com/users/3474",
"pm_score": 3,
"selected": false,
"text": "<p>You must have an empty line in your file.</p>\n\n<p>You may want to wrap your parseInt calls in a \"try\" block:</p>\n\n... | 2008/11/20 | [
"https://Stackoverflow.com/questions/303916",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18434/"
] | I'm trying to wrap my head around the best way to use IoC within my application for dependency injection, however I have a little issue.
I am using a loose implementation of the MVP pattern with a WPF app. Essentially, a presenter class is instantiated, and a view and task (e.g. IEmployeeView and IEmployeeTask for Emp... | You might want to do something like this (if you're in java 5 & up)
```
Scanner scanner = new Scanner(new File("tall.txt"));
int [] tall = new int [100];
int i = 0;
while(scanner.hasNextInt()){
tall[i++] = scanner.nextInt();
}
``` |
303,929 | <p>All I'm trying to do is display a separator (I've tried images & stylesheets) <strong>between</strong> the primary navigation menu items in Sharepoint. Here is what I want it to look like:</p>
<pre><code>Home | Menu1 | Menu2 | Menu3
</code></pre>
<p>When I attempt to use the StaticTopSeparatorImageUrl (using ... | [
{
"answer_id": 304210,
"author": "Nat",
"author_id": 13813,
"author_profile": "https://Stackoverflow.com/users/13813",
"pm_score": 2,
"selected": false,
"text": "<p>I prefer to inherit from the MossMenu that the SharePoint team released and customise the menu to producte <em>exactly</em>... | 2008/11/20 | [
"https://Stackoverflow.com/questions/303929",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/105/"
] | All I'm trying to do is display a separator (I've tried images & stylesheets) **between** the primary navigation menu items in Sharepoint. Here is what I want it to look like:
```
Home | Menu1 | Menu2 | Menu3
```
When I attempt to use the StaticTopSeparatorImageUrl (using a bar image) it results in the following:
`... | I prefer to inherit from the MossMenu that the SharePoint team released and customise the menu to producte *exactly* the html I want.
<http://blogs.msdn.com/sharepoint/archive/2006/12/02/customizing-the-wss-3-0-moss-2007-menu-control.aspx>
The instructions for [deployment](http://www.thesug.org/blogs/lsuslinky/Lists/... |
303,938 | <p>The question is this, why do I need to add an "import" directive on my <strong>Site.Master</strong> file to get Intellisense when the html helpers work without it.</p>
<p>Using a simple C# string extension method without a namespace == no problem. However, I wanted to put this extension in a namespace to be a good ... | [
{
"answer_id": 311653,
"author": "JSC",
"author_id": 37311,
"author_profile": "https://Stackoverflow.com/users/37311",
"pm_score": 0,
"selected": false,
"text": "<p>I agree that it is sometimes very annoying. But it is all with separation of concerns. You'll have to learn all your own an... | 2008/11/20 | [
"https://Stackoverflow.com/questions/303938",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2130585/"
] | The question is this, why do I need to add an "import" directive on my **Site.Master** file to get Intellisense when the html helpers work without it.
Using a simple C# string extension method without a namespace == no problem. However, I wanted to put this extension in a namespace to be a good programmer.
If I wrap ... | It's a VS limitation that when you add it to <namespaces> in **web.config**, IntelliSense doesn't show up.
But for the sake of completeness, I'll discuss the cause of it:
- Method 1 is not a correct way to do it at all, since **using** directives (**Imports** will compile down to **using** by **ASP.NET preprocessor**)... |
303,939 | <p>I'm wondering why styling an element within a specific class, like this:</p>
<pre><code>.reddish H1 { color: red }
</code></pre>
<p>is shown as an example of correct syntax in the CSS1 specification under Contextual selectors:</p>
<p><a href="http://www.w3.org/TR/2008/REC-CSS1-20080411/#class-as-selector" rel="no... | [
{
"answer_id": 304122,
"author": "philnash",
"author_id": 28376,
"author_profile": "https://Stackoverflow.com/users/28376",
"pm_score": 3,
"selected": true,
"text": "<p>That syntax is correct, but the example may have changed for a couple of reasons.</p>\n\n<p>Firstly it is not best prac... | 2008/11/20 | [
"https://Stackoverflow.com/questions/303939",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm wondering why styling an element within a specific class, like this:
```
.reddish H1 { color: red }
```
is shown as an example of correct syntax in the CSS1 specification under Contextual selectors:
[Cascading Style Sheets, level 1](http://www.w3.org/TR/2008/REC-CSS1-20080411/#class-as-selector)
but it's not s... | That syntax is correct, but the example may have changed for a couple of reasons.
Firstly it is not best practice to name classes by the description of what they do. In the case of `.reddish h1`, the example CSS shows that it is to be coloured red. However, if in a later design change the `h1` should in fact be blue t... |
303,955 | <p>I have a generic function which gets a interface as a type, now in one condition I have to create a new class depending on the interface. I have been thinking about it and a way to solve it would be to use an IoC but I was hoping there would be an other way because an IoC seems a bit like an overkill. </p>
<p>below... | [
{
"answer_id": 304123,
"author": "Nathan",
"author_id": 24954,
"author_profile": "https://Stackoverflow.com/users/24954",
"pm_score": 1,
"selected": false,
"text": "<p>If I understand what your question is, basically you want to do (in a sense) what RhinoMocks does, except that RhinoMock... | 2008/11/20 | [
"https://Stackoverflow.com/questions/303955",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/305008/"
] | I have a generic function which gets a interface as a type, now in one condition I have to create a new class depending on the interface. I have been thinking about it and a way to solve it would be to use an IoC but I was hoping there would be an other way because an IoC seems a bit like an overkill.
below is an att... | And why doesn't this work?
```
public class RepositoryManager<T> : IRepositoryManager<T> where T : Ixyz, new()
{
public T GetOrCreate(string id)
{
T item = (T)CreateNew(new T(), id);
return item;
}
}
```
An alternative, if you can't use new() is to pass in a delegate to create the object ... |
303,956 | <p>Is it possible using <a href="https://jquery.com/" rel="noreferrer">jQuery</a> to select all <code><a></code> links which href ends with "ABC"?</p>
<p>For example, if I want to find this link <code><a href="http://server/page.aspx?id=ABC"></code></p>
| [
{
"answer_id": 303961,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 12,
"selected": true,
"text": "<pre><code> $('a[href$=\"ABC\"]')...\n</code></pre>\n\n<p>Selector documentation can be found at <a href=\"http://doc... | 2008/11/20 | [
"https://Stackoverflow.com/questions/303956",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36036/"
] | Is it possible using [jQuery](https://jquery.com/) to select all `<a>` links which href ends with "ABC"?
For example, if I want to find this link `<a href="http://server/page.aspx?id=ABC">` | ```
$('a[href$="ABC"]')...
```
Selector documentation can be found at <http://docs.jquery.com/Selectors>
For attributes:
```
= is exactly equal
!= is not equal
^= is starts with
$= is ends with
*= is contains
~= is contains word
|= is starts with prefix (i.e., |= "prefix" matches "prefix-...")
``` |
303,970 | <p>I am having trouble constructing a single XPath statement to return two different sets of attributes. </p>
<p>For example take the following XML document:</p>
<pre><code><root>
<line name="one" alpha="a1" beta="b1"/>
<line name="two" alpha="a2" beta="b2"/>
<line name="three" alpha="a3" bet... | [
{
"answer_id": 303999,
"author": "Oppositional",
"author_id": 2029,
"author_profile": "https://Stackoverflow.com/users/2029",
"pm_score": 5,
"selected": true,
"text": "<p>By using the <code>|</code> operator in an XPath expression you can select several paths:</p>\n\n<pre><code>//@alpha ... | 2008/11/20 | [
"https://Stackoverflow.com/questions/303970",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3810/"
] | I am having trouble constructing a single XPath statement to return two different sets of attributes.
For example take the following XML document:
```
<root>
<line name="one" alpha="a1" beta="b1"/>
<line name="two" alpha="a2" beta="b2"/>
<line name="three" alpha="a3" beta="b3"/>
</root>
```
If I use the followi... | By using the `|` operator in an XPath expression you can select several paths:
```
//@alpha | //@beta
``` |
303,994 | <p>Is it possible for me to turn on audit logging on my mysql database?</p>
<p>I basically want to monitor all queries for an hour, and dump the log to a file.</p>
| [
{
"answer_id": 304008,
"author": "Robert Gamble",
"author_id": 25222,
"author_profile": "https://Stackoverflow.com/users/25222",
"pm_score": 8,
"selected": true,
"text": "<p>UPDATE: NO LONGER VALID FOR MYSQL 5.6+</p>\n<p>Start mysql with the --log option:</p>\n<pre><code>mysqld --log=log... | 2008/11/20 | [
"https://Stackoverflow.com/questions/303994",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1368/"
] | Is it possible for me to turn on audit logging on my mysql database?
I basically want to monitor all queries for an hour, and dump the log to a file. | UPDATE: NO LONGER VALID FOR MYSQL 5.6+
Start mysql with the --log option:
```
mysqld --log=log_file_name
```
or place the following in your `my.cnf` file:
```
log = log_file_name
```
Either one will log all queries to log\_file\_name.
You can also log only slow queries using the `--log-slow-queries` option inst... |
304,010 | <p>I have a multi-threaded application that is hanging on a call to _dl_sysinfo_int80(). According to gdb, all threads are stuck in this call.</p>
<p>The top of the stack trace looks like:</p>
<pre><code>#0 0x002727a2 in _dl_sysinfo_int80 () from /lib/ld-linux.so.2
#1 0x004f23de in __lll_mutex_lock_wait () from /l... | [
{
"answer_id": 304102,
"author": "SoapBox",
"author_id": 36384,
"author_profile": "https://Stackoverflow.com/users/36384",
"pm_score": 1,
"selected": false,
"text": "<p>int 80 is the software interrupt to make a kernel level system call. My guess is that pthread is doing a call in to th... | 2008/11/20 | [
"https://Stackoverflow.com/questions/304010",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1449/"
] | I have a multi-threaded application that is hanging on a call to \_dl\_sysinfo\_int80(). According to gdb, all threads are stuck in this call.
The top of the stack trace looks like:
```
#0 0x002727a2 in _dl_sysinfo_int80 () from /lib/ld-linux.so.2
#1 0x004f23de in __lll_mutex_lock_wait () from /lib/tls/libpthread.s... | int 80 is the software interrupt to make a kernel level system call. My guess is that pthread is doing a call in to the kernel that is hanging. There could be any number of reasons for why all of your threads would hang on a mutex like this:
- The mutex is locked by another thread that exited without releasing the ... |
304,011 | <p>What's the easiest way to truncate a C++ <code>float</code> variable that has a value of 0.6000002 to a value of 0.6000 and store it back in the variable?</p>
| [
{
"answer_id": 304013,
"author": "Brian R. Bondy",
"author_id": 3153,
"author_profile": "https://Stackoverflow.com/users/3153",
"pm_score": 4,
"selected": true,
"text": "<p>First it is important to know that floating point numbers are approximated. See the link provided by @Greg Hewgil... | 2008/11/20 | [
"https://Stackoverflow.com/questions/304011",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/191808/"
] | What's the easiest way to truncate a C++ `float` variable that has a value of 0.6000002 to a value of 0.6000 and store it back in the variable? | First it is important to know that floating point numbers are approximated. See the link provided by @Greg Hewgill to understand why this problem is not fully solvable.
But here are a couple of solutions to the problem that will probably meet your need:
Probably the better method but less efficient:
```
char sz[64]... |
304,041 | <p>I've been working with Vector2's and XNA, and I've come to find that calling the Normalize() member function on a Zero Vector normalizes it to a vector of {NaN, NaN}. This is all well and good, but in my case I'd prefer it instead just leave them as Zero Vectors.</p>
<p>Adding this code to my project enabled a cut... | [
{
"answer_id": 304077,
"author": "lomaxx",
"author_id": 493,
"author_profile": "https://Stackoverflow.com/users/493",
"pm_score": 0,
"selected": false,
"text": "<p>I'm not sure why your second code sample doesn't work but if the first lot of code does what you want you could simply work ... | 2008/11/20 | [
"https://Stackoverflow.com/questions/304041",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1388/"
] | I've been working with Vector2's and XNA, and I've come to find that calling the Normalize() member function on a Zero Vector normalizes it to a vector of {NaN, NaN}. This is all well and good, but in my case I'd prefer it instead just leave them as Zero Vectors.
Adding this code to my project enabled a cute extension... | This doesn't work because Vector 2 [is actually a struct](http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.vector2.aspx). This means it gets passed by value and you can't modify the caller's copy. I think the best you can do is the workaround specified by lomaxxx.
This illustrates why you should general... |
304,043 | <p>I'm trying to generate pairwise combinations of rows on based on their ids. SQLite version is 3.5.9. The table contents are the following:</p>
<pre><code>id|name|val
1|A|20
2|B|21
3|C|22
</code></pre>
<p>with table schema being:</p>
<pre><code>CREATE TABLE mytable (
id INTEGER NOT NULL,
name VARCHAR,
... | [
{
"answer_id": 304063,
"author": "tommym",
"author_id": 37607,
"author_profile": "https://Stackoverflow.com/users/37607",
"pm_score": 3,
"selected": true,
"text": "<p>Seems to be a bug in SQLite - the first result you posted is, as you suspected, wrong. I've tested it on both PG8.3 and ... | 2008/11/20 | [
"https://Stackoverflow.com/questions/304043",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39167/"
] | I'm trying to generate pairwise combinations of rows on based on their ids. SQLite version is 3.5.9. The table contents are the following:
```
id|name|val
1|A|20
2|B|21
3|C|22
```
with table schema being:
```
CREATE TABLE mytable (
id INTEGER NOT NULL,
name VARCHAR,
val INTEGER,
PRIMARY KEY (id... | Seems to be a bug in SQLite - the first result you posted is, as you suspected, wrong. I've tested it on both PG8.3 and sqlite3.6.4 on my workstation, couldn't reproduce. Got correct result in all cases. Might be linked to your sqlite version; try upgrading. |
304,044 | <p>I've got a fairly large MFC application that has just been migrated from VS6.0 to VS2008. It was a pretty painful process, but now I'd like to explore any managed-code options that may be available. I was able to successfully build the project using the /clr switch which seems to give me access to managed types. </p... | [
{
"answer_id": 304051,
"author": "Aaron Fischer",
"author_id": 5618,
"author_profile": "https://Stackoverflow.com/users/5618",
"pm_score": 1,
"selected": false,
"text": "<p>You can go from a system::String to CString because they share a common conversion (lptstr?) going to a System::Str... | 2008/11/20 | [
"https://Stackoverflow.com/questions/304044",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2376109/"
] | I've got a fairly large MFC application that has just been migrated from VS6.0 to VS2008. It was a pretty painful process, but now I'd like to explore any managed-code options that may be available. I was able to successfully build the project using the /clr switch which seems to give me access to managed types.
I'd ... | Option 3 works for pretty much the same reason option 2 does. CString::operator= has an overload for System::String. Don't forget that the assignment operator can do a lot more than copy a reference.
This page:
[How to: Convert Between Various String Types](http://msdn.microsoft.com/en-us/library/ms235631.aspx)
is *ve... |
304,049 | <p>Is there anyone out there using iPython with emacs 23? The documents on the emacs wiki are a bit of a muddle and I would be interested in hearing from anyone using emacs for Python development. Do you use the download python-mode and ipython.el? What do you recommend?</p>
| [
{
"answer_id": 304202,
"author": "JimB",
"author_id": 32880,
"author_profile": "https://Stackoverflow.com/users/32880",
"pm_score": 2,
"selected": false,
"text": "<p>never used it myself, but I do follow the ipython mailing list, and there was a <a href=\"http://lists.ipython.scipy.org/p... | 2008/11/20 | [
"https://Stackoverflow.com/questions/304049",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37370/"
] | Is there anyone out there using iPython with emacs 23? The documents on the emacs wiki are a bit of a muddle and I would be interested in hearing from anyone using emacs for Python development. Do you use the download python-mode and ipython.el? What do you recommend? | I got it working quite well with emacs 23. The only open issue is the focus not returning to the python buffer after sending the buffer to the iPython interpreter.
<http://www.emacswiki.org/emacs/PythonMode#toc10>
```
(setq load-path
(append (list nil
"~/.emacs.d/python-mode-1.0/"
... |
304,081 | <p>I'm building a winForms app in NET3.5SP1 using VS2008Express. Am trying to deserialize an object using the System.Web.Script.Serialization library.</p>
<p>The error is: Type 'jsonWinForm.Category' is not supported for deserialization of an array.</p>
<p>Cheers!</p>
<pre><code>using System;
using System.Collectio... | [
{
"answer_id": 304157,
"author": "Dave Mateer",
"author_id": 26086,
"author_profile": "https://Stackoverflow.com/users/26086",
"pm_score": 4,
"selected": false,
"text": "<p>I found my error.. should be:</p>\n\n<p>Cheers </p>\n\n<pre><code>JavaScriptSerializer serializer = new JavaScript... | 2008/11/20 | [
"https://Stackoverflow.com/questions/304081",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26086/"
] | I'm building a winForms app in NET3.5SP1 using VS2008Express. Am trying to deserialize an object using the System.Web.Script.Serialization library.
The error is: Type 'jsonWinForm.Category' is not supported for deserialization of an array.
Cheers!
```
using System;
using System.Collections.Generic;
using System.Comp... | It's great you found your error. If you are looking for another tool for JSON serialization you might want to try [JSON.Net](http://james.newtonking.com/pages/json-net.aspx). |
304,088 | <p>The comment to <a href="https://stackoverflow.com/questions/200090/how-do-you-convert-a-c-string-to-an-int#200099">this answer</a> got me wondering. I've always thought that C was a proper subset of C++, that is, any valid C code is valid C++ code by extension. Am I wrong about that? Is it possible to write a val... | [
{
"answer_id": 304091,
"author": "Brian R. Bondy",
"author_id": 3153,
"author_profile": "https://Stackoverflow.com/users/3153",
"pm_score": 6,
"selected": true,
"text": "<p>In general, yes C code is considered C++ code.</p>\n\n<p>But C is not a proper subset in a strict sense. There are... | 2008/11/20 | [
"https://Stackoverflow.com/questions/304088",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1288/"
] | The comment to [this answer](https://stackoverflow.com/questions/200090/how-do-you-convert-a-c-string-to-an-int#200099) got me wondering. I've always thought that C was a proper subset of C++, that is, any valid C code is valid C++ code by extension. Am I wrong about that? Is it possible to write a valid C program that... | In general, yes C code is considered C++ code.
But C is not a proper subset in a strict sense. There are a couple of exceptions.
Here are some valid things in C that are not valid in C++:
```
int *new;//<-- new is not a keyword in C
char *p = malloc(1024); //void * to char* without cast
```
There are more exampl... |
304,093 | <p>I was wondering why <code>shared_ptr</code> doesn't have an implicit constructor. The fact it doesn't is alluded to here: <a href="https://stackoverflow.com/questions/142391/getting-a-boostsharedptr-for-this">Getting a boost::shared_ptr for this</a></p>
<p>(I figured out the reason but thought it would be a fun que... | [
{
"answer_id": 304132,
"author": "Alex Lim",
"author_id": 39174,
"author_profile": "https://Stackoverflow.com/users/39174",
"pm_score": 2,
"selected": false,
"text": "<p>Long time lurker, and a 3rd year soft eng student here,\nHaphazard guess would be, to stop you from attempting to conv... | 2008/11/20 | [
"https://Stackoverflow.com/questions/304093",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3594/"
] | I was wondering why `shared_ptr` doesn't have an implicit constructor. The fact it doesn't is alluded to here: [Getting a boost::shared\_ptr for this](https://stackoverflow.com/questions/142391/getting-a-boostsharedptr-for-this)
(I figured out the reason but thought it would be a fun question to post anyway.)
```
#in... | In this case, the shared\_ptr would attempt to free your stack allocated int. You wouldn't want that, so the explicit constructor is there to make you think about it. |
304,109 | <p>Having the window handle for an open application, I'm able to use the GetWindowText function to retrieve the text from the title bar of the app. I would like to take this a step farther and retrieve the icon associated with the same app. </p>
<p>How might I go about doing this? I looked through what I thought wo... | [
{
"answer_id": 304120,
"author": "Adam Davis",
"author_id": 2915,
"author_profile": "https://Stackoverflow.com/users/2915",
"pm_score": 5,
"selected": true,
"text": "<pre><code>Icon ico = Icon.ExtractAssociatedIcon(theProcess.MainModule.FileName);\n</code></pre>\n\n<p><a href=\"https://s... | 2008/11/20 | [
"https://Stackoverflow.com/questions/304109",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39171/"
] | Having the window handle for an open application, I'm able to use the GetWindowText function to retrieve the text from the title bar of the app. I would like to take this a step farther and retrieve the icon associated with the same app.
How might I go about doing this? I looked through what I thought would be the re... | ```
Icon ico = Icon.ExtractAssociatedIcon(theProcess.MainModule.FileName);
```
[From TheSoftwareJedi](https://stackoverflow.com/questions/203456/how-can-i-get-the-icon-from-the-executable-file-only-having-an-instance-of-its#203490)
Initially this appears to be an exact duplicate of [How can I get the icon from the e... |
304,129 | <p>How do I return a constant from an sql statement? </p>
<p>For example how would I change the code below so "my message" would return if my (boolean expression) was true</p>
<pre><code>if (my boolean expression)
"my message"
else
select top 1 name from people;
</code></pre>
<p>I am using ms sql 2000</p>
| [
{
"answer_id": 304138,
"author": "Ned Batchelder",
"author_id": 14343,
"author_profile": "https://Stackoverflow.com/users/14343",
"pm_score": 6,
"selected": true,
"text": "<p>Did you try:</p>\n\n<pre><code>select 'my message';\n</code></pre>\n"
},
{
"answer_id": 304149,
"auth... | 2008/11/20 | [
"https://Stackoverflow.com/questions/304129",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1632/"
] | How do I return a constant from an sql statement?
For example how would I change the code below so "my message" would return if my (boolean expression) was true
```
if (my boolean expression)
"my message"
else
select top 1 name from people;
```
I am using ms sql 2000 | Did you try:
```
select 'my message';
``` |