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 |
|---|---|---|---|---|---|---|
460,300 | <p>Should I be storing the raw SQL queries in my c# code, or should I be delegating them to stored functions in the Postgres Backend?</p>
<p>If I should be storing them in code, since they can get quite long, what is the optimal way to store them (ie. as constants in a separate static class)?</p>
<p>Does using stored... | [
{
"answer_id": 460350,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 2,
"selected": true,
"text": "<p>I quite like storing SQL in text files embedded as resources into the assembly (when I absolutely <em>have</em> to hav... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460300",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49142/"
] | Should I be storing the raw SQL queries in my c# code, or should I be delegating them to stored functions in the Postgres Backend?
If I should be storing them in code, since they can get quite long, what is the optimal way to store them (ie. as constants in a separate static class)?
Does using stored functions have a... | I quite like storing SQL in text files embedded as resources into the assembly (when I absolutely *have* to have a significant number of them; I'm an ORM man normally).
Quite how you format that text file is up to you, of course. You could have double-line-break delimited:
```
UpdateCustomer:
UPDATE CUSTOMER SET NAME... |
460,301 | <p>When I add an HTTP handler:</p>
<pre><code><add verb="*" path="*test.aspx" type="Handler"/>
</code></pre>
<p>With the class:</p>
<pre><code>using System;
using System.Web;
public class Handler : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType =... | [
{
"answer_id": 460327,
"author": "Darin Dimitrov",
"author_id": 29407,
"author_profile": "https://Stackoverflow.com/users/29407",
"pm_score": 5,
"selected": true,
"text": "<p>I guess you are using a web site project in contrast of web application project. In this case you need to put the... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460301",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11574/"
] | When I add an HTTP handler:
```
<add verb="*" path="*test.aspx" type="Handler"/>
```
With the class:
```
using System;
using System.Web;
public class Handler : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
context.Response.Wri... | I guess you are using a web site project in contrast of web application project. In this case you need to put the code behind file of your handler (Handler.cs) in the special App\_Code folder. The markup file (Handler.ashx) may be at the root of your site:
```
<%@ WebHandler Language="C#" Class="Handler" CodeBehind="H... |
460,302 | <p>I am using Linked server for Transaction<br>
example</p>
<pre><code>Alter Proc [dbo].[usp_Select_TransferingDatasFromServerCheckingforExample]
@RserverName varchar(100), ----- Server Name
@RUserid Varchar(100), ----- server user id
@RPass Varchar(100), ----- Server Password
@DbName varchar(100) ... | [
{
"answer_id": 460327,
"author": "Darin Dimitrov",
"author_id": 29407,
"author_profile": "https://Stackoverflow.com/users/29407",
"pm_score": 5,
"selected": true,
"text": "<p>I guess you are using a web site project in contrast of web application project. In this case you need to put the... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460302",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53679/"
] | I am using Linked server for Transaction
example
```
Alter Proc [dbo].[usp_Select_TransferingDatasFromServerCheckingforExample]
@RserverName varchar(100), ----- Server Name
@RUserid Varchar(100), ----- server user id
@RPass Varchar(100), ----- Server Password
@DbName varchar(100) ----- Server da... | I guess you are using a web site project in contrast of web application project. In this case you need to put the code behind file of your handler (Handler.cs) in the special App\_Code folder. The markup file (Handler.ashx) may be at the root of your site:
```
<%@ WebHandler Language="C#" Class="Handler" CodeBehind="H... |
460,322 | <p>I am using JSON in PHP, and now I need to access it from JavaScript. How do I pass a JSON object to JavaScript?</p>
<pre><code><?php
$array = array("a"=>"Caucho", "b"=>"Resin", "c"=>"Quercus");
$json = json_encode($array);
>
</code></pre>
<p>where My.js has:</p>
<pre><code>showAll(){
al... | [
{
"answer_id": 460340,
"author": "Jan Hančič",
"author_id": 185527,
"author_profile": "https://Stackoverflow.com/users/185527",
"pm_score": 2,
"selected": false,
"text": "<p>You could request the JSON data with AJAX or you could pass the data from PHP to JavaScript as a JavaScript variab... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460322",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44984/"
] | I am using JSON in PHP, and now I need to access it from JavaScript. How do I pass a JSON object to JavaScript?
```
<?php
$array = array("a"=>"Caucho", "b"=>"Resin", "c"=>"Quercus");
$json = json_encode($array);
>
```
where My.js has:
```
showAll(){
alert("Show All Json Objects");
// How do I get th... | Assuming that you're using Ajax as your method to download the JSON, you would echo the result of the json\_encode:
```
<?php
$array = array("a"=>"Caucho", "b"=>"Resin", "c"=>"Quercus");
echo json_encode($array);
?>
```
And then within your call back event, you'd eval the response:
```
var obj = eval('(' +... |
460,331 | <p>I added a file to the index with:</p>
<pre><code>git add somefile.txt
</code></pre>
<p>I then got the SHA1 for this file with:</p>
<pre><code>git hash-object somefile.txt
</code></pre>
<p>I now have a SHA1 and I would like to retrieve the filename of the object in the index using the SHA1.</p>
<pre><code>git sh... | [
{
"answer_id": 460402,
"author": "Baishampayan Ghose",
"author_id": 8024,
"author_profile": "https://Stackoverflow.com/users/8024",
"pm_score": -1,
"selected": false,
"text": "<p>Commit the file and note the sha1 hash of the commit object. After that use</p>\n\n<pre><code>git ls-tree <... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460331",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/52416/"
] | I added a file to the index with:
```
git add somefile.txt
```
I then got the SHA1 for this file with:
```
git hash-object somefile.txt
```
I now have a SHA1 and I would like to retrieve the filename of the object in the index using the SHA1.
```
git show 5a5bf28dcd7944991944cc5076c7525439830122
```
This comma... | There's no such direct mapping in git as the name of the file is part of the tree object that contains the file, not of the blob object that is the file's contents.
It's not a usual operation to want to retrieve a file name from a SHA1 hash so perhaps you could expand on a real world use case for it?
If you're lookin... |
460,352 | <p>I'm trying to use sIFR (with the jQuery sIFR plugin) on my website, but have run into problems right from the start. I was able to create the swf with my chosen font, but when I run the script, I just get the default "Rendered with sIFR3" message instead of the text of my element.</p>
<p>Any ideas?</p>
<hr>
<p>As... | [
{
"answer_id": 460573,
"author": "Alex Gyoshev",
"author_id": 25427,
"author_profile": "https://Stackoverflow.com/users/25427",
"pm_score": 0,
"selected": false,
"text": "<p>It seems to me that the swf file has been broken (e.g. during export).</p>\n\n<p>You can determine this by replaci... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460352",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9021/"
] | I'm trying to use sIFR (with the jQuery sIFR plugin) on my website, but have run into problems right from the start. I was able to create the swf with my chosen font, but when I run the script, I just get the default "Rendered with sIFR3" message instead of the text of my element.
Any ideas?
---
As [Novemberborn him... | The jQuery plugin uses sIFR 2, however you seem to be using an (old) sIFR 3 movie. |
460,355 | <p>I want to be able to set an ASP.NET Theme in a gateway page, which will determine the theme based upon a partner id or something like that. I figure I'd just stick the theme name in session and get it from there if I need it.</p>
<p>I'm having trouble finding the right place to put this code in a single place.</p>... | [
{
"answer_id": 460372,
"author": "M4N",
"author_id": 19635,
"author_profile": "https://Stackoverflow.com/users/19635",
"pm_score": 2,
"selected": false,
"text": "<p>One option would be to create your own Page base class and handle the theme switching/setting there. Then use that class as... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460355",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16940/"
] | I want to be able to set an ASP.NET Theme in a gateway page, which will determine the theme based upon a partner id or something like that. I figure I'd just stick the theme name in session and get it from there if I need it.
I'm having trouble finding the right place to put this code in a single place.
I cannot seem... | One option would be to create your own Page base class and handle the theme switching/setting there. Then use that class as the base class of all your pages.
```
public class PageBase : Page
{
protected void Page_PreInit(object sender, EventArgs e)
{
//..
Page.Theme = "BlueTheme";
//..
}
}
public cl... |
460,356 | <p>I have strings like X,Y. I want to separate X from Y using javascript. Please describe how to as I am new at javascript</p>
| [
{
"answer_id": 460363,
"author": "unwind",
"author_id": 28169,
"author_profile": "https://Stackoverflow.com/users/28169",
"pm_score": 3,
"selected": false,
"text": "<p>Sounds like you want <a href=\"http://www.w3schools.com/jsref/jsref_split.asp\" rel=\"noreferrer\">split()</a>. You woul... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460356",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have strings like X,Y. I want to separate X from Y using javascript. Please describe how to as I am new at javascript | Sounds like you want [split()](http://www.w3schools.com/jsref/jsref_split.asp). You would use it like this:
```
a = "X,Y"
b = a.split(",")
```
This would create an array of the strings "X" and "Y" and put that in b. |
460,358 | <p>I'm trying to setup a sqlserver 2005 that will be accessed using C++ and ODBC (the data read will be sent in XML files). So, I want to read data from the database (preferably utf-8), compose a XML file and send it.</p>
<p>I have been browsing around and i haven't found a way to setup the database and the tables for... | [
{
"answer_id": 460363,
"author": "unwind",
"author_id": 28169,
"author_profile": "https://Stackoverflow.com/users/28169",
"pm_score": 3,
"selected": false,
"text": "<p>Sounds like you want <a href=\"http://www.w3schools.com/jsref/jsref_split.asp\" rel=\"noreferrer\">split()</a>. You woul... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460358",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20367/"
] | I'm trying to setup a sqlserver 2005 that will be accessed using C++ and ODBC (the data read will be sent in XML files). So, I want to read data from the database (preferably utf-8), compose a XML file and send it.
I have been browsing around and i haven't found a way to setup the database and the tables for using utf... | Sounds like you want [split()](http://www.w3schools.com/jsref/jsref_split.asp). You would use it like this:
```
a = "X,Y"
b = a.split(",")
```
This would create an array of the strings "X" and "Y" and put that in b. |
460,364 | <p>I read the Java tutorials on Sun for JAR files, but I still can't find a solution for my problem. I need to use a class from a jar file called jtwitter.jar, I downloaded the file, and tried executing it (I found out yesterday that .jar files can be executed by double clicking on them) and Vista gave me an error sayi... | [
{
"answer_id": 460373,
"author": "workmad3",
"author_id": 16035,
"author_profile": "https://Stackoverflow.com/users/16035",
"pm_score": 3,
"selected": false,
"text": "<p>You need to put the .jar file into your classpath when compiling/running your code. Then you just use standard imports... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460364",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47825/"
] | I read the Java tutorials on Sun for JAR files, but I still can't find a solution for my problem. I need to use a class from a jar file called jtwitter.jar, I downloaded the file, and tried executing it (I found out yesterday that .jar files can be executed by double clicking on them) and Vista gave me an error saying ... | Not every jar file is executable.
Now, you need to import the classes, which are there under the jar, in your java file. For example,
```
import org.xml.sax.SAXException;
```
If you are working on an IDE, then you should refer its documentation. Or at least specify which one you are using here in this thread. It wo... |
460,371 | <p>i recently stumbled upon a seemingly weird behavior that Google completely failed to explain.</p>
<pre><code>
using Microsoft.VisualStudio.TestTools.UnitTesting;
class TestClass
{
public override bool Equals(object obj)
{
return true;
}
}
[TestMethod]
public void TestMethod1()
{
TestClass ... | [
{
"answer_id": 460377,
"author": "Jon Limjap",
"author_id": 372,
"author_profile": "https://Stackoverflow.com/users/372",
"pm_score": 3,
"selected": false,
"text": "<p>When testing for nulls, do not use <code>Assert.AreEqual</code>.</p>\n\n<p>You have to use <code>Assert.IsNull()</code> ... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460371",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39590/"
] | i recently stumbled upon a seemingly weird behavior that Google completely failed to explain.
```
using Microsoft.VisualStudio.TestTools.UnitTesting;
class TestClass
{
public override bool Equals(object obj)
{
return true;
}
}
[TestMethod]
public void TestMethod1()
{
TestClass t = new TestCl... | Your TestClass violates the contract of [`Object.Equals`](http://msdn.microsoft.com/en-us/library/bsc2ak47.aspx). `Assert.AreEqual` is relying on that contract, quite reasonably.
The docs state (in the list of requirements):
* x.Equals(a null reference (Nothing in Visual Basic)) returns false. |
460,393 | <p>I can creat a GUI in javafx and call the JMF component within JavaFx, just like this</p>
<pre><code>public class JMFComponent extends SwingComponent{
var panel: JPanel;
public var center: java.awt.Component on replace{
println("[center] set component: {center}");
panel.add(center, BorderL... | [
{
"answer_id": 504999,
"author": "Honza",
"author_id": 8621,
"author_profile": "https://Stackoverflow.com/users/8621",
"pm_score": 2,
"selected": false,
"text": "<p>Why JMF? There is neat API under <a href=\"http://java.sun.com/javafx/1/docs/api/javafx.scene.media/javafx.scene.media.Medi... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460393",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I can creat a GUI in javafx and call the JMF component within JavaFx, just like this
```
public class JMFComponent extends SwingComponent{
var panel: JPanel;
public var center: java.awt.Component on replace{
println("[center] set component: {center}");
panel.add(center, BorderLayout.CENTER);
... | Why JMF? There is neat API under [javafx.scene.media](http://java.sun.com/javafx/1/docs/api/javafx.scene.media/javafx.scene.media.Media.html) |
460,404 | <p>I had a requirement where in the text field the first character should be a alpha numeric
and then i can allow a hyphen from thereafter in JavaScript.Also hyphen should not be allowed at the end</p>
| [
{
"answer_id": 460408,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 3,
"selected": false,
"text": "<pre><code>^[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]$\n</code></pre>\n"
},
{
"answer_id": 460416,
"author": "wvan... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460404",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11114/"
] | I had a requirement where in the text field the first character should be a alpha numeric
and then i can allow a hyphen from thereafter in JavaScript.Also hyphen should not be allowed at the end | If you do not want to match mutiple dashes after eachother:
```
^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$
```
This will match: `a`, `a-a`, `aaa-a`, `aaa-a-aaa-a-aaa-a`, etc
But not: `-`, `-a`, `a-`, `a--a`, `a-a-a-`, `a-a--a`, etc. |
460,423 | <p>My application I've recently inherited is FULL of deprecation warnings about the constructor:</p>
<pre><code>Date d = new Date(int year, int month, int day)
</code></pre>
<p>Does anyone know or can point to a reason why something as simple as this was "replaced" with something like this:</p>
<pre><code>Date d = n... | [
{
"answer_id": 460428,
"author": "guerda",
"author_id": 32043,
"author_profile": "https://Stackoverflow.com/users/32043",
"pm_score": 3,
"selected": false,
"text": "<p>The answer is portability.</p>\n\n<p>The class <code>Date</code> is not very flexible. You can define dates, but not wit... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460423",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1915/"
] | My application I've recently inherited is FULL of deprecation warnings about the constructor:
```
Date d = new Date(int year, int month, int day)
```
Does anyone know or can point to a reason why something as simple as this was "replaced" with something like this:
```
Date d = null;
Calendar cal = GregorianCalendar... | Originally, `Date` was intended to contain all logic concerning dates, but the API designers eventually realized that the API they had so far was woefully inadequate and could not be cleanly extended to deal correctly with issues such as timezones, locales, different calendars, daylight savings times, etc.
So they cre... |
460,425 | <p>While trying to integrate Yahoo Media Player into my own website, I want to allow users to click on a link to add the clicked track to the playlist. YMP API has got a function for doing that (<a href="http://mediaplayer.yahoo.com/api/#method_addTracks" rel="nofollow noreferrer">http://mediaplayer.yahoo.com/api/#meth... | [
{
"answer_id": 460429,
"author": "Aron Rotteveel",
"author_id": 11568,
"author_profile": "https://Stackoverflow.com/users/11568",
"pm_score": 1,
"selected": false,
"text": "<p>You should place a reference to the DOM element you want to add, most likely by id like so:</p>\n\n<pre><code>&l... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460425",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | While trying to integrate Yahoo Media Player into my own website, I want to allow users to click on a link to add the clicked track to the playlist. YMP API has got a function for doing that (<http://mediaplayer.yahoo.com/api/#method_addTracks>). It takes a DOM element. Now how should I pass the dom element. My code lo... | As far as I understand from the API page, you should be using
```
YAHOO.MediaPlayer.addTracks(document.getElementById('track1'), null, true);
```
(the documentation says "HTML DOM element (possibly **contains** media anchor tags)") |
460,446 | <p>How do the virtual functions work in C# and Java? </p>
<p>Does it use same vtable and vpointer concept similar to C++ or is it something totally different?</p>
| [
{
"answer_id": 460464,
"author": "Miserable Variable",
"author_id": 18573,
"author_profile": "https://Stackoverflow.com/users/18573",
"pm_score": 0,
"selected": false,
"text": "<p>I am sure Java does not use vtables, since it is able to support binary compatibility. </p>\n\n<p>To Clarify... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460446",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39742/"
] | How do the virtual functions work in C# and Java?
Does it use same vtable and vpointer concept similar to C++ or is it something totally different? | How do virtual functions work in Java?
--------------------------------------
Coding interviewers love this question. Yes. Although Java does NOT have a virtual keyword, Java has virtual functions and you can write them.
In object-oriented programming, a [virtual function](http://en.wikipedia.org/wiki/Virtual_functio... |
460,454 | <p>I'm quite confused about several books in .NET that I have read. Would someone out there like to explain to me what an identifier is and how it differs from a variable? Or variables and identifiers are the same?</p>
<p>Thanks in advance.</p>
| [
{
"answer_id": 460473,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "<p>Identifiers are the syntactic means to identify variables. Variables reference memory inside your program where you can sto... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460454",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48581/"
] | I'm quite confused about several books in .NET that I have read. Would someone out there like to explain to me what an identifier is and how it differs from a variable? Or variables and identifiers are the same?
Thanks in advance. | The difference between a variable and an identifier is the same as between a person and his or her name.
A variable is not an identifier. A variable **has** an identifier. It also has a type, and (if it is initialized) a value.
For example, the instruction:
```
bool isClosed = true;
```
declares and initializes a ... |
460,474 | <p>I want to run the following code:</p>
<pre><code>ajaxUpdate(10);
</code></pre>
<p>With a delay of 1 second between each iteration. How can I do this?</p>
| [
{
"answer_id": 460481,
"author": "Greg",
"author_id": 24181,
"author_profile": "https://Stackoverflow.com/users/24181",
"pm_score": 3,
"selected": false,
"text": "<p>You can use <a href=\"https://developer.mozilla.org/en/DOM/window.setInterval\" rel=\"nofollow noreferrer\"><code>setInter... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460474",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49153/"
] | I want to run the following code:
```
ajaxUpdate(10);
```
With a delay of 1 second between each iteration. How can I do this? | You can also do it with
```
setTimeout(function() {ajaxUpdate(10)}, 1000);
``` |
460,479 | <p>Given this input: [1,2,3,4]</p>
<p>I'd like to generate the set of spanning sets:</p>
<pre><code>[1] [2] [3] [4]
[1] [2] [3,4]
[1] [2,3] [4]
[1] [3] [2,4]
[1,2] [3] [4]
[1,3] [2] [4]
[1,4] [2] [3]
[1,2] [3,4]
[1,3] [2,4]
[1,4] [2,3]
[1,2,3] [4]
[1,2,4] [3]
[1,3,4] [2]
[2,3,4] [1]
[1,2,3,4]
</code></pre>
<p>Every ... | [
{
"answer_id": 460514,
"author": "Georg Schölly",
"author_id": 24587,
"author_profile": "https://Stackoverflow.com/users/24587",
"pm_score": 3,
"selected": false,
"text": "<p>What about this? I haven't tested it yet, but I'll try it later…</p>\n\n<p>I think this technique is called Dynam... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460479",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10293/"
] | Given this input: [1,2,3,4]
I'd like to generate the set of spanning sets:
```
[1] [2] [3] [4]
[1] [2] [3,4]
[1] [2,3] [4]
[1] [3] [2,4]
[1,2] [3] [4]
[1,3] [2] [4]
[1,4] [2] [3]
[1,2] [3,4]
[1,3] [2,4]
[1,4] [2,3]
[1,2,3] [4]
[1,2,4] [3]
[1,3,4] [2]
[2,3,4] [1]
[1,2,3,4]
```
Every set has all the elements of the o... | This should work, though I haven't tested it enough.
```
def spanningsets(items):
if not items: return
if len(items) == 1:
yield [[items[-1]]]
else:
for cc in spanningsets(items[:-1]):
yield cc + [[items[-1]]]
for i in range(len(cc)):
yield cc[:i] + [... |
460,483 | <p>How can I convert markdown into html in .NET?</p>
<pre class="lang-cs prettyprint-override"><code>var markdown = "Some **bold** text";
var output = ConvertMarkdownToHtml(markdown)
// Output: <p>Some <strong>bold</strong> text</p>
</code></pre>
<p>I have Markdown text stored in a database th... | [
{
"answer_id": 460491,
"author": "Garry Shutler",
"author_id": 6369,
"author_profile": "https://Stackoverflow.com/users/6369",
"pm_score": 3,
"selected": true,
"text": "<p><a href=\"https://github.com/StackExchange/MarkdownSharp\" rel=\"nofollow noreferrer\">Markdown Sharp</a> is what th... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460483",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3713/"
] | How can I convert markdown into html in .NET?
```cs
var markdown = "Some **bold** text";
var output = ConvertMarkdownToHtml(markdown)
// Output: <p>Some <strong>bold</strong> text</p>
```
I have Markdown text stored in a database that needs to be converted to html when it is displayed.
I know about StackOverflow's ... | [Markdown Sharp](https://github.com/StackExchange/MarkdownSharp) is what the site uses and is available on [NuGet](https://www.nuget.org/packages/MarkdownSharp/). |
460,486 | <p>I have a set of libraries written in Delphi.NET (.NET 1.1) which I want to use in my Win32 (Delphi) application. For performance related issues, I've decided to follow the COM route. </p>
<p>Sometimes, after rebuilding the DLL, when I try to instantiate the objects exposed through COM, the Win32 application hangs ... | [
{
"answer_id": 460566,
"author": "mj2008",
"author_id": 5544,
"author_profile": "https://Stackoverflow.com/users/5544",
"pm_score": 0,
"selected": false,
"text": "<p>Be sure that you shut down the code in a proper manner, and do not just stop it in the debugger. I've found that killing i... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460486",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/56990/"
] | I have a set of libraries written in Delphi.NET (.NET 1.1) which I want to use in my Win32 (Delphi) application. For performance related issues, I've decided to follow the COM route.
Sometimes, after rebuilding the DLL, when I try to instantiate the objects exposed through COM, the Win32 application hangs at the `Cre... | I have mixed experiences with COM; COM can sometimes be a real pain to get stable, so if not needed, I often take anoter route.
In this case, you could try to go around COM by using inverse P/Invoke.
Here are a few articles that can help you on this:
<http://blogs.codegear.com/timjarvis/2006/11/10/29270>
<http://www... |
460,508 | <p>Here is my sample data:</p>
<pre><code>1;a;b;c;; 2;d;e;f;; 3;g;h;i;;
4;j;k;l;; 5;m;n;o;;
6;p;q;r;;
</code></pre>
<p>Here is my sample format file (BCP 9):</p>
<pre><code>9.0
7
1 SQLCHAR 0 0 "" 0 x Latin1_General_CI_AS
2 SQLCHAR 0 0 ";" 2 i Latin1_General_CI_AS
3 SQLCHAR 0 0 ";" 3 s Latin1_General_CI_AS
4 SQLCH... | [
{
"answer_id": 460722,
"author": "Rich Andrews",
"author_id": 37381,
"author_profile": "https://Stackoverflow.com/users/37381",
"pm_score": 0,
"selected": false,
"text": "<p>OK, I got this to work for me. I used the following...</p>\n\n<p>Data file (based on your example)...</p>\n\n<pre>... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460508",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/55700/"
] | Here is my sample data:
```
1;a;b;c;; 2;d;e;f;; 3;g;h;i;;
4;j;k;l;; 5;m;n;o;;
6;p;q;r;;
```
Here is my sample format file (BCP 9):
```
9.0
7
1 SQLCHAR 0 0 "" 0 x Latin1_General_CI_AS
2 SQLCHAR 0 0 ";" 2 i Latin1_General_CI_AS
3 SQLCHAR 0 0 ";" 3 s Latin1_General_CI_AS
4 SQLCHAR 0 0 ";" 4 t Latin1_General_CI_AS
5... | asiaenforcer, my apologies for being off line for week!
Using your data above I think I've got it...
Firstly I had a problem with your destination table - the statement "CREATE TABLE [dbo].SansayRawInfo NOT NULL," is not the correct syntax so from looking at your previous format file I believe you missed out a column... |
460,510 | <p>I have a slapd LDAP server which is critical to my application. I want to monitor it in order to detect when it has become over-loaded or if it fails.</p>
<p>Unfortunately we are stuck with a very old edition of slapd which has a known bug: It cannot cope with more than 64 concurrent connections. If a client attemp... | [
{
"answer_id": 460592,
"author": "Siegfried Puchbauer",
"author_id": 46301,
"author_profile": "https://Stackoverflow.com/users/46301",
"pm_score": 2,
"selected": false,
"text": "<p>Not directly slapd related but have you thought of using <strong>netstat</strong> to fetch the number of es... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460510",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46411/"
] | I have a slapd LDAP server which is critical to my application. I want to monitor it in order to detect when it has become over-loaded or if it fails.
Unfortunately we are stuck with a very old edition of slapd which has a known bug: It cannot cope with more than 64 concurrent connections. If a client attempts to open... | The best tool for that is [lsof](http://people.freebsd.org/~abe/).
```
lsof -i tcp:389
```
will show you all TCP connections to your LDAP server. |
460,528 | <p>I am working with another coder on a website that is accessing SQL Server (2008 Express) through some web services he created (involving mostly LINQ to SQL), and the UI is in Silverlight. I've been working on another part of the system, but just got his latest code, and am trying to run it on my machine, but am get... | [
{
"answer_id": 467246,
"author": "Noah",
"author_id": 47496,
"author_profile": "https://Stackoverflow.com/users/47496",
"pm_score": 0,
"selected": false,
"text": "<p>The problem may be with the way that LINQ serializes the query results. If it detects relationships between tables then it... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460528",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/57001/"
] | I am working with another coder on a website that is accessing SQL Server (2008 Express) through some web services he created (involving mostly LINQ to SQL), and the UI is in Silverlight. I've been working on another part of the system, but just got his latest code, and am trying to run it on my machine, but am getting... | Ok, so I feel a bit silly.
After beating my head against this thing off and on for several days, I discovered that I had the Silverlight project set as the startup project. I needed it to be the web project that actually had the proper authentication settings for connecting to the database-- not to mention the actual... |
460,542 | <p>Can anyone explain the use of ^ operator in java with some examples?</p>
| [
{
"answer_id": 460546,
"author": "Serafina Brocious",
"author_id": 4977,
"author_profile": "https://Stackoverflow.com/users/4977",
"pm_score": 8,
"selected": true,
"text": "<p>This is the same as ^ in most languages, just an XOR.</p>\n\n<pre><code>false ^ false == false\ntrue ^ false == ... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460542",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40933/"
] | Can anyone explain the use of ^ operator in java with some examples? | This is the same as ^ in most languages, just an XOR.
```
false ^ false == false
true ^ false == true
false ^ true == true
true ^ true == false
``` |
460,562 | <p>I can not understand this shift operator (c# reference):</p>
<pre><code>class MainClass1
{
static void Main()
{
int i = 1;
long lg = 1;
Console.WriteLine("0x{0:x}", i << 1);
Console.WriteLine("0x{0:x}", i << 33);
Console.WriteLine("0x{0:x}", lg << 33);
... | [
{
"answer_id": 460568,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 6,
"selected": false,
"text": "<p><code><<</code> is the left-shift operator; this takes the binary representation of a value, and moves all t... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460562",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/57006/"
] | I can not understand this shift operator (c# reference):
```
class MainClass1
{
static void Main()
{
int i = 1;
long lg = 1;
Console.WriteLine("0x{0:x}", i << 1);
Console.WriteLine("0x{0:x}", i << 33);
Console.WriteLine("0x{0:x}", lg << 33);
}
}
/*
Output:
0x2
0x2
0x20... | `<<` is the left-shift operator; this takes the binary representation of a value, and moves all the bits "n" places to the left (except for "mod", see "1"), back-filling with zeros.
`>>` is the right-shift operator; this does nearly the opposite (moving to the right), except for signed values (i.e. those that can be n... |
460,567 | <p>I want to distribute a webstart application which uses RMI.</p>
<p>I want to avoid to ask the user the address of the RMI server, because the website that distributes the application is also the RMI server.</p>
<p>Furthermore, I don't know the address of the server at build time, therefore the address must be adde... | [
{
"answer_id": 460590,
"author": "Jonik",
"author_id": 56285,
"author_profile": "https://Stackoverflow.com/users/56285",
"pm_score": 3,
"selected": true,
"text": "<p>I haven't used Java RMI exactly (I've only used Java Web Start with <a href=\"http://hessian.caucho.com/\" rel=\"nofollow ... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460567",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15173/"
] | I want to distribute a webstart application which uses RMI.
I want to avoid to ask the user the address of the RMI server, because the website that distributes the application is also the RMI server.
Furthermore, I don't know the address of the server at build time, therefore the address must be added with ad hoc con... | I haven't used Java RMI exactly (I've only used Java Web Start with [Hessian](http://hessian.caucho.com/) binary protocol for doing something like RMI), but at least the part of passing the server address to the Web Start client app should be easy. When you generate the JNLP file in your application, add the address as... |
460,583 | <p>I want to shift elements inside container on any positions to the left or right. The shifting elements are not contiguous.</p>
<p>e.g I have a vector {1,2,3,4,5,6,7,8} and I want to shift {4,5,7} to the left on 2 positions, the expected result will be {1,4,5,2,7,3,6,8}</p>
<p>Is there an elegant way to solve it ?<... | [
{
"answer_id": 460608,
"author": "Rob Wells",
"author_id": 2974,
"author_profile": "https://Stackoverflow.com/users/2974",
"pm_score": 0,
"selected": false,
"text": "<p>Can't you do a simple insert and then erase?</p>\n\n<p>Don't forget that you'll invalidate any iterators that refer to ... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460583",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/52862/"
] | I want to shift elements inside container on any positions to the left or right. The shifting elements are not contiguous.
e.g I have a vector {1,2,3,4,5,6,7,8} and I want to shift {4,5,7} to the left on 2 positions, the expected result will be {1,4,5,2,7,3,6,8}
Is there an elegant way to solve it ? | You can write your own shifting function. Here's a simple one:
```
#include <iterator>
#include <algorithm>
template <typename Container, typename ValueType, typename Distance>
void shift(Container &c, const ValueType &value, Distance shifting)
{
typedef typename Container::iterator Iter;
// Here I assumed t... |
460,586 | <p>Consider the following code: </p>
<pre><code>def CalcSomething(a):
if CalcSomething._cache.has_key(a):
return CalcSomething._cache[a]
CalcSomething._cache[a] = ReallyCalc(a)
return CalcSomething._cache[a]
CalcSomething._cache = { }
</code></pre>
<p>This is the easiest way I can think of for si... | [
{
"answer_id": 460601,
"author": "Torsten Marek",
"author_id": 9567,
"author_profile": "https://Stackoverflow.com/users/9567",
"pm_score": 4,
"selected": false,
"text": "<p>Turn it into a decorator.</p>\n\n<pre><code>def static_var(var_name, initial_value):\n def _set_var(obj):\n ... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460586",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38193/"
] | Consider the following code:
```
def CalcSomething(a):
if CalcSomething._cache.has_key(a):
return CalcSomething._cache[a]
CalcSomething._cache[a] = ReallyCalc(a)
return CalcSomething._cache[a]
CalcSomething._cache = { }
```
This is the easiest way I can think of for simulating a 'local static' v... | Turn it into a callable object (since that's what it really is.)
```
class CalcSomething(object):
def __init__(self):
self._cache = {}
def __call__(self, a):
if a not in self._cache:
self._cache[a] = self.reallyCalc(a)
return self._cache[a]
def reallyCalc(self, a):
... |
460,589 | <p>I've installed XAMPP Apache server and put my website into htdocs. I've started Apache server. On my website I've got files with extension PHP and with extension PHP5.The difference is that when I type in into browser localhost/file.php - I see a parsed website.</p>
<p>But when I type localhost/file.php5 (i have th... | [
{
"answer_id": 486729,
"author": "Cody Caughlan",
"author_id": 25398,
"author_profile": "https://Stackoverflow.com/users/25398",
"pm_score": -1,
"selected": false,
"text": "<p>Adding:</p>\n\n<pre><code>AddType application/x-httpd-php .php .php5\n</code></pre>\n\n<p>worked for me under OS... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460589",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38940/"
] | I've installed XAMPP Apache server and put my website into htdocs. I've started Apache server. On my website I've got files with extension PHP and with extension PHP5.The difference is that when I type in into browser localhost/file.php - I see a parsed website.
But when I type localhost/file.php5 (i have this file on... | XAMPP passes by default files with the following extensions to PHP: .php **.php5** .php4 .php3 .phtml .phpt (this was tested with XAMPP Lite 1.6.8).
My suggestion would be to remove the "AddType text/html .php5" line from the XAMPP configuration. Alternatively, use a clean install of XAMPP and look at the differences ... |
460,591 | <p>I have a .NET Webservice which hosts a Method called AddMyObject.</p>
<pre><code>[WebMethod]
public void AddMyObject(MyObject[] objects){...}
</code></pre>
<p>Where MyObject is declared as</p>
<pre><code>public class MyObject
{
public string Pro1{get;set;}
public string Pro2{get;set;}
}
</code></pre>
<p>... | [
{
"answer_id": 460617,
"author": "krosenvold",
"author_id": 23691,
"author_profile": "https://Stackoverflow.com/users/23691",
"pm_score": 0,
"selected": false,
"text": "<p>Yes, in general it will fail. Not neccessarily on a .NET client (it's fairly lenient) but other clients will fail.<... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460591",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17558/"
] | I have a .NET Webservice which hosts a Method called AddMyObject.
```
[WebMethod]
public void AddMyObject(MyObject[] objects){...}
```
Where MyObject is declared as
```
public class MyObject
{
public string Pro1{get;set;}
public string Pro2{get;set;}
}
```
If I now add a Property to MyObject, the Client c... | Fortunately I just found the time to write a little test service for this issue.
What actually happens is, that if a property is added on client side, it's ignored on the old service.
Even when a Property is deleted on the client side, there is no Exception on the server: the Property is just `null`. |
460,596 | <p>If I have an exception in my business layer (e.g. a SQL exception in my JDBC connection bean), how can I propagate it with a custom message to a global <code>error.jsp</code> page?</p>
| [
{
"answer_id": 460615,
"author": "Romain Linsolas",
"author_id": 26457,
"author_profile": "https://Stackoverflow.com/users/26457",
"pm_score": 2,
"selected": false,
"text": "<p>The general way to display error message to the user in JSF is to use FacesMessage:</p>\n\n<p>On Java side:</p>... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460596",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | If I have an exception in my business layer (e.g. a SQL exception in my JDBC connection bean), how can I propagate it with a custom message to a global `error.jsp` page? | JSF 1.x doesn't provide any implicit error handling of this type, though you can redirect to an error page using navigation rules (assuming a form post)...
```
<navigation-case>
<description>
Handle a generic error outcome that might be returned
by any application Action.
</description>
<display-name>Generic Error Out... |
460,613 | <p>I have some code that looks like this:</p>
<pre><code>someFunc(value)
{
switch(value){
case 1:
case 2:
case 3:
#ifdef SOMEMACRO
case 4:
case 5:
#endif
return TRUE;
}
return FALSE;
}
</code></pre>
<p>SOMEMACRO is defined, and let's say the value is 4.. Why... | [
{
"answer_id": 460626,
"author": "GvS",
"author_id": 11492,
"author_profile": "https://Stackoverflow.com/users/11492",
"pm_score": 1,
"selected": false,
"text": "<p>Are you sure your module is compiled after you have defined SOMEMACRO?</p>\n"
},
{
"answer_id": 460629,
"author... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460613",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29482/"
] | I have some code that looks like this:
```
someFunc(value)
{
switch(value){
case 1:
case 2:
case 3:
#ifdef SOMEMACRO
case 4:
case 5:
#endif
return TRUE;
}
return FALSE;
}
```
SOMEMACRO is defined, and let's say the value is 4.. Why does case 4 and 5 get ski... | "switch" Isn't Broken
to, more or less, quote [The Pragmatic Programmer](https://rads.stackoverflow.com/amzn/click/com/020161622X).
Go ahead and look somewhere else for the error. To convince yourself add `value = 4` and `#define SOMEMACRO` right there in someFunc.
Make a clean build to make sure every dependancy is... |
460,634 | <p>I'm using jQuery UI Sortables to sort items between lists and drag / drop items from one list to the other. </p>
<p>The lists are collapsible with header DIVs that control the expand / collapse operations. I would like to have the lists expand automatically when hovering over their title DIVs with the mouse, but on... | [
{
"answer_id": 468230,
"author": "Soviut",
"author_id": 46914,
"author_profile": "https://Stackoverflow.com/users/46914",
"pm_score": 1,
"selected": false,
"text": "<p>This is because there is a bug in the latest official JQuery 1.3 release. Get the <a href=\"http://dev.jquery.com/brows... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460634",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51967/"
] | I'm using jQuery UI Sortables to sort items between lists and drag / drop items from one list to the other.
The lists are collapsible with header DIVs that control the expand / collapse operations. I would like to have the lists expand automatically when hovering over their title DIVs with the mouse, but only when I'... | <http://api.jqueryui.com/droppable/#event-over>
```
$( ".title" ).droppable({
over: function( event, ui ) {
$(this).next().show(); # show ul.sortable
}
})
```
need jquery-ui droppable, of course |
460,644 | <p>Does anybody know of a method to trigger an event in Prototype, as you can with jQuery's trigger function?</p>
<p>I have bound an event listener using the observe method, but I would also like to be able to fire the event programatically.</p>
<p>Thanks in advance</p>
| [
{
"answer_id": 460695,
"author": "Aron Rotteveel",
"author_id": 11568,
"author_profile": "https://Stackoverflow.com/users/11568",
"pm_score": 7,
"selected": true,
"text": "<p><a href=\"http://github.com/kangax/protolicious/blob/5b56fdafcd7d7662c9d648534225039b2e78e371/event.simulate.js\"... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460644",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13803/"
] | Does anybody know of a method to trigger an event in Prototype, as you can with jQuery's trigger function?
I have bound an event listener using the observe method, but I would also like to be able to fire the event programatically.
Thanks in advance | [`event.simulate.js`](http://github.com/kangax/protolicious/blob/5b56fdafcd7d7662c9d648534225039b2e78e371/event.simulate.js) fits your needs.
I've used this several times and it works like a charm. It allows you to **manually trigger native events**, such as click or hover like so:
```
$('foo').simulate('click');
``... |
460,652 | <p>So far I have a UITableView, it works properly and all.</p>
<p>My problem is when going into "editing" mode, apparently the cells are not changing at all, and the red sign (delete control) only shows up when I drag the cell out of the tableview (meaning the iphone reloads the cell again, and it is here when it dete... | [
{
"answer_id": 580189,
"author": "Steve Gibson",
"author_id": 65314,
"author_profile": "https://Stackoverflow.com/users/65314",
"pm_score": 0,
"selected": false,
"text": "<p>Your Controller is probably a subclass of UIViewController not UITableViewController. As far as I have found thus... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460652",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | So far I have a UITableView, it works properly and all.
My problem is when going into "editing" mode, apparently the cells are not changing at all, and the red sign (delete control) only shows up when I drag the cell out of the tableview (meaning the iphone reloads the cell again, and it is here when it detects that t... | Of course you can use a UIViewController.
in the `setEditing:animate` Method, simply call
```
[super setEditing:editing animated:animate];
[self.myTableView setEditing:editing animated:animate];
```
and you will get those nice little icons ;) |
460,653 | <p>I have an updatepanel which doesn't work. My whole code:</p>
<pre><code><%@ Page Language="C#" MasterPageFile="~/Master.Master" AutoEventWireup="true" CodeBehind="AlgemeenDocument.aspx.cs" Inherits="PCK_Web_new.WebForm7" Title="Untitled Page" %>
</code></pre>
<p></p>
<pre><code><asp:ScriptManager ID="Scr... | [
{
"answer_id": 460694,
"author": "Lonzo",
"author_id": 47342,
"author_profile": "https://Stackoverflow.com/users/47342",
"pm_score": 0,
"selected": false,
"text": "<p>The label you want its text to be set and the btnSave button elements should both be inside the Update Panel element.</p>... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460653",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40676/"
] | I have an updatepanel which doesn't work. My whole code:
```
<%@ Page Language="C#" MasterPageFile="~/Master.Master" AutoEventWireup="true" CodeBehind="AlgemeenDocument.aspx.cs" Inherits="PCK_Web_new.WebForm7" Title="Untitled Page" %>
```
```
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<script language... | I think the best tutor on the web is Joe Stagner. His material for .NET is awesome.
Here is a [link](http://www.asp.net/LEARN/ajax-videos/video-159.aspx) where he shows you exactly, step-by-step how to do what you are trying.
Addendum:
If I were you I'd create a clean page from the sample code Joe has provided. Go ... |
460,660 | <p>i'm interested if it is possible to make an application like an Address Book (Windows: Start->All Programs->Accessories->Address Book) in Delphi Personal Edition or in Turbo Delphi.</p>
<p>If yes, how to make it? Which components to use?</p>
<p>How to make an application to be used on some other computer, and that... | [
{
"answer_id": 460823,
"author": "Toon Krijthe",
"author_id": 18061,
"author_profile": "https://Stackoverflow.com/users/18061",
"pm_score": 2,
"selected": false,
"text": "<p>To start with the first question, you can write (almost) any application in Delphi. Other version often implies a ... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460660",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | i'm interested if it is possible to make an application like an Address Book (Windows: Start->All Programs->Accessories->Address Book) in Delphi Personal Edition or in Turbo Delphi.
If yes, how to make it? Which components to use?
How to make an application to be used on some other computer, and that no files would b... | To start with the first question, you can write (almost) any application in Delphi. Other version often implies a smaller library and possible limited use (as far as I know you can't sell comercial applications build with the free version, but maybe codegear changed this)
An addressbook is a nice and simple (database)... |
460,663 | <p>In PHP, you can make two variables point to the same data. </p>
<pre><code>$a = 'foo';
$b = 'bar';
$a =& $b;
echo $a // Outputs: bar
echo $b // Outputs: bar
</code></pre>
<p>What we are trying to do in Ruby is set <code>@app_session</code> to be equal to <code>session[@current_app[:uid]]</code>. So we only hav... | [
{
"answer_id": 460672,
"author": "Georg Schölly",
"author_id": 24587,
"author_profile": "https://Stackoverflow.com/users/24587",
"pm_score": 1,
"selected": false,
"text": "<p>Isn't this the default for all ruby objects? It wouldn't make sense to copy an object every time.</p>\n"
},
... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460663",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42146/"
] | In PHP, you can make two variables point to the same data.
```
$a = 'foo';
$b = 'bar';
$a =& $b;
echo $a // Outputs: bar
echo $b // Outputs: bar
```
What we are trying to do in Ruby is set `@app_session` to be equal to `session[@current_app[:uid]]`. So we only have to deal with `@app_session` in our app, and everyt... | All variables in Ruby are references to an object.
```
a = b
```
means that a and b point to the same object. That's why when you want to copy a given object, you need to write
```
a = b.dup
```
Writing
```
@app_session = session[@current_app[:uid]]
```
points to the same object so you should be fine.
EDIT: y... |
460,669 | <p>I'd like to script printing of a series of photographs, but to exact dimensions. (e.g. all jpegs in dir /tmp/printing, at 1.5" x 1.0", 6 to a page)</p>
<p>I happen to have my hands on a Ubuntu Linux box and a deskjet printer (hp5150) but could probably use Windows or possibly get another printer if absolutely requi... | [
{
"answer_id": 460759,
"author": "PEZ",
"author_id": 44639,
"author_profile": "https://Stackoverflow.com/users/44639",
"pm_score": 2,
"selected": true,
"text": "<p>I don't have my hands on a Linux box right now, but I think it should work to use something like ImageMagick (the \"convert\... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460669",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12744/"
] | I'd like to script printing of a series of photographs, but to exact dimensions. (e.g. all jpegs in dir /tmp/printing, at 1.5" x 1.0", 6 to a page)
I happen to have my hands on a Ubuntu Linux box and a deskjet printer (hp5150) but could probably use Windows or possibly get another printer if absolutely required.
I'm ... | I don't have my hands on a Linux box right now, but I think it should work to use something like ImageMagick (the "convert" command) to scale to images and then use the n-up printing of CUPS to print the images. The print command would look something like so:
```
lp -o number-up=6 my_scaled_image_*.jpg
``` |
460,677 | <p>I have a case where I need to serve "raw" swf files to the browser. That is, without embedding. We have had some problems making this work in IE now and then but managed to work around it. Until now. We're fixing some other issues with serving documents and as a side effect the flash files stop working in IE. Flash ... | [
{
"answer_id": 460759,
"author": "PEZ",
"author_id": 44639,
"author_profile": "https://Stackoverflow.com/users/44639",
"pm_score": 2,
"selected": true,
"text": "<p>I don't have my hands on a Linux box right now, but I think it should work to use something like ImageMagick (the \"convert\... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460677",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44639/"
] | I have a case where I need to serve "raw" swf files to the browser. That is, without embedding. We have had some problems making this work in IE now and then but managed to work around it. Until now. We're fixing some other issues with serving documents and as a side effect the flash files stop working in IE. Flash con... | I don't have my hands on a Linux box right now, but I think it should work to use something like ImageMagick (the "convert" command) to scale to images and then use the n-up printing of CUPS to print the images. The print command would look something like so:
```
lp -o number-up=6 my_scaled_image_*.jpg
``` |
460,733 | <p>I would like to know how Can I paas Page as Ref Parameter to a function</p>
<p>This is what I want to do</p>
<pre>
<code>
public partial class HomePage : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if(!SetupUserPermission.isSessionExpired())
{
... | [
{
"answer_id": 460741,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 2,
"selected": false,
"text": "<p>Why do you want to pass it <code>ref</code>? It seems to me that a regular pass should do; this passes the <strong... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460733",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I would like to know how Can I paas Page as Ref Parameter to a function
This is what I want to do
```
public partial class HomePage : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if(!SetupUserPermission.isSessionExpired())
{
string UserId = Session... | You can't pass a property by reference in C#. Why do you want to pass Page by reference in this case?
In VB you *can* pass a property by reference, and the equivalent in this case would be:
```
Page tmp = Page;
SetupUserPermission.SetupUserRights(ref tmp, Convert.ToInt32(UserId));
Page = tmp;
```
Are you really sur... |
460,755 | <p>How is it that Java's <code>BigDecimal</code> can be this painful?</p>
<pre><code>Double d = 13.3D;
BigDecimal bd1 = new BigDecimal(d);
BigDecimal bd2 = new BigDecimal(String.valueOf(d));
System.out.println("RESULT 1: "+bd1.toString());
System.out.println("RESULT 2: "+bd2.toString());
RESULT 1: 13.3000000000000... | [
{
"answer_id": 460763,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 3,
"selected": false,
"text": "<p>This isn't the fault of <code>BigDecimal</code> - it's the fault of <code>double</code>. <code>BigDecimal</code> is a... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460755",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2955/"
] | How is it that Java's `BigDecimal` can be this painful?
```
Double d = 13.3D;
BigDecimal bd1 = new BigDecimal(d);
BigDecimal bd2 = new BigDecimal(String.valueOf(d));
System.out.println("RESULT 1: "+bd1.toString());
System.out.println("RESULT 2: "+bd2.toString());
RESULT 1: 13.300000000000000710542735760100185871124... | Well, the [API](http://java.sun.com/javase/6/docs/api/java/math/BigDecimal.html#BigDecimal(double)) does address this apparent inconsistency in the constructor `BigDecimal(double val)`:
>
> 1. The results of this constructor can be somewhat unpredictable. One might
> assume that writing new
> BigDecimal(0.1) in Jav... |
460,766 | <p>(<em>I'm <a href="https://stackoverflow.com/questions/412459/how-to-generically-remove-f-units-of-measure">still</a> <a href="https://stackoverflow.com/questions/419521/f-units-of-measure-lifting-values-to-floatsomething">banging</a> on with units of measure in F#)</em></p>
<p>I'm having a problem making 'generic' ... | [
{
"answer_id": 460919,
"author": "Robert",
"author_id": 17864,
"author_profile": "https://Stackoverflow.com/users/17864",
"pm_score": 0,
"selected": false,
"text": "<p>Units of measure cannot be used as type parameters. This is because the are erased by the compiler during compilation. T... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460766",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11410/"
] | (*I'm [still](https://stackoverflow.com/questions/412459/how-to-generically-remove-f-units-of-measure) [banging](https://stackoverflow.com/questions/419521/f-units-of-measure-lifting-values-to-floatsomething) on with units of measure in F#)*
I'm having a problem making 'generic' functions which take 'typed' floats.
T... | You can change the first 'compiler no like' to
```
let mutable error_s : float<'a> = 0.0<_>
```
and the compiler seems to like that.
As for the second question, I am not seeing the same error as you, and this
```
[<Measure>] type km
//define a unit of measure
let someFloatFn x = x + 1.2 //this is a function which... |
460,775 | <p>I've got an issue that was wondering if could be solved in a particular way.</p>
<p>I would like to be able to pass a parameter or set some kind of variable in an MSBuild script that will be run on a TeamBuild server.</p>
<p>This parameter would be used as a condition in the setup of a TestFixture in MSTest to dec... | [
{
"answer_id": 460789,
"author": "Gishu",
"author_id": 1695,
"author_profile": "https://Stackoverflow.com/users/1695",
"pm_score": 1,
"selected": true,
"text": "<p>As a xUnit guideline, tests should <strong>not</strong> take in parameters. They should just run without someone having to c... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460775",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/942/"
] | I've got an issue that was wondering if could be solved in a particular way.
I would like to be able to pass a parameter or set some kind of variable in an MSBuild script that will be run on a TeamBuild server.
This parameter would be used as a condition in the setup of a TestFixture in MSTest to decided which concre... | As a xUnit guideline, tests should **not** take in parameters. They should just run without someone having to configure them.
```
public void TestMethodName()
```
Your need seems to be more towards [dependency injection](http://martinfowler.com/articles/injection.html). For which frameworks like [Spring.Net](http:/... |
460,788 | <p>In VB.Net is there any difference between the following three ways of initialising object variables</p>
<p>Method 1</p>
<pre><code>Dim commandObject As SqlCommand
commandObject = New SqlCommand("MadeUpCommand")
</code></pre>
<p>Method 2</p>
<pre><code>Dim commandObject As SqlCommand = New SqlCommand("MadeUpComm... | [
{
"answer_id": 460802,
"author": "Darin Dimitrov",
"author_id": 29407,
"author_profile": "https://Stackoverflow.com/users/29407",
"pm_score": 4,
"selected": true,
"text": "<p>There is no difference in the generated IL between the 3 methods.</p>\n"
},
{
"answer_id": 460822,
"a... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460788",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7585/"
] | In VB.Net is there any difference between the following three ways of initialising object variables
Method 1
```
Dim commandObject As SqlCommand
commandObject = New SqlCommand("MadeUpCommand")
```
Method 2
```
Dim commandObject As SqlCommand = New SqlCommand("MadeUpCommand")
```
Method 3
```
Dim commandObject ... | There is no difference in the generated IL between the 3 methods. |
460,796 | <p>I am trying to create a combobox style widget (jquery-ui compatible) andcurrently I am trying to get the static layout of the box sorted. The problem is when I have long text in the value area of the select it doesn't clip in Firefox (it actually wraps). I don't want this and tried various combinations overflow:hid... | [
{
"answer_id": 460803,
"author": "Kent Fredric",
"author_id": 15614,
"author_profile": "https://Stackoverflow.com/users/15614",
"pm_score": 4,
"selected": false,
"text": "<p>The problem is spans are inline elements, and you can't set width or height on inline elements. </p>\n\n<p>And as ... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460796",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34671/"
] | I am trying to create a combobox style widget (jquery-ui compatible) andcurrently I am trying to get the static layout of the box sorted. The problem is when I have long text in the value area of the select it doesn't clip in Firefox (it actually wraps). I don't want this and tried various combinations overflow:hidden ... | Try giving the element a `display:block`, or change the `SPAN` to a block-level element like `DIV`. |
460,799 | <p>now i learn cURL , i face one difficult that is to login into a page by username and password directly</p>
| [
{
"answer_id": 460807,
"author": "MatthieuP",
"author_id": 41469,
"author_profile": "https://Stackoverflow.com/users/41469",
"pm_score": 1,
"selected": false,
"text": "<p>For standard HTTP authentication, you could try: </p>\n\n<pre><code>curl http://username:password@url \n</code></pre... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460799",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | now i learn cURL , i face one difficult that is to login into a page by username and password directly | For standard HTTP authentication, you could try:
```
curl http://username:password@url
```
It should work! |
460,809 | <p>How can I ensure a dll is not unloaded while any objects in it exist?</p>
<p>The problem is, when I was using explict memory management I could delete the dll objects before freeing the dll, however with smart pointers I have no controll over the order there destroyed, meaning the dll may be freed first causeing a ... | [
{
"answer_id": 460975,
"author": "MSalters",
"author_id": 15416,
"author_profile": "https://Stackoverflow.com/users/15416",
"pm_score": 0,
"selected": false,
"text": "<p>MSDN is explicit on this topic: \"A thread that must unload the DLL in which it is executing and then terminate itself... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460809",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6266/"
] | How can I ensure a dll is not unloaded while any objects in it exist?
The problem is, when I was using explict memory management I could delete the dll objects before freeing the dll, however with smart pointers I have no controll over the order there destroyed, meaning the dll may be freed first causeing a crash when... | Assuming you do not want to terminate the thread when unloading the library (otherwise, see MSalters), you need to free the library from the caller that loaded it.
COM solves that by an in-DLL instance counter (much like yours, if I understand you correctly), and regulary checking it by calling a global exported `CanU... |
460,812 | <p>Im trying to define a dataTemplate for a business object in my wpf application a collection of which is being bound to a ListBox.</p>
<pre><code><UserControl.Resources>
<DataTemplate x:Key="ResizedItemsDataTemplate" DataType="{x:Type resizer:ResizeMonitorItem}">
<Border x:Name="bdr"... | [
{
"answer_id": 460864,
"author": "Matt Hamilton",
"author_id": 615,
"author_profile": "https://Stackoverflow.com/users/615",
"pm_score": 7,
"selected": true,
"text": "<p>This is probably more to do with the ListBoxItems themselves not taking up the full width of the ListBox. Add the <cod... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460812",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47835/"
] | Im trying to define a dataTemplate for a business object in my wpf application a collection of which is being bound to a ListBox.
```
<UserControl.Resources>
<DataTemplate x:Key="ResizedItemsDataTemplate" DataType="{x:Type resizer:ResizeMonitorItem}">
<Border x:Name="bdr" BorderBrush="Blue"
... | This is probably more to do with the ListBoxItems themselves not taking up the full width of the ListBox. Add the `HorizontalContentAlignment="Stretch"` attribute to your `ListBox` and see if it stretches the individual items to fill the width. |
460,815 | <p>I know this is a vague question, especially since I am not providing any code, but I am developing a .Net 2.0 application, and we have a WebRequest which posts data to an internally built API.</p>
<p>The strange thing happens on our 3rd (and always the 3rd) subsequent request which fails at the GetRequestStream() m... | [
{
"answer_id": 460824,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 5,
"selected": true,
"text": "<p>This usually happens if you're not disposing the WebResponse. There's a limit applied to the number of connections fro... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460815",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11194/"
] | I know this is a vague question, especially since I am not providing any code, but I am developing a .Net 2.0 application, and we have a WebRequest which posts data to an internally built API.
The strange thing happens on our 3rd (and always the 3rd) subsequent request which fails at the GetRequestStream() method of t... | This usually happens if you're not disposing the WebResponse. There's a limit applied to the number of connections from a client to the same machine, and by default it's two. The connections can be reused (or closed) if you close the WebResponse. The using statement is your friend here:
```
WebRequest request = [...];... |
460,816 | <p>Not only easy ones like .com or .net, but also, .co.uk, .fr, .gov.rw ... ? </p>
<p>Should I really make a huge mapping "tld to relevant whois server", or is there an easier way ?</p>
| [
{
"answer_id": 460827,
"author": "DanSingerman",
"author_id": 43965,
"author_profile": "https://Stackoverflow.com/users/43965",
"pm_score": 2,
"selected": false,
"text": "<p><a href=\"http://whois.net/\" rel=\"nofollow noreferrer\">http://whois.net/</a> any good?</p>\n"
},
{
"ans... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460816",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39263/"
] | Not only easy ones like .com or .net, but also, .co.uk, .fr, .gov.rw ... ?
Should I really make a huge mapping "tld to relevant whois server", or is there an easier way ? | <http://php.net/manual/en/function.checkdnsrr.php>
```
if (checkdnsrr('test.nl', 'A')) // or use ANY or for other see above link
{
echo 'Domain exists';
}
else
{
echo 'Domain does not exist';
}
``` |
460,831 | <p>Ok, I have managed to get the following working</p>
<pre><code>public IQueryable getTicketInformation(int ticketID)
{
var ticketDetails = from tickets in _context.tickets
join file in _context.file_objects on tickets.ticket_id equals file.source_id
where tickets.ticket_id == ticketID
sel... | [
{
"answer_id": 460837,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 4,
"selected": false,
"text": "<p>You mean:</p>\n\n<pre><code>select new MyObject { TicketId = tickets.ticket_id,\n Title = tickets.title, ...};... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460831",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Ok, I have managed to get the following working
```
public IQueryable getTicketInformation(int ticketID)
{
var ticketDetails = from tickets in _context.tickets
join file in _context.file_objects on tickets.ticket_id equals file.source_id
where tickets.ticket_id == ticketID
select new { tick... | You mean:
```
select new MyObject { TicketId = tickets.ticket_id,
Title = tickets.title, ...};
```
(note I tweaked the names slightly to be more C#-idiomatic)
This is an "object initializer" that creates a new `MyObject` (per record) and assigns the properties from the source data. What you had was an "anonymo... |
460,835 | <p>I'm using ant to build my project, and use the 'svnversion' executable to insert a version id into my sources for easy tracking of versions.</p>
<p>Running this ant file from the command line works, I've set my $PATH in .profile to include the path to svnversion and it works fine.</p>
<p>Now I try and run this sam... | [
{
"answer_id": 460862,
"author": "Egil",
"author_id": 44606,
"author_profile": "https://Stackoverflow.com/users/44606",
"pm_score": 2,
"selected": false,
"text": "<p>A quick search at developer.apple.com turned up <a href=\"http://developer.apple.com/qa/qa2001/qa1067.html\" rel=\"nofollo... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460835",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31884/"
] | I'm using ant to build my project, and use the 'svnversion' executable to insert a version id into my sources for easy tracking of versions.
Running this ant file from the command line works, I've set my $PATH in .profile to include the path to svnversion and it works fine.
Now I try and run this same ant file from i... | Correct -- it's in the plist file
```
~/.MacOSX/environment.plist
```
This file actually contains key-value pairs for any environment variables you want to set, for the whole login session. Unlike .profile/.cshrc etc, it's available to GUI programs. Unfortunately, you can't access other environment variables (e.g.,... |
460,857 | <p>I was browsing the Delphi 2009 language guide. And found something strange. In the list of directives (not compiler directives) I found <strong>pointermath</strong>. </p>
<pre><code>RAD-Studio
Reference
Delphi Reference
Delphi Language Guide
Fundamental Syntactic Elements
Fundamental S... | [
{
"answer_id": 460992,
"author": "Steve",
"author_id": 22712,
"author_profile": "https://Stackoverflow.com/users/22712",
"pm_score": 0,
"selected": false,
"text": "<p>I think what it means is it allows you to do C like pointer maths. Up to Delphi 2009, you could only do limited pointer m... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460857",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18061/"
] | I was browsing the Delphi 2009 language guide. And found something strange. In the list of directives (not compiler directives) I found **pointermath**.
```
RAD-Studio
Reference
Delphi Reference
Delphi Language Guide
Fundamental Syntactic Elements
Fundamental Syntactic Elements
... | Unless [Barry Kelly](https://stackoverflow.com/users/3712/barry-kelly) proves us wrong (he is the authority on that), I would vote for a documentation bug: it was meant for the '**compiler** directives' chapter. |
460,873 | <p>I need to iterate through the fields on a table and do something if its value does not equal its default value.</p>
<p>I'm in a trigger and so I know the table name. I then loop through each of
the fields using this loop:</p>
<pre><code>select @field = 0, @maxfield = max(ORDINAL_POSITION) from
INFORMATION_SCHEMA.C... | [
{
"answer_id": 461032,
"author": "VonC",
"author_id": 6309,
"author_profile": "https://Stackoverflow.com/users/6309",
"pm_score": 2,
"selected": false,
"text": "<p>You might want to give <a href=\"http://classpathchecker.free.fr/\" rel=\"nofollow noreferrer\">ClassPath Checker</a> and <a... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460873",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20315/"
] | I need to iterate through the fields on a table and do something if its value does not equal its default value.
I'm in a trigger and so I know the table name. I then loop through each of
the fields using this loop:
```
select @field = 0, @maxfield = max(ORDINAL_POSITION) from
INFORMATION_SCHEMA.COLUMNS where TABLE_NA... | Seems to work now. For those of you who are interested, this is what I had to do:
* Removed the Lucene 1.4.3 jar from my plugin
* Copied the old Lucene plugin from an older version of eclipse into version 3.4.
* Deleted all the dependencies in the plugin.xml wizard. Now all the Lucene plugins are visible.
* Selected v... |
460,879 | <p>I had user control in MVC ASP.NET which list the comments for particular image. I had given delete link with every comment. Now i want to delete that comment using Ajax link. Please tell me how can I use Ajax?</p>
<p>This is my user control and I am calling controller action on delete link:</p>
<pre><code><%@ C... | [
{
"answer_id": 461193,
"author": "Gavin",
"author_id": 55859,
"author_profile": "https://Stackoverflow.com/users/55859",
"pm_score": 0,
"selected": false,
"text": "<p>Use an Update Panel. It will capture the post back from your delete link and asyncronously reload the content. </p>\n\n<p... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460879",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I had user control in MVC ASP.NET which list the comments for particular image. I had given delete link with every comment. Now i want to delete that comment using Ajax link. Please tell me how can I use Ajax?
This is my user control and I am calling controller action on delete link:
```
<%@ Control Language="C#" Aut... | Use jQuery:
```
<script type="text/javascript">
function deleteComment(id) {
$.post(
"/MyController/DeleteAction",
{ id : id }
function (data) {
// do some gui updates
});
}
</script>
```
And use in a link:
```
<a onclick="deleteCommen... |
460,882 | <p>I feel like I'm running around in circles. I can't seem to make up my mind as to what the right repository pattern is using <a href="http://en.wikipedia.org/wiki/Language_Integrated_Query#LINQ_to_SQL" rel="noreferrer">LINQ to SQL</a>. If you're familiar with <a href="http://blog.wekeroad.com/" rel="noreferrer">Rob C... | [
{
"answer_id": 460896,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 4,
"selected": false,
"text": "<p>It depends on where the <a href=\"http://en.wikipedia.org/wiki/Data_transfer_object\" rel=\"nofollow noreferrer\">... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460882",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17744/"
] | I feel like I'm running around in circles. I can't seem to make up my mind as to what the right repository pattern is using [LINQ to SQL](http://en.wikipedia.org/wiki/Language_Integrated_Query#LINQ_to_SQL). If you're familiar with [Rob Conery's](http://blog.wekeroad.com/) [MVC Storefront](http://www.codeplex.com/mvcsam... | The thing is this, LINQ to SQL is not a true [Object Relation Mapper](http://en.wikipedia.org/wiki/Object-relational_mapping) (ORM), it is a data access layer generator. You can make it be an ORM by going deep by hand editing XML files and playing with [SqlMetal](http://msdn.microsoft.com/en-us/library/bb386987.aspx) a... |
460,905 | <p>Apologies if I get the terminology wrong. How do I define a constraint in MSSQL Server 2005 to enforce uniqueness in one column depending on another column?</p>
<p>E.g. considering the last two columns:</p>
<pre><code>1 A 1
2 A 2
3 A 2 <- Disallow because '2' has already appeared alongside 'A'... | [
{
"answer_id": 460913,
"author": "gkrogers",
"author_id": 54501,
"author_profile": "https://Stackoverflow.com/users/54501",
"pm_score": 4,
"selected": true,
"text": "<p>Try this: </p>\n\n<pre>CREATE TABLE tTable\n (field1 CHAR(1) NOT NULL,\n field2 INT NOT NULL,\n UNIQUE (fie... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460905",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/82/"
] | Apologies if I get the terminology wrong. How do I define a constraint in MSSQL Server 2005 to enforce uniqueness in one column depending on another column?
E.g. considering the last two columns:
```
1 A 1
2 A 2
3 A 2 <- Disallow because '2' has already appeared alongside 'A'
4 B 1
5 B 2... | Try this:
```
CREATE TABLE tTable
(field1 CHAR(1) NOT NULL,
field2 INT NOT NULL,
UNIQUE (field1, field2)
)
``` |
460,920 | <p>I'm trying to pass the following <code>String</code> to a <code>PreparedStatement</code>:</p>
<pre><code>private static final String QUICK_SEARCH = "select * from c where NAME like '% ? %'";
</code></pre>
<p>However, I get an SQL exception that the bind variable is missing.</p>
<p>Any suggestions?</p>
| [
{
"answer_id": 460913,
"author": "gkrogers",
"author_id": 54501,
"author_profile": "https://Stackoverflow.com/users/54501",
"pm_score": 4,
"selected": true,
"text": "<p>Try this: </p>\n\n<pre>CREATE TABLE tTable\n (field1 CHAR(1) NOT NULL,\n field2 INT NOT NULL,\n UNIQUE (fie... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460920",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24481/"
] | I'm trying to pass the following `String` to a `PreparedStatement`:
```
private static final String QUICK_SEARCH = "select * from c where NAME like '% ? %'";
```
However, I get an SQL exception that the bind variable is missing.
Any suggestions? | Try this:
```
CREATE TABLE tTable
(field1 CHAR(1) NOT NULL,
field2 INT NOT NULL,
UNIQUE (field1, field2)
)
``` |
460,931 | <p>Can anyone tell me if it's possible to have a the text in a single label control displayed in more than one style.</p>
<p>e.g. I have a label </p>
<p>I want the the text to appear with the style "english" (which it does), but I want the "th" of the text to be different (bold, different colour, whatever).</p>
<p>S... | [
{
"answer_id": 461009,
"author": "kenneth",
"author_id": 53363,
"author_profile": "https://Stackoverflow.com/users/53363",
"pm_score": 1,
"selected": false,
"text": "<p>yes, try the following</p>\n\n<pre><code>var la : Label;\nla.htmlText = '<TEXTFORMAT LEADING=\"3\"><P ALIGN=\"... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460931",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/57049/"
] | Can anyone tell me if it's possible to have a the text in a single label control displayed in more than one style.
e.g. I have a label
I want the the text to appear with the style "english" (which it does), but I want the "th" of the text to be different (bold, different colour, whatever).
So, the question in a nut... | Yes, it's possible. Take a look at the [`Label.htmlText`](http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/controls/Label.html#htmlText) documentation in the livedocs which explains how to set markup on a `Label` control, e.g.
```
<mx:Label>
<mx:htmlText><![CDATA[This is an example of <b>bold<... |
460,933 | <p>When user the "Implement Inteface X" context menu feature, the inserted code gets surrounded by a </p>
<pre><code>#region [interfacename] Members
#endregion
</code></pre>
<p>pair. I always end up deleting this, is there a way I can permanently turn it off? I had a quick search through the snippets directory, but... | [
{
"answer_id": 460987,
"author": "Frederik Gheysels",
"author_id": 55774,
"author_profile": "https://Stackoverflow.com/users/55774",
"pm_score": 6,
"selected": true,
"text": "<p>You can turn it off via Tools / Options </p>\n\n<p>Then, in the option-window, you select 'Text Editor', then ... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460933",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25462/"
] | When user the "Implement Inteface X" context menu feature, the inserted code gets surrounded by a
```
#region [interfacename] Members
#endregion
```
pair. I always end up deleting this, is there a way I can permanently turn it off? I had a quick search through the snippets directory, but wasn't sure if this was the... | You can turn it off via Tools / Options
Then, in the option-window, you select 'Text Editor', then the language of your choice (C# for ex).
Then, you select 'Advanced', and then, you have a checkbox which says:
'Surround generated code with #region' |
460,935 | <p>When developing a .NET Windows Forms Application we have the choice between those <code>App.config</code> tags to store our configuration values. Which one is better?</p>
<pre><code><configuration>
<!-- Choice 1 -->
<appSettings>
<add key="RequestTimeoutInMilliseconds" value="10000"/&g... | [
{
"answer_id": 461311,
"author": "Peter C",
"author_id": 1952,
"author_profile": "https://Stackoverflow.com/users/1952",
"pm_score": 4,
"selected": false,
"text": "<p>Application settings can be controlled from a designer (there is usually a Settings.settings file by default) so its easi... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460935",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48465/"
] | When developing a .NET Windows Forms Application we have the choice between those `App.config` tags to store our configuration values. Which one is better?
```
<configuration>
<!-- Choice 1 -->
<appSettings>
<add key="RequestTimeoutInMilliseconds" value="10000"/>
</appSettings>
<!-- Choice 2 -->
<confi... | The basic `<appSettings>` is easier to deal with - just slap in a `<add key="...." value="..." />` entry and you're done.
The downside is: there's no type-checking, e.g. you cannot safely assume your number that you wanted to configure there really is a number - someone could put a string into that setting..... you ju... |
460,942 | <p>I have some questions about partitioning and strategy, how and when to use it. As I understood from <a href="http://msdn.microsoft.com/en-us/library/ms345146.aspx#sql2k5parti_topic1" rel="nofollow noreferrer">Partitioned Tables and Indexes in SQL Server 2005</a>, partitioning is not used only for manageability but a... | [
{
"answer_id": 461022,
"author": "Brent Ozar",
"author_id": 26837,
"author_profile": "https://Stackoverflow.com/users/26837",
"pm_score": 3,
"selected": true,
"text": "<ol>\n<li><p>You can't create SQL Server partition functions with non-deterministic functions like getdate(). If you po... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460942",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53496/"
] | I have some questions about partitioning and strategy, how and when to use it. As I understood from [Partitioned Tables and Indexes in SQL Server 2005](http://msdn.microsoft.com/en-us/library/ms345146.aspx#sql2k5parti_topic1), partitioning is not used only for manageability but also to improve performance on very large... | 1. You can't create SQL Server partition functions with non-deterministic functions like getdate(). If you populated your database with data spanning 10 years, and then simply stopped and watched the SQL Server run for a few years, you would see SQL Server moving that data from one partition to another as dates changed... |
460,949 | <p>I'm adapting a pretty basic js function into a class. Anyway, basically it just creates a floating container
above the main page. I'm aware it's incomplete, but I'm in the middle of typing it up, and keep getting caught out when attempting to call the close() function. Firefox returns a <code>this.sdiv</code> is un... | [
{
"answer_id": 460981,
"author": "yfeldblum",
"author_id": 12349,
"author_profile": "https://Stackoverflow.com/users/12349",
"pm_score": 2,
"selected": false,
"text": "<p>You can't use <code>Pop.prototype.close()</code> to close all <code>Pop</code> instances. Instead, for each instance ... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460949",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm adapting a pretty basic js function into a class. Anyway, basically it just creates a floating container
above the main page. I'm aware it's incomplete, but I'm in the middle of typing it up, and keep getting caught out when attempting to call the close() function. Firefox returns a `this.sdiv` is undefined. I'm c... | You can't use `Pop.prototype.close()` to close all `Pop` instances. Instead, for each instance of `Pop` that you have created with the `new` operator, you need to call `popInstance.close()`. |
460,958 | <p>I'm trying to find a way to modify/extend a RakeFile from another RakeFile without actually changing it.</p>
<p>When I run my rake task I retrieve a solution from SVN which contains a rakefile. I want to: </p>
<ol>
<li>Change a variable in this rakefile. </li>
<li>Add a new task to this rakefile
which makes use of... | [
{
"answer_id": 463024,
"author": "August Lilleaas",
"author_id": 26051,
"author_profile": "https://Stackoverflow.com/users/26051",
"pm_score": 3,
"selected": false,
"text": "<p>Here's a way to run arbitrary code prior to executing the task.</p>\n\n<pre><code>your_task = Rake::Task['task:... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460958",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42278/"
] | I'm trying to find a way to modify/extend a RakeFile from another RakeFile without actually changing it.
When I run my rake task I retrieve a solution from SVN which contains a rakefile. I want to:
1. Change a variable in this rakefile.
2. Add a new task to this rakefile
which makes use of existing tasks.
3. Execute... | This is the code which I ended up with to solve the particular problem I was having.
```
Dir.chdir File.dirname(__FILE__) + '/their_app'
load 'RakeFile'
# Modify stuff from original RakeFile
COMPILE_TARGET = "release"
# Add my task
task :my_task =>[:my_pre_task, :their_task]
```
I don't know if this is the right w... |
460,978 | <p>In my helpset file, I'm declaring a favorites view, using</p>
<pre><code><view>
<name>Lesezeichen</name>
<label>Lesezeichen</label>
<type>javax.help.FavoritesView</type>
<data></data>
</view>
</code></pre>
<p>This automatically adds an appropriate... | [
{
"answer_id": 461134,
"author": "Boris Pavlović",
"author_id": 32090,
"author_profile": "https://Stackoverflow.com/users/32090",
"pm_score": 2,
"selected": true,
"text": "<p>If you extract the src.jar (rename it to src.zip and extract) and open the java class jh2.0/src/src/javax/help/re... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460978",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11765/"
] | In my helpset file, I'm declaring a favorites view, using
```
<view>
<name>Lesezeichen</name>
<label>Lesezeichen</label>
<type>javax.help.FavoritesView</type>
<data></data>
</view>
```
This automatically adds an appropriate button to the toolbar (in the swing application). Unfortunately, the tooltip of the b... | If you extract the src.jar (rename it to src.zip and extract) and open the java class jh2.0/src/src/javax/help/resources/Constants.java you will notice that in the section
```
// Tooltips for Actions
```
is located entry for localization:
```
{ "tooltip.FavoritesAction", "Add to Favorites"},
```
This constant is ... |
460,980 | <p>I'm trying to load the default HICON that explorer displays for: </p>
<ul>
<li>An open folder</li>
<li>An exe that has no embedded default icon of its own. This can also be seen in 'Add/Remove Programs' or 'Programs and Features' as it's called on Vista.</li>
</ul>
<p>Do you know where these can be found? I think... | [
{
"answer_id": 460996,
"author": "Xn0vv3r",
"author_id": 42475,
"author_profile": "https://Stackoverflow.com/users/42475",
"pm_score": 3,
"selected": true,
"text": "<p>I think they are in %windir%\\system32\\SHELL32.dll</p>\n\n<p>Found some code in the internet, try if that works:</p>\n\... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460980",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11898/"
] | I'm trying to load the default HICON that explorer displays for:
* An open folder
* An exe that has no embedded default icon of its own. This can also be seen in 'Add/Remove Programs' or 'Programs and Features' as it's called on Vista.
Do you know where these can be found? I think the folder icon might be in the res... | I think they are in %windir%\system32\SHELL32.dll
Found some code in the internet, try if that works:
```
HINSTANCE hDll;
hDll = LoadLibrary ( "SHELL32.dll" );
wincl.hIcon = LoadIcon (hDll , MAKEINTRESOURCE ( 1 ));
wincl.hIconSm = LoadIcon (hDll, MAKEINTRESOURCE ( 2 ));
```
---
Edit: Windows has a lot more icons... |
460,997 | <p>I have a table with 2 fields (<code>name</code>, <code>confirm</code>).
<code>confirm</code> is of type <code>tinyint</code> because I want to put in 0 or 1</p>
<p>Now I want to put 1 in <code>confirm</code>; is this statement correct?</p>
<pre><code>if($row['confirm']==0)
{
$query = "INSERT INTO opt (confirme... | [
{
"answer_id": 461007,
"author": "Frederik Gheysels",
"author_id": 55774,
"author_profile": "https://Stackoverflow.com/users/55774",
"pm_score": 2,
"selected": false,
"text": "<p>When 'confirmed' is a numeric column, then you should not put quotes around the 1.</p>\n\n<pre><code>INSERT I... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460997",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a table with 2 fields (`name`, `confirm`).
`confirm` is of type `tinyint` because I want to put in 0 or 1
Now I want to put 1 in `confirm`; is this statement correct?
```
if($row['confirm']==0)
{
$query = "INSERT INTO opt (confirmed) values('0')";
echo 'The user selected options has confirmed';
}
``` | The statement you've written is only correct if you also want the associated 'name' field to be NULL.
If you actually want both fields to be populated you should do:
```
INSERT INTO opt (name, confirmed) VALUES (?, ?)
```
and then use the `mysqli` or `PDO` family of functions to bind the `?` parameters to the user-... |
461,015 | <p>I'm trying to use the javascript port of processing found at <a href="http://ejohn.org/blog/processingjs/" rel="nofollow noreferrer">http://ejohn.org/blog/processingjs/</a> I want to use the following constructor. <code>Processing(CanvasElement, "some massive block of code");</code> I know javascript doesn't nativel... | [
{
"answer_id": 461034,
"author": "AnthonyWJones",
"author_id": 17516,
"author_profile": "https://Stackoverflow.com/users/17516",
"pm_score": 0,
"selected": false,
"text": "<p>Place the \"massive block of code\" in its own file on the server, fetch with AJAX and ensure it has reasonable c... | 2009/01/20 | [
"https://Stackoverflow.com/questions/461015",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14744/"
] | I'm trying to use the javascript port of processing found at <http://ejohn.org/blog/processingjs/> I want to use the following constructor. `Processing(CanvasElement, "some massive block of code");` I know javascript doesn't natively support multiline strings but is there a way to pass something like the following with... | Javascript actually does support multi-line strings: append a backslash to the end of each line:
```
alert('1\
2\
3');
```
Not very pretty, but it works.
An alternative would be to use a script to encode your text... I'd suggest PHP as it's a 1-liner:
```
<?=json_encode('your text');?>
``` |
461,026 | <p>I'm trying to create some basic logging for unhandled exceptions in my ASP.NET MVC application, but as I'm using IIS6 all requests come through .NET. Now while I agree that missing images are an important thing to flag, they aren't show-stoppers and so I'd like to set the event priority to high for 404s unless they ... | [
{
"answer_id": 461079,
"author": "Anthony Main",
"author_id": 258,
"author_profile": "https://Stackoverflow.com/users/258",
"pm_score": 0,
"selected": false,
"text": "<p>You would have to send all traffic through to the .net isapi layer and do a manual 404 check yourself (if file exists)... | 2009/01/20 | [
"https://Stackoverflow.com/questions/461026",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/192/"
] | I'm trying to create some basic logging for unhandled exceptions in my ASP.NET MVC application, but as I'm using IIS6 all requests come through .NET. Now while I agree that missing images are an important thing to flag, they aren't show-stoppers and so I'd like to set the event priority to high for 404s unless they are... | You can get it via `Context.Server.GetLastError()`:
```
if ((Context.Server.GetLastError() is HttpException) && ((Context.Server.GetLastError() as HttpException).GetHttpCode() == 404))
{
// do something
}
``` |
461,037 | <p>I’m using SharePoint (Business Data List web part) with the BDC. I use this to bring back data from the database, nice and simple.</p>
<p>However, when I do a search I receive a number of results being paged by the web page. This takes a while to bring back any search results (even when navigating between the paged... | [
{
"answer_id": 461079,
"author": "Anthony Main",
"author_id": 258,
"author_profile": "https://Stackoverflow.com/users/258",
"pm_score": 0,
"selected": false,
"text": "<p>You would have to send all traffic through to the .net isapi layer and do a manual 404 check yourself (if file exists)... | 2009/01/20 | [
"https://Stackoverflow.com/questions/461037",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47642/"
] | I’m using SharePoint (Business Data List web part) with the BDC. I use this to bring back data from the database, nice and simple.
However, when I do a search I receive a number of results being paged by the web page. This takes a while to bring back any search results (even when navigating between the paged data). I’... | You can get it via `Context.Server.GetLastError()`:
```
if ((Context.Server.GetLastError() is HttpException) && ((Context.Server.GetLastError() as HttpException).GetHttpCode() == 404))
{
// do something
}
``` |
461,074 | <p>I want to print a list to screen in a readable way. I use a loop to go through each element and make a new list which is formatted with commas and newlines. The problem is that in the first line of the output, I want a title. E.g., I want to print something like this:</p>
<pre><code>List: red, green, blue, black, c... | [
{
"answer_id": 461089,
"author": "squadette",
"author_id": 7754,
"author_profile": "https://Stackoverflow.com/users/7754",
"pm_score": 4,
"selected": true,
"text": "<p>It'll be</p>\n\n<pre><code>yes ' ' | head -7 | tr -d '\\n'\n</code></pre>\n\n<p>Change '7' into your number.</p>\n\n<p>M... | 2009/01/20 | [
"https://Stackoverflow.com/questions/461074",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51634/"
] | I want to print a list to screen in a readable way. I use a loop to go through each element and make a new list which is formatted with commas and newlines. The problem is that in the first line of the output, I want a title. E.g., I want to print something like this:
```
List: red, green, blue, black, cars,
bus... | It'll be
```
yes ' ' | head -7 | tr -d '\n'
```
Change '7' into your number.
Maybe you should take a look at
```
man fmt
```
also. |
461,093 | <p>I learned that compiler will expand macros while compiling. Templates are also expanded at the compile time. Is there any way to see this expanded code? I am compiling using Visual Studio 2008.</p>
<p>any thoughts?</p>
| [
{
"answer_id": 461107,
"author": "Dave Ray",
"author_id": 40310,
"author_profile": "https://Stackoverflow.com/users/40310",
"pm_score": 4,
"selected": true,
"text": "<p>The VC++ compiler (cl.exe) supports a few command line switches for this:</p>\n\n<pre><code>/E preprocess to stdout\n/P... | 2009/01/20 | [
"https://Stackoverflow.com/questions/461093",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/50419/"
] | I learned that compiler will expand macros while compiling. Templates are also expanded at the compile time. Is there any way to see this expanded code? I am compiling using Visual Studio 2008.
any thoughts? | The VC++ compiler (cl.exe) supports a few command line switches for this:
```
/E preprocess to stdout
/P preprocess to file
/EP preproscess to stdout with no #lines
```
Additional command-line switches can be added in your project properties. In my version (VC2005), Configuration Options -> C/C++ -> Command Line -> ... |
461,098 | <p>I have this function...</p>
<pre><code>private string dateConvert(string datDate)
{
System.Globalization.CultureInfo cultEnGb = new System.Globalization.CultureInfo("en-GB");
System.Globalization.CultureInfo cultEnUs = new System.Globalization.CultureInfo("en-US");
DateTime dtGb = Convert.T... | [
{
"answer_id": 461105,
"author": "mmx",
"author_id": 33708,
"author_profile": "https://Stackoverflow.com/users/33708",
"pm_score": 7,
"selected": true,
"text": "<pre><code>return dateTimeValue.ToString(\"MM-dd-yyyy\");\n</code></pre>\n"
},
{
"answer_id": 461111,
"author": "Gl... | 2009/01/20 | [
"https://Stackoverflow.com/questions/461098",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/52912/"
] | I have this function...
```
private string dateConvert(string datDate)
{
System.Globalization.CultureInfo cultEnGb = new System.Globalization.CultureInfo("en-GB");
System.Globalization.CultureInfo cultEnUs = new System.Globalization.CultureInfo("en-US");
DateTime dtGb = Convert.ToDateTime(datD... | ```
return dateTimeValue.ToString("MM-dd-yyyy");
``` |
461,106 | <p>The idea is to define a base class that can invoke methods defined in derrived classes, but at creation time I want to ensure, that such methods are defined exactly according to the requirements, which is that the methods take only one argument, a HashMap<code><String String</code>>.</p>
<p>So far I was able wit... | [
{
"answer_id": 461118,
"author": "Dave Ray",
"author_id": 40310,
"author_profile": "https://Stackoverflow.com/users/40310",
"pm_score": 3,
"selected": false,
"text": "<p>You can't. Java generic types are \"erased\" by the compiler, i.e. <code>HashMap<String, String></code> becomes ... | 2009/01/20 | [
"https://Stackoverflow.com/questions/461106",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | The idea is to define a base class that can invoke methods defined in derrived classes, but at creation time I want to ensure, that such methods are defined exactly according to the requirements, which is that the methods take only one argument, a HashMap`<String String`>.
So far I was able with the following code to ... | Indeed, there is type erasure but it is not applied to variables/fields - only to definitions of classes where the type params are erased and replaced with their upper bounds.
This means that what you are asking can be achieved. Here's how you can inspect the generic params of the first parameter of a method:
```
cla... |
461,136 | <p>I have the following output structure of executables in my solution:</p>
<pre>
%ProgramFiles%
|
+-[MyAppName]
|
+-[Client]
| |
| +-(EXE & several DLL assemblies)
|
+-[Common]
| |
| +-[Schema Assemblies]
... | [
{
"answer_id": 461171,
"author": "Gerrie Schenck",
"author_id": 57036,
"author_profile": "https://Stackoverflow.com/users/57036",
"pm_score": 0,
"selected": false,
"text": "<p>Here's how .Net finds the assemblies that are needed: <a href=\"http://msdn.microsoft.com/en-us/library/yx7xezcf... | 2009/01/20 | [
"https://Stackoverflow.com/questions/461136",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/82121/"
] | I have the following output structure of executables in my solution:
```
%ProgramFiles%
|
+-[MyAppName]
|
+-[Client]
| |
| +-(EXE & several DLL assemblies)
|
+-[Common]
| |
| +-[Schema Assemblies]
| |... | AFAIK the only solution is to have at least "stub" exes in MyAppBase and then define subdirectories as sources for DLL's in app.config for each application.
NTFS does support "mounting" other directories (ie. hard links) as subdirectories, but they're very unautomatic and since I've not tried going that way except the... |
461,138 | <p>I am currently logging an AJAX application with messages which include the times of certain interactions. So I have a couple of places where the code follows a pattern such as this: </p>
<pre><code>var startTime = new Date();
this.doFunction();
var endTime = new Date();
logger.log("doFunction took " + (endTime - s... | [
{
"answer_id": 461157,
"author": "krosenvold",
"author_id": 23691,
"author_profile": "https://Stackoverflow.com/users/23691",
"pm_score": 2,
"selected": true,
"text": "<p>No. All browsers are single-threaded in the javascript engine. I suspect that you can also solve this problem simply ... | 2009/01/20 | [
"https://Stackoverflow.com/questions/461138",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4120/"
] | I am currently logging an AJAX application with messages which include the times of certain interactions. So I have a couple of places where the code follows a pattern such as this:
```
var startTime = new Date();
this.doFunction();
var endTime = new Date();
logger.log("doFunction took " + (endTime - startTime) + " m... | No. All browsers are single-threaded in the javascript engine. I suspect that you can also solve this problem simply by invoking toTime() as a function instead of using eval(). You may want to look into the javascript [arguments](http://www.seifi.org/javascript/javascript-arguments.html) object and the javascript "[cal... |
461,139 | <p>I am automating some profiling tasks and want to log heap space and generation sizes real-time. The <a href="http://msdn.microsoft.com/en-us/library/bb384547.aspx" rel="noreferrer">profiling API</a> seems awfully complicated for what I need, and it seems to listen in on individual allocations and collections, which... | [
{
"answer_id": 461150,
"author": "Brian Rasmussen",
"author_id": 38206,
"author_profile": "https://Stackoverflow.com/users/38206",
"pm_score": 3,
"selected": false,
"text": "<p>There are performance counters for a lot of this stuff and if you can't use Perfmon, you can access counters th... | 2009/01/20 | [
"https://Stackoverflow.com/questions/461139",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15515/"
] | I am automating some profiling tasks and want to log heap space and generation sizes real-time. The [profiling API](http://msdn.microsoft.com/en-us/library/bb384547.aspx) seems awfully complicated for what I need, and it seems to listen in on individual allocations and collections, which isn't that important to me. Pro... | The term 'current memory usage' is a little loosely defined. Do you mean the working set? Whatever it means, you can use different properties such as `VirtualMemorySize`, `WorkingSet`, `PrivateMemorySize`, etc. from the process class to retrieve it.
```
long workingSet = System.Diagnostics.Process.GetCurrentProcess().... |
461,140 | <p>I have a simple scenario where a panel needs a masked loading indicator over it while its loading the content. I have the mask working fine using the following code but the loading indicator appears at the top when calling it the first time. When calling it after the panel is shown, ie. on a button event, the mask a... | [
{
"answer_id": 461266,
"author": "Mark Clancy",
"author_id": 57083,
"author_profile": "https://Stackoverflow.com/users/57083",
"pm_score": 4,
"selected": true,
"text": "<p>It appears the mask is applied to the panel before the html has been rendered completely. A simple solution was to d... | 2009/01/20 | [
"https://Stackoverflow.com/questions/461140",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/57083/"
] | I have a simple scenario where a panel needs a masked loading indicator over it while its loading the content. I have the mask working fine using the following code but the loading indicator appears at the top when calling it the first time. When calling it after the panel is shown, ie. on a button event, the mask appe... | It appears the mask is applied to the panel before the html has been rendered completely. A simple solution was to delay the mask shortly before applying it.
```
render: function(comp) {
setTimeout(function() { comp.loadPermissions(); }, 100);
}
``` |
461,146 | <p>Is the following stored procedure code robust for multi-user application. It is working fine. I was wondering if there is any better way to do it and if there is any performance issues.</p>
<p>The proc has three sql statements together like 1.Updating hardware status in Allocation Table 2. Calculating Next appropri... | [
{
"answer_id": 461181,
"author": "Mitch Wheat",
"author_id": 16076,
"author_profile": "https://Stackoverflow.com/users/16076",
"pm_score": 3,
"selected": true,
"text": "<p>Using a SERIALIZABLE transaction level is not recommended unless you absolutely have to have one. It will increase t... | 2009/01/20 | [
"https://Stackoverflow.com/questions/461146",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/56631/"
] | Is the following stored procedure code robust for multi-user application. It is working fine. I was wondering if there is any better way to do it and if there is any performance issues.
The proc has three sql statements together like 1.Updating hardware status in Allocation Table 2. Calculating Next appropriate Primar... | Using a SERIALIZABLE transaction level is not recommended unless you absolutely have to have one. It will increase the likelihood of blocking and decrease throughput.
You seem to be using it in order to guarantee a unique DEFECT\_ID? Why not use an IDENTITY column for DEFECT\_ID instead? |
461,167 | <p>What would be the best way to resize images, which could be of any dimension, to a fixed size, or at least to fit within a fixed size?</p>
<p>The images come from random urls that are not in my control, and I must ensure the images do not go out of an area roughly 250px x 300px, or 20% by 50% of a layer.</p>
<p>I ... | [
{
"answer_id": 461207,
"author": "Gumbo",
"author_id": 53114,
"author_profile": "https://Stackoverflow.com/users/53114",
"pm_score": 0,
"selected": false,
"text": "<p>You could use the following:</p>\n\n<pre><code>$maxWidth = 250;\n$maxHeight = 500;\n\n$validSize = true;\n$imageinfo = g... | 2009/01/20 | [
"https://Stackoverflow.com/questions/461167",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1246613/"
] | What would be the best way to resize images, which could be of any dimension, to a fixed size, or at least to fit within a fixed size?
The images come from random urls that are not in my control, and I must ensure the images do not go out of an area roughly 250px x 300px, or 20% by 50% of a layer.
I would think that ... | It's easy to do with ImageMagick. Either you use convert command line tool via exec or you use <http://www.francodacosta.com/phmagick/resizing-images> .
If you use 'convert' you can even tell ImageMagick to just resize larger images and to not convert smaller ones: <http://www.imagemagick.org/Usage/resize/>
If you ... |
461,184 | <p>I have created an application that runs in the taskbar. When a user clicks the application it pops up etc. What I would like is similar functionality to that in MSN when one of my friends logs in. Apparently this is know as a toast popup?
I basically want something to popup from every 20 minutes toast style fom the ... | [
{
"answer_id": 461318,
"author": "aku",
"author_id": 1196,
"author_profile": "https://Stackoverflow.com/users/1196",
"pm_score": 6,
"selected": true,
"text": "<p>This is pretty simple. You just need to set window in off-screen area and animate it's position until it is fully visible. Her... | 2009/01/20 | [
"https://Stackoverflow.com/questions/461184",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35441/"
] | I have created an application that runs in the taskbar. When a user clicks the application it pops up etc. What I would like is similar functionality to that in MSN when one of my friends logs in. Apparently this is know as a toast popup?
I basically want something to popup from every 20 minutes toast style fom the app... | This is pretty simple. You just need to set window in off-screen area and animate it's position until it is fully visible. Here is a sample code:
```
public partial class Form1 : Form
{
private Timer timer;
private int startPosX;
private int startPosY;
public Form1()
{
InitializeComponent(... |
461,203 | <p>I have a solid understanding of most <code>OOP</code> theory but the one thing that confuses me a lot is virtual destructors.</p>
<p>I thought that the destructor always gets called no matter what and for every object in the chain.</p>
<p>When are you meant to make them virtual and why?</p>
| [
{
"answer_id": 461213,
"author": "yesraaj",
"author_id": 22076,
"author_profile": "https://Stackoverflow.com/users/22076",
"pm_score": 6,
"selected": false,
"text": "<p>Make the destructor virtual whenever your class is polymorphic.</p>\n"
},
{
"answer_id": 461224,
"author": ... | 2009/01/20 | [
"https://Stackoverflow.com/questions/461203",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23339/"
] | I have a solid understanding of most `OOP` theory but the one thing that confuses me a lot is virtual destructors.
I thought that the destructor always gets called no matter what and for every object in the chain.
When are you meant to make them virtual and why? | Virtual destructors are useful when you might potentially delete an instance of a derived class through a pointer to base class:
```
class Base
{
// some virtual methods
};
class Derived : public Base
{
~Derived()
{
// Do some important cleanup
}
};
```
Here, you'll notice that I didn't dec... |
461,204 | <p>The following query does what I'd like it to do, however, I have no idea if it's efficient. I went through the <a href="http://docs.djangoproject.com/en/dev/topics/db/aggregation/" rel="nofollow noreferrer">Django aggregation</a> documentation, threw it together, looked at the query and tilted my head sideways like ... | [
{
"answer_id": 461226,
"author": "edgars",
"author_id": 6865,
"author_profile": "https://Stackoverflow.com/users/6865",
"pm_score": 4,
"selected": true,
"text": "<p>2) Yes, if settings.DEBUG is true, the raw sql queries are stored in django.db.connection.queries.</p>\n\n<p><a href=\"http... | 2009/01/20 | [
"https://Stackoverflow.com/questions/461204",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53390/"
] | The following query does what I'd like it to do, however, I have no idea if it's efficient. I went through the [Django aggregation](http://docs.djangoproject.com/en/dev/topics/db/aggregation/) documentation, threw it together, looked at the query and tilted my head sideways like a confused dog.
What the query actually... | 2) Yes, if settings.DEBUG is true, the raw sql queries are stored in django.db.connection.queries.
<http://blog.michaeltrier.com/2007/8/11/display-the-sql-django-orm-is-generating> |
461,231 | <p>For instance, take this piece of code:</p>
<pre><code>var person = new Person();
</code></pre>
<p>or for you Pythonistas:</p>
<pre><code>person = Person()
</code></pre>
<p>I'm told constantly how bad this is, but have yet to see an example of the immorality of these two lines of code. To me, person is a Person ... | [
{
"answer_id": 461239,
"author": "Andrew Hare",
"author_id": 34211,
"author_profile": "https://Stackoverflow.com/users/34211",
"pm_score": 8,
"selected": true,
"text": "<p>What is the reasoning of those telling you this is bad? I do this all the time. It is the simplest, expressive way... | 2009/01/20 | [
"https://Stackoverflow.com/questions/461231",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2147/"
] | For instance, take this piece of code:
```
var person = new Person();
```
or for you Pythonistas:
```
person = Person()
```
I'm told constantly how bad this is, but have yet to see an example of the immorality of these two lines of code. To me, person is a Person and trying to give it another name is a waste of t... | What is the reasoning of those telling you this is bad? I do this all the time. It is the simplest, expressive way to name a single variable of a type. If you needed two `Person` objects then you could prefix `person` with meaningful adjectives like
```
fastPerson
slowPerson
```
otherwise just
```
person
```
is f... |
461,236 | <pre><code>void foo(void **Pointer);
int main ()
{
int *IntPtr;
foo(&((void*)IntPtr));
}
</code></pre>
<p>Why do I get an error?</p>
<pre><code>error: lvalue required as unary ‘&’ operand
</code></pre>
<p>Thanks</p>
| [
{
"answer_id": 461243,
"author": "mmx",
"author_id": 33708,
"author_profile": "https://Stackoverflow.com/users/33708",
"pm_score": 3,
"selected": false,
"text": "<pre><code>void foo(void **Pointer);\n\nint main ()\n{\n int *IntPtr;\n\n foo((void**)&IntPtr);\n}\n</code></pre>\n"... | 2009/01/20 | [
"https://Stackoverflow.com/questions/461236",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48461/"
] | ```
void foo(void **Pointer);
int main ()
{
int *IntPtr;
foo(&((void*)IntPtr));
}
```
Why do I get an error?
```
error: lvalue required as unary ‘&’ operand
```
Thanks | (void\*) is not an lvalue, it is kind of a casting operator, you need to have the ampersand to the immediate left of the variable (lvalue).
This should be right:
```
foo(((void**)&IntPtr));
``` |
461,255 | <p>I have heard from people who swear by one or the other. Both are full-featured, excellent IDEs. But each has slightly different strengths. This is not meant to turn into a holy IDE war. Please downvote any flamebait answers. Thanks.</p>
<p>This is the analog of <a href="https://stackoverflow.com/questions/2397... | [
{
"answer_id": 461273,
"author": "Arne Burmeister",
"author_id": 12890,
"author_profile": "https://Stackoverflow.com/users/12890",
"pm_score": 0,
"selected": false,
"text": "<p>A working subversion integration, have a look at the <a href=\"http://www.jetbrains.net/jira/browse/IDEA/compon... | 2009/01/20 | [
"https://Stackoverflow.com/questions/461255",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23572/"
] | I have heard from people who swear by one or the other. Both are full-featured, excellent IDEs. But each has slightly different strengths. This is not meant to turn into a holy IDE war. Please downvote any flamebait answers. Thanks.
This is the analog of [this question](https://stackoverflow.com/questions/239732/thing... | My favourite small annoyance in IDEA (and favourite small feature in Eclipse) is the positioning of the character when typing an opening curly brace (e.g. "{") or a semicolon. You'll have to enable it in Eclipse (Window/Preferences/Java/Editor/Typing: "Automatically insert at correct position: Semicolon, Braces")
With... |
461,260 | <p>Is there a max. size you can set Xmx to? I set it to 1024m and eclipse opens ok. When I set it above 1024, eclipse doesn't open and I get the error "jvm terminated. Exit code=-1"...</p>
<p>I was doing this because I keep getting an "java.lang.OutOfMemoryError: Java heap space". I am reading in a 35.5Mb .txt file an... | [
{
"answer_id": 461284,
"author": "user54579",
"author_id": 54579,
"author_profile": "https://Stackoverflow.com/users/54579",
"pm_score": 3,
"selected": false,
"text": "<p>I think a 32 bit JVM has a maximum of 2GB memory.This might be out of date though. If I understood correctly, you set... | 2009/01/20 | [
"https://Stackoverflow.com/questions/461260",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Is there a max. size you can set Xmx to? I set it to 1024m and eclipse opens ok. When I set it above 1024, eclipse doesn't open and I get the error "jvm terminated. Exit code=-1"...
I was doing this because I keep getting an "java.lang.OutOfMemoryError: Java heap space". I am reading in a 35.5Mb .txt file and this err... | Yes, there is a maximum, but it's system dependent. Try it and see, doubling until you hit a limit then searching down. At least with Sun JRE 1.6 on linux you get interesting if not always informative error messages (peregrino is netbook running 32 bit ubuntu with 2G RAM and no swap):
```
peregrino:$ java -Xmx4096M -c... |
461,281 | <p>I would like to programmatically insert additional rows into a DataGrid (to act as subheadings). I have followed a number of articles online (namely option 3 from <a href="http://aspalliance.com/723" rel="nofollow noreferrer">http://aspalliance.com/723</a>) but they all result in the row being displayed correctly, b... | [
{
"answer_id": 461482,
"author": "Tom Robinson",
"author_id": 12124,
"author_profile": "https://Stackoverflow.com/users/12124",
"pm_score": 3,
"selected": true,
"text": "<p>Problem solved - somewhere in the 2500 lines of existing code-behind, something was hiding the first column, effect... | 2009/01/20 | [
"https://Stackoverflow.com/questions/461281",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12124/"
] | I would like to programmatically insert additional rows into a DataGrid (to act as subheadings). I have followed a number of articles online (namely option 3 from <http://aspalliance.com/723>) but they all result in the row being displayed correctly, but with no contents.
Here is the important part of the code I'm usi... | Problem solved - somewhere in the 2500 lines of existing code-behind, something was hiding the first column, effectively removing my addition. Something to watch out for if anyone else has similar problems.
Edit - Here's the code I've written to get round the problem in a reasonably generic way:
```
private void Inse... |
461,306 | <p>I am currently writing a small framework that will be used internally by other developers within the company.</p>
<p>I want to provide good Intellisense information, but I am not sure <em>how</em> to document thrown exceptions.</p>
<p>In the following example:</p>
<pre><code>public void MyMethod1()
{
MyMethod... | [
{
"answer_id": 461316,
"author": "GvS",
"author_id": 11492,
"author_profile": "https://Stackoverflow.com/users/11492",
"pm_score": 1,
"selected": false,
"text": "<p>You should document all exceptions that could possibly be thrown by your method.</p>\n\n<p>To hide the implementation detai... | 2009/01/20 | [
"https://Stackoverflow.com/questions/461306",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/169/"
] | I am currently writing a small framework that will be used internally by other developers within the company.
I want to provide good Intellisense information, but I am not sure *how* to document thrown exceptions.
In the following example:
```
public void MyMethod1()
{
MyMethod2();
// also may throw Invalid... | You should document every exception that might be thrown by your code, including those in any methods that you might call.
If the list gets a bit big, you might want to create your own exception type. Catch all the ones you might encounter within your method, wrap them in your exception, and throw that.
Another place... |
461,343 | <p>I want to get image from IImage object from specified path location.Here is the code .</p>
<pre><code> NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtInde... | [
{
"answer_id": 461495,
"author": "Adam Wright",
"author_id": 1200,
"author_profile": "https://Stackoverflow.com/users/1200",
"pm_score": 3,
"selected": false,
"text": "<p>I believe UIImage imageNamed looks for images from the application bundle, rather than by full path. You can use UIIm... | 2009/01/20 | [
"https://Stackoverflow.com/questions/461343",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I want to get image from IImage object from specified path location.Here is the code .
```
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString... | I believe UIImage imageNamed looks for images from the application bundle, rather than by full path. You can use UIImage imageWithContentsOfFile to load from a full path (but it won't be cached), or just put the image in your bundle and use imageNamed.
You also need to check that the file is actually being placed in y... |
461,361 | <p>I want my asp.net mvc framework system to send an e-mail everytime a certain action (inside a certain controller) is fired off. Are there any third party libraries or .net standard ways to accomplish this?</p>
| [
{
"answer_id": 461393,
"author": "terjetyl",
"author_id": 29519,
"author_profile": "https://Stackoverflow.com/users/29519",
"pm_score": 2,
"selected": false,
"text": "<p>Create a BaseController from which all your other controllers inherits.\nIn the BaseController override the OnActionEx... | 2009/01/20 | [
"https://Stackoverflow.com/questions/461361",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/148909/"
] | I want my asp.net mvc framework system to send an e-mail everytime a certain action (inside a certain controller) is fired off. Are there any third party libraries or .net standard ways to accomplish this? | A more up to date method would be to use [System.Net.Mail](http://msdn.microsoft.com/en-us/library/system.net.mail.smtpclient.aspx) - this is the 2.0 replacement for System.Web.Mail.
Something like this, called from either a BaseController (if there are other controllers that need this) the actual controller in questi... |
461,375 | <p>Where is the proper place to perform validation given the following scenario/code below:</p>
<p>In MethodA only: since this is the public method which is meant to be used by external assemblies?
In MethodA and B since both these can be accessed outside the class?
Or Methods A, B and C since method C may be used by ... | [
{
"answer_id": 461384,
"author": "Otávio Décio",
"author_id": 48684,
"author_profile": "https://Stackoverflow.com/users/48684",
"pm_score": 3,
"selected": true,
"text": "<p>Parameter validation should always be performed regardless of the caller's location (inside or outside of the assem... | 2009/01/20 | [
"https://Stackoverflow.com/questions/461375",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/57106/"
] | Where is the proper place to perform validation given the following scenario/code below:
In MethodA only: since this is the public method which is meant to be used by external assemblies?
In MethodA and B since both these can be accessed outside the class?
Or Methods A, B and C since method C may be used by another in... | Parameter validation should always be performed regardless of the caller's location (inside or outside of the assembly). Defensive programming, one can say. |
461,378 | <p>I have started to make heavy use of exceptions, I'm sure I'll grow out of it as a learn the advantages and disadvantages the hard way, but until I've become an exception guru I'd like to know if this technique is acceptable.</p>
<p>I intend to wrap, say a database exception in my own 'SorryFailedToSaveYourData' exc... | [
{
"answer_id": 461505,
"author": "Welbog",
"author_id": 52443,
"author_profile": "https://Stackoverflow.com/users/52443",
"pm_score": 0,
"selected": false,
"text": "<p>You're building a label inside of an exception, presumably because you want to display the message to the user. If your ... | 2009/01/20 | [
"https://Stackoverflow.com/questions/461378",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/982/"
] | I have started to make heavy use of exceptions, I'm sure I'll grow out of it as a learn the advantages and disadvantages the hard way, but until I've become an exception guru I'd like to know if this technique is acceptable.
I intend to wrap, say a database exception in my own 'SorryFailedToSaveYourData' exception and... | I wouldn't display each and every inner exception message to the user of your application. I would catch the real exception (ie SqlException) and rethrow it as your own exception (ie throw new YouCantSaveThisTwiceException("This customer ID already exists") ). Then just display that hand typed message to the user on a ... |
461,396 | <p>What is the easiest way to convert a <code>RECT</code> struct (<code>tagRECT</code>) or a <code>CRect</code> to a <code>Gdiplus::Rect</code>?</p>
<pre><code>Gdiplus::Rect tmpRect(rect.top, rect.left, rect.Width(), rect.Height());
</code></pre>
<p>works but is a lot of typing.</p>
| [
{
"answer_id": 461617,
"author": "Elliveny",
"author_id": 405555,
"author_profile": "https://Stackoverflow.com/users/405555",
"pm_score": 0,
"selected": false,
"text": "<p>I use the SQL Compare product from Red Gate (<a href=\"http://www.red-gate.com/products/SQL_Compare/index.htm\" rel=... | 2009/01/20 | [
"https://Stackoverflow.com/questions/461396",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1490/"
] | What is the easiest way to convert a `RECT` struct (`tagRECT`) or a `CRect` to a `Gdiplus::Rect`?
```
Gdiplus::Rect tmpRect(rect.top, rect.left, rect.Width(), rect.Height());
```
works but is a lot of typing. | The easiest way to do this is with Microsoft's `sp_help_revlogin`, a stored procedure that scripts all SQL Server logins, defaults and passwords, and keeps the same SIDs.
You can find it in this knowledge base article:
<http://support.microsoft.com/kb/918992> |
461,398 | <p>I have a really strange enum bug in Java.</p>
<pre><code>for(Answer ans : assessmentResult.getAnswersAsList()) { //originally stored in a table
//AnswerStatus stat = ans.getStatus();
if (ans.getStatus() == AnswerStatus.NOT_ASSESSED) {
assessed = false;
}
}
</code></pre>
<p>An answer is an answe... | [
{
"answer_id": 461421,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "<p>What happens if you use .equals instead of ==?</p>\n"
},
{
"answer_id": 461467,
"author": "Michael Borgwardt",
... | 2009/01/20 | [
"https://Stackoverflow.com/questions/461398",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a really strange enum bug in Java.
```
for(Answer ans : assessmentResult.getAnswersAsList()) { //originally stored in a table
//AnswerStatus stat = ans.getStatus();
if (ans.getStatus() == AnswerStatus.NOT_ASSESSED) {
assessed = false;
}
}
```
An answer is an answer to a question on a test.... | Solved.
It was the NetBeans debugger that tricked me. It does not pass the if test (although NetBeans says that).
Sorry for the inconvenience :-) |
461,403 | <p>I get Error: 'CanvasElement' is undefined when trying to run the following code using the javascript port of processing.</p>
<pre>
var p = Processing(CanvasElement);
p.size(100, 100);
p.background(0);
p.fill(255);
p.ellipse(50, 50, 50, 50);
</pre>
<p>Any help with this would be appreciated.</p>
| [
{
"answer_id": 461419,
"author": "Andrew Hare",
"author_id": 34211,
"author_profile": "https://Stackoverflow.com/users/34211",
"pm_score": 0,
"selected": false,
"text": "<p>Where is <code>CanvasElement</code> defined? It sounds like the code you posted is executing before the code that ... | 2009/01/20 | [
"https://Stackoverflow.com/questions/461403",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14744/"
] | I get Error: 'CanvasElement' is undefined when trying to run the following code using the javascript port of processing.
```
var p = Processing(CanvasElement);
p.size(100, 100);
p.background(0);
p.fill(255);
p.ellipse(50, 50, 50, 50);
```
Any help with this would be appreciated. | You need to have a canvas element somewhere on the page that you can select:
```
<canvas id="theCanvas" width="500" height="500"></canvas>
```
Then you can select the element however you want and pass it (or its ID) to the Processing function:
```
var p = Processing(document.getElementById("theCanvas")); // or Proc... |
461,406 | <p>I know of two methods of setting a default parameter, but I would like to know what the preferred method is.</p>
<pre><code>function Foo(par1, par2)
{
if(par2 == null)
par2 = "my default"
}
</code></pre>
<p>or</p>
<pre><code>function Foo(par1, par2)
{
par2 = par2 || "my default"
}
</code></pre>
<... | [
{
"answer_id": 461427,
"author": "mat",
"author_id": 42083,
"author_profile": "https://Stackoverflow.com/users/42083",
"pm_score": 2,
"selected": false,
"text": "<p>I usually use the second one because it adds less signal.</p>\n"
},
{
"answer_id": 461429,
"author": "Logan Ser... | 2009/01/20 | [
"https://Stackoverflow.com/questions/461406",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23855/"
] | I know of two methods of setting a default parameter, but I would like to know what the preferred method is.
```
function Foo(par1, par2)
{
if(par2 == null)
par2 = "my default"
}
```
or
```
function Foo(par1, par2)
{
par2 = par2 || "my default"
}
```
or is there a better way than either of these?
... | Personally I think the second form is just outright cleaner and more readable, certainly moreso than sergey's arguments inspection - though that can have it's place - but I prefer to pass extensible objects for args than have to maintain arg signatures.
*e.g.*
```
function Foo(myArgs)
{
myArgs.par1 = myArgs.par1 ... |
461,417 | <p>I'm trying to run my junit tests using ant. The tests are kicked off using a JUnit 4 test suite. If I run this direct from Eclipse the tests complete without error. However if I run it from ant then many of the tests fail with this error repeated over and over until the junit task crashes.</p>
<pre>
[junit] j... | [
{
"answer_id": 461488,
"author": "guerda",
"author_id": 32043,
"author_profile": "https://Stackoverflow.com/users/32043",
"pm_score": 2,
"selected": false,
"text": "<p>It sounds like there is an issue with paths.</p>\n\n<p>Check following error source:</p>\n\n<ul>\n<li>classpath: print o... | 2009/01/20 | [
"https://Stackoverflow.com/questions/461417",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/56679/"
] | I'm trying to run my junit tests using ant. The tests are kicked off using a JUnit 4 test suite. If I run this direct from Eclipse the tests complete without error. However if I run it from ant then many of the tests fail with this error repeated over and over until the junit task crashes.
```
[junit] java.util.z... | Found my problem. I had included my classes directory in my path using a **fileset** as opposed to a **pathelement** this was causing .class files to be opened as ZipFiles which of course threw an exception. |