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 |
|---|---|---|---|---|---|---|
397,927 | <p>In openmoko (stable hybrid release, SHR), how do you programatically turn-off the screensaver (the dimmed/blank screen after a few seconds of inactivity) just while your app is running?</p>
| [
{
"answer_id": 398343,
"author": "codelogic",
"author_id": 43427,
"author_profile": "https://Stackoverflow.com/users/43427",
"pm_score": 1,
"selected": false,
"text": "<p>In X, you can run</p>\n\n<pre><code>xset s off\n</code></pre>\n\n<p>to turn off the screensaver. Similarly gnome/free... | 2008/12/29 | [
"https://Stackoverflow.com/questions/397927",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46478/"
] | In openmoko (stable hybrid release, SHR), how do you programatically turn-off the screensaver (the dimmed/blank screen after a few seconds of inactivity) just while your app is running? | In X, you can run
```
xset s off
```
to turn off the screensaver. Similarly gnome/freedesktop exposes a DBUS API to control and inhibit screensaver mode. I don't know if OpenMoko supports the freedesktop spec, but if it does you should be able to use DBUS directly. You can see how Totem does it [here](http://svn.gno... |
397,944 | <p>For the following code:</p>
<pre><code><% foreach (Entities.Core.Location loc in locations){ %>
<div class="place_meta">
<img src="~/static/images/stars/star_25_sml.gif" runat="server" class="star_rating"/>
</div>
<% }; %>
</code></pre>
<p>I would like to display the star rating image... | [
{
"answer_id": 397974,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 0,
"selected": false,
"text": "<p>I would remove the <code>runat=\"server\"</code> attribute and reference the image using a relative path (or the ful... | 2008/12/29 | [
"https://Stackoverflow.com/questions/397944",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32372/"
] | For the following code:
```
<% foreach (Entities.Core.Location loc in locations){ %>
<div class="place_meta">
<img src="~/static/images/stars/star_25_sml.gif" runat="server" class="star_rating"/>
</div>
<% }; %>
```
I would like to display the star rating image for each location object displayed. However, only the f... | You can't use server controls within an inline loop, because ASP.NET needs to be able to uniquely identify each control to process it. The for... loop prevents this. The easiest and cleanest way is to use a Repeater control and bind your collection to it (in code-behind). Set the URL property in the bind event handler,... |
397,955 | <p>I have an xml in which i have stored some html under comments like this</p>
<pre><code> <root>
<node>
<!--
<a href="mailto:some@one.com"> Mail me </a>
-->
</node>
</root>
</code></pre>
<p>now in my Transform Xslt code of mine i am giving XPathNa... | [
{
"answer_id": 399600,
"author": "diciu",
"author_id": 2811,
"author_profile": "https://Stackoverflow.com/users/2811",
"pm_score": 3,
"selected": true,
"text": "<p>When part of the comment the node looses its special meaning - thus \"href\" is not a node so you cannot use it to select st... | 2008/12/29 | [
"https://Stackoverflow.com/questions/397955",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6351/"
] | I have an xml in which i have stored some html under comments like this
```
<root>
<node>
<!--
<a href="mailto:some@one.com"> Mail me </a>
-->
</node>
</root>
```
now in my Transform Xslt code of mine i am giving XPathNavigator which is pointing to node and in xslt i am passing the comme... | When part of the comment the node looses its special meaning - thus "href" is not a node so you cannot use it to select stuff.
You can select comments like this:
```
<xsl:template match="/">
<xsl:value-of select="/root/node/comment()" disable-output-escaping="yes"/>
</xsl:template>
```
This will produce based on yo... |
397,980 | <p>I am building a calculator in C#.
I am not sure what the best way is to have it increment a number in an array every time the button is pressed. Here is one of my current button event handler methods:</p>
<pre><code> //Assign button '2' to 2 with array address of 1
private void num2_Click(object sender, Eve... | [
{
"answer_id": 409435,
"author": "Tim Scott",
"author_id": 29493,
"author_profile": "https://Stackoverflow.com/users/29493",
"pm_score": 3,
"selected": true,
"text": "<p>Use UnitOfWorkApplication. <a href=\"http://lunaverse.wordpress.com/2008/07/13/rhino-commons-with-ms-mvc/\" rel=\"nof... | 2008/12/29 | [
"https://Stackoverflow.com/questions/397980",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49549/"
] | I am building a calculator in C#.
I am not sure what the best way is to have it increment a number in an array every time the button is pressed. Here is one of my current button event handler methods:
```
//Assign button '2' to 2 with array address of 1
private void num2_Click(object sender, EventArgs e)
... | Use UnitOfWorkApplication. [Here's how](http://lunaverse.wordpress.com/2008/07/13/rhino-commons-with-ms-mvc/). |
397,998 | <p>I have a table (T1) in t-sql with a column (C1) that contains almost 30,000 rows of data.
Each column contains values like MSA123, MSA245, MSA299, etc. I need to run an update script so the MSA part of the string changes to CMA. How can I do this?</p>
| [
{
"answer_id": 398003,
"author": "Kon",
"author_id": 22303,
"author_profile": "https://Stackoverflow.com/users/22303",
"pm_score": 1,
"selected": false,
"text": "<p>You can use <a href=\"http://msdn.microsoft.com/en-us/library/ms186862.aspx\" rel=\"nofollow noreferrer\">REPLACE</a> funct... | 2008/12/29 | [
"https://Stackoverflow.com/questions/397998",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33690/"
] | I have a table (T1) in t-sql with a column (C1) that contains almost 30,000 rows of data.
Each column contains values like MSA123, MSA245, MSA299, etc. I need to run an update script so the MSA part of the string changes to CMA. How can I do this? | ```
update t1
set c1 = replace(c1,"MSA","CMA")
where c1 like "MSA%"
``` |
398,008 | <p>We have a rails application in subversion that we deploy with Capistrano but have noticed that we can access the files in '/.svn', which presents a security concern. </p>
<p>I wanted to know what the best way to do this. A few ideas:</p>
<ul>
<li>Global Apache configuration to deny access </li>
<li>Adding .htacce... | [
{
"answer_id": 398064,
"author": "Vinko Vrsalovic",
"author_id": 5190,
"author_profile": "https://Stackoverflow.com/users/5190",
"pm_score": 7,
"selected": true,
"text": "<p>The best option is to use Apache configuration.</p>\n\n<p>Using htaccess or global configuration depends mainly on... | 2008/12/29 | [
"https://Stackoverflow.com/questions/398008",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19839/"
] | We have a rails application in subversion that we deploy with Capistrano but have noticed that we can access the files in '/.svn', which presents a security concern.
I wanted to know what the best way to do this. A few ideas:
* Global Apache configuration to deny access
* Adding .htaccess files in the public folder ... | The best option is to use Apache configuration.
Using htaccess or global configuration depends mainly on if you control your server.
If you do, you can use something like
```
<DirectoryMatch .*\.svn/.*>
Deny From All
</DirectoryMatch>
```
If you don't, you can do something similar in .htaccess files with File... |
398,010 | <p>I have a project in Xcode that contains multiple targets. One of these builds a sync schema bundle, and another one builds a Foundation command-line tool that initiates a sync session using the schema defined in the bundle.</p>
<p>The schema bundle template creates <code>Schema-strings.h</code> and <code>Schema-str... | [
{
"answer_id": 398064,
"author": "Vinko Vrsalovic",
"author_id": 5190,
"author_profile": "https://Stackoverflow.com/users/5190",
"pm_score": 7,
"selected": true,
"text": "<p>The best option is to use Apache configuration.</p>\n\n<p>Using htaccess or global configuration depends mainly on... | 2008/12/29 | [
"https://Stackoverflow.com/questions/398010",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2399475/"
] | I have a project in Xcode that contains multiple targets. One of these builds a sync schema bundle, and another one builds a Foundation command-line tool that initiates a sync session using the schema defined in the bundle.
The schema bundle template creates `Schema-strings.h` and `Schema-strings.m` files, which conta... | The best option is to use Apache configuration.
Using htaccess or global configuration depends mainly on if you control your server.
If you do, you can use something like
```
<DirectoryMatch .*\.svn/.*>
Deny From All
</DirectoryMatch>
```
If you don't, you can do something similar in .htaccess files with File... |
398,021 | <p>I want to change the text of a radio button (HTML element), not an ASP.NET component.</p>
<p>How can I change it from ASP.NET?</p>
| [
{
"answer_id": 398026,
"author": "Dillie-O",
"author_id": 71,
"author_profile": "https://Stackoverflow.com/users/71",
"pm_score": 5,
"selected": true,
"text": "<p>Add a simple:</p>\n\n<pre><code>runat=\"server\"\n</code></pre>\n\n<p>to your HTML tag and it will allow a few of the propert... | 2008/12/29 | [
"https://Stackoverflow.com/questions/398021",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44973/"
] | I want to change the text of a radio button (HTML element), not an ASP.NET component.
How can I change it from ASP.NET? | Add a simple:
```
runat="server"
```
to your HTML tag and it will allow a few of the properties to be modified through code behind.
These are known as "hybrid controls." |
398,032 | <p>What API or tools can I use to query the capabilities of the system and choose the most appropriate on for putting the PC to Sleep, Hibernate or shutdown mode?</p>
<p>Thanks for any pointers.</p>
| [
{
"answer_id": 398062,
"author": "Leon Tayson",
"author_id": 18413,
"author_profile": "https://Stackoverflow.com/users/18413",
"pm_score": 4,
"selected": true,
"text": "<p>Look at SystemInformation.PowerStatus, then you can call Application.SetSuspendState to put the PC to Sleep or Hiber... | 2008/12/29 | [
"https://Stackoverflow.com/questions/398032",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3811/"
] | What API or tools can I use to query the capabilities of the system and choose the most appropriate on for putting the PC to Sleep, Hibernate or shutdown mode?
Thanks for any pointers. | Look at SystemInformation.PowerStatus, then you can call Application.SetSuspendState to put the PC to Sleep or Hibernate like:
```
Application.SetSuspendState(PowerState.Hibernate, true, true);
``` |
398,100 | <p>It's quite possible a question like this has been asked before, but I can't think of the terms to search for.</p>
<p>I'm working on a photo gallery application, and want to display 9 thumbnails showing the context of the current photo being shown (in a 3x3 grid with the current photo in the centre, unless the curre... | [
{
"answer_id": 398115,
"author": "Charles Bretana",
"author_id": 32632,
"author_profile": "https://Stackoverflow.com/users/32632",
"pm_score": 0,
"selected": false,
"text": "<p>This is standard \"Row ordering\" problem... If your database has rowId capability you can use that, otherwise ... | 2008/12/29 | [
"https://Stackoverflow.com/questions/398100",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20972/"
] | It's quite possible a question like this has been asked before, but I can't think of the terms to search for.
I'm working on a photo gallery application, and want to display 9 thumbnails showing the context of the current photo being shown (in a 3x3 grid with the current photo in the centre, unless the current photo i... | Probably could just use a UNION, and then trim off the extra results in the procedural code that displays the results (as this will return 20 rows in the non-edge cases):
```
(SELECT
*
FROM photos
WHERE ID < #current_id#
ORDER BY ID DESC LIMIT 10)
UNION
(SELECT *
FROM photos
WHERE ID >= #current_i... |
398,110 | <p>How can you modify the URL for the current page that gets passed to Google Analytics? </p>
<p>(I need to strip the extensions from certain pages because for different cases a page can be requested with or without it and GA sees this as two different pages.) </p>
<p>For example, if the page URL is <code>http://my... | [
{
"answer_id": 398548,
"author": "Athena",
"author_id": 17846,
"author_profile": "https://Stackoverflow.com/users/17846",
"pm_score": 4,
"selected": true,
"text": "<p>Two possibilities come to mind: </p>\n\n<ol>\n<li><p>it can take a while, up to about 24 hours, for visits to be reflecte... | 2008/12/29 | [
"https://Stackoverflow.com/questions/398110",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18228/"
] | How can you modify the URL for the current page that gets passed to Google Analytics?
(I need to strip the extensions from certain pages because for different cases a page can be requested with or without it and GA sees this as two different pages.)
For example, if the page URL is `http://mysite/cake/ilikecake.html... | Two possibilities come to mind:
1. it can take a while, up to about 24 hours, for visits to be reflected in the Analytics statistics. How long ago did you make your change?
2. try beginning the pathname with a "/", so
```
pageTracker._trackPageview('/cake/ilikecake');
```
and then wait a bit, as per the first ite... |
398,111 | <p>What's a surefire way of detecting whether a user has Firebug enabled?</p>
| [
{
"answer_id": 398116,
"author": "ceejayoz",
"author_id": 1902010,
"author_profile": "https://Stackoverflow.com/users/1902010",
"pm_score": 4,
"selected": false,
"text": "<p>If firebug is enabled, window.console will not be undefined. console.firebug will return the version number.</p>\n... | 2008/12/29 | [
"https://Stackoverflow.com/questions/398111",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5123/"
] | What's a surefire way of detecting whether a user has Firebug enabled? | Original answer:
================
Check for the `console` object (created only with Firebug), like such:
```
if (window.console && window.console.firebug) {
//Firebug is enabled
}
```
---
Update (January 2012):
======================
The Firebug developers have [decided to remove `window.console.firebug`](http:... |
398,117 | <p>Given two shorts (<code>System.Int16</code>)</p>
<pre><code>short left = short.MaxValue;
short right = 1;
</code></pre>
<p>I want to get an <code>OverflowException</code> when adding them.</p>
<pre><code>checked(left+right)
</code></pre>
<p>does not work, because the result of <code>left+right</code> is an <code... | [
{
"answer_id": 398155,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 3,
"selected": true,
"text": "<p>The problem is that the addition <em>is</em> being done as short + short (which presumably exists in IL even if it doe... | 2008/12/29 | [
"https://Stackoverflow.com/questions/398117",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48722/"
] | Given two shorts (`System.Int16`)
```
short left = short.MaxValue;
short right = 1;
```
I want to get an `OverflowException` when adding them.
```
checked(left+right)
```
does not work, because the result of `left+right` is an `Int32`.
```
checked((short)(left+right))
```
works as expected.
My problem is that... | The problem is that the addition *is* being done as short + short (which presumably exists in IL even if it doesn't exist in C#) - and then the conversion is performed separately. This is shown by this complete program - even without the conversion, the result is -32768:
```
using System;
using System.Linq.Expressions... |
398,137 | <p>Hi What is the best way to do nested try & finally statements in delphi?</p>
<pre><code>var cds1 : TClientDataSet;
cds2 : TClientDataSet;
cds3 : TClientDataSet;
cds4 : TClientDataSet;
begin
cds1 := TClientDataSet.Create(application );
try
cds2 := TClientDataSet.Create(applicati... | [
{
"answer_id": 398161,
"author": "skamradt",
"author_id": 9217,
"author_profile": "https://Stackoverflow.com/users/9217",
"pm_score": 6,
"selected": true,
"text": "<p>how about the following:</p>\n\n<pre><code>var cds1 : TClientDataSet;\n cds2 : TClientDataSet;\n cds3 : TClientD... | 2008/12/29 | [
"https://Stackoverflow.com/questions/398137",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17560/"
] | Hi What is the best way to do nested try & finally statements in delphi?
```
var cds1 : TClientDataSet;
cds2 : TClientDataSet;
cds3 : TClientDataSet;
cds4 : TClientDataSet;
begin
cds1 := TClientDataSet.Create(application );
try
cds2 := TClientDataSet.Create(application );
try
... | how about the following:
```
var cds1 : TClientDataSet;
cds2 : TClientDataSet;
cds3 : TClientDataSet;
cds4 : TClientDataSet;
begin
cds1 := Nil;
cds2 := Nil;
cds3 := Nil;
cds4 := Nil;
try
cds1 := TClientDataSet.Create(nil);
cds2 := TClientDataSet.Create(ni... |
398,144 | <p>I'm baffled how to do this.</p>
<p>I need to take a datetime object and get the duration in hours, days, whatever, to the current time.</p>
<p>Thank you.</p>
| [
{
"answer_id": 398157,
"author": "Charlie Martin",
"author_id": 35092,
"author_profile": "https://Stackoverflow.com/users/35092",
"pm_score": 2,
"selected": false,
"text": "<p>You want the <a href=\"http://www.ruby-doc.org/core/classes/Time.html\" rel=\"nofollow noreferrer\">Time</a> cla... | 2008/12/29 | [
"https://Stackoverflow.com/questions/398144",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33287/"
] | I'm baffled how to do this.
I need to take a datetime object and get the duration in hours, days, whatever, to the current time.
Thank you. | Getting the duration in seconds is easy:
```
>> foo = Time.new
=> Mon Dec 29 18:23:51 +0100 2008
>> bar = Time.new
=> Mon Dec 29 18:23:56 +0100 2008
>> print bar - foo
5.104063=> nil
```
So, a little over five seconds.
But to present this in a somewhat more human-friendly form, you'll need a third-party addition, l... |
398,163 | <p>Let's say I have my pizza application with Topping and Pizza classes and they show in Django Admin like this:</p>
<pre><code>PizzaApp
-
Toppings >>>>>>>>>> Add / Change
Pizzas >>>>>>>>>> Add / Change
</code></pre>
<p>But I want them... | [
{
"answer_id": 398256,
"author": "Jeff",
"author_id": 33775,
"author_profile": "https://Stackoverflow.com/users/33775",
"pm_score": 0,
"selected": false,
"text": "<p>This is just a wild stab in the dark, but is there any chance that the order in which you call admin.site.register(< Mo... | 2008/12/29 | [
"https://Stackoverflow.com/questions/398163",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49898/"
] | Let's say I have my pizza application with Topping and Pizza classes and they show in Django Admin like this:
```
PizzaApp
-
Toppings >>>>>>>>>> Add / Change
Pizzas >>>>>>>>>> Add / Change
```
But I want them like this:
```
PizzaApp
-
Pizzas >>>>>>>>>> Add / Change
Toppings ... | This is actually covered at the very bottom of [Writing your first Django app, part 7](https://docs.djangoproject.com/en/3.0/intro/tutorial07/).
Here's the relevant section:
>
> **Customize the admin index page**
>
>
> On a similar note, you might want to
> customize the look and feel of the
> Django admin index... |
398,170 | <p>Simple question... is there a way to change the Assembly Version of a compiled .NET assembly?</p>
<p>I'd actually be fine with a way to change the Assembly File Version.</p>
| [
{
"answer_id": 398195,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 3,
"selected": false,
"text": "<p>Why do you want to do this? If it's so that another application can use it, you might want to look into <a href=\"htt... | 2008/12/29 | [
"https://Stackoverflow.com/questions/398170",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2848/"
] | Simple question... is there a way to change the Assembly Version of a compiled .NET assembly?
I'd actually be fine with a way to change the Assembly File Version. | You can use [ILMerge](https://github.com/dotnet/ILMerge):
```
ILMerge.exe Foo.dll /ver:1.2.3.4 /out:Foo2.dll
```
A valid reason to do this is to increment the assembly version in a build in you find breaking changes (using NDepend for example). That way if there are no breaking changes the assembly version stays the ... |
398,179 | <p>I just installed the FindBugs plugin for Eclipse, with the hope that it will help me find SQL injection vulnerabilities in my code. However, it doesn't seem to be finding anything, even when I deliberately put some in. </p>
<p>In the following examples, assume <code>staticFinalBaseQuery</code> is declared as foll... | [
{
"answer_id": 398650,
"author": "Adam Hawkes",
"author_id": 6703,
"author_profile": "https://Stackoverflow.com/users/6703",
"pm_score": 3,
"selected": true,
"text": "<p>It is hard to distinguish between safe code and unsafe code here. Sure, userInputfilterString <em>may</em> be unsafe, ... | 2008/12/29 | [
"https://Stackoverflow.com/questions/398179",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4257/"
] | I just installed the FindBugs plugin for Eclipse, with the hope that it will help me find SQL injection vulnerabilities in my code. However, it doesn't seem to be finding anything, even when I deliberately put some in.
In the following examples, assume `staticFinalBaseQuery` is declared as follows:
public static fin... | It is hard to distinguish between safe code and unsafe code here. Sure, userInputfilterString *may* be unsafe, but it is impossible to determine this at compile time. However, the single-quote character in a string concatenation is a tell-tale sign of using inject-able code. That's why FindBugs is triggering on the lin... |
398,188 | <p>We're having a small issue and could use some help - we have the need to combine multiple resultsets from one stored procedure into one resultset (the limitation of our Java reporting framework). We've looked at Union, etc. but the problem is that the stored procedure resultsets are multiple crosstab results and the... | [
{
"answer_id": 398196,
"author": "Charles Bretana",
"author_id": 32632,
"author_profile": "https://Stackoverflow.com/users/32632",
"pm_score": 2,
"selected": true,
"text": "<p>Your question does not specify which database vendor, or which client application framework you are using, but m... | 2008/12/29 | [
"https://Stackoverflow.com/questions/398188",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35309/"
] | We're having a small issue and could use some help - we have the need to combine multiple resultsets from one stored procedure into one resultset (the limitation of our Java reporting framework). We've looked at Union, etc. but the problem is that the stored procedure resultsets are multiple crosstab results and the (1... | Your question does not specify which database vendor, or which client application framework you are using, but most databases with stored procs have the capability to return multiple resultsets, and the few client frameworks I am familiar with (VB6, C++, .Net, etc.) all have the capability to retrieve these multiple re... |
398,203 | <p>One of my coworkers is having a problem pushing changes from git on his machine. If he logs into another machine, he can push just fine - but from his machine, when he tries to push he gets the following error</p>
<pre>
D:\Projects\test1\best-practices>git push
Counting objects: 4, done.
Compressing ob... | [
{
"answer_id": 398222,
"author": "Otto",
"author_id": 9594,
"author_profile": "https://Stackoverflow.com/users/9594",
"pm_score": 0,
"selected": false,
"text": "<p>Maybe he's created a branch in his local repo that already exists on the server and that ref can't be updated because it was... | 2008/12/29 | [
"https://Stackoverflow.com/questions/398203",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1322/"
] | One of my coworkers is having a problem pushing changes from git on his machine. If he logs into another machine, he can push just fine - but from his machine, when he tries to push he gets the following error
```
D:\Projects\test1\best-practices>git push
Counting objects: 4, done.
Compressing objects: 10... | I'm not a windows user so I'm stabbing in the dark a little here. It looks like the remote file system is mounted and you're just pushing to that (not using ssh:// or git://). Is that FS somehow mounted readonly? Can he create/modify files on there (outside of `git`)? |
398,212 | <p>I normally use C# and I'm attempting to convert a qbasic programmer to the joys of object oriented programming by easing him into VB 2005.</p>
<p>Below is a extremely simplified version of what I'm trying to accomplish. It successfully compiles, but all members in the array of card objects are set to "Nothing". T... | [
{
"answer_id": 398217,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 3,
"selected": true,
"text": "<p>Yes, when you create an array in .NET, every element of the array is set to the default value of the element type - wh... | 2008/12/29 | [
"https://Stackoverflow.com/questions/398212",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18043/"
] | I normally use C# and I'm attempting to convert a qbasic programmer to the joys of object oriented programming by easing him into VB 2005.
Below is a extremely simplified version of what I'm trying to accomplish. It successfully compiles, but all members in the array of card objects are set to "Nothing". The test line... | Yes, when you create an array in .NET, every element of the array is set to the default value of the element type - which is null/Nothing for classes.
You need to populate the array before you use it (or expect it to be full of null references).
Note that this would have behaved exactly the same way in C#.
EDIT: As ... |
398,221 | <p>A <a href="https://stackoverflow.com/questions/397817/unable-to-find-perl-modules-in-intrepid-ibex-ubuntu">recent question</a> here on SO got me thinking.</p>
<p>On most Linux distributions that I tried, some Perl modules would be available through the package manager. Others, of course, not. For quite a while I wo... | [
{
"answer_id": 398228,
"author": "Adam Bellaire",
"author_id": 21632,
"author_profile": "https://Stackoverflow.com/users/21632",
"pm_score": 4,
"selected": false,
"text": "<p>We install everything via the CPAN shell. This does ignore what package managers have to offer, but it avoids th... | 2008/12/29 | [
"https://Stackoverflow.com/questions/398221",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7498/"
] | A [recent question](https://stackoverflow.com/questions/397817/unable-to-find-perl-modules-in-intrepid-ibex-ubuntu) here on SO got me thinking.
On most Linux distributions that I tried, some Perl modules would be available through the package manager. Others, of course, not. For quite a while I would use my package ma... | Since this question was originally asked, [perlbrew](https://metacpan.org/module/App::perlbrew) has been released. It makes installing custom, self-contained perl installs trivial. And switching between those versions is just as easy:
```
perlbrew switch $version
``` |
398,223 | <p>How do I make my Apache 2 server force a browser to open a file transfer dialogue if the URL points to a file with a .pln or .psa extension?</p>
<p>I have a simple LAMP server with CentOS 5, Apache 2, MYSQL 5, PHP 5, recently built CentOS 5.2 i386 installation CDs. My web application generates files to be downloade... | [
{
"answer_id": 398230,
"author": "palehorse",
"author_id": 312,
"author_profile": "https://Stackoverflow.com/users/312",
"pm_score": 3,
"selected": false,
"text": "<p>You should be able to use the FilesMatch directive to add the necessary header.</p>\n\n<pre><code><FilesMatch \"\\.(?i... | 2008/12/29 | [
"https://Stackoverflow.com/questions/398223",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | How do I make my Apache 2 server force a browser to open a file transfer dialogue if the URL points to a file with a .pln or .psa extension?
I have a simple LAMP server with CentOS 5, Apache 2, MYSQL 5, PHP 5, recently built CentOS 5.2 i386 installation CDs. My web application generates files to be downloaded and impo... | You should be able to use the FilesMatch directive to add the necessary header.
```
<FilesMatch "\.(?i:pin)$">
Header set Content-Disposition attachment
</FilesMatch>
``` |
398,224 | <p>I have to mix some colors in a natural way. This means</p>
<pre><code>blue + yellow = green
blue + red = purple
</code></pre>
<p>And so on. I got the colors as RGB-Values. When I try to mix them I got the right "RGB"-results like</p>
<pre><code>green + red = yellow
yellow + blue = white
</code></pre>
<p>But not... | [
{
"answer_id": 398268,
"author": "Jason Cohen",
"author_id": 4926,
"author_profile": "https://Stackoverflow.com/users/4926",
"pm_score": 7,
"selected": true,
"text": "<p>\"Natural wet paint\" is a little ambiguous; the mixing of CMYK as suggested won't work because you're still adding co... | 2008/12/29 | [
"https://Stackoverflow.com/questions/398224",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1462/"
] | I have to mix some colors in a natural way. This means
```
blue + yellow = green
blue + red = purple
```
And so on. I got the colors as RGB-Values. When I try to mix them I got the right "RGB"-results like
```
green + red = yellow
yellow + blue = white
```
But not the right "natural-wet-paint"-results. Any good ... | "Natural wet paint" is a little ambiguous; the mixing of CMYK as suggested won't work because you're still adding colors.
**If you want results like in Photoshop (as Jon B checked) you need to use L\*a\*b\* space.** Formulas for converting RGB to/from Lab and a description [is here](http://en.wikipedia.org/wiki/Lab_co... |
398,231 | <p>I'm using an ObjectDataSource to bind data to a GridView; it works fine except that it always creates a new object to use as a data source. I can do all the setup just fine but I cannot use an instance of an existing object to specify as the "data source" for it. Is it possible to do this? If so, how? </p>
<p>I... | [
{
"answer_id": 398243,
"author": "Dillie-O",
"author_id": 71,
"author_profile": "https://Stackoverflow.com/users/71",
"pm_score": 0,
"selected": false,
"text": "<p>As I just discovered <a href=\"https://stackoverflow.com/questions/394492/why-is-my-applicationcache-passing-back-a-referenc... | 2008/12/29 | [
"https://Stackoverflow.com/questions/398231",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4068/"
] | I'm using an ObjectDataSource to bind data to a GridView; it works fine except that it always creates a new object to use as a data source. I can do all the setup just fine but I cannot use an instance of an existing object to specify as the "data source" for it. Is it possible to do this? If so, how?
If it's not pos... | Create an event handler for the ObjectCreating event on the ObjectDataSource.
You can assign the instance to using the ObjectDataSourceEventArgs property
```
protected void ObjectDataSource1_ObjectCreating(object sender, ObjectDataSourceEventArgs e)
{
e.ObjectInstance = myObject;
}
```
Wire this event up in the... |
398,237 | <p>In a web application I am working on, the user can click on a link to a CSV file. There is no header set for the mime-type, so the browser just renders it as text. I would like for this file to be sent as a .csv file, so the user can directly open it with calc, excel, gnumeric, etc. </p>
<pre><code>header('Conte... | [
{
"answer_id": 398239,
"author": "Sean Bright",
"author_id": 21926,
"author_profile": "https://Stackoverflow.com/users/21926",
"pm_score": 9,
"selected": true,
"text": "<p>You could try to force the browser to open a \"Save As...\" dialog by doing something like:</p>\n\n<pre><code>header... | 2008/12/29 | [
"https://Stackoverflow.com/questions/398237",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | In a web application I am working on, the user can click on a link to a CSV file. There is no header set for the mime-type, so the browser just renders it as text. I would like for this file to be sent as a .csv file, so the user can directly open it with calc, excel, gnumeric, etc.
```
header('Content-Type: text/csv... | You could try to force the browser to open a "Save As..." dialog by doing something like:
```
header('Content-type: text/csv');
header('Content-disposition: attachment;filename=MyVerySpecial.csv');
echo "cell 1, cell 2";
```
Which should work across most major browsers. |
398,257 | <p>I've a servlet running on Tomcat 5.5.27 and 5.5.26 and have a web form with POST method.
If I use Safari 3.2.1 I see from the logs that Tomcat receives a POST followed immediately/contemporarily by GET and it fails.
If I use Firefox 3.0.5 I see that it sends only POST and everything works.</p>
<p>Trying to debug wi... | [
{
"answer_id": 398289,
"author": "Marc Novakowski",
"author_id": 27020,
"author_profile": "https://Stackoverflow.com/users/27020",
"pm_score": 0,
"selected": false,
"text": "<p>It's hard to say without seeing your HTML for the form, but perhaps your submit button is a wrapped with a link... | 2008/12/29 | [
"https://Stackoverflow.com/questions/398257",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49916/"
] | I've a servlet running on Tomcat 5.5.27 and 5.5.26 and have a web form with POST method.
If I use Safari 3.2.1 I see from the logs that Tomcat receives a POST followed immediately/contemporarily by GET and it fails.
If I use Firefox 3.0.5 I see that it sends only POST and everything works.
Trying to debug with Eclipse... | I think you have an image tag that has an empty src. |
398,259 | <p>I am trying to create a hyperlink using LaTeX. When I use the command pdflatex to compile the file, I get an error.</p>
<p>The relevant lines of the document are:</p>
<pre><code>\documentclass[12pt]{article}
\usepackage{hyperref}
\begin{document}
...
\href{http://www.cs.utah.edu/dept/old/texinfo/as/gprof_toc.html}... | [
{
"answer_id": 398283,
"author": "dreeves",
"author_id": 4234,
"author_profile": "https://Stackoverflow.com/users/4234",
"pm_score": 2,
"selected": false,
"text": "<p>Does the hyperref package purport to make hyperlinks to arbitrary web pages? I thought it was just for intra-document li... | 2008/12/29 | [
"https://Stackoverflow.com/questions/398259",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am trying to create a hyperlink using LaTeX. When I use the command pdflatex to compile the file, I get an error.
The relevant lines of the document are:
```
\documentclass[12pt]{article}
\usepackage{hyperref}
\begin{document}
...
\href{http://www.cs.utah.edu/dept/old/texinfo/as/gprof_toc.html}{gprof}
```
pdflate... | Do you have the pzdr font installed? If you're on Debian or Ubuntu, try installing the texlive-fonts-recommended package. |
398,271 | <p>I am comparing the two base classes of each namespace and am a bit confused.</p>
<pre><code>System.Web.UI.WebControls.WebControl
System.Web.UI.HtmlControls.HtmlControl
</code></pre>
<p>I see small difference between the two. For instance, <code>HtmlControl</code> has much fewer properties while <code>WebControl</c... | [
{
"answer_id": 398284,
"author": "Powerlord",
"author_id": 15880,
"author_profile": "https://Stackoverflow.com/users/15880",
"pm_score": 4,
"selected": true,
"text": "<p>The controls in System.Web.UI.HtmlControls are just a thin wrapper around actual HTML controls. System.Web.UI.WebCont... | 2008/12/29 | [
"https://Stackoverflow.com/questions/398271",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am comparing the two base classes of each namespace and am a bit confused.
```
System.Web.UI.WebControls.WebControl
System.Web.UI.HtmlControls.HtmlControl
```
I see small difference between the two. For instance, `HtmlControl` has much fewer properties while `WebControl` has a lot of properties like the CssClass p... | The controls in System.Web.UI.HtmlControls are just a thin wrapper around actual HTML controls. System.Web.UI.WebControls.WebControl are your standard ASP.NET controls.
To expand on this a bit:
>
> The [System.Web.UI.HtmlControls](http://msdn.microsoft.com/en-us/library/system.web.ui.htmlcontrols(VS.80).aspx)
> nam... |
398,299 | <p>A friend was in need of an algorithm that would let him loop through the elements of an NxM matrix (N and M are odd). I came up with a solution, but I wanted to see if my fellow SO'ers could come up with a better solution.</p>
<p>I'm posting my solution as an answer to this question.</p>
<p><strong>Example Output:... | [
{
"answer_id": 398302,
"author": "Can Berk Güder",
"author_id": 2119,
"author_profile": "https://Stackoverflow.com/users/2119",
"pm_score": 7,
"selected": true,
"text": "<p>Here's my solution (in Python):</p>\n\n<pre class=\"lang-python prettyprint-override\"><code>def spiral(X, Y):\n ... | 2008/12/29 | [
"https://Stackoverflow.com/questions/398299",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2119/"
] | A friend was in need of an algorithm that would let him loop through the elements of an NxM matrix (N and M are odd). I came up with a solution, but I wanted to see if my fellow SO'ers could come up with a better solution.
I'm posting my solution as an answer to this question.
**Example Output:**
For a 3x3 matrix, t... | Here's my solution (in Python):
```python
def spiral(X, Y):
x = y = 0
dx = 0
dy = -1
for i in range(max(X, Y)**2):
if (-X/2 < x <= X/2) and (-Y/2 < y <= Y/2):
print (x, y)
# DO STUFF...
if x == y or (x < 0 and x == -y) or (x > 0 and x == 1-y):
dx, dy ... |
398,316 | <p>I have string that I want to chop to array of substrings of given length n. I am not interested in remainder (if length of string cannot be divided by n without remainder)</p>
<pre><code>let ChopString (myString : string) n =
let res =
seq{
for i = 0 to myString.Length / n - 1 do
... | [
{
"answer_id": 398417,
"author": "Juliet",
"author_id": 40516,
"author_profile": "https://Stackoverflow.com/users/40516",
"pm_score": 4,
"selected": true,
"text": "<p><code>stringInstance.[start..end]</code> is much more readable than <code>String.sub</code>. Here's what I came up with:<... | 2008/12/29 | [
"https://Stackoverflow.com/questions/398316",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25732/"
] | I have string that I want to chop to array of substrings of given length n. I am not interested in remainder (if length of string cannot be divided by n without remainder)
```
let ChopString (myString : string) n =
let res =
seq{
for i = 0 to myString.Length / n - 1 do
yield(... | `stringInstance.[start..end]` is much more readable than `String.sub`. Here's what I came up with:
```
let chop (input : string) len =
seq { for start in 0 .. len .. input.Length - 1
do yield input.[start..start + len - 1] }
|> Seq.toArray
```
Or you can use:
```
let chop (inp... |
398,333 | <p>I am crash-learning PHP for a project, and I have a ton of stupid questions to make. The first is the following. I have a structure like this:</p>
<ul>
<li>index.php</li>
<li>header.php</li>
<li>images/</li>
<li>data
<ul>
<li>data.php</li>
</ul></li>
</ul>
<p>Now, the problem is that I want to include the heade... | [
{
"answer_id": 398341,
"author": "Glenn",
"author_id": 25191,
"author_profile": "https://Stackoverflow.com/users/25191",
"pm_score": 0,
"selected": false,
"text": "<p>Take a look at <code>$_SERVER['PATH_TRANSLATED']</code></p>\n"
},
{
"answer_id": 398370,
"author": "Andreas G... | 2008/12/29 | [
"https://Stackoverflow.com/questions/398333",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2309/"
] | I am crash-learning PHP for a project, and I have a ton of stupid questions to make. The first is the following. I have a structure like this:
* index.php
* header.php
* images/
* data
+ data.php
Now, the problem is that I want to include the header.php file in the data.php file. That is no problem.
The problem I h... | Try including the file like such:
```
<?php
include($_SERVER['DOCUMENT_ROOT'].'/data/data.php/');
?>
```
The `DOCUMENT_ROOT` will return the path of the root folder, located on the web server of your website. |
398,344 | <p>I'm looking for something that runs in a terminal and allows me to track time. I'd like it to be open source but that isn't necessary. </p>
<p>Most time tracking apps I've found are either web or gui based and there for take longer to enter data then I'd like.</p>
| [
{
"answer_id": 398431,
"author": "Charlie Martin",
"author_id": 35092,
"author_profile": "https://Stackoverflow.com/users/35092",
"pm_score": 4,
"selected": false,
"text": "<p>a real basic one would be</p>\n\n<pre><code>$ echo `date`\": what I'm doing now\" >> timelog.txt\n</code><... | 2008/12/29 | [
"https://Stackoverflow.com/questions/398344",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14744/"
] | I'm looking for something that runs in a terminal and allows me to track time. I'd like it to be open source but that isn't necessary.
Most time tracking apps I've found are either web or gui based and there for take longer to enter data then I'd like. | TimeTrap. It's simple and lightweight, and somewhat intuitive to use.
```
$ t switch World Domination Plan
$ t in --at "5 minutes ago" Research Volcano Islands
$ t out
$ t display
Timesheet World Domination Plan:
Day Start End Duration Notes
Mar 14, 2009 19:53:30 - 20:06:15 0:12:45 Rese... |
398,347 | <p>I have some settings I need in a Javascript file -- servers to connect to -- that changes based on my environment. For <code>development</code>, <code>test</code>, and <code>staging</code>, I want to use the staging servers; for <code>production</code>, the production servers. I already have the settings in Ruby (... | [
{
"answer_id": 398523,
"author": "salt.racer",
"author_id": 757,
"author_profile": "https://Stackoverflow.com/users/757",
"pm_score": 3,
"selected": true,
"text": "<p>Can you do something like this?</p>\n\n<pre><code><% javascript_include_file \"#{RAILS_ENV}.js\" %>\n</code></pre>\... | 2008/12/29 | [
"https://Stackoverflow.com/questions/398347",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1190/"
] | I have some settings I need in a Javascript file -- servers to connect to -- that changes based on my environment. For `development`, `test`, and `staging`, I want to use the staging servers; for `production`, the production servers. I already have the settings in Ruby (configured in my `environment/xyz.rb` files). So ... | Can you do something like this?
```
<% javascript_include_file "#{RAILS_ENV}.js" %>
```
I do something similar, though it is not with a JS file, but with some RB files ... and I do it for the same reason, determining which servers to connect to.
For me, I have an rb file in my `"lib"` directory called `"constants.r... |
398,353 | <p>I know that WPF 3.5 SP1 supports a <code>StringFormat</code> in a binding, but can Silverlight do the same? I thought it could, but damned if I can make it work!</p>
<p>Here's a snippet of my XAML:</p>
<pre><code><TextBlock Text="{Binding StartTime, StringFormat=t}" />
</code></pre>
<p>It compiles OK, but I... | [
{
"answer_id": 398572,
"author": "Michael S. Scherotter",
"author_id": 27306,
"author_profile": "https://Stackoverflow.com/users/27306",
"pm_score": 5,
"selected": true,
"text": "<p>Silverlight 3 and below do not, but you can use a Value Converter and specify the ConverterParamenter in t... | 2008/12/29 | [
"https://Stackoverflow.com/questions/398353",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14537/"
] | I know that WPF 3.5 SP1 supports a `StringFormat` in a binding, but can Silverlight do the same? I thought it could, but damned if I can make it work!
Here's a snippet of my XAML:
```
<TextBlock Text="{Binding StartTime, StringFormat=t}" />
```
It compiles OK, but I get a runtime error when it gets to the browser..... | Silverlight 3 and below do not, but you can use a Value Converter and specify the ConverterParamenter in the binding. You'll have to create your own Value Converter by deriving a class from IValueConverter like I've shown [here](http://blogs.msdn.com/synergist/archive/2008/07/30/using-a-converterparameter-in-a-silverli... |
398,375 | <p>My company performed a data migration recently (in a SQL Server 2005 database) and we noticed that some tables created with SELECT INTO didn't maintained the calculated fields of the original tables, but instead SQL Server created regular fields with the type returned by the original calculation. For example, suppos... | [
{
"answer_id": 398424,
"author": "devio",
"author_id": 21336,
"author_profile": "https://Stackoverflow.com/users/21336",
"pm_score": 0,
"selected": false,
"text": "<p>My understanding is that the new table is created from the data types in the record set. However the record set does not ... | 2008/12/29 | [
"https://Stackoverflow.com/questions/398375",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49934/"
] | My company performed a data migration recently (in a SQL Server 2005 database) and we noticed that some tables created with SELECT INTO didn't maintained the calculated fields of the original tables, but instead SQL Server created regular fields with the type returned by the original calculation. For example, suppose t... | I don't think you would be able to do this with SELECT INTO - Just like if you were selecting against a view, it's just taking the results and pumping them to a new table.
You'll likely need to create the table with the computed columns first, then do a regular insert from the source table of the non-computed columns. |
398,378 | <p>What is the most efficient way to display the last 10 lines of a very large text file (this particular file is over 10GB). I was thinking of just writing a simple C# app but I'm not sure how to do this effectively.</p>
| [
{
"answer_id": 398390,
"author": "ctacke",
"author_id": 13154,
"author_profile": "https://Stackoverflow.com/users/13154",
"pm_score": 5,
"selected": false,
"text": "<p>I'd likely just open it as a binary stream, seek to the end, then back up looking for line breaks. Back up 10 (or 11 de... | 2008/12/29 | [
"https://Stackoverflow.com/questions/398378",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2849/"
] | What is the most efficient way to display the last 10 lines of a very large text file (this particular file is over 10GB). I was thinking of just writing a simple C# app but I'm not sure how to do this effectively. | Read to the end of the file, then seek backwards until you find ten newlines, and then read forward to the end taking into consideration various encodings. Be sure to handle cases where the number of lines in the file is less than ten. Below is an implementation (in C# as you tagged this), generalized to find the last ... |
398,388 | <p>How can i convert an array of bitmaps into a brand new image of TIFF format, adding all the bitmaps as frames in this new tiff image?</p>
<p>using .NET 2.0.</p>
| [
{
"answer_id": 398529,
"author": "Otávio Décio",
"author_id": 48684,
"author_profile": "https://Stackoverflow.com/users/48684",
"pm_score": 7,
"selected": true,
"text": "<p>Start with the first bitmap by putting it into an Image object</p>\n\n<pre><code>Bitmap bitmap = (Bitmap)Image.From... | 2008/12/29 | [
"https://Stackoverflow.com/questions/398388",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35286/"
] | How can i convert an array of bitmaps into a brand new image of TIFF format, adding all the bitmaps as frames in this new tiff image?
using .NET 2.0. | Start with the first bitmap by putting it into an Image object
```
Bitmap bitmap = (Bitmap)Image.FromFile(file);
```
Save the bitmap to memory as tiff
```
MemoryStream byteStream = new MemoryStream();
bitmap.Save(byteStream, ImageFormat.Tiff);
```
Put Tiff into another Image object
```
Image tiff = Image.FromStr... |
398,395 | <p>Why do most C programmers name variables like this:</p>
<pre><code>int *myVariable;
</code></pre>
<p>rather than like this:</p>
<pre><code>int* myVariable;
</code></pre>
<p>Both are valid. It seems to me that the asterisk is a part of the type, not a part of the variable name. Can anyone explain this logic?</p>
| [
{
"answer_id": 398403,
"author": "biozinc",
"author_id": 30698,
"author_profile": "https://Stackoverflow.com/users/30698",
"pm_score": 7,
"selected": false,
"text": "<p>If you look at it another way, <code>*myVariable</code> is of type <code>int</code>, which makes some sense.</p>\n"
}... | 2008/12/29 | [
"https://Stackoverflow.com/questions/398395",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26149/"
] | Why do most C programmers name variables like this:
```
int *myVariable;
```
rather than like this:
```
int* myVariable;
```
Both are valid. It seems to me that the asterisk is a part of the type, not a part of the variable name. Can anyone explain this logic? | They are EXACTLY equivalent.
However, in
```
int *myVariable, myVariable2;
```
It seems obvious that myVariable has type **int\***, while myVariable2 has type **int**.
In
```
int* myVariable, myVariable2;
```
it may seem obvious that both are of type **int\***, but that is not correct as `myVariable2` has type **... |
398,422 | <p>Given a set of properties files and list of files which may reference keys in those properties files, what's the easiest way to determine which keys are unused?</p>
<p>Example:</p>
<p>Given a project with files</p>
<p><em>muppets.properties</em></p>
<pre><code>kermit=Kermit the Frog
oscar=Oscar the Grouch
</code... | [
{
"answer_id": 398524,
"author": "OscarRyz",
"author_id": 20654,
"author_profile": "https://Stackoverflow.com/users/20654",
"pm_score": 1,
"selected": false,
"text": "<p>IntelliJ IDEA has this functionality. Unfortunately is it used within the app and not as a Maven plugin.</p>\n\n<p>Som... | 2008/12/29 | [
"https://Stackoverflow.com/questions/398422",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1557/"
] | Given a set of properties files and list of files which may reference keys in those properties files, what's the easiest way to determine which keys are unused?
Example:
Given a project with files
*muppets.properties*
```
kermit=Kermit the Frog
oscar=Oscar the Grouch
```
*smurfs.properties*
```
papa=Papa Smurf
... | IntelliJ IDEA has this functionality. Unfortunately is it used within the app and not as a Maven plugin.
Some of the modules in IDEA are open source. Many plugins are available to the community. Perhaps you could peek at their website to see if there is anything you can grab.
I hope this helps <http://www.jetbrains.n... |
398,441 | <p>I'm playing around with Project Euler's <a href="http://projecteuler.net/index.php?section=problems&id=220" rel="nofollow noreferrer">Problem 220</a>, and I'm a little confused about the Wikipedia article on the topic, <a href="http://en.wikipedia.org/wiki/Dragon_curve" rel="nofollow noreferrer">Dragon Curve</a>... | [
{
"answer_id": 398471,
"author": "starblue",
"author_id": 49246,
"author_profile": "https://Stackoverflow.com/users/49246",
"pm_score": 3,
"selected": true,
"text": "<p>m is the number of zero bits at the least significant end of the number.\nThe simplest algorithm is to divide by 2 as l... | 2008/12/29 | [
"https://Stackoverflow.com/questions/398441",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13051/"
] | I'm playing around with Project Euler's [Problem 220](http://projecteuler.net/index.php?section=problems&id=220), and I'm a little confused about the Wikipedia article on the topic, [Dragon Curve](http://en.wikipedia.org/wiki/Dragon_curve). On the topic of calculating the direction of the nth turn without having to dra... | m is the number of zero bits at the least significant end of the number.
The simplest algorithm is to divide by 2 as long as the number is even,
but you could also use binary search to speed it up.
All integers can be expressed in this way. |
398,468 | <p>I've got a sql query (using Firebird as the RDBMS) in which I need to order the results by a field, EDITION. I need to order by the contents of the field, however. i.e. "NE" goes first, "OE" goes second, "OP" goes third, and blanks go last. Unfortunately, I don't have a clue how this could be accomplished. All I've ... | [
{
"answer_id": 398484,
"author": "Peter T. LaComb Jr.",
"author_id": 8513,
"author_profile": "https://Stackoverflow.com/users/8513",
"pm_score": 3,
"selected": false,
"text": "<p>Add those values to another table with a numeric column for their rank:</p>\n\n<pre><code>Edition Rank\nNE ... | 2008/12/29 | [
"https://Stackoverflow.com/questions/398468",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48957/"
] | I've got a sql query (using Firebird as the RDBMS) in which I need to order the results by a field, EDITION. I need to order by the contents of the field, however. i.e. "NE" goes first, "OE" goes second, "OP" goes third, and blanks go last. Unfortunately, I don't have a clue how this could be accomplished. All I've eve... | ```
Order By Case Edition
When 'NE' Then 1
When 'OE' Then 2
When 'OP' Then 3
Else 4 End
``` |
398,476 | <p>I'm trying to edit the output joomla main_menu module so I can make a custom dropdown menu. At the moment it currently outputs html like this:</p>
<pre><code><ul class="menu">
<li class="active item1" id="current"><a href="#"><span>First Level Item </span</a></li>
<li cl... | [
{
"answer_id": 398776,
"author": "Paul Sheldrake",
"author_id": 28672,
"author_profile": "https://Stackoverflow.com/users/28672",
"pm_score": 3,
"selected": true,
"text": "<p>It turns out that the span tags are added in a completely different file.</p>\n\n<p>If you go to modules/mod_main... | 2008/12/29 | [
"https://Stackoverflow.com/questions/398476",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28672/"
] | I'm trying to edit the output joomla main\_menu module so I can make a custom dropdown menu. At the moment it currently outputs html like this:
```
<ul class="menu">
<li class="active item1" id="current"><a href="#"><span>First Level Item </span</a></li>
<li class="parent item63"><a href="#"><span>First Level Item P... | It turns out that the span tags are added in a completely different file.
If you go to modules/mod\_mainmenu directory there is a helper.php file that also controls some of the output.
On lines 285 and 293 there are some span tags in the code. Deleting those made the output work the way that I wanted it to. |
398,509 | <p>What are the advantages of replacing <code>(int)reader[0]</code> with <code>reader.GetInt32(0)</code>? I'm sure such casting functions are there for a reason, but other than it feeling more aesthetically pleasing to avoid the cast myself, I'm not sure what those reasons are.</p>
| [
{
"answer_id": 398602,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 1,
"selected": false,
"text": "<p>The former can also accept the column name as a string rather than an index, and will attempt to cast the column va... | 2008/12/29 | [
"https://Stackoverflow.com/questions/398509",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18192/"
] | What are the advantages of replacing `(int)reader[0]` with `reader.GetInt32(0)`? I'm sure such casting functions are there for a reason, but other than it feeling more aesthetically pleasing to avoid the cast myself, I'm not sure what those reasons are. | In code....
```
void OneWay()
{
System.Data.SqlClient.SqlDataReader reader = null;
int i = reader.GetInt32(0);
}
void OtherWay()
{
System.Data.SqlClient.SqlDataReader reader = null;
int i = (int)reader[0];
}
```
In IL
`... |
398,517 | <p>I'm using MS SQL Server.</p>
<p>When I define the database schema I define a (non-materialized) view, which includes many fields, for example as follows (where "Topic" is the name of a table, and the view is a self-join on the Topic table):</p>
<pre><code>CREATE VIEW View_Topic_Ancestor AS
SELECT
Subordinate.I... | [
{
"answer_id": 398531,
"author": "Charles Bretana",
"author_id": 32632,
"author_profile": "https://Stackoverflow.com/users/32632",
"pm_score": 3,
"selected": true,
"text": "<p>The Query optimizer creates a query plan by combining the sql which defines the view with the sql you construct ... | 2008/12/29 | [
"https://Stackoverflow.com/questions/398517",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49942/"
] | I'm using MS SQL Server.
When I define the database schema I define a (non-materialized) view, which includes many fields, for example as follows (where "Topic" is the name of a table, and the view is a self-join on the Topic table):
```
CREATE VIEW View_Topic_Ancestor AS
SELECT
Subordinate.Id AS Subordinate_Id,
... | The Query optimizer creates a query plan by combining the sql which defines the view with the sql you construct to "select" from the view into a single sql query. If, in this combined, optimized sql, any specific attribute (column) is not necessary, it will not be used.. specifically, if the final select does not requi... |
398,518 | <p>I don't know if it's legit at StackOverflow to post your own answer to a question, but I saw nobody had asked this already. I went looking for a C# Glob and didn't find one, so I wrote one that others might find useful.</p>
| [
{
"answer_id": 398522,
"author": "Mark Maxham",
"author_id": 49737,
"author_profile": "https://Stackoverflow.com/users/49737",
"pm_score": 4,
"selected": false,
"text": "<pre><code> /// <summary>\n /// return a list of files that matches some wildcard pattern, e.g. \n /// ... | 2008/12/29 | [
"https://Stackoverflow.com/questions/398518",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49737/"
] | I don't know if it's legit at StackOverflow to post your own answer to a question, but I saw nobody had asked this already. I went looking for a C# Glob and didn't find one, so I wrote one that others might find useful. | ```
/// <summary>
/// return a list of files that matches some wildcard pattern, e.g.
/// C:\p4\software\dotnet\tools\*\*.sln to get all tool solution files
/// </summary>
/// <param name="glob">pattern to match</param>
/// <returns>all matching paths</returns>
public static IEnumerable<str... |
398,543 | <p>While learning different languages, I've often seen objects allocated on the fly, most often in Java and C#, like this:</p>
<pre><code>functionCall(new className(initializers));
</code></pre>
<p>I understand that this is perfectly legal in memory-managed languages, but can this technique be used in C++ without cau... | [
{
"answer_id": 398551,
"author": "Otávio Décio",
"author_id": 48684,
"author_profile": "https://Stackoverflow.com/users/48684",
"pm_score": 3,
"selected": false,
"text": "<p>Yes, as long as you deallocate the memory inside the function. But by no means this is a best practice for C++.</p... | 2008/12/29 | [
"https://Stackoverflow.com/questions/398543",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1256/"
] | While learning different languages, I've often seen objects allocated on the fly, most often in Java and C#, like this:
```
functionCall(new className(initializers));
```
I understand that this is perfectly legal in memory-managed languages, but can this technique be used in C++ without causing a memory leak? | Your code is valid (assuming functionCall() actually guarantees that the pointer gets deleted), but it's fragile and will make alarm bells go off in the heads of most C++ programmers.
There are multiple problems with your code:
* First and foremost, who owns the pointer? Who is responsible for freeing it? The calling... |
398,547 | <p>Assume a requirement of implementing a class "CAR".</p>
<p>Now, this class contains various states like "un-ignited", "ignited", "broken-down", "punctured", etc.,</p>
<p>The way I look at to implement this requirement is to have boolean flags aka "properties" in the class and 'check the state' using these boolean ... | [
{
"answer_id": 398554,
"author": "OscarRyz",
"author_id": 20654,
"author_profile": "https://Stackoverflow.com/users/20654",
"pm_score": 2,
"selected": false,
"text": "<p>This definitely sounds to be a job for the <a href=\"http://en.wikipedia.org/wiki/State_pattern\" rel=\"nofollow noref... | 2008/12/29 | [
"https://Stackoverflow.com/questions/398547",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Assume a requirement of implementing a class "CAR".
Now, this class contains various states like "un-ignited", "ignited", "broken-down", "punctured", etc.,
The way I look at to implement this requirement is to have boolean flags aka "properties" in the class and 'check the state' using these boolean flags inside each... | This definitely sounds to be a job for the [State Pattern](http://en.wikipedia.org/wiki/State_pattern)
Basically you create your application ( context ) and define the behavior for some operation into a separate class/interface ( state )
This class will have different implementing subclasses , one per state.
When t... |
398,560 | <p>How can I split by word boundary in a regex engine that doesn't support it?</p>
<p>python's re can match on \b but doesn't seem to support splitting on it. I seem to recall dealing with other regex engines that had the same limitation.</p>
<p>example input:</p>
<pre><code>"hello, foo"
</code></pre>
<p>expected o... | [
{
"answer_id": 398570,
"author": "gnud",
"author_id": 27204,
"author_profile": "https://Stackoverflow.com/users/27204",
"pm_score": 0,
"selected": false,
"text": "<p>Try </p>\n\n<pre><code>>>> re.compile(r'\\W\\b').split('hello, foo')\n['hello,', 'foo']\n</code></pre>\n\n<p>This... | 2008/12/29 | [
"https://Stackoverflow.com/questions/398560",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41613/"
] | How can I split by word boundary in a regex engine that doesn't support it?
python's re can match on \b but doesn't seem to support splitting on it. I seem to recall dealing with other regex engines that had the same limitation.
example input:
```
"hello, foo"
```
expected output:
```
['hello', ', ', 'foo']
```
... | (\W+) can give you the expected output:
```
>>> re.compile(r'(\W+)').split('hello, foo')
['hello', ', ', 'foo']
``` |
398,612 | <p>I have a Class see below, when i am trying to query it from another page it not linking e.g. if i put "var Notes = HandhedNotes.GetNotesByLinkIDJoin();" when i look at Notes theres not links there. I think its due to the IQuerable maybe I should be using something elese??</p>
<pre><code>namespace WebSys
{
public ... | [
{
"answer_id": 398622,
"author": "E Rolnicki",
"author_id": 46449,
"author_profile": "https://Stackoverflow.com/users/46449",
"pm_score": 2,
"selected": false,
"text": "<p>.pfx is an extension for a security certificate. they typically are password-protected.</p>\n"
},
{
"answer_... | 2008/12/29 | [
"https://Stackoverflow.com/questions/398612",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a Class see below, when i am trying to query it from another page it not linking e.g. if i put "var Notes = HandhedNotes.GetNotesByLinkIDJoin();" when i look at Notes theres not links there. I think its due to the IQuerable maybe I should be using something elese??
```
namespace WebSys
{
public partial class ... | A file containing an encrypted private key. It's probably being used for code signing the application (so the user knows who created the program and hence if they can trust it).
You can probably see it being used by right-clicking on the project, getting Properties, then looking at the Signing tab. |
398,621 | <p>See subject, note that this question only applies to the .NET <strong>compact</strong> framework. This happens on the emulators that ship with Windows Mobile 6 Professional SDK as well as on my English HTC Touch Pro (all .NET CF 3.5). iso-8859-1 stands for Western European (ISO), which is probably the most important... | [
{
"answer_id": 398681,
"author": "Otis",
"author_id": 18292,
"author_profile": "https://Stackoverflow.com/users/18292",
"pm_score": 3,
"selected": false,
"text": "<p><a href=\"http://msdn.microsoft.com/en-us/library/x5b31f9d.aspx\" rel=\"noreferrer\" title=\"This MSDN article\">This MSDN... | 2008/12/29 | [
"https://Stackoverflow.com/questions/398621",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | See subject, note that this question only applies to the .NET **compact** framework. This happens on the emulators that ship with Windows Mobile 6 Professional SDK as well as on my English HTC Touch Pro (all .NET CF 3.5). iso-8859-1 stands for Western European (ISO), which is probably the most important encoding beside... | I would try to use "windows-1252" as encoding string. [According to Wikipedia](http://en.wikipedia.org/wiki/Windows-1252), Windows-1252 is a superset of ISO-8859-1.
```
System.Text.Encoding.GetEncoding(1252)
``` |
398,641 | <p>I have a factory that builds the objects with longest lifetime in my application. These have types, lets say, <code>ClientA</code> and <code>ClientB</code>, which depend on <code>Provider</code> (an abstract class with many possible implementations), so both clients have a reference to Provider as member.</p>
<p>Ac... | [
{
"answer_id": 398649,
"author": "Ray Tayek",
"author_id": 51292,
"author_profile": "https://Stackoverflow.com/users/51292",
"pm_score": 2,
"selected": false,
"text": "<p>make provider an instance variable of AppFactory. then make provider a smart pointer or delete it in AppFactory's dto... | 2008/12/29 | [
"https://Stackoverflow.com/questions/398641",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23477/"
] | I have a factory that builds the objects with longest lifetime in my application. These have types, lets say, `ClientA` and `ClientB`, which depend on `Provider` (an abstract class with many possible implementations), so both clients have a reference to Provider as member.
According to the command-line arguments, the ... | It's very simple with a shared ownership smart pointer:
```
App AppFactory::buildApp()
{
boost::shared_ptr<Provider> provider;
if (some condition)
{
provider.reset(new ProviderX());
}
else
{
provider.reset(new ProviderY());
}
ClientA clientA(provider);
ClientB cli... |
398,648 | <p>I want to make a table that simply has two integer columns to serve as a mapping table between two different data sets and I wish to put the correct constraints on it.</p>
<p>I initially set the two columns as a compound primary key, but then realized that represents a many to many, only keeping duplicate many to m... | [
{
"answer_id": 398655,
"author": "Doug Currie",
"author_id": 33252,
"author_profile": "https://Stackoverflow.com/users/33252",
"pm_score": 0,
"selected": false,
"text": "<p>Use a UNIQUE column constraint on each column.</p>\n"
},
{
"answer_id": 398659,
"author": "Charles Bret... | 2008/12/29 | [
"https://Stackoverflow.com/questions/398648",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21367/"
] | I want to make a table that simply has two integer columns to serve as a mapping table between two different data sets and I wish to put the correct constraints on it.
I initially set the two columns as a compound primary key, but then realized that represents a many to many, only keeping duplicate many to many mappin... | Create a Primary Key on one column and another separate unique constraint or unique index, on the other.
```
CREATE TABLE [dbo].[test](
[x] [int] NOT NULL,
[y] [int] NOT NULL,
CONSTRAINT [PK_test] PRIMARY KEY CLUSTERED
( [x] ASC)
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF,
... |
398,664 | <p>It seems vsize() and length() return the same results. Does anyone know of a practical example of when to use vsize instead of length?</p>
<pre><code>select vsize(object_name), length(object_name) from user_objects
</code></pre>
<p>Result:</p>
<pre><code>/468ba408_LDAPHelper 20 20
/de807749_LDAPHelper 20 ... | [
{
"answer_id": 398729,
"author": "tuinstoel",
"author_id": 43901,
"author_profile": "https://Stackoverflow.com/users/43901",
"pm_score": 2,
"selected": false,
"text": "<p>see: <a href=\"http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:1897591221788\" rel=\"nofollow nor... | 2008/12/29 | [
"https://Stackoverflow.com/questions/398664",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/700/"
] | It seems vsize() and length() return the same results. Does anyone know of a practical example of when to use vsize instead of length?
```
select vsize(object_name), length(object_name) from user_objects
```
Result:
```
/468ba408_LDAPHelper 20 20
/de807749_LDAPHelper 20 20
A4201_A4201_UK 14 14
A4201_PGM_F... | Well, Length() takes a character argument (CHAR, VARCHAR2, NCHAR, NVARCHAR2, CLOB, or NCLOB) whereas VSize() takes just about any data type, so if you pass Length() a noncharacter data type there has to be an implicit conversion.
Length is also sensitive to to character sets.
```
drop table daa_test;
create table daa... |
398,665 | <p>I'm working on a demo that makes use of Spring.NET IoC capability in ASP.NET MVC . It's kind of like the MyBlog application presented on pair programming video tutorial on www.asp.net site. I've completed the same demo using Microsoft's Unity framework and now want to try out the Spring container.
To that end I've i... | [
{
"answer_id": 398749,
"author": "Matthias Hryniszak",
"author_id": 49970,
"author_profile": "https://Stackoverflow.com/users/49970",
"pm_score": 3,
"selected": true,
"text": "<p>I've found the answer!</p>\n\n<p>My object definition looked like that:</p>\n\n<pre><code><!-- Controlers ... | 2008/12/29 | [
"https://Stackoverflow.com/questions/398665",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49970/"
] | I'm working on a demo that makes use of Spring.NET IoC capability in ASP.NET MVC . It's kind of like the MyBlog application presented on pair programming video tutorial on www.asp.net site. I've completed the same demo using Microsoft's Unity framework and now want to try out the Spring container.
To that end I've impl... | I've found the answer!
My object definition looked like that:
```
<!-- Controlers -->
<object name="Home" type="MyBlog.Controllers.HomeController">
<property name="BlogService" ref="BlogService" />
<property name="BlogEntryService" ref="BlogEntryService" />
<property name="BlogEntryCommentService" ref="Bl... |
398,682 | <p>I have a macro that looks like this:</p>
<pre><code>#define coutError if (VERBOSITY_SETTING >= VERBOSITY_ERROR) ods()
</code></pre>
<p>where ods() is a class that behaves similarly to cout, and VERBOSITY_SETTING is a global variable. There are a few of these for different verbosity settings, and it allows... | [
{
"answer_id": 398698,
"author": "Tim",
"author_id": 10755,
"author_profile": "https://Stackoverflow.com/users/10755",
"pm_score": 0,
"selected": false,
"text": "<p>I think the real problem is the use of the macro - not the code that gets preprocessed. But I don't think this is the answ... | 2008/12/29 | [
"https://Stackoverflow.com/questions/398682",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28776/"
] | I have a macro that looks like this:
```
#define coutError if (VERBOSITY_SETTING >= VERBOSITY_ERROR) ods()
```
where ods() is a class that behaves similarly to cout, and VERBOSITY\_SETTING is a global variable. There are a few of these for different verbosity settings, and it allows the code to look something ... | You could try - temporarily - modifying the macro to something like this, and see what doesn't compile...
```
#define coutError {} if (VERBOSITY_SETTING >= VERBOSITY_ERROR) ods()
```
The 'else' clauses should now give errors. |
398,708 | <p>I'm working on wrapping my head around the factory pattern by using it in a simple data storage project in my free time. The idea is to take simple data and save it to a database using a simple factory pattern in VB.NET. I think I have a basic understanding of the pattern itself, however, what I'm struggling with ... | [
{
"answer_id": 398740,
"author": "Otávio Décio",
"author_id": 48684,
"author_profile": "https://Stackoverflow.com/users/48684",
"pm_score": 1,
"selected": false,
"text": "<p>I took a simpler approach. I defined an Entity class and I have a factory that produces list of entity (List< E... | 2008/12/29 | [
"https://Stackoverflow.com/questions/398708",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13955/"
] | I'm working on wrapping my head around the factory pattern by using it in a simple data storage project in my free time. The idea is to take simple data and save it to a database using a simple factory pattern in VB.NET. I think I have a basic understanding of the pattern itself, however, what I'm struggling with is ho... | I took a simpler approach. I defined an Entity class and I have a factory that produces list of entity (List< Entity >). I tell the factory what types I want to get back, it assumes the type to be the table, the properties to be the columns, generate the sql, get the data, populate a list of new instances of the type.
... |
398,747 | <p>We have a database (SQL Server 2005) which we would like to get under source control. As part of that we are going to have a version table to store the current version number of the database. Is there a way to limit that table to only holding one row? Or is storing the version number in a table a bad idea? </p>
... | [
{
"answer_id": 398756,
"author": "Otávio Décio",
"author_id": 48684,
"author_profile": "https://Stackoverflow.com/users/48684",
"pm_score": 4,
"selected": true,
"text": "<p>Use a trigger.</p>\n"
},
{
"answer_id": 398765,
"author": "Ole",
"author_id": 49540,
"author_pr... | 2008/12/29 | [
"https://Stackoverflow.com/questions/398747",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1973027/"
] | We have a database (SQL Server 2005) which we would like to get under source control. As part of that we are going to have a version table to store the current version number of the database. Is there a way to limit that table to only holding one row? Or is storing the version number in a table a bad idea?
Ended up u... | Use a trigger. |
398,748 | <p>I've created a new J2SE project in NetBeans, and I can run it from the IDE, but when I try to run it using Ant on the command line, I get the following problem:</p>
<p><snip></p>
<pre><code>run:
[java] Exception in thread "main" java.lang.NoClassDefFoundError: IndexBuilder
[java] Java Result: 1
</c... | [
{
"answer_id": 603420,
"author": "Rogier",
"author_id": 72894,
"author_profile": "https://Stackoverflow.com/users/72894",
"pm_score": 0,
"selected": false,
"text": "<p>Did you try setting the working directory to \"build\\classes\" in the Project Properties -> Run tab?</p>\n"
},
{
... | 2008/12/29 | [
"https://Stackoverflow.com/questions/398748",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4203/"
] | I've created a new J2SE project in NetBeans, and I can run it from the IDE, but when I try to run it using Ant on the command line, I get the following problem:
<snip>
```
run:
[java] Exception in thread "main" java.lang.NoClassDefFoundError: IndexBuilder
[java] Java Result: 1
```
<snip>
Based on the sni... | When you are running it from the command line, you are actually invoking [Apache Ant](http://ant.apache.org). The reason you are getting the ClassNotFound Exception is because ${javac.classpath} and all the other properties are not being properly populated. That is why your code runs from within the Netbeans context. N... |
398,760 | <p>What's the difference between the following two pieces of HTML (apologies if there are any typos as I'm typing this freehand)?</p>
<p>Using jQuery:</p>
<pre><code><script type="text/javascript">
$(document).ready(function() {
$("#clickme").click(function() {
alert("clicked!");
... | [
{
"answer_id": 398797,
"author": "orip",
"author_id": 37020,
"author_profile": "https://Stackoverflow.com/users/37020",
"pm_score": 3,
"selected": false,
"text": "<p>One of the differences is that adding handlers with jQuery's <code>click</code> doesn't remove previous handlers.</p>\n"
... | 2008/12/29 | [
"https://Stackoverflow.com/questions/398760",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1574/"
] | What's the difference between the following two pieces of HTML (apologies if there are any typos as I'm typing this freehand)?
Using jQuery:
```
<script type="text/javascript">
$(document).ready(function() {
$("#clickme").click(function() {
alert("clicked!");
});
});
</script>
<a ... | One big difference is that jQuery's events are handled in a registry which is parsed on the click event. Crucially, this means that you are permitted to assign multiple callbacks, and have them triggered in the order in which they were registered:
```
<script type="text/javascript">
$(document).ready(function() {
... |
398,777 | <p>Is there some sort of formatting protocol for html email? We have an automated system that sends reports via email, when I look at the source I see them delimited by line length with an "=" breaking the line. That is, I get something like :</p>
<pre><code><html><body>some text some text some text some=... | [
{
"answer_id": 398813,
"author": "cletus",
"author_id": 18393,
"author_profile": "https://Stackoverflow.com/users/18393",
"pm_score": 4,
"selected": true,
"text": "<p>You have to send the message as <a href=\"http://www.enewsletterpro.com/articles/multi_part_mime_messages.asp\" rel=\"nof... | 2008/12/29 | [
"https://Stackoverflow.com/questions/398777",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19479/"
] | Is there some sort of formatting protocol for html email? We have an automated system that sends reports via email, when I look at the source I see them delimited by line length with an "=" breaking the line. That is, I get something like :
```
<html><body>some text some text some text some=
some text some text some t... | You have to send the message as [multi-part MIME](http://www.enewsletterpro.com/articles/multi_part_mime_messages.asp). Best practices are:
* Always send an HTML and a pure text version this way for mail clients that don't support HTML or some people just turn off HTML in emails (there are security/spam isssues with i... |
398,781 | <p>I want to build a nice API (C#) to make it easier for people to consume, I think I've seen this before and want to know how to do this:</p>
<pre><code>MyNamespace.Cars car = null;
if(someTestCondition)
car = new Honda();
else
car = new Toyota();
car.Drive(40);
</code></pre>
<p>Is this possible?... | [
{
"answer_id": 398790,
"author": "Aaron Smith",
"author_id": 12969,
"author_profile": "https://Stackoverflow.com/users/12969",
"pm_score": 1,
"selected": false,
"text": "<p>Make a class named Cars. Give it the Drive method. Extend that base class in your Honda and Toyota classes.</p>\n... | 2008/12/29 | [
"https://Stackoverflow.com/questions/398781",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39677/"
] | I want to build a nice API (C#) to make it easier for people to consume, I think I've seen this before and want to know how to do this:
```
MyNamespace.Cars car = null;
if(someTestCondition)
car = new Honda();
else
car = new Toyota();
car.Drive(40);
```
Is this possible? If so, what needs to be d... | ```
Interface Car
{
void Drive(int miles);
}
class Honda : Car
{
...
}
class Toyota : Car
{
...
}
``` |
398,801 | <p>I was wondering what everyone thinks of this. Is the code easy to follow? Or is there a better way to do this? By the way, this is how I am currently doing validation at the moment with ASP.NET MVC. I can follow it, but I am the one who wrote it. For some reason SO is removing the line breaks between the validators.... | [
{
"answer_id": 398810,
"author": "Charlie Martin",
"author_id": 35092,
"author_profile": "https://Stackoverflow.com/users/35092",
"pm_score": 2,
"selected": false,
"text": "<p>I'm not a C# guy by any means, but it appears straightforward. It seems to be putting a bunch of rules into a s... | 2008/12/29 | [
"https://Stackoverflow.com/questions/398801",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43380/"
] | I was wondering what everyone thinks of this. Is the code easy to follow? Or is there a better way to do this? By the way, this is how I am currently doing validation at the moment with ASP.NET MVC. I can follow it, but I am the one who wrote it. For some reason SO is removing the line breaks between the validators.
... | I'll vote yes on puritanical grounds - the formatting is inconsistent and there isn't a comment in sight.
Pragmatically one can follow what you're doing with a little effort though. |
398,803 | <p>I have two report parameters that were set up automatically when I created their associated datasets. They are ReportID and CompanyID. The user selects a Company Name from a list box and a Report Name from another list box. The standard SELECT ID, Name FROM TableName query was used to fill the respective list boxes.... | [
{
"answer_id": 398819,
"author": "Dano",
"author_id": 26938,
"author_profile": "https://Stackoverflow.com/users/26938",
"pm_score": 2,
"selected": false,
"text": "<p>Doesn't throwing in Parameters!ReportID.Value into a textbox in the header work?</p>\n\n<p>From what it sounds like, you s... | 2008/12/29 | [
"https://Stackoverflow.com/questions/398803",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have two report parameters that were set up automatically when I created their associated datasets. They are ReportID and CompanyID. The user selects a Company Name from a list box and a Report Name from another list box. The standard SELECT ID, Name FROM TableName query was used to fill the respective list boxes. Th... | I've had no problem doing this with the original set of parameters that are populated from a query.
In my reports I have a "Farm" parameter which is populated by a "SELECT FarmNumber, FarmName FROM Farms" query. The user selects the farm he wants from a ComboBox. I show the selected farm in the header of the report us... |
398,804 | <p>I've got an existing Access MDB. I'm adding a command button to an existing Form that runs an existing report. The change being made is that this button needs to pass in a parameter containing the ID of the record being reported on - currently the report runs on every record in the MDB.</p>
<p>I've altered the Qu... | [
{
"answer_id": 398854,
"author": "Fionnuala",
"author_id": 2548,
"author_profile": "https://Stackoverflow.com/users/2548",
"pm_score": 6,
"selected": true,
"text": "<p>The DoCmd.OpenReport method has various arguments, one of which is a Where statement:</p>\n\n<pre><code>DoCmd.OpenReport... | 2008/12/29 | [
"https://Stackoverflow.com/questions/398804",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19074/"
] | I've got an existing Access MDB. I'm adding a command button to an existing Form that runs an existing report. The change being made is that this button needs to pass in a parameter containing the ID of the record being reported on - currently the report runs on every record in the MDB.
I've altered the Query that the... | The DoCmd.OpenReport method has various arguments, one of which is a Where statement:
```
DoCmd.OpenReport"rptReport", acViewPreview,,"ID=" & Me.ID
```
That is
```
expression.OpenReport(ReportName, View, FilterName, WhereCondition, WindowMode, OpenArgs)
``` |
398,806 | <p>I have a view that I want to add some custom drawing to.</p>
<p>I know how to do this with a View that isn't connected to a Nib/Xib file </p>
<ul>
<li>you write the drawing code in the <code>-drawRect:</code> method.</li>
</ul>
<p>But if I <code>init</code> the view using</p>
<pre><code>[[MyView alloc] initWithN... | [
{
"answer_id": 399009,
"author": "codelogic",
"author_id": 43427,
"author_profile": "https://Stackoverflow.com/users/43427",
"pm_score": 2,
"selected": false,
"text": "<p>How about doing all the drawing in a simple subview and add it to the XIB view (in viewDidLoad)?</p>\n"
},
{
... | 2008/12/29 | [
"https://Stackoverflow.com/questions/398806",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1075/"
] | I have a view that I want to add some custom drawing to.
I know how to do this with a View that isn't connected to a Nib/Xib file
* you write the drawing code in the `-drawRect:` method.
But if I `init` the view using
```
[[MyView alloc] initWithNibName:@"MyView" bundle:[NSBundle mainBundle]];
```
`-drawRect:` o... | I think the issue is that you're treating a view and its view controller as interchangeable. For example, there's no `-[UIView initWithNibName:bundle:]` method — that's a UIViewController method.
Furthermore, a view isn't really like a "canvas" for drawing. A view will be asked to draw itself; in general, it won't be ... |
398,816 | <p>I'm trying to write javascript to find page elements relative to a given element by using parentNode, firstChild, nextSibling, childNodes[], and so on. Firefox messes this up by inserting text nodes between each html element. I've read that I can defeat this by removing all whitespace between elements but I've tried... | [
{
"answer_id": 398842,
"author": "Ady",
"author_id": 31395,
"author_profile": "https://Stackoverflow.com/users/31395",
"pm_score": 0,
"selected": false,
"text": "<p>you could use tagName to check the name of the tag. If undefined then this is your 'phantom' text node.</p>\n\n<p>e.g.\n<co... | 2008/12/29 | [
"https://Stackoverflow.com/questions/398816",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44394/"
] | I'm trying to write javascript to find page elements relative to a given element by using parentNode, firstChild, nextSibling, childNodes[], and so on. Firefox messes this up by inserting text nodes between each html element. I've read that I can defeat this by removing all whitespace between elements but I've tried th... | I have a workaround. You can insert the two methods below:
```
Element.prototype.fChild = function(){
var firstChild = this.firstChild;
while(firstChild != null && firstChild.nodeType === 3){
firstChild = firstChild.nextSibling;
}
return firstChild;
}
Element.prototype.nSibling = function(){
... |
398,866 | <p>I am running into a design disagreement with a co-worker and would like people's opinion on object constructor design. In brief, which object construction method would you prefer and why? </p>
<pre><code> public class myClass
{
Application m_App;
public myClass(ApplicationObject app)
... | [
{
"answer_id": 398997,
"author": "billybob",
"author_id": 49464,
"author_profile": "https://Stackoverflow.com/users/49464",
"pm_score": 2,
"selected": false,
"text": "<p>My view is that you give the class the smallest set of \"stuff\" it needs for it to do its job. The \"Application\" me... | 2008/12/29 | [
"https://Stackoverflow.com/questions/398866",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2916/"
] | I am running into a design disagreement with a co-worker and would like people's opinion on object constructor design. In brief, which object construction method would you prefer and why?
```
public class myClass
{
Application m_App;
public myClass(ApplicationObject app)
{
... | Hell, why not just make one giant class called "Do" and one method on it called "It" and pass the whole universe into the It method?
```
Do.It(universe)
```
Keep things as small as possible. Discrete means easier to debug when things inevitably break. |
398,871 | <p>Is there a way to do the following using LINQ?</p>
<pre><code>foreach (var c in collection)
{
c.PropertyToSet = value;
}
</code></pre>
<p>To clarify, I want to iterate through each object in a collection and then update a property on each object.</p>
<p>My use case is I have a bunch of comments on a blog post... | [
{
"answer_id": 398894,
"author": "JaredPar",
"author_id": 23283,
"author_profile": "https://Stackoverflow.com/users/23283",
"pm_score": 3,
"selected": false,
"text": "<p>There is no built-in extension method to do this. Although defining one is fairly straight forward. At the bottom of... | 2008/12/29 | [
"https://Stackoverflow.com/questions/398871",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/493/"
] | Is there a way to do the following using LINQ?
```
foreach (var c in collection)
{
c.PropertyToSet = value;
}
```
To clarify, I want to iterate through each object in a collection and then update a property on each object.
My use case is I have a bunch of comments on a blog post, and I want to iterate through e... | While you can use a `ForEach` extension method, if you want to use just the framework you can do
```
collection.Select(c => {c.PropertyToSet = value; return c;}).ToList();
```
The `ToList` is needed in order to evaluate the select immediately due to *lazy evaluation*. |
398,878 | <p>I see that over on this question <a href="https://stackoverflow.com/questions/312024/linqy-way-to-check-if-any-objects-in-a-collection-have-the-same-property-value">LINQy way to check if any objects in a collection have the same property value</a> there is a request to say how to do something using LINQ to see if a ... | [
{
"answer_id": 398912,
"author": "Craig Stuntz",
"author_id": 7714,
"author_profile": "https://Stackoverflow.com/users/7714",
"pm_score": 1,
"selected": false,
"text": "<p>LINQ is almost never the fastest way (in terms of raw execution time) to do anything.</p>\n\n<p>It's usually \"fast ... | 2008/12/29 | [
"https://Stackoverflow.com/questions/398878",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22777/"
] | I see that over on this question [LINQy way to check if any objects in a collection have the same property value](https://stackoverflow.com/questions/312024/linqy-way-to-check-if-any-objects-in-a-collection-have-the-same-property-value) there is a request to say how to do something using LINQ to see if a property match... | >
> However, is this the fastest reasonable process by which to do this?
>
>
>
I'd guess that a fast way (perhaps the fastest way) to do it might be to add all the objects into a Dictionary or a HashSet, using the property as the key field: a method like HashSet.Add has a return code which tells you whether this p... |
398,882 | <p>I'm building an application in C# that has a static class which initiate a COM class and handles some event handlers of another class that hooks keyboard.
When I call a method of the COM class from a button event handler in my WPF window, the method works without any problems but when I call it in one of the event c... | [
{
"answer_id": 465888,
"author": "Vinay",
"author_id": 28641,
"author_profile": "https://Stackoverflow.com/users/28641",
"pm_score": 0,
"selected": false,
"text": "<p>Refer this KB <a href=\"http://support.microsoft.com/kb/198996\" rel=\"nofollow noreferrer\">http://support.microsoft.com... | 2008/12/29 | [
"https://Stackoverflow.com/questions/398882",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34623/"
] | I'm building an application in C# that has a static class which initiate a COM class and handles some event handlers of another class that hooks keyboard.
When I call a method of the COM class from a button event handler in my WPF window, the method works without any problems but when I call it in one of the event call... | Wrap your code in a new thread:
```
Thread thread = new Thread(() =>
{
ManagementObjectSearcher theSearcher = new ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive");
foreach (ManagementObject currentObject in theSearcher.Get())
{
Debug.WriteLine("Device present: " + currentObject); ... |
398,883 | <p>I have a structure</p>
<pre><code>typedef struct my_s {
int x;
...
} my_T;
my_t * p_my_t;
</code></pre>
<p>I want to set the address of <code>p_my_t</code> to <code>NULL</code> and so far this is how I've tried to do this:</p>
<pre><code>memset (&p_my_t, 0, sizeof(my_t*))
</code></pre>
<p>This doesn'... | [
{
"answer_id": 398897,
"author": "Robert Gamble",
"author_id": 25222,
"author_profile": "https://Stackoverflow.com/users/25222",
"pm_score": 4,
"selected": false,
"text": "<p>Don't use <code>memset</code> to initialize a null pointer as this will set the memory to all bits zero which is ... | 2008/12/29 | [
"https://Stackoverflow.com/questions/398883",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a structure
```
typedef struct my_s {
int x;
...
} my_T;
my_t * p_my_t;
```
I want to set the address of `p_my_t` to `NULL` and so far this is how I've tried to do this:
```
memset (&p_my_t, 0, sizeof(my_t*))
```
This doesn't not look right to me though. What is the correct way of doing this?
---
... | Don't use `memset` to initialize a null pointer as this will set the memory to all bits zero which is not guaranteed to be the representation of a null pointer, just do this:
```
p_my_t = NULL;
```
or the equivalent:
```
p_my_t = 0;
``` |
398,886 | <p>I am working with a shared memory application, and to delete the segments I use the following command:</p>
<pre><code> ipcrm -M 0x0000162e (this is the key)
</code></pre>
<p>But I do not know if I'm doing the right things, because when I run <code>ipcs</code> I see the same segment but with the key 0x0000000. So i... | [
{
"answer_id": 398910,
"author": "paxdiablo",
"author_id": 14860,
"author_profile": "https://Stackoverflow.com/users/14860",
"pm_score": 6,
"selected": true,
"text": "<p>I vaguely remember from my UNIX (AIX and HPUX, I'll admit I've never used shared memory in Linux) days that deletion s... | 2008/12/29 | [
"https://Stackoverflow.com/questions/398886",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39160/"
] | I am working with a shared memory application, and to delete the segments I use the following command:
```
ipcrm -M 0x0000162e (this is the key)
```
But I do not know if I'm doing the right things, because when I run `ipcs` I see the same segment but with the key 0x0000000. So is the memory segment really deleted? ... | I vaguely remember from my UNIX (AIX and HPUX, I'll admit I've never used shared memory in Linux) days that deletion simply marks the block as no longer attachable by new clients.
It will only be physically deleted at some point after there are no more processes attached to it.
This is the same as with regular files ... |
398,953 | <p><a href="http://java.sun.com/docs/books/effective/" rel="noreferrer">Effective Java (Second Edition)</a>, Item 4, discusses using private constructors to enforce noninstantiability. Here's the code sample from the book:</p>
<pre><code>public final class UtilityClass {
private UtilityClass() {
throw new ... | [
{
"answer_id": 398960,
"author": "C. K. Young",
"author_id": 13,
"author_profile": "https://Stackoverflow.com/users/13",
"pm_score": 6,
"selected": true,
"text": "<p>There is an assertion: \"I'm asserting that this constructor will never be called\". So, indeed, <code>AssertionError</cod... | 2008/12/29 | [
"https://Stackoverflow.com/questions/398953",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29995/"
] | [Effective Java (Second Edition)](http://java.sun.com/docs/books/effective/), Item 4, discusses using private constructors to enforce noninstantiability. Here's the code sample from the book:
```
public final class UtilityClass {
private UtilityClass() {
throw new AssertionError();
}
}
```
However, `... | There is an assertion: "I'm asserting that this constructor will never be called". So, indeed, `AssertionError` is correct here. |
398,982 | <p>Which types of classes can use <code>foreach</code> loops?</p>
| [
{
"answer_id": 398986,
"author": "George Stocker",
"author_id": 16587,
"author_profile": "https://Stackoverflow.com/users/16587",
"pm_score": 3,
"selected": false,
"text": "<p>From <a href=\"http://msdn.microsoft.com/en-us/library/ttw7t8t6(VS.80).aspx\" rel=\"noreferrer\">MSDN</a>: </p>\... | 2008/12/29 | [
"https://Stackoverflow.com/questions/398982",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48616/"
] | Which types of classes can use `foreach` loops? | Actually, **strictly** speaking, all you need to use `foreach` is a public `GetEnumerator()` method that returns something with a `bool MoveNext()` method and a `? Current {get;}` property. However, the most **common** meaning of this is "something that implements `IEnumerable`/`IEnumerable<T>`, returning an `IEnumerat... |
399,021 | <p>I recently came upon something called <a href="http://sourceforge.net/projects/rpoku/" rel="nofollow noreferrer">Rpoku</a> which is a spoken computer language. I also found some research called <a href="http://sourceforge.net/projects/voicecode/" rel="nofollow noreferrer">Voice Code</a> which takes a different appro... | [
{
"answer_id": 399047,
"author": "George Stocker",
"author_id": 16587,
"author_profile": "https://Stackoverflow.com/users/16587",
"pm_score": 1,
"selected": false,
"text": "<p>I've been thinking about this one a lot; and I think it would take a paradigm shift (not to mention advances in ... | 2008/12/29 | [
"https://Stackoverflow.com/questions/399021",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11397/"
] | I recently came upon something called [Rpoku](http://sourceforge.net/projects/rpoku/) which is a spoken computer language. I also found some research called [Voice Code](http://sourceforge.net/projects/voicecode/) which takes a different approach. There's a [demo video here](http://www.youtube.com/watch?v=A7f9Iik3q58).... | I've been thinking about this one a lot; and I think it would take a paradigm shift (not to mention advances in AI on the scale of Star Trek) to allow programmers to be as productive orally as they are when writing.
For instance, in this simple code example, I'm actually saying a lot more than I'm typing:
```
List<E... |
399,022 | <p>Why doesn't the following work (Python 2.5.2)?</p>
<pre><code>>>> import datetime
>>> class D(datetime.date):
def __init__(self, year):
datetime.date.__init__(self, year, 1, 1)
>>> D(2008)
Traceback (most recent call last):
File "<stdin>", line 1, in <module... | [
{
"answer_id": 399033,
"author": "Vinko Vrsalovic",
"author_id": 5190,
"author_profile": "https://Stackoverflow.com/users/5190",
"pm_score": 2,
"selected": false,
"text": "<p>Here's the answer, and a possible solution (use a function or strptime instead of subclassing)</p>\n\n<p><a href=... | 2008/12/29 | [
"https://Stackoverflow.com/questions/399022",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1626/"
] | Why doesn't the following work (Python 2.5.2)?
```
>>> import datetime
>>> class D(datetime.date):
def __init__(self, year):
datetime.date.__init__(self, year, 1, 1)
>>> D(2008)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: function takes exactly 3 arguments (1... | Regarding several other answers, this doesn't have anything to do with dates being implemented in C per se. The `__init__` method does nothing because they are *immutable* objects, therefore the constructor (`__new__`) should do all the work. You would see the same behavior subclassing int, str, etc.
```
>>> import da... |
399,032 | <p>Im writing a program at the moment that interacts with a MySQL database and im having a problem. As you can see I've written a query that will look for products in the products table that corresponds to the barcode that the user has inputted. </p>
<p>If the barcode that is input by the user is found in the products... | [
{
"answer_id": 399056,
"author": "orip",
"author_id": 37020,
"author_profile": "https://Stackoverflow.com/users/37020",
"pm_score": 0,
"selected": false,
"text": "<p>Are you expecting a single row as a result? If so, try this:</p>\n\n<pre><code>row = cursor.fetchone()\nprint row[\"produc... | 2008/12/29 | [
"https://Stackoverflow.com/questions/399032",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47204/"
] | Im writing a program at the moment that interacts with a MySQL database and im having a problem. As you can see I've written a query that will look for products in the products table that corresponds to the barcode that the user has inputted.
If the barcode that is input by the user is found in the products table, I ... | The answer depends on what you mean by "assign a variable to a for loop." This wording is confusing because a for loop is a tool for controlling the flow of execution -- it's not normally thought of as having a value. But I think I know what you mean. Every time the loop runs, it will execute `print "%s" % (row["produc... |
399,040 | <p>I'd like to know if there is a way to tell the Enterprise Library Caching objects to flush all configured caches for that process to flush.</p>
<p>Even enumerating through all of the configured caches for that process, and manually flushing each one, is ok, but is there an API method from EntLib.Caching that will g... | [
{
"answer_id": 3121511,
"author": "Shiraz Bhaiji",
"author_id": 86611,
"author_profile": "https://Stackoverflow.com/users/86611",
"pm_score": 0,
"selected": false,
"text": "<p>I do not think that there is a way to flush all caches. Recycling the application pool would do it, but this wou... | 2008/12/29 | [
"https://Stackoverflow.com/questions/399040",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/698/"
] | I'd like to know if there is a way to tell the Enterprise Library Caching objects to flush all configured caches for that process to flush.
Even enumerating through all of the configured caches for that process, and manually flushing each one, is ok, but is there an API method from EntLib.Caching that will give me tho... | How about this:
```
CacheManagerSettings conf = (CacheManagerSettings)ConfigurationSourceFactory.Create()
.GetSection(CacheManagerSettings.SectionName);
conf.CacheManagers.ForEach(delegate(CacheManagerDataBase cache) {
CacheFactory.GetCacheManager(cache.Name).Flush();
});
``` |
399,045 | <p>I can't seem to get it to "work". Perhaps I'm not even testing it correctly. I've got a <%= DateTime.Now.ToString() %> line in my aspx page. I've tried setting caching declarativly like this</p>
<pre><code><%@ OutputCache VaryByParam="SchoolId" Duration="180" Location="Server" NoStore="false" %>
</code>... | [
{
"answer_id": 399059,
"author": "Steven Behnke",
"author_id": 42588,
"author_profile": "https://Stackoverflow.com/users/42588",
"pm_score": 1,
"selected": false,
"text": "<p>I don't think this will work because DateTime.Now is a property that is always updated. You'd have to save it in... | 2008/12/29 | [
"https://Stackoverflow.com/questions/399045",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/50011/"
] | I can't seem to get it to "work". Perhaps I'm not even testing it correctly. I've got a <%= DateTime.Now.ToString() %> line in my aspx page. I've tried setting caching declarativly like this
```
<%@ OutputCache VaryByParam="SchoolId" Duration="180" Location="Server" NoStore="false" %>
```
I've also tried setting it ... | ugh. The issue was a Response.Cache.SetCacheability(HttpCacheability.NoCache) in the Page\_Load of a usercontrol buried 3 levels deep from the page. I appreciate the help, though.
-al |
399,053 | <p>I've read a lot of tutorials and can not really find anything comprehensive on this subject. </p>
<p>I had written the following code to do one function:</p>
<pre><code>#include <fstream>
#include <string>
#include <iostream>
using namespace std;
ifstream ReadFile( ifstream& openInputFile, ... | [
{
"answer_id": 399094,
"author": "Doug T.",
"author_id": 8123,
"author_profile": "https://Stackoverflow.com/users/8123",
"pm_score": 0,
"selected": false,
"text": "<p>It seems you shouldn't need to return by pointer in the above case.</p>\n\n<p>If you do need to return a modified result,... | 2008/12/29 | [
"https://Stackoverflow.com/questions/399053",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40120/"
] | I've read a lot of tutorials and can not really find anything comprehensive on this subject.
I had written the following code to do one function:
```
#include <fstream>
#include <string>
#include <iostream>
using namespace std;
ifstream ReadFile( ifstream& openInputFile, string& sLine, int& chgLine );
int main()
... | The C++ way to do this would be to create a class that wraps up all of the opening, reading and writing. Note that this would also handle closing the file automatically, a good example of [RAII](http://en.wikipedia.org/wiki/Resource_acquisition_is_initialization).
```
// FancyFile.h:
class FancyFile
{
private:
... |
399,066 | <p>I'm writing an algorithm in PHP to solve a given Sudoku puzzle. I've set up a somewhat object-oriented implementation with two classes: a <code>Square</code> class for each individual tile on the 9x9 board, and a <code>Sudoku</code> class, which has a matrix of <code>Square</code>s to represent the board.</p>
<p>T... | [
{
"answer_id": 399225,
"author": "PEZ",
"author_id": 44639,
"author_profile": "https://Stackoverflow.com/users/44639",
"pm_score": 3,
"selected": true,
"text": "<p>This is somewhat like what you have already ruled out as \"extremely inefficient\", but with builtin functions so it might b... | 2008/12/29 | [
"https://Stackoverflow.com/questions/399066",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13604/"
] | I'm writing an algorithm in PHP to solve a given Sudoku puzzle. I've set up a somewhat object-oriented implementation with two classes: a `Square` class for each individual tile on the 9x9 board, and a `Sudoku` class, which has a matrix of `Square`s to represent the board.
The implementation of the algorithm I'm using... | This is somewhat like what you have already ruled out as "extremely inefficient", but with builtin functions so it might be quite efficient:
```
$all_possibilities = "1234567891234";
$unique = array();
foreach (count_chars($all_possibilities, 1) as $c => $occurrences) {
if ($occurrences == 1)
$unique[] = chr($c... |
399,067 | <p>Bear with me while I explain my question. Skip down to the bold heading if you already understand extended slice list indexing.</p>
<p>In python, you can index lists using slice notation. Here's an example:</p>
<pre><code>>>> A = list(range(10))
>>> A[0:5]
[0, 1, 2, 3, 4]
</code></pre>
<p>You c... | [
{
"answer_id": 399082,
"author": "Charlie Martin",
"author_id": 35092,
"author_profile": "https://Stackoverflow.com/users/35092",
"pm_score": 0,
"selected": false,
"text": "<pre><code>a[4::-1]\n</code></pre>\n\n<p>Example:</p>\n\n<pre><code>Python 2.6 (r26:66714, Dec 4 2008, 11:34:15) \... | 2008/12/29 | [
"https://Stackoverflow.com/questions/399067",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44743/"
] | Bear with me while I explain my question. Skip down to the bold heading if you already understand extended slice list indexing.
In python, you can index lists using slice notation. Here's an example:
```
>>> A = list(range(10))
>>> A[0:5]
[0, 1, 2, 3, 4]
```
You can also include a stride, which acts like a "step":
... | Ok, I think this is probably as good as I will get it. Thanks to Abgan for sparking the idea. This relies on the fact that None in a slice is treated as if it were a missing parameter. Anyone got anything better?
```
def getReversedList(aList, end, start, step):
return aList[end:start if start!=-1 else None:step]
... |
399,078 | <p>I am tired of always trying to guess, if I should escape special characters like '<code>()[]{}|</code>' etc. when using many implementations of regexps.</p>
<p>It is different with, for example, Python, sed, grep, awk, Perl, rename, Apache, find and so on.
Is there any rule set which tells when I should, and when I... | [
{
"answer_id": 399087,
"author": "Charlie Martin",
"author_id": 35092,
"author_profile": "https://Stackoverflow.com/users/35092",
"pm_score": 2,
"selected": false,
"text": "<p>Really, there isn't. there are about a half-zillion different regex syntaxes; they seem to come down to Perl, E... | 2008/12/29 | [
"https://Stackoverflow.com/questions/399078",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37511/"
] | I am tired of always trying to guess, if I should escape special characters like '`()[]{}|`' etc. when using many implementations of regexps.
It is different with, for example, Python, sed, grep, awk, Perl, rename, Apache, find and so on.
Is there any rule set which tells when I should, and when I should not, escape s... | Which characters you must and which you mustn't escape indeed depends on the regex flavor you're working with.
For PCRE, and most other so-called Perl-compatible flavors, escape these outside character classes:
```
.^$*+?()[{\|
```
and these inside character classes:
```
^-]\
```
For POSIX extended regexes (ERE)... |
399,101 | <p>Here is some XAML</p>
<pre><code><HierarchicalDataTemplate DataType="{x:Type data:FolderEntity}"
ItemsSource="{Binding Path=FolderEntities,UpdateSourceTrigger=PropertyChanged}">
<Label Content="{Binding FolderName}"/>
</HierarchicalDataTemplate>
<TreeView/>
</code></pre>
<p>data:Folder... | [
{
"answer_id": 399127,
"author": "Matt Hamilton",
"author_id": 615,
"author_profile": "https://Stackoverflow.com/users/615",
"pm_score": 3,
"selected": true,
"text": "<p>Yes, the underlying collection (FolderEntities) will need to be an <code>ObservableCollection<T></code> for the ... | 2008/12/29 | [
"https://Stackoverflow.com/questions/399101",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/58961/"
] | Here is some XAML
```
<HierarchicalDataTemplate DataType="{x:Type data:FolderEntity}"
ItemsSource="{Binding Path=FolderEntities,UpdateSourceTrigger=PropertyChanged}">
<Label Content="{Binding FolderName}"/>
</HierarchicalDataTemplate>
<TreeView/>
```
data:FolderEntity is a LINQ to SQL data class which implement... | Yes, the underlying collection (FolderEntities) will need to be an `ObservableCollection<T>` for the HierarchicalDataTemplate to be notified of the changes. Either that or a collection that implements [INotifyCollectionChanged](http://msdn.microsoft.com/en-us/library/system.collections.specialized.inotifycollectionchan... |
399,114 | <p>C++ offers three floating point types: float, double, and long double. I infrequently use floating-point in my code, but when I do, I'm always caught out by warnings on innocuous lines like</p>
<pre><code>float PiForSquares = 4.0;
</code></pre>
<p>The problem is that the literal 4.0 is a double, not a float - Whic... | [
{
"answer_id": 399120,
"author": "Doug T.",
"author_id": 8123,
"author_profile": "https://Stackoverflow.com/users/8123",
"pm_score": 5,
"selected": false,
"text": "<p>You probably knew this, but you <strong>can</strong> make literal floats/long doubles</p>\n\n<pre><code> float f = 4.0f;\... | 2008/12/29 | [
"https://Stackoverflow.com/questions/399114",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1737/"
] | C++ offers three floating point types: float, double, and long double. I infrequently use floating-point in my code, but when I do, I'm always caught out by warnings on innocuous lines like
```
float PiForSquares = 4.0;
```
The problem is that the literal 4.0 is a double, not a float - Which is irritating.
For inte... | You probably knew this, but you **can** make literal floats/long doubles
```
float f = 4.0f;
long double f = 4.0l;
```
Double is the default because thats what most people use. Long doubles may be overkill or and floats have very bad precision. Double works for almost every application.
Why the naming? One day al... |
399,129 | <p>I've been trying (and failing) to figure out how to send email via Python.</p>
<p>Trying the example from here:
<a href="http://docs.python.org/library/smtplib.html#smtplib.SMTP" rel="noreferrer">http://docs.python.org/library/smtplib.html#smtplib.SMTP</a></p>
<p>but added the line <code>server = smtplib.SMTP_SSL(... | [
{
"answer_id": 399140,
"author": "Abgan",
"author_id": 46308,
"author_profile": "https://Stackoverflow.com/users/46308",
"pm_score": 1,
"selected": false,
"text": "<p>Incorrect port maybe? I'm using <strong>587</strong> for <strong>smtp.gmail.com</strong> and it works.</p>\n"
},
{
... | 2008/12/29 | [
"https://Stackoverflow.com/questions/399129",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/50019/"
] | I've been trying (and failing) to figure out how to send email via Python.
Trying the example from here:
<http://docs.python.org/library/smtplib.html#smtplib.SMTP>
but added the line `server = smtplib.SMTP_SSL('smtp.gmail.com', 465)` after I got a bounceback about not having an SSL connection.
Now I'm getting this:... | The following code works for me:
```
import smtplib
FROMADDR = "my.real.address@gmail.com"
LOGIN = FROMADDR
PASSWORD = "my.real.password"
TOADDRS = ["my.real.address@gmail.com"]
SUBJECT = "Test"
msg = ("From: %s\r\nTo: %s\r\nSubject: %s\r\n\r\n"
% (FROMADDR, ", ".join(TOADDRS), SUBJECT) )
msg += "some te... |
399,135 | <p>When using Visual Studio (though ideally this can apply to the generic case) and double click on a button I've created, the event handler code that is auto generated uses the following signature:</p>
<pre><code>Protected Sub btnSubmitRequest_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnSubmitReque... | [
{
"answer_id": 399145,
"author": "recursive",
"author_id": 44743,
"author_profile": "https://Stackoverflow.com/users/44743",
"pm_score": 4,
"selected": true,
"text": "<p>Create another method called <code>SubmitNewEmployeeRequest</code>. In <code>btnSubmitRequest_Click</code>, call <cod... | 2008/12/29 | [
"https://Stackoverflow.com/questions/399135",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/71/"
] | When using Visual Studio (though ideally this can apply to the generic case) and double click on a button I've created, the event handler code that is auto generated uses the following signature:
```
Protected Sub btnSubmitRequest_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnSubmitRequest.Click
End ... | Create another method called `SubmitNewEmployeeRequest`. In `btnSubmitRequest_Click`, call `SubmitNewEmployeeRequest`. That is the most logical separation of duties. |
399,137 | <p>Here's a PHP example of mine. Can anyone find a shorter/easier way to do this?</p>
<pre><code><? foreach($posts as $post){?>
<div class="<?=($c++%2==1)?‘odd’:NULL?>">
<?=$post?>
</div>
<? }?>
<style>
.odd{background-color:red;}
</style>
</code></p... | [
{
"answer_id": 399156,
"author": "Vilx-",
"author_id": 41360,
"author_profile": "https://Stackoverflow.com/users/41360",
"pm_score": 7,
"selected": true,
"text": "<p>Fundamentally - no. That's about as easy as it gets. You might rewrite it a bit shorter/cleaner, but the idea will be the ... | 2008/12/29 | [
"https://Stackoverflow.com/questions/399137",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46443/"
] | Here's a PHP example of mine. Can anyone find a shorter/easier way to do this?
```
<? foreach($posts as $post){?>
<div class="<?=($c++%2==1)?‘odd’:NULL?>">
<?=$post?>
</div>
<? }?>
<style>
.odd{background-color:red;}
</style>
```
Examples in other languages would be fun to see as well. | Fundamentally - no. That's about as easy as it gets. You might rewrite it a bit shorter/cleaner, but the idea will be the same. This is how I would write it:
```
$c = true; // Let's not forget to initialize our variables, shall we?
foreach($posts as $post)
echo '<div'.(($c = !$c)?' class="odd"':'').">$post</div>";... |
399,155 | <p>I posted days ago about access control to web service (<a href="https://stackoverflow.com/questions/390853/access-control-to-web-service">Access control to web service</a>). In short, I have an ASP.NET web service deployed on <strong>//service/webservice</strong> and I want my ASP.NET web application (app1) on the <... | [
{
"answer_id": 410195,
"author": "ccook",
"author_id": 51275,
"author_profile": "https://Stackoverflow.com/users/51275",
"pm_score": 2,
"selected": false,
"text": "<p>Sounds like the SSL certificate is failing to authenticate for the web service client. A good check is if you go to the ... | 2008/12/30 | [
"https://Stackoverflow.com/questions/399155",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31936/"
] | I posted days ago about access control to web service ([Access control to web service](https://stackoverflow.com/questions/390853/access-control-to-web-service)). In short, I have an ASP.NET web service deployed on **//service/webservice** and I want my ASP.NET web application (app1) on the **//web1** to access the web... | Sounds like the SSL certificate is failing to authenticate for the web service client. A good check is if you go to the service from the client’s machine and get an alert in the browser about an SSL certificate your service will not authenticate with the certificate (certificate is not trusted). It’s not that the certi... |
399,190 | <p>When using ActionLink to render data from database which has HTML tags </p>
<pre><code>(ie <p>)
</code></pre>
<p>incorporated in it, ActionLink escapes the tags. What is the best way to handle this? </p>
| [
{
"answer_id": 399191,
"author": "Ady",
"author_id": 31395,
"author_profile": "https://Stackoverflow.com/users/31395",
"pm_score": 4,
"selected": true,
"text": "<p><a href=\"http://www.ffmpeg.org/\" rel=\"noreferrer\">ffmpeg</a> is probably your best bet, there is even a <a href=\"http:/... | 2008/12/30 | [
"https://Stackoverflow.com/questions/399190",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49632/"
] | When using ActionLink to render data from database which has HTML tags
```
(ie <p>)
```
incorporated in it, ActionLink escapes the tags. What is the best way to handle this? | [ffmpeg](http://www.ffmpeg.org/) is probably your best bet, there is even a [php module](http://ffmpeg-php.sourceforge.net/) of it.
ffmpeg -i "FileName"
Alternativly you could read the information from the flv file directly by opening the file and reading the meta information. |
399,202 | <p>I thought a great way to test my understanding of generic functions would be to create a function that would spit out a hex representation of a hash using one of the classes that inherits from HashAlgorithm. Since all of the HashAlgorithm classes offer ComputeHash, I thought this would be simple. When I construct su... | [
{
"answer_id": 399217,
"author": "Matt Hamilton",
"author_id": 615,
"author_profile": "https://Stackoverflow.com/users/615",
"pm_score": 3,
"selected": true,
"text": "<p>Try adding the <code>new()</code> clause to the end of your generic constraints:</p>\n\n<pre><code>public static strin... | 2008/12/30 | [
"https://Stackoverflow.com/questions/399202",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48700/"
] | I thought a great way to test my understanding of generic functions would be to create a function that would spit out a hex representation of a hash using one of the classes that inherits from HashAlgorithm. Since all of the HashAlgorithm classes offer ComputeHash, I thought this would be simple. When I construct such ... | Try adding the `new()` clause to the end of your generic constraints:
```
public static string GetHexHash<HashAlgorithmToUse>(Stream dataStreamToHash)
where HashAlgorithmToUse : HashAlgorithm, new()
```
This tells the type that "HashAlgorithmToUse" has a parameterless (default) constructor. Should do the trick. |
399,204 | <p>Given the following xml fragment:</p>
<pre><code><Problems>
<Problem>
<File>file1</File>
<Description>desc1</Description>
</Problem>
<Problem>
<File>file1</File>
<Description>desc2</Description>
</Problem>
<Pr... | [
{
"answer_id": 399262,
"author": "Richard A",
"author_id": 24355,
"author_profile": "https://Stackoverflow.com/users/24355",
"pm_score": 4,
"selected": true,
"text": "<p>Here's how I'd do it, using the Muenchean method. Google 'xslt muenchean' for more info from smarter people. There mig... | 2008/12/30 | [
"https://Stackoverflow.com/questions/399204",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/246/"
] | Given the following xml fragment:
```
<Problems>
<Problem>
<File>file1</File>
<Description>desc1</Description>
</Problem>
<Problem>
<File>file1</File>
<Description>desc2</Description>
</Problem>
<Problem>
<File>file2</File>
<Description>desc1</Description>
</Problem>
</Problems>
``... | Here's how I'd do it, using the Muenchean method. Google 'xslt muenchean' for more info from smarter people. There might be a clever way, but I'll leave that to others.
One note, I avoid using capitals at the start of xml element names, eg 'File', but that's up to you.
```
<?xml version="1.0"?>
<xsl:stylesheet versio... |
399,209 | <p>In bash is there a quick way to do tab auto-completion based on the middle of a word. </p>
<p>So for example, if I have these files in a directory: </p>
<pre><code>001_apple.txt 002_pear.txt 003_dog.txt
</code></pre>
<p>I would like to type the sequence: <code>*d<TAB></code> to auto-complete 003_dog.txt. <... | [
{
"answer_id": 399221,
"author": "Ben",
"author_id": 36522,
"author_profile": "https://Stackoverflow.com/users/36522",
"pm_score": 0,
"selected": false,
"text": "<p>You can substitute \n<code>`ls *d*`</code>\n to achieve the same effect, not quite as convenient as tab-completion however<... | 2008/12/30 | [
"https://Stackoverflow.com/questions/399209",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17174/"
] | In bash is there a quick way to do tab auto-completion based on the middle of a word.
So for example, if I have these files in a directory:
```
001_apple.txt 002_pear.txt 003_dog.txt
```
I would like to type the sequence: `*d<TAB>` to auto-complete 003\_dog.txt.
Can this be done in bash? Is it easier to do in ... | Try ESC-g for glob expansion.
And you should always install the bash-completion package (included by default often, but you need to source it in your bash profile script). |
399,214 | <p>here is some sample javascript:</p>
<pre><code>SomeObjectType = function() {
}
SomeObjectType.prototype = {
field1: null,
field2: null
}
SomeOtherObject = function() {
}
SomeOtherObject.prototype =
{
doSomething: function(val) {
/// <param name="val" type="SomeObjectType"></param>... | [
{
"answer_id": 414593,
"author": "Alan Oursland",
"author_id": 37189,
"author_profile": "https://Stackoverflow.com/users/37189",
"pm_score": 3,
"selected": true,
"text": "<p>That is not supported in VS 2008. It will be supported in the next version.</p>\n\n<p>In VS 2008, the XML comments... | 2008/12/30 | [
"https://Stackoverflow.com/questions/399214",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3543/"
] | here is some sample javascript:
```
SomeObjectType = function() {
}
SomeObjectType.prototype = {
field1: null,
field2: null
}
SomeOtherObject = function() {
}
SomeOtherObject.prototype =
{
doSomething: function(val) {
/// <param name="val" type="SomeObjectType"></param>
var val2 = new So... | That is not supported in VS 2008. It will be supported in the next version.
In VS 2008, the XML comments are only used to generate tooltip information. And I think the tooltips may only be supported in referenced files. |
399,222 | <p>Isn't the use of delegates to help with some asynchronous cases? I tried the following but my UI still hangs. When on earth do you use delegates?</p>
<pre><code> Public Class Form1
Private Delegate Sub testDelegate()
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As _
System.EventA... | [
{
"answer_id": 399229,
"author": "Otávio Décio",
"author_id": 48684,
"author_profile": "https://Stackoverflow.com/users/48684",
"pm_score": 2,
"selected": false,
"text": "<p>Here's what I sent to a coworker:</p>\n\n<p>Basically delegates can be used for Callbacks, Events and Asynchronous... | 2008/12/30 | [
"https://Stackoverflow.com/questions/399222",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23667/"
] | Isn't the use of delegates to help with some asynchronous cases? I tried the following but my UI still hangs. When on earth do you use delegates?
```
Public Class Form1
Private Delegate Sub testDelegate()
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As _
System.EventArgs) Handles B... | It's kind of ironic, but everybody's favorite answer (use BeginInvoke) is not in fact correct. The delegate target method will execute on a threadpool thread. You are not allowed to touch controls on a thread other than the thread that created them, almost always the program's main thread.
If you try it using the .NET... |
399,250 | <p>PHP's parse_url() has a host field, which includes the full host. I'm looking for the most reliable (and least costly) way to only return the domain and TLD.</p>
<p>Given the examples:</p>
<ul>
<li><a href="http://www.google.com/foo" rel="noreferrer">http://www.google.com/foo</a>, parse_url() returns www.google.c... | [
{
"answer_id": 399258,
"author": "Gavin M. Roy",
"author_id": 13203,
"author_profile": "https://Stackoverflow.com/users/13203",
"pm_score": 1,
"selected": false,
"text": "<p>Dug this up from a related post, for the idea of keeping a table: <a href=\"http://mxr.mozilla.org/mozilla-centra... | 2008/12/30 | [
"https://Stackoverflow.com/questions/399250",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13203/"
] | PHP's parse\_url() has a host field, which includes the full host. I'm looking for the most reliable (and least costly) way to only return the domain and TLD.
Given the examples:
* <http://www.google.com/foo>, parse\_url() returns www.google.com for host
* <http://www.google.co.uk/foo>, parse\_url() returns www.googl... | How about something like that?
```
function getDomain($url) {
$pieces = parse_url($url);
$domain = isset($pieces['host']) ? $pieces['host'] : '';
if (preg_match('/(?P<domain>[a-z0-9][a-z0-9\-]{1,63}\.[a-z\.]{2,6})$/i', $domain, $regs)) {
return $regs['domain'];
}
return false;
}
```
Will extract the do... |
399,252 | <p>For testing purposes I want send mail to my localhost user account rather than my webserver. I am unsure how to do this using mail.app. Any help would be appreciated.</p>
| [
{
"answer_id": 399284,
"author": "codelogic",
"author_id": 43427,
"author_profile": "https://Stackoverflow.com/users/43427",
"pm_score": 4,
"selected": true,
"text": "<p>If you don't specifically want to use Mail.app, you can send mail using the <code>mail</code> command. Open Terminal a... | 2008/12/30 | [
"https://Stackoverflow.com/questions/399252",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49684/"
] | For testing purposes I want send mail to my localhost user account rather than my webserver. I am unsure how to do this using mail.app. Any help would be appreciated. | If you don't specifically want to use Mail.app, you can send mail using the `mail` command. Open Terminal and:
```
mail -s "Testing" `whoami`@`hostname`
<type something>
Ctrl-D to finish and send
```
Those are backticks, not single quotes. `whoami` returns the current user's username and `hostname` returns the local... |
399,263 | <p>I'm writing a Firefox extension that needs to know what the username of the currently logged in user is in Windows, Mac, or Linux. So if I'm logged into my machine as "brh", it'll return "brh". Any idea how to do that from extension JavaScript?</p>
| [
{
"answer_id": 399333,
"author": "Dave Kasper",
"author_id": 859,
"author_profile": "https://Stackoverflow.com/users/859",
"pm_score": 0,
"selected": false,
"text": "<p>Don't think that's possible, seems like it would be a security hole if it were.</p>\n"
},
{
"answer_id": 399381... | 2008/12/30 | [
"https://Stackoverflow.com/questions/399263",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11284/"
] | I'm writing a Firefox extension that needs to know what the username of the currently logged in user is in Windows, Mac, or Linux. So if I'm logged into my machine as "brh", it'll return "brh". Any idea how to do that from extension JavaScript? | Firefox extensions play by different rules to normal JavaScript running in the page: finding the current user is absolutely possible.
Open your Error Console (in Tools) and enter this:
```
Components.classes["@mozilla.org/process/environment;1"].getService(Components.interfaces.nsIEnvironment).get('USER')
```
The e... |
399,270 | <p>If I'm using a <code>Hashtable</code>, I can write code like this:</p>
<pre><code>object item = hashtable[key] ?? default_value;
</code></pre>
<p>That works whether or not <code>key</code> appears in the <code>Hashtable</code>.</p>
<p>I can't do that with a <code>Dictionary<TKey. TValue></code>. If the key... | [
{
"answer_id": 399276,
"author": "Sparr",
"author_id": 13675,
"author_profile": "https://Stackoverflow.com/users/13675",
"pm_score": 0,
"selected": false,
"text": "<p>I am pretty sure that this restriction is one of the functional reasons for the creation of the wrapper in the first plac... | 2008/12/30 | [
"https://Stackoverflow.com/questions/399270",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19403/"
] | If I'm using a `Hashtable`, I can write code like this:
```
object item = hashtable[key] ?? default_value;
```
That works whether or not `key` appears in the `Hashtable`.
I can't do that with a `Dictionary<TKey. TValue>`. If the key's not present in the dictionary, that will throw a `KeyNotFoundException`. So I hav... | The difference between a `Dictionary<T>` and a `Hashtable` is that a `Dictionary<T>` is a generic type that can specialize to store value types along reference types.
The hashtable can only store reference types (a `Object` passed by reference) and only value types that are boxed (also passed by reference).
When a di... |