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 |
|---|---|---|---|---|---|---|
382,382 | <p>Is there any way in JavaScript how to find out user clicked through the same domain 2 or more times? </p>
<p>I need to popup a window after user clicked anywhere on the site for 3 times. I know how to do it after one click - with <code>document.referrer</code> or <code>addEventListener</code>, but then I'm lost.</p... | [
{
"answer_id": 382400,
"author": "Anirvan",
"author_id": 31100,
"author_profile": "https://Stackoverflow.com/users/31100",
"pm_score": 2,
"selected": false,
"text": "<p>Sure. You need to store a list of users' click events, either in a cookie, or in a server-side data store. On every rec... | 2008/12/19 | [
"https://Stackoverflow.com/questions/382382",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46866/"
] | Is there any way in JavaScript how to find out user clicked through the same domain 2 or more times?
I need to popup a window after user clicked anywhere on the site for 3 times. I know how to do it after one click - with `document.referrer` or `addEventListener`, but then I'm lost.
I need something that will captur... | I tried this and it worked fine:
```
window.onload = function() {
var clicked = readCookie('popunder');
if(clicked == null) {
clicked = 0;
}
var allLinks = document.getElementsByTagName("a");
for(i=0;i<=allLinks.length;i++) {
allLinks[i].addEventListener("click",countClicks,true);
... |
382,383 | <p>I am working on an ASP.NET page that we, in code impersonate the requesting user. We are using the following code to start impersonating.</p>
<pre><code>Dim impersonationContext As System.Security.Principal.WindowsImpersonationContext
Dim currentWindowsIdentity As System.Security.Principal.WindowsIdentity
currentW... | [
{
"answer_id": 382436,
"author": "Dan Esparza",
"author_id": 19020,
"author_profile": "https://Stackoverflow.com/users/19020",
"pm_score": 0,
"selected": false,
"text": "<p>I know that I've used impersonation in ASP.NET before (using C# and accessing the filesystem) and I was wondering i... | 2008/12/19 | [
"https://Stackoverflow.com/questions/382383",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13279/"
] | I am working on an ASP.NET page that we, in code impersonate the requesting user. We are using the following code to start impersonating.
```
Dim impersonationContext As System.Security.Principal.WindowsImpersonationContext
Dim currentWindowsIdentity As System.Security.Principal.WindowsIdentity
currentWindowsIdentity ... | I think @John Sonmez is right, you're hitting the Double Hop issue. Impersonation is only half of the story, you also need to look at Delegation (assuming your network is using Kerberos authentication). The articles below were the most useful in helping me through the same issue
[Impersonation and Delegation](http://m... |
382,406 | <p>We're on Team Foundation Server 2008 and I'm trying to find a way to report on the change in completed work from week to week at the task level. The MDX query below works pretty well, but I'd like to get rid of need to hard code last week's date. I've tried using prevmember and parallelperiod without success, but I'... | [
{
"answer_id": 382985,
"author": "sliderhouserules",
"author_id": 31385,
"author_profile": "https://Stackoverflow.com/users/31385",
"pm_score": 2,
"selected": false,
"text": "<p>Look at the provided Work Completed report. It automatically sets one of its date fields to today minus one mo... | 2008/12/19 | [
"https://Stackoverflow.com/questions/382406",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/162/"
] | We're on Team Foundation Server 2008 and I'm trying to find a way to report on the change in completed work from week to week at the task level. The MDX query below works pretty well, but I'd like to get rid of need to hard code last week's date. I've tried using prevmember and parallelperiod without success, but I'm n... | Look at the provided Work Completed report. It automatically sets one of its date fields to today minus one month.
EDIT: Just logged into my work system to double check on this. The report is actually called "Remaining Work". Go to the SharePoint portal that was created for your Team Project, and find the list of stan... |
382,418 | <p>I'm wondering if anyone knows how this happens? My website is down, but every computer on my internet connection/router can see it. I've cleared my cache etc, but another computer in the house shouldn't be seeing a site that's offline. How weird?</p>
<p>It's hosted remotely, not on my network or anything. </p>
| [
{
"answer_id": 382419,
"author": "tunnuz",
"author_id": 25418,
"author_profile": "https://Stackoverflow.com/users/25418",
"pm_score": 1,
"selected": false,
"text": "<p>Internet provider cache maybe.</p>\n"
},
{
"answer_id": 382424,
"author": "Ben",
"author_id": 11522,
... | 2008/12/19 | [
"https://Stackoverflow.com/questions/382418",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42589/"
] | I'm wondering if anyone knows how this happens? My website is down, but every computer on my internet connection/router can see it. I've cleared my cache etc, but another computer in the house shouldn't be seeing a site that's offline. How weird?
It's hosted remotely, not on my network or anything. | Do you know the IP address of your web server?
Do you have direct access to the Internet on port 80?
Tell if your server is up or down by doing the following
```
telnet 255.255.255.255 80
```
Where 255.255.255.255 is your web server's IP address. On windows the screen will go blank if the server answers. Then ty... |
382,464 | <p>When I upload a file to a site using the ASP:File control the FileName property is different in IE and Firefox. In Firefox, it just provides the name of the file, but IE provides the full path to the file.</p>
<p>I have worked around this by adding the code:</p>
<pre><code>Dim FileName As String = file.FileName
I... | [
{
"answer_id": 382604,
"author": "Ryan Cook",
"author_id": 43029,
"author_profile": "https://Stackoverflow.com/users/43029",
"pm_score": 5,
"selected": true,
"text": "<p>This is a security/privacy concern, firefox/mozilla is doing it right and you will not get a way to get the full path ... | 2008/12/19 | [
"https://Stackoverflow.com/questions/382464",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10420/"
] | When I upload a file to a site using the ASP:File control the FileName property is different in IE and Firefox. In Firefox, it just provides the name of the file, but IE provides the full path to the file.
I have worked around this by adding the code:
```
Dim FileName As String = file.FileName
If FileName.LastIndexOf... | This is a security/privacy concern, firefox/mozilla is doing it right and you will not get a way to get the full path without an add-in, applet, silverlight, flash or some other mechanism.
Here is more info on Mozilla's stance:
<https://developer.mozilla.org/en/Updating_web_applications_for_Firefox_3>
See the sectio... |
382,466 | <p>I never actually thought I'd run into speed-issues with python, but I have. I'm trying to compare really big lists of dictionaries to each other based on the dictionary values. I compare two lists, with the first like so</p>
<pre><code>biglist1=[{'transaction':'somevalue', 'id':'somevalue', 'date':'somevalue' ...},... | [
{
"answer_id": 382483,
"author": "J S",
"author_id": 25676,
"author_profile": "https://Stackoverflow.com/users/25676",
"pm_score": 2,
"selected": false,
"text": "<p>What you want to do is to use correct data structures: </p>\n\n<ol>\n<li><p>Create a dictionary of mappings of tuples of ot... | 2008/12/19 | [
"https://Stackoverflow.com/questions/382466",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40372/"
] | I never actually thought I'd run into speed-issues with python, but I have. I'm trying to compare really big lists of dictionaries to each other based on the dictionary values. I compare two lists, with the first like so
```
biglist1=[{'transaction':'somevalue', 'id':'somevalue', 'date':'somevalue' ...}, {'transactio'... | Index on the fields you want to use for lookup. O(n+m)
```
matches = []
biglist1_indexed = {}
for item in biglist1:
biglist1_indexed[(item["transaction"], item["date"])] = item
for item in biglist2:
if (item["transaction"], item["date"]) in biglist1_indexed:
matches.append(item)
```
This is probabl... |
382,471 | <p>We have an issue with the way we are creating a <code>Mutex</code>. The problem line is: </p>
<pre><code>MutexAccessRule rule = new MutexAccessRule("Everyone", MutexRights.FullControl, AccessControlType.Allow);
</code></pre>
<p>The hardcoded "Everyone" string only works on English OSes, how do we change this line ... | [
{
"answer_id": 382476,
"author": "Sam Saffron",
"author_id": 17174,
"author_profile": "https://Stackoverflow.com/users/17174",
"pm_score": 5,
"selected": true,
"text": "<p>Google is being helpful today: </p>\n\n<p>Looks like <a href=\"http://www.hanselman.com/blog/FindingOutTheNameOfTheE... | 2008/12/19 | [
"https://Stackoverflow.com/questions/382471",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17174/"
] | We have an issue with the way we are creating a `Mutex`. The problem line is:
```
MutexAccessRule rule = new MutexAccessRule("Everyone", MutexRights.FullControl, AccessControlType.Allow);
```
The hardcoded "Everyone" string only works on English OSes, how do we change this line so it works in all languages? | Google is being helpful today:
Looks like [this will help](http://www.hanselman.com/blog/FindingOutTheNameOfTheEVERYONEGroupOnANonenglishInternationalVersionOfWindows.aspx)
This code solves this problem:
```
SecurityIdentifier sid = new SecurityIdentifier(WellKnownSidType.WorldSid, null);
MutexAccessRule rule... |
382,473 | <p>I'm trying to write a Cucumber scenario that requires me to have a logged in user - that would normally be quite simple but I'm only using OpenID authentication (curtosy of the authentication plugin). However after digging through the open_id_authentication plugins guts I'm not sure how I could achieve this within C... | [
{
"answer_id": 382597,
"author": "DEfusion",
"author_id": 6432,
"author_profile": "https://Stackoverflow.com/users/6432",
"pm_score": 3,
"selected": true,
"text": "<p>I've figured out a way, if you place this in your features/support/env.rb:</p>\n\n<pre><code>ActionController::Base.class... | 2008/12/19 | [
"https://Stackoverflow.com/questions/382473",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6432/"
] | I'm trying to write a Cucumber scenario that requires me to have a logged in user - that would normally be quite simple but I'm only using OpenID authentication (curtosy of the authentication plugin). However after digging through the open\_id\_authentication plugins guts I'm not sure how I could achieve this within Cu... | I've figured out a way, if you place this in your features/support/env.rb:
```
ActionController::Base.class_eval do
private
def begin_open_id_authentication(identity_url, options = {})
yield OpenIdAuthentication::Result.new(:successful), identity_url, nil
end
end
```
Then you can just do something like t... |
382,474 | <p>Is there a version of JDE for emacs that supports the JDK 6.10? I haven't been able to find any information on this. While it runs, every time I attempt to compile files the JDE says that it doesn't recognize my JDK version and reverts to assuming it is a Java5 version. </p>
| [
{
"answer_id": 382842,
"author": "Charlie Martin",
"author_id": 35092,
"author_profile": "https://Stackoverflow.com/users/35092",
"pm_score": 1,
"selected": false,
"text": "<p>You can set your paths up in the configuration settings by \"registering\" a JDK version using <code>M-x customi... | 2008/12/19 | [
"https://Stackoverflow.com/questions/382474",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41241/"
] | Is there a version of JDE for emacs that supports the JDK 6.10? I haven't been able to find any information on this. While it runs, every time I attempt to compile files the JDE says that it doesn't recognize my JDK version and reverts to assuming it is a Java5 version. | I've made following customizations for JDE:
```
'(jde-bug-debugger-host-address "127.0.0.1")
'(jde-bug-jre-home "/usr/lib/jvm/java-6-sun")
'(jde-compile-option-debug (quote ("all" (t nil nil))))
'(jde-debugger (quote ("jdb")))
'(jde-global-classpath (quote ("." "/usr/share/java/" "/usr/lib/jvm/java-6-sun/")))
'(jde-jd... |
382,475 | <p>I have an MFC wrapper over a COM object. There is a function that takes a large number of options, which are mostly optional. How do I pass some arguments but not others? </p>
<p>For what it's worth, the optional arguments are listed as VARIANT*.</p>
<p>Below is the code</p>
<pre><code>CComVariant vFalse = fal... | [
{
"answer_id": 382670,
"author": "1800 INFORMATION",
"author_id": 3146,
"author_profile": "https://Stackoverflow.com/users/3146",
"pm_score": -1,
"selected": false,
"text": "<p>An unspecified variant is normally VT_EMPTY:</p>\n\n<pre><code>_variant_t vtEmpty(VT_EMPTY);\n</code></pre>\n\n... | 2008/12/19 | [
"https://Stackoverflow.com/questions/382475",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4066/"
] | I have an MFC wrapper over a COM object. There is a function that takes a large number of options, which are mostly optional. How do I pass some arguments but not others?
For what it's worth, the optional arguments are listed as VARIANT\*.
Below is the code
```
CComVariant vFalse = false;
CApplication application;
... | To skip an optional parameter in a COM method pass a VARIANT of type VT\_ERROR and the error code must by DISP\_E\_PARAMNOTFOUND.
```
CComVariant vtOptional;
vtOptional.vt = VT_ERROR;
vtOptional.scode = DISP_E_PARAMNOTFOUND;
```
Now you can use vtOptional as a parameter you don't want to specify if the parameter is ... |
382,478 | <p>I've read a lot recently about how writing multi-threaded apps is a huge pain in the neck, and have learned enough about the topic to understand, at least at some level, why it is so. </p>
<p>I've read that using functional programming techniques can help alleviate some of this pain, but I've never seen a simple e... | [
{
"answer_id": 382489,
"author": "Yuval Adam",
"author_id": 24545,
"author_profile": "https://Stackoverflow.com/users/24545",
"pm_score": 1,
"selected": false,
"text": "<p>Concurrency is quite a complicated subject in computer science, which demands good understanding of hardware archite... | 2008/12/19 | [
"https://Stackoverflow.com/questions/382478",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30529/"
] | I've read a lot recently about how writing multi-threaded apps is a huge pain in the neck, and have learned enough about the topic to understand, at least at some level, why it is so.
I've read that using functional programming techniques can help alleviate some of this pain, but I've never seen a simple example of f... | I'll add an example of how functional code can be used to *safely* make code concurrent.
Here is some code you might want to do in parallel, so you don't have wait for one file to finish to start downloading the next:
```
void DownloadHTMLFiles(List<string> urls)
{
foreach(string url in urls)
{
Down... |
382,479 | <p>I am using log4net in my .NET 3.5 console application and would like the log messages I generate to be seen in both the console standard out and the RollingFileAppender. The file output is working like a charm, but I am seeing a stream of status messages flowing to the console standard out when I execute. I would li... | [
{
"answer_id": 383562,
"author": "alexandrul",
"author_id": 19756,
"author_profile": "https://Stackoverflow.com/users/19756",
"pm_score": 2,
"selected": false,
"text": "<p>Please try to replicate the problem using a new project one step at the time (first reference log4net with no append... | 2008/12/19 | [
"https://Stackoverflow.com/questions/382479",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am using log4net in my .NET 3.5 console application and would like the log messages I generate to be seen in both the console standard out and the RollingFileAppender. The file output is working like a charm, but I am seeing a stream of status messages flowing to the console standard out when I execute. I would like ... | I just went through this same problem (which, unsurprisingly, is how I found this question).
Anyway, my problem, and possibly yours as well, was caused by a web/app config file setting of "`<`log4net debug=true`>`". Too obvious, right? I had pasted the skeleton of my app.config settings in from a web snippet, and had ... |
382,485 | <p>I'm looking for something like <code>break</code> for loops.</p>
<p>Here's some example code (using Symfony's lime) where <code>stop()</code> would not let the class continue and <code>I_DONT_WANT_THIS_TO_RUN()</code> would not be executed.</p>
<pre><code>$browser->isStatusCode(200)
->isRequestParameter('m... | [
{
"answer_id": 382510,
"author": "Paige Ruten",
"author_id": 813,
"author_profile": "https://Stackoverflow.com/users/813",
"pm_score": 3,
"selected": false,
"text": "<p>You could use <a href=\"http://php.net/exceptions\" rel=\"noreferrer\">PHP exceptions</a>:</p>\n\n<pre><code>// This fu... | 2008/12/19 | [
"https://Stackoverflow.com/questions/382485",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46443/"
] | I'm looking for something like `break` for loops.
Here's some example code (using Symfony's lime) where `stop()` would not let the class continue and `I_DONT_WANT_THIS_TO_RUN()` would not be executed.
```
$browser->isStatusCode(200)
->isRequestParameter('module', 'home')
->isRequestParameter('action', 'index')
... | Just return another class which will return $this for every method called.
Example:
```
class NoMethods {
public function __call($name, $args)
{
echo __METHOD__ . " called $name with " . count($args) . " arguments.\n";
return $this;
}
}
class Browser {
public function runThis()
{
... |
382,487 | <p>Does anyone know how to install IronPython 2.0 with NGEN'ed binaries using the MSI package? The <a href="http://www.codeplex.com/IronPython" rel="nofollow noreferrer">official IronPython homepage</a> says that the NGEN option will greatly improve startup time, but for some reason it is not enabled by default. It d... | [
{
"answer_id": 382508,
"author": "Igal Serban",
"author_id": 25737,
"author_profile": "https://Stackoverflow.com/users/25737",
"pm_score": 1,
"selected": false,
"text": "<p><strong>Update 1:</strong>\nIf you are using scripts for mass distribution, Then you can probably just ngen from yo... | 2008/12/19 | [
"https://Stackoverflow.com/questions/382487",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38087/"
] | Does anyone know how to install IronPython 2.0 with NGEN'ed binaries using the MSI package? The [official IronPython homepage](http://www.codeplex.com/IronPython) says that the NGEN option will greatly improve startup time, but for some reason it is not enabled by default. It doesn't actually state which MSI parameters... | Try passing in NGENDLLS=True from the commandline. |
382,527 | <p>I run into this regularly, and am just looking for best practice/approach. I have a database / datamodule-containing app, and want to fire up the database/datasets on startup w/o having "active at runtime" set to true at design time (database location varies). Also run a web "check for updates" routine when the ap... | [
{
"answer_id": 382585,
"author": "Steve",
"author_id": 22712,
"author_profile": "https://Stackoverflow.com/users/22712",
"pm_score": 1,
"selected": false,
"text": "<p>I'm not sure I understand why you need the global variables? Nowadays I write ALL my Delphi apps without a single global ... | 2008/12/19 | [
"https://Stackoverflow.com/questions/382527",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32303/"
] | I run into this regularly, and am just looking for best practice/approach. I have a database / datamodule-containing app, and want to fire up the database/datasets on startup w/o having "active at runtime" set to true at design time (database location varies). Also run a web "check for updates" routine when the app sta... | I generally always turn off auto creation of all forms EXCEPT for the main form and possibly the primary datamodule.
One trick that I learned you can do, is add your datamodule to your project, allow it to auto-create and create BEFORE your main form. Then, when your main form is created, the onCreate for the datamodu... |
382,535 | <p>We have an SPItemEventReceiver compiled into its own assembly. </p>
<p>We are using STSDev to package up a SharePoint solution with this EventReceiver as a feature. I am not assigning the SPItemEventReceiver to a specific ListTemplateId within the elements.xml, but am instead linking a ReceiverAssembly in the fea... | [
{
"answer_id": 383014,
"author": "Bjørn Furuknap",
"author_id": 28382,
"author_profile": "https://Stackoverflow.com/users/28382",
"pm_score": 0,
"selected": false,
"text": "<p>I am not sure what you want with the upgrade, whether you want the new event handler to be applied to old lists ... | 2008/12/19 | [
"https://Stackoverflow.com/questions/382535",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1048/"
] | We have an SPItemEventReceiver compiled into its own assembly.
We are using STSDev to package up a SharePoint solution with this EventReceiver as a feature. I am not assigning the SPItemEventReceiver to a specific ListTemplateId within the elements.xml, but am instead linking a ReceiverAssembly in the feature.xml and... | Maybe you can encapsulate the logic that is prone to change into a separate assembly, that is referenced and used by your event handler. This way, the event handler itself won't change have to change, you would only deploy the updated "logic" assembly to the GAC or bin directory(ies) appropriately.
HTH,
jt |
382,564 | <p>The ProxyMetaClass and Iterceptor classes for intercepting arbitrary Groovy method calls is well documented. Is there also a way to intercept property accesses? When I try to do this by intercepting "getProperty", I still get the error message:</p>
<p>groovy.lang.MissingPropertyException: No such property: foo</p... | [
{
"answer_id": 384081,
"author": "Ted Naleid",
"author_id": 8912,
"author_profile": "https://Stackoverflow.com/users/8912",
"pm_score": 1,
"selected": false,
"text": "<p>I'm not completely sure about the use-case that you're trying to solve, but likely you want one of either <a href=\"ht... | 2008/12/19 | [
"https://Stackoverflow.com/questions/382564",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33897/"
] | The ProxyMetaClass and Iterceptor classes for intercepting arbitrary Groovy method calls is well documented. Is there also a way to intercept property accesses? When I try to do this by intercepting "getProperty", I still get the error message:
groovy.lang.MissingPropertyException: No such property: foo | I'm not completely sure about the use-case that you're trying to solve, but likely you want one of either [propertyMissing](http://groovy.codehaus.org/Using+methodMissing+and+propertyMissing) or [getProperty (or maybe invokeMethod)](http://groovy.codehaus.org/Using+invokeMethod+and+getProperty).
The first will let you... |
382,576 | <p>I have a .xib file containing a UIView and 2 UILabel subviews linked to a class named Note with outlets assigned to each label appropriately, the definition for this class contains the following.</p>
<pre><code>@interface Note : UIView {
IBOutlet UILabel *time;
IBOutlet UILabel *content;
}
</code></pre>
<p... | [
{
"answer_id": 382659,
"author": "bjartek",
"author_id": 23914,
"author_profile": "https://Stackoverflow.com/users/23914",
"pm_score": -1,
"selected": false,
"text": "<p>I belive you are correct. See the documentation links below for more details. </p>\n\n<p>Documentation:</p>\n\n<ul>\n<... | 2008/12/19 | [
"https://Stackoverflow.com/questions/382576",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26986/"
] | I have a .xib file containing a UIView and 2 UILabel subviews linked to a class named Note with outlets assigned to each label appropriately, the definition for this class contains the following.
```
@interface Note : UIView {
IBOutlet UILabel *time;
IBOutlet UILabel *content;
}
```
I'm constructing this wit... | This is correct for the iPhone; it would not be correct on the Mac, though.
However, you may want to rework this code. It isn't safe to assume that the view will be the last object loaded from the nib. I'd suggest instead that you either connect it to a "note" outlet in your view controller or scan the list for an obj... |
382,587 | <p>Further to <a href="https://stackoverflow.com/questions/26551/how-to-pass-command-line-parameters-in-batch-file">How to Pass Command Line Parameters in batch file</a> how does one get the rest of the parameters with specifying them exactly? I don't want to use SHIFT because I don't know how many parameters there mig... | [
{
"answer_id": 382785,
"author": "Patrick Cuff",
"author_id": 7903,
"author_profile": "https://Stackoverflow.com/users/7903",
"pm_score": 6,
"selected": true,
"text": "<p>Here's how you can do it without using <code>SHIFT</code>:</p>\n\n<pre><code>@echo off\n\nfor /f \"tokens=1-3*\" %%a ... | 2008/12/19 | [
"https://Stackoverflow.com/questions/382587",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14420/"
] | Further to [How to Pass Command Line Parameters in batch file](https://stackoverflow.com/questions/26551/how-to-pass-command-line-parameters-in-batch-file) how does one get the rest of the parameters with specifying them exactly? I don't want to use SHIFT because I don't know how many parameters there might be and woul... | Here's how you can do it without using `SHIFT`:
```
@echo off
for /f "tokens=1-3*" %%a in ("%*") do (
set par1=%%a
set par2=%%b
set par3=%%c
set therest=%%d
)
echo the script is %0
echo Parameter 1 is %par1%
echo Parameter 2 is %par2%
echo Parameter 3 is %par3%
echo and the rest are %therest%
``` |
382,590 | <p>Working with a latex document with eps images as in the example below...</p>
<pre><code>\documentclass[11pt]{paper}
\usepackage[dvips]{graphicx}
\usepackage{fullpage}
\usepackage{hyperref}
\usepackage{amsmath}
\DeclareMathSizes{8}{8}{8}{8}
\author{Matt Miller}
\title{my paper}
\begin{document}
\begin{figure}[!h... | [
{
"answer_id": 382595,
"author": "doppelfish",
"author_id": 235914,
"author_profile": "https://Stackoverflow.com/users/235914",
"pm_score": 0,
"selected": false,
"text": "<p>As a quick fix, try passing the [draft] option to the graphix package.</p>\n"
},
{
"answer_id": 382795,
... | 2008/12/19 | [
"https://Stackoverflow.com/questions/382590",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17712/"
] | Working with a latex document with eps images as in the example below...
```
\documentclass[11pt]{paper}
\usepackage[dvips]{graphicx}
\usepackage{fullpage}
\usepackage{hyperref}
\usepackage{amsmath}
\DeclareMathSizes{8}{8}{8}{8}
\author{Matt Miller}
\title{my paper}
\begin{document}
\begin{figure}[!ht]
\begin{... | How big are the eps files? Latex only needs to know the size of the bounding box, which is at the beginning of the file.
dvips (not dvipdf) shouldn't take too much time since it just needs to embed the eps into the postscript file.
dvipdf, on the other hand has to convert the eps into pdf, which is expensive. |
382,591 | <p>Trying to rotate a div element...This might be DOM blasphemy, could it work possibly with a canvas element? I'm not sure - if anybody has any ideas of how this could work or why it doesn't, I'd love to know. Thanks.</p>
| [
{
"answer_id": 382638,
"author": "strager",
"author_id": 39992,
"author_profile": "https://Stackoverflow.com/users/39992",
"pm_score": 0,
"selected": false,
"text": "<p>I doubt you can rotate an element using DOM/CSS. Your best bet would be to render to a canvas and rotate that (not sur... | 2008/12/19 | [
"https://Stackoverflow.com/questions/382591",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43889/"
] | Trying to rotate a div element...This might be DOM blasphemy, could it work possibly with a canvas element? I'm not sure - if anybody has any ideas of how this could work or why it doesn't, I'd love to know. Thanks. | To rotate a DIV Make use of `WebkitTransform / -moz-transform: rotate(Xdeg)`.
This will not work in IE. The Raphael library does work with IE and **[it does rotation](https://dmitrybaranovskiy.github.io/raphael/image-rotation.html)**. I believe it uses `canvas`es
If you want to animate the rotation, you can use a re... |
382,603 | <p>So in Ruby there is a trick to specify infinity:</p>
<pre><code>1.0/0
=> Infinity
</code></pre>
<p>I believe in Python you can do something like this</p>
<pre><code>float('inf')
</code></pre>
<p>These are just examples though, I'm sure most languages have infinity in some capacity. When would you actually use... | [
{
"answer_id": 382605,
"author": "Kenan Banks",
"author_id": 43089,
"author_profile": "https://Stackoverflow.com/users/43089",
"pm_score": 5,
"selected": false,
"text": "<p>Off the top of the head, it can be useful as an initial value when searching for a minimum value.</p>\n\n<p>For exa... | 2008/12/19 | [
"https://Stackoverflow.com/questions/382603",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42413/"
] | So in Ruby there is a trick to specify infinity:
```
1.0/0
=> Infinity
```
I believe in Python you can do something like this
```
float('inf')
```
These are just examples though, I'm sure most languages have infinity in some capacity. When would you actually use this construct in the real world? Why would using i... | Dijkstra's Algorithm typically assigns infinity as the initial edge weights in a graph. This doesn't *have* to be "infinity", just some arbitrarily constant but in java I typically use Double.Infinity. I assume ruby could be used similarly. |
382,608 | <p>My colleague suggests that texniscope is somehow to blame and that I should try purging it from my system. I really hope not to have to resort to that!</p>
<p>Possible clues:</p>
<ul>
<li><p>This wasn't an issue till I upgraded to Leopard.</p></li>
<li><p>When I say the fonts are screwed up, I mean the main text ... | [
{
"answer_id": 382645,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>Look at the pdf in Adobe Reader under the document properties. If you have Type 3 (?) bitmap fonts for the math, you need ... | 2008/12/19 | [
"https://Stackoverflow.com/questions/382608",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4234/"
] | My colleague suggests that texniscope is somehow to blame and that I should try purging it from my system. I really hope not to have to resort to that!
Possible clues:
* This wasn't an issue till I upgraded to Leopard.
* When I say the fonts are screwed up, I mean the main text looks like maybe it's the default mac s... | Apple knows about the problem and isn't planning to fix it (I had a faculty member spend a lot of time testing and submit a bug to Apple). Their claim is that PDFTeX is embedding the fonts incorrectly, and they have fixed the Apple PDF library to be more strict about what it will and won't accept, which means that you ... |
382,624 | <p>In <a href="http://abstracthack.wordpress.com/2007/09/05/multi-threaded-map-for-python/" rel="nofollow noreferrer">this blog article</a> they use the construct:</p>
<pre><code> @measured
def some_func():
#...
# Presumably outputs something like "some_func() is finished in 121.333 s" somewhere
</code></pre>... | [
{
"answer_id": 382627,
"author": "Kenan Banks",
"author_id": 43089,
"author_profile": "https://Stackoverflow.com/users/43089",
"pm_score": 2,
"selected": false,
"text": "<p>Yes it's real. It's a function decorator. </p>\n\n<p>Function decorators in Python are functions that take a funct... | 2008/12/20 | [
"https://Stackoverflow.com/questions/382624",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30529/"
] | In [this blog article](http://abstracthack.wordpress.com/2007/09/05/multi-threaded-map-for-python/) they use the construct:
```
@measured
def some_func():
#...
# Presumably outputs something like "some_func() is finished in 121.333 s" somewhere
```
This `@measured` directive doesn't seem to work with raw p... | `@measured` decorates the some\_func() function, using a function or class named `measured`. The `@` is the decorator syntax, `measured` is the decorator function name.
Decorators can be a bit hard to understand, but they are basically used to either wrap code around a function, or inject code into one.
For example t... |
382,629 | <p>Ok I'm at my work this friday setting up a table that will have data in it that will come from a separate file called values.php. When I write it like this, the divs turn up blank. I think I have the "include" written wrong, does an absolute path not work?</p>
<pre><code><?php include('http://www.nextadvisor.c... | [
{
"answer_id": 382652,
"author": "lbrandao",
"author_id": 47883,
"author_profile": "https://Stackoverflow.com/users/47883",
"pm_score": 3,
"selected": true,
"text": "<p>The type of include you are trying to do is blocked by default, not to say that it is dangerous. You are trying to incl... | 2008/12/20 | [
"https://Stackoverflow.com/questions/382629",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43035/"
] | Ok I'm at my work this friday setting up a table that will have data in it that will come from a separate file called values.php. When I write it like this, the divs turn up blank. I think I have the "include" written wrong, does an absolute path not work?
```
<?php include('http://www.nextadvisor.com/credit_report_se... | The type of include you are trying to do is blocked by default, not to say that it is dangerous. You are trying to include a remote file.
If your script is in the same machine as the "values.php" you should use an absolute path similar to "/var/www/nextadvisor.com/credit\_report\_services/values.php" or a relative pa... |
382,633 | <p>We are using <a href="http://checkstyle.sourceforge.net/index.html" rel="nofollow noreferrer">CheckStyle</a> to enforce our style standards. One of the style rules we opted to include was the <em>NeedBraces</em> module.</p>
<p><em><a href="http://checkstyle.sourceforge.net/config_blocks.html#NeedBraces" rel="nofol... | [
{
"answer_id": 382695,
"author": "Lawrence Dol",
"author_id": 8946,
"author_profile": "https://Stackoverflow.com/users/8946",
"pm_score": 4,
"selected": true,
"text": "<p>I believe it is making an exception because, though formatted strangely, what you have is an \"else if\". It shouldn... | 2008/12/20 | [
"https://Stackoverflow.com/questions/382633",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/92/"
] | We are using [CheckStyle](http://checkstyle.sourceforge.net/index.html) to enforce our style standards. One of the style rules we opted to include was the *NeedBraces* module.
*[NeedBraces](http://checkstyle.sourceforge.net/config_blocks.html#NeedBraces)* specifies that every block type statement (such as `if`, `else`... | I believe it is making an exception because, though formatted strangely, what you have is an "else if". It shouldn't force you to put braces around the "if" in this case because you would end up with "... else { if { ... } }
Your code should be formatted:
```
if (true)
{
System.out.println("20");
}
else if (tr... |
382,675 | <p>I am looking for a way to position a div (it would be a pop-up that would be activated by a user hovering and/or clicking much like lightbox) over an a split iframe where the top iframe is content from my server and the bottom iframe is content from another server. Like this:</p>
<pre>
---------------------------... | [
{
"answer_id": 382699,
"author": "Soviut",
"author_id": 46914,
"author_profile": "https://Stackoverflow.com/users/46914",
"pm_score": 2,
"selected": false,
"text": "<p>Your best bet would be to make sure you set styles to:</p>\n\n<pre><code>.overlapper\n{\n position: absolute;\n z-... | 2008/12/20 | [
"https://Stackoverflow.com/questions/382675",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47880/"
] | I am looking for a way to position a div (it would be a pop-up that would be activated by a user hovering and/or clicking much like lightbox) over an a split iframe where the top iframe is content from my server and the bottom iframe is content from another server. Like this:
```
------------------------------------... | Take a look at this:
<http://ahare.us/test.html>
This page does pretty much what you are asking for. I would try to avoid z-index as much as possible because once you head down that road you are committed to it in ways that may become painful.
(Just so you know I tested this in Firefox 3 and IE 6).
Here is the code... |
382,711 | <p>I was looking at sql inner queries (bit like the sql equivalent of a C# anon method), and was wondering, can I return more than one value from a query?</p>
<p>For example, return the number of rows in a table as one output value, and also, as another output value, return the distinct number of rows?</p>
<p>Also, h... | [
{
"answer_id": 382728,
"author": "GluedHands",
"author_id": 37726,
"author_profile": "https://Stackoverflow.com/users/37726",
"pm_score": 2,
"selected": false,
"text": "<p>You could do your first question by doing this:</p>\n\n<pre><code>SELECT\n COUNT(field1),\n COUNT(DISTINCT field2)... | 2008/12/20 | [
"https://Stackoverflow.com/questions/382711",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32484/"
] | I was looking at sql inner queries (bit like the sql equivalent of a C# anon method), and was wondering, can I return more than one value from a query?
For example, return the number of rows in a table as one output value, and also, as another output value, return the distinct number of rows?
Also, how does distinct ... | You could do your first question by doing this:
```
SELECT
COUNT(field1),
COUNT(DISTINCT field2)
FROM table
```
(For the first field you could do \* if needed to count null values.)
Distinct means the definition of the word. It eliminates duplicate returned rows.
Returning 2 values instead of 1 would depend on... |
382,720 | <p>I find it hard to generate the dbscripts from TOAD. I get errors when executing the scripts things like looping chain of synonyms or certain statement not abel to exceute etc.</p>
<p>Is there any seamless way in said like connecting a remote oracle schema and just duplicate to my local environment?</p>
<p>And also... | [
{
"answer_id": 382771,
"author": "derobert",
"author_id": 27727,
"author_profile": "https://Stackoverflow.com/users/27727",
"pm_score": 2,
"selected": false,
"text": "<p>Syncing an entire schema, data and all, is fairly easily done with exp and imp:</p>\n\n<pre><code>$ exp username/passw... | 2008/12/20 | [
"https://Stackoverflow.com/questions/382720",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I find it hard to generate the dbscripts from TOAD. I get errors when executing the scripts things like looping chain of synonyms or certain statement not abel to exceute etc.
Is there any seamless way in said like connecting a remote oracle schema and just duplicate to my local environment?
And also do synchronizati... | Syncing an entire schema, data and all, is fairly easily done with exp and imp:
```
$ exp username/password@source-sid CONSISTENT=Y DIRECT=Y OWNER=schema FILE=schema.exp
$ ⋮ # some command(s) to nuke objects, see below
$ imp username/password@dest-sid FROMUSER=schema FILE=schema.exp
```
You can import into a differe... |
382,734 | <p>I'm trying to run the following commands:</p>
<pre><code>replace -x "must " A2input.txt
replace -x " a" -f -s ## A2input.txt
replace -x to -s ## -a A2input.txt
replace -x faith -f "unequivocal" A2input.txt
</code></pre>
<p>And it'd be nice if I could just alias it to something short and simple like "a", "b", "c", ... | [
{
"answer_id": 382760,
"author": "derobert",
"author_id": 27727,
"author_profile": "https://Stackoverflow.com/users/27727",
"pm_score": 0,
"selected": false,
"text": "<p>If you can't get an alias to work, just write a short shell script, chmod +x, and put it somewhere in your $PATH (like... | 2008/12/20 | [
"https://Stackoverflow.com/questions/382734",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20526/"
] | I'm trying to run the following commands:
```
replace -x "must " A2input.txt
replace -x " a" -f -s ## A2input.txt
replace -x to -s ## -a A2input.txt
replace -x faith -f "unequivocal" A2input.txt
```
And it'd be nice if I could just alias it to something short and simple like "a", "b", "c", "d", etc...
However, some... | I got it to work by storing the string with the double quote in a variable with the string surrounded by single quotes. When I use the variable I up inside single quotes.
Example:
```
[11:~] phi%
[11:~] phi% set text = 'a quote "'
[11:~] phi% alias ec echo '$text'
[11:~] phi% ec
a quote "
[11:~] phi%
[11:~] phi... |
382,747 | <p>How do I submit the ListBox selections to the ModelBinder?</p>
<pre><code><%=Html.Hidden("response.Index",index)%>
<%=Html.ListBox("response[index].ChoiceID",
new MultiSelectList(gc.choice,"ChoiceID","ChoiceText") )%>
</code></pre>
<p>'gc.choice' is a List </p>
<p>I can get the fisrt ... | [
{
"answer_id": 700730,
"author": "Rokey Ge",
"author_id": 84543,
"author_profile": "https://Stackoverflow.com/users/84543",
"pm_score": 1,
"selected": false,
"text": "<p>I built a presentation model <code>SamplePresentationModel</code> class that has a MultiSelect member <code>userList</... | 2008/12/20 | [
"https://Stackoverflow.com/questions/382747",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | How do I submit the ListBox selections to the ModelBinder?
```
<%=Html.Hidden("response.Index",index)%>
<%=Html.ListBox("response[index].ChoiceID",
new MultiSelectList(gc.choice,"ChoiceID","ChoiceText") )%>
```
'gc.choice' is a List
I can get the fisrt selected value to the model, but not the secon... | I have solved this in a slightly different way...
```
[Model]
public IEnumerable<string> SelectedStores { get; set; }
[View]
<%= Html.ListBox("SelectedStores",
(MultiSelectList)ViewData["Stores"],
new { size = "8" }) %>
[Controller]
ViewData["Stores"] =
new MultiSelectList(StoreItems, "Value", "Text",... |
382,791 | <p>I am getting this error when starting up Jetty that uses Mysql Connection Pool. Could someone help me out please?</p>
<pre><code>[root@localhost test]# java -DOPTIONS=plus,ext.default -classpath %CLASSPATH% -jar /usr/src/jetty7/start.jar myjetty.xml
2008-12-20 18:24:08.138::INFO: Logging to STDERR via org.mortbay... | [
{
"answer_id": 1268516,
"author": "Adam Batkin",
"author_id": 120808,
"author_profile": "https://Stackoverflow.com/users/120808",
"pm_score": 2,
"selected": false,
"text": "<p><a href=\"http://markmail.org/message/yr67nl6dohol4glz\" rel=\"nofollow noreferrer\">Ensure</a> that the jetty-p... | 2008/12/20 | [
"https://Stackoverflow.com/questions/382791",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am getting this error when starting up Jetty that uses Mysql Connection Pool. Could someone help me out please?
```
[root@localhost test]# java -DOPTIONS=plus,ext.default -classpath %CLASSPATH% -jar /usr/src/jetty7/start.jar myjetty.xml
2008-12-20 18:24:08.138::INFO: Logging to STDERR via org.mortbay.log.StdErrLog
... | [Ensure](http://markmail.org/message/yr67nl6dohol4glz) that the jetty-plus.jar file is on your classpath, and also that the configuration file `etc/jetty-plus.xml` is included on the command line:
```
java -DOPTIONS=plus,ext.default -classpath %CLASSPATH% -jar /usr/src/jetty7/start.jar /path/to/etc/jetty-plus.xml myje... |
382,811 | <p>How do you set a function to \C-' ? when I try to do :</p>
<pre><code>(global-set-key "\C-'" 'myfunct)
</code></pre>
<p>it gives me "Invalid modifier in string".</p>
| [
{
"answer_id": 382816,
"author": "ShreevatsaR",
"author_id": 4958,
"author_profile": "https://Stackoverflow.com/users/4958",
"pm_score": 5,
"selected": true,
"text": "<p>What is <code>\\C-'</code>? Do you want something to happen when you type backslash+c+quote? Or do you mean <code>C-'<... | 2008/12/20 | [
"https://Stackoverflow.com/questions/382811",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41241/"
] | How do you set a function to \C-' ? when I try to do :
```
(global-set-key "\C-'" 'myfunct)
```
it gives me "Invalid modifier in string". | What is `\C-'`? Do you want something to happen when you type backslash+c+quote? Or do you mean `C-'` (control+quote)? If it's the latter (and I guess it is), then you should use
```
(global-set-key (kbd "C-'") 'myfunct)
``` |
382,822 | <p>I declared a private variable </p>
<pre><code>vector<SomeClass> theVector;
</code></pre>
<p>someplace inside my SomeClass class.</p>
<p>Why can't I say: <code>delete theVector</code> inside my SomeClass destructor?</p>
<p>The compiler error says:</p>
<pre><code> type `class Vector<SomeClass>' argume... | [
{
"answer_id": 382823,
"author": "PolyThinker",
"author_id": 47707,
"author_profile": "https://Stackoverflow.com/users/47707",
"pm_score": 2,
"selected": false,
"text": "<p>This is because theVector is not a pointer, which is what <code>delete' expects. \"Expected pointer\" means the ope... | 2008/12/20 | [
"https://Stackoverflow.com/questions/382822",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45963/"
] | I declared a private variable
```
vector<SomeClass> theVector;
```
someplace inside my SomeClass class.
Why can't I say: `delete theVector` inside my SomeClass destructor?
The compiler error says:
```
type `class Vector<SomeClass>' argument given to `delete', expected pointer
```
What expected pointer? | If new and delete go hand in hand.
To delete something you need to create it via new (which gives you a pointer). You can then delete the pointer. The way you are declaring the vector it is being created on the stack (not the heap) and will be deallocated when it goes out of scope.
```
int main()
{
vector<SomeCla... |
382,854 | <p>Button class:</p>
<pre><code>class SubmitButton extends JButton implements ActionListener {
public SubmitButton(String title){
super(title);
....
</code></pre>
<p>Where I declare it:</p>
<pre><code>SubmitButton submit = new SubmitButton("Submit");
submit.setBounds(530+150, 200, 100, 25);
</cod... | [
{
"answer_id": 382864,
"author": "cliff.meyers",
"author_id": 41754,
"author_profile": "https://Stackoverflow.com/users/41754",
"pm_score": 1,
"selected": false,
"text": "<p><a href=\"http://java.sun.com/javase/6/docs/api/javax/swing/JButton.html#JButton(java.lang.String)\" rel=\"nofollo... | 2008/12/20 | [
"https://Stackoverflow.com/questions/382854",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51518/"
] | Button class:
```
class SubmitButton extends JButton implements ActionListener {
public SubmitButton(String title){
super(title);
....
```
Where I declare it:
```
SubmitButton submit = new SubmitButton("Submit");
submit.setBounds(530+150, 200, 100, 25);
```
**How does super(title) set the Stri... | * SubmitButton extends JButton
* JButton has a constructor which might look like this (simplified):
```
public JButton(String title) {
setText(title);
}
```
* SubmitBUtton has a constructor:
```
public SubmitButton(String title) {
super(title);
}
```
The SubmitButton constructor is calling the superclass (... |
382,878 | <p>I have a java class file with a main method. In Windows, I would like to be able to drag files onto a desktop icon/short/etc that would call supply the filenames to my main method. Basically, I want to allow users to drag-and-drop files at program execution instead of having type them on the command line.</p>
<p>An... | [
{
"answer_id": 382909,
"author": "kevindaub",
"author_id": 27669,
"author_profile": "https://Stackoverflow.com/users/27669",
"pm_score": 0,
"selected": false,
"text": "<p>Adding onto Adiel A. If you create a batch file, which launches your a Java window using Swing. You would have the ... | 2008/12/20 | [
"https://Stackoverflow.com/questions/382878",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a java class file with a main method. In Windows, I would like to be able to drag files onto a desktop icon/short/etc that would call supply the filenames to my main method. Basically, I want to allow users to drag-and-drop files at program execution instead of having type them on the command line.
Any thoughts... | To build on daub815's answer, in Windows, you can use a batch file to pass
arguments to another command. In this case, we'll use the `java` launcher to
launch your class with the `main` method.
I did a quick Google search on how to do write a batch file to take multiple arguments,
and [found a page with a batch file t... |
382,880 | <p>My team is working on a conversion project to convert one product (but with many facets) from VB6 to .Net (we have over ~300k LOC). Before I got on board, the decision was made that regardless of the location of the assembly, or folder structure, all classes / structs will be in one namespace:</p>
<p>.</p>
<p>They... | [
{
"answer_id": 382903,
"author": "Andrew Hare",
"author_id": 34211,
"author_profile": "https://Stackoverflow.com/users/34211",
"pm_score": 0,
"selected": false,
"text": "<p>If your code was laundry you would have two choices, either you can keep everything in one big pile and rifle throu... | 2008/12/20 | [
"https://Stackoverflow.com/questions/382880",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42536/"
] | My team is working on a conversion project to convert one product (but with many facets) from VB6 to .Net (we have over ~300k LOC). Before I got on board, the decision was made that regardless of the location of the assembly, or folder structure, all classes / structs will be in one namespace:
.
They even go as far a... | Good answers, already
=====================
I read a lot of good answers (the drive folder's image is a good one, for example, as is the object/concept separation/organization).
Still, some other, less "technical" arguments could help, not to explain why namespaces are better than the alternative, but to unearth the ... |
382,883 | <p>For the sake of an example, is this statement</p>
<pre><code>window.Number.constructor.prototype.constructor();
</code></pre>
<p>read like a path?</p>
<pre><code>C:\Users\Vista\Documents\Work\text.txt
</code></pre>
<p>From left to right</p>
<pre><code>window:\Number\constructor\prototype\constructor()
</code></... | [
{
"answer_id": 382893,
"author": "Charlie Martin",
"author_id": 35092,
"author_profile": "https://Stackoverflow.com/users/35092",
"pm_score": 0,
"selected": false,
"text": "<p>Yes, or like a field in a <code>struct</code> in C. It's actually a bunch of hash tables or dictionaries. So y... | 2008/12/20 | [
"https://Stackoverflow.com/questions/382883",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | For the sake of an example, is this statement
```
window.Number.constructor.prototype.constructor();
```
read like a path?
```
C:\Users\Vista\Documents\Work\text.txt
```
From left to right
```
window:\Number\constructor\prototype\constructor()
```
where `window` is the root object, `Number` is an object inside... | Read from left to right. Each "thing" resolves to an object. Objects can have properties or functions. A property is another object, which can in turn have its own properties and functions. If it is a function, then to be legal syntax the function must return an object. Then the chained item to the right must be a prop... |
382,928 | <p>I need to create a wpf treeviewlist to look something like this:</p>
<pre><code>AAAA
BBBB
....CCCC
....DDDD
.......EEEE
FFFFF
</code></pre>
<p>(where the dots above are indents)</p>
<p>I need to do this from vb.net (2008) code.</p>
<p>I've spent an embarrassingly long amount of time trying to figure this ou... | [
{
"answer_id": 383046,
"author": "Mark Carpenter",
"author_id": 47645,
"author_profile": "https://Stackoverflow.com/users/47645",
"pm_score": 3,
"selected": true,
"text": "<p>You can do it quite easily. Simply add your child TreeViewItems directly to the parent item, like so (C#, but ver... | 2008/12/20 | [
"https://Stackoverflow.com/questions/382928",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18735/"
] | I need to create a wpf treeviewlist to look something like this:
```
AAAA
BBBB
....CCCC
....DDDD
.......EEEE
FFFFF
```
(where the dots above are indents)
I need to do this from vb.net (2008) code.
I've spent an embarrassingly long amount of time trying to figure this out, and so far all I’ve got is:
vb.net:
... | You can do it quite easily. Simply add your child TreeViewItems directly to the parent item, like so (C#, but very clear)
```
var parent = new TreeViewItem();
var child = new TreeViewItem();
parent.Header = "Hey";
child.Header = "There!";
parent.Items.Add(child);
treeView1.Items.Add(parent);
``` |
382,930 | <p>I have this jQuery code that queries an API on a keyup event (via keyterms.php). It works as it is, but I'm trying to figure out how to implement a "pause" so to speak such that it will only do a query after a certain amount of time (say 2sec.) after the last keyup. Any help will be much appreciated. Thanks!</p>
... | [
{
"answer_id": 382956,
"author": "Andrew Rollings",
"author_id": 40410,
"author_profile": "https://Stackoverflow.com/users/40410",
"pm_score": 0,
"selected": false,
"text": "<p>Use a <code>setTimeout</code> to only call the ajax method two seconds after the key is pressed, rather than ca... | 2008/12/20 | [
"https://Stackoverflow.com/questions/382930",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47947/"
] | I have this jQuery code that queries an API on a keyup event (via keyterms.php). It works as it is, but I'm trying to figure out how to implement a "pause" so to speak such that it will only do a query after a certain amount of time (say 2sec.) after the last keyup. Any help will be much appreciated. Thanks!
```
$(doc... | You can use the jQuery plugin that StackOverflow uses for its [Users Page](https://stackoverflow.com/users); it's called [TypeWatch](https://github.com/medihack/typewatch)
It can be applied like such:
```
<input type="text" id="tb" />
<script>
$("#tb").typeWatch({ highlight: true, wait: 500, captureLength: -1, callb... |
382,963 | <p>I'm trying to get a dynamic movie clip from the timeline.</p>
<p>I have a timeline of unknown length with a movie clip with instance name "blah" on one of the key frames (assumed 88 in this case).<br/>
No matter what I do, I cannot get a reference to the said movie clip. </p>
<p>Here's what I tried:</p>
<pre><cod... | [
{
"answer_id": 382948,
"author": "Adeel Ansari",
"author_id": 42769,
"author_profile": "https://Stackoverflow.com/users/42769",
"pm_score": 3,
"selected": false,
"text": "<p>Why not. <a href=\"http://blog.objectmentor.com/articles/category/testing-guis\" rel=\"noreferrer\">Here</a> is a ... | 2008/12/20 | [
"https://Stackoverflow.com/questions/382963",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41983/"
] | I'm trying to get a dynamic movie clip from the timeline.
I have a timeline of unknown length with a movie clip with instance name "blah" on one of the key frames (assumed 88 in this case).
No matter what I do, I cannot get a reference to the said movie clip.
Here's what I tried:
```
trace(blah); // null
trace(t... | The answer which has evolved over the last few years is, *you don't apply TDD to the GUI, you design the GUI in such as way that there's a layer just underneath you can develop with TDD.* The Gui is reduced to a trivial mapping of controls to the ViewModel, often with framework bindings, and so is ignored for TDD.
Thi... |
382,980 | <p>Is there some command line or AppleScript that I can write/run to make the machine go to sleep automatically or even better, into hibernate mode? </p>
<p>I can run the program as root.</p>
| [
{
"answer_id": 382986,
"author": "Rob Kennedy",
"author_id": 33732,
"author_profile": "https://Stackoverflow.com/users/33732",
"pm_score": 4,
"selected": true,
"text": "<pre><code>osascript -e 'tell application \"Finder\" to sleep'\n</code></pre>\n"
},
{
"answer_id": 390450,
... | 2008/12/20 | [
"https://Stackoverflow.com/questions/382980",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23072/"
] | Is there some command line or AppleScript that I can write/run to make the machine go to sleep automatically or even better, into hibernate mode?
I can run the program as root. | ```
osascript -e 'tell application "Finder" to sleep'
``` |
382,993 | <p>A colleague of mine recently got bitten badly by writing out of bounds to a static array on the stack (he added an element to it without increasing the array size). Shouldn't the compiler catch this kind of error? The following code compiles cleanly with gcc, even with the <code>-Wall -Wextra</code> options, and y... | [
{
"answer_id": 383000,
"author": "Friedrich",
"author_id": 15068,
"author_profile": "https://Stackoverflow.com/users/15068",
"pm_score": 0,
"selected": false,
"text": "<p>There are some extension in gcc for that (from compiler side)\n<a href=\"http://www.doc.ic.ac.uk/~awl03/projects/miro... | 2008/12/20 | [
"https://Stackoverflow.com/questions/382993",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9530/"
] | A colleague of mine recently got bitten badly by writing out of bounds to a static array on the stack (he added an element to it without increasing the array size). Shouldn't the compiler catch this kind of error? The following code compiles cleanly with gcc, even with the `-Wall -Wextra` options, and yet it is clearly... | GCC *does* warn about this. But you need to do two things:
1. Enable optimization. Without at least -O2, GCC is not doing enough analysis to know what `a` is, and that you ran off the edge.
2. Change your example so that a[] is actually used, otherwise GCC generates a no-op program and has completely discarded your as... |
382,998 | <p>Does anyone know exactly what Windows XP does when you click "Repair" on a network connection? I'd like to do the same programmatically or from a command line.</p>
<p>I did a Google search and found <a href="http://windowsitpro.com/article/articleid/41060/what-actions-occur-when-i-click-repair-on-a-network-connecti... | [
{
"answer_id": 383005,
"author": "Steven A. Lowe",
"author_id": 9345,
"author_profile": "https://Stackoverflow.com/users/9345",
"pm_score": 0,
"selected": false,
"text": "<pre><code>ipconfig /renew\n</code></pre>\n"
},
{
"answer_id": 383006,
"author": "chaos",
"author_id"... | 2008/12/20 | [
"https://Stackoverflow.com/questions/382998",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20336/"
] | Does anyone know exactly what Windows XP does when you click "Repair" on a network connection? I'd like to do the same programmatically or from a command line.
I did a Google search and found [this article](http://windowsitpro.com/article/articleid/41060/what-actions-occur-when-i-click-repair-on-a-network-connection-i... | Thanks, guys, I think I figured it out. The steps in the [MS KB article posted by lpfavreau](http://support.microsoft.com/kb/289256/EN-US/) are *almost* complete. That's what I tried and it didn't work. However, if I do `ipconfig /release` first then it seems to work. I suspect that the "Repair" button does that withou... |
383,016 | <p>How does container object like vector in stl get destroyed even though they are created in heap?</p>
<p><strong>EDIT</strong></p>
<p>If the container holds pointers then how to destroy those pointer objects</p>
| [
{
"answer_id": 383022,
"author": "zvrba",
"author_id": 2583,
"author_profile": "https://Stackoverflow.com/users/2583",
"pm_score": 0,
"selected": false,
"text": "<p>As with any other object in the heap, it must be destroyed manually (with delete).</p>\n"
},
{
"answer_id": 383040,... | 2008/12/20 | [
"https://Stackoverflow.com/questions/383016",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22076/"
] | How does container object like vector in stl get destroyed even though they are created in heap?
**EDIT**
If the container holds pointers then how to destroy those pointer objects | An STL container of pointer will NOT clean up the data pointed at. It will only clean up the space holding the pointer. If you want the vector to clean up pointer data you need to use some kind of smart pointer implementation:
```
{
std::vector<SomeClass*> v1;
v1.push_back(new SomeClass());
std::vector<bo... |
383,026 | <p>I find this comes up a lot, and I'm not sure the best way to approach it. </p>
<p><strong>The question I have is how to make the decision between using foreign keys to lookup tables, or using lookup table values directly in the tables requesting it, avoiding the lookup table relationship completely.</strong></p>
<... | [
{
"answer_id": 383033,
"author": "chaos",
"author_id": 47529,
"author_profile": "https://Stackoverflow.com/users/47529",
"pm_score": 1,
"selected": false,
"text": "<p>Normalization is pretty universally regarded as part of best practices in databases, and normalization says yeah, you pus... | 2008/12/20 | [
"https://Stackoverflow.com/questions/383026",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37966/"
] | I find this comes up a lot, and I'm not sure the best way to approach it.
**The question I have is how to make the decision between using foreign keys to lookup tables, or using lookup table values directly in the tables requesting it, avoiding the lookup table relationship completely.**
Points to keep in mind:
* W... | You can use a lookup table with a VARCHAR primary key, and your main data table uses a FOREIGN KEY on its column, with cascading updates.
```
CREATE TABLE ColorLookup (
color VARCHAR(20) PRIMARY KEY
);
CREATE TABLE ItemsWithColors (
...other columns...,
color VARCHAR(20),
FOREIGN KEY (color) REFERENCES ColorL... |
383,047 | <h1>Background</h1>
<p>In Visual Studio 2008
Create a new Windows Forms Application, this will create a skeleton project with a class called "Form1". VS2008 automatically creates a Dispose() method.</p>
<pre><code> /// <summary>
/// Clean up any resources being used.
/// </summary>
/// <... | [
{
"answer_id": 383053,
"author": "JaredPar",
"author_id": 23283,
"author_profile": "https://Stackoverflow.com/users/23283",
"pm_score": 3,
"selected": false,
"text": "<p>No it is not safe to delete this code. Several components depend on this pattern to be in effect in order to properly... | 2008/12/20 | [
"https://Stackoverflow.com/questions/383047",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13477/"
] | Background
==========
In Visual Studio 2008
Create a new Windows Forms Application, this will create a skeleton project with a class called "Form1". VS2008 automatically creates a Dispose() method.
```
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true... | **Absolutely don't delete it** if there is the slightest chance of you ever using something like a System.Windows.Forms.Timer on the form. And there always is the chance of this.
It's this code which will dispose the timer when the form closes, and if you don't dispose the timer then it will keep running. I have taken... |
383,057 | <p>I need to transfer data from one table to the same table in another server which has been truncated. What is the easiest way to do this?</p>
| [
{
"answer_id": 383061,
"author": "mmx",
"author_id": 33708,
"author_profile": "https://Stackoverflow.com/users/33708",
"pm_score": 2,
"selected": false,
"text": "<p>Use the SQL Server Import and Export wizard. It's probably the easiest way to accomplish this task.</p>\n\n<p>For more adva... | 2008/12/20 | [
"https://Stackoverflow.com/questions/383057",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47957/"
] | I need to transfer data from one table to the same table in another server which has been truncated. What is the easiest way to do this? | Setup [linked servers](http://msdn.microsoft.com/en-us/library/aa213778(SQL.80).aspx) and then use the following on the destination database:
```
INSERT INTO existingTable (col1,col2..)
SELECT col1,col2...
FROM linkedserver.dbo.database.othertable
``` |
383,058 | <p>I am using Jruby and rails 2.2.2. My problem is I have a migration that is not being correctly written to the database schema.</p>
<p>Here is my migration: </p>
<pre><code>class CreateNotes < ActiveRecord::Migration
def self.up
create_table(:notes, :options => 'ENGINE=MyISAM') do |t|
t.string :... | [
{
"answer_id": 383357,
"author": "Christian Lescuyer",
"author_id": 341,
"author_profile": "https://Stackoverflow.com/users/341",
"pm_score": 4,
"selected": true,
"text": "<p>As I use foreign key constraints, I use the SQL format for migrations. In <em>environment.rb</em>:</p>\n\n<pre><c... | 2008/12/20 | [
"https://Stackoverflow.com/questions/383058",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5004/"
] | I am using Jruby and rails 2.2.2. My problem is I have a migration that is not being correctly written to the database schema.
Here is my migration:
```
class CreateNotes < ActiveRecord::Migration
def self.up
create_table(:notes, :options => 'ENGINE=MyISAM') do |t|
t.string :title
t.text :body
... | As I use foreign key constraints, I use the SQL format for migrations. In *environment.rb*:
```
# Use SQL instead of Active Record's schema dumper when creating the test database.
# This is necessary if your schema can't be completely dumped by the schema dumper,
# like if you have constraints or database-specific col... |
383,073 | <p>I'd like to write a script that interacts with my DB using a Django app's model. However, I would like to be able to run this script from the command line or via cron. What all do I need to import to allow this?</p>
| [
{
"answer_id": 383089,
"author": "Soviut",
"author_id": 46914,
"author_profile": "https://Stackoverflow.com/users/46914",
"pm_score": 4,
"selected": false,
"text": "<p>You need to set up the Django environment variables. These tell Python where your project is, and what the name of the ... | 2008/12/20 | [
"https://Stackoverflow.com/questions/383073",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1595/"
] | I'd like to write a script that interacts with my DB using a Django app's model. However, I would like to be able to run this script from the command line or via cron. What all do I need to import to allow this? | You need to set up the Django environment variables. These tell Python where your project is, and what the name of the settings module is (the project name in the settings module is optional):
```
import os
os.environ['PYTHONPATH'] = '/path/to/myproject'
os.environ['DJANGO_SETTINGS_MODULE'] = 'myproject.settings'
``... |
383,099 | <p>I have the following code:</p>
<pre><code><tr>
<td width="60%">
<dl>
<dt>Full Name</dt>
<dd>
<input name="fullname[]" type="text" class="txt w90" id="fullname[]" value="<?php echo $value; ?>" />
</dd&g... | [
{
"answer_id": 383106,
"author": "Vinko Vrsalovic",
"author_id": 5190,
"author_profile": "https://Stackoverflow.com/users/5190",
"pm_score": 3,
"selected": false,
"text": "<p>It's just an array:</p>\n\n<pre><code>foreach ($_POST['fullname'] as $name) {\n echo $name.\"\\n\";\n}\n</code... | 2008/12/20 | [
"https://Stackoverflow.com/questions/383099",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37667/"
] | I have the following code:
```
<tr>
<td width="60%">
<dl>
<dt>Full Name</dt>
<dd>
<input name="fullname[]" type="text" class="txt w90" id="fullname[]" value="<?php echo $value; ?>" />
</dd>
</dl>
</td>
<td width="30%">
<dl>
... | It's just an array:
```
foreach ($_POST['fullname'] as $name) {
echo $name."\n";
}
```
If the problem is you want to iterate over the two arrays in parallel simply use one of them to get the indexes:
```
for ($i=0; $i < count($_POST['fullname']); $i++) {
echo $_POST['fullname'][$i]."\n";
echo $_POST['jo... |
383,101 | <p>i'm having a hard time with Xcode; for some reason, it just won't let me pass a variable from one view controller class to another. It should work, i was basically just copying/pasting from my other classes (it works on all of them... except this one). I've been at it all night long, tried everything i could think o... | [
{
"answer_id": 383105,
"author": "Adam Rosenfield",
"author_id": 9530,
"author_profile": "https://Stackoverflow.com/users/9530",
"pm_score": 0,
"selected": false,
"text": "<p>Just a guess, but did you try using the arrow operator <code>-></code> instead of the dot operator <code>.</co... | 2008/12/20 | [
"https://Stackoverflow.com/questions/383101",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | i'm having a hard time with Xcode; for some reason, it just won't let me pass a variable from one view controller class to another. It should work, i was basically just copying/pasting from my other classes (it works on all of them... except this one). I've been at it all night long, tried everything i could think of a... | This doesn't exaclty answer your question, but your memory management is a bit wonky. This line:
```
[dvc dealloc];
```
should read like this:
```
[dvc release];
dvc = nil;
```
In Cocoa, you should never call `dealloc` directly -- follow the `retain/release/autorelease` pattern and things will work better and as ... |
383,103 | <p>I would like to know is there any way by which we can change the Image color at runtime.
for e.g lets say I am having a JPG bind to an Image control of ASP.Net. Next I am having a dropdown List which gives me the various color option like red,gree,etc. I would now like to change the color of the Image to the one sel... | [
{
"answer_id": 383305,
"author": "MusiGenesis",
"author_id": 14606,
"author_profile": "https://Stackoverflow.com/users/14606",
"pm_score": 4,
"selected": false,
"text": "<p>Here is a code sample that loads a JPEG, changes any red pixels in the image to blue, and then displays the bitmap ... | 2008/12/20 | [
"https://Stackoverflow.com/questions/383103",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I would like to know is there any way by which we can change the Image color at runtime.
for e.g lets say I am having a JPG bind to an Image control of ASP.Net. Next I am having a dropdown List which gives me the various color option like red,gree,etc. I would now like to change the color of the Image to the one select... | Here is a code sample that loads a JPEG, changes any red pixels in the image to blue, and then displays the bitmap in a picture box:
```
Bitmap bmp = (Bitmap)Bitmap.FromFile("image.jpg");
for (int x = 0; x < bmp.Width; x++)
{
for (int y = 0; y < bmp.Height; y++)
{
if (bmp.GetPixel(x, y) == Color.Red)
... |
383,104 | <p>When testing in any language, how does everybody <strong>phrase their assertion messages</strong>?</p>
<p>I see three obvious ways:</p>
<pre><code># assume failure
assert (4-2) == 2, "Subtracting 2 from 4 doesn't equal 2"
# describe success
assert (4-2) == 2, "Subtracting 2 from 4 should equal 2"
# be vauge with... | [
{
"answer_id": 383108,
"author": "Roddy",
"author_id": 1737,
"author_profile": "https://Stackoverflow.com/users/1737",
"pm_score": 3,
"selected": true,
"text": "<p>The important thing with an assert is the actual condition being tested. In C you can use the preprocessor \"stringization\"... | 2008/12/20 | [
"https://Stackoverflow.com/questions/383104",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13216/"
] | When testing in any language, how does everybody **phrase their assertion messages**?
I see three obvious ways:
```
# assume failure
assert (4-2) == 2, "Subtracting 2 from 4 doesn't equal 2"
# describe success
assert (4-2) == 2, "Subtracting 2 from 4 should equal 2"
# be vauge with failure
assert (4-2) == 2, "Subtr... | The important thing with an assert is the actual condition being tested. In C you can use the preprocessor "stringization" to output the actual condition being tested. My code just outputs
```
Assert Failed: (4-2)==2 : Line 123, File foo.c
```
If you're lucky, you can get a stack dump as well... |
383,116 | <p>I'm trying to make a modal dialog in the least amount of jQuery code as possible because my project already has a bit too much jQuery loaded into it.</p>
<p>So, I first needed an overlay, which is achieved with:</p>
<pre><code>$('body').wrapInner('<div />')
.css('opacity','0.5')
.css('z-index','2')
.attr('id... | [
{
"answer_id": 383141,
"author": "Jennifer",
"author_id": 22360,
"author_profile": "https://Stackoverflow.com/users/22360",
"pm_score": 3,
"selected": false,
"text": "<p>I think your best solution might be to use a jquery plugin. A quick google search threw up this: <a href=\"http://www.... | 2008/12/20 | [
"https://Stackoverflow.com/questions/383116",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm trying to make a modal dialog in the least amount of jQuery code as possible because my project already has a bit too much jQuery loaded into it.
So, I first needed an overlay, which is achieved with:
```
$('body').wrapInner('<div />')
.css('opacity','0.5')
.css('z-index','2')
.attr('id','dim1');
```
Disregard ... | See this quick [demo](http://pastebin.me/494ce61eb12fa) here, the key lies to the modal being absolute over the top of the opaque background. The demo dynamically adds the background overlay div and the modal div to the body but you could define these in the html and just show them.
Agreed there is no need to use a pl... |
383,164 | <p>I have build a WPF application where users can drag and drop MP3 files onto a listbox. I need a way to calculate the total duration of the playlist.</p>
<p>Any libraries I should use? Or is it possible using only the .NET framework?</p>
| [
{
"answer_id": 383289,
"author": "D'Arcy Rittich",
"author_id": 39430,
"author_profile": "https://Stackoverflow.com/users/39430",
"pm_score": 1,
"selected": false,
"text": "<p>I ended up writing my own for this purpose a few years back. You can write an effective one client-side using fl... | 2008/12/20 | [
"https://Stackoverflow.com/questions/383164",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2172/"
] | I have build a WPF application where users can drag and drop MP3 files onto a listbox. I need a way to calculate the total duration of the playlist.
Any libraries I should use? Or is it possible using only the .NET framework? | After lots of theorizing, I found a way to correctly and indisputably calculate a duration of an mp3 file.
Let me first re-iterate why standard methods above won't work:
ID3 method: not all files have id3 tags, and if they have it, they might not have duration field set in it.
Estimating by reading one frame \* file... |
383,172 | <p>What is the correct output (meaning correct by the ECMA standard) of the following program?</p>
<pre><code>function nl(x) { document.write(x + "<br>"); }
nl(Function.prototype);
nl(Function.prototype.prototype);
nl(Function.prototype.prototype == Object.prototype);
nl(Function.prototype.prototype.prototype);
... | [
{
"answer_id": 383290,
"author": "some",
"author_id": 36866,
"author_profile": "https://Stackoverflow.com/users/36866",
"pm_score": 4,
"selected": false,
"text": "<p><strong>Function.prototype</strong></p>\n\n<p>From <a href=\"http://www.ecma-international.org/publications/files/ECMA-ST/... | 2008/12/20 | [
"https://Stackoverflow.com/questions/383172",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15055/"
] | What is the correct output (meaning correct by the ECMA standard) of the following program?
```
function nl(x) { document.write(x + "<br>"); }
nl(Function.prototype);
nl(Function.prototype.prototype);
nl(Function.prototype.prototype == Object.prototype);
nl(Function.prototype.prototype.prototype);
```
Chrome and IE6... | What you're doing here isn't really walking the prototype chain - [this question](https://stackoverflow.com/questions/383201/relation-between-prototype-and-prototype-in-javascript) might help you understand what is actually going on. I didn't bother to check the ECMA spec, but here is my take on the issue:
* **Functio... |
383,183 | <p>I'm new to JSF world please help me out in generating a pop up window in the page.</p>
<p>Here is my requirement I will be having a list of links in my master page(parent) on click of each link I need to show a pop up which contains some details, which I need to get from DB in the pop up mbean. I will have few butt... | [
{
"answer_id": 402333,
"author": "SCdF",
"author_id": 1666,
"author_profile": "https://Stackoverflow.com/users/1666",
"pm_score": 0,
"selected": false,
"text": "<p>So (if I understand your problem correctly) the problem is that the second time the modified values of the bean are not maki... | 2008/12/20 | [
"https://Stackoverflow.com/questions/383183",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44256/"
] | I'm new to JSF world please help me out in generating a pop up window in the page.
Here is my requirement I will be having a list of links in my master page(parent) on click of each link I need to show a pop up which contains some details, which I need to get from DB in the pop up mbean. I will have few buttons in my ... | Have you checked your faces-config.xml file to make sure your bean is in request scope ?
```
<managed-bean-scope>request</managed-bean-scope>
```
If you bean is in session or application scope, the bean is not re-created each time you refresh the page so the values in the bean would not change. |
383,185 | <p>When a function is attached to an object and called:</p>
<pre><code>function f() { return this.x; }
var o = {x: 20};
o.func = f;
o.func(); //evaluates to 20
</code></pre>
<p><code>this</code> refers to the object that the function was called as a method of. It's equivalent to doing <code>f.call(o)</code>.</p>
<p>... | [
{
"answer_id": 383190,
"author": "Greg",
"author_id": 24181,
"author_profile": "https://Stackoverflow.com/users/24181",
"pm_score": 4,
"selected": true,
"text": "<p>The global object is actually the window so you can do</p>\n\n<pre><code>if (this === window)\n</code></pre>\n"
},
{
... | 2008/12/20 | [
"https://Stackoverflow.com/questions/383185",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15055/"
] | When a function is attached to an object and called:
```
function f() { return this.x; }
var o = {x: 20};
o.func = f;
o.func(); //evaluates to 20
```
`this` refers to the object that the function was called as a method of. It's equivalent to doing `f.call(o)`.
When the function is called not as part of an object, `... | The global object is actually the window so you can do
```
if (this === window)
``` |
383,189 | <p>The ECMA standard defines a hidden, internal property <code>[[Call]]</code>, which, if implemented, mean the object is callable / is a function.</p>
<p>In Python, something similar takes place, except that you can override it yourself to create your own callable objects:</p>
<pre><code>>>> class B:
... ... | [
{
"answer_id": 383199,
"author": "some",
"author_id": 36866,
"author_profile": "https://Stackoverflow.com/users/36866",
"pm_score": 3,
"selected": true,
"text": "<p>As far as I know it's not possible. It is supposed to be an internal property of an object and not exposed to the script it... | 2008/12/20 | [
"https://Stackoverflow.com/questions/383189",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15055/"
] | The ECMA standard defines a hidden, internal property `[[Call]]`, which, if implemented, mean the object is callable / is a function.
In Python, something similar takes place, except that you can override it yourself to create your own callable objects:
```
>>> class B:
... def __call__(self, x,y): print x,y
...
... | As far as I know it's not possible. It is supposed to be an internal property of an object and not exposed to the script itself. The only way I know is to define a function.
However, since functions is first class citizens you can add properties to them:
```
function myfunc(){
var myself = arguments.callee;
mysel... |
383,201 | <p>From <a href="http://www.jibbering.com/faq/faq_notes/closures.html" rel="noreferrer">http://www.jibbering.com/faq/faq_notes/closures.html</a> :</p>
<blockquote>
<p>Note: ECMAScript defines an internal [[prototype]] property of the internal Object type. This property is not directly accessible with scripts, but it is... | [
{
"answer_id": 383232,
"author": "JacquesB",
"author_id": 7488,
"author_profile": "https://Stackoverflow.com/users/7488",
"pm_score": 7,
"selected": true,
"text": "<p>I believe you are right in most cases. </p>\n\n<p>Every object has a hidden <code>[[Prototype]]</code> property, which is... | 2008/12/20 | [
"https://Stackoverflow.com/questions/383201",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15055/"
] | From <http://www.jibbering.com/faq/faq_notes/closures.html> :
>
> Note: ECMAScript defines an internal [[prototype]] property of the internal Object type. This property is not directly accessible with scripts, but it is the chain of objects referred to with the internal [[prototype]] property that is used in property... | I believe you are right in most cases.
Every object has a hidden `[[Prototype]]` property, which is used for inheritance. Functions additionally have a public `prototype` property, which is used only when the function is used as constructor: When an object is constructed using `new`, the `[[Prototype]]` property of t... |
383,211 | <p>I'm spending a bit of time with Erlang, and I'm wanting to apply TDD to code I'm writing.</p>
<p>While <a href="http://www.erlang.org/doc/apps/eunit/chapter.html" rel="noreferrer">EUnit</a> in the standard lib provides a nice traditional unit testing framework for testing regular style code, there doesn't seem to b... | [
{
"answer_id": 383227,
"author": "Diomidis Spinellis",
"author_id": 20520,
"author_profile": "https://Stackoverflow.com/users/20520",
"pm_score": 1,
"selected": false,
"text": "<p>Because errors in concurrent code manifest themselves depending on the order various parts get executed, I ... | 2008/12/20 | [
"https://Stackoverflow.com/questions/383211",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14160/"
] | I'm spending a bit of time with Erlang, and I'm wanting to apply TDD to code I'm writing.
While [EUnit](http://www.erlang.org/doc/apps/eunit/chapter.html) in the standard lib provides a nice traditional unit testing framework for testing regular style code, there doesn't seem to be anything to help specifically with t... | The question is a bit vague ("Erlang is concurrent, test it with Erlang!") but I'll try to elaborate a bit.
Testing Erlang code can range from the straightforwardly simple (the right input produces the right output) to setting up complex test harnesses that verify your component behaves the way it should. What is best... |
383,251 | <p>I want to style the slider control so that the height of the draggable thumb is set to 8 pixels.</p>
<p>What is the simplest way to do this in <a href="http://en.wikipedia.org/wiki/Windows_Presentation_Foundation" rel="nofollow noreferrer">WPF</a>?</p>
<pre><code><Slider>
<Slider.Style>
<... | [
{
"answer_id": 383482,
"author": "John",
"author_id": 33,
"author_profile": "https://Stackoverflow.com/users/33",
"pm_score": 2,
"selected": false,
"text": "<p>You will have to create a control template to restyle the part of the control you want.</p>\n\n<p>Have a look at this <a href=\"... | 2008/12/20 | [
"https://Stackoverflow.com/questions/383251",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2172/"
] | I want to style the slider control so that the height of the draggable thumb is set to 8 pixels.
What is the simplest way to do this in [WPF](http://en.wikipedia.org/wiki/Windows_Presentation_Foundation)?
```
<Slider>
<Slider.Style>
<!-- which xaml here? -->
</Slider.style>
</Slider>
``` | The Slider Control has many parts Thumb, RepeatButtons and a Track. It is one of those controls that have named elements, like PART\_Track, referenced by the code-behind for it to work correctly. A good starting point is to use Blend to help you out.
Start a new project (or create a new window). In the XAML window add... |
383,291 | <p>I am implementing a list, and I am wondering about the definition of the IndexOutOfRange. Which one of the following do you think is better?</p>
<pre><code>/// <exception cref="IndexOutOfRangeException">if index is less than 0
/// or greater than <see cref="Count"/>
public T this[int index] { get { retu... | [
{
"answer_id": 383300,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>Is it possible you could also have a \"Base\" property, then you could say:</p>\n\n<pre><code>/// <exception cref=\"Inde... | 2008/12/20 | [
"https://Stackoverflow.com/questions/383291",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41283/"
] | I am implementing a list, and I am wondering about the definition of the IndexOutOfRange. Which one of the following do you think is better?
```
/// <exception cref="IndexOutOfRangeException">if index is less than 0
/// or greater than <see cref="Count"/>
public T this[int index] { get { return myArray[index]; } }
``... | **Slightly OT:** can you encapsulate a list rather than an array, and then everything falls out in the wash since the encapsulated list will generate appropriate exceptions?
**Edit:** if you really need the array internally, how about *wrapping it in a list inside the accessor first*, and then selecting by index. This... |
383,293 | <p>I am using xcode 2.4.1 on tiger. When i do below everything is ok. when i do</p>
<pre><code>pthread_mutex_t mute;
ImageMan()
{
dibSize=0;
mute = PTHREAD_MUTEX_INITIALIZER;
}
</code></pre>
<p>I get these two errors</p>
<pre><code>error: expected primary-expression before '{' token
error: expected `;' befo... | [
{
"answer_id": 383343,
"author": "geocar",
"author_id": 37507,
"author_profile": "https://Stackoverflow.com/users/37507",
"pm_score": 5,
"selected": true,
"text": "<p><code>PTHREAD_MUTEX_INITIALIZER</code> is a constant initializer, valid when in initialization only. It is a macro that d... | 2008/12/20 | [
"https://Stackoverflow.com/questions/383293",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am using xcode 2.4.1 on tiger. When i do below everything is ok. when i do
```
pthread_mutex_t mute;
ImageMan()
{
dibSize=0;
mute = PTHREAD_MUTEX_INITIALIZER;
}
```
I get these two errors
```
error: expected primary-expression before '{' token
error: expected `;' before '{' token
```
I dont know why. H... | `PTHREAD_MUTEX_INITIALIZER` is a constant initializer, valid when in initialization only. It is a macro that doesn't necessarily expand to an integral type.
Your `mute=mutex;` is invalid- instead you should use:
```
pthread_mutex_init(&mute, NULL);
```
or if you're allocating mutexes dynamically:
```
m = malloc(si... |
383,307 | <p>A simple question</p>
<p>Consider this piece of code in C#</p>
<pre><code>String a;
String b;
String c;
1. a =
2. b =
3. //Comment
4. c = "a String";
</code></pre>
<p>During compilation, it was fine, but i hit an error when I run my application. From my logs, the error occur at the above.</p>
<p>Question:... | [
{
"answer_id": 383315,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 2,
"selected": false,
"text": "<p>Your original code was not legal. Your edited code is fine; all 3 variables are assigned the same string (\"a Stri... | 2008/12/20 | [
"https://Stackoverflow.com/questions/383307",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12944/"
] | A simple question
Consider this piece of code in C#
```
String a;
String b;
String c;
1. a =
2. b =
3. //Comment
4. c = "a String";
```
During compilation, it was fine, but i hit an error when I run my application. From my logs, the error occur at the above.
Question:
Is the error caused by the comment in... | Your original code was not legal. Your edited code is fine; all 3 variables are assigned the same string ("a String").
What *exact* error are you seeing?
---
(question updated to include "Object reference not set to an instance of an object")
This error has nothing to do with the code posted (unless you mis-represe... |
383,314 | <p>I have a window with 2 column grid.
Left column contains a browser control</p>
<p>I woould like to display a little window or something to show a
that the webpage is still loading.</p>
<p>How could I do this?? Could I have a floating window in the 2nd column
that shows in front of the browser??? please explain ho... | [
{
"answer_id": 384051,
"author": "bendewey",
"author_id": 37881,
"author_profile": "https://Stackoverflow.com/users/37881",
"pm_score": 2,
"selected": false,
"text": "<p>I'm not sure what you mean by displaying a \"little window\". do you mean a popup window or an element that displays ... | 2008/12/20 | [
"https://Stackoverflow.com/questions/383314",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40568/"
] | I have a window with 2 column grid.
Left column contains a browser control
I woould like to display a little window or something to show a
that the webpage is still loading.
How could I do this?? Could I have a floating window in the 2nd column
that shows in front of the browser??? please explain how?
Malcolm
Than... | The way I have accomplished this is by creating a user control with exposed Show() and Hide() methods. Below is the code.
Loading.xaml:
```
<UserControl x:Class="UK.Budgeting.XBAP.Loading"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" H... |
383,321 | <p>I added a new column in my table.</p>
<pre><code>ALTER TABLE neue_buch modify preis not null;
</code></pre>
<p>and I have got this error:</p>
<pre><code>Error starting at line 40 in command:
ALTER TABLE neue_buch
modify preis not null
Error report:
SQL Error: ORA-02296: cannot enable (S1885872.) - null values fou... | [
{
"answer_id": 383333,
"author": "Justin Cave",
"author_id": 10397,
"author_profile": "https://Stackoverflow.com/users/10397",
"pm_score": 3,
"selected": false,
"text": "<p>The error message is telling you that there are some rows in <code>NEUE_BUCH</code> where the <code>PREIS</code> co... | 2008/12/20 | [
"https://Stackoverflow.com/questions/383321",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I added a new column in my table.
```
ALTER TABLE neue_buch modify preis not null;
```
and I have got this error:
```
Error starting at line 40 in command:
ALTER TABLE neue_buch
modify preis not null
Error report:
SQL Error: ORA-02296: cannot enable (S1885872.) - null values found
02296. 00000 - "cannot enable (%s.... | The error message is telling you that there are some rows in `NEUE_BUCH` where the `PREIS` column is NULL. You will need to modify those rows to have non-NULL values before you can create this NOT NULL constraint. |
383,347 | <p>Let's say I've got an object <code>Customer</code> with a couple properties (<code>ID</code>, <code>FirstName</code>, <code>LastName</code>). I've got the default constructor <code>Customer()</code>, but then I've also got a <code>Customer(DataRow dr)</code>, since I load this object from a database and that's a si... | [
{
"answer_id": 383352,
"author": "PolyThinker",
"author_id": 47707,
"author_profile": "https://Stackoverflow.com/users/47707",
"pm_score": 5,
"selected": true,
"text": "<p>Simplest solution seems to be: construct another function that does the job you want to do and have both constructor... | 2008/12/20 | [
"https://Stackoverflow.com/questions/383347",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3248/"
] | Let's say I've got an object `Customer` with a couple properties (`ID`, `FirstName`, `LastName`). I've got the default constructor `Customer()`, but then I've also got a `Customer(DataRow dr)`, since I load this object from a database and that's a simple way to do it.
I frequently come to a point where I want to set u... | Simplest solution seems to be: construct another function that does the job you want to do and have both constructors call that function. |
383,368 | <p>I'm implementing saved data on my app by using NSUserDefaults, like this:</p>
<pre><code>[[NSUserDefaults standardUserDefaults] registerDefaults:[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithInt:0],@"mySetting",nil]];
// check
int firstLaunch = [[NSUserDefaults standardUserDefaults] integerForKey:@... | [
{
"answer_id": 383379,
"author": "PEZ",
"author_id": 44639,
"author_profile": "https://Stackoverflow.com/users/44639",
"pm_score": 0,
"selected": false,
"text": "<p>The docs has this to say about resetStandardUserDefaults:</p>\n\n<blockquote>\n <p>A subsequent invocation of\n standardU... | 2008/12/20 | [
"https://Stackoverflow.com/questions/383368",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36182/"
] | I'm implementing saved data on my app by using NSUserDefaults, like this:
```
[[NSUserDefaults standardUserDefaults] registerDefaults:[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithInt:0],@"mySetting",nil]];
// check
int firstLaunch = [[NSUserDefaults standardUserDefaults] integerForKey:@"mySetting"];
... | For the key which you wish to revert to the default, `-removeObjectForKey:` will remove its definition from the app preferences. All things being equal, this means that subsequent invocations of `-<type>ForKey:` will return the registered default. |
383,390 | <p>I've installed PowerShell recently and one of the first things I started looking for was how to create a new user. After looking for some time I still haven't found this.
I have a little experience in bash on linux and find it very effective. Creating users there is trivial.
Is there an easy\built-in way to create a... | [
{
"answer_id": 383396,
"author": "BobbyShaftoe",
"author_id": 38426,
"author_profile": "https://Stackoverflow.com/users/38426",
"pm_score": 5,
"selected": true,
"text": "<p>You can use the localhost's <a href=\"http://msdn.microsoft.com/en-us/library/aa772170.aspx\" rel=\"noreferrer\">AD... | 2008/12/20 | [
"https://Stackoverflow.com/questions/383390",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/430254/"
] | I've installed PowerShell recently and one of the first things I started looking for was how to create a new user. After looking for some time I still haven't found this.
I have a little experience in bash on linux and find it very effective. Creating users there is trivial.
Is there an easy\built-in way to create a lo... | You can use the localhost's [ADSI](http://msdn.microsoft.com/en-us/library/aa772170.aspx):
```
function create-account ([string]$accountName = "testuser") {
$hostname = hostname
$comp = [adsi] "WinNT://$hostname"
$user = $comp.Create("User", $accountName)
$user.SetPassword("Password1")
$us... |
383,402 | <p>In <a href="https://stackoverflow.com/questions/377716/javascript-automatic-gettersetters-john-resig-book">another question</a>, a user pointed out that the <code>new</code> keyword was dangerous to use and proposed a solution to object creation that did not use <code>new</code>. I didn't believe that was true, most... | [
{
"answer_id": 383422,
"author": "Greg Dean",
"author_id": 1200558,
"author_profile": "https://Stackoverflow.com/users/1200558",
"pm_score": 5,
"selected": false,
"text": "<p>The rationale behind not using the <em>new</em> keyword, is simple:</p>\n<p>By not using it at all, you avoid the... | 2008/12/20 | [
"https://Stackoverflow.com/questions/383402",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7595/"
] | In [another question](https://stackoverflow.com/questions/377716/javascript-automatic-gettersetters-john-resig-book), a user pointed out that the `new` keyword was dangerous to use and proposed a solution to object creation that did not use `new`. I didn't believe that was true, mostly because I've used [Prototype](htt... | Crockford has done a lot to popularize good JavaScript techniques. His opinionated stance on key elements of the language have sparked many useful discussions. That said, there are far too many people that take each proclamation of "bad" or "harmful" as gospel, refusing to look beyond one man's opinion. It can be a bit... |
383,403 | <p>Print all 12 verses of the <a href="http://en.wikipedia.org/wiki/The_Twelve_Days_of_Christmas_(song)" rel="nofollow noreferrer">popular holiday song</a>.</p>
<p>By 12 <em>verses</em> I mean the repetition of each line as is sung in the song, ie</p>
<p>Verse One:
On the first day of Christmas my true love gave to m... | [
{
"answer_id": 383404,
"author": "fizzer",
"author_id": 18167,
"author_profile": "https://Stackoverflow.com/users/18167",
"pm_score": 6,
"selected": true,
"text": "<p>Common Lisp:</p>\n\n<pre><code>(mapc #'princ\n (reverse (maplist #'(lambda(l)\n (format nil \n \"... | 2008/12/20 | [
"https://Stackoverflow.com/questions/383403",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18167/"
] | Print all 12 verses of the [popular holiday song](http://en.wikipedia.org/wiki/The_Twelve_Days_of_Christmas_(song)).
By 12 *verses* I mean the repetition of each line as is sung in the song, ie
Verse One:
On the first day of Christmas my true love gave to me
a partridge in a pear tree.
Verse Two
On the second day of... | Common Lisp:
```
(mapc #'princ
(reverse (maplist #'(lambda(l)
(format nil
"On the ~:R day of Christmas my true love gave to me~%~{~a~%~}~%"
(length l) l))
'("twelve drummers drumming,"
"eleven pipers piping,"
"ten lords a-leaping,"
"nine ladies dancin... |
383,405 | <p>I'm working on a small GreaseMonkey script where I would like to embed a jQuery plugin (Markitup) so that the script is fully self contained (images + js) except for jQuery which is served from google.</p>
<p>I found the site <a href="http://www.greywyvern.com/code/php/binary2base64" rel="noreferrer">http://www.gre... | [
{
"answer_id": 383442,
"author": "John Boker",
"author_id": 2847,
"author_profile": "https://Stackoverflow.com/users/2847",
"pm_score": 5,
"selected": true,
"text": "<p>maybe just a thought but maybe the \"href\" should be \"src\" instead.</p>\n"
},
{
"answer_id": 383443,
"au... | 2008/12/20 | [
"https://Stackoverflow.com/questions/383405",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32728/"
] | I'm working on a small GreaseMonkey script where I would like to embed a jQuery plugin (Markitup) so that the script is fully self contained (images + js) except for jQuery which is served from google.
I found the site <http://www.greywyvern.com/code/php/binary2base64> which says that you can embed javascript with the... | maybe just a thought but maybe the "href" should be "src" instead. |
383,416 | <p>If I am using <code>ReaderWriterLockSlim</code> to acquire read/write locks, do I need to make my variables <code>volatile</code> or use <code>Interlocked.Increment</code>?</p>
<p>For example, would the code in the <code>Add</code> method below work fine, or does it need enhancement?</p>
<pre><code>public class Ap... | [
{
"answer_id": 383418,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 3,
"selected": true,
"text": "<p>I would fully <em>expect</em> the write-lock to function as a memory barrier (within the write-lock, in particular)... | 2008/12/20 | [
"https://Stackoverflow.com/questions/383416",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41283/"
] | If I am using `ReaderWriterLockSlim` to acquire read/write locks, do I need to make my variables `volatile` or use `Interlocked.Increment`?
For example, would the code in the `Add` method below work fine, or does it need enhancement?
```
public class AppendableList<T> { // semi-immutable; supports appending only
... | I would fully *expect* the write-lock to function as a memory barrier (within the write-lock, in particular), but I can't prove it off-hand.
Whether you need the complexity of `ReaderWriterLockSlim` depends on the context; `Interlocked`, `volatile`, `lock` or `[MethodImpl]` might each do the job far more simply. You m... |
383,449 | <p>I have a JSP page that receives an ArrayList of event objects, each event object contains an ArrayList of dates. I am iterating through the event objects with the following:</p>
<p>
</p>
<p>How can I iterate through the dateTimes ArrayList of each event object and print out eac... | [
{
"answer_id": 383458,
"author": "cletus",
"author_id": 18393,
"author_profile": "https://Stackoverflow.com/users/18393",
"pm_score": 2,
"selected": false,
"text": "<p>If I understand your question, you essentially have an ArrayList of ArrayLists. JSTL has some fairly odd rules for what... | 2008/12/20 | [
"https://Stackoverflow.com/questions/383449",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16684/"
] | I have a JSP page that receives an ArrayList of event objects, each event object contains an ArrayList of dates. I am iterating through the event objects with the following:
How can I iterate through the dateTimes ArrayList of each event object and print out each events date/times ? | If I understand your question, you essentially have an ArrayList of ArrayLists. JSTL has some fairly odd rules for what a valid "items" "collection" is. This wasn't sufficiently answered by the [JSTL 1.2 specification](http://jcp.org/aboutJava/communityprocess/mrel/jsr052/index2.html) so I went to the source code.
for... |
383,469 | <p>I have this method:</p>
<pre><code>public bool CanExecute()
</code></pre>
<p>And after 70 commits, I added an extra parameter</p>
<pre><code>public bool CanExecute(IStation target)
</code></pre>
<p>Now the problem is I have 7 unit tests covering this CanExecute methods testing various nulls/property combinations... | [
{
"answer_id": 383488,
"author": "Jennifer",
"author_id": 22360,
"author_profile": "https://Stackoverflow.com/users/22360",
"pm_score": 3,
"selected": false,
"text": "<p>Could you not keep both methods in the code? Unless it is mandatory for the IStation parameter to be non null then you... | 2008/12/20 | [
"https://Stackoverflow.com/questions/383469",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3055/"
] | I have this method:
```
public bool CanExecute()
```
And after 70 commits, I added an extra parameter
```
public bool CanExecute(IStation target)
```
Now the problem is I have 7 unit tests covering this CanExecute methods testing various nulls/property combinations.
Adding this simple parameter required a fix of... | If you know that the method is likely to change yet again, I think the sensible thing to do is overload the method and *add* unit tests for the overloaded members, instead of changing old unit tests. If the stars align for you, you might even find that the overloaded methods call the original no-arg method, so you only... |
383,480 | <p>Have created a c++ implementation of the Hough transform for detecting lines in images. Found lines are represented using rho, theta, as described on wikipedia:</p>
<blockquote>
<p>"The parameter r represents the distance between the line and the origin, while θ is the angle of the vector from the origin to this ... | [
{
"answer_id": 383527,
"author": "Federico A. Ramponi",
"author_id": 18770,
"author_profile": "https://Stackoverflow.com/users/18770",
"pm_score": 5,
"selected": true,
"text": "<p>Looking at the <a href=\"http://en.wikipedia.org/wiki/Hough_transform\" rel=\"noreferrer\">Wikipedia page</a... | 2008/12/20 | [
"https://Stackoverflow.com/questions/383480",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47971/"
] | Have created a c++ implementation of the Hough transform for detecting lines in images. Found lines are represented using rho, theta, as described on wikipedia:
>
> "The parameter r represents the distance between the line and the origin, while θ is the angle of the vector from the origin to this closest point "
>
>... | Looking at the [Wikipedia page](http://en.wikipedia.org/wiki/Hough_transform), I see that the equation of a straight line corresponding to a given given r, θ pair is
```
r = x cosθ + y sinθ
```
Thus, if I understand, given two pairs r1, θ1 and r2, θ2, to find the intersection you must solve for the unknowns x,y the ... |
383,481 | <p>// Tratamento de eventos: caso o utilizador clique numa das células da tabela
Hello again guys,
I was trying to display a UIAlertView to show the summary of a 'Movie' object i have stored and my idea was to show two buttons in it if i had the movie's website stored, or just to show one if the movie didn't have one.<... | [
{
"answer_id": 383483,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>Can you see the pic?\nIt's here if you can't: <a href=\"http://i41.tinypic.com/2vc9hg9.jpg\" rel=\"nofollow noreferrer\">ht... | 2008/12/20 | [
"https://Stackoverflow.com/questions/383481",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | // Tratamento de eventos: caso o utilizador clique numa das células da tabela
Hello again guys,
I was trying to display a UIAlertView to show the summary of a 'Movie' object i have stored and my idea was to show two buttons in it if i had the movie's website stored, or just to show one if the movie didn't have one.
Od... | The first dialog is the standard UIAlertView. The second I can only guess, but I would assume it's when you have too much message text, and it looks different to signal the user that they can scroll the message. The third is UIAlertView with just a title and no message at all. |
383,528 | <p>I have a Perl hash whose keys start with, or are, numbers.</p>
<p>If I use,</p>
<pre><code>foreach my $key (sort keys %hash) {
print $hash{$key} . "\n";
}
</code></pre>
<p>the list might come out as,</p>
<pre><code>0
0001
1000
203
23
</code></pre>
<p>Instead of</p>
<pre><code>0
0001
23
203
1000
</code></pr... | [
{
"answer_id": 383539,
"author": "Paul Tomblin",
"author_id": 3333,
"author_profile": "https://Stackoverflow.com/users/3333",
"pm_score": 6,
"selected": true,
"text": "<pre><code>foreach my $key (sort { $a <=> $b} keys %hash) {\n print $hash{$key} . \"\\n\";\n}\n</code></pre>\n\... | 2008/12/20 | [
"https://Stackoverflow.com/questions/383528",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15884/"
] | I have a Perl hash whose keys start with, or are, numbers.
If I use,
```
foreach my $key (sort keys %hash) {
print $hash{$key} . "\n";
}
```
the list might come out as,
```
0
0001
1000
203
23
```
Instead of
```
0
0001
23
203
1000
``` | ```
foreach my $key (sort { $a <=> $b} keys %hash) {
print $hash{$key} . "\n";
}
```
The sort operation takes an optional comparison "subroutine" (either as a block of code, as I've done here, or the name of a subroutine). I've supplied an in-line comparison that treats the keys as numbers using the built-in nume... |
383,550 | <p>im just starting to learn flex and im trying to understand how Flex does remoting? From what i have read it looks like Flex provides a LifeCycle data services war which sits on your server and intercepts your remote calls , is this close?</p>
<p>Im concerned that if i use this option that 1. Ill have to add an extr... | [
{
"answer_id": 383539,
"author": "Paul Tomblin",
"author_id": 3333,
"author_profile": "https://Stackoverflow.com/users/3333",
"pm_score": 6,
"selected": true,
"text": "<pre><code>foreach my $key (sort { $a <=> $b} keys %hash) {\n print $hash{$key} . \"\\n\";\n}\n</code></pre>\n\... | 2008/12/20 | [
"https://Stackoverflow.com/questions/383550",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24481/"
] | im just starting to learn flex and im trying to understand how Flex does remoting? From what i have read it looks like Flex provides a LifeCycle data services war which sits on your server and intercepts your remote calls , is this close?
Im concerned that if i use this option that 1. Ill have to add an extra war to m... | ```
foreach my $key (sort { $a <=> $b} keys %hash) {
print $hash{$key} . "\n";
}
```
The sort operation takes an optional comparison "subroutine" (either as a block of code, as I've done here, or the name of a subroutine). I've supplied an in-line comparison that treats the keys as numbers using the built-in nume... |
383,560 | <p>In my custom button I need to show that it had focus(provides some tactile feel to tabbing to the button) and show that its pressed but what I have found is my focused state is displaying rather then my pressed state. How can I correct this. I would like to have mouse over to pressed not mouse over then focused(... | [
{
"answer_id": 394881,
"author": "Shawn Wildermuth",
"author_id": 40125,
"author_profile": "https://Stackoverflow.com/users/40125",
"pm_score": 2,
"selected": true,
"text": "<p>When you press it is becomes focused, can't do anything about that...you can clear the Visual State Manager's F... | 2008/12/20 | [
"https://Stackoverflow.com/questions/383560",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5618/"
] | In my custom button I need to show that it had focus(provides some tactile feel to tabbing to the button) and show that its pressed but what I have found is my focused state is displaying rather then my pressed state. How can I correct this. I would like to have mouse over to pressed not mouse over then focused(when th... | When you press it is becomes focused, can't do anything about that...you can clear the Visual State Manager's Focus content and then it won't *look* focused, but it get focus from the mouse interaction no matter what you do. |
383,565 | <p>I'm using Python to <strong>infinitely</strong> iterate over a list, repeating each element in the list a number of times. For example given the list:</p>
<pre><code>l = [1, 2, 3, 4]
</code></pre>
<p>I would like to output each element two times and then repeat the cycle:</p>
<pre><code>1, 1, 2, 2, 3, 3, 4, 4, 1,... | [
{
"answer_id": 383573,
"author": "rob",
"author_id": 43927,
"author_profile": "https://Stackoverflow.com/users/43927",
"pm_score": 1,
"selected": false,
"text": "<p>Solution should be something like</p>\n\n<pre><code>iterable = [1, 2, 3, 4]\nn = 2\n\nwhile (True):\n for elem in iterable... | 2008/12/20 | [
"https://Stackoverflow.com/questions/383565",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37522/"
] | I'm using Python to **infinitely** iterate over a list, repeating each element in the list a number of times. For example given the list:
```
l = [1, 2, 3, 4]
```
I would like to output each element two times and then repeat the cycle:
```
1, 1, 2, 2, 3, 3, 4, 4, 1, 1, 2, 2 ...
```
I've got an idea of where to s... | How about this:
```
import itertools
def bicycle(iterable, repeat=1):
for item in itertools.cycle(iterable):
for _ in xrange(repeat):
yield item
c = bicycle([1,2,3,4], 2)
print [c.next() for _ in xrange(10)]
```
EDIT: incorporated [bishanty's](https://stackoverflow.com/users/37522/bishanty)... |
383,570 | <p>What is the easiest way in Java to map strings (Java <code>String</code>) to (positive) integers (Java <code>int</code>), so that</p>
<ul>
<li>equal strings map to equal integers, and</li>
<li>different strings map to different integers?</li>
</ul>
<p>So, similar to <code>hashCode()</code> but different strings ar... | [
{
"answer_id": 383575,
"author": "Bill the Lizard",
"author_id": 1288,
"author_profile": "https://Stackoverflow.com/users/1288",
"pm_score": 2,
"selected": false,
"text": "<p>There's not going to be an easy or complete solution. We use hashes because there are way more possible Strings ... | 2008/12/20 | [
"https://Stackoverflow.com/questions/383570",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12547/"
] | What is the easiest way in Java to map strings (Java `String`) to (positive) integers (Java `int`), so that
* equal strings map to equal integers, and
* different strings map to different integers?
So, similar to `hashCode()` but different strings are required to produce different integers. So, in a sense, it would b... | This is impossible to achieve without any restrictions, simply because there are more possible Strings than there are integers, so eventually you will run out of numbers.
A solution is only possible when you limit the number of usable Strings. Then you can use a simple counter. Here is a simple implementation where al... |
383,587 | <p>The built-in <code>Math.Pow()</code> function in .NET raises a <code>double</code> base to a <code>double</code> exponent and returns a <code>double</code> result.</p>
<p>What's the best way to do the same with integers?</p>
<p>Added: It seems that one can just cast <code>Math.Pow()</code> result to (int), but wil... | [
{
"answer_id": 383596,
"author": "Vilx-",
"author_id": 41360,
"author_profile": "https://Stackoverflow.com/users/41360",
"pm_score": 7,
"selected": true,
"text": "<p>A pretty fast one might be something like this:</p>\n\n<pre><code>int IntPow(int x, uint pow)\n{\n int ret = 1;\n wh... | 2008/12/20 | [
"https://Stackoverflow.com/questions/383587",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33080/"
] | The built-in `Math.Pow()` function in .NET raises a `double` base to a `double` exponent and returns a `double` result.
What's the best way to do the same with integers?
Added: It seems that one can just cast `Math.Pow()` result to (int), but will this always produce the correct number and no rounding errors? | A pretty fast one might be something like this:
```
int IntPow(int x, uint pow)
{
int ret = 1;
while ( pow != 0 )
{
if ( (pow & 1) == 1 )
ret *= x;
x *= x;
pow >>= 1;
}
return ret;
}
```
Note that this does not allow negative powers. I'll leave that as an exerc... |
383,595 | <p>I had a typo in my fstab and it boots to a commandline but is readonly, I know what the error is but i can't change it because it's mounted as readonly. I want to mount the filesystem and make the changes. I know I can boot a live distro and edit it that way, but i was wondering if there was an easier way to do it.<... | [
{
"answer_id": 383842,
"author": "MarkR",
"author_id": 13724,
"author_profile": "https://Stackoverflow.com/users/13724",
"pm_score": 5,
"selected": false,
"text": "<p>Yes, if you end up in single-user mode with a readonly root, try:</p>\n\n<pre><code>mount / -o remount,rw\n</code></pre>\... | 2008/12/20 | [
"https://Stackoverflow.com/questions/383595",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I had a typo in my fstab and it boots to a commandline but is readonly, I know what the error is but i can't change it because it's mounted as readonly. I want to mount the filesystem and make the changes. I know I can boot a live distro and edit it that way, but i was wondering if there was an easier way to do it.
It... | Yes, if you end up in single-user mode with a readonly root, try:
```
mount / -o remount,rw
```
Maybe a -n is necessary, maybe not. That should remount the root fs read/write (assuming there's nothing wrong with it). |
383,600 | <p>I have a Java web app that reads a MySql db and returns DateTime fields. What is the best way to convert the DateTime fields returned in the resultset into something more readable?</p>
<p>Currently the DateTime fields print as:</p>
<p>2008-12-14 16:30:00</p>
<p>but I would like something more user friendly like:... | [
{
"answer_id": 383612,
"author": "Zoredache",
"author_id": 20267,
"author_profile": "https://Stackoverflow.com/users/20267",
"pm_score": 2,
"selected": false,
"text": "<p>Mysql <a href=\"http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_date-format\" rel=\"nofo... | 2008/12/20 | [
"https://Stackoverflow.com/questions/383600",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16684/"
] | I have a Java web app that reads a MySql db and returns DateTime fields. What is the best way to convert the DateTime fields returned in the resultset into something more readable?
Currently the DateTime fields print as:
2008-12-14 16:30:00
but I would like something more user friendly like:
14 Dec 2008 at 16:30
I... | Another option is to use the JSTL. The formatting library makes it easy to display a date in any format and it is i18n aware. The advantage is that you can leave the date as a Date object and manipulate it as such but only convert it when you need to display. The format tag will look like this:
```
<fmt:formatDate val... |
383,623 | <p>How do you apply 'or' to all values of a list in Python? I'm thinking something like:</p>
<pre><code>or([True, True, False])
</code></pre>
<p>or if it was possible:</p>
<pre><code>reduce(or, [True, True, False])
</code></pre>
| [
{
"answer_id": 383637,
"author": "Dustin",
"author_id": 39975,
"author_profile": "https://Stackoverflow.com/users/39975",
"pm_score": 2,
"selected": false,
"text": "<p>You can do this:</p>\n\n<pre><code>reduce(lambda a,b: a or b, [True, True, False])\n</code></pre>\n"
},
{
"answe... | 2008/12/20 | [
"https://Stackoverflow.com/questions/383623",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6068/"
] | How do you apply 'or' to all values of a list in Python? I'm thinking something like:
```
or([True, True, False])
```
or if it was possible:
```
reduce(or, [True, True, False])
``` | The built-in function `any` does what you want:
```
>>> any([True, True, False])
True
>>> any([False, False, False])
False
>>> any([False, False, True])
True
```
`any` has the advantage over `reduce` of shortcutting the test for later items in the sequence once it finds a true value. This can be very handy if the se... |
383,631 | <p>How do I use the <code>json_encode()</code> function with MySQL query results? Do I need to iterate through the rows or can I just apply it to the entire results object?</p>
| [
{
"answer_id": 383662,
"author": "Hugh Bothwell",
"author_id": 33258,
"author_profile": "https://Stackoverflow.com/users/33258",
"pm_score": 5,
"selected": false,
"text": "<p><a href=\"http://www.php.net/mysql_query\" rel=\"noreferrer\">http://www.php.net/mysql_query</a> says \"<code>mys... | 2008/12/20 | [
"https://Stackoverflow.com/questions/383631",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12073/"
] | How do I use the `json_encode()` function with MySQL query results? Do I need to iterate through the rows or can I just apply it to the entire results object? | ```
$sth = mysqli_query($conn, "SELECT ...");
$rows = array();
while($r = mysqli_fetch_assoc($sth)) {
$rows[] = $r;
}
print json_encode($rows);
```
The function `json_encode` needs PHP >= 5.2 and the **php-json** package - as mentioned [here](https://stackoverflow.com/questions/7318191/enable-json-encode-in-php)
... |
383,633 | <p>I am working on a UNIX box, and trying to run an application, which gives some debug logs to the standard output. I have redirected this output to a log file, but now wish to get the lines where the error is being shown.</p>
<p>My problem here is that a simple</p>
<pre><code>cat output.log | grep FAIL
</code></pre... | [
{
"answer_id": 383639,
"author": "Mike Reedell",
"author_id": 4897,
"author_profile": "https://Stackoverflow.com/users/4897",
"pm_score": 4,
"selected": true,
"text": "<p>grep -A $NUM</p>\n\n<p>This will print $NUM lines of trailing context after matches.</p>\n\n<p>-B $NUM prints leading... | 2008/12/20 | [
"https://Stackoverflow.com/questions/383633",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35416/"
] | I am working on a UNIX box, and trying to run an application, which gives some debug logs to the standard output. I have redirected this output to a log file, but now wish to get the lines where the error is being shown.
My problem here is that a simple
```
cat output.log | grep FAIL
```
does not help out. As this ... | grep -A $NUM
This will print $NUM lines of trailing context after matches.
-B $NUM prints leading context.
>
> man grep is your best friend.
>
>
>
So in your case:
>
> cat log | grep -A 3 -B 3 FAIL
>
>
> |
383,634 | <p>Well I run a small video website and on the actual video page there is a strip of "related videos" similar to most video sides (e.g. YouTube) and currently all I'm doing is taking one of its tags randomly and finding other videos with the same tag. Not surprisingly this isn't a great method as some tags are very va... | [
{
"answer_id": 383669,
"author": "frankodwyer",
"author_id": 42404,
"author_profile": "https://Stackoverflow.com/users/42404",
"pm_score": 1,
"selected": false,
"text": "<p>Very interesting question.</p>\n\n<p>This is just thinking out loud, but some options I can think of are:</p>\n\n<p... | 2008/12/20 | [
"https://Stackoverflow.com/questions/383634",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/428190/"
] | Well I run a small video website and on the actual video page there is a strip of "related videos" similar to most video sides (e.g. YouTube) and currently all I'm doing is taking one of its tags randomly and finding other videos with the same tag. Not surprisingly this isn't a great method as some tags are very vague ... | This query should return the id's of videos (v2) that have tags in common with your given video (v1), in descending order of the number of tags in common.
```
SELECT v2.video_id
FROM VideoTags AS v1
JOIN VideoTags AS v2
USING (tag_id)
WHERE v1.video_id = ?
AND v1.video_id <> v2.video_id
GROUP BY v2.video_id
ORD... |
383,658 | <p>I am programming winforms using c# and vb.net.</p>
<p>I love the arrows used in coderush.</p>
<p>for those who have not seen coderush arrows ,please see this image.</p>
<p><a href="https://i.stack.imgur.com/6IVX6.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6IVX6.jpg" alt="http://www.aspnetp... | [
{
"answer_id": 383669,
"author": "frankodwyer",
"author_id": 42404,
"author_profile": "https://Stackoverflow.com/users/42404",
"pm_score": 1,
"selected": false,
"text": "<p>Very interesting question.</p>\n\n<p>This is just thinking out loud, but some options I can think of are:</p>\n\n<p... | 2008/12/20 | [
"https://Stackoverflow.com/questions/383658",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48027/"
] | I am programming winforms using c# and vb.net.
I love the arrows used in coderush.
for those who have not seen coderush arrows ,please see this image.
[](https://i.stack.imgur.com/6IVX6.jpg... | This query should return the id's of videos (v2) that have tags in common with your given video (v1), in descending order of the number of tags in common.
```
SELECT v2.video_id
FROM VideoTags AS v1
JOIN VideoTags AS v2
USING (tag_id)
WHERE v1.video_id = ?
AND v1.video_id <> v2.video_id
GROUP BY v2.video_id
ORD... |
383,680 | <p>I've developed a web service in asp.net and am able to test it from an in-project aspx page and can readily display the information that was returned in JSON format.</p>
<p>I now need to consume the web service from a stand-alone html page.</p>
<p>Does someone have experience with this? I'm puzzled by the part th... | [
{
"answer_id": 383688,
"author": "Mark Brackett",
"author_id": 2199,
"author_profile": "https://Stackoverflow.com/users/2199",
"pm_score": 1,
"selected": false,
"text": "<p><a href=\"http://encosia.com/2008/03/27/using-jquery-to-consume-aspnet-json-web-services/\" rel=\"nofollow noreferr... | 2008/12/20 | [
"https://Stackoverflow.com/questions/383680",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36902/"
] | I've developed a web service in asp.net and am able to test it from an in-project aspx page and can readily display the information that was returned in JSON format.
I now need to consume the web service from a stand-alone html page.
Does someone have experience with this? I'm puzzled by the part that would replace t... | See this link:
<http://encosia.com/2008/03/27/using-jquery-to-consume-aspnet-json-web-services/>
Use JQuery
www.jquery.org
Essentially, you make your Web Service script callable, just an attribute in your Web Service definition and you do:
```
$.ajax({
type: "POST",
url: "~/MyService.asmx/MyMethod",
... |
383,686 | <p>I've got a "diagnostics" page in my ASP.NET application which does things like verify the database connection(s), display the current appSettings and ConnectionStrings, etc. A section of this page displays the Assembly versions of important types used throughout, but I could not figure out how to effectively show t... | [
{
"answer_id": 383690,
"author": "Kent Boogaart",
"author_id": 5380,
"author_profile": "https://Stackoverflow.com/users/5380",
"pm_score": 8,
"selected": false,
"text": "<p>Getting loaded assemblies for the current <code>AppDomain</code>:</p>\n\n<pre><code>var loadedAssemblies = AppDomai... | 2008/12/20 | [
"https://Stackoverflow.com/questions/383686",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13960/"
] | I've got a "diagnostics" page in my ASP.NET application which does things like verify the database connection(s), display the current appSettings and ConnectionStrings, etc. A section of this page displays the Assembly versions of important types used throughout, but I could not figure out how to effectively show the v... | This extension method gets all referenced assemblies, recursively, including nested assemblies.
As it uses `ReflectionOnlyLoad`, it loads the assemblies in a separate AppDomain, which has the advantage of not interfering with the JIT process.
You'll notice that there is also a `MyGetMissingAssembliesRecursive`. You c... |
383,689 | <p>I made a custom TObjectList descendant designed to hold subclasses of a base object class. It looks something like this:</p>
<pre><code>interface
TMyDataList<T: TBaseDatafile> = class(TObjectList<TBaseDatafile>)
public
constructor Create;
procedure upload(db: TDataSet);
end;
imple... | [
{
"answer_id": 383698,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 5,
"selected": true,
"text": "<p>You're trying to create an instance of <code>T</code> via <code>T.Create</code>. This doesn't work because the comp... | 2008/12/20 | [
"https://Stackoverflow.com/questions/383689",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32914/"
] | I made a custom TObjectList descendant designed to hold subclasses of a base object class. It looks something like this:
```
interface
TMyDataList<T: TBaseDatafile> = class(TObjectList<TBaseDatafile>)
public
constructor Create;
procedure upload(db: TDataSet);
end;
implementation
constructor TMyD... | You're trying to create an instance of `T` via `T.Create`. This doesn't work because the compiler doesn't know that your generic type has a parameterless constructor (remember: this is no requirement). To rectify this, you've got to create a constructor constraint, which looks like this:
```
<T: constructor>
```
or,... |
383,692 | <p>I've looked on Wikipedia and Googled it and read the official documentation, but I still haven't got to the point where I really understand what JSON is, and why I'd use it.</p>
<p>I have been building applications using PHP, MySQL and JavaScript / HTML for a while, and if JSON can do something to make my life easie... | [
{
"answer_id": 383699,
"author": "Andreas Grech",
"author_id": 44084,
"author_profile": "https://Stackoverflow.com/users/44084",
"pm_score": 10,
"selected": true,
"text": "<p><strong>JSON (JavaScript Object Notation) is a lightweight format that is used for data interchanging.</strong> ... | 2008/12/20 | [
"https://Stackoverflow.com/questions/383692",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11522/"
] | I've looked on Wikipedia and Googled it and read the official documentation, but I still haven't got to the point where I really understand what JSON is, and why I'd use it.
I have been building applications using PHP, MySQL and JavaScript / HTML for a while, and if JSON can do something to make my life easier or my c... | **JSON (JavaScript Object Notation) is a lightweight format that is used for data interchanging.** It is based on a subset of JavaScript language (the way objects are built in JavaScript). As [stated in the MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON), some JavaScript is n... |
383,728 | <p>Well, I have this bit of code that is slowing down the program hugely because it is linear complexity but called a lot of times making the program quadratic complexity. If possible I would like to reduce its computational complexity but otherwise I'll just optimize it where I can. So far I have reduced down to:</p>
... | [
{
"answer_id": 383732,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 3,
"selected": false,
"text": "<p>Ignoring the algorithm for a moment (yes, I know, bad idea), the running time of this can be decreased <em>hugely<... | 2008/12/20 | [
"https://Stackoverflow.com/questions/383728",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Well, I have this bit of code that is slowing down the program hugely because it is linear complexity but called a lot of times making the program quadratic complexity. If possible I would like to reduce its computational complexity but otherwise I'll just optimize it where I can. So far I have reduced down to:
```
de... | Based off OP's second edit:
```
def table(n):
if n == 2: return 1
if n%4 != 1: return
mod = 0
a1 = n - 1
for a in xrange(1, a1, 2):
mod += a
while mod >= n: mod -= n
if mod == a1: return a//2 + 1
``` |
383,734 | <p>What do you recommend for displaying URLs and handling views in Rails for cities, regions, countries?</p>
<p>i.e:</p>
<p>/us/ca/San-Fransisco</p>
<p>/countries/us/regions/ca/cities/San-Fransisco</p>
<p>Should be able to:
List all countries, list all regions within country and list all cities within a region and ... | [
{
"answer_id": 383824,
"author": "Arne Burmeister",
"author_id": 12890,
"author_profile": "https://Stackoverflow.com/users/12890",
"pm_score": 1,
"selected": false,
"text": "<p>I would prefer the simple /us/ca/San-Fransisco. A shorter path will result in a listing:</p>\n\n<ul>\n<li>/ lis... | 2008/12/20 | [
"https://Stackoverflow.com/questions/383734",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/50718/"
] | What do you recommend for displaying URLs and handling views in Rails for cities, regions, countries?
i.e:
/us/ca/San-Fransisco
/countries/us/regions/ca/cities/San-Fransisco
Should be able to:
List all countries, list all regions within country and list all cities within a region and country.
Where would you put c... | Agree with Arne. I don't see any problem with the first variant.
As for the second question, you better get the list of regions in the RegionsController.
Say you want to
```
GET /us/regions
```
then you should route it to
```
class RegionsController < ApplicationController
# GET /:country_code/regions
# GET... |
383,735 | <p>Are methods calls really so slow or is there something wrong in my computer?</p>
<pre><code>static void Main(string[] args) {
Stopwatch sw = new Stopwatch(); sw.Start();
for (int i = 0; i < 10000000; i++) {
double z = Math.Pow(i,2);
}
Console.WriteLine(sw.ElapsedMilliseconds);
sw = S... | [
{
"answer_id": 383741,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 3,
"selected": false,
"text": "<p>Chances are you either:</p>\n\n<ul>\n<li>Built in debug mode</li>\n<li>Ran in the debugger.</li>\n</ul>\n\n<p>My resu... | 2008/12/20 | [
"https://Stackoverflow.com/questions/383735",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38561/"
] | Are methods calls really so slow or is there something wrong in my computer?
```
static void Main(string[] args) {
Stopwatch sw = new Stopwatch(); sw.Start();
for (int i = 0; i < 10000000; i++) {
double z = Math.Pow(i,2);
}
Console.WriteLine(sw.ElapsedMilliseconds);
sw = Stopwatch.StartNew... | >
> 1723 13 Is that more like what you'd expect?
>
>
>
Yes, that's what I would expect. I'm not running in debug mode (debug mode gives me 1900/3200). Running it with the IDE open or closed I get the same results. Using csc or using ngen install does not change the result.
I think I should reinstall .net framewo... |
383,738 | <p>We're developing a Python web service and a client web site in parallel. When we make an HTTP request from the client to the service, one call consistently raises a socket.error in socket.py, in read:</p>
<pre>(104, 'Connection reset by peer')</pre>
<p>When I listen in with wireshark, the "good" and "bad" respons... | [
{
"answer_id": 383816,
"author": "S.Lott",
"author_id": 10661,
"author_profile": "https://Stackoverflow.com/users/10661",
"pm_score": 6,
"selected": true,
"text": "<p>I've had this problem. See <a href=\"http://www.itmaybeahack.com/homepage/iblog/architecture/C551260341/E20081031204203/... | 2008/12/20 | [
"https://Stackoverflow.com/questions/383738",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10612/"
] | We're developing a Python web service and a client web site in parallel. When we make an HTTP request from the client to the service, one call consistently raises a socket.error in socket.py, in read:
```
(104, 'Connection reset by peer')
```
When I listen in with wireshark, the "good" and "bad" responses look very s... | I've had this problem. See [The Python "Connection Reset By Peer" Problem](http://www.itmaybeahack.com/homepage/iblog/architecture/C551260341/E20081031204203/index.html).
You have (most likely) run afoul of small timing issues based on the Python Global Interpreter Lock.
You can (sometimes) correct this with a `time.... |