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 |
|---|---|---|---|---|---|---|
530,281 | <pre><code>class Program
{
static void Main(string[] args)
{
String value = "Two";
Type enumType = typeof(Numbers);
Numbers number = (Numbers)Enum.Parse(enumType, value);
Console.WriteLine(Enum.Parse(enumType, value));
}
public enum Numbers : int
{
One,
... | [
{
"answer_id": 530299,
"author": "Eclipse",
"author_id": 8701,
"author_profile": "https://Stackoverflow.com/users/8701",
"pm_score": 4,
"selected": true,
"text": "<p>I suspect that both <code>FirstValue</code> and <code>Two</code> have an internal value of 1, so the system doesn't know w... | 2009/02/09 | [
"https://Stackoverflow.com/questions/530281",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/64353/"
] | ```
class Program
{
static void Main(string[] args)
{
String value = "Two";
Type enumType = typeof(Numbers);
Numbers number = (Numbers)Enum.Parse(enumType, value);
Console.WriteLine(Enum.Parse(enumType, value));
}
public enum Numbers : int
{
One,
Two,... | I suspect that both `FirstValue` and `Two` have an internal value of 1, so the system doesn't know which string to output.
```
public enum Numbers : int
{
One, // defaults to 0
Two, // defaults to 1
Three, // defaults to 2
Four, // defaults to 3
FirstValue = 1 // forced to 1
}
```
There is a uniq... |
530,286 | <p>I'm trying to run a WCF ServiceHost as an NT Service on a Windows 2007 SP1 Server. The ServiceHost is reponsible for hosting a single service endpoint: a basicHttpBinding with the following address:</p>
<pre><code>http://localhost:5555/ToBlah
</code></pre>
<p>When I run this ServiceHost on my local machine (Wind... | [
{
"answer_id": 530308,
"author": "driAn",
"author_id": 50430,
"author_profile": "https://Stackoverflow.com/users/50430",
"pm_score": 1,
"selected": false,
"text": "<p>What <strong>identity</strong> is configured for the NT service? To isolate the problem, try using a local-admin account ... | 2009/02/09 | [
"https://Stackoverflow.com/questions/530286",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/60096/"
] | I'm trying to run a WCF ServiceHost as an NT Service on a Windows 2007 SP1 Server. The ServiceHost is reponsible for hosting a single service endpoint: a basicHttpBinding with the following address:
```
http://localhost:5555/ToBlah
```
When I run this ServiceHost on my local machine (Windows XP), it works fine - whe... | It seems to me that either a firewall on the server or another configuration setting is blocking the port.
If not, then your service may be experiencing an error during the creation of the ServiceHost object instance or during the creation of the service endpoint, and the error is for some reason not trapped(?). You ... |
530,287 | <p>I am interested in writing utf-8 encoded strings to a file.</p>
<p>I did this with low level functions open() and write().
In the first place I set the locale to a utf-8 aware character set with
<code>setlocale("LC_ALL", "de_DE.utf8")</code>.
But the resulting file does not contain utf-8 characters, only iso8859 en... | [
{
"answer_id": 530312,
"author": "Oliver N.",
"author_id": 39122,
"author_profile": "https://Stackoverflow.com/users/39122",
"pm_score": 0,
"selected": false,
"text": "<p>Can you open up the file in a hex editor and verify, with a simple input example, that the written bytes are not the ... | 2009/02/09 | [
"https://Stackoverflow.com/questions/530287",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49628/"
] | I am interested in writing utf-8 encoded strings to a file.
I did this with low level functions open() and write().
In the first place I set the locale to a utf-8 aware character set with
`setlocale("LC_ALL", "de_DE.utf8")`.
But the resulting file does not contain utf-8 characters, only iso8859 encoded umlauts. What a... | Changing the locale won't change the actual data written to the file using write(). You have to actually *produce* UTF-8 characters to write them to a file. For that purpose you can use libraries as [ICU](http://www.icu-project.org/).
*Edit after your edit of the question*: UTF-8 characters are only different from ISO... |
530,307 | <p>I would like to know the best way to delete records from a live database and refresh the page instantly. At the moment I am using ajax, with the following javascript method:</p>
<pre><code>function deleterec(layer, pk) {
url = "get_records.php?cmd=deleterec&pk="+pk+"&sid="+Math.random();
update('Layer... | [
{
"answer_id": 530370,
"author": "theraccoonbear",
"author_id": 7210,
"author_profile": "https://Stackoverflow.com/users/7210",
"pm_score": 4,
"selected": true,
"text": "<p>Without digging too much into your code specifics, I don't know of any way to update/delete from the server side DB... | 2009/02/09 | [
"https://Stackoverflow.com/questions/530307",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1246613/"
] | I would like to know the best way to delete records from a live database and refresh the page instantly. At the moment I am using ajax, with the following javascript method:
```
function deleterec(layer, pk) {
url = "get_records.php?cmd=deleterec&pk="+pk+"&sid="+Math.random();
update('Layer2', url);
}
```
if c... | Without digging too much into your code specifics, I don't know of any way to update/delete from the server side DB without doing a round trip (either AJAX or a page navigation). I would however recommend using a JavaScript framework (like [jQuery](http://jquery.com/), or something else) to handle the AJAX and DOM mani... |
530,320 | <p>Is there a way to provide access to users in my database to execute <strong><code>msdb.dbo.sp_send_dbmail</code></strong> without needing to add them to the MSDB database and the DatabaseMailUserRole?</p>
<p>I've tried this:</p>
<pre><code>ALTER PROCEDURE [dbo].[_TestSendMail]
(
@To NVARCHAR(1000),
@Subject N... | [
{
"answer_id": 536028,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>One possible solution is to encapsulate the mailing as a stored procedure e.g. mail_error_as_MAILER (wich you will later ca... | 2009/02/09 | [
"https://Stackoverflow.com/questions/530320",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6624/"
] | Is there a way to provide access to users in my database to execute **`msdb.dbo.sp_send_dbmail`** without needing to add them to the MSDB database and the DatabaseMailUserRole?
I've tried this:
```
ALTER PROCEDURE [dbo].[_TestSendMail]
(
@To NVARCHAR(1000),
@Subject NVARCHAR(100),
@Body NVARCHAR(MAX)
)
WITH EXE... | Your approach is OK, but your wrapper proc must be in the msdb database.
Then, you execute "EXEC msdb.dbo.\_TestSendMail"
This still leave the issue of permissions on dbo.\_TestSendMail in msdb.
But public/EXECUTE will be enough: it only exposes the 3 parameters you need.
If in doubt, add WITH ENCRYPTION. This is goo... |
530,329 | <p>I am raising exceptions in two different places in my Python code:</p>
<pre><code>holeCards = input("Select a hand to play: ")
try:
if len(holeCards) != 4:
raise ValueError(holeCards + ' does not represent a valid hand.')
</code></pre>
<p>AND <strong>(edited to correct raising code)</strong></p>
<pre>... | [
{
"answer_id": 530358,
"author": "James Orr",
"author_id": 41457,
"author_profile": "https://Stackoverflow.com/users/41457",
"pm_score": 4,
"selected": true,
"text": "<p>\"card\" probably represents a tuple containing the string \"Kr.\" When you use the + operator on a tuple, you create... | 2009/02/09 | [
"https://Stackoverflow.com/questions/530329",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5287/"
] | I am raising exceptions in two different places in my Python code:
```
holeCards = input("Select a hand to play: ")
try:
if len(holeCards) != 4:
raise ValueError(holeCards + ' does not represent a valid hand.')
```
AND **(edited to correct raising code)**
```
def __init__(self, card):
[...]
if self... | "card" probably represents a tuple containing the string "Kr." When you use the + operator on a tuple, you create a new tuple with the extra item added.
edit: nope, I'm wrong. Adding a string to a tuple:
```
>> ("Kr",) + "foo"
```
generates an error:
```
TypeError: can only concatenate tuple (not "str") to tuple
... |
530,342 | <p>I transfered a workking WCF service from my development environment to the QA environment, including the certificates (Root Authority, Root Auth revocation list, Service certificate - including its PK).</p>
<p>Afterward I located the private key usihg 'FindPrivateKey' and gave all the relavent accounts full permiss... | [
{
"answer_id": 1411669,
"author": "jp2code",
"author_id": 153923,
"author_profile": "https://Stackoverflow.com/users/153923",
"pm_score": 1,
"selected": false,
"text": "<p>Here's a tutorial explaining how to create a certificate that is supposed to remedy this problem:</p>\n\n<p><a href=... | 2009/02/09 | [
"https://Stackoverflow.com/questions/530342",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I transfered a workking WCF service from my development environment to the QA environment, including the certificates (Root Authority, Root Auth revocation list, Service certificate - including its PK).
Afterward I located the private key usihg 'FindPrivateKey' and gave all the relavent accounts full permissions to ac... | I ran into this same error in a simple WFC service written with VS2010 SP1 on Win 7. The fix that I found was to add
```
<dns value="localhost" />
```
to the <identity> section of app.config
Source: <http://social.msdn.microsoft.com/Forums/en-AU/wcf/thread/439539ef-e8d7-4e7d-b36e-b80acd401606> |
530,356 | <p>I'm trying to code a simple, sufficiently accurate filter for validating a piece of hardware in an RTL simulation. We're simulating the randomness inherent in a chip's flip-flops, by randomly initializing all the flip-flops in the design to either 0 or 1. This corresponds to the chip's flip-flops getting some rand... | [
{
"answer_id": 530376,
"author": "Lance Roberts",
"author_id": 13295,
"author_profile": "https://Stackoverflow.com/users/13295",
"pm_score": 2,
"selected": false,
"text": "<p>OK, here's what I found:</p>\n<p>P = 1 - Q(X)</p>\n<p>where</p>\n<p>Q(X) = [1 - 1/2(Z)]/[(X + 1 - XZ) x 1/2 x Z^(... | 2009/02/09 | [
"https://Stackoverflow.com/questions/530356",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20712/"
] | I'm trying to code a simple, sufficiently accurate filter for validating a piece of hardware in an RTL simulation. We're simulating the randomness inherent in a chip's flip-flops, by randomly initializing all the flip-flops in the design to either 0 or 1. This corresponds to the chip's flip-flops getting some random va... | If you want a quick test to see if a sequence of bits is random based on the longest streak of 1's, you can use the fact that the expected longest streak of 1's in N bits is Θ(log(N)).
Furthermore, the probability that the longest streak exceeds r\*log₂(N) bits is at most 1/N^(r-1), and similarly the probability that ... |
530,381 | <p>I would like to provide a WHERE condition on an inner query by specifying innertable.id = outertable.id. However, MySQL (5.0.45) reports "Unknown column 'outertable.id' in 'where clause'". Is this type of query possible?</p>
<p>The inner query is pivoting rows to columns using a GROUP BY. This could be entirely be ... | [
{
"answer_id": 530444,
"author": "AJM",
"author_id": 64226,
"author_profile": "https://Stackoverflow.com/users/64226",
"pm_score": 0,
"selected": false,
"text": "<p>My suggestion was going to be what you ruled out on the grounds of efficiency. E.g. leaving out the where clause and using ... | 2009/02/09 | [
"https://Stackoverflow.com/questions/530381",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/64358/"
] | I would like to provide a WHERE condition on an inner query by specifying innertable.id = outertable.id. However, MySQL (5.0.45) reports "Unknown column 'outertable.id' in 'where clause'". Is this type of query possible?
The inner query is pivoting rows to columns using a GROUP BY. This could be entirely be performed ... | The answer to your question is no, it is not possible to reference correlation names as you are doing. The derived table is produced by your inner query before the outer query starts evaluating joins. So the correlation names like `t`, `tp`, and `u` are not available to the inner query.
To solve this, I'd recommend us... |
530,385 | <p>The project I'm currently working on uses Enterprise Libraries V3.1 framework for logging.</p>
<p>I need to take the log file that's generated and archive it off at specific points. The built in Trace Listeners seem to keep the file open in-between logging events. I've set up a custom Trace Listener which will appe... | [
{
"answer_id": 1402854,
"author": "Don Vince",
"author_id": 6023,
"author_profile": "https://Stackoverflow.com/users/6023",
"pm_score": 1,
"selected": false,
"text": "<p>I suspect that perhaps the Enterprise Application Blocks although (probably) wonderful, seem unnecessarily complicated... | 2009/02/09 | [
"https://Stackoverflow.com/questions/530385",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6023/"
] | The project I'm currently working on uses Enterprise Libraries V3.1 framework for logging.
I need to take the log file that's generated and archive it off at specific points. The built in Trace Listeners seem to keep the file open in-between logging events. I've set up a custom Trace Listener which will append to a fi... | The CustomTraceListener derives from TraceListener, this has a StringDictionary called Attributes.
This will contain all the attributes in the configuration line for your TraceListener and can be gotten out by name, eg.
```
string logFileName= Attributes["fileName"]
``` |
530,425 | <p>I'm working on a deadlock detection algorithm and I'm only given kernel level libraries, i.e. <code>#include <linux/somelibrary></code> and nothing else. Are there kernel-level facilities that will allow me to get the pid of the current process similar to <a href="http://www.kernel.org/doc/man-pages/online/pag... | [
{
"answer_id": 530472,
"author": "MarkR",
"author_id": 13724,
"author_profile": "https://Stackoverflow.com/users/13724",
"pm_score": 2,
"selected": false,
"text": "<p>This question makes little sense.</p>\n\n<p>Are you writing kernel-based code? In which case you can get the pid of the c... | 2009/02/09 | [
"https://Stackoverflow.com/questions/530425",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm working on a deadlock detection algorithm and I'm only given kernel level libraries, i.e. `#include <linux/somelibrary>` and nothing else. Are there kernel-level facilities that will allow me to get the pid of the current process similar to [`getpid()`](http://www.kernel.org/doc/man-pages/online/pages/man2/getpid.2... | I did some quick research and I found the answer. Thanks so much for your direction. The quick code I used was:
```
printf("My current process id/pid is %d\n", current->pid);
```
Thanks again! |
530,426 | <p>I have a large database of users (~200,000) that I'm transferring from a ASP.NET application to a Ruby on Rails application. I don't really want to ask every user to reset their password and so I'm trying to re-implement the C# password hashing function in Ruby.</p>
<p>The old function is this:</p>
<pre><code>pub... | [
{
"answer_id": 530467,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 1,
"selected": false,
"text": "<p>You need to unencode the salt to convert it back to it's byte representation and then concatenate that with the pass... | 2009/02/09 | [
"https://Stackoverflow.com/questions/530426",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2843/"
] | I have a large database of users (~200,000) that I'm transferring from a ASP.NET application to a Ruby on Rails application. I don't really want to ask every user to reset their password and so I'm trying to re-implement the C# password hashing function in Ruby.
The old function is this:
```
public string EncodePassw... | Just a quick update, a colleague of mine has solved this:
```
require "base64"
require "digest"
require "jcode"
def encode_password(password, salt)
bytes = ""
password.each_char { |c| bytes += c + "\x00" }
salty = Base64.decode64(salt)
concat = salty+bytes
sha1 = Digest::SHA1.digest(concat)
encoded = Base64.enc... |
530,441 | <p>How would I go about using a negative lookbehind(or any other method) regular expression to ignore strings that contains a specific substring?</p>
<p>I've read two previous stackoverflow questions:<br>
<a href="https://stackoverflow.com/questions/367862/java-regexp-for-file-filtering">java-regexp-for-file-filtering... | [
{
"answer_id": 530468,
"author": "Zach Scrivena",
"author_id": 20029,
"author_profile": "https://Stackoverflow.com/users/20029",
"pm_score": 3,
"selected": true,
"text": "<p>Could you just match any path that doesn't end with a <code>/</code></p>\n\n<pre><code>String inRegEx = \"^.* \\\"... | 2009/02/09 | [
"https://Stackoverflow.com/questions/530441",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/828/"
] | How would I go about using a negative lookbehind(or any other method) regular expression to ignore strings that contains a specific substring?
I've read two previous stackoverflow questions:
[java-regexp-for-file-filtering](https://stackoverflow.com/questions/367862/java-regexp-for-file-filtering)
[regex-to-matc... | Could you just match any path that doesn't end with a `/`
```
String inRegEx = "^.* \"GET (.*[^/]) HTTP/.*$";
```
---
This can also be done using *negative lookbehind*
```
String inRegEx = "^.* \"GET (.+)(?<!/) HTTP/.*$";
```
Here, `(?<!/)` says "the *preceding* sequence must *not* match `/`". |
530,450 | <p>I'm trying to accomplish the following in ASP.Net:</p>
<ol>
<li>Create a WPF Canvas control</li>
<li>Spin up a WPF Image control and a BitmapImage object</li>
<li>Set the BitmapImage source to a Uri for an image</li>
<li>Add the image to the canvas</li>
<li>When the image is downloaded render the canvas to a new bi... | [
{
"answer_id": 531900,
"author": "HakonB",
"author_id": 45323,
"author_profile": "https://Stackoverflow.com/users/45323",
"pm_score": 1,
"selected": false,
"text": "<p>Did you verify that adding the STAThread attribute to the DownloadAndSave method actually makes it run in a STA thread? ... | 2009/02/09 | [
"https://Stackoverflow.com/questions/530450",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5152/"
] | I'm trying to accomplish the following in ASP.Net:
1. Create a WPF Canvas control
2. Spin up a WPF Image control and a BitmapImage object
3. Set the BitmapImage source to a Uri for an image
4. Add the image to the canvas
5. When the image is downloaded render the canvas to a new bitmap
My code works correctly in WPF ... | I think the DownloadCompleted event is never raised because BitmapImage loads asynchronously when you use the UriSource property which allows the background thread (DownloadAndSave method) to complete before the image is loaded.
What worked for me recently in an almost identical situation was to download the bitmap re... |
530,461 | <p>The source tree that I work on has files indented with different tab values, (not to mention spaces) and the best I can do is to set emacs to use the style found in the region of code I am modifying. Instead of doing M-x set-variable tab-width to 4 or 8, a key binding to toggle the tab-width among these two value wo... | [
{
"answer_id": 530566,
"author": "Sean Bright",
"author_id": 21926,
"author_profile": "https://Stackoverflow.com/users/21926",
"pm_score": 0,
"selected": false,
"text": "<p>Throw this in your <code>.emacs</code> or <code>.emacs.d/init.el</code> file:</p>\n\n<pre><code>(defun toggle-space... | 2009/02/09 | [
"https://Stackoverflow.com/questions/530461",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17880/"
] | The source tree that I work on has files indented with different tab values, (not to mention spaces) and the best I can do is to set emacs to use the style found in the region of code I am modifying. Instead of doing M-x set-variable tab-width to 4 or 8, a key binding to toggle the tab-width among these two value would... | ```
;; Obviously substitute your preferred key for <f8>
(global-set-key (kbd "<f8>") 'tf-toggle-tab-width-setting) ; ' "fix" highlighting
(defun tf-toggle-tab-width-setting ()
"Toggle setting tab widths between 4 and 8"
(interactive)
(setq tab-width (if (= tab-width 8) 4 8))
(redraw-display))
```
*Ed... |
530,466 | <p>I am writing out a table using just the template system in Django, and it is not showing the border around empty table cells.</p>
<p>No problem I thought - I've solved this problem before. I put &nbsp in any cell that was to be left empty. Django kindly converted the ampersand to &amp so that I have &... | [
{
"answer_id": 530485,
"author": "benlumley",
"author_id": 39161,
"author_profile": "https://Stackoverflow.com/users/39161",
"pm_score": 1,
"selected": false,
"text": "<p>There is the empty cells CSS property.</p>\n\n<p><a href=\"http://www.w3.org/TR/CSS21/tables.html#empty-cells\" rel=\... | 2009/02/09 | [
"https://Stackoverflow.com/questions/530466",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30441/"
] | I am writing out a table using just the template system in Django, and it is not showing the border around empty table cells.
No problem I thought - I've solved this problem before. I put   in any cell that was to be left empty. Django kindly converted the ampersand to & so that I have &nbsp in the empty cel... | This is a known CSS/HTML 'problem.' You want to use Django's "[default](http://docs.djangoproject.com/en/dev/ref/templates/builtins/?from=olddocs#default)" filter.
```
{{value|default:"&nbsp;"}}
```
(I'll be damned if I could get that to come out right. In SO, how do you write "nbsp;" without the & in front caus... |
530,482 | <p>In C# 3.5 using a ComboBox to display the results of a LinQ Query. How do I set the SelectedItem property of the ComboBox when the LinQ query is returning an anonymous type?</p>
<p>I set the DataSource of the ComboBox along these lines:</p>
<pre><code>comboBox1.DataSource = from p in db.products
... | [
{
"answer_id": 530490,
"author": "JaredPar",
"author_id": 23283,
"author_profile": "https://Stackoverflow.com/users/23283",
"pm_score": 0,
"selected": false,
"text": "<p>This should do the trick</p>\n\n<pre><code>var list = (from p in db.products\n select new {\n ... | 2009/02/09 | [
"https://Stackoverflow.com/questions/530482",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8273/"
] | In C# 3.5 using a ComboBox to display the results of a LinQ Query. How do I set the SelectedItem property of the ComboBox when the LinQ query is returning an anonymous type?
I set the DataSource of the ComboBox along these lines:
```
comboBox1.DataSource = from p in db.products
select p;
comboB... | How about converting it to a list, then choosing the correct one from it. Since SelectedItem doesn't seem to work, you may want to try setting SelectedValue.
```
var productList = (from p in db.products
select new {
ProductId = p.ProductID,
Name = p.Name
... |
530,486 | <p>I Have a Gridview . I wanted to display data from Webservice via Ajax calls in ASP.net Please ,let me know the solution for this. Thanks in Advance.</p>
| [
{
"answer_id": 530490,
"author": "JaredPar",
"author_id": 23283,
"author_profile": "https://Stackoverflow.com/users/23283",
"pm_score": 0,
"selected": false,
"text": "<p>This should do the trick</p>\n\n<pre><code>var list = (from p in db.products\n select new {\n ... | 2009/02/09 | [
"https://Stackoverflow.com/questions/530486",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I Have a Gridview . I wanted to display data from Webservice via Ajax calls in ASP.net Please ,let me know the solution for this. Thanks in Advance. | How about converting it to a list, then choosing the correct one from it. Since SelectedItem doesn't seem to work, you may want to try setting SelectedValue.
```
var productList = (from p in db.products
select new {
ProductId = p.ProductID,
Name = p.Name
... |
530,493 | <p>I like the look and feel of the WordPress editor (version 2.7), and I would like to use it in another web application that is written in ASP.NET. I've used TinyMCE before, and I've even extended it in the past. However, I can't seem to get the Wordpress configuration to work!</p>
<p>I've downloaded the entire Wor... | [
{
"answer_id": 530490,
"author": "JaredPar",
"author_id": 23283,
"author_profile": "https://Stackoverflow.com/users/23283",
"pm_score": 0,
"selected": false,
"text": "<p>This should do the trick</p>\n\n<pre><code>var list = (from p in db.products\n select new {\n ... | 2009/02/09 | [
"https://Stackoverflow.com/questions/530493",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/54420/"
] | I like the look and feel of the WordPress editor (version 2.7), and I would like to use it in another web application that is written in ASP.NET. I've used TinyMCE before, and I've even extended it in the past. However, I can't seem to get the Wordpress configuration to work!
I've downloaded the entire WordPress packa... | How about converting it to a list, then choosing the correct one from it. Since SelectedItem doesn't seem to work, you may want to try setting SelectedValue.
```
var productList = (from p in db.products
select new {
ProductId = p.ProductID,
Name = p.Name
... |
530,500 | <p>I am based in the UK and have two webservers, one German based (1&1) and the other is UK based (Easyspace).</p>
<p>I recently signed up to the UK easyspace server because it was about the same price I paid for my 1&1 server but also I wanted to see if my sites hosted on a UK server gave better results in te... | [
{
"answer_id": 530514,
"author": "Aram Verstegen",
"author_id": 64234,
"author_profile": "https://Stackoverflow.com/users/64234",
"pm_score": 2,
"selected": false,
"text": "<p>I have never heard of common search engines ranking sites by their response time as it is highly variable due to... | 2009/02/09 | [
"https://Stackoverflow.com/questions/530500",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51604/"
] | I am based in the UK and have two webservers, one German based (1&1) and the other is UK based (Easyspace).
I recently signed up to the UK easyspace server because it was about the same price I paid for my 1&1 server but also I wanted to see if my sites hosted on a UK server gave better results in terms of UK based tr... | My main concern is losing UK based customers if the server is located outside the UK but it appears from the comments that this is probably not the case.
However, my UK server is based in Scotland, my other server is based in Germany and is actually closer to London than Scotland?
Just to compare the speed between Sc... |
530,504 | <p>I was looking through some code from the <a href="http://www.libsdl.org" rel="noreferrer">SDL</a> library and came across a function declared like this:</p>
<pre><code>LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
</code></pre>
<p>Now, I'm a Delphi coder. No hablo C muy bien, senor. ... | [
{
"answer_id": 530509,
"author": "BobbyShaftoe",
"author_id": 38426,
"author_profile": "https://Stackoverflow.com/users/38426",
"pm_score": 5,
"selected": true,
"text": "<p>The \"CALLBACK\" is a calling convention. There are other kinds of calling conventions. CALLBACK is the same as __... | 2009/02/09 | [
"https://Stackoverflow.com/questions/530504",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32914/"
] | I was looking through some code from the [SDL](http://www.libsdl.org) library and came across a function declared like this:
```
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
```
Now, I'm a Delphi coder. No hablo C muy bien, senor. But I remember enough syntax from my college courses to... | The "CALLBACK" is a calling convention. There are other kinds of calling conventions. CALLBACK is the same as \_\_stdcall.
<http://www.codeguru.com/cpp/cpp/cpp_mfc/callbacks/article.php/c10557>
Some more information at Raymond Chen's blog:
<http://blogs.msdn.com/oldnewthing/archive/2004/01/08/48616.aspx> |
530,508 | <p>I need to display a list of records from a database table ordered by some numeric column. The table looks like this:</p>
<pre><code>CREATE TABLE items (
position int NOT NULL,
name varchar(100) NOT NULL,
);
INSERT INTO items (position, name) VALUE
(1, 'first'),
(5, 'second'),
(8, 'third'),
(9, 'fourth'),
(15, ... | [
{
"answer_id": 530527,
"author": "chaos",
"author_id": 47529,
"author_profile": "https://Stackoverflow.com/users/47529",
"pm_score": 1,
"selected": false,
"text": "<p>ORDER BY (FIELD(position, 1, 5, 8, 9, 15, 20) + parameter) % 7</p>\n\n<p>Edit: To make the peanut gallery happy, the gene... | 2009/02/09 | [
"https://Stackoverflow.com/questions/530508",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I need to display a list of records from a database table ordered by some numeric column. The table looks like this:
```
CREATE TABLE items (
position int NOT NULL,
name varchar(100) NOT NULL,
);
INSERT INTO items (position, name) VALUE
(1, 'first'),
(5, 'second'),
(8, 'third'),
(9, 'fourth'),
(15, 'fifth'),
(20,... | See how this works for you. Uses generic SQL so it should be valid for MySql (untested) as well.
```
DECLARE @user_sort INTEGER
SET @user_sort = 0
SELECT position, name FROM
(
SELECT I1.position, I1.name, COUNT(*) AS rownumber, (SELECT COUNT(*) FROM items) AS maxrows
FROM items I1, items I2
WHERE I2.position <... |
530,513 | <p>Title pretty much says it all.<br>
Given a table like</p>
<pre><code><table>
<tr>
<th>Header 1</td>
<th>Header 2</td>
</tr>
<tr>
<td>Datum 1</td>
<td> Datum 2</td>
</tr>
<tr>
<td>Datum 1</td>... | [
{
"answer_id": 530520,
"author": "Chris KL",
"author_id": 58110,
"author_profile": "https://Stackoverflow.com/users/58110",
"pm_score": 2,
"selected": false,
"text": "<p>Dunno if it's like Dojo CSS3 queries, but you could use the first-child pseudo class, if jQuery supports it:</p>\n\n<p... | 2009/02/09 | [
"https://Stackoverflow.com/questions/530513",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5056/"
] | Title pretty much says it all.
Given a table like
```
<table>
<tr>
<th>Header 1</td>
<th>Header 2</td>
</tr>
<tr>
<td>Datum 1</td>
<td> Datum 2</td>
</tr>
<tr>
<td>Datum 1</td>
<td> Datum 2</td>
</tr>
</table>
```
How to select the row which contains the th headers and no other... | Expression:
```
$(function() {
$("tr:has(th):not(:has(td))").hide();
});
```
or even just:
```
$(function() {
$("tr:not(:has(td))").hide();
});
```
Full example:
```
<html>
<head>
<title>Layout</title>
</head>
<body>
<table>
<tr>
<th>Header 1</td>
<th>Header 2</td>
</tr>
<tr>
<td>Datum 1<... |
530,515 | <p>JSON ignores any parameters with null values. So, when I create a string using JsonConverter.ExportToString these properties are missing. Also any integers with null values are replaced with -2147483648</p>
<p>This becomes an issue when I try to deserialize this string (I am writing my own deserializer and not usin... | [
{
"answer_id": 530569,
"author": "Bravax",
"author_id": 13911,
"author_profile": "https://Stackoverflow.com/users/13911",
"pm_score": 0,
"selected": false,
"text": "<p>Could you use an empty string i.e. \"\" instead of null, and use a placeholder number e.g. -2147483648 to indicate a nul... | 2009/02/09 | [
"https://Stackoverflow.com/questions/530515",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | JSON ignores any parameters with null values. So, when I create a string using JsonConverter.ExportToString these properties are missing. Also any integers with null values are replaced with -2147483648
This becomes an issue when I try to deserialize this string (I am writing my own deserializer and not using Json.Imp... | I am not sure that I understand the question. JSON is just a subset of javascript and properties with null values can be represented like so:
```
{"property1": 1, "property2": null}
```
In this case, `property1` is a numeric and had value 1, while `property2` has value `null`. I'm not sure from which library the Jso... |
530,522 | <p>Suppose I have an object representing a person, with getter and setter methods for the person's email address. The setter method definition might look something like this:</p>
<pre><code>setEmailAddress(String emailAddress)
{
this.emailAddress = emailAddress;
}
</code></pre>
<p>Calling <code>person.set... | [
{
"answer_id": 530533,
"author": "Erik Forbes",
"author_id": 16942,
"author_profile": "https://Stackoverflow.com/users/16942",
"pm_score": 2,
"selected": false,
"text": "<p>This is a pretty common problem falling under the title '<a href=\"https://stackoverflow.com/questions/tagged/valid... | 2009/02/09 | [
"https://Stackoverflow.com/questions/530522",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40356/"
] | Suppose I have an object representing a person, with getter and setter methods for the person's email address. The setter method definition might look something like this:
```
setEmailAddress(String emailAddress)
{
this.emailAddress = emailAddress;
}
```
Calling `person.setEmailAddress(0)`, then, would g... | **Welcome to the world of programming!**
I don't think your question is a symptom of an error on your part. Rather it is a **basic problem** which appears in many guises throughout the programming world. Strings that have some structure and *meaning* are passed around between different subsystems of an application and... |
530,526 | <p>I can't seem to figure out how to access POST data using WSGI. I tried the example on the wsgi.org website and it didn't work. I'm using Python 3.0 right now. Please don't recommend a WSGI framework as that is not what I'm looking for. </p>
<p>I would like to figure out how to get it into a fieldstorage object.</p>... | [
{
"answer_id": 530559,
"author": "Ali Afshar",
"author_id": 28380,
"author_profile": "https://Stackoverflow.com/users/28380",
"pm_score": -1,
"selected": false,
"text": "<p>I would suggest you look at how some frameworks do it for an example. (I am not recommending any single one, just u... | 2009/02/09 | [
"https://Stackoverflow.com/questions/530526",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49701/"
] | I can't seem to figure out how to access POST data using WSGI. I tried the example on the wsgi.org website and it didn't work. I'm using Python 3.0 right now. Please don't recommend a WSGI framework as that is not what I'm looking for.
I would like to figure out how to get it into a fieldstorage object. | Assuming you are trying to get just the POST data into a FieldStorage object:
```
# env is the environment handed to you by the WSGI server.
# I am removing the query string from the env before passing it to the
# FieldStorage so we only have POST data in there.
post_env = env.copy()
post_env['QUERY_STRING'] = ''
post... |
530,530 | <p>The purpose of my question is to strengthen my knowledge base with Python and get a better picture of it, which includes knowing its faults and surprises. To keep things specific, I'm only interested in the CPython interpreter.</p>
<p>I'm looking for something similar to what learned from my <a href="https://stack... | [
{
"answer_id": 530550,
"author": "David",
"author_id": 9908,
"author_profile": "https://Stackoverflow.com/users/9908",
"pm_score": 3,
"selected": false,
"text": "<p>The only gotcha/surprise I've dealt with is with CPython's GIL. If for whatever reason you expect python threads in CPytho... | 2009/02/09 | [
"https://Stackoverflow.com/questions/530530",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9908/"
] | The purpose of my question is to strengthen my knowledge base with Python and get a better picture of it, which includes knowing its faults and surprises. To keep things specific, I'm only interested in the CPython interpreter.
I'm looking for something similar to what learned from my [PHP landmines](https://stackover... | **Expressions in default arguments are calculated when the function is defined, *not* when it’s called.**
**Example:** consider defaulting an argument to the current time:
```
>>>import time
>>> def report(when=time.time()):
... print when
...
>>> report()
1210294387.19
>>> time.sleep(5)
>>> report()
1210294387.... |
530,539 | <p>In a dictionary like this:</p>
<pre><code>Dictionary<string, string> openWith = new Dictionary<string, string>();
openWith.Add("txt", "notepad.exe");
openWith.Add("bmp", "paint.exe");
openWith.Add("dib", "paint.exe");
openWith.Add("rtf", "wordpad.exe");
Console.WriteLine("For key = \"rtf\", value = {0... | [
{
"answer_id": 530540,
"author": "Daniel LeCheminant",
"author_id": 62055,
"author_profile": "https://Stackoverflow.com/users/62055",
"pm_score": 9,
"selected": true,
"text": "<p>You are printing a formatted string. The {0} means to insert the first parameter following the format string... | 2009/02/09 | [
"https://Stackoverflow.com/questions/530539",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/62096/"
] | In a dictionary like this:
```
Dictionary<string, string> openWith = new Dictionary<string, string>();
openWith.Add("txt", "notepad.exe");
openWith.Add("bmp", "paint.exe");
openWith.Add("dib", "paint.exe");
openWith.Add("rtf", "wordpad.exe");
Console.WriteLine("For key = \"rtf\", value = {0}.", openWith["rtf"]);
``... | You are printing a formatted string. The {0} means to insert the first parameter following the format string; in this case the value associated with the key "rtf".
For String.Format, which is similar, if you had something like
```
// Format string {0} {1}
String.Format("This {0... |
530,546 | <p>Is it possible to write a single Python regular expression that can be applied to a multi-line string and change all occurrences of "foo" to "bar", but only on lines beginning with "#"?</p>
<p>I was able to get this working in Perl, using Perl's \G regular expression sigil, which matches the end of the previous mat... | [
{
"answer_id": 530552,
"author": "Harley Holcombe",
"author_id": 1057,
"author_profile": "https://Stackoverflow.com/users/1057",
"pm_score": 2,
"selected": false,
"text": "<pre><code>lines = mystring.split('\\n')\nfor line in lines:\n if line.startswith('#'):\n line = line.repl... | 2009/02/09 | [
"https://Stackoverflow.com/questions/530546",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/91385/"
] | Is it possible to write a single Python regular expression that can be applied to a multi-line string and change all occurrences of "foo" to "bar", but only on lines beginning with "#"?
I was able to get this working in Perl, using Perl's \G regular expression sigil, which matches the end of the previous match. Howeve... | ```
lines = mystring.split('\n')
for line in lines:
if line.startswith('#'):
line = line.replace('foo', 'bar')
```
No need for a regex. |
530,560 | <p>Is it possible to make Dojo (javascript) widgets validate for XHTML?</p>
<p>If so, how?</p>
<p>Can it be something as simple as using CDATA?</p>
| [
{
"answer_id": 530552,
"author": "Harley Holcombe",
"author_id": 1057,
"author_profile": "https://Stackoverflow.com/users/1057",
"pm_score": 2,
"selected": false,
"text": "<pre><code>lines = mystring.split('\\n')\nfor line in lines:\n if line.startswith('#'):\n line = line.repl... | 2009/02/09 | [
"https://Stackoverflow.com/questions/530560",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Is it possible to make Dojo (javascript) widgets validate for XHTML?
If so, how?
Can it be something as simple as using CDATA? | ```
lines = mystring.split('\n')
for line in lines:
if line.startswith('#'):
line = line.replace('foo', 'bar')
```
No need for a regex. |
530,565 | <p>I'm very fresh with web dev, but am putting together a simple software catalog with classic ASP. Everything seems fine, except I want to use a value from my SQL database twice on the page. For example, in the page title as well as in the body of the page, however I can only seem to use each value once:</p>
<pre><... | [
{
"answer_id": 530580,
"author": "EnocNRoll - AnandaGopal Pardue",
"author_id": 54289,
"author_profile": "https://Stackoverflow.com/users/54289",
"pm_score": 1,
"selected": false,
"text": "<p>You may need to just extract the value to a local Var and use it twice. I have seen weird stuff... | 2009/02/09 | [
"https://Stackoverflow.com/questions/530565",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/62172/"
] | I'm very fresh with web dev, but am putting together a simple software catalog with classic ASP. Everything seems fine, except I want to use a value from my SQL database twice on the page. For example, in the page title as well as in the body of the page, however I can only seem to use each value once:
```
....
Set nI... | Assign it to a variable; don't just pull the value from the Recordset.
```
Set nItem = Request.QueryString("ID")
strSQL = "SELECT * "_
& "FROM [Packages] "_
& "WHERE id='" & nItem & "';"
Set rstSearch = cnnSearch.Execute(strSQL)
Dim software
software = rstSearch("Software")
' set your other fields as varia... |
530,587 | <p><em>With reference to <a href="https://stackoverflow.com/questions/505040/developing-a-robocode-type-game-with-net-for-a-school-assignment">this programming game</a> I am currently building.</em></p>
<p><strong>Important: Scroll down to see [Edit]</strong></p>
<p>Some of the methods that a user can call in my game... | [
{
"answer_id": 530888,
"author": "colithium",
"author_id": 61332,
"author_profile": "https://Stackoverflow.com/users/61332",
"pm_score": 1,
"selected": false,
"text": "<p>To help with the math:</p>\n\n<p>If you want to move <strong>d</strong> pixel distances in <strong>t</strong> seconds... | 2009/02/09 | [
"https://Stackoverflow.com/questions/530587",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44084/"
] | *With reference to [this programming game](https://stackoverflow.com/questions/505040/developing-a-robocode-type-game-with-net-for-a-school-assignment) I am currently building.*
**Important: Scroll down to see [Edit]**
Some of the methods that a user can call in my game will be methods that will do a Translate Transf... | Solution
--------
Thanks to the help of both [Andy Mikula](https://stackoverflow.com/questions/534424/math-in-wpf-getting-new-x-y-coordinates-after-a-translation/534475#534475) and [Cameron MacFarland](https://stackoverflow.com/questions/534424/math-in-wpf-getting-new-x-y-coordinates-after-a-translation/534628#534628)... |
530,590 | <p>I'm trying to pull out HTTP Headers and an HTTP Response Code from a synchronous HTTP request on the iPhone. I generally don't have any issues doing this with asynchronous requests, although a bit of trouble here. The HTTP Response Headers are null and HTTP Status Code is 0. Web server is configured proper and I can... | [
{
"answer_id": 530844,
"author": "Chris Lundie",
"author_id": 20685,
"author_profile": "https://Stackoverflow.com/users/20685",
"pm_score": 2,
"selected": false,
"text": "<p>The error code you got is NSURLErrorUserCancelledAuthentication and is documented in <a href=\"http://developer.ap... | 2009/02/09 | [
"https://Stackoverflow.com/questions/530590",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm trying to pull out HTTP Headers and an HTTP Response Code from a synchronous HTTP request on the iPhone. I generally don't have any issues doing this with asynchronous requests, although a bit of trouble here. The HTTP Response Headers are null and HTTP Status Code is 0. Web server is configured proper and I can re... | The error code you got is NSURLErrorUserCancelledAuthentication and is documented in [Foundation Constants Reference](http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Miscellaneous/Foundation_Constants/Reference/reference.html#//apple_ref/doc/c_ref/NSURLErrorUserCancelledAuthentication). You might be... |
530,601 | <p>Basically I am storing millions of vector3 values in a list. But right now the vector3s are defined like so:</p>
<pre><code>[5,6,7]
</code></pre>
<p>which I believe is a list. The values will not be modified nor I need any vector3 functionality.</p>
<p>Is this the most performant way to do this?</p>
| [
{
"answer_id": 530622,
"author": "jacobangel",
"author_id": 31318,
"author_profile": "https://Stackoverflow.com/users/31318",
"pm_score": 3,
"selected": false,
"text": "<p>The best way is probably using tuples rather than a list. Tuples are faster than lists, and cannot be modified once ... | 2009/02/09 | [
"https://Stackoverflow.com/questions/530601",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51816/"
] | Basically I am storing millions of vector3 values in a list. But right now the vector3s are defined like so:
```
[5,6,7]
```
which I believe is a list. The values will not be modified nor I need any vector3 functionality.
Is this the most performant way to do this? | If you are storing millions of them, the best way (both for speed and memory use) is to use [numpy](http://numpy.scipy.org/).
If you want to avoid numpy and use only built-in python modules, using tuples instead of lists will save you some overhead. |
530,614 | <p>How can I format my output in C++? In other words, what is the C++ equivalent to the use of <code>printf</code> like this:</p>
<pre><code>printf("%05d", zipCode);
</code></pre>
<p>I know I could just use <code>printf</code> in C++, but I would prefer the output operator <code><<</code>.</p>
<p>Would you jus... | [
{
"answer_id": 530617,
"author": "Nik Reiman",
"author_id": 14302,
"author_profile": "https://Stackoverflow.com/users/14302",
"pm_score": 4,
"selected": false,
"text": "<p>Use the <a href=\"http://www.fredosaurus.com/notes-cpp/io/omanipulators.html\" rel=\"noreferrer\">setw and setfill</... | 2009/02/10 | [
"https://Stackoverflow.com/questions/530614",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/60628/"
] | How can I format my output in C++? In other words, what is the C++ equivalent to the use of `printf` like this:
```
printf("%05d", zipCode);
```
I know I could just use `printf` in C++, but I would prefer the output operator `<<`.
Would you just use the following?
```
std::cout << "ZIP code: " << sprintf("%05d", z... | This will do the trick, at least for non-negative numbers(a) such as the ZIP codes(b) mentioned in your question.
```
#include <iostream>
#include <iomanip>
using namespace std;
cout << setw(5) << setfill('0') << zipCode << endl;
// or use this if you don't like 'using namespace std;'
std::cout << std::setw(5) << st... |
530,627 | <p>Is it possible to get a query string from a PDO object with bound parameters without executing it first? I have code similar to the following (where $dbc is the PDO object):</p>
<pre><code>$query = 'SELECT * FROM users WHERE username = ?';
$result = $dbc->prepare($query);
$username = 'bob';
$result->bindParam... | [
{
"answer_id": 530705,
"author": "Crescent Fresh",
"author_id": 45433,
"author_profile": "https://Stackoverflow.com/users/45433",
"pm_score": 5,
"selected": true,
"text": "<p>In short: no. See <a href=\"https://stackoverflow.com/questions/210564/pdo-prepared-statements/210693#210693\">Ge... | 2009/02/10 | [
"https://Stackoverflow.com/questions/530627",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13281/"
] | Is it possible to get a query string from a PDO object with bound parameters without executing it first? I have code similar to the following (where $dbc is the PDO object):
```
$query = 'SELECT * FROM users WHERE username = ?';
$result = $dbc->prepare($query);
$username = 'bob';
$result->bindParam(1, $username);
echo... | In short: no. See [Getting raw SQL query string from PDO prepared statements](https://stackoverflow.com/questions/210564/pdo-prepared-statements/210693#210693)
If you want to just emulate it, try:
```
echo preg_replace('?', $username, $result->queryString);
``` |
530,633 | <p>Does anyone know how get a listing of all files changed in multiple changesets in Visual Studio Team System 2005? I basically want to see a listing of all files changed from the start of a development effort till the end.</p>
| [
{
"answer_id": 850257,
"author": "Jason Williams",
"author_id": 97385,
"author_profile": "https://Stackoverflow.com/users/97385",
"pm_score": -1,
"selected": false,
"text": "<p>You can use TF.exe from the command line to get at an awful lot of information very easily.</p>\n\n<p>Even if i... | 2009/02/10 | [
"https://Stackoverflow.com/questions/530633",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30383/"
] | Does anyone know how get a listing of all files changed in multiple changesets in Visual Studio Team System 2005? I basically want to see a listing of all files changed from the start of a development effort till the end. | With the power tools installed:
```
# get-tfschangeset doesn't support arrays, so you have to loop
100, 200, 300 | % { get-tfschangeset $_ } | select-tfsitem | select -unique path | sort
# powershell also has a range operator...
100..105 | % { get-tfschangeset $_ } | select-tfsitem
``` |
530,641 | <p>I have a <code>User.create</code> action that provisionally registers a new user and sends an email with a generated password. What is the most Rails-like way to complete that action? I want to do everything exactly right from now on. No more nonsense. This time I'm serious.</p>
<p>I'm thinking these are the option... | [
{
"answer_id": 530647,
"author": "Aram Verstegen",
"author_id": 64234,
"author_profile": "https://Stackoverflow.com/users/64234",
"pm_score": 2,
"selected": false,
"text": "<p>Definitely option 3, redirecting to the show action. When you do this the user will be redirected when the actio... | 2009/02/10 | [
"https://Stackoverflow.com/questions/530641",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42595/"
] | I have a `User.create` action that provisionally registers a new user and sends an email with a generated password. What is the most Rails-like way to complete that action? I want to do everything exactly right from now on. No more nonsense. This time I'm serious.
I'm thinking these are the options...
1. Create a vie... | This is more of a user experience question.
Leave the create action as something that just creates and has no output (or just a simple `201 Created` header if created by an API call). Do a `redirect_to` to either:
1. A thanks page telling them how to wait and what will happen next
2. The homepage with a very visible ... |
530,649 | <p>You can do this in Python, but is it possible in PHP?</p>
<pre><code>>>> def a(): print 1
...
>>> def a(): print 2
...
>>> a()
2
</code></pre>
<p>e.g.:</p>
<pre><code><? function var_dump() {} ?>
Fatal error: Cannot redeclare var_dump() in /tmp/- on line 1
</code></pre>
| [
{
"answer_id": 530653,
"author": "Paolo Bergantino",
"author_id": 16417,
"author_profile": "https://Stackoverflow.com/users/16417",
"pm_score": 3,
"selected": false,
"text": "<p>No, it is not possible to do this as you might expect.</p>\n\n<p>From the <a href=\"http://php.net/manual/en/f... | 2009/02/10 | [
"https://Stackoverflow.com/questions/530649",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11125/"
] | You can do this in Python, but is it possible in PHP?
```
>>> def a(): print 1
...
>>> def a(): print 2
...
>>> a()
2
```
e.g.:
```
<? function var_dump() {} ?>
Fatal error: Cannot redeclare var_dump() in /tmp/- on line 1
``` | This is a *bit* late, but I just want to point out that since PHP 5.3, it is actually possible to override internal functions without using a PHP extension.
The trick is that you can redefine an internal PHP function inside a namespace. It's based on the way PHP does name resolution for functions:
Inside namespace (s... |
530,660 | <p>I am building a site that is an interface used to create XML files that are read as input by a server side program.</p>
<p>The website allows users to dynamically create blocks of HTML. Each block can be thought of as an object and contains several input fields. When the user submits the form, the data is turned in... | [
{
"answer_id": 530673,
"author": "Luca Matteis",
"author_id": 50394,
"author_profile": "https://Stackoverflow.com/users/50394",
"pm_score": 0,
"selected": false,
"text": "<p>Why are you processing the HTML into an XML if you want to <em>preserve</em> the HTML? </p>\n\n<p>Just keep the HT... | 2009/02/10 | [
"https://Stackoverflow.com/questions/530660",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/196/"
] | I am building a site that is an interface used to create XML files that are read as input by a server side program.
The website allows users to dynamically create blocks of HTML. Each block can be thought of as an object and contains several input fields. When the user submits the form, the data is turned into an XML ... | What [strager said](https://stackoverflow.com/questions/530660/best-way-to-preserve-user-generated-html-across-a-post-request/530703#530703). Plus, with Javascript you can get the HTML string for any element:
```
document.getElementById('myimportantthing').innerHTML
```
And send that to your server for inclusion in ... |
530,662 | <p>In the Dojo Javascript library, I understand how to use dojo.connect or dojo.publish to wire up my event handler to an event. That functionality works great. </p>
<p>But I want to do one additional thing. </p>
<p>I want my event handler to fire first, before any other already defined event handlers. I suppose this... | [
{
"answer_id": 533548,
"author": "Luca Matteis",
"author_id": 50394,
"author_profile": "https://Stackoverflow.com/users/50394",
"pm_score": 0,
"selected": false,
"text": "<p>When events are fired they are connected to their <em>action</em> (onload, onclick). So how would you fire an even... | 2009/02/10 | [
"https://Stackoverflow.com/questions/530662",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31892/"
] | In the Dojo Javascript library, I understand how to use dojo.connect or dojo.publish to wire up my event handler to an event. That functionality works great.
But I want to do one additional thing.
I want my event handler to fire first, before any other already defined event handlers. I suppose this could be called ... | Try modifying your event like this:
```
function alertTest(){
alert('test');
}
function alertTest2(){
alert('test2');
}
window.onload = alertTest2; //just setting it to simulate that an event
//is already set
oldOnload = window.onload; //store the old event into a temporary varia... |
530,670 | <p>Has anyone not noticed that JQuery uses ActiveX controls?</p>
<p>When a user has limited their activex security they will get script prompt popups and a yellow bar accross the top of their browser window.
-This setting is by default on Windows Servers.
-Internet Cafe's dont support Active X.
-Company internal wor... | [
{
"answer_id": 530684,
"author": "Luca Matteis",
"author_id": 50394,
"author_profile": "https://Stackoverflow.com/users/50394",
"pm_score": 5,
"selected": true,
"text": "<p>Only spot where <code>ActiveX</code> is mentioned in the jQuery code is for the <code>ActiveXObject</code> which is... | 2009/02/10 | [
"https://Stackoverflow.com/questions/530670",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/64027/"
] | Has anyone not noticed that JQuery uses ActiveX controls?
When a user has limited their activex security they will get script prompt popups and a yellow bar accross the top of their browser window.
-This setting is by default on Windows Servers.
-Internet Cafe's dont support Active X.
-Company internal workstations ... | Only spot where `ActiveX` is mentioned in the jQuery code is for the `ActiveXObject` which is used for XMLHttpRequests:
```
// Create the request object; Microsoft failed to properly
// implement the XMLHttpRequest in IE7, so we use the ActiveXObject when it is available
var xhr = window.ActiveXObject ? new ActiveXOb... |
530,681 | <p>I need to transfer data from one table to another. The second table got a primary key constraint (and the first one have no constraint). They have the same structure. What I want is to select all rows from table A and insert it in table B without the duplicate row (if a row is0 duplicate, I only want to take the fir... | [
{
"answer_id": 530694,
"author": "Thilo",
"author_id": 14955,
"author_profile": "https://Stackoverflow.com/users/14955",
"pm_score": 2,
"selected": false,
"text": "<p>What is your database? In Oracle you could say</p>\n\n<pre><code>SELECT FROM your_table\nWHERE rowid in\n(SELECT MIN(rowi... | 2009/02/10 | [
"https://Stackoverflow.com/questions/530681",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/60002/"
] | I need to transfer data from one table to another. The second table got a primary key constraint (and the first one have no constraint). They have the same structure. What I want is to select all rows from table A and insert it in table B without the duplicate row (if a row is0 duplicate, I only want to take the first ... | First, you need to define what makes a row "first". I'll make up an arbitrary definition and you can change the SQL as you need to for what you want. For this example, I assume "first" to be the lowest value for MyField4 and if they are equal then the lowest value for MyField5. It also accounts for the possibility of a... |
530,682 | <p>Is there a way of using python and win32com to copy and paste such that python scripts can run in the background and not mess up the "users" copy and paste ability?</p>
<pre><code>from win32com.client import Dispatch
import win32com.client
xlApp = Dispatch("Excel.Application")
xlWb = xlApp.Workbooks.Open(filename_... | [
{
"answer_id": 531004,
"author": "John Fouhy",
"author_id": 15154,
"author_profile": "https://Stackoverflow.com/users/15154",
"pm_score": 1,
"selected": false,
"text": "<p>Just read the data out into python, and then write it back.</p>\n\n<p>Instead of:</p>\n\n<pre><code>ws.Range('a1:k%s... | 2009/02/10 | [
"https://Stackoverflow.com/questions/530682",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35781/"
] | Is there a way of using python and win32com to copy and paste such that python scripts can run in the background and not mess up the "users" copy and paste ability?
```
from win32com.client import Dispatch
import win32com.client
xlApp = Dispatch("Excel.Application")
xlWb = xlApp.Workbooks.Open(filename_xls)
ws = xlWb... | Instead of:
```
ws.Range('a1:k%s' % row).select
ws.Range('a1:k%s' % row).cut
ws.Range('a7').select
ws.paste
```
I did:
```
ws.Range("A1:K5").Copy(ws.Range("A7:K11"))
```
according to [MSDN: Excel Object Model Reference](http://msdn.microsoft.com/en-us/library/bb178833%28v=office.12%29.aspx) |
530,683 | <p>When creating a new ASP.NET AJAX Web Application in Visual Studio 2005, the default web.config contains the following section (inside the <em>compilation</em> node):</p>
<pre><code><assemblies>
<add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/... | [
{
"answer_id": 530688,
"author": "Randolpho",
"author_id": 12716,
"author_profile": "https://Stackoverflow.com/users/12716",
"pm_score": 6,
"selected": true,
"text": "<p>It may or may not be safely removed. The Assemblies node is for configuration-based reference addition. It's used by A... | 2009/02/10 | [
"https://Stackoverflow.com/questions/530683",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/775/"
] | When creating a new ASP.NET AJAX Web Application in Visual Studio 2005, the default web.config contains the following section (inside the *compilation* node):
```
<assemblies>
<add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</assemblies>
```
Whether ... | It may or may not be safely removed. The Assemblies node is for configuration-based reference addition. It's used by ASP.NET websites that deploy uncompiled .cs code files to their website, rather than (as sensible people do) compiled assemblies.
If you are deploying code-behind files to your website rather than asse... |
530,693 | <p>In my php application user able to enter the tags(like here while ask question).
I assume it will be regexp, and I used one - mb_split('\W+', $text) - to split by non-word characters. </p>
<p>But I want to allow users to enter characters like "-,_,+,#" etc which are valid ones to be in url and are common. </p>
<p... | [
{
"answer_id": 530696,
"author": "Zach Scrivena",
"author_id": 20029,
"author_profile": "https://Stackoverflow.com/users/20029",
"pm_score": 3,
"selected": false,
"text": "<p>Split by whitespace <code>\\s+</code> instead.</p>\n"
},
{
"answer_id": 530697,
"author": "chaos",
... | 2009/02/10 | [
"https://Stackoverflow.com/questions/530693",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/58123/"
] | In my php application user able to enter the tags(like here while ask question).
I assume it will be regexp, and I used one - mb\_split('\W+', $text) - to split by non-word characters.
But I want to allow users to enter characters like "-,\_,+,#" etc which are valid ones to be in url and are common.
Is there exiti... | Use the [explode()](http://ca3.php.net/manual/en/function.explode.php) function and separate by either spaces or commas. Example:
```
$string = 'tag1 tag-2 tag#3';
$tags = explode(' ', $string); //Tags will be an array
``` |
530,701 | <p>I am looking to allow users to select a pre-uploaded image to a user generated web page.</p>
<p>I have a list of the available images, so I could easily do this with a select control, however, I'd really like to allow the users to select from a pop up of thumbnails, rather than text, then have that populate a text ... | [
{
"answer_id": 530713,
"author": "Aram Verstegen",
"author_id": 64234,
"author_profile": "https://Stackoverflow.com/users/64234",
"pm_score": 1,
"selected": false,
"text": "<p>I was rather impressed with <a href=\"http://www.acewebdesign.com.au/customselect.php\" rel=\"nofollow noreferre... | 2009/02/10 | [
"https://Stackoverflow.com/questions/530701",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/52494/"
] | I am looking to allow users to select a pre-uploaded image to a user generated web page.
I have a list of the available images, so I could easily do this with a select control, however, I'd really like to allow the users to select from a pop up of thumbnails, rather than text, then have that populate a text form eleme... | ```
function fillBox(myImg){
imageSource = myImg.src;
imgName = // do some stuff to get only the filename, minus the dirs
document.getElementById("yourTextBox").value = imgName;
}
```
and as you're generating your thumbnails, add this to the img tag:
```
onclick="javascript:fillBox(this);"
```
I haven'... |
530,731 | <p>I am getting this exception: </p>
<blockquote>
<p><em>The communication object,
System.ServiceModel.Channels.ServiceChannel,
cannot be used for communication
because it is in the Faulted state.</em></p>
</blockquote>
<p>The WCF service uses the default wsHttpBinding. I am using WCF in the following way whe... | [
{
"answer_id": 531140,
"author": "Brian",
"author_id": 19299,
"author_profile": "https://Stackoverflow.com/users/19299",
"pm_score": 7,
"selected": true,
"text": "<p><a href=\"http://msdn.microsoft.com/en-us/library/aa355056.aspx\" rel=\"noreferrer\">You should avoid putting client proxi... | 2009/02/10 | [
"https://Stackoverflow.com/questions/530731",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37494/"
] | I am getting this exception:
>
> *The communication object,
> System.ServiceModel.Channels.ServiceChannel,
> cannot be used for communication
> because it is in the Faulted state.*
>
>
>
The WCF service uses the default wsHttpBinding. I am using WCF in the following way wherever I am using it:
```
using (var... | [You should avoid putting client proxies in `using` blocks.](http://msdn.microsoft.com/en-us/library/aa355056.aspx) |
530,736 | <p>I am trying to do what I think is something simple, but I suspect I am simply too n00b to know that I am probably doing something wrong. I have a LINQ query return:</p>
<pre><code>IQueryable<CWords> Result
</code></pre>
<p>Where CWords is a class I defined as follows:</p>
<pre><code>public class CWords
{
... | [
{
"answer_id": 533410,
"author": "Paul G.",
"author_id": 64127,
"author_profile": "https://Stackoverflow.com/users/64127",
"pm_score": 0,
"selected": false,
"text": "<p>I believe your goodWords is <code>IQueryable<CWords></code> type?</p>\n\n<p>So why not like this?</p>\n\n<pre><co... | 2009/02/10 | [
"https://Stackoverflow.com/questions/530736",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/64052/"
] | I am trying to do what I think is something simple, but I suspect I am simply too n00b to know that I am probably doing something wrong. I have a LINQ query return:
```
IQueryable<CWords> Result
```
Where CWords is a class I defined as follows:
```
public class CWords
{
public CWords(){}
public string _colu... | Brandon, this is a normal mistake when using LINQ. See, the IQueryable returned from LINQ does not actually contain your items, that's why you can't index into it. It has only enough information to perform the query when you actually ask for the items. This is called "[deferred execution](http://blogs.msdn.com/charlie/... |
530,760 | <p>I'm trying to figure out how to do this, and I"m stumped. I'm sure it's something simple that I'm just missing.</p>
<p>Say I have a table that is a collection of names, and I want to check if a subset of those names exist like this:</p>
<pre><code>var names = new List{ "John", "Steven", "Mary"};
var dbNames = from... | [
{
"answer_id": 530772,
"author": "Uri",
"author_id": 23072,
"author_profile": "https://Stackoverflow.com/users/23072",
"pm_score": 3,
"selected": true,
"text": "<p>The Java Developer Almanac contains some <a href=\"http://www.exampledepot.com/egs/javax.swing.table/PackCol.html\" rel=\"no... | 2009/02/10 | [
"https://Stackoverflow.com/questions/530760",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17744/"
] | I'm trying to figure out how to do this, and I"m stumped. I'm sure it's something simple that I'm just missing.
Say I have a table that is a collection of names, and I want to check if a subset of those names exist like this:
```
var names = new List{ "John", "Steven", "Mary"};
var dbNames = from n in Db.Names
... | The Java Developer Almanac contains some [good sample code](http://www.exampledepot.com/egs/javax.swing.table/PackCol.html) for packing tables based on column width, this may be a good place to start. |
530,769 | <p>I am use Jquery accordion plugin.
I need to use my own header icons,
according to doc, i need to create css class with background image.</p>
<p>so i did this in my css file.</p>
<pre><code>.normal_arrow {
background : url(../images/arrowonly.jpg);
}
.circle_arrow {
background : url(../images/circle_arrow.... | [
{
"answer_id": 530785,
"author": "Paolo Bergantino",
"author_id": 16417,
"author_profile": "https://Stackoverflow.com/users/16417",
"pm_score": 2,
"selected": false,
"text": "<p>Your code looks correct.</p>\n\n<p>Try using <code>background-image:</code> instead of <code>background:</code... | 2009/02/10 | [
"https://Stackoverflow.com/questions/530769",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am use Jquery accordion plugin.
I need to use my own header icons,
according to doc, i need to create css class with background image.
so i did this in my css file.
```
.normal_arrow {
background : url(../images/arrowonly.jpg);
}
.circle_arrow {
background : url(../images/circle_arrow.jpg);
}
.circle_arro... | Your code looks correct.
Try using `background-image:` instead of `background:`
Also use a tool like [`Firebug`](http://getfirebug.com/) to make absolutely sure the relatives paths are going where you think they are going. |
530,782 | <p>Looking for a way to pass an associative array to a method. I'm looking to rewrite an Actionscript tween package in C# but running into trouble with "associative" arrays/objects. Normally in Actionscript I might do something like:</p>
<pre><code>public function tween(obj:DisplayObject, params:Object = null):void {
... | [
{
"answer_id": 530795,
"author": "paxdiablo",
"author_id": 14860,
"author_profile": "https://Stackoverflow.com/users/14860",
"pm_score": 0,
"selected": false,
"text": "<p>It worked fine for me. One thing I noticed is that there was a security check dialog box (trust content from Sun?) an... | 2009/02/10 | [
"https://Stackoverflow.com/questions/530782",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53653/"
] | Looking for a way to pass an associative array to a method. I'm looking to rewrite an Actionscript tween package in C# but running into trouble with "associative" arrays/objects. Normally in Actionscript I might do something like:
```
public function tween(obj:DisplayObject, params:Object = null):void {
if (params... | Turns out it was because I was using the NetBeans generated JNLPs. Take a look at [this article](http://www.dieajax.com/2008/12/19/10-minute-javafx-tutorial-deploy-javafx-applets-and-applications-both-online-and-offline/). It describes exactly the problem I was having and how to fix it, towards the bottom. In a nutshel... |
530,792 | <p>I have been attempting to do the following for a few days to no avail:</p>
<p>I have a GWT application that makes several RPC calls on startup to load initial data. For the most part, this data is relatively static, so I'd skip the RPC call if I could. But the data changes more often than the application does, so... | [
{
"answer_id": 531280,
"author": "rustyshelf",
"author_id": 6044,
"author_profile": "https://Stackoverflow.com/users/6044",
"pm_score": 2,
"selected": false,
"text": "<p>Yes (this is something I do a lot):</p>\n\n<p><a href=\"http://wiki.shiftyjelly.com/index.php/GWT#Speed_up_Page_Loadin... | 2009/02/10 | [
"https://Stackoverflow.com/questions/530792",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have been attempting to do the following for a few days to no avail:
I have a GWT application that makes several RPC calls on startup to load initial data. For the most part, this data is relatively static, so I'd skip the RPC call if I could. But the data changes more often than the application does, so I'd rather ... | Yes (this is something I do a lot):
<http://wiki.shiftyjelly.com/index.php/GWT#Speed_up_Page_Loading.2C_by_pre-serializing_your_GWT_calls>
The basics of it are that you make the call when your server is rendering the page, and get GWT to serialize it to it's normal RPC form, and store it in the page in a javascript v... |
530,799 | <p>Question is as stated in the title: What are the performance implications of marking methods / properties as virtual?</p>
<p>Note - I'm assuming the virtual methods will <em>not</em> be overloaded in the common case; I'll usually be working with the base class here.</p>
| [
{
"answer_id": 530817,
"author": "Richard A",
"author_id": 24355,
"author_profile": "https://Stackoverflow.com/users/24355",
"pm_score": 2,
"selected": false,
"text": "<p>From your tags, you're talking c#. I can only answer from a Delphi perspective. I think it will be similar. (I am exp... | 2009/02/10 | [
"https://Stackoverflow.com/questions/530799",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16942/"
] | Question is as stated in the title: What are the performance implications of marking methods / properties as virtual?
Note - I'm assuming the virtual methods will *not* be overloaded in the common case; I'll usually be working with the base class here. | Virtual functions only have a very small performance overhead compared to direct calls. At a low level, you're basically looking at an array lookup to get a function pointer, and then a call via a function pointer. Modern CPUs can even predict indirect function calls reasonably well in their branch predictors, so they ... |
530,802 | <p>I have a class library that mainly logs the string to text file. One of its method is LogString(string str) so I'm just wondering based on the function below if I call it for many times like over 600 times, does it cause stackoverflow?</p>
<pre><code> public void LogString(string str)
{
try
... | [
{
"answer_id": 530811,
"author": "Kyle Cronin",
"author_id": 658,
"author_profile": "https://Stackoverflow.com/users/658",
"pm_score": 3,
"selected": false,
"text": "<p>That doesn't even appear to be a recursive function. I don't see how that would cause a stack overflow.</p>\n\n<p>In or... | 2009/02/10 | [
"https://Stackoverflow.com/questions/530802",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/64398/"
] | I have a class library that mainly logs the string to text file. One of its method is LogString(string str) so I'm just wondering based on the function below if I call it for many times like over 600 times, does it cause stackoverflow?
```
public void LogString(string str)
{
try
{
... | That doesn't even appear to be a recursive function. I don't see how that would cause a stack overflow.
In order to overflow a stack you have to continually call functions from within functions. Every time you do this, more stack space is used to resume the calling function when the called function returns. Recursive ... |
530,820 | <p>Using Delphi Steema TeeChart component, if I link a BarSeries to a dataset using the user interface, it shows up fine, but if I do it using code (which I need to), it's only showing one bar, even when I have several records in the database. What am I doing wrong?</p>
<p>Code:</p>
<pre><code>var
i:Integer;
Ba... | [
{
"answer_id": 531000,
"author": "Argalatyr",
"author_id": 18484,
"author_profile": "https://Stackoverflow.com/users/18484",
"pm_score": 0,
"selected": false,
"text": "<p>TChart refreshes the query each time you set</p>\n\n<blockquote>\n <p>ADataSet.Active := true;</p>\n</blockquote>\n\... | 2009/02/10 | [
"https://Stackoverflow.com/questions/530820",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26305/"
] | Using Delphi Steema TeeChart component, if I link a BarSeries to a dataset using the user interface, it shows up fine, but if I do it using code (which I need to), it's only showing one bar, even when I have several records in the database. What am I doing wrong?
Code:
```
var
i:Integer;
Bar:TBarSeries;
begin
... | This code works for me (using an Access database with fields ID and Height, I dropped a TDBChart, TADODataSet, and a TButton on a form):
```
procedure TForm1.Button1Click(Sender: TObject);
var
Bar : TBarSeries;
begin
ADODataSet1.Close;
ADODataSet1.ConnectionString := 'Provider=Microsoft.Jet.OLED... |
530,825 | <p>I want to use <code>printf</code> to display hex numbers in the form <code>0x###</code>, but if the number is 0, I want to omit the <code>0x</code> part.</p>
| [
{
"answer_id": 530830,
"author": "Joe",
"author_id": 57135,
"author_profile": "https://Stackoverflow.com/users/57135",
"pm_score": 1,
"selected": false,
"text": "<p>Why make it hard?</p>\n\n<pre>\nif number = 0\n printf without formatting\nelse\n printf with formatting\n</pre>\n"
},
... | 2009/02/10 | [
"https://Stackoverflow.com/questions/530825",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39036/"
] | I want to use `printf` to display hex numbers in the form `0x###`, but if the number is 0, I want to omit the `0x` part. | ```
printf("%#x", number);
```
Note that this does **exactly** what you want. If the value of number is 0, it prints 0, otherwise it prints in hex. Example:
```
int x = 0;
int y = 548548;
printf("%#x %#x\n", x, y);
```
Results in:
```
0 0x85ec4
``` |
530,832 | <p>I have an assignment from my comp. system org. subject and unfortunately I'm kind of new when it comes to assembly language. I'm supposed to write a program that displays the numbers 0,2,4,6,8,10 respectively. How would I go about this?</p>
<p>Maybe this'll answer my question: (Reactions please)</p>
<pre><code>.mo... | [
{
"answer_id": 530853,
"author": "Chris Ballance",
"author_id": 1551,
"author_profile": "https://Stackoverflow.com/users/1551",
"pm_score": 2,
"selected": false,
"text": "<p>You do know there is more than one flavor of \"Assembly Language.\" </p>\n"
},
{
"answer_id": 530862,
... | 2009/02/10 | [
"https://Stackoverflow.com/questions/530832",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have an assignment from my comp. system org. subject and unfortunately I'm kind of new when it comes to assembly language. I'm supposed to write a program that displays the numbers 0,2,4,6,8,10 respectively. How would I go about this?
Maybe this'll answer my question: (Reactions please)
```
.model small
.stack 100H... | Go see your lecturer and/or tutor and ask for advice. That's what they're there for. You haven't given us anywhere *near* enough info to help you out.
Here's what I *think* your ABCD program should look like. I suggest you use it as a baseline to try to make a 0 2 4 ... version.
```
model proc
.stack 100H
... |
530,842 | <p>How do you modify a model you've generated using modeling? For example, the model myModel originally had columns a, b and c, but I now want to add column d.</p>
| [
{
"answer_id": 530846,
"author": "Andrew Hampton",
"author_id": 466,
"author_profile": "https://Stackoverflow.com/users/466",
"pm_score": 4,
"selected": false,
"text": "<p>The best answer I've found so far is run this from your project root:</p>\n\n<pre><code>ruby script/generate migrati... | 2009/02/10 | [
"https://Stackoverflow.com/questions/530842",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/466/"
] | How do you modify a model you've generated using modeling? For example, the model myModel originally had columns a, b and c, but I now want to add column d. | Rails 3 and above use the following code :
```
rails generate migration add_fieldname_id_to_tablename fieldname:string
```
---
Rails 2
```
ruby script/generate migration add_fieldname_to_tablename fieldname:string
```
This no longer works and returns the following error in Rails 3:
>
> ruby: No such file or d... |
530,866 | <p>I'm trying to animate the background for an ASP.Net hyperlink to do a yellow fade on an update panels refresh. So far it works almost all of the time, but occasionally a javascript error is thrown "Invalid Propery value." and it debugs into the jquery color plug-in code to this line...</p>
<pre><code>fx.elem.style... | [
{
"answer_id": 540131,
"author": "Nicholas Head",
"author_id": 22505,
"author_profile": "https://Stackoverflow.com/users/22505",
"pm_score": 4,
"selected": true,
"text": "<p>I think I ran into the same problem as you on another project; I had a DIV inside of another DIV (which didn't hav... | 2009/02/10 | [
"https://Stackoverflow.com/questions/530866",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49294/"
] | I'm trying to animate the background for an ASP.Net hyperlink to do a yellow fade on an update panels refresh. So far it works almost all of the time, but occasionally a javascript error is thrown "Invalid Propery value." and it debugs into the jquery color plug-in code to this line...
```
fx.elem.style[attr] = "rgb("... | I think I ran into the same problem as you on another project; I had a DIV inside of another DIV (which didn't have it's background explicitly defined.) I was trying to "flash" the background color of the inner DIV and was running into that error. Only after I assigned a specific color to the container DIV did the erro... |
530,882 | <p>I am trying to call php's HTML purifier from .NET using this code:</p>
<pre><code> Process myProcess = new Process();
myProcess.StartInfo.FileName = "C:\Path\to\php.exe";
myProcess.StartInfo.Arguments = "C:\Path\to\purify.php";
myProcess.StartInfo.UseShellExecute = false;
myProcess.StartInfo.Red... | [
{
"answer_id": 530915,
"author": "dreamlax",
"author_id": 10320,
"author_profile": "https://Stackoverflow.com/users/10320",
"pm_score": 2,
"selected": false,
"text": "<p>Try</p>\n\n<pre><code>myProcess.StartInfo.StandardOutputEncoding = System.Text.Encoding.UTF8;\n</code></pre>\n"
},
... | 2009/02/10 | [
"https://Stackoverflow.com/questions/530882",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am trying to call php's HTML purifier from .NET using this code:
```
Process myProcess = new Process();
myProcess.StartInfo.FileName = "C:\Path\to\php.exe";
myProcess.StartInfo.Arguments = "C:\Path\to\purify.php";
myProcess.StartInfo.UseShellExecute = false;
myProcess.StartInfo.RedirectStandardO... | Try
```
myProcess.StartInfo.StandardOutputEncoding = System.Text.Encoding.UTF8;
``` |
530,883 | <p>I asked a previous question <a href="https://stackoverflow.com/questions/530787/simple-http-web-server">here</a> but after reading the answers realised I hadn't done a very good job of defining my requirements.</p>
<p>Here's what I'm after:</p>
<ul>
<li>Cross platform</li>
<li>Drag, drop and start</li>
<li>Prefera... | [
{
"answer_id": 530974,
"author": "user64349",
"author_id": 64349,
"author_profile": "https://Stackoverflow.com/users/64349",
"pm_score": 1,
"selected": false,
"text": "<p>I have found a some-what small web server in the form of a Firefox addon. It works on any platform that Firefox works... | 2009/02/10 | [
"https://Stackoverflow.com/questions/530883",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37196/"
] | I asked a previous question [here](https://stackoverflow.com/questions/530787/simple-http-web-server) but after reading the answers realised I hadn't done a very good job of defining my requirements.
Here's what I'm after:
* Cross platform
* Drag, drop and start
* Preferably a single file
So to sum up I want somethi... | Python implementation:
```
#!/usr/bin/env python
import SimpleHTTPServer, BaseHTTPServer
def launchServer(ports):
for port in ports:
try:
serv = BaseHTTPServer.HTTPServer(('', port), SimpleHTTPServer.SimpleHTTPRequestHandler)
except:
continue
else:
prin... |
530,923 | <p>Does dependency injection mean that you don't ever need the 'new' keyword? Or is it reasonable to directly create simple leaf classes such as collections?</p>
<p>In the example below I inject the comparator, query and dao, but the SortedSet is directly instantiated:</p>
<pre><code>public Iterable<Employee> g... | [
{
"answer_id": 530929,
"author": "Don Branson",
"author_id": 56076,
"author_profile": "https://Stackoverflow.com/users/56076",
"pm_score": 4,
"selected": true,
"text": "<p>Just because Dependency Injection is a useful pattern doesn't mean that we use it for everything. Even when using D... | 2009/02/10 | [
"https://Stackoverflow.com/questions/530923",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53191/"
] | Does dependency injection mean that you don't ever need the 'new' keyword? Or is it reasonable to directly create simple leaf classes such as collections?
In the example below I inject the comparator, query and dao, but the SortedSet is directly instantiated:
```
public Iterable<Employee> getRecentHires()
{
Sorte... | Just because Dependency Injection is a useful pattern doesn't mean that we use it for everything. Even when using DI, there will often be a need for *new*. Don't delete new just yet. |
530,925 | <p>I am trying to perform the following SQL using LINQ and the closest I got was doing cross joins and sum calculations. I know there has to be a better way to write it so I am turning to the stack team for help.</p>
<pre><code>SELECT T1.Column1, T1.Column2, SUM(T3.Column1) AS Amount
FROM T1
INNER JOIN T2
... | [
{
"answer_id": 530947,
"author": "Nick Berardi",
"author_id": 17,
"author_profile": "https://Stackoverflow.com/users/17",
"pm_score": 6,
"selected": true,
"text": "<p>Try this:</p>\n\n<pre><code>var total = from T1 in context.T1\n join T2 in context.T2 on T1.T2ID equals T2.T2I... | 2009/02/10 | [
"https://Stackoverflow.com/questions/530925",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3080/"
] | I am trying to perform the following SQL using LINQ and the closest I got was doing cross joins and sum calculations. I know there has to be a better way to write it so I am turning to the stack team for help.
```
SELECT T1.Column1, T1.Column2, SUM(T3.Column1) AS Amount
FROM T1
INNER JOIN T2
ON T1.T1ID = ... | Try this:
```
var total = from T1 in context.T1
join T2 in context.T2 on T1.T2ID equals T2.T2ID
join T3 in context.T3 on T2.T3ID equals T3.T3ID
group T3 by new { T1.Column1, T1.Column2 } into g
select new {
Column1 = T1.Column1,
Column2 ... |
530,958 | <p>I need to get the last click arguments.</p>
<p>My JavaScript code:</p>
<pre><code> <a href="#" onclick="show(fid1,1);">Link1</a>
<a href="#" onclick="show(fid2,2);">Link2</a>
<a href="#" onclick="show(fid3,2);">Link3</a>
</code></pre>
<p>Now I need another JavaScript function... | [
{
"answer_id": 530973,
"author": "Cato Johnston",
"author_id": 62118,
"author_profile": "https://Stackoverflow.com/users/62118",
"pm_score": 0,
"selected": false,
"text": "<p>Set a global variable in the show function. Then read it in the lastClickID function.</p>\n"
},
{
"answer... | 2009/02/10 | [
"https://Stackoverflow.com/questions/530958",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44984/"
] | I need to get the last click arguments.
My JavaScript code:
```
<a href="#" onclick="show(fid1,1);">Link1</a>
<a href="#" onclick="show(fid2,2);">Link2</a>
<a href="#" onclick="show(fid3,2);">Link3</a>
```
Now I need another JavaScript function that finds out the last click of show function's arguments. How can ... | If I understand your question correctly, you want to keep track of the most-recent arguments to `show()`, right? If that's indeed what you want to do, you could add two variables to your global namespace and just assign the values whenever you call `show()`:
```
last_foo = 0; // Global namespace
last_bar = 0;
functio... |
530,963 | <p>I'm constantly doing this</p>
<pre><code>puts “The temperature is “ + String(temperature) + “.”
</code></pre>
<p>in my debugging code, and another option is to use interpolation</p>
<pre><code>puts “The temperature is #{temperature}.”
</code></pre>
<p>is there any less cumbersome way to do this?</p>
<p><strong>... | [
{
"answer_id": 530981,
"author": "wfarr",
"author_id": 2286,
"author_profile": "https://Stackoverflow.com/users/2286",
"pm_score": 4,
"selected": true,
"text": "<p>None that are all that worthwhile for small cases like that.</p>\n\n<p>Though, you should prefer interpolation as it's less ... | 2009/02/10 | [
"https://Stackoverflow.com/questions/530963",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8047/"
] | I'm constantly doing this
```
puts “The temperature is “ + String(temperature) + “.”
```
in my debugging code, and another option is to use interpolation
```
puts “The temperature is #{temperature}.”
```
is there any less cumbersome way to do this?
**Edit:** This is just for debugging, if that matters. | None that are all that worthwhile for small cases like that.
Though, you should prefer interpolation as it's less expensive than concatenation. |
531,014 | <p>So I am working on a project which uses ASP.NET. I am trying to call Cache["key"] but the compiler complains about how System.Web.Caching.Cache is "nat valid at this point".</p>
<p>If I call Cache obj = new Cache(); the obj is always null.</p>
<p>I can access HttpContext.Current.Cache - but this doesnt let me spe... | [
{
"answer_id": 531040,
"author": "Jim Petkus",
"author_id": 38053,
"author_profile": "https://Stackoverflow.com/users/38053",
"pm_score": 5,
"selected": true,
"text": "<p>You should be able to absolute or sliding expiration calling the insert on HttpRuntime.Cache. It has several overload... | 2009/02/10 | [
"https://Stackoverflow.com/questions/531014",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11194/"
] | So I am working on a project which uses ASP.NET. I am trying to call Cache["key"] but the compiler complains about how System.Web.Caching.Cache is "nat valid at this point".
If I call Cache obj = new Cache(); the obj is always null.
I can access HttpContext.Current.Cache - but this doesnt let me specify an absolute e... | You should be able to absolute or sliding expiration calling the insert on HttpRuntime.Cache. It has several overloads. Ex:
```
HttpRuntime.Cache.Insert("EXAMPLE_KEY",
exampleItem,
Nothing,
DateTime.Now.AddHours(1),
... |
531,025 | <p>I've inherited a code base and I'm writing a little tool to update a database for it. The code uses a data access layer like SubSonic (but it is home-grown). There are many properties of an object, like "id", "templateFROM" and "templateTO", but there are 50 of them.</p>
<p>On screen, I can't display all 50 prope... | [
{
"answer_id": 531034,
"author": "okutane",
"author_id": 53481,
"author_profile": "https://Stackoverflow.com/users/53481",
"pm_score": 4,
"selected": true,
"text": "<p>You need to use System.Reflection for that task.</p>\n\n<pre><code>entObj.GetType().GetProperty(\"templateFROM\").SetVal... | 2009/02/10 | [
"https://Stackoverflow.com/questions/531025",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/232/"
] | I've inherited a code base and I'm writing a little tool to update a database for it. The code uses a data access layer like SubSonic (but it is home-grown). There are many properties of an object, like "id", "templateFROM" and "templateTO", but there are 50 of them.
On screen, I can't display all 50 properties each i... | You need to use System.Reflection for that task.
```
entObj.GetType().GetProperty("templateFROM").SetValue(entObj, _sVal, null);
```
This should help you. |
531,029 | <p>I have recently come up with a situation where I need to trim some rather large log files once they grow beyond a certain size. Everything but the last 1000 lines in each file is disposed of, the job is run every half hour by cron. My solution was to simply run through the list of files, check size and trim if neces... | [
{
"answer_id": 531050,
"author": "Jonathan Leffler",
"author_id": 15168,
"author_profile": "https://Stackoverflow.com/users/15168",
"pm_score": 2,
"selected": false,
"text": "<p>Estimate the average length of a line in the log - call it N bytes.</p>\n\n<p>Seek backwards from the end of t... | 2009/02/10 | [
"https://Stackoverflow.com/questions/531029",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2533756/"
] | I have recently come up with a situation where I need to trim some rather large log files once they grow beyond a certain size. Everything but the last 1000 lines in each file is disposed of, the job is run every half hour by cron. My solution was to simply run through the list of files, check size and trim if necessar... | I realize you're wanting to use Perl, but if this is a UNIX system, why not use the "tail" utility to do the trimming? You could do this in BASH with a very simple script:
```
if [ `stat -f "%z" "$file"` -gt "$MAX_FILE_SIZE" ]; then
tail -1000 $file > $file.tmp
#copy and then rm to avoid inode problems
cp... |
531,035 | <p>I am trying to port this line from MS SQL Server to SQLite</p>
<pre><code>IF NOT EXISTS(SELECT 1 FROM EVENTTYPE WHERE EventTypeName = 'ANI Received')
INSERT INTO EVENTTYPE (EventTypeName) VALUES ('ANI Received');
</code></pre>
<p>It seems that SQLite does not support IF NOT EXISTS or at least I can't make it ... | [
{
"answer_id": 531147,
"author": "beach",
"author_id": 53892,
"author_profile": "https://Stackoverflow.com/users/53892",
"pm_score": 8,
"selected": true,
"text": "<p>How about this?</p>\n\n<pre><code>INSERT OR IGNORE INTO EVENTTYPE (EventTypeName) VALUES 'ANI Received'\n</code></pre>\n\n... | 2009/02/10 | [
"https://Stackoverflow.com/questions/531035",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9382/"
] | I am trying to port this line from MS SQL Server to SQLite
```
IF NOT EXISTS(SELECT 1 FROM EVENTTYPE WHERE EventTypeName = 'ANI Received')
INSERT INTO EVENTTYPE (EventTypeName) VALUES ('ANI Received');
```
It seems that SQLite does not support IF NOT EXISTS or at least I can't make it work.
Am I missing somethi... | How about this?
```
INSERT OR IGNORE INTO EVENTTYPE (EventTypeName) VALUES 'ANI Received'
```
(Untested as I don't have SQLite... however [this link](http://www.sqlite.org/lang_insert.html) is quite descriptive.)
Additionally, this should also work:
```
INSERT INTO EVENTTYPE (EventTypeName)
SELECT 'ANI Received'
W... |
531,048 | <p>I have the following CSS that i have "hacked" with PHP because it doesn't align properly in IE7. Is there a better way to do this without resorting to PHP?</p>
<pre><code> #Menu
{
width: 100%;
height: 32px;
padding-top: <?php if(preg_match('/msie/i', $_SERVER['HTTP_USER_AGENT'])){echo... | [
{
"answer_id": 531088,
"author": "bendewey",
"author_id": 37881,
"author_profile": "https://Stackoverflow.com/users/37881",
"pm_score": 0,
"selected": false,
"text": "<p>This method still uses some conditional comments, but at least your not evaluating your code via PHP. In order to be ... | 2009/02/10 | [
"https://Stackoverflow.com/questions/531048",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/60102/"
] | I have the following CSS that i have "hacked" with PHP because it doesn't align properly in IE7. Is there a better way to do this without resorting to PHP?
```
#Menu
{
width: 100%;
height: 32px;
padding-top: <?php if(preg_match('/msie/i', $_SERVER['HTTP_USER_AGENT'])){echo '22px';}else{ech... | Whoa. Yeah, don't do that. You'll want o look at using "conditional comments" to include the css you want. Your first commenter bendewey has shown how you can target IE7 easily. There are other types of conditional comments as well which will allow you to target other versions of IE.
Here they are:
```
<!--[if IE]>
... |
531,056 | <p>I have a method thats run on a button click, with 4 labels. What I need to do is update a label after each block of code executes. I've tried threading, updatepanels, etc and can't seem to get anything to work. I thought the timer would work, but it only ticks when you're not inside a method. The code looks somethin... | [
{
"answer_id": 531070,
"author": "Element",
"author_id": 50970,
"author_profile": "https://Stackoverflow.com/users/50970",
"pm_score": 1,
"selected": false,
"text": "<p>Can you expose the 3 methods to client script and then call them sequentially from your client side code, when method1 ... | 2009/02/10 | [
"https://Stackoverflow.com/questions/531056",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47489/"
] | I have a method thats run on a button click, with 4 labels. What I need to do is update a label after each block of code executes. I've tried threading, updatepanels, etc and can't seem to get anything to work. I thought the timer would work, but it only ticks when you're not inside a method. The code looks something l... | You have a misunderstanding of how asp.net works. Your server code runs in response to a request from a browser for a *complete* html page. This is true even when all you really want to do is run some button click code. The *entire page* must be rebuilt from scratch anyway, even on postbacks. It's just the way web form... |
531,076 | <p>I'm trying to identify the scanners attached to the computer. One of the possible solutions is to use WIA (Windows Image Acquisition Automation Library).</p>
<p>These were my actions so far:</p>
<ul>
<li>Download wiaaut.dll</li>
<li>Copy it to system32</li>
<li>Register it with "regsvr32 wiaaut.dll" (successfully)... | [
{
"answer_id": 1353040,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": -1,
"selected": false,
"text": "<p>Try change the line :</p>\n\n<pre><code>foreach (WIA.DeviceInfo info in manager.DeviceInfos)\n</code></pre>\n\n<p>and rep... | 2009/02/10 | [
"https://Stackoverflow.com/questions/531076",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26447/"
] | I'm trying to identify the scanners attached to the computer. One of the possible solutions is to use WIA (Windows Image Acquisition Automation Library).
These were my actions so far:
* Download wiaaut.dll
* Copy it to system32
* Register it with "regsvr32 wiaaut.dll" (successfully)
* Add reference to my project in V... | try it with this class:
```
using System;
using System.Collections.Generic;
using System.Text;
using WIA;
using WIAVIDEOLib;
namespace Scanner
{
public class ImageAcquisition
{
private WIALib.WiaClass WiaClass;
private WIALib.ItemClass ItemClass;
private WIALib.CollectionClass CollectionClassDevices;
... |
531,085 | <p>I'm trying to make a loop in masm32 running under Windows Vista, however I did it this way and even though it actually finishes the loop, it crashes and I see no obvious reason why...any ideas?</p>
<pre><code>.386
.model flat, stdcall
option casemap :none
include \masm32\include\windows.inc
include \masm32\include... | [
{
"answer_id": 531101,
"author": "sharptooth",
"author_id": 57428,
"author_profile": "https://Stackoverflow.com/users/57428",
"pm_score": 1,
"selected": false,
"text": "<p>ClubPetey is right. MASM doesn't produce an epiloge for your code. So the processor continues execution of what it f... | 2009/02/10 | [
"https://Stackoverflow.com/questions/531085",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28586/"
] | I'm trying to make a loop in masm32 running under Windows Vista, however I did it this way and even though it actually finishes the loop, it crashes and I see no obvious reason why...any ideas?
```
.386
.model flat, stdcall
option casemap :none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
... | You need to have an "exit" to end your application. Also, my personal style is to put everything inside a subroutine, but that's just me.
something like:
`.code`
start:
```
call main
inkey
exit
```
main proc
```
mov loop_stopper,2
loop_start:
invoke StdOut, addr ProgramText
cmp loop_stopper, 0
dec lo... |
531,109 | <p>I have a table in SQLite:</p>
<pre><code>CREATE TABLE "EventType"
(
[EventTypeID] INTEGER PRIMARY KEY,
[EventTypeName] VARCHAR(50) NOT NULL UNIQUE
);
</code></pre>
<p>Since EventTypeID is an integer and a primary key, that automatically makes it an auto-incrementing column, and that works fine.</p>
<p>I'd like ... | [
{
"answer_id": 531127,
"author": "bendewey",
"author_id": 37881,
"author_profile": "https://Stackoverflow.com/users/37881",
"pm_score": 5,
"selected": true,
"text": "<p><a href=\"https://stackoverflow.com/questions/304543/does-sqlite-support-scopeidentity\">Does SQLite support SCOPE_IDEN... | 2009/02/10 | [
"https://Stackoverflow.com/questions/531109",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9382/"
] | I have a table in SQLite:
```
CREATE TABLE "EventType"
(
[EventTypeID] INTEGER PRIMARY KEY,
[EventTypeName] VARCHAR(50) NOT NULL UNIQUE
);
```
Since EventTypeID is an integer and a primary key, that automatically makes it an auto-incrementing column, and that works fine.
I'd like to insert a row into the table an... | [Does SQLite support SCOPE\_IDENTITY?](https://stackoverflow.com/questions/304543/does-sqlite-support-scopeidentity)
>
> Check out the [FAQ](http://www.sqlite.org/faq.html#q1). The
> [sqlite3\_last\_insert\_rowid()](http://www.sqlite.org/c3ref/last_insert_rowid.html)
> function will do it. Careful of
> triggers th... |
531,114 | <p>While debugging a program in Xcode I have several <code>CFStringRef</code> variables that point to strings with lengths around the 200 character mark.</p>
<p>In the debugger, it only shows the value of these strings up to a certain length and then just ellipses them away. I'd really like to see the full value of the... | [
{
"answer_id": 531128,
"author": "Jason Coco",
"author_id": 34218,
"author_profile": "https://Stackoverflow.com/users/34218",
"pm_score": 6,
"selected": true,
"text": "<p>In the debugging console you can get the string value by doing something like:</p>\n<pre><code>(gdb) print (void)CFSh... | 2009/02/10 | [
"https://Stackoverflow.com/questions/531114",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49697/"
] | While debugging a program in Xcode I have several `CFStringRef` variables that point to strings with lengths around the 200 character mark.
In the debugger, it only shows the value of these strings up to a certain length and then just ellipses them away. I'd really like to see the full value of the strings.
Is there ... | In the debugging console you can get the string value by doing something like:
```
(gdb) print (void)CFShow(myCFString)
```
or:
```
(gdb) po (NSString*)myCFString
```
Either of those will display the entire string's contents to the debugging console. It's probably the easiest way to deal with large, variable-leng... |
531,126 | <p>Given:</p>
<pre><code>Object nestKey;
Object nestedKey;
Object nestedValue;
Map<T,Map<T,T>> nest;
Map<T,T> nested;
</code></pre>
<p>How is a mapping added to nested where:</p>
<blockquote>
<p>nest.containsKey(nestKey) == true;</p>
</blockquote>
<p>?</p>
<p>Or is there an existing library ... | [
{
"answer_id": 531149,
"author": "amit",
"author_id": 62237,
"author_profile": "https://Stackoverflow.com/users/62237",
"pm_score": 0,
"selected": false,
"text": "<p>Not sure what you mean. I think you want to add to the nested map like the following:</p>\n\n<pre><code>nest.get(nestKey).... | 2009/02/10 | [
"https://Stackoverflow.com/questions/531126",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13491/"
] | Given:
```
Object nestKey;
Object nestedKey;
Object nestedValue;
Map<T,Map<T,T>> nest;
Map<T,T> nested;
```
How is a mapping added to nested where:
>
> nest.containsKey(nestKey) == true;
>
>
>
?
Or is there an existing library of collections that would be more effective? | You mean something like the following *generic method*?
```
static <U,V,W> W putNestedEntry(
Map<U,Map<V,W>> nest,
U nestKey,
V nestedKey,
W nestedValue)
{
Map<V,W> nested = nest.get(nestKey);
if (nested == null)
{
nested = new HashMap<V,W>();
nest.put(nestK... |
531,133 | <p>I love to organize my code, so ideally I want one class per file or, when I have non-member functions, one function per file.</p>
<p>The reasons are:</p>
<ol>
<li><p>When I read the code I will always
know in what file I should find a
certain function or class. </p></li>
<li><p>If it's one class or one non-member
... | [
{
"answer_id": 531141,
"author": "Mr Fooz",
"author_id": 25050,
"author_profile": "https://Stackoverflow.com/users/25050",
"pm_score": 5,
"selected": true,
"text": "<p>IMHO, you should combine items into logical groupings and create your files based on that. </p>\n\n<p>When I'm writing ... | 2009/02/10 | [
"https://Stackoverflow.com/questions/531133",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/60628/"
] | I love to organize my code, so ideally I want one class per file or, when I have non-member functions, one function per file.
The reasons are:
1. When I read the code I will always
know in what file I should find a
certain function or class.
2. If it's one class or one non-member
function per header file, then I won'... | IMHO, you should combine items into logical groupings and create your files based on that.
When I'm writing functions, there are often a half a dozen or so that are tightly related to each other. I tend to put them together in a single header and implementation file.
When I write classes, I usually limit myself to ... |
531,151 | <p>I can get/set registry values using the Microsoft.Win32.Registry class. For example,</p>
<pre><code>Microsoft.Win32.Registry.SetValue(
@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run",
"MyApp",
Application.ExecutablePath);
</code></pre>
<p>But I can't delete any value. How do I delet... | [
{
"answer_id": 531164,
"author": "Sören Kuklau",
"author_id": 1600,
"author_profile": "https://Stackoverflow.com/users/1600",
"pm_score": 1,
"selected": false,
"text": "<p><a href=\"http://msdn.microsoft.com/en-us/library/microsoft.win32.registrykey.deletevalue.aspx\" rel=\"nofollow nore... | 2009/02/10 | [
"https://Stackoverflow.com/questions/531151",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/60200/"
] | I can get/set registry values using the Microsoft.Win32.Registry class. For example,
```
Microsoft.Win32.Registry.SetValue(
@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run",
"MyApp",
Application.ExecutablePath);
```
But I can't delete any value. How do I delete a registry value? | To delete the value set in your question:
```
string keyName = @"Software\Microsoft\Windows\CurrentVersion\Run";
using (RegistryKey key = Registry.CurrentUser.OpenSubKey(keyName, true))
{
if (key == null)
{
// Key doesn't exist. Do whatever you want to handle
// this case
}
else
{
... |
531,157 | <p>I have a text file with a lot of datetime strings in isoformat. The strings are similar to this:</p>
<pre><code>'2009-02-10 16:06:52.598800'
</code></pre>
<p>These strings were generated using <code>str(datetime_object)</code>. The problem is that, for some reason, <code>str(datetime_object)</code> generates a diffe... | [
{
"answer_id": 531203,
"author": "RSabet",
"author_id": 49219,
"author_profile": "https://Stackoverflow.com/users/49219",
"pm_score": 3,
"selected": false,
"text": "<p>Someone has already filed a bug with this issue: <a href=\"http://bugs.python.org/issue1982\" rel=\"noreferrer\">Issue ... | 2009/02/10 | [
"https://Stackoverflow.com/questions/531157",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23657/"
] | I have a text file with a lot of datetime strings in isoformat. The strings are similar to this:
```
'2009-02-10 16:06:52.598800'
```
These strings were generated using `str(datetime_object)`. The problem is that, for some reason, `str(datetime_object)` generates a different format when the datetime object has micro... | Alternatively:
```
from datetime import datetime
def str2datetime(s):
parts = s.split('.')
dt = datetime.strptime(parts[0], "%Y-%m-%d %H:%M:%S")
return dt.replace(microsecond=int(parts[1]))
```
Using `strptime` itself to parse the date/time string (so no need to think up corner cases for a regex). |
531,171 | <p>I am using GenTLB.exe to compile a ridl file to .tlb and _TLB.pas files.</p>
<p>In the resulting _TLB.pas file, there are hints that it has renamed a number of symbols by appending an underscore to the end of the name.</p>
<p>A sample of the hints is:</p>
<pre><code>// Errors:
// Hint: Symbol 'Assign' renamed t... | [
{
"answer_id": 531369,
"author": "BennyBechDk",
"author_id": 34857,
"author_profile": "https://Stackoverflow.com/users/34857",
"pm_score": 3,
"selected": false,
"text": "<p>I am not sure, but often an underscore is appended in front of a name, if the name is conflicting with and exsistin... | 2009/02/10 | [
"https://Stackoverflow.com/questions/531171",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/64439/"
] | I am using GenTLB.exe to compile a ridl file to .tlb and \_TLB.pas files.
In the resulting \_TLB.pas file, there are hints that it has renamed a number of symbols by appending an underscore to the end of the name.
A sample of the hints is:
```
// Errors:
// Hint: Symbol 'Assign' renamed to 'Assign_'
// Hint: Enu... | Assign is renamed to Assign\_ because of a mapping in tlibimp.sym, a INI-format text file in the same directory as `tlibimp`.
Another piece of logic continuously appends '\_' until the name is unique with respect to prior global names `tlibimp` has found. All enumeration members are interpreted as globals. Are there a... |
531,178 | <p>I'm trying to figure out the correct syntax to use the pipe operator |> into the creation of an object. Currently I'm using a static member to create the object and just piping to that. Here is the simplified version.</p>
<pre><code>type Shape =
val points : Vector[]
new (points) =
{ points = po... | [
{
"answer_id": 531229,
"author": "Brian",
"author_id": 19299,
"author_profile": "https://Stackoverflow.com/users/19299",
"pm_score": 5,
"selected": true,
"text": "<p>There's always</p>\n\n<pre><code>(fun args -> new Shape(args))\n</code></pre>\n"
},
{
"answer_id": 531258,
... | 2009/02/10 | [
"https://Stackoverflow.com/questions/531178",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17919/"
] | I'm trying to figure out the correct syntax to use the pipe operator |> into the creation of an object. Currently I'm using a static member to create the object and just piping to that. Here is the simplified version.
```
type Shape =
val points : Vector[]
new (points) =
{ points = points; }
sta... | There's always
```
(fun args -> new Shape(args))
``` |
531,187 | <p>This one is nasty complicated to solve. </p>
<p>I have a table containing date ranges, each date range has a priority. Highest priority means this date range is the most important. </p>
<p>Or in SQL</p>
<pre><code>create table #ranges (Start int, Finish int, Priority int)
insert #ranges values (1 , 10, 0)
ins... | [
{
"answer_id": 531266,
"author": "dkretz",
"author_id": 31641,
"author_profile": "https://Stackoverflow.com/users/31641",
"pm_score": 0,
"selected": false,
"text": "<p>I'm a little confused about what you want to end up with. Is this the same as simply having a set of dates where one ran... | 2009/02/10 | [
"https://Stackoverflow.com/questions/531187",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17174/"
] | This one is nasty complicated to solve.
I have a table containing date ranges, each date range has a priority. Highest priority means this date range is the most important.
Or in SQL
```
create table #ranges (Start int, Finish int, Priority int)
insert #ranges values (1 , 10, 0)
insert #ranges values (2 , 5 , 1... | This is most of the way there, possible improvement would be joining up adjacent ranges of the same priority. It's full of cool trickery.
```
select Start, cast(null as int) as Finish, cast(null as int) as Priority
into #processed
from #ranges
union
select Finish, NULL, NULL
from #ranges
update p
set Finish =... |
531,202 | <p>I was looking at a way to dynamically create thumbnails using PHP and GD but everytime i select a large image maybe 10MegaPixels about 4-5MB it gives the error</p>
<pre><code>**images/Surabhi_Cow.jpgimages/tn/Surabhi_Cow.jpg
Fatal error: Allowed memory size of 31457280 bytes exhausted (tried to allocate 10368 bytes... | [
{
"answer_id": 531207,
"author": "Paolo Bergantino",
"author_id": 16417,
"author_profile": "https://Stackoverflow.com/users/16417",
"pm_score": 2,
"selected": false,
"text": "<p>You want to use <a href=\"http://us.php.net/imagick\" rel=\"nofollow noreferrer\"><code>ImageMagick</code></a>... | 2009/02/10 | [
"https://Stackoverflow.com/questions/531202",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/64445/"
] | I was looking at a way to dynamically create thumbnails using PHP and GD but everytime i select a large image maybe 10MegaPixels about 4-5MB it gives the error
```
**images/Surabhi_Cow.jpgimages/tn/Surabhi_Cow.jpg
Fatal error: Allowed memory size of 31457280 bytes exhausted (tried to allocate 10368 bytes) in C:\Progra... | You want to use [`ImageMagick`](http://us.php.net/imagick). It is much more efficient in handling large images than GD. |
531,212 | <p>On a Linux box, I need to display the average CPU utilisation per hour for the last week. Is that information logged somewhere? Or do I need to write a script that wakes up every 15 minutes to copy <em>/proc/loadavg</em> to a logfile?</p>
<p>EDIT: I'm not allowed to use any tools other than those that come with Li... | [
{
"answer_id": 531228,
"author": "David Z",
"author_id": 56541,
"author_profile": "https://Stackoverflow.com/users/56541",
"pm_score": 5,
"selected": true,
"text": "<p>As far as I know it's not stored anywhere... It's a trivial thing to write, anyway. Just add something like</p>\n\n<pre>... | 2009/02/10 | [
"https://Stackoverflow.com/questions/531212",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39905/"
] | On a Linux box, I need to display the average CPU utilisation per hour for the last week. Is that information logged somewhere? Or do I need to write a script that wakes up every 15 minutes to copy */proc/loadavg* to a logfile?
EDIT: I'm not allowed to use any tools other than those that come with Linux. | As far as I know it's not stored anywhere... It's a trivial thing to write, anyway. Just add something like
```
cat /proc/loadavg >> /var/log/loads
```
to your `crontab`.
Note that there are monitoring tools (like [Munin](http://munin-monitoring.org/)) which can do this kind of thing for you, and generate pretty gr... |
531,224 | <p>I'm trying to setup Django on an internal company server. (No external connection to the Internet.)</p>
<p>Looking over the server setup documentation it appears that the "<a href="http://docs.djangoproject.com/en/dev/howto/deployment/fastcgi/#running-django-on-a-shared-hosting-provider-with-apache" rel="nofollow n... | [
{
"answer_id": 531275,
"author": "Justin Voss",
"author_id": 5616,
"author_profile": "https://Stackoverflow.com/users/5616",
"pm_score": 2,
"selected": false,
"text": "<p>Try using a utility called <a href=\"http://pypi.python.org/pypi/virtualenv\" rel=\"nofollow noreferrer\">virtualenv<... | 2009/02/10 | [
"https://Stackoverflow.com/questions/531224",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24718/"
] | I'm trying to setup Django on an internal company server. (No external connection to the Internet.)
Looking over the server setup documentation it appears that the "[Running Django on a shared-hosting provider with Apache](http://docs.djangoproject.com/en/dev/howto/deployment/fastcgi/#running-django-on-a-shared-hostin... | In your settings you have to point go actual egg file, not directory where egg file is located. It should look something like:
```
sys.path.append('/path/to/flup/egg/flup-1.0.1-py2.5.egg')
``` |
531,230 | <p>When coding new javascript heavy websites, which order or web browser do you code for?</p>
<p>I can see these possible orders, but I am not sure which I like best:</p>
<ol>
<li>Code for one first and get it working well, then start testing with other and fix errors as I go.
<ul>
<li>This will allow for the most r... | [
{
"answer_id": 531233,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 3,
"selected": false,
"text": "<p>Use <a href=\"http://jquery.com\" rel=\"nofollow noreferrer\">jQuery</a> and do them all at once.</p>\n"
},
{
... | 2009/02/10 | [
"https://Stackoverflow.com/questions/531230",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/62248/"
] | When coding new javascript heavy websites, which order or web browser do you code for?
I can see these possible orders, but I am not sure which I like best:
1. Code for one first and get it working well, then start testing with other and fix errors as I go.
* This will allow for the most rapid development (with Fire... | This is sort of a trick question. In my opinion you need to work in this order:
**1: Conform to Standards**
This gets you closest to working in every browser without having to test against every browser. Additionally, you gain the huge benefit that your site should work with any new browser that comes along (Chrome i... |
531,292 | <p>I'm looking to add a "Download this File" function below every video on one of my sites. I need to force the user to download the file, instead of just linking to it, since that begins playing a file in the browser sometimes. The problem is, the video files are stored on a separate server. </p>
<p>Any way I can for... | [
{
"answer_id": 531294,
"author": "Paolo Bergantino",
"author_id": 16417,
"author_profile": "https://Stackoverflow.com/users/16417",
"pm_score": 7,
"selected": true,
"text": "<p>You could try something like this:</p>\n<pre><code><?php\n\n// Locate.\n$file_name = 'file.avi';\n$file_url ... | 2009/02/10 | [
"https://Stackoverflow.com/questions/531292",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm looking to add a "Download this File" function below every video on one of my sites. I need to force the user to download the file, instead of just linking to it, since that begins playing a file in the browser sometimes. The problem is, the video files are stored on a separate server.
Any way I can force the dow... | You could try something like this:
```
<?php
// Locate.
$file_name = 'file.avi';
$file_url = 'http://www.myremoteserver.com/' . $file_name;
// Configure.
header('Content-Type: application/octet-stream');
header("Content-Transfer-Encoding: Binary");
header("Content-disposition: attachment; filename=\"".$file_name."\... |
531,304 | <p>sports.jsp:</p>
<pre><code><?xml version="1.0" encoding="UTF-8"?>
<%@ page contentType="text/xml;charset=ISO-8859-1" %>
<% response.setHeader("Content-Disposition", "attachment; filename=\"playlist.xml\""); %>
<playlist version="1" xmlns = "http://xspf.org/ns/0/">
<title>My Band Ro... | [
{
"answer_id": 531310,
"author": "Bhushan Bhangale",
"author_id": 57423,
"author_profile": "https://Stackoverflow.com/users/57423",
"pm_score": 1,
"selected": false,
"text": "<p>You cannot do that due to security restrictions. You cannot get access of user system and start writing files ... | 2009/02/10 | [
"https://Stackoverflow.com/questions/531304",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/59649/"
] | sports.jsp:
```
<?xml version="1.0" encoding="UTF-8"?>
<%@ page contentType="text/xml;charset=ISO-8859-1" %>
<% response.setHeader("Content-Disposition", "attachment; filename=\"playlist.xml\""); %>
<playlist version="1" xmlns = "http://xspf.org/ns/0/">
<title>My Band Rocks Your Socks</title>
<trackList>
<%!... | You're asking for a feature that no browser wants to provide, due to security risks. You don't want a browser to be able to overwrite an arbitrary file on the system with no user prompt.
If you really need to do this, you need to be running a signed Applet or Web Start application. With this, you have permission to wr... |
531,311 | <p>I render a page using YUI. and depending on the user I need to change how it is rendered. This change is not something that can be parametrized, it is drastic and different for each user.</p>
<p>Please tell me how can I generate Javascript dynamically?</p>
| [
{
"answer_id": 531319,
"author": "M.N",
"author_id": 18615,
"author_profile": "https://Stackoverflow.com/users/18615",
"pm_score": 2,
"selected": false,
"text": "<p>You can probably create two separate Java script files, and include the required file, depending upon the user type.</p>\n\... | 2009/02/10 | [
"https://Stackoverflow.com/questions/531311",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/54082/"
] | I render a page using YUI. and depending on the user I need to change how it is rendered. This change is not something that can be parametrized, it is drastic and different for each user.
Please tell me how can I generate Javascript dynamically? | I personally use a PHP file to pass a JavaScript object made up of some basic session and internal settings, nothing mission-critical as passing information to the client isn't overly secure, but I believe it might follow the same principles as what you are looking for.
Similarly, I use this to display certain element... |
531,344 | <p>Currently it seems that I can only use effects in their most basic form when using the Dialog widget. For example, the following will use the drop effect for both showing and hiding the dialog box:</p>
<pre><code>$('#dialog').dialog({show:'drop', hide:'drop'});
</code></pre>
<p>However, the default for the drop m... | [
{
"answer_id": 531582,
"author": "Steerpike",
"author_id": 60598,
"author_profile": "https://Stackoverflow.com/users/60598",
"pm_score": 0,
"selected": false,
"text": "<p>You may find this link of <a href=\"http://labs.cloudream.name/jquery/dialog/dialog.html\" rel=\"nofollow noreferrer\... | 2009/02/10 | [
"https://Stackoverflow.com/questions/531344",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1376/"
] | Currently it seems that I can only use effects in their most basic form when using the Dialog widget. For example, the following will use the drop effect for both showing and hiding the dialog box:
```
$('#dialog').dialog({show:'drop', hide:'drop'});
```
However, the default for the drop method always drops to the l... | This is currently not Possible with 1.6 and 1.7.1. |
531,352 | <p>I have a Container with Opacity 0.3</p>
<pre><code>$('#containerFeatured').css('opacity',0.3)
</code></pre>
<p>The fact is that when I try to overlay a DIV wrap with images the opacity takes the whole DIV. I tried with z-index but nothing happens.</p>
<p><a href="http://ivorbluecss.s3.amazonaws.com/index.html" re... | [
{
"answer_id": 531381,
"author": "euge1979",
"author_id": 62713,
"author_profile": "https://Stackoverflow.com/users/62713",
"pm_score": 2,
"selected": false,
"text": "<p>When you specify the opacity of an element (i.e. div), that opacity will apply to its child elements too. An obvious w... | 2009/02/10 | [
"https://Stackoverflow.com/questions/531352",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a Container with Opacity 0.3
```
$('#containerFeatured').css('opacity',0.3)
```
The fact is that when I try to overlay a DIV wrap with images the opacity takes the whole DIV. I tried with z-index but nothing happens.
[My example here](http://ivorbluecss.s3.amazonaws.com/index.html)
Thank you! | When you specify the opacity of an element (i.e. div), that opacity will apply to its child elements too. An obvious way around this is to get your non-transparent content outside of the div and use CSS positioning. |
531,371 | <p>What is the use of a Junit <code>@Before</code> and <code>@Test</code> annotations in java? How can I use them with netbeans?</p>
| [
{
"answer_id": 531385,
"author": "guerda",
"author_id": 32043,
"author_profile": "https://Stackoverflow.com/users/32043",
"pm_score": 5,
"selected": false,
"text": "<ol>\n<li><p>If I understood you correctly, you want to know, what the annotation <a href=\"http://junit.sourceforge.net/ja... | 2009/02/10 | [
"https://Stackoverflow.com/questions/531371",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | What is the use of a Junit `@Before` and `@Test` annotations in java? How can I use them with netbeans? | Can you be more precise?
Do you need to understand what are `@Before` and `@Test` annotation?
`@Test` annotation is an annotation (since JUnit 4) that indicates the attached method is an unit test. That allows you to use any method name to have a test. For example:
```
@Test
public void doSomeTestOnAMethod() {
// Y... |
531,380 | <p>Can I initialize an instance variable in Java, when I initialise it when I declare it, and initialise it with the return value of a method, which I define later in the class. </p>
<p>Something like this:</p>
<pre><code>public class MyClass {
integers[] myArray = new integers[length()];
int length() {
... | [
{
"answer_id": 531394,
"author": "kmkaplan",
"author_id": 50902,
"author_profile": "https://Stackoverflow.com/users/50902",
"pm_score": -1,
"selected": false,
"text": "<p>You have to make the method static:</p>\n\n<pre><code>static int length() { … }\n</code></pre>\n"
},
{
"answe... | 2009/02/10 | [
"https://Stackoverflow.com/questions/531380",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42155/"
] | Can I initialize an instance variable in Java, when I initialise it when I declare it, and initialise it with the return value of a method, which I define later in the class.
Something like this:
```
public class MyClass {
integers[] myArray = new integers[length()];
int length() {
....
}
}
`... | Seems to work fine for me, with the method static or not static:
```
public class test
{
public int[] myarray = new int[this.length()];
public int length() {
return 5;
}
public static void main(String[] args)
{
test foo = new test();
for (int element : foo.myarray) {
... |
531,384 | <p>I have a class.</p>
<pre><code>Public Class Foo
Private _Name As String
Public Property Name() As String
Get
Return _Name
End Get
Set(ByVal value As String)
_Name = value
End Set
End Property
Private _Age As String
Public Property Age() As... | [
{
"answer_id": 531388,
"author": "Brannon",
"author_id": 5745,
"author_profile": "https://Stackoverflow.com/users/5745",
"pm_score": 9,
"selected": true,
"text": "<p>Use Reflection:</p>\n\n<pre><code>Type type = obj.GetType();\nPropertyInfo[] properties = type.GetProperties();\n\nforeach... | 2009/02/10 | [
"https://Stackoverflow.com/questions/531384",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/62889/"
] | I have a class.
```
Public Class Foo
Private _Name As String
Public Property Name() As String
Get
Return _Name
End Get
Set(ByVal value As String)
_Name = value
End Set
End Property
Private _Age As String
Public Property Age() As String
... | Use Reflection:
```
Type type = obj.GetType();
PropertyInfo[] properties = type.GetProperties();
foreach (PropertyInfo property in properties)
{
Console.WriteLine("Name: " + property.Name + ", Value: " + property.GetValue(obj, null));
}
```
for Excel - what tools/reference item must be added to gain access to B... |
531,427 | <p>This must come up very often.</p>
<p>When the user is editing preferences in an Android app, I'd like them to be able to see the currently set value of the preference in the <code>Preference</code> summary.</p>
<p>Example: if I have a Preference setting for "Discard old messages" that specifies the number of days ... | [
{
"answer_id": 2888607,
"author": "DozenCrows",
"author_id": 167880,
"author_profile": "https://Stackoverflow.com/users/167880",
"pm_score": 7,
"selected": false,
"text": "<p>There are ways to make this a more generic solution, if that suits your needs.</p>\n\n<p>For example, if you want... | 2009/02/10 | [
"https://Stackoverflow.com/questions/531427",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35112/"
] | This must come up very often.
When the user is editing preferences in an Android app, I'd like them to be able to see the currently set value of the preference in the `Preference` summary.
Example: if I have a Preference setting for "Discard old messages" that specifies the number of days after which messages need to... | There are ways to make this a more generic solution, if that suits your needs.
For example, if you want to generically have all list preferences show their choice as summary, you could have this for your `onSharedPreferenceChanged` implementation:
```
public void onSharedPreferenceChanged(SharedPreferences sharedPref... |
531,429 | <p>After reading <a href="http://www.codinghorror.com/blog/archives/001174.html" rel="nofollow noreferrer">Jeff's article</a> about the importance of sitemaps, so I decided to generate one for my dynamic website.</p>
<p>I saw some articles about how to implement it with ASP.NET but every solution I saw showed how to g... | [
{
"answer_id": 2888607,
"author": "DozenCrows",
"author_id": 167880,
"author_profile": "https://Stackoverflow.com/users/167880",
"pm_score": 7,
"selected": false,
"text": "<p>There are ways to make this a more generic solution, if that suits your needs.</p>\n\n<p>For example, if you want... | 2009/02/10 | [
"https://Stackoverflow.com/questions/531429",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/50468/"
] | After reading [Jeff's article](http://www.codinghorror.com/blog/archives/001174.html) about the importance of sitemaps, so I decided to generate one for my dynamic website.
I saw some articles about how to implement it with ASP.NET but every solution I saw showed how to generate it on the fly [with an HTTP Handler](ht... | There are ways to make this a more generic solution, if that suits your needs.
For example, if you want to generically have all list preferences show their choice as summary, you could have this for your `onSharedPreferenceChanged` implementation:
```
public void onSharedPreferenceChanged(SharedPreferences sharedPref... |
531,431 | <p>I have a class as follows</p>
<pre><code>Public Class Foo
Private _Name As String
<ShowInDisplay()> _
Public Property Name() As String
Get
Return _Name
End Get
Set(ByVal value As String)
_Name = value
End Set
End Property
Private _Ag... | [
{
"answer_id": 531435,
"author": "Brannon",
"author_id": 5745,
"author_profile": "https://Stackoverflow.com/users/5745",
"pm_score": 3,
"selected": true,
"text": "<p><strong>Edit</strong>: Updated with correct VB <code>GetType()</code> call:</p>\n\n<pre><code>If _Property.IsDefined(GetTy... | 2009/02/10 | [
"https://Stackoverflow.com/questions/531431",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/62889/"
] | I have a class as follows
```
Public Class Foo
Private _Name As String
<ShowInDisplay()> _
Public Property Name() As String
Get
Return _Name
End Get
Set(ByVal value As String)
_Name = value
End Set
End Property
Private _Age As String
Publ... | **Edit**: Updated with correct VB `GetType()` call:
```
If _Property.IsDefined(GetType(ShowInDisplayAttribute), True) Then
``` |
531,438 | <p><strong>I need to be able to trigger a event whenever an object is added to a <code>Queue<Delegate></code>.</strong></p>
<p>I created a new class that extends <code>Queue</code>: </p>
<pre><code>public delegate void ChangedEventHandler(object sender, EventArgs e);
public class QueueWithChange<Delegate>... | [
{
"answer_id": 531444,
"author": "Krzysztof Kozmic",
"author_id": 13163,
"author_profile": "https://Stackoverflow.com/users/13163",
"pm_score": 0,
"selected": false,
"text": "<p>You have to override Enqueue, to call OnChanged.</p>\n"
},
{
"answer_id": 531450,
"author": "Marc ... | 2009/02/10 | [
"https://Stackoverflow.com/questions/531438",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44084/"
] | **I need to be able to trigger a event whenever an object is added to a `Queue<Delegate>`.**
I created a new class that extends `Queue`:
```
public delegate void ChangedEventHandler(object sender, EventArgs e);
public class QueueWithChange<Delegate> : Queue<Delegate>
{
public event ChangedEventHandler Changed;
... | If you mean the non-generic `Queue` class, then you can just override `Enqueue`:
```
public override void Enqueue(object obj)
{
base.Enqueue(obj);
OnChanged(EventArgs.Empty);
}
```
However, if you mean the generic `Queue<T>` class, then note that there is no suitable virtual method to override. You might do ... |
531,452 | <p>How does it actually reduce noise..can you suggest some nice tutorials?</p>
| [
{
"answer_id": 532074,
"author": "John D. Cook",
"author_id": 25188,
"author_profile": "https://Stackoverflow.com/users/25188",
"pm_score": 4,
"selected": false,
"text": "<p>One way to use SVD to reduce noise is to do the decomposition, set components that are near zero to be exactly zer... | 2009/02/10 | [
"https://Stackoverflow.com/questions/531452",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | How does it actually reduce noise..can you suggest some nice tutorials? | SVD can be understood from a geometric sense for square matrices as a transformation on a vector.
Consider a square n x n matrix M multiplying a vector v to produce an output vector w:
```
w = M*v
```
The singular value decomposition M is the product of three matrices `M=U*S*V`, so `w=U*S*V*v`. U and V are orthonor... |