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 |
|---|---|---|---|---|---|---|
282,035 | <p>How does one lock the focus of a .net application to a specific control? For example, if I have a form with 5 text boxes, and I want them filled out in a specific order, how can I stop someone who is in box 1 from tabbing/clicking to box 2, or hitting OK or Cancel or anything else? Is there an easy way, or do I ha... | [
{
"answer_id": 282060,
"author": "Serhat Ozgel",
"author_id": 31505,
"author_profile": "https://Stackoverflow.com/users/31505",
"pm_score": 2,
"selected": false,
"text": "<p>Handle the Leave event of your textBox1. Inside the event handler, if your conditions are not met, for e.g. if the... | 2008/11/11 | [
"https://Stackoverflow.com/questions/282035",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | How does one lock the focus of a .net application to a specific control? For example, if I have a form with 5 text boxes, and I want them filled out in a specific order, how can I stop someone who is in box 1 from tabbing/clicking to box 2, or hitting OK or Cancel or anything else? Is there an easy way, or do I have to... | Handle the Leave event of your textBox1. Inside the event handler, if your conditions are not met, for e.g. if the user has not entered some input, reset the focus back to the control.
```
private void textBox1_Leave(object sender, EventArgs e)
{
if string.isNullOrEmpty(textBox1.Text)
{
textBox1.focus(... |
282,061 | <p>I have a bit of a problem. I wrote an API a long time ago for our production system, and it used Apache XML Beans. The schema was homogeneous (ie no imports, everything was from within the same schema), and everything worked just fine, even if the code for API handling was incredibly verbose. I've since written a... | [
{
"answer_id": 282060,
"author": "Serhat Ozgel",
"author_id": 31505,
"author_profile": "https://Stackoverflow.com/users/31505",
"pm_score": 2,
"selected": false,
"text": "<p>Handle the Leave event of your textBox1. Inside the event handler, if your conditions are not met, for e.g. if the... | 2008/11/11 | [
"https://Stackoverflow.com/questions/282061",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32232/"
] | I have a bit of a problem. I wrote an API a long time ago for our production system, and it used Apache XML Beans. The schema was homogeneous (ie no imports, everything was from within the same schema), and everything worked just fine, even if the code for API handling was incredibly verbose. I've since written a far s... | Handle the Leave event of your textBox1. Inside the event handler, if your conditions are not met, for e.g. if the user has not entered some input, reset the focus back to the control.
```
private void textBox1_Leave(object sender, EventArgs e)
{
if string.isNullOrEmpty(textBox1.Text)
{
textBox1.focus(... |
282,062 | <p>I have a class like this:</p>
<pre><code>public class Stretcher : Panel {
public static readonly DependencyProperty StretchAmountProp = DependencyProperty.RegisterAttached("StretchAmount", typeof(double), typeof(Stretcher), null);
public static void SetStretchAmount(DependencyObject obj, double amount)
... | [
{
"answer_id": 282410,
"author": "Bryant",
"author_id": 10893,
"author_profile": "https://Stackoverflow.com/users/10893",
"pm_score": 3,
"selected": true,
"text": "<p>I think I figured this out, although I'm not totally sure I understand the reason why it works. </p>\n\n<p>In order to ge... | 2008/11/11 | [
"https://Stackoverflow.com/questions/282062",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6803/"
] | I have a class like this:
```
public class Stretcher : Panel {
public static readonly DependencyProperty StretchAmountProp = DependencyProperty.RegisterAttached("StretchAmount", typeof(double), typeof(Stretcher), null);
public static void SetStretchAmount(DependencyObject obj, double amount)
{
Fr... | I think I figured this out, although I'm not totally sure I understand the reason why it works.
In order to get your example to work I had to create a custom type called Stretch with a property called StretchAmount. Once I did that and put that inside the property element tags it worked. Otherwise it wasn't called.
... |
282,084 | <p>Help!</p>
<p>I have a PHP (PHP 5.2.5) script on HOST1 trying to connect to an MySql database HOST2. Both hosts are in Shared Host environments controlled through CPanel.</p>
<p>HOST2 is set to allow remote database connections from HOST1.</p>
<p>The PHP connect I'm using is:-
$h2 = IPADDRESS;
$dbu = DBUSE... | [
{
"answer_id": 282112,
"author": "willasaywhat",
"author_id": 12234,
"author_profile": "https://Stackoverflow.com/users/12234",
"pm_score": 1,
"selected": false,
"text": "<p>Just some ideas:</p>\n\n<ul>\n<li>HOST1 does not have remote access to HOST2 (shared host is disallowing)</li>\n<l... | 2008/11/11 | [
"https://Stackoverflow.com/questions/282084",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27200/"
] | Help!
I have a PHP (PHP 5.2.5) script on HOST1 trying to connect to an MySql database HOST2. Both hosts are in Shared Host environments controlled through CPanel.
HOST2 is set to allow remote database connections from HOST1.
The PHP connect I'm using is:-
$h2 = IPADDRESS;
$dbu = DBUSER;
$dbp = DBPASS;
```
$DBlin... | somestring is probably the reverse-lookup for your web-server.
Can you modify privileges from your cPanel? Have you done anything to allow access from your workstation (ODBC)?
The error-message seems to indicate that you have network-access to the mysql-server, but not privileges for your username from that specific ... |
282,091 | <p>I am instantiating a local COM server using CoCreateInstance. Sometimes the application providing the server takes a long time to start. When this happens, Windows pops a dialog box like this:</p>
<p><strong>Server Busy</strong></p>
<p>The action cannot be completed because the other program is busy. Choose 'Swi... | [
{
"answer_id": 282309,
"author": "Sunlight",
"author_id": 33650,
"author_profile": "https://Stackoverflow.com/users/33650",
"pm_score": 2,
"selected": false,
"text": "<p>Have a look at <code>IMessageFilter</code> and <code>CoRegisterMessageFilter</code>.</p>\n"
},
{
"answer_id": ... | 2008/11/11 | [
"https://Stackoverflow.com/questions/282091",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36699/"
] | I am instantiating a local COM server using CoCreateInstance. Sometimes the application providing the server takes a long time to start. When this happens, Windows pops a dialog box like this:
**Server Busy**
The action cannot be completed because the other program is busy. Choose 'Switch To' to activate the busy pro... | If you're using MFC, we used to do stuff like this:
```
// prevent the damned "Server Busy" dialog.
AfxOleGetMessageFilter()->EnableBusyDialog(0);
AfxOleGetMessageFilter()->EnableNotRespondingDialog(0);
``` |
282,093 | <p>I want my php script to create an output file in a folder based on the date. The way I'm doing this is that its supposed to get the foldername/filename from a text file outputted by another program which I am unable to edit.</p>
<p>So the file its grabbing the data from looks like this:</p>
<pre><code>data/newfol... | [
{
"answer_id": 282107,
"author": "Overbeeke",
"author_id": 21238,
"author_profile": "https://Stackoverflow.com/users/21238",
"pm_score": 0,
"selected": false,
"text": "<p>Can't you just do this by creating the dir with mkdir (<a href=\"http://nl.php.net/manual/en/function.mkdir.php\" rel... | 2008/11/11 | [
"https://Stackoverflow.com/questions/282093",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I want my php script to create an output file in a folder based on the date. The way I'm doing this is that its supposed to get the foldername/filename from a text file outputted by another program which I am unable to edit.
So the file its grabbing the data from looks like this:
```
data/newfolder/10302008/log_for_T... | ```
if(!file_exists(dirname($file)))
mkdir(dirname($file), 0777, true);
//do stuff with $file.
```
Use the third parameter to [mkdir()](http://php.net/mkdir), which makes it create directories recursively. |
282,127 | <p>I've got three (relevant) models, specified like this:</p>
<pre><code>class User < ActiveRecord::Base
has_many :posts
has_many :comments
has_many :comments_received, :through => :posts, :source => :comments
end
class Post < ActiveRecord::Base
belongs_to :user
has_many :comments
end
class Com... | [
{
"answer_id": 282443,
"author": "Cameron Price",
"author_id": 35526,
"author_profile": "https://Stackoverflow.com/users/35526",
"pm_score": 0,
"selected": false,
"text": "<p>I have to confess, I'm a little confused by the variable names, but first off, I'm surprised your has_many :throu... | 2008/11/11 | [
"https://Stackoverflow.com/questions/282127",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I've got three (relevant) models, specified like this:
```
class User < ActiveRecord::Base
has_many :posts
has_many :comments
has_many :comments_received, :through => :posts, :source => :comments
end
class Post < ActiveRecord::Base
belongs_to :user
has_many :comments
end
class Comment < ActiveRecord::Base
... | Although the syntax to deinfe resource and model relationship is similar, you shouldn't be fooled into thinking that a resource maps to a model. Read what [David Black has to say](http://dablog.rubypal.com/2008/3/23/splitting-hairs-over-resource).
The problem you're having is with the routes you're generating. Using t... |
282,129 | <p>I know about using a -vsdoc.js file for <a href="http://en.wikipedia.org/wiki/IntelliSense" rel="nofollow noreferrer">IntelliSense</a>, and the one for jQuery is easy to find. What other JavaScript, Ajax, and DHTML libraries have them and where can I find those files? Also, is there a document which outlines the sp... | [
{
"answer_id": 311874,
"author": "Adam",
"author_id": 1341,
"author_profile": "https://Stackoverflow.com/users/1341",
"pm_score": 5,
"selected": true,
"text": "<p>An excellent blog posting from Betrand LeRoy on IntelliSense format for JavaScript: \n<em><a href=\"http://weblogs.asp.net/bl... | 2008/11/11 | [
"https://Stackoverflow.com/questions/282129",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22777/"
] | I know about using a -vsdoc.js file for [IntelliSense](http://en.wikipedia.org/wiki/IntelliSense), and the one for jQuery is easy to find. What other JavaScript, Ajax, and DHTML libraries have them and where can I find those files? Also, is there a document which outlines the specifications for -vsdoc.js files? | An excellent blog posting from Betrand LeRoy on IntelliSense format for JavaScript:
*[The format for JavaScript doc comments](http://weblogs.asp.net/bleroy/archive/2007/04/23/the-format-for-javascript-doc-comments.aspx)*.
In a nutshell:
Summary - used to describe a function/method or event. Syntax:
```
<summary loc... |
282,157 | <p>Assuming one has an abstract base class <code>foo</code> with <code>__get()</code> defined, and a child class <code>bar</code> which inherits from <code>foo</code> with a private variable <code>$var</code>, will the parent <code>__get()</code> be called when trying to access the private <code>$var</code> from outsid... | [
{
"answer_id": 282167,
"author": "Electronic Zebra",
"author_id": 1742702,
"author_profile": "https://Stackoverflow.com/users/1742702",
"pm_score": 4,
"selected": true,
"text": "<p>Yes. </p>\n\n<pre><code><?php\n abstract class foo\n {\n public function __get($var)\n ... | 2008/11/11 | [
"https://Stackoverflow.com/questions/282157",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1742702/"
] | Assuming one has an abstract base class `foo` with `__get()` defined, and a child class `bar` which inherits from `foo` with a private variable `$var`, will the parent `__get()` be called when trying to access the private `$var` from outside the class? | Yes.
```
<?php
abstract class foo
{
public function __get($var)
{
echo "Parent (Foo) __get() called for $var\n";
}
}
class bar extends foo
{
private $var;
public function __construct()
{
$this->var = "25\n";
}
... |
282,161 | <p>I just found out that by converting PNG32 to PNG8 via Photoshop will fix the PNG transparency bug in IE<=6. </p>
<p>So I had this thought that instead of serving PNG32 to all browser, why not serve PNG8 if the client is using IE<=6. </p>
<p>I'm not really an expert when it comes to htaccess/httpd directives ... | [
{
"answer_id": 282174,
"author": "okoman",
"author_id": 35903,
"author_profile": "https://Stackoverflow.com/users/35903",
"pm_score": 0,
"selected": false,
"text": "<p>Put this in your .htaccess</p>\n\n<pre><code>RewriteEngine on\nRewriteRule ^/(.*)\\.png$ /$18.png [L,QSA]\n</code></pre>... | 2008/11/11 | [
"https://Stackoverflow.com/questions/282161",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20300/"
] | I just found out that by converting PNG32 to PNG8 via Photoshop will fix the PNG transparency bug in IE<=6.
So I had this thought that instead of serving PNG32 to all browser, why not serve PNG8 if the client is using IE<=6.
I'm not really an expert when it comes to htaccess/httpd directives so I'm here for help.
... | I haven't actually tried this, but I think it should work:
```
RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} ^Mozilla/4.0\ \(compatible;\ MSIE\ [1-6]\.
RewriteCond %{REQUEST_FILENAME} ^(.+)(\.png)$
RewriteCond %18%2 -f
RewriteRule ^(.+)\.png$ $18.png [L,QSA]
```
The first line turns mod\_rewrite on (and can be omi... |
282,178 | <p>So I have a User model that :has_many other models like Documents, Videos, Posts and the like. My question arises when I execute a "do" block from the User model like so:</p>
<pre><code>has_many :posts do
def recent
find(:all, :order => 'created_at desc', :limit => 12)
end
end
</code></pre>
<... | [
{
"answer_id": 282187,
"author": "mwilliams",
"author_id": 23909,
"author_profile": "https://Stackoverflow.com/users/23909",
"pm_score": 3,
"selected": true,
"text": "<p>It looks like you should take a look at using <a href=\"http://railscasts.com/episodes/108\" rel=\"nofollow noreferrer... | 2008/11/11 | [
"https://Stackoverflow.com/questions/282178",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36715/"
] | So I have a User model that :has\_many other models like Documents, Videos, Posts and the like. My question arises when I execute a "do" block from the User model like so:
```
has_many :posts do
def recent
find(:all, :order => 'created_at desc', :limit => 12)
end
end
```
This just lets me call someth... | It looks like you should take a look at using [named\_scope](http://railscasts.com/episodes/108).
There's no reason why you should have a do block against your association.
You you should turn that recent method into a named scope and you can then tack on :dependent => destroy etc etc.
Good luck! |
282,184 | <p>Javascript usage has gotten remarkably more sophisticated and powerful in the past five years. One aspect of this sort of functional programming I struggle with, esp with Javascript’s peculiarities, is how to make clear either through comments or code just what is happening. Often this sort of code takes a while to ... | [
{
"answer_id": 282199,
"author": "okoman",
"author_id": 35903,
"author_profile": "https://Stackoverflow.com/users/35903",
"pm_score": 0,
"selected": false,
"text": "<p>I think it is one of the aims of those frameworks like prototype or jQuery to hide most of the JavaScript stuff. Since i... | 2008/11/11 | [
"https://Stackoverflow.com/questions/282184",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4440/"
] | Javascript usage has gotten remarkably more sophisticated and powerful in the past five years. One aspect of this sort of functional programming I struggle with, esp with Javascript’s peculiarities, is how to make clear either through comments or code just what is happening. Often this sort of code takes a while to dec... | The use of a common library is one thing, but I think a lot of "getting" JavaScript is simply spending time writing it. Things that may seem esoteric will slowly become mundane. This is true of just about any language or framework.
Many of the idioms used in JavaScript, such as anonymous functions, literal syntax, etc... |
282,191 | <p>in my flex application, I created a Tilelist. In this Tilelist, I am using an ItemRenderer to create a box consisting of an image and an VSlider in each tile. </p>
<p>The tile need to be dragable when you click on the image, but not dragable when you slide the slider. How can I achieve this ? I have been scratching... | [
{
"answer_id": 284779,
"author": "Blizter",
"author_id": 387920,
"author_profile": "https://Stackoverflow.com/users/387920",
"pm_score": 1,
"selected": false,
"text": "<p>I found a solution to my problem, however it may not be the best one.</p>\n\n<p>Using this : </p>\n\n<pre><code> ... | 2008/11/11 | [
"https://Stackoverflow.com/questions/282191",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/387920/"
] | in my flex application, I created a Tilelist. In this Tilelist, I am using an ItemRenderer to create a box consisting of an image and an VSlider in each tile.
The tile need to be dragable when you click on the image, but not dragable when you slide the slider. How can I achieve this ? I have been scratching my head s... | I found a solution to my problem, however it may not be the best one.
Using this :
```
public var overImage:Boolean = false;
public function checkAllow(evt:DragEvent):void {
if(overImage == false)
{
evt.preventDefault()
}
}
public... |
282,192 | <p>I'm trying to auto-generate a plain text email with a trademark symbol in it. I've tried everything I can think of but it's still not going through.</p>
<pre><code><cfmail from="#x#" to="#y#" subject="test" charset="UTF-8">
™
&trade;
#Chr(153)#
</cfmail>
</code></pre>
| [
{
"answer_id": 282218,
"author": "Matty",
"author_id": 26241,
"author_profile": "https://Stackoverflow.com/users/26241",
"pm_score": 2,
"selected": false,
"text": "<p>I think that this is not so much an issue with CFMail but rather an issue with email clients displaying the characters co... | 2008/11/11 | [
"https://Stackoverflow.com/questions/282192",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8724/"
] | I'm trying to auto-generate a plain text email with a trademark symbol in it. I've tried everything I can think of but it's still not going through.
```
<cfmail from="#x#" to="#y#" subject="test" charset="UTF-8">
™
™
#Chr(153)#
</cfmail>
``` | This is an encoding issue.
You state the mail is encoded as UTF-8, but `Chr(153)` does not return a trademark symbol in Unicode. It does in Windows-1252, but `Chr()` works with Unicode code points.
Use `Chr(8482)` to nail it to the [Unicode TM symbol](http://www.fileformat.info/info/unicode/char/2122/index.htm).
I'v... |
282,198 | <p>I want to select a bunch of <code>span</code>s in a <code>div</code> whose CSS contains a particular background color. How do I achieve this?</p>
| [
{
"answer_id": 282208,
"author": "okoman",
"author_id": 35903,
"author_profile": "https://Stackoverflow.com/users/35903",
"pm_score": -1,
"selected": false,
"text": "<p>Use the attribute selector [attribute=value] to look for a certain attribute value.</p>\n\n<pre><code>#id_of_the_div sp... | 2008/11/11 | [
"https://Stackoverflow.com/questions/282198",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I want to select a bunch of `span`s in a `div` whose CSS contains a particular background color. How do I achieve this? | if i understand the question correctly, the selector `[attribute=value]` **will not work** because `<span>` does not contain an attribute "background-color". you can test that out quickly to confirm it won't match anything:
```
$('#someDiv span[background-color]').size(); // returns 0
```
given:
```
.one, .two {
... |
282,222 | <p>I just want ask the steps when trying to create a simple SQL select statement in UNIX inside/within IF..THEN..FI statement.</p>
<p>I know how to use the 'select' and 'if..then' statements in SQL*Plus, but I'm having a difficulties having a UNIX script to point to variables: If 'ABC' to 'Select...'</p>
<h2>Example:... | [
{
"answer_id": 282253,
"author": "ConcernedOfTunbridgeWells",
"author_id": 15401,
"author_profile": "https://Stackoverflow.com/users/15401",
"pm_score": 2,
"selected": false,
"text": "<p>This sounds like you're trying to embed SQLPlus in a shell script. From memory the incantation shoul... | 2008/11/11 | [
"https://Stackoverflow.com/questions/282222",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I just want ask the steps when trying to create a simple SQL select statement in UNIX inside/within IF..THEN..FI statement.
I know how to use the 'select' and 'if..then' statements in SQL\*Plus, but I'm having a difficulties having a UNIX script to point to variables: If 'ABC' to 'Select...'
Example:
--------
if [ "... | This sounds like you're trying to embed SQLPlus in a shell script. From memory the incantation should look something like:
```
if [ $? -eq ABC ]; then
SQLPLUS /S USER/PASS@Instance <<EOF
SET echo off;
SET pagesize 0;
SET heading off;
SPOOL foo.out
select foo from bar
EOF
fi
```
Everything between the SQLPLUS and EOF... |
282,252 | <p>I have multiple ordered lists. Unfortunately, the order of the items isn't a simple alpha or numeric comparison, otherwise this is trivial. So what I have is something like:</p>
<pre><code>List #1 List #2 List #3
groundhog groundhog easter
mothersday mayday mothersday
midsummer ... | [
{
"answer_id": 282261,
"author": "bdumitriu",
"author_id": 35415,
"author_profile": "https://Stackoverflow.com/users/35415",
"pm_score": 4,
"selected": true,
"text": "<p>You may want to have a look at <a href=\"http://en.wikipedia.org/wiki/Topological_sort\" rel=\"nofollow noreferrer\">t... | 2008/11/11 | [
"https://Stackoverflow.com/questions/282252",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8173/"
] | I have multiple ordered lists. Unfortunately, the order of the items isn't a simple alpha or numeric comparison, otherwise this is trivial. So what I have is something like:
```
List #1 List #2 List #3
groundhog groundhog easter
mothersday mayday mothersday
midsummer laborday ... | You may want to have a look at [topological sorting](http://en.wikipedia.org/wiki/Topological_sort). I think it applies quite well to your case. |
282,298 | <p>I have an htaccess file that uses mod_rewrite to redirect /controller to /index.php?controller=%controller%</p>
<p>Like this:</p>
<pre><code># Various rewrite rules.
<IfModule mod_rewrite.c>
RewriteEngine on
# Rewrite current-style URLs of the form 'index.php?controller=x&action=y'.
RewriteCond %{... | [
{
"answer_id": 282364,
"author": "Mark S.",
"author_id": 13968,
"author_profile": "https://Stackoverflow.com/users/13968",
"pm_score": 1,
"selected": false,
"text": "<p>I ended up using PHP to do it:</p>\n\n<pre><code>if (in_array($controllerString, $configuration['protected']))\n{\n ... | 2008/11/11 | [
"https://Stackoverflow.com/questions/282298",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13968/"
] | I have an htaccess file that uses mod\_rewrite to redirect /controller to /index.php?controller=%controller%
Like this:
```
# Various rewrite rules.
<IfModule mod_rewrite.c>
RewriteEngine on
# Rewrite current-style URLs of the form 'index.php?controller=x&action=y'.
RewriteCond %{REQUEST_FILENAME} !-f
Rewrit... | ```
<Location /secret>
AuthName localhost
AuthType Basic
AuthUserFile <file>
Require valid-user
</Location>
``` |
282,308 | <p>I'm working with an ASP.net 2.0 GridView control that is bound to the results of a sql query, so it looks something like this:</p>
<pre><code><asp:GridView ID="MySitesGridView" runat="server" AutoGenerateColumns="False" DataSourceID="InventoryDB" AllowSorting="True" CellPadding="4" ForeColor="#333333" GridLines=... | [
{
"answer_id": 282324,
"author": "Cristian Libardo",
"author_id": 16526,
"author_profile": "https://Stackoverflow.com/users/16526",
"pm_score": 1,
"selected": false,
"text": "<p>Have you tried TemplateField in combination with Eval?</p>\n\n<pre><code><asp:TemplateField>\n <It... | 2008/11/11 | [
"https://Stackoverflow.com/questions/282308",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2327/"
] | I'm working with an ASP.net 2.0 GridView control that is bound to the results of a sql query, so it looks something like this:
```
<asp:GridView ID="MySitesGridView" runat="server" AutoGenerateColumns="False" DataSourceID="InventoryDB" AllowSorting="True" CellPadding="4" ForeColor="#333333" GridLines="None" OnRowComma... | TemplateFields are the way to go.
I usually prefer to have a private string function in the Page which I pass several object variables, and calculate the resulting string.
```
<a href="<%# CalculateUrl(Eval("PublicIP"), Eval("Customer")) %>">site</a>
```
and in the code-behind:
```
private string CalculateUrl(obje... |
282,317 | <p>In C# I sometimes wish I could make special methods for certain "instantiations" of generic classes.</p>
<p><strong>UPDATE: The following code is just a dumb example of a more abstract problem - don't focus too much on time series, just the principles of "adding extra methods" for certain T</strong>.</p>
<p>Exampl... | [
{
"answer_id": 282425,
"author": "FlySwat",
"author_id": 1965,
"author_profile": "https://Stackoverflow.com/users/1965",
"pm_score": 0,
"selected": false,
"text": "<p>I'd consider implementing a factory to return the appropriate subclass.</p>\n"
},
{
"answer_id": 282506,
"aut... | 2008/11/11 | [
"https://Stackoverflow.com/questions/282317",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31890/"
] | In C# I sometimes wish I could make special methods for certain "instantiations" of generic classes.
**UPDATE: The following code is just a dumb example of a more abstract problem - don't focus too much on time series, just the principles of "adding extra methods" for certain T**.
Example:
```
class Timeseries<T>
{... | You could always use the self-referential generics trick:
```
public class TimeSeries<T, U> where U : TimeSeries<T, U>
{
U Slice(...)
}
public class TimeSeriesDouble : TimeSeries<double, TimeSeriesDouble>
{
...
}
```
It can get a bit brain-bending, but it can work. |
282,363 | <p>I run a series of time consuming operations on a background worker thread. At various stages I update a (windows form) progress bar by invoking a delegate. However, one of the more time operations occurs on a single line of code.</p>
<p>Is it possible to :</p>
<p>a) Update the UI while that single line of code i... | [
{
"answer_id": 282380,
"author": "jons911",
"author_id": 34375,
"author_profile": "https://Stackoverflow.com/users/34375",
"pm_score": 3,
"selected": true,
"text": "<p>Unfortunately, probably not. The background worker thread needs to call ReportProgress to update the UI thread, and it ... | 2008/11/11 | [
"https://Stackoverflow.com/questions/282363",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2680373/"
] | I run a series of time consuming operations on a background worker thread. At various stages I update a (windows form) progress bar by invoking a delegate. However, one of the more time operations occurs on a single line of code.
Is it possible to :
a) Update the UI while that single line of code is being executed, o... | Unfortunately, probably not. The background worker thread needs to call ReportProgress to update the UI thread, and it needs to watch the CancellationPending to know whether it should stop or not. So, if your worker thread is running along-running operation in a single line, there's no way to make this work.
Perhaps,... |
282,369 | <p>Recently I had to move one of my web applications to a new hosting provider. The mail and web service is still held on the old hosting site however, when I try to send an email from the new server,I get an error; </p>
<p>"The server rejected one or more recipient addresses. The server response was:</p>
<pre><code>... | [
{
"answer_id": 282387,
"author": "Owen",
"author_id": 4853,
"author_profile": "https://Stackoverflow.com/users/4853",
"pm_score": 2,
"selected": false,
"text": "<p>i'm not sure how C# would handle the specifics (sockets?), but basically you just want to make a connection to your new POP ... | 2008/11/11 | [
"https://Stackoverflow.com/questions/282369",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26300/"
] | Recently I had to move one of my web applications to a new hosting provider. The mail and web service is still held on the old hosting site however, when I try to send an email from the new server,I get an error;
"The server rejected one or more recipient addresses. The server response was:
```
450 <email_address>: ... | i'm not sure how C# would handle the specifics (sockets?), but basically you just want to make a connection to your new POP server. here's a sample POP transaction:
```
$ telnet new-pop-server.com 110
Connected to new-pop-server.com.
Escape character is '^]'.
+OK
USER <username>
+OK
PASS <password>
+OK ... |
282,372 | <p>want to pass boost::bind to a method expecting a plain function pointer (same signature).</p>
<pre><code>typedef void TriggerProc_type(Variable*,void*);
void InitVariable(TriggerProc_type *proc);
boost::function<void (Variable*, void*)> triggerProc ...
InitVariable(triggerProc);
error C2664: 'InitVariable' :... | [
{
"answer_id": 282433,
"author": "coryan",
"author_id": 33325,
"author_profile": "https://Stackoverflow.com/users/33325",
"pm_score": 4,
"selected": false,
"text": "<p>I think you want to use the target() member function of boost::function (isn't that a mouthful...)</p>\n\n<pre><code>#in... | 2008/11/11 | [
"https://Stackoverflow.com/questions/282372",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20003/"
] | want to pass boost::bind to a method expecting a plain function pointer (same signature).
```
typedef void TriggerProc_type(Variable*,void*);
void InitVariable(TriggerProc_type *proc);
boost::function<void (Variable*, void*)> triggerProc ...
InitVariable(triggerProc);
error C2664: 'InitVariable' : cannot convert para... | Has anyone noticed that the [accepted answer](https://stackoverflow.com/a/282433/20003) only works with trivial cases? The only way that function<>::target() will return an object that can be bound to a C callback, is if it was constructed with an object that can be bound to a C callback. If that's the case, then you c... |
282,391 | <p>.NET 3.5, C#</p>
<p>I have a web app with a "search" feature. Some of the fields that are searchable are first-class columns in the table, but some of them are in fact nested fields inside an XML data type. </p>
<p>Previously, I built a system for dynamically constructing the SQL for my search. I had a nice clas... | [
{
"answer_id": 282514,
"author": "Daniel M",
"author_id": 36559,
"author_profile": "https://Stackoverflow.com/users/36559",
"pm_score": 5,
"selected": true,
"text": "<p>Now that is an interesting question. </p>\n\n<p>Right now, you cannot instruct SQL Server to perform XML functions dire... | 2008/11/11 | [
"https://Stackoverflow.com/questions/282391",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17803/"
] | .NET 3.5, C#
I have a web app with a "search" feature. Some of the fields that are searchable are first-class columns in the table, but some of them are in fact nested fields inside an XML data type.
Previously, I built a system for dynamically constructing the SQL for my search. I had a nice class hierarchy that bu... | Now that is an interesting question.
Right now, you cannot instruct SQL Server to perform XML functions directly from Linq.
However, you can get Linq to use user defined functions...
so, you could setup a udf to process the xml, get the right data, etc, and then use that in your Linq expresion. This will execute on ... |
282,393 | <p>I have a rather complex decorator written by someone else. What I want to do is call a decorated version of the function one time based on a descision or call the original function (not decorated) another time. Is this possible?</p>
| [
{
"answer_id": 282399,
"author": "Ali Afshar",
"author_id": 28380,
"author_profile": "https://Stackoverflow.com/users/28380",
"pm_score": 6,
"selected": true,
"text": "<p>With:</p>\n\n<pre><code>decorator(original_function)()\n</code></pre>\n\n<p>Without:</p>\n\n<pre><code>original_funct... | 2008/11/11 | [
"https://Stackoverflow.com/questions/282393",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7883/"
] | I have a rather complex decorator written by someone else. What I want to do is call a decorated version of the function one time based on a descision or call the original function (not decorated) another time. Is this possible? | With:
```
decorator(original_function)()
```
Without:
```
original_function()
```
A decorator is just a function which takes a function as an argument and returns another one. The @ syntax is totally optional. Perhaps a sift through some [documentation](https://wiki.python.org/moin/PythonDecorators) might help cl... |
282,406 | <p>I am just getting started with IoC containers so apologies if this is a stupid question.</p>
<p>I have code like the following in an app</p>
<pre><code>internal static class StaticDataHandlerFactory
{
public static IStaticDataHandler CreateHandler(StaticDataUpdate staticDataUpdate)
{
... | [
{
"answer_id": 282428,
"author": "Tim Scott",
"author_id": 29493,
"author_profile": "https://Stackoverflow.com/users/29493",
"pm_score": 1,
"selected": false,
"text": "<p>The short answer is yes, it allows it. This <a href=\"http://ayende.com/Blog/archive/2008/10/05/components-implement... | 2008/11/11 | [
"https://Stackoverflow.com/questions/282406",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17194/"
] | I am just getting started with IoC containers so apologies if this is a stupid question.
I have code like the following in an app
```
internal static class StaticDataHandlerFactory
{
public static IStaticDataHandler CreateHandler(StaticDataUpdate staticDataUpdate)
{
if (staticDataUpdat... | Actually, although it is possible to replace some of the code with an inversion of control system, it's not obvious to me it's a good idea. Dependency injection tends to be best for configuration of systems, not dynamic creation of objects. To put it a different way, the container itself is a huge global variable and a... |
282,422 | <p>I have a Flash application that is hosted from within a Drupal page. Some parts of the Flash application should be available to all users, but some should only be available to a logged-in user. (The specific role doesn't matter, just that they are any authorized user of the site).</p>
<p>From within Flash, I can ... | [
{
"answer_id": 282462,
"author": "Owen",
"author_id": 4853,
"author_profile": "https://Stackoverflow.com/users/4853",
"pm_score": 2,
"selected": false,
"text": "<h2>The \"right\" solution</h2>\n\n<p>you probably want to look at something like the <a href=\"http://drupal.org/project/servi... | 2008/11/11 | [
"https://Stackoverflow.com/questions/282422",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4540/"
] | I have a Flash application that is hosted from within a Drupal page. Some parts of the Flash application should be available to all users, but some should only be available to a logged-in user. (The specific role doesn't matter, just that they are any authorized user of the site).
From within Flash, I can detect wheth... | I was able to do this using Drupal's "system" and "user" services:
* install the [Services Module](http://drupal.org/project/services)
* enable the "system" and "user" services
* for the code below, disable API Keys. (Or leave them enabled and supply the extra arguments)
* permission both authenticated and anonymous u... |
282,444 | <p>Is it possible to detect, on the client side, whether the user is using an encrypted page or not?</p>
<p>Put another way -- I want to know if the URL of the current page starts with http or https.</p>
| [
{
"answer_id": 282454,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 7,
"selected": true,
"text": "<p>Use <code>window.location.protocol</code> to check if it is <code>https:</code></p>\n\n<pre><code>function isSecure()... | 2008/11/11 | [
"https://Stackoverflow.com/questions/282444",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Is it possible to detect, on the client side, whether the user is using an encrypted page or not?
Put another way -- I want to know if the URL of the current page starts with http or https. | Use `window.location.protocol` to check if it is `https:`
```
function isSecure()
{
return window.location.protocol == 'https:';
}
```
Alternatively you can omit specifying "window" if you don't have a locally scoped location.
```
function isSecure()
{
return location.protocol == 'https:';
}
``` |
282,451 | <p>I have a .net transaction with a SQL insert to a SQL Server 2005 database. The table has an identity primary key. </p>
<p>When an error occurs within the transaction, <code>Rollback()</code> is called. The row inserts are rolled back correctly, however the next time I insert data to the table, the identity is incre... | [
{
"answer_id": 282461,
"author": "Gavin Miller",
"author_id": 33226,
"author_profile": "https://Stackoverflow.com/users/33226",
"pm_score": 3,
"selected": false,
"text": "<p>As far as I know the rows for insertion claim the autonumber and on rollback that number is lost for good. If you... | 2008/11/11 | [
"https://Stackoverflow.com/questions/282451",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19763/"
] | I have a .net transaction with a SQL insert to a SQL Server 2005 database. The table has an identity primary key.
When an error occurs within the transaction, `Rollback()` is called. The row inserts are rolled back correctly, however the next time I insert data to the table, the identity is incremented as if the roll... | If you think about it, the auto-increment number **should not** be transactional. If other transactions had to wait to see if the auto-number was going to be used or "rolled back", they would be blocked by the existing transaction using the auto-number. For example, consider my psuedo code below with table A using an a... |
282,457 | <p>I am working on a small project to take a CSV file and then insert its data into a HTML table (I would use datagrid and dataset or datatable, but the system I will be talking to does not support ASP.NET uploads for sending newsletters).</p>
<p>Anyway, I will use the file.readalllines method to return the contents o... | [
{
"answer_id": 282488,
"author": "Gary Willoughby",
"author_id": 13227,
"author_profile": "https://Stackoverflow.com/users/13227",
"pm_score": -1,
"selected": false,
"text": "<p>The Split() method takes a char parameter which can be used to specify the delimiter. So you can do something ... | 2008/11/11 | [
"https://Stackoverflow.com/questions/282457",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32484/"
] | I am working on a small project to take a CSV file and then insert its data into a HTML table (I would use datagrid and dataset or datatable, but the system I will be talking to does not support ASP.NET uploads for sending newsletters).
Anyway, I will use the file.readalllines method to return the contents of the csv ... | Use the overloaded version of `string.Split()` that limits the number of returned values.
```
string makeModel = csvArray[0]; // or whichever column it is in
string[] makeAndModel = makeModel.Split( new char[] { ' ' } , 2 );
string make = makeAndModel[0];
string model = makeAndModel[1];
``` |
282,459 | <p>I know of <code>is</code> and <code>as</code> for <code>instanceof</code>, but what about the reflective <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html#isInstance(java.lang.Object)" rel="noreferrer">isInstance()</a> method?</p>
| [
{
"answer_id": 282469,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 7,
"selected": true,
"text": "<p>The equivalent of Java’s <code>obj.getClass().isInstance(otherObj)</code> in C# is as follows:</p>\n\n<pre><code>bo... | 2008/11/11 | [
"https://Stackoverflow.com/questions/282459",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36744/"
] | I know of `is` and `as` for `instanceof`, but what about the reflective [isInstance()](http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html#isInstance(java.lang.Object)) method? | The equivalent of Java’s `obj.getClass().isInstance(otherObj)` in C# is as follows:
```
bool result = obj.GetType().IsAssignableFrom(otherObj.GetType());
```
Note that while both Java and C# work on the runtime type object (Java `java.lang.Class` ≣ C# `System.Type`) of an `obj` (via `.getClass()` vs `.getType()`), J... |
282,460 | <p>How can I determine current version of my repository to see if I need to upgrade it (svnadmin upgrade)?</p>
<p>In reality I'm hosting SVN with 3rd party and I want to find out if I need to ask them to upgrade my repos or not.</p>
<p>I'm asking since 1.5 server will keep repo version at 1.4, unless I miss something... | [
{
"answer_id": 282484,
"author": "bdumitriu",
"author_id": 35415,
"author_profile": "https://Stackoverflow.com/users/35415",
"pm_score": 6,
"selected": false,
"text": "<p>Have a look at <code><REPO>/db/format</code>. After upgrading to 1.5 format, my <code>format</code> file shows:... | 2008/11/11 | [
"https://Stackoverflow.com/questions/282460",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19124/"
] | How can I determine current version of my repository to see if I need to upgrade it (svnadmin upgrade)?
In reality I'm hosting SVN with 3rd party and I want to find out if I need to ask them to upgrade my repos or not.
I'm asking since 1.5 server will keep repo version at 1.4, unless I miss something? | Have a look at `<REPO>/db/format`. After upgrading to 1.5 format, my `format` file shows:
```
3
layout sharded 1000
```
Before it used to be:
```
2
``` |
282,468 | <p>The following C# code takes 5 minutes to run:</p>
<pre><code>int i = 1;
string fraction = "";
while (fraction.Length < 1000000)
{
fraction += i.ToString();
i++;
}
</code></pre>
<p>"Optimising it" like this causes it to run in 1.5 seconds:</p>
<pre><code>int i = 1;
string fraction = "";
while (fraction.... | [
{
"answer_id": 282476,
"author": "Mitch Wheat",
"author_id": 16076,
"author_profile": "https://Stackoverflow.com/users/16076",
"pm_score": 3,
"selected": false,
"text": "<p>Use <a href=\"http://msdn.microsoft.com/en-us/library/system.text.stringbuilder.aspx\" rel=\"nofollow noreferrer\">... | 2008/11/11 | [
"https://Stackoverflow.com/questions/282468",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15537/"
] | The following C# code takes 5 minutes to run:
```
int i = 1;
string fraction = "";
while (fraction.Length < 1000000)
{
fraction += i.ToString();
i++;
}
```
"Optimising it" like this causes it to run in 1.5 seconds:
```
int i = 1;
string fraction = "";
while (fraction.Length < 1000000)
{
// concatenating... | You will probably see that the first 1000 chars will take almost no time opposed to the last 1000 chars.
I would assume that the time-consuming part is the actual copying of the large string into a new memory-area every time you add a char that is the tough work for your computer.
Your optimization can easily be com... |
282,475 | <p>Consider the following trivial HTML page that throws an error:</p>
<pre><code><html><head><script>
throw new Error('oops');
alert('should not reach here');
</script></head></html>
</code></pre>
<p>The user I am logged into Vista with is a member of both the Administrators an... | [
{
"answer_id": 282476,
"author": "Mitch Wheat",
"author_id": 16076,
"author_profile": "https://Stackoverflow.com/users/16076",
"pm_score": 3,
"selected": false,
"text": "<p>Use <a href=\"http://msdn.microsoft.com/en-us/library/system.text.stringbuilder.aspx\" rel=\"nofollow noreferrer\">... | 2008/11/11 | [
"https://Stackoverflow.com/questions/282475",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2766/"
] | Consider the following trivial HTML page that throws an error:
```
<html><head><script>
throw new Error('oops');
alert('should not reach here');
</script></head></html>
```
The user I am logged into Vista with is a member of both the Administrators and Debugger Users groups.
If I run Internet Explorer on Vista ... | You will probably see that the first 1000 chars will take almost no time opposed to the last 1000 chars.
I would assume that the time-consuming part is the actual copying of the large string into a new memory-area every time you add a char that is the tough work for your computer.
Your optimization can easily be com... |
282,489 | <p>What is a good way to set up a single container div with some border images surrounding it (in my case only on the left, bottom, and right sides)? I have it centered at the top of the page, overlapping everything else (so like that OSX-style slide-down dialog).</p>
<p>Here's the basic layout:</p>
<p><img src="http... | [
{
"answer_id": 282476,
"author": "Mitch Wheat",
"author_id": 16076,
"author_profile": "https://Stackoverflow.com/users/16076",
"pm_score": 3,
"selected": false,
"text": "<p>Use <a href=\"http://msdn.microsoft.com/en-us/library/system.text.stringbuilder.aspx\" rel=\"nofollow noreferrer\">... | 2008/11/11 | [
"https://Stackoverflow.com/questions/282489",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5291/"
] | What is a good way to set up a single container div with some border images surrounding it (in my case only on the left, bottom, and right sides)? I have it centered at the top of the page, overlapping everything else (so like that OSX-style slide-down dialog).
Here's the basic layout:
{
// do stuff
}, 0);
</code></pre>
<p>Actually return control to the UI from within a loop? When are you supposed to use it? Does it work equally well in all browsers?</p>
| [
{
"answer_id": 282527,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "<p><a href=\"http://blog.thinkature.com/index.php/2006/11/26/escaping-the-javascript-call-stack-with-settimeout/\" rel=\"nofol... | 2008/11/11 | [
"https://Stackoverflow.com/questions/282499",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1169746/"
] | Does this pattern:
```
setTimeout(function(){
// do stuff
}, 0);
```
Actually return control to the UI from within a loop? When are you supposed to use it? Does it work equally well in all browsers? | It runs code asynchronously (not in parallel though). The delay is usually changed to a minimum of 10ms, but that doesn't matter.
The main use for this trick is to avoid limit of call stack depth. If you risk reaching limit (walk deep tree structure and plan to do a lot of work on leafs), you can use timeout to start ... |
282,503 | <p>The <code>PropertyGrid</code> control is very useful for editing objects at run-time. I'm using it as follows:</p>
<pre><code>Form form = new Form();
form.Parent = this;
form.Text = "Editing MyMemberVariable";
PropertyGrid p = new PropertyGrid();
p.Parent = form;
p.Dock = DockStyle.Fill;
p.SelectedObject = _MyMemb... | [
{
"answer_id": 282863,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>I did some research and even reproduced the problem, however the solution I found won't help you, but I'm hoping the inform... | 2008/11/11 | [
"https://Stackoverflow.com/questions/282503",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2683/"
] | The `PropertyGrid` control is very useful for editing objects at run-time. I'm using it as follows:
```
Form form = new Form();
form.Parent = this;
form.Text = "Editing MyMemberVariable";
PropertyGrid p = new PropertyGrid();
p.Parent = form;
p.Dock = DockStyle.Fill;
p.SelectedObject = _MyMemberVariable;
p.PropertyVal... | This isn't very elegant, but it solved the issue I was having when someone updates / changes the order of a collection from a property grid:
```
propertyGrid1.PropertyValueChanged += (o, args) => PropertyGridValueChanged();
propertyGrid1.LostFocus += (sender, args) => PropertyGridValueChanged();
```
I listen to the ... |
282,522 | <p>In Ant is there any way to do something like this:</p>
<pre><code><arguments id="arg-list">
<arg value="arg1" />
<arg value="arg2" />
</arguments>
<property name="prop1" refid="arg-list" />
</code></pre>
<p>I'm trying to write a macro for psexec and I'm looking for a nice way... | [
{
"answer_id": 282583,
"author": "Richard A",
"author_id": 24355,
"author_profile": "https://Stackoverflow.com/users/24355",
"pm_score": 4,
"selected": true,
"text": "<p>I don't know of an answer to your specific question. The documentation is clear that refid 'Only yields reasonable res... | 2008/11/11 | [
"https://Stackoverflow.com/questions/282522",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18437/"
] | In Ant is there any way to do something like this:
```
<arguments id="arg-list">
<arg value="arg1" />
<arg value="arg2" />
</arguments>
<property name="prop1" refid="arg-list" />
```
I'm trying to write a macro for psexec and I'm looking for a nice way to pass in the argument list.
I know that you can do s... | I don't know of an answer to your specific question. The documentation is clear that refid 'Only yields reasonable results for references to PATH like structures or properties.'
Without a bit more information on what you're trying to do, it's hard to comment. At the risk of changing your design, rather than answering ... |
282,526 | <p>I've noticed, using visual studio 2003, that I can "comment out" my comments to make them no longer be comments. This one needs an example:</p>
<p>If I have:</p>
<pre><code>/*
int commented_out = 0;
*/
</code></pre>
<p>I can comment out the /* and */ with // and code within the /* and */ is no longer "commented o... | [
{
"answer_id": 282533,
"author": "paxdiablo",
"author_id": 14860,
"author_profile": "https://Stackoverflow.com/users/14860",
"pm_score": 3,
"selected": false,
"text": "<p>It should work in any compiler as the <code>//</code> is encountered first in the input stream.</p>\n\n<p>I tend to u... | 2008/11/11 | [
"https://Stackoverflow.com/questions/282526",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29703/"
] | I've noticed, using visual studio 2003, that I can "comment out" my comments to make them no longer be comments. This one needs an example:
If I have:
```
/*
int commented_out = 0;
*/
```
I can comment out the /\* and \*/ with // and code within the /\* and \*/ is no longer "commented out" (the text changes to non-... | Yep, this is perfectly normal behavior. The C++ standard says that a `/*` is the start of a comment block only if it itself is not commented out. I often use what you've written above to comment or uncomment a block of code by adding/deleting one character. A nice little trick for switching between two blocks of code, ... |
282,531 | <p>I'm looking for a .NET library that will allow creation of a Word document. I need to export HTML based content to a Word doc (97-2003 format, not docx).</p>
<p>I know that there are the Microsoft Office Automation libraries and Office interop, but as far as I can tell, they require that you have office actually i... | [
{
"answer_id": 282551,
"author": "Erik Hesselink",
"author_id": 8071,
"author_profile": "https://Stackoverflow.com/users/8071",
"pm_score": 0,
"selected": false,
"text": "<p>Since the doc format specification is not open, and the interop assemblies are the Microsoft solution, I fear that... | 2008/11/11 | [
"https://Stackoverflow.com/questions/282531",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/194/"
] | I'm looking for a .NET library that will allow creation of a Word document. I need to export HTML based content to a Word doc (97-2003 format, not docx).
I know that there are the Microsoft Office Automation libraries and Office interop, but as far as I can tell, they require that you have office actually installed an... | *Would it work if I somehow converted the CSS to be embedded in the HTML??*
Yes. I use an internal style sheet, as I mentioned.
Document Example:
```
<html>
<head>
<STYLE type="text/css">
h1 {text-align:center; font-size:12.0pt; font-family:Arial; font-weight:bold;}
p {margin:0in; margin-bottom:0pt; font-si... |
282,539 | <p>I was wondering if there is a way to implement an action listener for a Jbutton without a name. For example, I have the following for loop that creates a button for each letter of the alphabet.</p>
<pre><code>for (int i = 65; i < 91; i++){
alphabetPanel.add(new JButton("<html><center>" + (char)i... | [
{
"answer_id": 282558,
"author": "John Gardner",
"author_id": 13687,
"author_profile": "https://Stackoverflow.com/users/13687",
"pm_score": 3,
"selected": true,
"text": "<p>Your question is a little vague. it would be trivial to modify the loop to add a listener inside the loop:</p>\n\n... | 2008/11/11 | [
"https://Stackoverflow.com/questions/282539",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29326/"
] | I was wondering if there is a way to implement an action listener for a Jbutton without a name. For example, I have the following for loop that creates a button for each letter of the alphabet.
```
for (int i = 65; i < 91; i++){
alphabetPanel.add(new JButton("<html><center>" + (char)i));
}
```
Is there a way th... | Your question is a little vague. it would be trivial to modify the loop to add a listener inside the loop:
```
ActionListener listener = something;
for (int i = 65; i < 91; i++){
JButton button = new JButton("<html><center>" + (char)i);
button.addActionListener( listener );
alphabetPanel.add(button);
}... |
282,545 | <p>I'm writing my first Windows CE app using the .NET Compact Framework v3.5.<br>
I need the app to be able to do an HTTP POST to a URL.<br>
It appears that the .NET CF does not have System.Web.<br>
So, I could use some guidence on how to accomplish and HTTP Posts using the .Net CF.
Thanks,
Greg</p>
| [
{
"answer_id": 282732,
"author": "ctacke",
"author_id": 13154,
"author_profile": "https://Stackoverflow.com/users/13154",
"pm_score": 0,
"selected": false,
"text": "<p>The <a href=\"http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest_members.aspx\" rel=\"nofollow noreferrer... | 2008/11/11 | [
"https://Stackoverflow.com/questions/282545",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23823/"
] | I'm writing my first Windows CE app using the .NET Compact Framework v3.5.
I need the app to be able to do an HTTP POST to a URL.
It appears that the .NET CF does not have System.Web.
So, I could use some guidence on how to accomplish and HTTP Posts using the .Net CF.
Thanks,
Greg | Does this satisfy your needs?
You need to import
System.IO
System.Net
System.Net.HttpWebRequest
```
Try
Dim Request As HttpWebRequest = CType(WebRequest.Create("<The server>"), HttpWebRequest)
Request.AllowWriteStreamBuffering = True
Request.KeepAlive = False
Request.Credentials = CredentialC... |
282,570 | <p>Simple question, hopefully an easy way and just want to verify I'm doing it the correct / efficient way.</p>
<p>I have a class T object, which is typically put into a vector that is created in my main() function. It can be any kind of data, string, int, float.. etc. I'm reading from a file... which is inputted fr... | [
{
"answer_id": 282573,
"author": "SoapBox",
"author_id": 36384,
"author_profile": "https://Stackoverflow.com/users/36384",
"pm_score": 2,
"selected": true,
"text": "<p>It looks like it will work fine, and I would say this is probably the best way to do it. But why are you asking here in... | 2008/11/11 | [
"https://Stackoverflow.com/questions/282570",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28392/"
] | Simple question, hopefully an easy way and just want to verify I'm doing it the correct / efficient way.
I have a class T object, which is typically put into a vector that is created in my main() function. It can be any kind of data, string, int, float.. etc. I'm reading from a file... which is inputted from the user ... | It looks like it will work fine, and I would say this is probably the best way to do it. But why are you asking here instead of just testing it yourself? |
282,571 | <p>I'm trying to design a homepage for an MVC site that has two different views, based on if the user is logged in or not.</p>
<p>So image the default (not logged in) view is showing general, nonspecific info. If i'm logged in, the view is showing mostly personal stuff instead.</p>
<p>What's the best practice to hand... | [
{
"answer_id": 282585,
"author": "Adrian Clark",
"author_id": 148,
"author_profile": "https://Stackoverflow.com/users/148",
"pm_score": 5,
"selected": true,
"text": "<p>This should be a simple case of returning the appropriate view from your controller.</p>\n\n<pre><code>public ActionRes... | 2008/11/11 | [
"https://Stackoverflow.com/questions/282571",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30674/"
] | I'm trying to design a homepage for an MVC site that has two different views, based on if the user is logged in or not.
So image the default (not logged in) view is showing general, nonspecific info. If i'm logged in, the view is showing mostly personal stuff instead.
What's the best practice to handling this? Don't ... | This should be a simple case of returning the appropriate view from your controller.
```
public ActionResult Index()
If (User.IsLoggedOn)
{
// Do user-specific controller stuff here...
return View("LoggedOnIndex");
}
else
{
// Do anon controller stuff here...
retu... |
282,575 | <p>I have a system which sits on a web server and generates files on the fly in response to HTTP requests. This is currently implemented as an HTTPHandler.</p>
<p>Once the files are generated, they don't change very often, so I'd like to implement a cache.</p>
<p>Ideally, I'd like the web server to look at the cache ... | [
{
"answer_id": 282617,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 1,
"selected": false,
"text": "<p>How about redirecting to your HttpHandler using the customError configuration.</p>\n\n<pre><code><customErrors mo... | 2008/11/11 | [
"https://Stackoverflow.com/questions/282575",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/475/"
] | I have a system which sits on a web server and generates files on the fly in response to HTTP requests. This is currently implemented as an HTTPHandler.
Once the files are generated, they don't change very often, so I'd like to implement a cache.
Ideally, I'd like the web server to look at the cache folder and serve ... | It's actually really simple, just point your 404 error page in IIS to your HTTPHandler.
Request.RawUrl will look like:
```
http://yourdomain.com/yourhandler.ashx;originally/requested/url
``` |
282,576 | <p>How does one do namespaced controllers in Merb, for instance to create an admin section to the site? In Rails one would use Admin::CategoriesController, is this similar in Merb or is this another recommended way of doing it?</p>
| [
{
"answer_id": 283197,
"author": "Laz",
"author_id": 34991,
"author_profile": "https://Stackoverflow.com/users/34991",
"pm_score": 3,
"selected": true,
"text": "<p>The namespace method seems to do it.</p>\n\n<p>This is placed in the routes file (router.rb):</p>\n\n<pre><code>namespace :a... | 2008/11/11 | [
"https://Stackoverflow.com/questions/282576",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34991/"
] | How does one do namespaced controllers in Merb, for instance to create an admin section to the site? In Rails one would use Admin::CategoriesController, is this similar in Merb or is this another recommended way of doing it? | The namespace method seems to do it.
This is placed in the routes file (router.rb):
```
namespace :admin do
resources :categories
end
```
This generates routes like:
```
edit_admin_category - /admin/categories/:id/edit(.:format)
delete_admin_category - /admin/categories/:id/delete(.:format)
admin_categories - /... |
282,600 | <p>For large <code>n</code> (see below for how to determine what's large enough), it's safe to treat, by the central limit theorem, the distribution of the sample mean as normal (gaussian) but I'd like a procedure that gives a confidence interval for any <code>n</code>. The way to do that is to use a Student T distrib... | [
{
"answer_id": 282633,
"author": "BCS",
"author_id": 1343,
"author_profile": "https://Stackoverflow.com/users/1343",
"pm_score": -1,
"selected": false,
"text": "<p>I think you can. I'd have to Google/Wikipidia for it so I'll leave that as an exercise for the reader.</p>\n"
},
{
"... | 2008/11/12 | [
"https://Stackoverflow.com/questions/282600",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4234/"
] | For large `n` (see below for how to determine what's large enough), it's safe to treat, by the central limit theorem, the distribution of the sample mean as normal (gaussian) but I'd like a procedure that gives a confidence interval for any `n`. The way to do that is to use a Student T distribution with `n-1` degrees o... | [Huge thanks to John D Cook for much of what I learned in putting together this answer!]
First, here's the reason not to use sum-of-squares: <http://www.johndcook.com/blog/2008/09/26/>
What you should do instead:
Keep track of the count (n), the mean (u), and a quantity (s) from which sample variance and standard er... |
282,603 | <p>I'm using a logging module that can have reporting enabled/disabled at runtime. Calls generally go something like:</p>
<pre><code>WARN(
"Danger Will Robinson! There are "
+ boost::lexical_cast<string>(minutes)
+ " minutes of oxygen left!"
);
</code></pre>
<p>I'm using an inline function for WA... | [
{
"answer_id": 282611,
"author": "Mr Fooz",
"author_id": 25050,
"author_profile": "https://Stackoverflow.com/users/25050",
"pm_score": 1,
"selected": false,
"text": "<p>I'd guess that it only has a chance to optimize it out if it can prove that there are no side effects (which might be d... | 2008/11/12 | [
"https://Stackoverflow.com/questions/282603",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3594/"
] | I'm using a logging module that can have reporting enabled/disabled at runtime. Calls generally go something like:
```
WARN(
"Danger Will Robinson! There are "
+ boost::lexical_cast<string>(minutes)
+ " minutes of oxygen left!"
);
```
I'm using an inline function for WARN, but I'm curious as to how mu... | If you need to be able to selectively enable and disable the warnings at run-time, the compiler will *not* be able to optimize out the call.
What you need is to rename your *function* to `WARN2` and add a macro something like:
```
#define WARN(s) do {if (WARNINGS_ENABLED) WARN2(s);} while (false)
```
This will prev... |
282,604 | <h3>(ANSWER) How to export some Geography data from a Microsoft Sql Server 2008.</h3>
<p>You'll need to use the command line argument BCP to dump the data in it's original (native) format to a binary file. Then on the other server you can bulk insert this binary data back into a table of the same strucutre.</p>
<p>he... | [
{
"answer_id": 637513,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>bulk insert error!!!\nMsg 6522, Level 16, State 1, Line 1\nA .NET Framework error occurred during execution of user-defined... | 2008/11/12 | [
"https://Stackoverflow.com/questions/282604",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30674/"
] | ### (ANSWER) How to export some Geography data from a Microsoft Sql Server 2008.
You'll need to use the command line argument BCP to dump the data in it's original (native) format to a binary file. Then on the other server you can bulk insert this binary data back into a table of the same strucutre.
here's some code.... | I originally removed the question in the opening post, to replace it with the answer (at the end of '08) ... and make it a wiki.
So yeah .. the OP is the answer :P |
282,615 | <p>I'm a new to MSBuild and wanted to play around with it a bit, but I just cannot figure out why this isn't working.</p>
<p>So my solution has two projects: "Model" and "BuildTasks". BuildTasks just has a single class:</p>
<pre><code>using Microsoft.Build.Utilities;
namespace BuildTasks
{
public class Test : T... | [
{
"answer_id": 282626,
"author": "Aaron Powell",
"author_id": 11388,
"author_profile": "https://Stackoverflow.com/users/11388",
"pm_score": 0,
"selected": false,
"text": "<p>Are you sure you have your path write? Shouldn't it be in the <code>bin\\Configuration Type\\BuildTasks.dll</code>... | 2008/11/12 | [
"https://Stackoverflow.com/questions/282615",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34715/"
] | I'm a new to MSBuild and wanted to play around with it a bit, but I just cannot figure out why this isn't working.
So my solution has two projects: "Model" and "BuildTasks". BuildTasks just has a single class:
```
using Microsoft.Build.Utilities;
namespace BuildTasks
{
public class Test : Task
{
publ... | We tried this and we found that you have to place the UsingTask at the top of the project file (and have all your paths right). However once thats in place and the task loads up it will only work once. After that the build starts failing because it cant copy the DLL that the task is in. We are actually running a post b... |
282,619 | <p>We have a My_list class that has a list of pointers to Abstract_things. To optimize on memory usage, all derived Things use one memory pool that is established with the "new and delete" stereotype. In order to size the pool properly during the initization of the application, the builder figures out which Thing is ... | [
{
"answer_id": 282636,
"author": "Tamas Czinege",
"author_id": 8954,
"author_profile": "https://Stackoverflow.com/users/8954",
"pm_score": 0,
"selected": false,
"text": "<p>I am not sure if I understand this correctly, but what is stopping you from having a build step which enumerates al... | 2008/11/12 | [
"https://Stackoverflow.com/questions/282619",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36756/"
] | We have a My\_list class that has a list of pointers to Abstract\_things. To optimize on memory usage, all derived Things use one memory pool that is established with the "new and delete" stereotype. In order to size the pool properly during the initization of the application, the builder figures out which Thing is the... | **Updated**: ok ... the embedded system requirement changes things somewhat.
You could use a class to register the derived classes automatically, and then added a static instance of this class to each derived class. You still have to remember to do this though, but at least it is self contained in a single place.
So... |
282,627 | <p>I'm attempting to utilize <a href="http://en.wikipedia.org/wiki/VBScript" rel="nofollow noreferrer">VBScript</a> to connect pull the <code>physicalDeliveryOfficeName</code> attribute in <a href="http://en.wikipedia.org/wiki/Active_Directory" rel="nofollow noreferrer">Active Directory</a> by providing the email addre... | [
{
"answer_id": 288873,
"author": "Otus",
"author_id": 36613,
"author_profile": "https://Stackoverflow.com/users/36613",
"pm_score": 2,
"selected": false,
"text": "<p>If using an <a href=\"http://en.wikipedia.org/wiki/Lightweight_Directory_Access_Protocol\" rel=\"nofollow noreferrer\">LDA... | 2008/11/12 | [
"https://Stackoverflow.com/questions/282627",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18853/"
] | I'm attempting to utilize [VBScript](http://en.wikipedia.org/wiki/VBScript) to connect pull the `physicalDeliveryOfficeName` attribute in [Active Directory](http://en.wikipedia.org/wiki/Active_Directory) by providing the email address.
I know how to do it with a common name like the following:
```
Set MyUser = GetOb... | I ended up writing the following:
```
Function getOffice (strname, uname)
strEmail = uname
WScript.Echo "email: " & strEmail
Dim objRoot : Set objRoot = GetObject("LDAP://RootDSE")
Dim objDomain : Set objDomain = GetObject("LDAP://" & objRoot.Get("defaultNamingContext"))
Dim cn : Set cn = CreateObject("ADODB.Conne... |
282,644 | <p>What is the correct way to convert ASP.NET SOAP-based web services to JSON-based responses?
...And then call these from jQuery?</p>
<p>What are "best practices" when integrating jQuery based AJAX and ASP.NET?
Articles? Books?</p>
| [
{
"answer_id": 282695,
"author": "Frank Schwieterman",
"author_id": 32203,
"author_profile": "https://Stackoverflow.com/users/32203",
"pm_score": 3,
"selected": true,
"text": "<p>JSON conversion to .NET classes can be done with <strong>System.Runtime.Serialization</strong> and <strong>Sy... | 2008/11/12 | [
"https://Stackoverflow.com/questions/282644",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36590/"
] | What is the correct way to convert ASP.NET SOAP-based web services to JSON-based responses?
...And then call these from jQuery?
What are "best practices" when integrating jQuery based AJAX and ASP.NET?
Articles? Books? | JSON conversion to .NET classes can be done with **System.Runtime.Serialization** and **System.Runtime.Serialization.JSON**. I suspect you're more interested in setting up function calls from client to server. I think it is worth trying [this tutorial](http://asp.net/AJAX/Documentation/Live/tutorials/ASPNETAJAXWebServi... |
282,647 | <p>In PHP, I can write:</p>
<pre><code>$vname = 'phone';
$$vname = '555-1234';
print $phone;
</code></pre>
<p>... And the script will output "555-1234".</p>
<p>Is there any equivalent in Perl?</p>
<p>Is there any way to constrain <code>$phone</code> to the scope of the local block, as if I'd written <code>my $phone... | [
{
"answer_id": 282668,
"author": "Christian C. Salvadó",
"author_id": 5445,
"author_profile": "https://Stackoverflow.com/users/5445",
"pm_score": 3,
"selected": false,
"text": "<p>You can do it in a very similar way:</p>\n\n<pre><code>$vname = \"phone\";\n$$vname = \"555-1234\";\nprint $... | 2008/11/12 | [
"https://Stackoverflow.com/questions/282647",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3528/"
] | In PHP, I can write:
```
$vname = 'phone';
$$vname = '555-1234';
print $phone;
```
... And the script will output "555-1234".
Is there any equivalent in Perl?
Is there any way to constrain `$phone` to the scope of the local block, as if I'd written `my $phone`? Using `my $$vname` gives me "Can't declare scalar der... | What you're attempting to do is called a "symbolic reference." While you can do this in Perl [you shouldn't](http://perl.plover.com/varvarname.html). Symbolic references only work with global variables -- not lexical (`my`) ones. There is no way to restrict their scope. **Symbolic references are dangerous.** For that r... |
282,653 | <p>Something that confuses me, but has never caused any problems... the recommended way to dispatch an event is as follows:</p>
<pre><code>public event EventHandler SomeEvent;
...
{
....
if(SomeEvent!=null)SomeEvent();
}
</code></pre>
<p>In a multi-threaded environment, how does this code guarantee that anoth... | [
{
"answer_id": 282661,
"author": "denis phillips",
"author_id": 748,
"author_profile": "https://Stackoverflow.com/users/748",
"pm_score": 2,
"selected": false,
"text": "<p>The recommended way is a little different and uses a temporary as follows:</p>\n\n<pre><code>EventHandler tmpEvent =... | 2008/11/12 | [
"https://Stackoverflow.com/questions/282653",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14357/"
] | Something that confuses me, but has never caused any problems... the recommended way to dispatch an event is as follows:
```
public event EventHandler SomeEvent;
...
{
....
if(SomeEvent!=null)SomeEvent();
}
```
In a multi-threaded environment, how does this code guarantee that another thread will not alter t... | In C# 6.0 you can use monadic Null-conditional operator `?.` to check for null and raise events in easy and thread-safe way.
```
SomeEvent?.Invoke(this, args);
```
It’s thread-safe because it evaluates the left-hand side only once, and keeps it in a temporary variable. You can read more [here](https://github.com/dot... |
282,667 | <p>I'm relatively new to programming and I have to write a function that reads in input from the user and to fill two arrays then compare them. I guess what I'm confused on is how to read in both arrays.</p>
<p>This is what I'm supposed to do,</p>
<p>Write a table_diff function that compares two arrays of integers an... | [
{
"answer_id": 282701,
"author": "CodingWithSpike",
"author_id": 28278,
"author_profile": "https://Stackoverflow.com/users/28278",
"pm_score": 0,
"selected": false,
"text": "<p>This doesn't really answer your question, but in your \"while\" condition, you already check for \"r != 1\", so... | 2008/11/12 | [
"https://Stackoverflow.com/questions/282667",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm relatively new to programming and I have to write a function that reads in input from the user and to fill two arrays then compare them. I guess what I'm confused on is how to read in both arrays.
This is what I'm supposed to do,
Write a table\_diff function that compares two arrays of integers and returns the su... | I think you want to change your code to the following:
```
while((r = scanf("%i", &value)) != 1 && ptra < endptra)
{
*(ptra++) = value;
if (r==1)
printf("No room after reading values\n\n");
else if(r != EOF)
printf("invalid char");
}
while((r = scanf("%i\n", ... |
282,670 | <p>If I have a list like this:</p>
<pre><code><ul id="mylist">
<li id="list-item1">text 1</li>
<li id="list-item2">text 2</li>
<li id="list-item3">text 3</li>
<li id="list-item4">text 4</li>
</ul>
</code></pre>
<p>What's the easiest way to re... | [
{
"answer_id": 282711,
"author": "nickf",
"author_id": 9021,
"author_profile": "https://Stackoverflow.com/users/9021",
"pm_score": 8,
"selected": true,
"text": "<p>Though there's probably an easier way to do this using a JS Library, here's a working solution using vanilla js.</p>\n\n<pre... | 2008/11/12 | [
"https://Stackoverflow.com/questions/282670",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21677/"
] | If I have a list like this:
```
<ul id="mylist">
<li id="list-item1">text 1</li>
<li id="list-item2">text 2</li>
<li id="list-item3">text 3</li>
<li id="list-item4">text 4</li>
</ul>
```
What's the easiest way to re-arrange the DOM nodes to my preference? (This needs to happen automatically when the ... | Though there's probably an easier way to do this using a JS Library, here's a working solution using vanilla js.
```
var list = document.getElementById('mylist');
var items = list.childNodes;
var itemsArr = [];
for (var i in items) {
if (items[i].nodeType == 1) { // get rid of the whitespace text nodes
it... |
282,676 | <p>I have some shapefile (demographic/heat map data in the USA, such as crime in New York) data imported into a sql server 2008 database, field data type: <em>Geography</em>.</p>
<p>How can i get this data, from a <em>select</em> query, in a format which i can then display on google maps or microsoft virtual earth?</p... | [
{
"answer_id": 282730,
"author": "wonderchook",
"author_id": 32113,
"author_profile": "https://Stackoverflow.com/users/32113",
"pm_score": 0,
"selected": false,
"text": "<p>The easiest way to do this is to select to XML and then transform the data into GeoRSS or KML. Virtual Earth and G... | 2008/11/12 | [
"https://Stackoverflow.com/questions/282676",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30674/"
] | I have some shapefile (demographic/heat map data in the USA, such as crime in New York) data imported into a sql server 2008 database, field data type: *Geography*.
How can i get this data, from a *select* query, in a format which i can then display on google maps or microsoft virtual earth?
thanks!
Edit 1: So far, ... | Geri Langlois's Sharpmap link is to 0.9 If you want bleeding edge, the repository is here:
<http://sharpmapv2.googlecode.com/svn>
Also, you have to make sure your data is Lat/Long WGS84 and not something else before you start placing coordinate info into your KML. I don't know of a way to do that in SQLServer2008 (mig... |
282,692 | <p>How can you express X of Y are true, in boolean logic? a rule like 2 of the following must be true (A, B, C, D, E, F)
is it a form of multiplcation or set operations?<br>
the end result is all the permutations like AB OR AC OR AD, if you said 3 of following it is like ABC, ABD, ABE, etc.. so it is like (A,B,C)^2?</... | [
{
"answer_id": 282728,
"author": "Charlie Martin",
"author_id": 35092,
"author_profile": "https://Stackoverflow.com/users/35092",
"pm_score": 2,
"selected": false,
"text": "<p>You've got the idea there. To express \"k of n holds\" you're going to need to enumerate all cases for which k ... | 2008/11/12 | [
"https://Stackoverflow.com/questions/282692",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5111/"
] | How can you express X of Y are true, in boolean logic? a rule like 2 of the following must be true (A, B, C, D, E, F)
is it a form of multiplcation or set operations?
the end result is all the permutations like AB OR AC OR AD, if you said 3 of following it is like ABC, ABD, ABE, etc.. so it is like (A,B,C)^2?
thank... | In boolean logic (**v** is OR, **'** following the predicate is NOT):
```
A B C'D'E'F' v
A B'C'D'E'F v
A'B C'D'E'F' v
: : : : : :
<absolute bucketload of boolean expressions>
: : : : : :
A'B'C'D'E F
```
With permutations, there's a great many subexpressions you need to write.
Of course, if this is a programming qu... |
282,700 | <p>I'm working on a school project and I'm getting some weird errors from Xcode. I'm using TextMate's Command+R function to compile the project. Compilation seems to work okay but linking fails with an error message I don't understand. </p>
<p>ld output:</p>
<blockquote>
<p>ld: duplicate symbol text_field(std::basi... | [
{
"answer_id": 282710,
"author": "Josh Kelley",
"author_id": 25507,
"author_profile": "https://Stackoverflow.com/users/25507",
"pm_score": 3,
"selected": false,
"text": "<p>It sounds like io_functions.cpp is being included twice (once by generics.cpp, once by main.cpp).</p>\n"
},
{
... | 2008/11/12 | [
"https://Stackoverflow.com/questions/282700",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16204/"
] | I'm working on a school project and I'm getting some weird errors from Xcode. I'm using TextMate's Command+R function to compile the project. Compilation seems to work okay but linking fails with an error message I don't understand.
ld output:
>
> ld: duplicate symbol text\_field(std::basic\_istream >&)in /path/fin... | My first thought was that you're including it twice on the linker command but it appears to be complaining about having the same function in `main.o` and `generics.o`.
So it looks like you're including the `io_functions.cpp` file into the `main.cpp` and `generics.cpp` which is a bad idea at the best of times.
You sho... |
282,712 | <p>I'm quite confused about the basic concepts of a Hash table. If I were to code a hash how would I even begin? What is the difference between a Hash table and just a normal array? </p>
<p>Basically if someone answered this question I think all my questions would be answered:
If I had 100 randomly generated numbers (... | [
{
"answer_id": 282722,
"author": "Daniel Spiewak",
"author_id": 9815,
"author_profile": "https://Stackoverflow.com/users/9815",
"pm_score": 4,
"selected": false,
"text": "<p>Hashtables are <em>associative</em>. This is a huge difference from arrays, which are just linear data structures... | 2008/11/12 | [
"https://Stackoverflow.com/questions/282712",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36545/"
] | I'm quite confused about the basic concepts of a Hash table. If I were to code a hash how would I even begin? What is the difference between a Hash table and just a normal array?
Basically if someone answered this question I think all my questions would be answered:
If I had 100 randomly generated numbers (as keys), ... | The answers so far have helped to define hash tables and explain some theory, but I think an example may help you get a better feeling for them.
*What is the difference between a hash table and just a normal array?*
A hash table and an array are both structures that allow you to store and retrieve data. Both allow yo... |
282,729 | <p>I was wondering if someone would be able to help me write a CQL query for NDepend that will show me all the methods in my form class that handle the form events. So I would like to be able to find all the methods that look like this:</p>
<pre><code>Private Sub AddFolderButton_Click(ByVal sender As System.Object, B... | [
{
"answer_id": 282931,
"author": "Nathan W",
"author_id": 6335,
"author_profile": "https://Stackoverflow.com/users/6335",
"pm_score": 0,
"selected": false,
"text": "<p>I have sort of got something that works but its not really 100% correct, because all the form generated event handlers h... | 2008/11/12 | [
"https://Stackoverflow.com/questions/282729",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6335/"
] | I was wondering if someone would be able to help me write a CQL query for NDepend that will show me all the methods in my form class that handle the form events. So I would like to be able to find all the methods that look like this:
```
Private Sub AddFolderButton_Click(ByVal sender As System.Object, ByVal e As Syste... | I am Patrick from the NDepend team and I confirm, so far using a condition 'Namelike + regular expression' on the 'method name + signature' is the best way to achieve what you want with CQL. |
282,740 | <p>Currently we have a DLL that checks whether a username/password is a valid Windows user using the Windows API LogonUser method. We need to enhance it so it checks whether the user belongs to a specified group as well. Is there a Windows method that does that?</p>
<p>Given a Windows username and password, find out w... | [
{
"answer_id": 282775,
"author": "Rob Walker",
"author_id": 3631,
"author_profile": "https://Stackoverflow.com/users/3631",
"pm_score": 0,
"selected": false,
"text": "<p>The closest single API is <a href=\"http://msdn.microsoft.com/en-us/library/aa376389(VS.85).aspx\" rel=\"nofollow nore... | 2008/11/12 | [
"https://Stackoverflow.com/questions/282740",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26305/"
] | Currently we have a DLL that checks whether a username/password is a valid Windows user using the Windows API LogonUser method. We need to enhance it so it checks whether the user belongs to a specified group as well. Is there a Windows method that does that?
Given a Windows username and password, find out whether the... | Thanks Abhijit, that function seems to do the job, I also found this link which had sample code:
<http://delphi.newswhat.com/geoxml/forumhistorythread?groupname=borland.public.delphi.nativeapi.win32&messageid=40914cf6@newsgroups.borland.com>
```
unit GetGroupsForUserUnit;
interface
uses
Windows, SysUtils, Classes... |
282,746 | <p>I'm writing C# code that needs to connect to COM events. I implemented the use of
IConnectionPointContainer and IConnectionPoint thus:</p>
<pre><code> IConnectionPointContainer connectionPointContainer = internalGenerator as IConnectionPointContainer;
if (connectionPointContainer == null)
{
... | [
{
"answer_id": 282796,
"author": "Rob Walker",
"author_id": 3631,
"author_profile": "https://Stackoverflow.com/users/3631",
"pm_score": 1,
"selected": false,
"text": "<p>IConnectionPointContainer is implemented on the CCW (COM callable wrapper) that .NET automatically generates when expo... | 2008/11/12 | [
"https://Stackoverflow.com/questions/282746",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36694/"
] | I'm writing C# code that needs to connect to COM events. I implemented the use of
IConnectionPointContainer and IConnectionPoint thus:
```
IConnectionPointContainer connectionPointContainer = internalGenerator as IConnectionPointContainer;
if (connectionPointContainer == null)
{
Debug.Fail("... | I didn't find a way to do this.
Eventually I will define another interface in .Net and will write 2 code paths, one for .Net objects and one for real COM objects. |
282,758 | <p>Sometimes you have strings that must fit within a certain pixel width. This function attempts to do so efficiently. Please post your suggestions or refactorings below :)</p>
<pre><code>function fitStringToSize(str,len) {
var shortStr = str;
var f = document.createElement("span");
f.style.display = 'hidd... | [
{
"answer_id": 282773,
"author": "Mr Fooz",
"author_id": 25050,
"author_profile": "https://Stackoverflow.com/users/25050",
"pm_score": 2,
"selected": false,
"text": "<p>At a quick glance, it looks good to me. Here are some minor suggestions:</p>\n\n<ul>\n<li><p>Use a binary search to fi... | 2008/11/12 | [
"https://Stackoverflow.com/questions/282758",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13289/"
] | Sometimes you have strings that must fit within a certain pixel width. This function attempts to do so efficiently. Please post your suggestions or refactorings below :)
```
function fitStringToSize(str,len) {
var shortStr = str;
var f = document.createElement("span");
f.style.display = 'hidden';
f.sty... | There are a couple of problems with your code.
* Why `/ 5` ? The width of the characters depends on `font-family` and `font-size`.
* You must escape `str` in the abbr title (or else an " will make the code invalid).
* `diff` is not declared and ends up in the global scope
* The `substring` is not supposed to work like... |
282,791 | <ul>
<li><p>How do I utilize a ?: operator in the SELECT clause of a LINQ query? If this can't be done, how can I emulate one? The goal is to get a CASE block in my select clause. As you might suspect, I'm getting an error: <em>Invalid anonymous type member declarator. Anonymous type members must be declared with a m... | [
{
"answer_id": 282806,
"author": "LeppyR64",
"author_id": 16592,
"author_profile": "https://Stackoverflow.com/users/16592",
"pm_score": 0,
"selected": false,
"text": "<p>I'm fairly new to Linq to SQL but I'm pretty sure it would go like this:</p>\n\n<pre><code>var query =\n from a in ... | 2008/11/12 | [
"https://Stackoverflow.com/questions/282791",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11112/"
] | * How do I utilize a ?: operator in the SELECT clause of a LINQ query? If this can't be done, how can I emulate one? The goal is to get a CASE block in my select clause. As you might suspect, I'm getting an error: *Invalid anonymous type member declarator. Anonymous type members must be declared with a member assignmen... | When creating an anonymous type (what you're doing with the "new" without specifying a type) you have to specify the member name for each property. From your example, it would look something like this: (also fixed your joins)
```
var query = from a in db.tblActivities
join i in db.tblIPs on a.ipid equals i... |
282,800 | <p>I don't even know where to go with this. Google wasn't very helpful. As with my previous question. I'm using TextMate's Command+R to compile the project.</p>
<blockquote>
<p>game.h:16:error: declaration of ‘Player* HalfSet::Player() const’</p>
<p>players.h:11:error: changes meaning of ‘Player’ from ‘class Player’</p... | [
{
"answer_id": 282818,
"author": "SoapBox",
"author_id": 36384,
"author_profile": "https://Stackoverflow.com/users/36384",
"pm_score": 5,
"selected": true,
"text": "<p>In C++ you cannot name a function the same name as a class/struct/typedef. You have a class named \"Player\" and so the... | 2008/11/12 | [
"https://Stackoverflow.com/questions/282800",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16204/"
] | I don't even know where to go with this. Google wasn't very helpful. As with my previous question. I'm using TextMate's Command+R to compile the project.
>
> game.h:16:error: declaration of ‘Player\* HalfSet::Player() const’
>
>
> players.h:11:error: changes meaning of ‘Player’ from ‘class Player’
>
>
> game.h:21... | In C++ you cannot name a function the same name as a class/struct/typedef. You have a class named "Player" and so the HalfSet class has a function named "Player" ("Player \*Player()"). You need to rename one of these (probably changing HalfSet's Player() to getPlayer() or somesuch). |
282,802 | <p>I know that I can <code> svn diff -r a:b repo </code> to view the changes between the two specified revisions. What I'd like is a diff for every revision that changed the file. Is such a command available?</p>
| [
{
"answer_id": 282887,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 5,
"selected": false,
"text": "<p>You could use <code>git-svn</code> to import the repository into a Git repository, then use <code>git log -p filename<... | 2008/11/12 | [
"https://Stackoverflow.com/questions/282802",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23071/"
] | I know that I can `svn diff -r a:b repo` to view the changes between the two specified revisions. What I'd like is a diff for every revision that changed the file. Is such a command available? | There's no built-in command for it, so I usually just do something like this:
```
#!/bin/bash
# history_of_file
#
# Outputs the full history of a given file as a sequence of
# logentry/diff pairs. The first revision of the file is emitted as
# full text since there's not previous version to compare it to.
function ... |
282,831 | <p>I am trying to see what are the gotchas in using XmlHttpWebRequest such that it works for Safari, Firefox and IE?</p>
| [
{
"answer_id": 282842,
"author": "Corey Trager",
"author_id": 9328,
"author_profile": "https://Stackoverflow.com/users/9328",
"pm_score": 1,
"selected": false,
"text": "<p>Here's somebody who got his hands dirty with that question:</p>\n\n<p><a href=\"http://www.webmasterworld.com/javasc... | 2008/11/12 | [
"https://Stackoverflow.com/questions/282831",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am trying to see what are the gotchas in using XmlHttpWebRequest such that it works for Safari, Firefox and IE? | probably the most obvious difference is how to get an XMLHttpRequest in the first place:
```
var xhr;
if (window.XMLHttpRequest) {
xhr = new XMLHttpRequest(); // Mozilla/Webkit/Opera
} else if (window.ActiveXObject) {
xhr = new ActiveXObject('Msxml2.XMLHTTP'); // IE
} else {
throw new Error('Ajax likely not s... |
282,832 | <p>I am trying to do something like this</p>
<pre><code>public void GetData(ref Dictionary<T,V> dataDictionary)
{
}
</code></pre>
<p>Where T can be GUID, string, or int and V is custom user or item object.</p>
| [
{
"answer_id": 282846,
"author": "jons911",
"author_id": 34375,
"author_profile": "https://Stackoverflow.com/users/34375",
"pm_score": 0,
"selected": false,
"text": "<p>Does this help? Any additional info would be helpful.</p>\n\n<pre><code>public void GetData<T, V>(ref Dictionary... | 2008/11/12 | [
"https://Stackoverflow.com/questions/282832",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am trying to do something like this
```
public void GetData(ref Dictionary<T,V> dataDictionary)
{
}
```
Where T can be GUID, string, or int and V is custom user or item object. | Why do you want the ability to change the callers reference? Why isn't
```
public Dictionary<T,V> GetData<T,V>()
```
good enough?
In your ref-based world:
```
public void GetData<T,V>(ref Dictionary<T,V> dictionary)
```
---
EDIT: Not that I in any way condone the following, but ...
If you need to care about th... |
282,838 | <p>I know this question had been asked more than a few times, but so far I haven't been able to find a good solution for it.</p>
<p>I've got a panel with other control on it.<br>
I want to draw a line on it and on top of all the controls in the panel</p>
<p>I came across 3 types of solutions (non of them worked the w... | [
{
"answer_id": 282857,
"author": "MusiGenesis",
"author_id": 14606,
"author_profile": "https://Stackoverflow.com/users/14606",
"pm_score": 3,
"selected": false,
"text": "<p>If you want the line to be just a simple horizontal or vertical line, put another panel (disabled so it doesn't pic... | 2008/11/12 | [
"https://Stackoverflow.com/questions/282838",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36777/"
] | I know this question had been asked more than a few times, but so far I haven't been able to find a good solution for it.
I've got a panel with other control on it.
I want to draw a line on it and on top of all the controls in the panel
I came across 3 types of solutions (non of them worked the way I wanted) :
1.... | Turns out this is a whole lot easier than I thought. Thanks for not accepting any of my other answers. Here is the two-step process for creating a **Fline** (**f**loating **line** - sorry, it's late):
[](https://i.stack.imgur.com/MG0Lw.jpg)
**Step 1**: Add a UserControl... |
282,858 | <p>In standard php or source code based projects we easily keep all of the code in SVN and each developer can checkout their own copy and collaborate on the same code. </p>
<p>When developing a Drupal site however, much of the work is in "setup". Besides the theme and modules you don't really have any "source code".... | [
{
"answer_id": 282942,
"author": "Nick Sergeant",
"author_id": 22468,
"author_profile": "https://Stackoverflow.com/users/22468",
"pm_score": 4,
"selected": false,
"text": "<p>I wrote an article on <a href=\"http://nicksergeant.com/2007/painless-drupal-revision-control-with-cvs-and-subver... | 2008/11/12 | [
"https://Stackoverflow.com/questions/282858",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36780/"
] | In standard php or source code based projects we easily keep all of the code in SVN and each developer can checkout their own copy and collaborate on the same code.
When developing a Drupal site however, much of the work is in "setup". Besides the theme and modules you don't really have any "source code". How do you ... | I think a good strategy here is to use the install profile API. With install profile API you can do most things that using the Drupal admin tools do. Most core forms simply set variables in the variables table. To be able to sensibly version your non content database contents i.e. configuration it is wise to use update... |
282,859 | <p>I remember from way back at university using a switch with 'binary search' or 'binary switch'. Something like that, My google foo is broken today. Anyway it goes down like this: You define an array of possible options (Strings usually), some magic happens, and those options in the array become the cases in the switc... | [
{
"answer_id": 282869,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 4,
"selected": true,
"text": "<p>I think what you are looking for is an <a href=\"http://java.sun.com/docs/books/tutorial/java/javaOO/enum.html\" rel=... | 2008/11/12 | [
"https://Stackoverflow.com/questions/282859",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3431280/"
] | I remember from way back at university using a switch with 'binary search' or 'binary switch'. Something like that, My google foo is broken today. Anyway it goes down like this: You define an array of possible options (Strings usually), some magic happens, and those options in the array become the cases in the switch h... | I think what you are looking for is an [Enum](http://java.sun.com/docs/books/tutorial/java/javaOO/enum.html).
From the link above...
```
public enum Day {
SUNDAY, MONDAY, TUESDAY, WEDNESDAY,
THURSDAY, FRIDAY, SATURDAY
}
public class EnumTest {
Day day;
public EnumTest(Day day) {
this.day... |
282,862 | <p>Is there a way to have a function return a editable reference to some internal data. Here's an example I hope helps show what I mean.</p>
<pre><code>class foo
{
public int value;
}
class bar
{
bar()
{
m_foo = new foo();
m_foo.value = 42;
}
private m_foo;
foo getFoo(){return m_... | [
{
"answer_id": 282878,
"author": "jpoh",
"author_id": 4368,
"author_profile": "https://Stackoverflow.com/users/4368",
"pm_score": 0,
"selected": false,
"text": "<p>You're already returning the reference of <code>foo</code> in <code>getFoo</code> (this happens by default). So any changes ... | 2008/11/12 | [
"https://Stackoverflow.com/questions/282862",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36782/"
] | Is there a way to have a function return a editable reference to some internal data. Here's an example I hope helps show what I mean.
```
class foo
{
public int value;
}
class bar
{
bar()
{
m_foo = new foo();
m_foo.value = 42;
}
private m_foo;
foo getFoo(){return m_foo;}
}
class... | Actually, your code sample, after some cleaning up, does demonstrate that when you assign 37 to value, you are changing bar's interman m\_foo too. So the answer is, your function is returning a reference type. Now, maybe your real code is different, and it's returning not an reference type but an int, a value type, or ... |
282,883 | <p>We need to start adding internationalisation to our program. Thankfully not the whole thing yet, just a few bits, but I want the way we do it to scale up to potentially cover the whole program. The thing is, our program is based on plugins, so not all strings belong in the same place.</p>
<p>As far as I understand ... | [
{
"answer_id": 282919,
"author": "matt b",
"author_id": 4249,
"author_profile": "https://Stackoverflow.com/users/4249",
"pm_score": 2,
"selected": false,
"text": "<p>You don't <em>have</em> to implement ResourceBundles as a series of classes, with one class per locale (i.e. a class named... | 2008/11/12 | [
"https://Stackoverflow.com/questions/282883",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1000/"
] | We need to start adding internationalisation to our program. Thankfully not the whole thing yet, just a few bits, but I want the way we do it to scale up to potentially cover the whole program. The thing is, our program is based on plugins, so not all strings belong in the same place.
As far as I understand it, Java's... | You don't *have* to implement ResourceBundles as a series of classes, with one class per locale (i.e. a class named `MyProgramStrings`, `MyProgramStrings_fr`, `MyProgramStrings_de`). The ResourceBundle class will fall back to using properties files if need be:
```
public static void main(String[] args) {
Resource... |
282,899 | <p>If you have a particular line of C code in mind to examine in the machine output, how would you locate it in objdump output. Here is an example</p>
<pre><code>if (cond)
foo;
bar();
</code></pre>
<p>and I want to see if bar was inlined as I'd like.
Or would you use some alternative tool instead of objdump?</... | [
{
"answer_id": 282934,
"author": "Johannes Schaub - litb",
"author_id": 34509,
"author_profile": "https://Stackoverflow.com/users/34509",
"pm_score": 4,
"selected": true,
"text": "<p>You can start objdump using the <code>-S</code> option (like <code>\"objdump -Sd a.out\"</code>). It will... | 2008/11/12 | [
"https://Stackoverflow.com/questions/282899",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30636/"
] | If you have a particular line of C code in mind to examine in the machine output, how would you locate it in objdump output. Here is an example
```
if (cond)
foo;
bar();
```
and I want to see if bar was inlined as I'd like.
Or would you use some alternative tool instead of objdump? | You can start objdump using the `-S` option (like `"objdump -Sd a.out"`). It will display the sourcecode intermixxed with the assembler code, if the source-files the code was compiled from are available.
Alternatively, you can use the following way:
```
int main(void) {
int a = 0;
asm("#");
return a;
}
`... |
282,901 | <p>I'm reading in a lot of data from ldap which needs to be compared to the respective records in the database. To minimize the number of SQL queries, I want to batch multiple ldap records into a single query.</p>
<p>All this is pretty simple: A thread to produce ldap results, and a thread to consume those results a... | [
{
"answer_id": 282909,
"author": "Corey Trager",
"author_id": 9328,
"author_profile": "https://Stackoverflow.com/users/9328",
"pm_score": 0,
"selected": false,
"text": "<p>The \"EOF\" approach is perfectly respectable. Let's look at the microcosm of an ANSI string. The null is the EO... | 2008/11/12 | [
"https://Stackoverflow.com/questions/282901",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm reading in a lot of data from ldap which needs to be compared to the respective records in the database. To minimize the number of SQL queries, I want to batch multiple ldap records into a single query.
All this is pretty simple: A thread to produce ldap results, and a thread to consume those results and run the S... | I would follow the "Make it Run, Make it Right, Make it Fast, Make it Simple" pattern.
Can you implement this correctly without an special "EOF" token? If not, then you just have to use the EOF token, do not sweat it. Yes, the termination condition is more complex, but now it is "Right." |
282,904 | <p>I have this PHP script that I wrote to automatically follow users that post messages with certain terms. It works 100% of the time on a bunch of test accounts but then does not work on the account I'd like to use it with. </p>
<p>I've checked the account's API rate limit and it's well within the boundaries. I've ... | [
{
"answer_id": 284875,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>Try using:</p>\n\n<pre><code>curl_setopt($ch, CURLOPT_VERBOSE, 1);\n</code></pre>\n\n<p>to and see if it helps identify... | 2008/11/12 | [
"https://Stackoverflow.com/questions/282904",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30098/"
] | I have this PHP script that I wrote to automatically follow users that post messages with certain terms. It works 100% of the time on a bunch of test accounts but then does not work on the account I'd like to use it with.
I've checked the account's API rate limit and it's well within the boundaries. I've also verifie... | To debug your cURL request everything has been said, but maybe you could use [Services\_Twitter](http://pear.php.net/package/Services_Twitter), which is a package wrapped around the Twitter-API. It provides pretty robust response handling.
Currently supports search and friendships also.
If you don't want to do that, ... |
282,916 | <p>I am extremely new at php and I was wondering if someone could help me use either a <code>for()</code> or <code>while()</code> loop to create an array of 10 elements.</p>
| [
{
"answer_id": 282917,
"author": "Owen",
"author_id": 4853,
"author_profile": "https://Stackoverflow.com/users/4853",
"pm_score": 5,
"selected": false,
"text": "<pre><code>$array = array();\n$array2 = array();\n\n// for example\nfor ($i = 0; $i < 10; ++$i) {\n $array[] = 'new eleme... | 2008/11/12 | [
"https://Stackoverflow.com/questions/282916",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am extremely new at php and I was wondering if someone could help me use either a `for()` or `while()` loop to create an array of 10 elements. | ```
$array = array();
$array2 = array();
// for example
for ($i = 0; $i < 10; ++$i) {
$array[] = 'new element';
}
// while example
while (count($array2) < 10 ) {
$array2[] = 'new element';
}
print "For: ".count($array)."<br />";
print "While: ".count($array2)."<br />";
``` |
282,938 | <p>What is the best way to give the user feedback for a color selection?<br>
I have a dialog with a "Select Color" push button which pops a <code>QColorDialog</code>. After the selection is made I want to show the user the color selected.<br>
Usually I do this using a <code>QLabel</code> and changing it's background co... | [
{
"answer_id": 283262,
"author": "Jérôme",
"author_id": 2796,
"author_profile": "https://Stackoverflow.com/users/2796",
"pm_score": 3,
"selected": false,
"text": "<p>The way I'm doing it is the following :</p>\n\n<p>I actually change the color of the button, to reflect the user choice. T... | 2008/11/12 | [
"https://Stackoverflow.com/questions/282938",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9611/"
] | What is the best way to give the user feedback for a color selection?
I have a dialog with a "Select Color" push button which pops a `QColorDialog`. After the selection is made I want to show the user the color selected.
Usually I do this using a `QLabel` and changing it's background color in the palette. This me... | The way I'm doing it is the following :
I actually change the color of the button, to reflect the user choice. To do this, I'm using the Qt style sheet, which ensure it is portable :
```
const QString COLOR_STYLE("QPushButton { background-color : %1; color : %2; }");
QColor ChosenColor; // Color chosen by the user w... |
282,943 | <p>Does anyone have a good way of implementing something like a sequence in SQL server?</p>
<p>Sometimes you just don't want to use a GUID, besides the fact that they are ugly as heck. Maybe the sequence you want isn't numeric? Besides, inserting a row and then asking the DB what the number is just seems so hackish.<... | [
{
"answer_id": 282957,
"author": "matt b",
"author_id": 4249,
"author_profile": "https://Stackoverflow.com/users/4249",
"pm_score": 3,
"selected": false,
"text": "<p><a href=\"http://msdn.microsoft.com/en-us/library/ms186775.aspx\" rel=\"noreferrer\">An Identity column</a> is roughly ana... | 2008/11/12 | [
"https://Stackoverflow.com/questions/282943",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3453/"
] | Does anyone have a good way of implementing something like a sequence in SQL server?
Sometimes you just don't want to use a GUID, besides the fact that they are ugly as heck. Maybe the sequence you want isn't numeric? Besides, inserting a row and then asking the DB what the number is just seems so hackish. | Sql Server 2012 has introduced [`SEQUENCE` objects](http://msdn.microsoft.com/en-us/library/ff878058.aspx), which allow you to generate sequential numeric values not associated with any table.
Creating them are easy:
```
CREATE SEQUENCE Schema.SequenceName
AS int
INCREMENT BY 1 ;
```
An example of using them before... |
282,977 | <p>Suppose that I have a Java class with a static method, like so:</p>
<pre>
class A
{
static void foo()
{
// Which class invoked me?
}
}
</pre>
<p>And suppose further that class A has an arbitrary number of subclasses:</p>
<pre>
class B extends A { }
class C extends A { }
class D extends A { }
.... | [
{
"answer_id": 283008,
"author": "Daniel Spiewak",
"author_id": 9815,
"author_profile": "https://Stackoverflow.com/users/9815",
"pm_score": 4,
"selected": true,
"text": "<p>It can't, and that's part of the problem with static methods. As far as the compiler is concerned <code>A.foo()</c... | 2008/11/12 | [
"https://Stackoverflow.com/questions/282977",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36794/"
] | Suppose that I have a Java class with a static method, like so:
```
class A
{
static void foo()
{
// Which class invoked me?
}
}
```
And suppose further that class A has an arbitrary number of subclasses:
```
class B extends A { }
class C extends A { }
class D extends A { }
...
```
Now consi... | It can't, and that's part of the problem with static methods. As far as the compiler is concerned `A.foo()` and `B.foo()` are exactly the same thing. In fact, they compile down to the same bytecode. You can't get more similar than that.
If you really need this sort of information, use a singleton and turn `foo()` into... |
282,983 | <p>I'm following several tutorials and references trying to get my kernel set up. I've come across some unfamiliar code in a tutorial that isn't explaining it at all. It's code that I'm told maps the <code>16 IRQs (0-15)</code> to ISR locations <code>32-47</code>:</p>
<pre><code>void irq_remap(void)
{
outportb(0x2... | [
{
"answer_id": 283033,
"author": "Evan Teran",
"author_id": 13430,
"author_profile": "https://Stackoverflow.com/users/13430",
"pm_score": 5,
"selected": true,
"text": "<p><code>outb</code> and similar, write to hardware IO ports. Basically, there are 2 primary options for communicating w... | 2008/11/12 | [
"https://Stackoverflow.com/questions/282983",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19521/"
] | I'm following several tutorials and references trying to get my kernel set up. I've come across some unfamiliar code in a tutorial that isn't explaining it at all. It's code that I'm told maps the `16 IRQs (0-15)` to ISR locations `32-47`:
```
void irq_remap(void)
{
outportb(0x20, 0x11);
outportb(0xA0, 0x11);
... | `outb` and similar, write to hardware IO ports. Basically, there are 2 primary options for communicating with a device. You can have the device mapped to memory or IO ports.
As for how this code works, i'll comment it for you:
ICW stands for "Initialization Commands Words"
```
outportb(0x20, 0x11); /* write ICW1 to ... |
283,004 | <p>I'm building an ORM library with reuse and simplicity in mind; everything goes fine except that I got stuck by a stupid inheritance limitation. Please consider the code below:</p>
<pre><code>class BaseModel {
/*
* Return an instance of a Model from the database.
*/
static public function get (/* v... | [
{
"answer_id": 283094,
"author": "Owen",
"author_id": 4853,
"author_profile": "https://Stackoverflow.com/users/4853",
"pm_score": 8,
"selected": true,
"text": "<p>in short. this is not possible. in php4 you could implement a terrible hack (examine the <code>debug_backtrace()</code>) but ... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283004",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36797/"
] | I'm building an ORM library with reuse and simplicity in mind; everything goes fine except that I got stuck by a stupid inheritance limitation. Please consider the code below:
```
class BaseModel {
/*
* Return an instance of a Model from the database.
*/
static public function get (/* varargs */) {
... | in short. this is not possible. in php4 you could implement a terrible hack (examine the `debug_backtrace()`) but that method does not work in PHP5. references:
* [30423](http://bugs.php.net/bug.php?id=30423)
=============================================
* [37684](http://bugs.php.net/bug.php?id=37684)
================... |
283,027 | <p>I am working on a WPF application that opens and displays XPS documents. When the application closes, the specification is the application should delete the opened XPS document for clean up. However, when opening a certain XPS document, the application throws an exception that the file is still in use when it tries ... | [
{
"answer_id": 283104,
"author": "Ana Betts",
"author_id": 5728,
"author_profile": "https://Stackoverflow.com/users/5728",
"pm_score": 0,
"selected": false,
"text": "<p><a href=\"http://blogs.msdn.com/junfeng/archive/2008/04/21/use-htrace-to-debug-handle-leak.aspx\" rel=\"nofollow norefe... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283027",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am working on a WPF application that opens and displays XPS documents. When the application closes, the specification is the application should delete the opened XPS document for clean up. However, when opening a certain XPS document, the application throws an exception that the file is still in use when it tries to ... | Make the xpsDocument a member, then don't call close() on it :) |
283,032 | <p>I am using UIActivityIndicatorView to showing user that there is something going on, let them wait. But UIActivityIndicatorView looks small, do not have background color, and not very obvious to the user. While in iPhone SDK's UIImagePickerController, it uses the similar mechanism, but with the black background as w... | [
{
"answer_id": 283119,
"author": "leonho",
"author_id": 30883,
"author_profile": "https://Stackoverflow.com/users/30883",
"pm_score": 4,
"selected": false,
"text": "<p>If you just want a different background color of your UIActivityIndictatorView, you could just send the setBackgroundCol... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283032",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32096/"
] | I am using UIActivityIndicatorView to showing user that there is something going on, let them wait. But UIActivityIndicatorView looks small, do not have background color, and not very obvious to the user. While in iPhone SDK's UIImagePickerController, it uses the similar mechanism, but with the black background as well... | If you just want a different background color of your UIActivityIndictatorView, you could just send the setBackgroundColor message to the object, i.e.:
```
[activityIndicator setBackgroundColor:[UIColor blackColor]];
```
By the way, you can change the size of the indicator as well. just do setFrame or initWithFrame ... |
283,035 | <p>I have a Windows application (VS2005/C#) which comes in two versions, Enterprise and Pro. In the Pro version, some of the features and menus are disabled. Currently, I'm doing this by commenting out the disabling code to create the Enterprise version, then I copy each executable file to another location. Obviously t... | [
{
"answer_id": 283044,
"author": "moobaa",
"author_id": 3569,
"author_profile": "https://Stackoverflow.com/users/3569",
"pm_score": 0,
"selected": false,
"text": "<p>Why not create a separate assembly that enables / disables the features as required? Then just include the appropriate ass... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283035",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5255/"
] | I have a Windows application (VS2005/C#) which comes in two versions, Enterprise and Pro. In the Pro version, some of the features and menus are disabled. Currently, I'm doing this by commenting out the disabling code to create the Enterprise version, then I copy each executable file to another location. Obviously this... | from the BUILD menu, select configuration manager option
on the active solution configuration dropdown select "new"
create two new 'configurations' one for PRO and one for ENTERPRISE
close the configuration manager.
open the project properties (from the project context menu)
select the build tab
select the PRO co... |
283,045 | <p>I need help writing the following method:</p>
<pre><code>def get_new_location(current_location, target_location, distance_travelled):
...
...
return new_location
</code></pre>
<p>where all locations are (lat,long)</p>
<p>I realize that there are different models for the earth (WGS-84, GRS-80, ...) whi... | [
{
"answer_id": 283139,
"author": "Drew Hall",
"author_id": 23934,
"author_profile": "https://Stackoverflow.com/users/23934",
"pm_score": 2,
"selected": false,
"text": "<p>As BenjiSmith said, there are potentially several paths that connect any A & B on the globe, but the two most pop... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283045",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20498/"
] | I need help writing the following method:
```
def get_new_location(current_location, target_location, distance_travelled):
...
...
return new_location
```
where all locations are (lat,long)
I realize that there are different models for the earth (WGS-84, GRS-80, ...) which take into account the fact tha... | As BenjiSmith said, there are potentially several paths that connect any A & B on the globe, but the two most popular (by far!) are the "great circle" and "rhumb line" paths.
A great circle gives the shortest distance (by constructing a plane from the two points & the center of the earth & following a circular arc in... |
283,061 | <p>My installation of APEX has come pear shaped on a Oracle 9.2.0.5.0 instance, all the packages are invalid.</p>
<p>I've tried recompiling everything with DBMS_UTILITY.compile_schema, but still all the packages are invalid. So, tried recompiling individual packages,</p>
<pre><code>SQL> ALTER PACKAGE FLOWS_020000.... | [
{
"answer_id": 283085,
"author": "Gary Myers",
"author_id": 25714,
"author_profile": "https://Stackoverflow.com/users/25714",
"pm_score": 2,
"selected": false,
"text": "<p>try </p>\n\n<pre><code>SHOW ERRORS PACKAGE BODY FLOWS_020000.WWV_FLOW_QUERY\n</code></pre>\n"
},
{
"answer_i... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283061",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3839/"
] | My installation of APEX has come pear shaped on a Oracle 9.2.0.5.0 instance, all the packages are invalid.
I've tried recompiling everything with DBMS\_UTILITY.compile\_schema, but still all the packages are invalid. So, tried recompiling individual packages,
```
SQL> ALTER PACKAGE FLOWS_020000.WWV_FLOW_QUERY COMPILE... | After giving up on this problem for a few months, then coming back to it, I worked it out.
The package I was trying to compile had been wrapped. Apparently, you when compiling wrapped packages, you must be logged in as the package owner.
I suspect a bug was also at play here, as some deeper investigation showed when ... |
283,063 | <p>Given the following simple example:</p>
<pre><code> List<string> list = new List<string>() { "One", "Two", "Three", "three", "Four", "Five" };
CaseInsensitiveComparer ignoreCaseComparer = new CaseInsensitiveComparer();
var distinctList = list.Distinct(ignoreCaseComparer as IEqualityComparer... | [
{
"answer_id": 283188,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 9,
"selected": true,
"text": "<p><code>StringComparer</code> does what you need:</p>\n\n<pre><code>List<string> list = new List<string>(... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283063",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5023/"
] | Given the following simple example:
```
List<string> list = new List<string>() { "One", "Two", "Three", "three", "Four", "Five" };
CaseInsensitiveComparer ignoreCaseComparer = new CaseInsensitiveComparer();
var distinctList = list.Distinct(ignoreCaseComparer as IEqualityComparer<string>).ToList();
```
... | `StringComparer` does what you need:
```
List<string> list = new List<string>() {
"One", "Two", "Three", "three", "Four", "Five" };
var distinctList = list.Distinct(
StringComparer.CurrentCultureIgnoreCase).ToList();
```
(or invariant / ordinal / etc depending on the data you are comparing) |
283,090 | <p>I'd like to popup a simple dialog with an editor box, to let user enter some value then just return. I am wondering whether iPhone SDK has that kind of support.</p>
<p>Thanks.</p>
| [
{
"answer_id": 283194,
"author": "Max Stewart",
"author_id": 18338,
"author_profile": "https://Stackoverflow.com/users/18338",
"pm_score": 2,
"selected": false,
"text": "<p>You need to create your popup (UIAlertView) and add a UITextField (or whatever component you'd like to use) to it a... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283090",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32096/"
] | I'd like to popup a simple dialog with an editor box, to let user enter some value then just return. I am wondering whether iPhone SDK has that kind of support.
Thanks. | I found a solution at :
<http://www.iphonedevsdk.com/forum/iphone-sdk-development/1704-uitextfield-inside-uialertview.html>
Here is the code which works for me.
```
UIAlertView *myAlertView = [[UIAlertView alloc] initWithTitle:@"Your title here" message:@"this gets covered" delegate:self cancelButtonTitle:@"Cancel" ... |
283,103 | <p>DDL for Database Tables:</p>
<pre><code> Users:
id - int - identity
name - varchar - unique
PCs:
id - int - idnetity
name - varchar - unique
userid - FK to Users
Apps:
id - int - identity
name - varchar
pcid - FK to PCs
</code></pre>
<p>I created a DataContext using the... | [
{
"answer_id": 283108,
"author": "Glenn Slaven",
"author_id": 2975,
"author_profile": "https://Stackoverflow.com/users/2975",
"pm_score": 0,
"selected": false,
"text": "<p>That looks fine to me, I'm not sure why that would create a cross join</p>\n"
},
{
"answer_id": 283157,
... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283103",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16592/"
] | DDL for Database Tables:
```
Users:
id - int - identity
name - varchar - unique
PCs:
id - int - idnetity
name - varchar - unique
userid - FK to Users
Apps:
id - int - identity
name - varchar
pcid - FK to PCs
```
I created a DataContext using the Linq To SQL designer in V... | That will work. It's normal because the second "from" inquires in the PC's set of the users and the third "from", the Apps set of the pcs. And I guess that is not going generate a cross join as T-Sql, because the conditions are already defined in the foreign keys and associations.
But I guess this should be the syntac... |
283,120 | <p>I want to assign default values to a column in my select sql query so that if the value of that column is null I get that default value in my recordset. Is there anyway to do this?</p>
<p>Example:</p>
<pre><code>select col1 (some default value) from tblname;
</code></pre>
| [
{
"answer_id": 283129,
"author": "LeppyR64",
"author_id": 16592,
"author_profile": "https://Stackoverflow.com/users/16592",
"pm_score": 3,
"selected": false,
"text": "<pre><code>select\n isnull(col1, defaultvalue)\nfrom\n tblname;\n</code></pre>\n"
},
{
"answer_id": 283133,
... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283120",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I want to assign default values to a column in my select sql query so that if the value of that column is null I get that default value in my recordset. Is there anyway to do this?
Example:
```
select col1 (some default value) from tblname;
``` | The preferable way is to use ANSI compatible function [COALESCE](http://msdn.microsoft.com/en-us/library/ms190349.aspx):
```
SELECT COALESCE(column_name, default_value) FROM table_name;
```
You also could read [an article](http://databases.aspfaq.com/database/coalesce-vs-isnull-sql.html) which compares COALESCE and ... |
283,128 | <p>I'm writing a wrapper class for a command line executable. This exe accepts input from <code>stdin</code> until I hit <code>Ctrl+C</code> in the command prompt shell, in which case it prints output to <code>stdout</code> based on the input. I want to simulate that <code>Ctrl+C</code> press in C# code, sending the ... | [
{
"answer_id": 283137,
"author": "Alon L",
"author_id": 30884,
"author_profile": "https://Stackoverflow.com/users/30884",
"pm_score": -1,
"selected": false,
"text": "<p>Try actually sending the Key Combination Ctrl+C, instead of directly terminating the process:</p>\n\n<pre><code> [DllIm... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283128",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19252/"
] | I'm writing a wrapper class for a command line executable. This exe accepts input from `stdin` until I hit `Ctrl+C` in the command prompt shell, in which case it prints output to `stdout` based on the input. I want to simulate that `Ctrl+C` press in C# code, sending the kill command to a .NET `Process` object. I've tri... | I've actually just figured out the answer. Thank you both for your answers, but it turns out that all i had to do was this:
```
p.StandardInput.Close()
```
which causes the program I've spawned to finish reading from stdin and output what i need. |
283,131 | <p>Can anyone help me to put a vertical scroll bar for an <code><asp:CheckBoxList></code>?</p>
| [
{
"answer_id": 283137,
"author": "Alon L",
"author_id": 30884,
"author_profile": "https://Stackoverflow.com/users/30884",
"pm_score": -1,
"selected": false,
"text": "<p>Try actually sending the Key Combination Ctrl+C, instead of directly terminating the process:</p>\n\n<pre><code> [DllIm... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283131",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29867/"
] | Can anyone help me to put a vertical scroll bar for an `<asp:CheckBoxList>`? | I've actually just figured out the answer. Thank you both for your answers, but it turns out that all i had to do was this:
```
p.StandardInput.Close()
```
which causes the program I've spawned to finish reading from stdin and output what i need. |
283,143 | <p>I was trying to figure out how to implement method_missing in C# 4, based on all of 2 blog posts floating around on IDynamicObject. </p>
<p>What I want to do is have a Business Logic Layer that has a Repository, and if the method is missing from the Business Logic Layer, just call the Repository and pass through it... | [
{
"answer_id": 283207,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 1,
"selected": false,
"text": "<p>I believe you need to return a new MetaObject with the returned value as a constant expression.</p>\n\n<p>That's cert... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283143",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24616/"
] | I was trying to figure out how to implement method\_missing in C# 4, based on all of 2 blog posts floating around on IDynamicObject.
What I want to do is have a Business Logic Layer that has a Repository, and if the method is missing from the Business Logic Layer, just call the Repository and pass through its result.... | I believe you need to return a new MetaObject with the returned value as a constant expression.
That's certainly what happens on [this CodeProject page](http://www.codeproject.com/KB/cs/moemeka.aspx?display=Print). Worth a try :) |
283,156 | <p>So my program needs to go through a plain text file line by line essentially:</p>
<pre><code>Read line 1:
Do commands
loop
Read line2:
Do Commands
loop
</code></pre>
<p>etc until its done with the entire file does anyone know any good coding examples for this, all the tutorials seem to show open and writing/readin... | [
{
"answer_id": 283162,
"author": "Sani Singh Huttunen",
"author_id": 26742,
"author_profile": "https://Stackoverflow.com/users/26742",
"pm_score": 0,
"selected": false,
"text": "<p>You could do it like this:</p>\n\n<pre><code>Using f As System.IO.FileStream = System.IO.File.OpenRead(\"so... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283156",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | So my program needs to go through a plain text file line by line essentially:
```
Read line 1:
Do commands
loop
Read line2:
Do Commands
loop
```
etc until its done with the entire file does anyone know any good coding examples for this, all the tutorials seem to show open and writing/reading textfiles but nothing on... | ```
For Each line As String In System.IO.File.ReadAllLines("file.txt")
' Do Something'
Next
``` |
283,165 | <p>Are there any known hash algorithms which input a vector of int's and output a single int that work similarly to an inner product?</p>
<p>In other words, I am thinking about a hash algorithm that might look like this in C++:</p>
<pre><code>// For simplicity, I'm not worrying about overflow, and assuming |v| < 7... | [
{
"answer_id": 283246,
"author": "Rob",
"author_id": 34224,
"author_profile": "https://Stackoverflow.com/users/34224",
"pm_score": 2,
"selected": false,
"text": "<p>Depending on the size of the constants, I'd have to say the degree of chaos in the input vector will have an impact on the ... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283165",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3561/"
] | Are there any known hash algorithms which input a vector of int's and output a single int that work similarly to an inner product?
In other words, I am thinking about a hash algorithm that might look like this in C++:
```
// For simplicity, I'm not worrying about overflow, and assuming |v| < 7.
int HashVector(const v... | I did some (unpublished, practical) experiments with testing a variety of string hash algorithms. (It turns out that Java's default hash function for Strings sucks.)
The easy experiment is to hash the English dictionary and compare how many collisions you have on algorithm A vs algorithm B.
You can construct a simil... |
283,169 | <p>Suppose I have some code:</p>
<pre><code>let listB = [ 1; 2; 3 ]
</code></pre>
<p>Using Lisp notation, how do I do a <code>car</code> and <code>cadr</code> against this list? I know cons is <code>::</code>.</p>
<p>Or in Scheme, <code>first</code> and <code>rest</code>?</p>
| [
{
"answer_id": 283184,
"author": "Christian C. Salvadó",
"author_id": 5445,
"author_profile": "https://Stackoverflow.com/users/5445",
"pm_score": 4,
"selected": true,
"text": "<p><em>List.head</em>: Returns the first element of a nonempty list <em>(The head of the list)</em>.</p>\n\n<p><... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283169",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26227/"
] | Suppose I have some code:
```
let listB = [ 1; 2; 3 ]
```
Using Lisp notation, how do I do a `car` and `cadr` against this list? I know cons is `::`.
Or in Scheme, `first` and `rest`? | *List.head*: Returns the first element of a nonempty list *(The head of the list)*.
*List.tail*: Returns all the elements of a
nonempty list except the first *(The tail or rest of the list)*.
Example (*using F# Interactive Console*):
```
> let sample = [1;2;3;4];;
val sample : int list
> List.head sample;;
val it... |
283,193 | <p>I have a list of email address which I want to distribute evenly by domain.</p>
<p>For example:</p>
<p>let the list be, </p>
<pre><code>a@a.com
b@a.com
c@a.com
a@b.com
b@b.com
c@c.com
</code></pre>
<p>The output should be </p>
<pre><code>a@a.com
a@b.com
c@c.com
b@a.com
b@b.com
c@a.com
</code></pre>
<p>The sour... | [
{
"answer_id": 283200,
"author": "Xenph Yan",
"author_id": 264,
"author_profile": "https://Stackoverflow.com/users/264",
"pm_score": 0,
"selected": false,
"text": "<p>My starting attempt would be a hash map of linked lists, so that once all the domain collisions were grouped, you could i... | 2008/11/12 | [
"https://Stackoverflow.com/questions/283193",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25453/"
] | I have a list of email address which I want to distribute evenly by domain.
For example:
let the list be,
```
a@a.com
b@a.com
c@a.com
a@b.com
b@b.com
c@c.com
```
The output should be
```
a@a.com
a@b.com
c@c.com
b@a.com
b@b.com
c@a.com
```
The source list is not sorted by domain as in example, but can be sorte... | Here is my solution to this problem. Given an input like
```
[["A", 13], ["B", 5], ["C", 3], ["D", 1]]
```
The output is
```
AABABAACABAACABAACABAD
```
Ruby source of the program is:
```
require "pp"
def shuffle (total, num)
ret_arr = Array.new
intervel = total/num.to_f
0.upto(num-1) do |i|
val = i... |