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 |
|---|---|---|---|---|---|---|
500,864 | <p>In Python, I can compile a regular expression to be case-insensitive using <code>re.compile</code>:</p>
<pre><code>>>> s = 'TeSt'
>>> casesensitive = re.compile('test')
>>> ignorecase = re.compile('test', re.IGNORECASE)
>>>
>>> print casesensitive.match(s)
None
>>... | [
{
"answer_id": 500870,
"author": "Michael Haren",
"author_id": 29,
"author_profile": "https://Stackoverflow.com/users/29",
"pm_score": 11,
"selected": true,
"text": "<p>Pass <code>re.IGNORECASE</code> to the <code>flags</code> param of <a href=\"https://docs.python.org/library/re.html#re... | 2009/02/01 | [
"https://Stackoverflow.com/questions/500864",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42974/"
] | In Python, I can compile a regular expression to be case-insensitive using `re.compile`:
```
>>> s = 'TeSt'
>>> casesensitive = re.compile('test')
>>> ignorecase = re.compile('test', re.IGNORECASE)
>>>
>>> print casesensitive.match(s)
None
>>> print ignorecase.match(s)
<_sre.SRE_Match object at 0x02F0B608>
```
Is t... | Pass `re.IGNORECASE` to the `flags` param of [`search`](https://docs.python.org/library/re.html#re.search), [`match`](https://docs.python.org/library/re.html#re.match), or [`sub`](https://docs.python.org/library/re.html#re.sub):
```
re.search('test', 'TeSt', re.IGNORECASE)
re.match('test', 'TeSt', re.IGNORECASE)
re.su... |
500,886 | <p>I am very new to C and I have some problems learning about pointers. I experimented swapping and that's all what I can do with them :) I know that every variable has its own address in memory cells (this is what my lecturer told us) and every variable's value can be obtained by going to its associated address and th... | [
{
"answer_id": 500894,
"author": "PolyThinker",
"author_id": 47707,
"author_profile": "https://Stackoverflow.com/users/47707",
"pm_score": 3,
"selected": false,
"text": "<p>I think this is where classical books are more useful than most online resources. If you can get a copy, read <em>T... | 2009/02/01 | [
"https://Stackoverflow.com/questions/500886",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am very new to C and I have some problems learning about pointers. I experimented swapping and that's all what I can do with them :) I know that every variable has its own address in memory cells (this is what my lecturer told us) and every variable's value can be obtained by going to its associated address and then ... | Printing addresses and values is a reasonable way to look at them. But if you can get a debugger up and running, that's much better, because you can follow pointers faster, watch them change as you step, and so on.
If you're familiar with "shortcuts" in Windows, or soft links in linux filesystems, then it might help, ... |
500,913 | <p>There are environment variables you can set to help debug memory issues on the Mac, but how do you set the environment variables or enable these flags described in NSDebug.h for iPhone development? </p>
<pre><code>NAME OF ENV. VARIABLE DEFAULT SET TO...
NSDebugEnabled NO ... | [
{
"answer_id": 501272,
"author": "François P.",
"author_id": 54380,
"author_profile": "https://Stackoverflow.com/users/54380",
"pm_score": 3,
"selected": true,
"text": "<p>You have to go into the \"Get info\" contextual menu of your executable (inside the \"Executables\" group in the lef... | 2009/02/01 | [
"https://Stackoverflow.com/questions/500913",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | There are environment variables you can set to help debug memory issues on the Mac, but how do you set the environment variables or enable these flags described in NSDebug.h for iPhone development?
```
NAME OF ENV. VARIABLE DEFAULT SET TO...
NSDebugEnabled NO "YES"
NSZomb... | You have to go into the "Get info" contextual menu of your executable (inside the "Executables" group in the left panel of XCode). Then go in the arguments tab. You can add the environnement variables that you specified above in the box at the bottom ("Variables to set in the env.". Simply type YES or NO, you don't nee... |
500,915 | <p>When I use the XML serializer to serialize a <code>DateTime</code>, it is written in the following format:</p>
<pre><code><Date>2007-11-14T12:01:00</Date>
</code></pre>
<p>When passing this through an XSLT stylesheet to output HTML, how can I format this? In most cases I just need the date, and when I ... | [
{
"answer_id": 500941,
"author": "Dirk Vollmar",
"author_id": 40347,
"author_profile": "https://Stackoverflow.com/users/40347",
"pm_score": 5,
"selected": false,
"text": "<p>Date formatting is not easy in XSLT 1.0. Probably the most elegant way is to write a short XSLT extension function... | 2009/02/01 | [
"https://Stackoverflow.com/questions/500915",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31317/"
] | When I use the XML serializer to serialize a `DateTime`, it is written in the following format:
```
<Date>2007-11-14T12:01:00</Date>
```
When passing this through an XSLT stylesheet to output HTML, how can I format this? In most cases I just need the date, and when I need the time I of course don't want the "funny T... | Here are a couple of 1.0 templates that you can use:-
```
<xsl:template name="formatDate">
<xsl:param name="dateTime" />
<xsl:variable name="date" select="substring-before($dateTime, 'T')" />
<xsl:variable name="year" select="substring-before($date, '-')" />
<xsl:variable name="month" select="substring... |
500,925 | <p>For the following block of code:</p>
<pre><code>For I = 0 To listOfStrings.Count - 1
If myString.Contains(lstOfStrings.Item(I)) Then
Return True
End If
Next
Return False
</code></pre>
<p>The output is:</p>
<p><strong>Case 1:</strong></p>
<pre class="lang-none prettyprint-override"><code>myString:... | [
{
"answer_id": 500930,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 10,
"selected": true,
"text": "<p>With LINQ, and using C# (I don't know VB much these days):</p>\n\n<pre><code>bool b = listOfStrings.Any(s=>mySt... | 2009/02/01 | [
"https://Stackoverflow.com/questions/500925",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/57175/"
] | For the following block of code:
```
For I = 0 To listOfStrings.Count - 1
If myString.Contains(lstOfStrings.Item(I)) Then
Return True
End If
Next
Return False
```
The output is:
**Case 1:**
```none
myString: C:\Files\myfile.doc
listOfString: C:\Files\, C:\Files2\
Result: True
```
**Case 2:**
```... | With LINQ, and using C# (I don't know VB much these days):
```
bool b = listOfStrings.Any(s=>myString.Contains(s));
```
or (shorter and more efficient, but arguably less clear):
```
bool b = listOfStrings.Any(myString.Contains);
```
If you were testing equality, it would be worth looking at `HashSet` etc, but thi... |
500,926 | <p>So, In our appDelegate we're all used to creating a uinavigationcontroller outlet and linking it to a uinavigationcontroller in the XIB.</p>
<p>However in subsequent viewcontrollers I can only add uibarbuttonitems programatically by accessing the uinavigationcontroller. Is there a way to add buttons to applications... | [
{
"answer_id": 500930,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 10,
"selected": true,
"text": "<p>With LINQ, and using C# (I don't know VB much these days):</p>\n\n<pre><code>bool b = listOfStrings.Any(s=>mySt... | 2009/02/01 | [
"https://Stackoverflow.com/questions/500926",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51420/"
] | So, In our appDelegate we're all used to creating a uinavigationcontroller outlet and linking it to a uinavigationcontroller in the XIB.
However in subsequent viewcontrollers I can only add uibarbuttonitems programatically by accessing the uinavigationcontroller. Is there a way to add buttons to applications uinavigat... | With LINQ, and using C# (I don't know VB much these days):
```
bool b = listOfStrings.Any(s=>myString.Contains(s));
```
or (shorter and more efficient, but arguably less clear):
```
bool b = listOfStrings.Any(myString.Contains);
```
If you were testing equality, it would be worth looking at `HashSet` etc, but thi... |
500,935 | <p>while learning some basic programming with python, i found web.py. i
got stuck with a stupid problem:</p>
<p>i wrote a simple console app with a main loop that proccesses items
from a queue in seperate threads. my goal is to use web.py to add
items to my queue and report status of the queue via web request. i
got t... | [
{
"answer_id": 501570,
"author": "Shalom Craimer",
"author_id": 54491,
"author_profile": "https://Stackoverflow.com/users/54491",
"pm_score": 1,
"selected": false,
"text": "<p>Wouldn't is be simpler to re-write your main-loop code to be a function that you call over and over again, and t... | 2009/02/01 | [
"https://Stackoverflow.com/questions/500935",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51627/"
] | while learning some basic programming with python, i found web.py. i
got stuck with a stupid problem:
i wrote a simple console app with a main loop that proccesses items
from a queue in seperate threads. my goal is to use web.py to add
items to my queue and report status of the queue via web request. i
got this runnin... | I found a working solution. In a seperate module i create my webserver:
```
import web
import threading
class MyWebserver(threading.Thread):
def run (self):
urls = ('/', 'MyWebserver')
app = web.application(urls, globals())
app.run()
def POST ...
```
In the main programm i just call... |
500,939 | <p>I have a table with a code like this:</p>
<pre><code><table cellpadding="6" rules="groups" frame="no">
<thead>
<tr><th>Date</th><th>Length</th><th>Time</th></tr>
</thead>
<tbody>
<tr><td>31. January1</td><td>28 km</... | [
{
"answer_id": 500942,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<pre><code>border=\"0\"\n</code></pre>\n\n<p>However, you should use stylesheets instead for things like this....</p>\n"
},
... | 2009/02/01 | [
"https://Stackoverflow.com/questions/500939",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39740/"
] | I have a table with a code like this:
```
<table cellpadding="6" rules="groups" frame="no">
<thead>
<tr><th>Date</th><th>Length</th><th>Time</th></tr>
</thead>
<tbody>
<tr><td>31. January1</td><td>28 km</td><td>3 hours</tr>
</tbody></table>
```
The problem is that in IE the table has frame and a tableborder = 1.
... | Try this:
```
<!DOCTYPE html>
<html>
<head>
<title>Example:Table with Header Underline Border</title>
<style type="text/css">
table.groups
{
border-collapse: collapse;
}
table.groups thead th
{
border-bottom: solid 1px black;
}
t... |
500,967 | <p>I have a list of breakpoints which I want to add each time I debug a particular program.</p>
<p>Is there a way I can put all of the breakpoint information in a file and use it at the start of each debug session? In other words can I <strong>provide a script file with breakpoint information to GDB before I give the ... | [
{
"answer_id": 500975,
"author": "Sean Bright",
"author_id": 21926,
"author_profile": "https://Stackoverflow.com/users/21926",
"pm_score": 5,
"selected": false,
"text": "<p>You can put all of the commands you want into a <code>.gdbinit</code> file that lives in the same directory as the ... | 2009/02/01 | [
"https://Stackoverflow.com/questions/500967",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2745562/"
] | I have a list of breakpoints which I want to add each time I debug a particular program.
Is there a way I can put all of the breakpoint information in a file and use it at the start of each debug session? In other words can I **provide a script file with breakpoint information to GDB before I give the 'run' command?** | You can put all of the commands you want into a `.gdbinit` file that lives in the same directory as the executable you are debugging.
Something like:
```
b somefile.c:128
b otherfile.c:33
```
Should work just fine.
Yes, the `-x` command line argument will allow you to execute arbitrary files at GDB startup, but ma... |
500,995 | <p>I've been playing <a href="http://www.kongregate.com/games/asagoPAN/chain-of-fire" rel="nofollow noreferrer">this flash game</a> and after I'd gotten over the initial ('lol, fire') reaction I started to wonder how I could replicate this contact-mutate behaviour in programming. I guess it's a little like the <a href=... | [
{
"answer_id": 501024,
"author": "jheriko",
"author_id": 17604,
"author_profile": "https://Stackoverflow.com/users/17604",
"pm_score": 3,
"selected": true,
"text": "<p>I think you are on the right track with what you are thinking, some <a href=\"http://en.wikipedia.org/wiki/Particle_syst... | 2009/02/01 | [
"https://Stackoverflow.com/questions/500995",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2025/"
] | I've been playing [this flash game](http://www.kongregate.com/games/asagoPAN/chain-of-fire) and after I'd gotten over the initial ('lol, fire') reaction I started to wonder how I could replicate this contact-mutate behaviour in programming. I guess it's a little like the [honeypot xkcd](http://xkcd.com/350/).
I was th... | I think you are on the right track with what you are thinking, some [particles](http://en.wikipedia.org/wiki/Particle_system) in a box would do fine here. I can't imagine you would find papers on such a specific and simple case but perhaps for some of the techniques required, but an implementation of the backend should... |
501,008 | <p>I want to create an array/list of strings of the Comma seperated strings (file extensions) that are entered in a Textbox.</p>
<p>For the following block of code:</p>
<pre><code> Dim csv As String = Textbox1.Text + ","
While csv.IndexOf(".") <> -1
lstOfStrings.Add(csv.S... | [
{
"answer_id": 501015,
"author": "Darin Dimitrov",
"author_id": 29407,
"author_profile": "https://Stackoverflow.com/users/29407",
"pm_score": 4,
"selected": true,
"text": "<p>A better way would be to use the <a href=\"http://msdn.microsoft.com/en-us/library/system.string.split.aspx\" rel... | 2009/02/01 | [
"https://Stackoverflow.com/questions/501008",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/57175/"
] | I want to create an array/list of strings of the Comma seperated strings (file extensions) that are entered in a Textbox.
For the following block of code:
```
Dim csv As String = Textbox1.Text + ","
While csv.IndexOf(".") <> -1
lstOfStrings.Add(csv.Substring(0, csv.IndexOf(","... | A better way would be to use the [Split](http://msdn.microsoft.com/en-us/library/system.string.split.aspx) method:
```
Dim lstOfStrings() As String = Textbox1.Text.Split(","c)
``` |
501,013 | <p>I am designing a REST api that needs paging (per x) enforces from the server side.</p>
<p>What would be the right way to page through any collection of resources:</p>
<p>Option 1:</p>
<pre><code>GET /resource/page/<pagenr>
GET /resource/tags/<tag1>,<tag2>/page/<pagenr>
GET /resource/search... | [
{
"answer_id": 501025,
"author": "Allain Lalonde",
"author_id": 2443,
"author_profile": "https://Stackoverflow.com/users/2443",
"pm_score": 2,
"selected": false,
"text": "<p>With my limited understanding of what REST is about, then the following might be the \"most\" restful. </p>\n\n<p... | 2009/02/01 | [
"https://Stackoverflow.com/questions/501013",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/56495/"
] | I am designing a REST api that needs paging (per x) enforces from the server side.
What would be the right way to page through any collection of resources:
Option 1:
```
GET /resource/page/<pagenr>
GET /resource/tags/<tag1>,<tag2>/page/<pagenr>
GET /resource/search/<query>/page/<pagenr>
```
Option 2:
```
GET /res... | What the URI looks like is not the most important part. What you should be thinking about instead is how it is presented to the user. A page should for example have a link to the "next" page and another link to the "previous" page (if there is one). Take a look at [RFC 5005 Feed Paging and Archiving](https://www.rfc-ed... |
501,026 | <p>I want to check whether <code>Value1</code> below contains "abc" within the first X characters. How would you check this with an <code>if</code> statement?</p>
<pre><code>var Value1 = "ddabcgghh";
if (Value1.Contains("abc"))
{
found = true;
}
</code></pre>
<p>It could be within the first 3, 4 or 5 characters.... | [
{
"answer_id": 501029,
"author": "olle",
"author_id": 48383,
"author_profile": "https://Stackoverflow.com/users/48383",
"pm_score": 3,
"selected": false,
"text": "<pre><code>if (Value1.StartsWith(\"abc\")) { found = true; }\n</code></pre>\n"
},
{
"answer_id": 501030,
"author"... | 2009/02/01 | [
"https://Stackoverflow.com/questions/501026",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I want to check whether `Value1` below contains "abc" within the first X characters. How would you check this with an `if` statement?
```
var Value1 = "ddabcgghh";
if (Value1.Contains("abc"))
{
found = true;
}
```
It could be within the first 3, 4 or 5 characters. | Or if you need to set the value of found:
```
found = Value1.StartsWith("abc")
```
Edit: Given your edit, I would do something like:
```
found = Value1.Substring(0, 5).Contains("abc")
``` |
501,027 | <p>I get the feeling this is probably something I should know but I can't think of it right now. I'm trying to get a function to build a list where the name of the list is an argument given in the function;</p>
<p>e.g.</p>
<pre><code>def make_hand(deck, handname):
handname = []
for c in range(5):
hand... | [
{
"answer_id": 501041,
"author": "Kiv",
"author_id": 49559,
"author_profile": "https://Stackoverflow.com/users/49559",
"pm_score": 4,
"selected": true,
"text": "<p>You can keep a dictionary where the keys are the name of the hand and the values are the list. </p>\n\n<p>Then you can just ... | 2009/02/01 | [
"https://Stackoverflow.com/questions/501027",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33061/"
] | I get the feeling this is probably something I should know but I can't think of it right now. I'm trying to get a function to build a list where the name of the list is an argument given in the function;
e.g.
```
def make_hand(deck, handname):
handname = []
for c in range(5):
handname.append(deck.pop(... | You can keep a dictionary where the keys are the name of the hand and the values are the list.
Then you can just say dictionary[handname] to access a particular hand. Along the lines of:
```
hands = {} # Create a new dictionary to hold the hands.
hands["flush"] = make_hand(deck) # Generate some hands using your func... |
501,069 | <p>I am trying to figure out how to define a function that works on multiple types of parameters (e.g. int and int64). As I understand it, function overloading is not possible in F# (certainly the compiler complains). Take for example the following function.</p>
<pre><code>let sqrt_int = function
| n:int -> i... | [
{
"answer_id": 501116,
"author": "Mauricio Scheffer",
"author_id": 21239,
"author_profile": "https://Stackoverflow.com/users/21239",
"pm_score": 4,
"selected": false,
"text": "<p>Yes, this can be done. Take a look at <a href=\"http://cs.hubfs.net/forums/thread/5343.aspx\" rel=\"noreferre... | 2009/02/01 | [
"https://Stackoverflow.com/questions/501069",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44389/"
] | I am trying to figure out how to define a function that works on multiple types of parameters (e.g. int and int64). As I understand it, function overloading is not possible in F# (certainly the compiler complains). Take for example the following function.
```
let sqrt_int = function
| n:int -> int (sqrt (float n... | Overloading is typically the bugaboo of type-inferenced languages (at least when, like F#, the type system isn't powerful enough to contain type-classes). There are a number of choices you have in F#:
* Use overloading on methods (members of a type), in which case overloading works much like as in other .Net languages... |
501,079 | <p>Some applications, like Photoshop, allow users to drag a picture from a web browser, or drag a file from the filesystem, onto the application's icon in the dock. Doing this opens the file in that application.</p>
<p>How is this done? I'd like to use Cocoa and Objective-C, but I'm interested in any solutions in an... | [
{
"answer_id": 501416,
"author": "Peter Hosey",
"author_id": 30461,
"author_profile": "https://Stackoverflow.com/users/30461",
"pm_score": 3,
"selected": false,
"text": "<p>If your application is document-based and you filled out the necessary keys in your Info.plist correctly, then it J... | 2009/02/01 | [
"https://Stackoverflow.com/questions/501079",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1615/"
] | Some applications, like Photoshop, allow users to drag a picture from a web browser, or drag a file from the filesystem, onto the application's icon in the dock. Doing this opens the file in that application.
How is this done? I'd like to use Cocoa and Objective-C, but I'm interested in any solutions in any languages. | NSApplication allows you to set a delegate for your application. If the user drags a file onto your dock icon, NSApplication will call the method
```
- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename
```
of your delegate object, in case it implements any such method. In case the conte... |
501,090 | <p>How do I convert a decimal to an int?</p>
| [
{
"answer_id": 501091,
"author": "jason",
"author_id": 45914,
"author_profile": "https://Stackoverflow.com/users/45914",
"pm_score": 8,
"selected": false,
"text": "<p>Use <code>Convert.ToInt32</code> from <code>mscorlib</code> as in</p>\n\n<pre><code>decimal value = 3.14m;\nint n = Conve... | 2009/02/01 | [
"https://Stackoverflow.com/questions/501090",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | How do I convert a decimal to an int? | Use `Convert.ToInt32` from `mscorlib` as in
```
decimal value = 3.14m;
int n = Convert.ToInt32(value);
```
See [MSDN](http://msdn.microsoft.com/en-us/library/93kx4xke.aspx). You can also use `Decimal.ToInt32`. Again, see [MSDN](http://msdn.microsoft.com/en-us/library/system.decimal.toint32.aspx). Finally, you can do... |
501,105 | <p>I just translated this program,</p>
<pre><code>#include <stdio.h>
int dam[1000][1000];
int main (int argc, const char * argv[]) {
// insert code here...
printf("Hello, World!\n");
return 0;
}
</code></pre>
<p>to assembly using gcc producing,</p>
<pre><code> .cstring
LC0:
.ascii "Hello,... | [
{
"answer_id": 501138,
"author": "Eli Bendersky",
"author_id": 8206,
"author_profile": "https://Stackoverflow.com/users/8206",
"pm_score": 5,
"selected": true,
"text": "<p>From the <code>as</code> manual:</p>\n\n<blockquote>\n <p>..comm declares a common symbol named\n symbol. When lin... | 2009/02/01 | [
"https://Stackoverflow.com/questions/501105",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51164/"
] | I just translated this program,
```
#include <stdio.h>
int dam[1000][1000];
int main (int argc, const char * argv[]) {
// insert code here...
printf("Hello, World!\n");
return 0;
}
```
to assembly using gcc producing,
```
.cstring
LC0:
.ascii "Hello, World!\0"
.text
.globl _main
_main:
... | From the `as` manual:
>
> ..comm declares a common symbol named
> symbol. When linking, a common symbol
> in one object file may be merged with
> a defined or common symbol of the same
> name in another object file. If ld
> does not see a definition for the
> symbol--just one or more common
> symbols--then it ... |
501,122 | <p>In Microsoft Sql it is possible to encrypted stored procedures with </p>
<pre><code>CREATE PROCEDURE dbo.foo
WITH ENCRYPTION
AS
BEGIN
SELECT 'foo'
END
</code></pre>
<p>This stops people looking at stored procedures code.</p>
<p>How can I do this in <strong>MySql</strong> 5.0.x ?</p>
| [
{
"answer_id": 501143,
"author": "Espo",
"author_id": 2257,
"author_profile": "https://Stackoverflow.com/users/2257",
"pm_score": 3,
"selected": true,
"text": "<p>You can not do this in MySQL. See bug #<a href=\"http://bugs.mysql.com/bug.php?id=4210\" rel=\"nofollow noreferrer\">4210</a>... | 2009/02/01 | [
"https://Stackoverflow.com/questions/501122",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17560/"
] | In Microsoft Sql it is possible to encrypted stored procedures with
```
CREATE PROCEDURE dbo.foo
WITH ENCRYPTION
AS
BEGIN
SELECT 'foo'
END
```
This stops people looking at stored procedures code.
How can I do this in **MySql** 5.0.x ? | You can not do this in MySQL. See bug #[4210](http://bugs.mysql.com/bug.php?id=4210).
[Edit]: The comment from [Leonidas](https://stackoverflow.com/users/57510/leonidas) on [another answer](https://stackoverflow.com/questions/501122/can-stored-procedure-in-mysql-5-0-x-be-encrypted/501145#501145) to this question needs... |
501,163 | <pre><code>template<class Y>
operator auto_ptr_ref<Y>() throw() {
return auto_ptr_ref<Y>(release());
}
</code></pre>
<p>It is part of implementation of class auto_ptr in standard library.</p>
<p>What does this means to do?</p>
<p>Why there is an "auto_ptr_ref" between "operator" and "()"?</p>... | [
{
"answer_id": 501182,
"author": "user7116",
"author_id": 7116,
"author_profile": "https://Stackoverflow.com/users/7116",
"pm_score": 3,
"selected": true,
"text": "<p>That is the conversion operator in action, casting from auto_ptr to auto_ptr_ref<Y>.</p>\n"
},
{
"answer_id... | 2009/02/01 | [
"https://Stackoverflow.com/questions/501163",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/52913/"
] | ```
template<class Y>
operator auto_ptr_ref<Y>() throw() {
return auto_ptr_ref<Y>(release());
}
```
It is part of implementation of class auto\_ptr in standard library.
What does this means to do?
Why there is an "auto\_ptr\_ref" between "operator" and "()"? | That is the conversion operator in action, casting from auto\_ptr to auto\_ptr\_ref<Y>. |
501,171 | <p>I'm trying to parse an Atom feed programmatically. I have the atom XML downloaded as a string. I can load the XML into an <code>XmlDocument</code>. However, I can't traverse the document using XPath. Whenever I try, I get <code>null</code>.</p>
<p>I've been using this Atom feed as a test: <a href="http://steve-yegg... | [
{
"answer_id": 501192,
"author": "kdgregory",
"author_id": 42126,
"author_profile": "https://Stackoverflow.com/users/42126",
"pm_score": 4,
"selected": true,
"text": "<p>While the C# implementation may allow default namespaces (I don't know), the XPath 1.0 spec doesn't. So, give \"Atom\"... | 2009/02/01 | [
"https://Stackoverflow.com/questions/501171",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/392/"
] | I'm trying to parse an Atom feed programmatically. I have the atom XML downloaded as a string. I can load the XML into an `XmlDocument`. However, I can't traverse the document using XPath. Whenever I try, I get `null`.
I've been using this Atom feed as a test: <http://steve-yegge.blogspot.com/feeds/posts/default>
Ca... | While the C# implementation may allow default namespaces (I don't know), the XPath 1.0 spec doesn't. So, give "Atom" its own prefix:
```
nsMngr.AddNamespace("atom", "http://www.w3.org/2005/Atom");
```
And change your XPath appropriately:
```
XmlNode node = atom.SelectSingleNode("//atom:entry/atom:link/app:edited", ... |
501,187 | <pre><code>import os
xp1 = "\Documents and Settings\"
xp2 = os.getenv("USERNAME")
print xp1+xp2
</code></pre>
<p>Gives me error</p>
<pre><code> File "1.py", line 2
xp1 = "\Documents and Settings\"
^
SyntaxError: EOL while scannning single-quoted string
</code></pre>
<p>Can you help me... | [
{
"answer_id": 501197,
"author": "gimel",
"author_id": 6491,
"author_profile": "https://Stackoverflow.com/users/6491",
"pm_score": 5,
"selected": false,
"text": "<p>The backslash character is interpreted as an escape. Use double backslashes for windows paths:</p>\n\n<pre><code>>>&g... | 2009/02/01 | [
"https://Stackoverflow.com/questions/501187",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | ```
import os
xp1 = "\Documents and Settings\"
xp2 = os.getenv("USERNAME")
print xp1+xp2
```
Gives me error
```
File "1.py", line 2
xp1 = "\Documents and Settings\"
^
SyntaxError: EOL while scannning single-quoted string
```
Can you help me please, do you see the problem? | The backslash character is interpreted as an escape. Use double backslashes for windows paths:
```
>>> xp1 = "\\Documents and Settings\\"
>>> xp1
'\\Documents and Settings\\'
>>> print xp1
\Documents and Settings\
>>>
``` |
501,194 | <p>What would be the best way to look in a <code>string[]</code> to see if it contains a element. This was my first shot at it. But perhaps there is something that I am overlooking. The array size will be no larger than 200 elements.</p>
<pre><code>bool isStringInArray(string[] strArray, string key)
{
for (int i =... | [
{
"answer_id": 501203,
"author": "Dave Markle",
"author_id": 24995,
"author_profile": "https://Stackoverflow.com/users/24995",
"pm_score": 9,
"selected": true,
"text": "<p>Just use the already built-in Contains() method:</p>\n\n<pre><code>using System.Linq;\n\n//...\n\nstring[] array = {... | 2009/02/01 | [
"https://Stackoverflow.com/questions/501194",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/54009/"
] | What would be the best way to look in a `string[]` to see if it contains a element. This was my first shot at it. But perhaps there is something that I am overlooking. The array size will be no larger than 200 elements.
```
bool isStringInArray(string[] strArray, string key)
{
for (int i = 0; i <= strArray.Length ... | Just use the already built-in Contains() method:
```
using System.Linq;
//...
string[] array = { "foo", "bar" };
if (array.Contains("foo")) {
//...
}
``` |
501,205 | <p>I have a highly trafficked application on one debian machine and apache has started acting strange. </p>
<p>Every time I start apache, tons of apache processes are spawned, the app doesn't load at all, and very quickly the whole machine freezes and must be powercycled to reboot.</p>
<p>Here is what I get for top i... | [
{
"answer_id": 501266,
"author": "kdgregory",
"author_id": 42126,
"author_profile": "https://Stackoverflow.com/users/42126",
"pm_score": 4,
"selected": false,
"text": "<p>Have you changed your configuration file recently? If yes, I trust you keep the old version for diffing?</p>\n\n<p>If... | 2009/02/01 | [
"https://Stackoverflow.com/questions/501205",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/61232/"
] | I have a highly trafficked application on one debian machine and apache has started acting strange.
Every time I start apache, tons of apache processes are spawned, the app doesn't load at all, and very quickly the whole machine freezes and must be powercycled to reboot.
Here is what I get for top immediately after ... | You have probably made the error of configuring Apache to use far more than all of your ram. This is an easy mistake to make.
I am assuming you are using a Prefork Apache, and an in-process application server (such as PHP or mod\_perl). In this model, you will end up with a maximum of (MaxClients \* max memory usage o... |
501,227 | <p>I have a drop down menu and it works perfectly on everything except IE6 & IE7.</p>
<ul>
<li><a href="http://img140.imageshack.us/img140/1171/picture2ow4.png" rel="nofollow noreferrer">Here it is in the Safari/Firefox browsers</a></li>
<li><a href="http://img175.imageshack.us/img175/3897/picture1gc5.png" rel="no... | [
{
"answer_id": 501236,
"author": "gkrogers",
"author_id": 54501,
"author_profile": "https://Stackoverflow.com/users/54501",
"pm_score": 4,
"selected": true,
"text": "<p>Have you tried setting the <a href=\"http://www.w3schools.com/Css/pr_pos_z-index.asp\" rel=\"nofollow noreferrer\">z-in... | 2009/02/01 | [
"https://Stackoverflow.com/questions/501227",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26130/"
] | I have a drop down menu and it works perfectly on everything except IE6 & IE7.
* [Here it is in the Safari/Firefox browsers](http://img140.imageshack.us/img140/1171/picture2ow4.png)
* [Here is how it looks in IE6 & IE7](http://img175.imageshack.us/img175/3897/picture1gc5.png)
Here is the CSS for the div where it hide... | Have you tried setting the [z-index](http://www.w3schools.com/Css/pr_pos_z-index.asp) of the picture that's currently obscuring your menu to, say, 0? Have you got a "live" test URL we can look at? Alternatively, on the basis that IE is treating z-index incorrectly, have you got the leeway to position your drop-down men... |
501,231 | <p>I have a cocoa class set up that I want to use to connect to a RESTful web service I'm building. I have decided to use HTTP Basic Authentication on my PHP backend like so…</p>
<pre><code><?php
if (!isset($_SERVER['PHP_AUTH_USER'])) {
header('WWW-Authenticate: Basic realm="My Realm"');
header('HTTP/1.0 40... | [
{
"answer_id": 501869,
"author": "Mike Abdullah",
"author_id": 28768,
"author_profile": "https://Stackoverflow.com/users/28768",
"pm_score": 7,
"selected": true,
"text": "<p>A synchronous <code>NSURLConnection</code> will absolutely work with <code>NSURLCredentialStorage</code>. Here's h... | 2009/02/01 | [
"https://Stackoverflow.com/questions/501231",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42523/"
] | I have a cocoa class set up that I want to use to connect to a RESTful web service I'm building. I have decided to use HTTP Basic Authentication on my PHP backend like so…
```
<?php
if (!isset($_SERVER['PHP_AUTH_USER'])) {
header('WWW-Authenticate: Basic realm="My Realm"');
header('HTTP/1.0 401 Unauthorized');... | A synchronous `NSURLConnection` will absolutely work with `NSURLCredentialStorage`. Here's how things usually work:
1. `NSURLConnection` requests the page from the server
2. The server replies with a 401 response
3. `NSURLConnection` looks to see what credentials it can glean from the URL
4. If the URL did **not** pro... |
501,232 | <p>I'm writing a Ruby script and would like to use a n-ary tree data structure.</p>
<p>Is there a good implementation that is available as source code? Thanks.</p>
| [
{
"answer_id": 501425,
"author": "Otto",
"author_id": 9594,
"author_profile": "https://Stackoverflow.com/users/9594",
"pm_score": 3,
"selected": false,
"text": "<p>A Hash whose attributes are all Arrays?</p>\n"
},
{
"answer_id": 501612,
"author": "rampion",
"author_id": 9... | 2009/02/01 | [
"https://Stackoverflow.com/questions/501232",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/61239/"
] | I'm writing a Ruby script and would like to use a n-ary tree data structure.
Is there a good implementation that is available as source code? Thanks. | To expand on Otto's answer, an easy way of getting a Hash to auto-vivify arrays is to use the default value block with `Hash::new`, like so:
```
node_children = Hash.new { |_node_children, node_key| _node_children[node_key] = [] }
```
But really, the code depends on what you want to do with your arrays. You can eith... |
501,253 | <p>Is there a way to iterate over a Time range in Ruby, and set the delta?</p>
<p>Here is an idea of what I would like to do:</p>
<pre><code>for hour in (start_time..end_time, hour)
hour #=> Time object set to hour
end
</code></pre>
<p>You can iterate over the Time objects, but it returns every second between... | [
{
"answer_id": 501291,
"author": "Zach Langley",
"author_id": 45230,
"author_profile": "https://Stackoverflow.com/users/45230",
"pm_score": 7,
"selected": true,
"text": "<p>Prior to 1.9, you could use <code>Range#step</code>:</p>\n\n<pre><code>(start_time..end_time).step(3600) do |hour|\... | 2009/02/01 | [
"https://Stackoverflow.com/questions/501253",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12322/"
] | Is there a way to iterate over a Time range in Ruby, and set the delta?
Here is an idea of what I would like to do:
```
for hour in (start_time..end_time, hour)
hour #=> Time object set to hour
end
```
You can iterate over the Time objects, but it returns every second between the two. What I really need is a wa... | Prior to 1.9, you could use `Range#step`:
```
(start_time..end_time).step(3600) do |hour|
# ...
end
```
However, this strategy is quite slow since it would call `Time#succ` 3600 times. Instead,
as pointed out by dolzenko in [his answer](https://stackoverflow.com/a/1340731/525478), a more efficient solution is to u... |
501,277 | <p>According to the <a href="http://docs.oracle.com/javase/specs/" rel="noreferrer">Java Language Sepecification</a>, 3rd edition:</p>
<blockquote>
<p><a href="http://docs.oracle.com/javase/specs/jls/se6/html/classes.html#303584" rel="noreferrer">It is a compile-time error if a generic class is a direct or indirect ... | [
{
"answer_id": 501284,
"author": "IAdapter",
"author_id": 30453,
"author_profile": "https://Stackoverflow.com/users/30453",
"pm_score": 4,
"selected": false,
"text": "<p>Here is a simple example of how to use the exception:</p>\n\n<pre><code>class IntegerExceptionTest {\n public static ... | 2009/02/01 | [
"https://Stackoverflow.com/questions/501277",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41283/"
] | According to the [Java Language Sepecification](http://docs.oracle.com/javase/specs/), 3rd edition:
>
> [It is a compile-time error if a generic class is a direct or indirect subclass of `Throwable`.](http://docs.oracle.com/javase/specs/jls/se6/html/classes.html#303584)
>
>
>
I wish to understand why this decisio... | As mark said, the types are not reifiable, which is a problem in the following case:
```
try {
doSomeStuff();
} catch (SomeException<Integer> e) {
// ignore that
} catch (SomeException<String> e) {
crashAndBurn()
}
```
Both `SomeException<Integer>` and `SomeException<String>` are erased to the same type, th... |
501,290 | <p>Liu Chang asked a very similar question to this one here, <a href="https://stackoverflow.com/questions/264395/linux-equivalent-of-the-mac-os-x-open-command">Linux equivalent of the Mac OS X "open" command</a>.</p>
<p>Is there a windows equivalent for the Mac OS X "open" command. I'm trying to run a profi... | [
{
"answer_id": 501295,
"author": "Charles Duffy",
"author_id": 14122,
"author_profile": "https://Stackoverflow.com/users/14122",
"pm_score": 7,
"selected": true,
"text": "<p>The closest thing available is <code>start</code>.</p>\n\n<hr>\n\n<p>If its first argument is double-quoted, that ... | 2009/02/01 | [
"https://Stackoverflow.com/questions/501290",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4767/"
] | Liu Chang asked a very similar question to this one here, [Linux equivalent of the Mac OS X "open" command](https://stackoverflow.com/questions/264395/linux-equivalent-of-the-mac-os-x-open-command).
Is there a windows equivalent for the Mac OS X "open" command. I'm trying to run a profiler that will open it's results,... | The closest thing available is `start`.
---
If its first argument is double-quoted, that argument is treated as a window title rather than a filename. Thus, to use it robustly, add an empty string as the first argument:
```
start "" "my filename.foo"
```
[Thank you to @Holger for pointing this out!](https://stacko... |
501,304 | <p>I'm considering using CouchDB for an upcoming site, but I'm a little confused as far as far as how to implement a system of user ratings for the site. Basically, each item of content can be rated by a given user. What way of doing this makes the most sense in the CouchDB model? I would think the DRYest and most logi... | [
{
"answer_id": 501427,
"author": "Joe Soul-bringer",
"author_id": 56279,
"author_profile": "https://Stackoverflow.com/users/56279",
"pm_score": 1,
"selected": false,
"text": "<p>Well <a href=\"http://damienkatz.net/\" rel=\"nofollow noreferrer\">Damien Katz</a>, one of the Couchdb develo... | 2009/02/01 | [
"https://Stackoverflow.com/questions/501304",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11105/"
] | I'm considering using CouchDB for an upcoming site, but I'm a little confused as far as far as how to implement a system of user ratings for the site. Basically, each item of content can be rated by a given user. What way of doing this makes the most sense in the CouchDB model? I would think the DRYest and most logical... | Sounds like you've got a reasonable idea going. CouchDB is so new that I think it'll take awhile for best practices to shake out.
A map/reduce pair like this might form a reasonable starting point.
map:
```
function(doc) {
if(doc.type='rating' && doc.content_id) {
emit(doc.content_id, doc.rating);
}
}
``... |
501,308 | <p>What does the last line mean in the following code?</p>
<pre><code>import pickle, urllib
handle = urllib.urlopen("http://www.pythonchallenge.com/pc/def/banner.p")
... | [
{
"answer_id": 501318,
"author": "Nikhil",
"author_id": 853,
"author_profile": "https://Stackoverflow.com/users/853",
"pm_score": 2,
"selected": false,
"text": "<p><code>[e[1] * e[0] for e in elt]</code> is a list comprehension, which evaluates to a list itself by looping through another... | 2009/02/01 | [
"https://Stackoverflow.com/questions/501308",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/54964/"
] | What does the last line mean in the following code?
```
import pickle, urllib
handle = urllib.urlopen("http://www.pythonchallenge.com/pc/def/banner.p")
data = pickle... | Maybe best explained with an example:
```
print "".join([e[1] * e[0] for e in elt])
```
is the short form of
```
x = []
for e in elt:
x.append(e[1] * e[0])
print "".join(x)
```
List comprehensions are simply syntactic sugar for `for` loops, which make an expression out of a sequence of statements.
`elt` can be... |
501,325 | <p>I've got a simple java class that looks something like this:<br></p>
<pre><code>public class Skin implements Serializable {
public String scoreFontName = "TahomaBold";
...
public int scoreFontHeight = 20;
...
public int blockSize = 16;
...
public int[] nextBlockX = {205, 205, 2... | [
{
"answer_id": 501339,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 4,
"selected": true,
"text": "<p>XStream is really great library for just this.</p>\n\n<p><a href=\"http://x-stream.github.io/\" rel=\"nofollow noreferrer\">... | 2009/02/01 | [
"https://Stackoverflow.com/questions/501325",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/61248/"
] | I've got a simple java class that looks something like this:
```
public class Skin implements Serializable {
public String scoreFontName = "TahomaBold";
...
public int scoreFontHeight = 20;
...
public int blockSize = 16;
...
public int[] nextBlockX = {205, 205, 205, 205};
... | XStream is really great library for just this.
<http://x-stream.github.io/>
You can set up aliases for your class and even custom data formats to make the XML file more readable. |
501,332 | <p>My Macbook was stuck yesterday, when I tried to paste 1200 lines of 80 characters to Vim. It was much faster to download the file, and not to paste the text.</p>
<p>I have thought that this problem might be the reason, why internet operators allow slower uploading than downloading.</p>
| [
{
"answer_id": 501341,
"author": "ʞɔıu",
"author_id": 41613,
"author_profile": "https://Stackoverflow.com/users/41613",
"pm_score": 2,
"selected": false,
"text": "<p>did you try paste mode? set paste / set nopaste?</p>\n"
},
{
"answer_id": 501349,
"author": "Brian Rasmussen",... | 2009/02/01 | [
"https://Stackoverflow.com/questions/501332",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/54964/"
] | My Macbook was stuck yesterday, when I tried to paste 1200 lines of 80 characters to Vim. It was much faster to download the file, and not to paste the text.
I have thought that this problem might be the reason, why internet operators allow slower uploading than downloading. | If you paste it into a terminal window, Vim thinks you're typing it out by hand, and it will try and update the display as you go. You can access your clipboard (on OS X) using the `pbpaste` and `pbcopy` commands, so you can just do this in Vim:
```
:read !pbpaste
```
or in a shell:
```
bash$ pbpaste | vim -
```
... |
501,347 | <p>A common (i assume?) type of query:</p>
<p>I have two tables ('products', 'productsales'). Each record in 'productsales' represents a sale (so it has 'date', 'quantity', 'product_id'). How do i efficiently make a query like the following:</p>
<p>Retrieve the product names of all products that were sold more than X... | [
{
"answer_id": 501359,
"author": "AnthonyWJones",
"author_id": 17516,
"author_profile": "https://Stackoverflow.com/users/17516",
"pm_score": 2,
"selected": true,
"text": "<pre><code> SELECT p.[name]\n FROM products p\n WHERE p.product_id in (SELECT s.product_id\n FROM productsales s\... | 2009/02/01 | [
"https://Stackoverflow.com/questions/501347",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | A common (i assume?) type of query:
I have two tables ('products', 'productsales'). Each record in 'productsales' represents a sale (so it has 'date', 'quantity', 'product\_id'). How do i efficiently make a query like the following:
Retrieve the product names of all products that were sold more than X times between d... | ```
SELECT p.[name]
FROM products p
WHERE p.product_id in (SELECT s.product_id
FROM productsales s
WHERE s.[date] between @dateStart and @dateEnd
GROUP BY s.product_id
HAVING Sum(s.quantity) > @X )
``` |
501,348 | <p>I'm still pretty new to JSON and GWT and I'm trying to figure out how to pass JSON data back from a page into my GWT app. I pass the JSON back to a class:</p>
<pre><code>public class GetProductTree extends JavaScriptObject {
protected GetProductTree() { }
public final native String getCustomerName() /*-{... | [
{
"answer_id": 501560,
"author": "rustyshelf",
"author_id": 6044,
"author_profile": "https://Stackoverflow.com/users/6044",
"pm_score": 3,
"selected": true,
"text": "<p>This error is from the compiler, complaining that it can't find that type in it's classpath. For the GWT compiler to fi... | 2009/02/01 | [
"https://Stackoverflow.com/questions/501348",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16631/"
] | I'm still pretty new to JSON and GWT and I'm trying to figure out how to pass JSON data back from a page into my GWT app. I pass the JSON back to a class:
```
public class GetProductTree extends JavaScriptObject {
protected GetProductTree() { }
public final native String getCustomerName() /*-{ return this.cu... | This error is from the compiler, complaining that it can't find that type in it's classpath. For the GWT compiler to find your classes they have to be and in your classpath, and they have to be referenced in a .gwt.xml module file as well. Can you post your package names and the contents of your .gwt.xml files? My gues... |
501,363 | <p>Thanks for reading this.</p>
<p>I would have thought it would be as simple as using the .split function on the select .val(), but I get a js error. This is the code I am using. I will use .each() to loop through the selected items...but would like to understand what I am doing wrong...</p>
<p>If I set opts with a ... | [
{
"answer_id": 501382,
"author": "Christian C. Salvadó",
"author_id": 5445,
"author_profile": "https://Stackoverflow.com/users/5445",
"pm_score": 4,
"selected": true,
"text": "<p>The val() function when there are more than one option selected returns you already an array, you don't need ... | 2009/02/01 | [
"https://Stackoverflow.com/questions/501363",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2755/"
] | Thanks for reading this.
I would have thought it would be as simple as using the .split function on the select .val(), but I get a js error. This is the code I am using. I will use .each() to loop through the selected items...but would like to understand what I am doing wrong...
If I set opts with a literal..the spli... | The val() function when there are more than one option selected returns you already an array, you don't need to do the split.
```
$("#oneOpt").bind("click", function() {
var opts = $("#select1").val();
$("#text2").val("1st opt: " + opts[0]);
});
``` |
501,367 | <p>Using the tcsh shell on Free BSD, is there a way to recursively list all files and directories including the owner, group and relative path to the file?</p>
<p>ls -alR comes close, but it does not show the relative path in front of every file, it shows the path at the top of a grouping i.e.</p>
<pre><code>owner% l... | [
{
"answer_id": 501381,
"author": "James Brady",
"author_id": 29903,
"author_profile": "https://Stackoverflow.com/users/29903",
"pm_score": 6,
"selected": true,
"text": "<p>How about this:</p>\n\n<pre><code>find . -exec ls -dl \\{\\} \\; | awk '{print $3, $4, $9}'\n</code></pre>\n"
},
... | 2009/02/01 | [
"https://Stackoverflow.com/questions/501367",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/52130/"
] | Using the tcsh shell on Free BSD, is there a way to recursively list all files and directories including the owner, group and relative path to the file?
ls -alR comes close, but it does not show the relative path in front of every file, it shows the path at the top of a grouping i.e.
```
owner% ls -alR
total 0
drwxr-... | How about this:
```
find . -exec ls -dl \{\} \; | awk '{print $3, $4, $9}'
``` |
501,373 | <p>Have a class with couple of integers and a pointer , </p>
<pre><code> class A {
int a;
int b;
char* s;
public:
...
class ConstructA {
A &a;
public:
ConstructA (A& ta) : a(ta) {}
...
};
};
</code></pre>
<p>As seen ConstructA is... | [
{
"answer_id": 501399,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 3,
"selected": false,
"text": "<p>Since there is no way for a constructor to fail in C++, an object either:</p>\n\n<ul>\n<li>does not exist</li>\n<li>is... | 2009/02/01 | [
"https://Stackoverflow.com/questions/501373",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43756/"
] | Have a class with couple of integers and a pointer ,
```
class A {
int a;
int b;
char* s;
public:
...
class ConstructA {
A &a;
public:
ConstructA (A& ta) : a(ta) {}
...
};
};
```
As seen ConstructA is responsible for constructing obje... | Since there is no way for a constructor to fail in C++, an object either:
* does not exist
* is successfully constructed.
If a constructor throws an exception, the object effectively does not exist at the point the exception is caught.
You may want to implement an additional method such as `isOK()` that returns whet... |
501,375 | <p>As far as I can tell, it is not possible to place a CSS background image 1em from the right border of any block, neither is it possible to place a image 1em from the bottom.</p>
<p>The following code places the background image 1em from the left and 2em from the top.</p>
<pre><code><div class="foo" style="backg... | [
{
"answer_id": 501449,
"author": "Luca Matteis",
"author_id": 50394,
"author_profile": "https://Stackoverflow.com/users/50394",
"pm_score": 0,
"selected": false,
"text": "<p>After some research the actual x pixel length of the background position is <strong>always</strong> counted from t... | 2009/02/01 | [
"https://Stackoverflow.com/questions/501375",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1606/"
] | As far as I can tell, it is not possible to place a CSS background image 1em from the right border of any block, neither is it possible to place a image 1em from the bottom.
The following code places the background image 1em from the left and 2em from the top.
```
<div class="foo" style="background: url('bar.png') no... | The [CSS3 background-position spec](http://www.w3.org/TR/css3-background/#background-position) allows you to change the anchor point from the top left to anything you want. For example, the following will set the lower bottom corner of the image 1em from the right and 2px from the bottom:
```
background-position: righ... |
501,378 | <p>This question is related to <a href="https://stackoverflow.com/questions/501213/how-can-i-have-my-abstract-at-the-titlepage-in-latex">the post</a> about having abstract at the titlepage.
I want to reset the page numbering at the given section.</p>
| [
{
"answer_id": 501394,
"author": "Torsten Marek",
"author_id": 9567,
"author_profile": "https://Stackoverflow.com/users/9567",
"pm_score": 6,
"selected": false,
"text": "<p>I use</p>\n\n<pre><code>\\pagenumbering{roman}\n</code></pre>\n\n<p>for everything in the frontmatter and then swit... | 2009/02/01 | [
"https://Stackoverflow.com/questions/501378",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/54964/"
] | This question is related to [the post](https://stackoverflow.com/questions/501213/how-can-i-have-my-abstract-at-the-titlepage-in-latex) about having abstract at the titlepage.
I want to reset the page numbering at the given section. | You can also reset page number counter:
```
\setcounter{page}{1}
```
However, with this technique you get wrong page numbers in Acrobat in the top left page numbers field:
```
\maketitle: 1
\tableofcontents: 2
\setcounter{page}{1}
\section{Introduction}: 1
...
``` |
501,407 | <p>I'm merging in a remote branch that may have a lot of conflicts. How can I tell if it will have conflicts or not?</p>
<p>I don't see anything like a <code>--dry-run</code> on <code>git-merge</code>. </p>
| [
{
"answer_id": 501461,
"author": "mipadi",
"author_id": 28804,
"author_profile": "https://Stackoverflow.com/users/28804",
"pm_score": 11,
"selected": true,
"text": "<p>As noted previously, pass in the <code>--no-commit</code> flag, but to avoid a fast-forward commit, also pass in <code>-... | 2009/02/01 | [
"https://Stackoverflow.com/questions/501407",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9594/"
] | I'm merging in a remote branch that may have a lot of conflicts. How can I tell if it will have conflicts or not?
I don't see anything like a `--dry-run` on `git-merge`. | As noted previously, pass in the `--no-commit` flag, but to avoid a fast-forward commit, also pass in `--no-ff`, like so:
```
$ git merge --no-commit --no-ff $BRANCH
```
To examine the staged changes:
```
$ git diff --cached
```
And you can undo the merge, even if it is a fast-forward merge:
```
$ git merge --ab... |
501,409 | <p>I want to use the jQuery accordion tool for a form i'm building so I used some sample code from the jquery website but it doesn't work at all! </p>
<p>The javascript does nothing at all so you just get the html rendered. I am using version 1.3.1 of jquery with version 1.6rc6 of jquery-ui.</p>
<pre><code><head r... | [
{
"answer_id": 501418,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>are you sure the js reference is correct and loaded?\nhave you tried using firebug's js debugger in order to step into the ... | 2009/02/01 | [
"https://Stackoverflow.com/questions/501409",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40623/"
] | I want to use the jQuery accordion tool for a form i'm building so I used some sample code from the jquery website but it doesn't work at all!
The javascript does nothing at all so you just get the html rendered. I am using version 1.3.1 of jquery with version 1.6rc6 of jquery-ui.
```
<head runat="server">
<scri... | The accordion function is all lowercase, you have also one missing parenthesis and one curly brace:
```
$(document).ready(
function() {
$('#accordion').accordion(
{
header: "h3"
});
}
);
```
See your script running [here](http://jsbin.com/e... |
501,412 | <p>I noticed today that auto-boxing can sometimes cause ambiguity in method overload resolution. The simplest example appears to be this:</p>
<pre><code>public class Test {
static void f(Object a, boolean b) {}
static void f(Object a, Object b) {}
static void m(int a, boolean b) { f(a,b); }
}
</code></pre... | [
{
"answer_id": 501438,
"author": "Kevin",
"author_id": 26620,
"author_profile": "https://Stackoverflow.com/users/26620",
"pm_score": 2,
"selected": false,
"text": "<blockquote>\n <p>So why did the overload resolution\n fail? Why didn't the compiler auto-box\n the first argument, and a... | 2009/02/01 | [
"https://Stackoverflow.com/questions/501412",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41283/"
] | I noticed today that auto-boxing can sometimes cause ambiguity in method overload resolution. The simplest example appears to be this:
```
public class Test {
static void f(Object a, boolean b) {}
static void f(Object a, Object b) {}
static void m(int a, boolean b) { f(a,b); }
}
```
When compiled, it ca... | When you cast the first argument to Object yourself, the compiler will match the method without using autoboxing (JLS3 15.12.2):
>
> The first phase (§15.12.2.2) performs
> overload resolution without permitting
> boxing or unboxing conversion, or the
> use of variable arity method
> invocation. If no applicable ... |
501,431 | <p>I am working on a Moodle project and I have downloaded and installed the latest build(1.9) on my system. I'm using this framework for the very first time so presently trying to get familiar with the environment and the documentation.</p>
<p>My need is to embed an iCal kinda calendar on Moodle's front page using the... | [
{
"answer_id": 501438,
"author": "Kevin",
"author_id": 26620,
"author_profile": "https://Stackoverflow.com/users/26620",
"pm_score": 2,
"selected": false,
"text": "<blockquote>\n <p>So why did the overload resolution\n fail? Why didn't the compiler auto-box\n the first argument, and a... | 2009/02/01 | [
"https://Stackoverflow.com/questions/501431",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/61255/"
] | I am working on a Moodle project and I have downloaded and installed the latest build(1.9) on my system. I'm using this framework for the very first time so presently trying to get familiar with the environment and the documentation.
My need is to embed an iCal kinda calendar on Moodle's front page using the PHP iCale... | When you cast the first argument to Object yourself, the compiler will match the method without using autoboxing (JLS3 15.12.2):
>
> The first phase (§15.12.2.2) performs
> overload resolution without permitting
> boxing or unboxing conversion, or the
> use of variable arity method
> invocation. If no applicable ... |
501,435 | <p>I have to replace the content of this xml string through java</p>
<pre><code><My:tag>value_1 22&#xA;value_2 54&#xA;value_3 11</My:tag>
</code></pre>
<p>so, this string has been taken from an xml and when I acquire it I have this result:</p>
<pre><code><My:tag>value_1 22
value_2 54
value_... | [
{
"answer_id": 501443,
"author": "Fabian Steeg",
"author_id": 18154,
"author_profile": "https://Stackoverflow.com/users/18154",
"pm_score": 0,
"selected": false,
"text": "<p>I'd suggest using an XML library like <a href=\"http://www.jdom.org/\" rel=\"nofollow noreferrer\">JDOM</a> or <a ... | 2009/02/01 | [
"https://Stackoverflow.com/questions/501435",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39339/"
] | I have to replace the content of this xml string through java
```
<My:tag>value_1 22
value_2 54
value_3 11</My:tag>
```
so, this string has been taken from an xml and when I acquire it I have this result:
```
<My:tag>value_1 22
value_2 54
value_3 11</My:tag>
```
If I try to replace the content by this way... | I'm not 100% sure how the java regex-engine works, but I can't possibly imagine that an entity would cause your problems. You should first try to simply remove your brackets, since you're replacing the entire expression, and not extracting anything.
What might be causing it though is if your entity is actually transla... |
501,460 | <p>How can I format a date as <code>dd/mm/yyyy</code> or <code>mm/dd/yy</code> ? </p>
<p>Like in VB <code>format("dd/mm/yy",now)</code></p>
<p>How can I do this in C#?</p>
| [
{
"answer_id": 501466,
"author": "M4N",
"author_id": 19635,
"author_profile": "https://Stackoverflow.com/users/19635",
"pm_score": 6,
"selected": false,
"text": "<p>It's almost the same, simply use the <code>DateTime.ToString()</code> method, e.g:</p>\n\n<pre><code>DateTime.Now.ToString(... | 2009/02/01 | [
"https://Stackoverflow.com/questions/501460",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43907/"
] | How can I format a date as `dd/mm/yyyy` or `mm/dd/yy` ?
Like in VB `format("dd/mm/yy",now)`
How can I do this in C#? | It's almost the same, simply use the `DateTime.ToString()` method, e.g:
```
DateTime.Now.ToString("dd/MM/yy");
```
Or:
```
DateTime dt = GetDate(); // GetDate() returns some date
dt.ToString("dd/MM/yy");
```
In addition, you might want to consider using one of the predefined date/time formats, e.g:
```
DateTime.... |
501,463 | <p>I want a way to be able to schedule callbacks, I want to be able register lots of different callbacks at various times to a "Scheduler"-object. Something like this.</p>
<pre><code>public class Foo
{
public void Bar()
{
Scheduler s = new Scheduler();
s.Schedule(() => Debug.WriteLine("Hello... | [
{
"answer_id": 501475,
"author": "mmx",
"author_id": 33708,
"author_profile": "https://Stackoverflow.com/users/33708",
"pm_score": 3,
"selected": true,
"text": "<p>This is a good approach. You should dynamically set the timer to go off as soon as the next event is going to occur. You do ... | 2009/02/01 | [
"https://Stackoverflow.com/questions/501463",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46187/"
] | I want a way to be able to schedule callbacks, I want to be able register lots of different callbacks at various times to a "Scheduler"-object. Something like this.
```
public class Foo
{
public void Bar()
{
Scheduler s = new Scheduler();
s.Schedule(() => Debug.WriteLine("Hello in an hour!"), D... | This is a good approach. You should dynamically set the timer to go off as soon as the next event is going to occur. You do this by putting jobs in a priority queue. After all, in any case you are **always limited to the resolution** the system can provide, but you should code so that it be the **only** limiting factor... |
501,486 | <p>OK, <em><a href="https://sourceware.org/gdb/onlinedocs/gdb/Set-Breaks.html" rel="noreferrer">info break</a></em> lists the breakpoints, but not in a format that would work well with reusing them using the --command <a href="https://stackoverflow.com/questions/500967/gdb-breakpoints">as in this question</a>. Does GDB... | [
{
"answer_id": 501500,
"author": "Paul Beckingham",
"author_id": 14356,
"author_profile": "https://Stackoverflow.com/users/14356",
"pm_score": 4,
"selected": false,
"text": "<p>Put your GDB commands and breakpoints in a <a href=\"https://sourceware.org/gdb/onlinedocs/gdb/gdbinit-man.html... | 2009/02/01 | [
"https://Stackoverflow.com/questions/501486",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10578/"
] | OK, *[info break](https://sourceware.org/gdb/onlinedocs/gdb/Set-Breaks.html)* lists the breakpoints, but not in a format that would work well with reusing them using the --command [as in this question](https://stackoverflow.com/questions/500967/gdb-breakpoints). Does GDB have a method for dumping them into a file accep... | As of GDB 7.2 (2011-08-23) you can now use the *[save breakpoints](https://sourceware.org/gdb/onlinedocs/gdb/Save-Breakpoints.html)* command.
```
save breakpoints <filename>
Save all current breakpoint definitions to a file suitable for use
in a later debugging session. To read the saved breakpoint
definitions,... |
501,505 | <p>Is it a good practice to bootstrap your PHP application.
I found two ways to bootstrap my PHP application. Need some suggestions which is a better way.</p>
<p><strong>First.</strong><br>
Define a constant for the folder structures</p>
<pre><code>$controllerPath = 'controller';
define('CONTROLLER', str_replace('\\'... | [
{
"answer_id": 501515,
"author": "Richard Levasseur",
"author_id": 36805,
"author_profile": "https://Stackoverflow.com/users/36805",
"pm_score": 3,
"selected": true,
"text": "<p>Use ini_set to set it to the directory -above- your application. That why you can use the literal strings in... | 2009/02/01 | [
"https://Stackoverflow.com/questions/501505",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/241755/"
] | Is it a good practice to bootstrap your PHP application.
I found two ways to bootstrap my PHP application. Need some suggestions which is a better way.
**First.**
Define a constant for the folder structures
```
$controllerPath = 'controller';
define('CONTROLLER', str_replace('\\', '/', realpath($controllerPath)).'... | Use ini\_set to set it to the directory -above- your application. That why you can use the literal strings in your require statements. In addition, it makes it easier to use reuse code
```
require 'coolapp/class/Model.php'
require 'coolapp/display/Router.php'
require 'spinoff/display/JsView.php'
// etc
```
Its simil... |
501,507 | <p>I'm trying to figure out how to map a component as a primary key in nhibernate and if possible in fluent nhibernate as well. </p>
<p>The component in question is a unique set of 3d coordinates, here's the object:</p>
<pre><code>public class SpaceLocation
{
public virtual SpaceCoordinate Coordinates { get; set;... | [
{
"answer_id": 501515,
"author": "Richard Levasseur",
"author_id": 36805,
"author_profile": "https://Stackoverflow.com/users/36805",
"pm_score": 3,
"selected": true,
"text": "<p>Use ini_set to set it to the directory -above- your application. That why you can use the literal strings in... | 2009/02/01 | [
"https://Stackoverflow.com/questions/501507",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25847/"
] | I'm trying to figure out how to map a component as a primary key in nhibernate and if possible in fluent nhibernate as well.
The component in question is a unique set of 3d coordinates, here's the object:
```
public class SpaceLocation
{
public virtual SpaceCoordinate Coordinates { get; set; }
public virtual... | Use ini\_set to set it to the directory -above- your application. That why you can use the literal strings in your require statements. In addition, it makes it easier to use reuse code
```
require 'coolapp/class/Model.php'
require 'coolapp/display/Router.php'
require 'spinoff/display/JsView.php'
// etc
```
Its simil... |
501,511 | <p>I am playing around with a little seam app that has session scope. The last method is sending as mail. How can I invalidate my session after having the mail sent? Right now, when the user calls the initial url again, the session still lives and all of the previously filled in form data is still there.</p>
<p>I have... | [
{
"answer_id": 501618,
"author": "IAdapter",
"author_id": 30453,
"author_profile": "https://Stackoverflow.com/users/30453",
"pm_score": 1,
"selected": false,
"text": "<p>Session.instance().invalidate();</p>\n"
},
{
"answer_id": 578286,
"author": "Simon Gibbs",
"author_id"... | 2009/02/01 | [
"https://Stackoverflow.com/questions/501511",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am playing around with a little seam app that has session scope. The last method is sending as mail. How can I invalidate my session after having the mail sent? Right now, when the user calls the initial url again, the session still lives and all of the previously filled in form data is still there.
I have found exa... | Per [ISASI's answer](https://stackoverflow.com/questions/501511/how-to-invalidate-seam-pojo-session/501618#501618) you can use this code to invalidate the session:
```
Session.instance().invalidate();
```
In answer to your follow up "question" (which you added as an answer, bizarrely). To close the session after inf... |
501,513 | <p>Given the following code,the hover function works correctly, but when clicked, loses the <code>clicked_no_event_box</code> class. Not sure where I'm going wrong...</p>
<pre><code>/* On document.ready.. */ $(function(){
$(".no_event_box").hover(
function(){$(this).addClass("clicked_no_event_box"... | [
{
"answer_id": 501519,
"author": "SilentGhost",
"author_id": 12855,
"author_profile": "https://Stackoverflow.com/users/12855",
"pm_score": 3,
"selected": true,
"text": "<p>it works exactly as you told it to. if you want to have class to stick you can add an alias to that class name in cs... | 2009/02/01 | [
"https://Stackoverflow.com/questions/501513",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/55619/"
] | Given the following code,the hover function works correctly, but when clicked, loses the `clicked_no_event_box` class. Not sure where I'm going wrong...
```
/* On document.ready.. */ $(function(){
$(".no_event_box").hover(
function(){$(this).addClass("clicked_no_event_box");},
functio... | it works exactly as you told it to. if you want to have class to stick you can add an alias to that class name in css.
```
.clicked_no_event_box, .new_name_to_be_used_in_click_function {
/* definition */
}
``` |
501,585 | <p>I waste a lot of time between Vim and Python. I find it too slow to manually copy-paste from Python to Vim and vice versa. A good broken example is:</p>
<blockquote>
<p>%!python for i in xrange(25); print 6*i \n </p>
</blockquote>
<p>How can you do such tweaks direcly in Vim? <strong>[Solved]</strong></p>
... | [
{
"answer_id": 501606,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 3,
"selected": false,
"text": "<p>From your example, it appears as though you want to execute a Python script and have the output of the script appear i... | 2009/02/01 | [
"https://Stackoverflow.com/questions/501585",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/54964/"
] | I waste a lot of time between Vim and Python. I find it too slow to manually copy-paste from Python to Vim and vice versa. A good broken example is:
>
> %!python for i in xrange(25); print 6\*i \n
>
>
>
How can you do such tweaks direcly in Vim? **[Solved]**
**[Clarification]** I need things to Vim, like printi... | In any of your vim windows, type something like this:
```
for x in range(1,10):
print '-> %d' % x
```
Visually select both of those lines (V to start visual mode), and type the following:
```
:!python
```
Because you pressed ':' in visual mode, that will end up looking like:
```
:'<,'>!python
```
Hit enter... |
501,588 | <p>I'm trying to make a method that returns a string of words in opposite order.</p>
<p>IE/ "The rain in Spain falls mostly on the"
would return: "the on mostly falls Spain in rain The"</p>
<p>For this I am not supposed to use any built in Java classes just basic Java.</p>
<p>So far I have:</p>
<pre><code> l... | [
{
"answer_id": 501593,
"author": "Dave Ray",
"author_id": 40310,
"author_profile": "https://Stackoverflow.com/users/40310",
"pm_score": 4,
"selected": true,
"text": "<p>In Java, Strings are immutable, i.e. they can't be changed. concat() returns a new string with the concatenation. So yo... | 2009/02/01 | [
"https://Stackoverflow.com/questions/501588",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/61276/"
] | I'm trying to make a method that returns a string of words in opposite order.
IE/ "The rain in Spain falls mostly on the"
would return: "the on mostly falls Spain in rain The"
For this I am not supposed to use any built in Java classes just basic Java.
So far I have:
```
lastSpace = stringIn.length();
fo... | In Java, Strings are immutable, i.e. they can't be changed. concat() returns a new string with the concatenation. So you want something like this:
```
stringOut = stringOut.concat(word);
```
or
```
stringOut += word
```
as Ray notes, there are more succinct ways to do this though. |
501,597 | <p>Currently I'm using the auto-tools to build/install and package a project of mine, but I would really like to move to something that feels more "pythonic".</p>
<p>My project consists of two scripts, one module, two glade GUI descriptions, and two .desktop files. It's currently a pure python project, though that's ... | [
{
"answer_id": 501624,
"author": "Torsten Marek",
"author_id": 9567,
"author_profile": "https://Stackoverflow.com/users/9567",
"pm_score": 1,
"selected": false,
"text": "<p>In general, yes - everything is better than autotools when building Python projects.</p>\n\n<p>I have good experien... | 2009/02/01 | [
"https://Stackoverflow.com/questions/501597",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34996/"
] | Currently I'm using the auto-tools to build/install and package a project of mine, but I would really like to move to something that feels more "pythonic".
My project consists of two scripts, one module, two glade GUI descriptions, and two .desktop files. It's currently a pure python project, though that's likely to c... | **I managed to get this to work, but it kinda feels to me more like a *workaround*.**
Don't know what's the preferred way to handle this...
I used the following `setup.py` file (full version is [here](https://gist.github.com/brutus/e4bdb1d2c1705558b2ff)):
```
from setuptools import setup
setup(
# ...
data_file... |
501,609 | <p>I try to manipulate file in sub directory in my project root directory.</p>
<p>I have folder with name "Basic Usage HTML" and i try this code:</p>
<pre><code>[NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"index" ofType:@"html" inDirectory:@"Basic Usage HTML" ]isDirecto... | [
{
"answer_id": 503142,
"author": "rpetrich",
"author_id": 4007,
"author_profile": "https://Stackoverflow.com/users/4007",
"pm_score": 2,
"selected": false,
"text": "<p>Most likely Xcode's build process isn't including the \"Basic Usage HTML\" subfolder in your build.</p>\n\n<p>Also, you ... | 2009/02/01 | [
"https://Stackoverflow.com/questions/501609",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32034/"
] | I try to manipulate file in sub directory in my project root directory.
I have folder with name "Basic Usage HTML" and i try this code:
```
[NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"index" ofType:@"html" inDirectory:@"Basic Usage HTML" ]isDirectory:YES] ]
```
And i... | Most likely Xcode's build process isn't including the "Basic Usage HTML" subfolder in your build.
Also, you may want to split each statement out and `NSLog` them to see where it's failing. |
501,626 | <p>I have been using Emacs to write Python 2 code. Now I have both Python 2.6 and 3.0 installed on my system, and I need to write Python 3 code as well.</p>
<p>Here is how the different versions are set up in /usr/bin:</p>
<pre><code>python -> python2.6*
python2 -> python2.6*
python2.6*
python3 -> python3.0... | [
{
"answer_id": 502304,
"author": "jrockway",
"author_id": 8457,
"author_profile": "https://Stackoverflow.com/users/8457",
"pm_score": 2,
"selected": false,
"text": "<p>The answer is yes. If you can distinguish Python 2 from Python 3, then it is a Simple Matter Of Programming to get emac... | 2009/02/01 | [
"https://Stackoverflow.com/questions/501626",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have been using Emacs to write Python 2 code. Now I have both Python 2.6 and 3.0 installed on my system, and I need to write Python 3 code as well.
Here is how the different versions are set up in /usr/bin:
```
python -> python2.6*
python2 -> python2.6*
python2.6*
python3 -> python3.0*
python3.0*
```
Is there an... | If you are using python-mode.el you can try to change `py-which-shell`. In order to do this on a per-file basis you can put
```
# -*- py-which-shell: "python3"; -*-
```
at the first line of your file - or at the second line if the first line starts with `#!`.
Another choice is to put
```
# Local Variables:
# py-whi... |
501,648 | <p>Whenever I create a new Java file in Eclipse and check off the option to add <code>public static void main(String args[])</code>, this code is generated:</p>
<pre><code>public class Test {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
... | [
{
"answer_id": 501659,
"author": "Fortyrunner",
"author_id": 16828,
"author_profile": "https://Stackoverflow.com/users/16828",
"pm_score": -1,
"selected": false,
"text": "<p>Eclipse has a <strong>lot</strong> of configuration options. Take a look in the Windows | Preferences dialog (or t... | 2009/02/01 | [
"https://Stackoverflow.com/questions/501648",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49153/"
] | Whenever I create a new Java file in Eclipse and check off the option to add `public static void main(String args[])`, this code is generated:
```
public class Test {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
}
}
```
How do i:
*... | The indention is a formatting issue while the comments is a template issue.
The templates are in **Window -> Preferences -> Java -> Code Style -> Code Templates**. Browse all of them and look for the things you would like to change.
The Formatter is a little bit more complicated. You find it under **Window -> Prefere... |
501,656 | <p>I noticed the following comment in my copy of Expert F# on page 379:</p>
<blockquote>
<p><strong>Passing and Processing Messages</strong></p>
<p>A distinction is often made between
<em>shared-memory concurrency</em> and <em>message
passing concurrency</em>. The former is
often more efficient on local m... | [
{
"answer_id": 502120,
"author": "Logan Capaldo",
"author_id": 61289,
"author_profile": "https://Stackoverflow.com/users/61289",
"pm_score": 3,
"selected": false,
"text": "<p>I think you've been a little confused by terminology. Erlang processes do not necessarily correspond directly to ... | 2009/02/01 | [
"https://Stackoverflow.com/questions/501656",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40516/"
] | I noticed the following comment in my copy of Expert F# on page 379:
>
> **Passing and Processing Messages**
>
>
> A distinction is often made between
> *shared-memory concurrency* and *message
> passing concurrency*. The former is
> often more efficient on local machines
> and is covered in the section "Using
... | I think you've been a little confused by terminology. Erlang processes do not necessarily correspond directly to OS processes. A given OS process can have multiple Erlang processes (and usually does), much like your process has multiple threads. If you want to communicate between multiple OS processes, you may want to ... |
501,671 | <p>How can I get superscript done, only in CSS?</p>
<p>I have a stylesheet where I mark the external links with a superscript character, but I'm having a hard time getting the character aligned correctly.</p>
<p>What I have currently, looks like this:</p>
<pre><code>a.external:after {
font-size: 50%;
vertical-al... | [
{
"answer_id": 501689,
"author": "cletus",
"author_id": 18393,
"author_profile": "https://Stackoverflow.com/users/18393",
"pm_score": 8,
"selected": false,
"text": "<p>Honestly I don't see the point in doing superscript/subscript in CSS only. There's no handy CSS attribute for it, just ... | 2009/02/01 | [
"https://Stackoverflow.com/questions/501671",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2238/"
] | How can I get superscript done, only in CSS?
I have a stylesheet where I mark the external links with a superscript character, but I'm having a hard time getting the character aligned correctly.
What I have currently, looks like this:
```
a.external:after {
font-size: 50%;
vertical-align: top;
content: "+";
}
... | You can do superscript with [**`vertical-align: super`**](https://developer.mozilla.org/en-US/docs/CSS/vertical-align), (plus an accompanying [`font-size`](https://developer.mozilla.org/en-US/docs/CSS/font-size) reduction).
However, be sure to **read the other answers** here, particularly those by [paulmurray](https:/... |
501,692 | <p>I'd like to set up commit emails on a project I'm work on, as described here:<br>
<a href="http://producingoss.com/en/vc.html#commit-emails" rel="noreferrer">http://producingoss.com/en/vc.html#commit-emails</a></p>
<p>That is, use a post commit hook to send an email to a list containing the commit title/log and d... | [
{
"answer_id": 501701,
"author": "Sean Bright",
"author_id": 21926,
"author_profile": "https://Stackoverflow.com/users/21926",
"pm_score": 3,
"selected": false,
"text": "<p>We use <a href=\"http://opensource.perlig.de/svnmailer/\" rel=\"noreferrer\">svnmailer</a> for this. We symlink ou... | 2009/02/01 | [
"https://Stackoverflow.com/questions/501692",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4161/"
] | I'd like to set up commit emails on a project I'm work on, as described here:
<http://producingoss.com/en/vc.html#commit-emails>
That is, use a post commit hook to send an email to a list containing the commit title/log and diff of the changes.
What's the easiest way on a Linux machine to set this up? | When creating new repository a sample post-commit hook is provided in `hooks/post-commit.tmpl`. It contains a line that looks more or less like this:
```
/usr/share/subversion/hook-scripts/commit-email.pl "$REPOS" "$REV" commit-watchers@example.org
```
Just substitute the email with the address you want to send noti... |
501,699 | <p>I have a iPhone program that has a UIImage. This UIImage needs to be transferred to a javascript Image object in a UIWebView. I was thinking this could be done by using a data url I send to the UIWebView like this:</p>
<pre><code>[wview stringByEvaluatingJavaScriptFromString:@"loadimage('%d')",dataurlfromuiimage];
... | [
{
"answer_id": 501808,
"author": "François P.",
"author_id": 54380,
"author_profile": "https://Stackoverflow.com/users/54380",
"pm_score": 0,
"selected": false,
"text": "<p>Unfortunately, you'll need to convert your UIImage to the a file representation of your image, not the decoded pixe... | 2009/02/01 | [
"https://Stackoverflow.com/questions/501699",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/764272/"
] | I have a iPhone program that has a UIImage. This UIImage needs to be transferred to a javascript Image object in a UIWebView. I was thinking this could be done by using a data url I send to the UIWebView like this:
```
[wview stringByEvaluatingJavaScriptFromString:@"loadimage('%d')",dataurlfromuiimage];
```
So, I ne... | To get an NSData representation of your image in the PNG format, use
```
NSData *dataForPNGFile = UIImagePNGRepresentation(yourImage);
```
Likewise, a JPEG representation can be obtained using
```
NSData *dataForJPEGFile = UIImageJPEGRepresentation(yourImage, 0.9f);
```
Once you have the NSData, you could write i... |
501,708 | <p>I'm building a site using ASP.NET MVC with lots of jQuery and AJAX stuff, and I'd like the main menu to work with AJAX as more or less the rest of the site does.</p>
<p>In an ideal scenario, I would like my main menu to
1) load the main content with AJAX if the user has activated javascript
2) change the url in th... | [
{
"answer_id": 501738,
"author": "Isaac Waller",
"author_id": 764272,
"author_profile": "https://Stackoverflow.com/users/764272",
"pm_score": 0,
"selected": false,
"text": "<p><strong>For #2:</strong> You can add a #hash to the end of the url: example in your menu:</p>\n\n<pre><code><... | 2009/02/01 | [
"https://Stackoverflow.com/questions/501708",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38055/"
] | I'm building a site using ASP.NET MVC with lots of jQuery and AJAX stuff, and I'd like the main menu to work with AJAX as more or less the rest of the site does.
In an ideal scenario, I would like my main menu to
1) load the main content with AJAX if the user has activated javascript
2) change the url in the address ... | Though I agree with some of the other comments about not loading content via AJAX for the sake of it, #2 in your list is a common problem that often crops up when dealing with AJAX and is worth answering.
The **only** way to change the URL without the browser reloading is by adding a `#` to the end . Example:
```
htt... |
501,719 | <p>I want to dynamically add new forms to a Django formset, so that when the user clicks an "add" button it runs JavaScript that adds a new form (which is part of the formset) to the page.</p>
| [
{
"answer_id": 501930,
"author": "Daniel Naab",
"author_id": 32638,
"author_profile": "https://Stackoverflow.com/users/32638",
"pm_score": 2,
"selected": false,
"text": "<p>One option would be to create a formset with every possible form, but initially set the unrequired forms to hidden ... | 2009/02/01 | [
"https://Stackoverflow.com/questions/501719",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/61295/"
] | I want to dynamically add new forms to a Django formset, so that when the user clicks an "add" button it runs JavaScript that adds a new form (which is part of the formset) to the page. | This is how I do it, using [jQuery](http://www.jquery.com):
My template:
```
<h3>My Services</h3>
{{ serviceFormset.management_form }}
{% for form in serviceFormset.forms %}
<div class='table'>
<table class='no_error'>
{{ form.as_table }}
</table>
</div>
{% endfor %}
<input type="button" value... |
501,723 | <p>I have two pdf or postscript files (I can work with either one). What I want to do is merge each page on top of the other so that page1 of document A will be combined with page 1 of document B to produce page 1 of the output document. This isn't something I necessarily want need to do programatically, although tha... | [
{
"answer_id": 508711,
"author": "pi.",
"author_id": 15274,
"author_profile": "https://Stackoverflow.com/users/15274",
"pm_score": 5,
"selected": false,
"text": "<p>I had success solving this problem (PDF only and Python) by using <a href=\"http://pybrary.net/pyPdf/\" rel=\"noreferrer\">... | 2009/02/01 | [
"https://Stackoverflow.com/questions/501723",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9648/"
] | I have two pdf or postscript files (I can work with either one). What I want to do is merge each page on top of the other so that page1 of document A will be combined with page 1 of document B to produce page 1 of the output document. This isn't something I necessarily want need to do programatically, although that wou... | You can do this with pdf files using the command line tool [pdftk](http://www.pdfhacks.com/pdftk/) using the `stamp` or `background` option.
e.g.
```
$ pdftk file1.pdf background file2.pdf output combinedfile.pdf
```
This will only work with a one-page background file. If you have multiple pages, you can use the [`... |
501,731 | <p>I'm trying to get a grip on the OCaml language syntax and am having some trouble with applying some OOP structures. My goal with the below code is to have a class bar that inherits from a virtual class foo. The virtual class contains three virtual methods that I hope to take an instance of a "player" object as a par... | [
{
"answer_id": 501747,
"author": "Brian",
"author_id": 19299,
"author_profile": "https://Stackoverflow.com/users/19299",
"pm_score": 3,
"selected": true,
"text": "<p>(I don't know OCaml, but I do know F#, and they are similar, so hopefully I am guessing right.)</p>\n\n<p>Try changing </p... | 2009/02/01 | [
"https://Stackoverflow.com/questions/501731",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25985/"
] | I'm trying to get a grip on the OCaml language syntax and am having some trouble with applying some OOP structures. My goal with the below code is to have a class bar that inherits from a virtual class foo. The virtual class contains three virtual methods that I hope to take an instance of a "player" object as a parame... | (I don't know OCaml, but I do know F#, and they are similar, so hopefully I am guessing right.)
Try changing
```
method virtual doThis : player
method virtual doThat : player
method virtual notifyAll : player array
```
to
```
method virtual doThis : player -> unit
method virtual doThat : player -> unit
method v... |
501,737 | <p>Now i ran into some stupid situation. I want the users to be able to use textile, but they shouldn't mess around with my valid HTML around their entry. So I have to escape the HTML somehow.</p>
<ul>
<li><p><code>html_escape(textilize("</body>Foo"))</code> would break textile while</p></li>
<li><p><code>textil... | [
{
"answer_id": 501835,
"author": "sleske",
"author_id": 43681,
"author_profile": "https://Stackoverflow.com/users/43681",
"pm_score": 0,
"selected": false,
"text": "<p>Looks like textile simply doesn't support what you want.</p>\n\n<p>You really want to only allow a carefully controlled ... | 2009/02/01 | [
"https://Stackoverflow.com/questions/501737",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28401/"
] | Now i ran into some stupid situation. I want the users to be able to use textile, but they shouldn't mess around with my valid HTML around their entry. So I have to escape the HTML somehow.
* `html_escape(textilize("</body>Foo"))` would break textile while
* `textilize(html_escape("</body>Foo"))` would work, but break... | For those who run into the same problem: If you are using the **RedCloth gem** you can just define your own method (in one of your helpers).
```
def safe_textilize( s )
if s && s.respond_to?(:to_s)
doc = RedCloth.new( s.to_s )
doc.filter_html = true
doc.to_html
end
end
```
Excerpt from the Documenta... |
501,774 | <p>I have a template class, C_Foo<T>, which is specialised in a number of ways.</p>
<pre><code>struct Bar_Base { ... };
struct Bar_1 : public Bar_Base { ... };
struct Bar_2 : public Bar_Base { ... };
struct Bar_3 : public Bar_Base { ... };
class C_Foo<T> { ... };
class C_Foo_1 : public C_Foo<Bar_1>... | [
{
"answer_id": 501783,
"author": "strager",
"author_id": 39992,
"author_profile": "https://Stackoverflow.com/users/39992",
"pm_score": 2,
"selected": false,
"text": "<p>The problem is that <code>C_Foo</code> cannot be instantiated because it requires template parameters.</p>\n\n<p>You ca... | 2009/02/01 | [
"https://Stackoverflow.com/questions/501774",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13500/"
] | I have a template class, C\_Foo<T>, which is specialised in a number of ways.
```
struct Bar_Base { ... };
struct Bar_1 : public Bar_Base { ... };
struct Bar_2 : public Bar_Base { ... };
struct Bar_3 : public Bar_Base { ... };
class C_Foo<T> { ... };
class C_Foo_1 : public C_Foo<Bar_1> { ... };
class C_Foo_2 : publi... | You can do that, if the function does not depend on the template parameter:
```
// note: not a template
class C_Foo_Common {
public:
virtual void do_stuff() = 0;
};
template<typename T>
class C_Foo : public C_Foo_Common {
virtual void do_stuff() {
// do stuff...
}
};
vector<C_Foo_Common *> v;
v... |
501,813 | <p>Inside a form for adding a category I am rendering a control that contains a second form for adding a subcategory. The category form's action is category/add while the inner form's action is ../addSubcategory. My problem is that when submitting the inner form, my Add action is called.</p>
<p>So, my question is this... | [
{
"answer_id": 501838,
"author": "Tomas Aschan",
"author_id": 38055,
"author_profile": "https://Stackoverflow.com/users/38055",
"pm_score": 1,
"selected": false,
"text": "<p>in case you're using AJAX to post, you could write your own js methods that fire on the click of the submit button... | 2009/02/01 | [
"https://Stackoverflow.com/questions/501813",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Inside a form for adding a category I am rendering a control that contains a second form for adding a subcategory. The category form's action is category/add while the inner form's action is ../addSubcategory. My problem is that when submitting the inner form, my Add action is called.
So, my question is this: how can ... | in case you're using AJAX to post, you could write your own js methods that fire on the click of the submit button, calling the correct action methods.
in case you're not using AJAX, i would recommend separating the two forms in your markup, and then aligning the subcategory form inside the category form with css. use... |
501,816 | <p>I'm using C++ to understand how exactly pointers work. I have this piece of code using arrays, which I'm using just to understand how the equivalent works with pointers.</p>
<pre><code>int main() {
int arr[10] = {1,2,3};
char arr2[10] = {'c','i','a','o','\0'};
cout << arr << endl;
... | [
{
"answer_id": 501820,
"author": "Darron",
"author_id": 22704,
"author_profile": "https://Stackoverflow.com/users/22704",
"pm_score": 1,
"selected": false,
"text": "<p>There is a standard overload for char* that outputs a NUL terminated string.</p>\n"
},
{
"answer_id": 501821,
... | 2009/02/01 | [
"https://Stackoverflow.com/questions/501816",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/50394/"
] | I'm using C++ to understand how exactly pointers work. I have this piece of code using arrays, which I'm using just to understand how the equivalent works with pointers.
```
int main() {
int arr[10] = {1,2,3};
char arr2[10] = {'c','i','a','o','\0'};
cout << arr << endl;
cout << arr2 << endl;
}
... | It's the operator<< that is overloaded for `const void*` and for `const char*`. Your char array is converted to `const char*` and passed to that overload, because it fits better than to `const void*`. The int array, however, is converted to `const void*` and passed to that version. The version of operator<< taking `con... |
501,849 | <p>Given an array:</p>
<pre><code>array1 = [1 2 3];
</code></pre>
<p>I have to reverse it like so:</p>
<pre><code>array1MirrorImage = [3 2 1];
</code></pre>
<p>So far I obtained this ugly solution:</p>
<pre><code>array1MirrorImage = padarray(array1, [0 length(array1)], 'symmetric', 'pre');
array1MirrorImage = arra... | [
{
"answer_id": 501883,
"author": "Tomas Aschan",
"author_id": 38055,
"author_profile": "https://Stackoverflow.com/users/38055",
"pm_score": 4,
"selected": false,
"text": "<p>you can use</p>\n\n<pre><code>rowreverse = fliplr(row) % for a row vector (or each row of a 2D array)\ncolreve... | 2009/02/01 | [
"https://Stackoverflow.com/questions/501849",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48465/"
] | Given an array:
```
array1 = [1 2 3];
```
I have to reverse it like so:
```
array1MirrorImage = [3 2 1];
```
So far I obtained this ugly solution:
```
array1MirrorImage = padarray(array1, [0 length(array1)], 'symmetric', 'pre');
array1MirrorImage = array1MirrorImage(1:length(array1));
```
Is there a prettier s... | **UPDATE:** In newer versions of MATLAB (R2013b and after) it is preferred to use the function [`flip`](http://www.mathworks.com/help/matlab/ref/flip.html) instead of [`flipdim`](http://www.mathworks.com/help/matlab/ref/flipdim.html), which has the same calling syntax:
```
a = flip(a, 1); % Reverses elements in each ... |
501,853 | <pre><code>public interface IProcessor<T>
{
void Process(T instance);
}
foreach(AbstractType instance in myClass.SomeCollection)
OnProcess(instance);
public void OnProcess<T>(T instance)
{
IProcessor<T> processor =
unityContainer.Resolve<IProcessor<T>>();
processor.Process(... | [
{
"answer_id": 501866,
"author": "Andy",
"author_id": 45062,
"author_profile": "https://Stackoverflow.com/users/45062",
"pm_score": 0,
"selected": false,
"text": "<p>If I understand your problem, you want to call a process that's dependent on 2 types (the type of processor, and the objec... | 2009/02/01 | [
"https://Stackoverflow.com/questions/501853",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/61311/"
] | ```
public interface IProcessor<T>
{
void Process(T instance);
}
foreach(AbstractType instance in myClass.SomeCollection)
OnProcess(instance);
public void OnProcess<T>(T instance)
{
IProcessor<T> processor =
unityContainer.Resolve<IProcessor<T>>();
processor.Process(instance);
}
```
The problem with th... | 2 will be a performance killer (the necessary dynamic/relection **invoke** in particular is slow)
1 is a common answer to this problem, especially with explicit implementation; the problem is getting hold of the type... does unity allow query with a `Type` instance, rather than via generics? If so something like below... |
501,857 | <p>I'm looking for interesting PostSharp aspects - anything that you found useful and wouldn't mind sharing.</p>
| [
{
"answer_id": 502032,
"author": "Ric Tokyo",
"author_id": 42019,
"author_profile": "https://Stackoverflow.com/users/42019",
"pm_score": 2,
"selected": false,
"text": "<p>The coolest aspect of it for me is that it can help me implement the <a href=\"http://en.wikipedia.org/wiki/Single_re... | 2009/02/01 | [
"https://Stackoverflow.com/questions/501857",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9476/"
] | I'm looking for interesting PostSharp aspects - anything that you found useful and wouldn't mind sharing. | The coolest aspect of it for me is that it can help me implement the [single responsibility principle](http://en.wikipedia.org/wiki/Single_responsibility_principle):
*"In object-oriented programming, the single responsibility principle states that every object should have a single responsibility, and that all its serv... |
501,872 | <p>I'm having trouble with lists in OCaml. I've read conflicting statements saying whether or not the lists can be modified at runtime. Can the cons operator be used at runtime?</p>
<p>Additionally, why is a doberman (see below) allowed to be in a list of chihuahuas? How would one go about adding another chihuahua ont... | [
{
"answer_id": 501896,
"author": "OJ.",
"author_id": 611,
"author_profile": "https://Stackoverflow.com/users/611",
"pm_score": 2,
"selected": false,
"text": "<p>you need to have your list on the right hand side, not the left. Ie:</p>\n\n<pre><code>c3 :: arrayOfDogs;;\n</code></pre>\n\n<p... | 2009/02/02 | [
"https://Stackoverflow.com/questions/501872",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25985/"
] | I'm having trouble with lists in OCaml. I've read conflicting statements saying whether or not the lists can be modified at runtime. Can the cons operator be used at runtime?
Additionally, why is a doberman (see below) allowed to be in a list of chihuahuas? How would one go about adding another chihuahua onto the list... | 1) You can use the cons operator at runtime, it just returns a new list rather than mutating the input list.
2) Class types in OCaml use "structural" subtyping, rather than Java-style "nominal" subtyping. The inferred type of `arrayOfDogs` will be "an object with a method named `bark` of type `unit -> unit` (not neces... |
501,886 | <p>I'm trying to learn WPF and the MVVM problem, but have hit a snag.
This question is similar but not quite the same <a href="https://stackoverflow.com/questions/454868/handling-dialogs-in-wpf-with-mvvm">as this one (handling-dialogs-in-wpf-with-mvvm)</a>...</p>
<p>I have a "Login" form written using the MVV... | [
{
"answer_id": 501907,
"author": "Orion Edwards",
"author_id": 234,
"author_profile": "https://Stackoverflow.com/users/234",
"pm_score": 2,
"selected": false,
"text": "<p>Here's what I initially did, which does work, however it seems rather long-winded and ugly (global static anything is... | 2009/02/02 | [
"https://Stackoverflow.com/questions/501886",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/234/"
] | I'm trying to learn WPF and the MVVM problem, but have hit a snag.
This question is similar but not quite the same [as this one (handling-dialogs-in-wpf-with-mvvm)](https://stackoverflow.com/questions/454868/handling-dialogs-in-wpf-with-mvvm)...
I have a "Login" form written using the MVVM pattern.
This form has a Vi... | I was inspired by [Thejuan's answer](https://stackoverflow.com/questions/501886/wpf-mvvm-newbie-how-should-the-viewmodel-close-the-form/1153602#1153602) to write a simpler attached property. No styles, no triggers; instead, you can just do this:
```
<Window ...
xmlns:xc="clr-namespace:ExCastle.Wpf"
xc:... |
501,891 | <p>I want to use GNU screen in such a way that the user doesn't know it's there. It's to help ensure that a text based management application that I'm writing can only be used by a single user at a time. To guard against against users locking everyone else out by running the application and going, leaving it running wh... | [
{
"answer_id": 501938,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 3,
"selected": true,
"text": "<p>It looks like the following in <code>.screenrc</code> does the trick:</p>\n\n<pre><code>escape ''\n</code></pre>\n\n<p>... | 2009/02/02 | [
"https://Stackoverflow.com/questions/501891",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/61318/"
] | I want to use GNU screen in such a way that the user doesn't know it's there. It's to help ensure that a text based management application that I'm writing can only be used by a single user at a time. To guard against against users locking everyone else out by running the application and going, leaving it running when ... | It looks like the following in `.screenrc` does the trick:
```
escape ''
```
This does not set the escape character to `'`, but disables the escape mechanism entirely. |
501,899 | <p>Let's say I have two classes like the following:</p>
<pre><code>Class A
{
public:
..
private:
int length;
}
Class B: public Class A
{
public:
..
private:
float length;
}
</code></pre>
<p>What I would like to know is:</p>
<ol>
<li>Is <em>overriding of base class data members</em> allowed?</li>
<li>If yes, is i... | [
{
"answer_id": 501908,
"author": "Vinay",
"author_id": 28641,
"author_profile": "https://Stackoverflow.com/users/28641",
"pm_score": 4,
"selected": true,
"text": "<p>You can use templatized members i.e., generic members instead of overriding the members.</p>\n\n<p>You can also declare a ... | 2009/02/02 | [
"https://Stackoverflow.com/questions/501899",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/61315/"
] | Let's say I have two classes like the following:
```
Class A
{
public:
..
private:
int length;
}
Class B: public Class A
{
public:
..
private:
float length;
}
```
What I would like to know is:
1. Is *overriding of base class data members* allowed?
2. If yes, is it a good practice?
3. If no, what is the best way... | You can use templatized members i.e., generic members instead of overriding the members.
You can also declare a VARIANT(COM) like union.
```
struct MyData
{
int vt; // To store the type
union
{
LONG lVal;
BYTE bVal;
... |
501,906 | <p>Let's say I have two strings: a and b. To compare whether a and be have the same values when case is ignored, I've always used:</p>
<pre><code>// (Assume a and b have been verified not to be null)
if (a.ToLower() == b.ToLower())
</code></pre>
<p>However, using Reflector, I've seen this a few times in the .NET Fra... | [
{
"answer_id": 501914,
"author": "John T",
"author_id": 36457,
"author_profile": "https://Stackoverflow.com/users/36457",
"pm_score": 0,
"selected": false,
"text": "<p>ToLower() is not a comparison function, it puts the string to lower case. When the == operator is used on String objects... | 2009/02/02 | [
"https://Stackoverflow.com/questions/501906",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11574/"
] | Let's say I have two strings: a and b. To compare whether a and be have the same values when case is ignored, I've always used:
```
// (Assume a and b have been verified not to be null)
if (a.ToLower() == b.ToLower())
```
However, using Reflector, I've seen this a few times in the .NET Framework:
```
// (arg three... | The Remarks section of the [MSDN article](http://msdn.microsoft.com/en-us/library/zkcaxw5y.aspx) should explain things. Essentially, the reason is for compatibility across different cultures settings. |
501,943 | <p>I use a datepicker for choosing an appointment day. I already set the date range to be only for the next month. That works fine. I want to exclude Saturdays and Sundays from the available choices. Can this be done? If so, how?</p>
| [
{
"answer_id": 503082,
"author": "Adam Bellaire",
"author_id": 21632,
"author_profile": "https://Stackoverflow.com/users/21632",
"pm_score": 9,
"selected": true,
"text": "<p>There is the <code>beforeShowDay</code> option, which takes a function to be called for each date, returning true ... | 2009/02/02 | [
"https://Stackoverflow.com/questions/501943",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18393/"
] | I use a datepicker for choosing an appointment day. I already set the date range to be only for the next month. That works fine. I want to exclude Saturdays and Sundays from the available choices. Can this be done? If so, how? | There is the `beforeShowDay` option, which takes a function to be called for each date, returning true if the date is allowed or false if it is not. From the docs:
---
**beforeShowDay**
The function takes a date as a parameter and must return an array with [0] equal to true/false indicating whether or not this date... |
501,962 | <p>I want to make a function which moves items from one STL list to another if they match a certain condition.</p>
<p>This code is not the way to do it. The iterator will most likely be invalidated by the erase() function and cause a problem:</p>
<pre><code>for(std::list<MyClass>::iterator it = myList.begin(); ... | [
{
"answer_id": 501969,
"author": "Ray Hidayat",
"author_id": 49643,
"author_profile": "https://Stackoverflow.com/users/49643",
"pm_score": 0,
"selected": false,
"text": "<p>Another attempt:</p>\n\n<pre><code>for(std::list<MyClass>::iterator it = myList.begin(); it != myList.end; ) ... | 2009/02/02 | [
"https://Stackoverflow.com/questions/501962",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5324/"
] | I want to make a function which moves items from one STL list to another if they match a certain condition.
This code is not the way to do it. The iterator will most likely be invalidated by the erase() function and cause a problem:
```
for(std::list<MyClass>::iterator it = myList.begin(); it != myList.end(); it++)
{... | `Erase` [returns an iterator](http://en.cppreference.com/w/cpp/container/list/erase) pointing to the element after the erased one:
```
std::list<MyClass>::iterator it = myList.begin();
while (it != myList.end())
{
if(myCondition(*it))
{
myOtherList.push_back(*it);
it = myList.erase(it);
}
else
{
... |
502,002 | <p>When using the <code>rm</code> command to delete files in Powershell, they are permanently deleted.</p>
<p>Instead of this, I would like to have the deleted item go to the recycle bin, like what happens when files are deleted through the UI.</p>
<p>How can you do this in PowerShell?</p>
| [
{
"answer_id": 502034,
"author": "Alex Shirshov",
"author_id": 56935,
"author_profile": "https://Stackoverflow.com/users/56935",
"pm_score": 4,
"selected": false,
"text": "<p>It works in PowerShell pretty much the same way as Chris Ballance's solution in JScript:</p>\n\n<pre><code> $shel... | 2009/02/02 | [
"https://Stackoverflow.com/questions/502002",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1496/"
] | When using the `rm` command to delete files in Powershell, they are permanently deleted.
Instead of this, I would like to have the deleted item go to the recycle bin, like what happens when files are deleted through the UI.
How can you do this in PowerShell? | Here is a shorter version that reduces a bit of work
```
$path = "<path to file>"
$shell = new-object -comobject "Shell.Application"
$item = $shell.Namespace(0).ParseName("$path")
$item.InvokeVerb("delete")
``` |
502,021 | <p>In C# rounding a number is easy:</p>
<pre><code>Math.Round(1.23456, 4); // returns 1.2346
</code></pre>
<p>However, I want to round a number such that the fractional part of the number rounds to the closest fractional part of a predefined fraction (e.g. 1/8th) and I'm trying to find out if the .NET library already... | [
{
"answer_id": 502026,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 5,
"selected": true,
"text": "<p>You could do this:</p>\n\n<pre><code>Math.Round(n * 8) / 8.0\n</code></pre>\n"
},
{
"answer_id": 502028,
"a... | 2009/02/02 | [
"https://Stackoverflow.com/questions/502021",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1463/"
] | In C# rounding a number is easy:
```
Math.Round(1.23456, 4); // returns 1.2346
```
However, I want to round a number such that the fractional part of the number rounds to the closest fractional part of a predefined fraction (e.g. 1/8th) and I'm trying to find out if the .NET library already has this built in.
So, f... | You could do this:
```
Math.Round(n * 8) / 8.0
``` |
502,022 | <p>I'm wanting to find the number of mantissa digits and the unit round-off on a particular computer. I have an understanding of what these are, just no idea how to find them - though I understand they can vary from computer to computer. </p>
<p>I need this number in order to perform certain aspects of numerical anal... | [
{
"answer_id": 502040,
"author": "paxdiablo",
"author_id": 14860,
"author_profile": "https://Stackoverflow.com/users/14860",
"pm_score": 4,
"selected": true,
"text": "<p>I would think that whatever language you were using would specify how floats were stored. I know Java does this by use... | 2009/02/02 | [
"https://Stackoverflow.com/questions/502022",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23323/"
] | I'm wanting to find the number of mantissa digits and the unit round-off on a particular computer. I have an understanding of what these are, just no idea how to find them - though I understand they can vary from computer to computer.
I need this number in order to perform certain aspects of numerical analysis, like ... | I would think that whatever language you were using would specify how floats were stored. I know Java does this by use of a specific IEEE standard (754, I think).
If it's not specified, I would think you could just do your own check by adding 0.5 to 1 to see if the actual number changes. If it does, then add 0.25 to 1... |
502,042 | <p>While creating and inserting DOM element's, it seems that the functions used for the task are returning before the elements show in the page.</p>
<p>Before starting to insert the elements I set the display property of a div to 'block' and after inserting the elements I set the property to 'none', the problem is, th... | [
{
"answer_id": 502045,
"author": "nickf",
"author_id": 9021,
"author_profile": "https://Stackoverflow.com/users/9021",
"pm_score": 3,
"selected": true,
"text": "<p>I believe that the DOM won't refresh until after the script has finished running.</p>\n\n<p>To make it run asynchronously, y... | 2009/02/02 | [
"https://Stackoverflow.com/questions/502042",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/61327/"
] | While creating and inserting DOM element's, it seems that the functions used for the task are returning before the elements show in the page.
Before starting to insert the elements I set the display property of a div to 'block' and after inserting the elements I set the property to 'none', the problem is, the indicato... | I believe that the DOM won't refresh until after the script has finished running.
To make it run asynchronously, you could try wrapping it in a `setTimeout` call, with a timeout of zero milliseconds. In pseudocode:
```
showLoadingIndicator();
setTimeout(addElements, 0);
function addElements() {
// perform your lo... |
502,059 | <p>So I have some code that looks like this:</p>
<pre><code>int a[10];
a = arrayGen(a,9);
</code></pre>
<p>and the arrayGen function looks like this:</p>
<pre><code>int* arrayGen(int arrAddr[], int maxNum)
{
int counter=0;
while(arrAddr[counter] != '\0') {
arrAddr[counter] = gen(maxNum);
coun... | [
{
"answer_id": 502068,
"author": "Ray Hidayat",
"author_id": 49643,
"author_profile": "https://Stackoverflow.com/users/49643",
"pm_score": 0,
"selected": false,
"text": "<p>Try calling your parameter <code>int* arrAddr</code>, not <code>int arrAddr[]</code>. Although when I think about i... | 2009/02/02 | [
"https://Stackoverflow.com/questions/502059",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45777/"
] | So I have some code that looks like this:
```
int a[10];
a = arrayGen(a,9);
```
and the arrayGen function looks like this:
```
int* arrayGen(int arrAddr[], int maxNum)
{
int counter=0;
while(arrAddr[counter] != '\0') {
arrAddr[counter] = gen(maxNum);
counter++;
}
return arrAddr;
}
`... | The basic magic here is this identity in C:
```
*(a+i) == a[i]
```
Okay, now I'll make this be readable English.
Here's the issue: An array name isn't an lvalue; it can't be assigned to. So the line you have with
```
a = arrayGen(...)
```
is the problem. See this example:
```
int main() {
int a[10];
a ... |
502,060 | <p>Is there any documentation on the parameters to WebForm_PostBackOptions? I can't find anything by Googling.</p>
| [
{
"answer_id": 635701,
"author": "Daniel P",
"author_id": 76808,
"author_profile": "https://Stackoverflow.com/users/76808",
"pm_score": 7,
"selected": true,
"text": "<p>There is no official documentation on this. However if you look at the javascript source code you will see this:</p>\n\... | 2009/02/02 | [
"https://Stackoverflow.com/questions/502060",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27294/"
] | Is there any documentation on the parameters to WebForm\_PostBackOptions? I can't find anything by Googling. | There is no official documentation on this. However if you look at the javascript source code you will see this:
```
function WebForm_PostBackOptions(eventTarget, eventArgument, validation, validationGroup, actionUrl, trackFocus, clientSubmit)
```
I think the parameter names are quite self-explanatory. |
502,094 | <p>I have the following query. </p>
<pre><code>SELECT p.author_name, p.author_id,
DISTINCT p.topic_id, t.title
FROM `ibf_posts` p, `ibf_topics` t
WHERE p.topic_id = t.tid
ORDER BY pid DESC
LIMIT 8"
</code></pre>
<p>When I run it, I get the following MySQL Error:</p>
<pre><code>You have an error in your SQL syntax;... | [
{
"answer_id": 502096,
"author": "Grant Limberg",
"author_id": 27314,
"author_profile": "https://Stackoverflow.com/users/27314",
"pm_score": 0,
"selected": false,
"text": "<p>Distinct needs to be before p.author_name. You can't choose only p.topic_id to be distinct in this case. If wha... | 2009/02/02 | [
"https://Stackoverflow.com/questions/502094",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/58670/"
] | I have the following query.
```
SELECT p.author_name, p.author_id,
DISTINCT p.topic_id, t.title
FROM `ibf_posts` p, `ibf_topics` t
WHERE p.topic_id = t.tid
ORDER BY pid DESC
LIMIT 8"
```
When I run it, I get the following MySQL Error:
```
You have an error in your SQL syntax; check the manual that corresponds to y... | It's
```
SELECT DISTINCT ...
```
You can't specify `DISTINCT` only for a single column; it only works for keeping complete duplicate records out of the result set. |
502,112 | <p>I'm trying to override the onError event handler of a web form to allow "A potentially dangerous Request.Form value was detected from the client" type errors to be handled within the form rather than ending up at the application level error handler.</p>
<p>I found some sample code like this :</p>
<pre><code> pro... | [
{
"answer_id": 502162,
"author": "Jason",
"author_id": 10639,
"author_profile": "https://Stackoverflow.com/users/10639",
"pm_score": 0,
"selected": false,
"text": "<p>I don't think you'll be able to handle the error in the Page_load event. In the <a href=\"http://msdn.microsoft.com/en-u... | 2009/02/02 | [
"https://Stackoverflow.com/questions/502112",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/61340/"
] | I'm trying to override the onError event handler of a web form to allow "A potentially dangerous Request.Form value was detected from the client" type errors to be handled within the form rather than ending up at the application level error handler.
I found some sample code like this :
```
protected override void ... | You actually can catch the error at the page level, but it will kill the page lifecycle. So you have to use a trick to get around it. Example:
```
public override void ProcessRequest(HttpContext context)
{
try
{
base.ProcessRequest(context);
}
catch(HttpRequestValidationException ex)
{
context.Resp... |
502,119 | <p>Not sure if I'm reading <a href="https://stackoverflow.com/questions/163797">this</a> right, but it seems like Scaffold will not do a one-to-many relationship in its entirety. For instance, if I create <code>messages</code> with scaffold and then I want <code>comments</code> on those <code>messages</code> (one <code... | [
{
"answer_id": 502240,
"author": "Chirantan",
"author_id": 45942,
"author_profile": "https://Stackoverflow.com/users/45942",
"pm_score": 4,
"selected": false,
"text": "<p>Yes. Scaffold works for a model and related controller. It does not take care of or work with relationships. </p>\n\n... | 2009/02/02 | [
"https://Stackoverflow.com/questions/502119",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8047/"
] | Not sure if I'm reading [this](https://stackoverflow.com/questions/163797) right, but it seems like Scaffold will not do a one-to-many relationship in its entirety. For instance, if I create `messages` with scaffold and then I want `comments` on those `messages` (one `message` -> many `comments`), I have to go through ... | This is true, but, it's not the end of the story. There are at least two alternatives to Scaffold that both work quite well and automatically pick up on relationships between classes (based on your ActiveRecord relationship indicators like has\_many). One of these alternatives is [Streamlined](http://github.com/relevan... |
502,122 | <p>A recent homework assignment I have received asks us to take expressions which could create a loss of precision when performed in the computer, and alter them so that this loss is avoided.</p>
<p>Unfortunately, the directions for doing this haven't been made very clear. From watching various examples being performe... | [
{
"answer_id": 502137,
"author": "shoosh",
"author_id": 9611,
"author_profile": "https://Stackoverflow.com/users/9611",
"pm_score": 4,
"selected": true,
"text": "<p>Another rule of thumb usually used is this: When adding a long series of numbers, start adding from numbers closest to zero... | 2009/02/02 | [
"https://Stackoverflow.com/questions/502122",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23323/"
] | A recent homework assignment I have received asks us to take expressions which could create a loss of precision when performed in the computer, and alter them so that this loss is avoided.
Unfortunately, the directions for doing this haven't been made very clear. From watching various examples being performed, I know ... | Another rule of thumb usually used is this: When adding a long series of numbers, start adding from numbers closest to zero and end with the biggest numbers.
Explaining why this is good is abit tricky. when you're adding small numbers to a large numbers, there is a chance they will be completely discarded because they... |
502,134 | <p>It is useful to have skeleton or template files that you can just copy and use as a basis for a new script or app. </p>
<p>For example, I use the following ones (emacs with the auto-insert module automatically opens a copy of the appropriate skeleton file when I create a new file).</p>
<p><strong>Perl</strong>:</p... | [
{
"answer_id": 502139,
"author": "jrockway",
"author_id": 8457,
"author_profile": "https://Stackoverflow.com/users/8457",
"pm_score": 2,
"selected": false,
"text": "<p>My Perl templates look like this:</p>\n\n<p>If I am opening a .pm module:</p>\n\n<pre><code>use MooseX::Declare;\nclass ... | 2009/02/02 | [
"https://Stackoverflow.com/questions/502134",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/60628/"
] | It is useful to have skeleton or template files that you can just copy and use as a basis for a new script or app.
For example, I use the following ones (emacs with the auto-insert module automatically opens a copy of the appropriate skeleton file when I create a new file).
**Perl**:
```
#!/usr/bin/perl -w
use st... | My Perl templates look like this:
If I am opening a .pm module:
```
use MooseX::Declare;
class What::Ever {
};
1;
```
Or, if not on a [MooseX::Declare](http://search.cpan.org/perldoc?MooseX::Declare) project:
```
package What::Ever;
use Moose;
1;
```
If it's a .pl file:
```
#!/usr/bin/env perl
use strict;
us... |
502,156 | <p>Just like the subject states. I want to be able to run iisreset, batch files, etc. from the a console application. Can I/How do I do it?</p>
| [
{
"answer_id": 502163,
"author": "Otávio Décio",
"author_id": 48684,
"author_profile": "https://Stackoverflow.com/users/48684",
"pm_score": 4,
"selected": true,
"text": "<p>That's quite possible, for example:</p>\n\n<pre><code> System.Diagnostics.Process.Start(@\"C:\\listfiles.bat\");\n<... | 2009/02/02 | [
"https://Stackoverflow.com/questions/502156",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34133/"
] | Just like the subject states. I want to be able to run iisreset, batch files, etc. from the a console application. Can I/How do I do it? | That's quite possible, for example:
```
System.Diagnostics.Process.Start(@"C:\listfiles.bat");
``` |
502,178 | <p>this is a rather basic java question</p>
<p>I have an array containing String that i want to sort using java.util.Arrays.sort</p>
<p>when i write</p>
<pre><code>String[] myArray = {"A","B","C"};
java.util.Arrays.sort(myArray);
</code></pre>
<p>it gets sorted correctly</p>
<p>however when i have</p>
<pre><code>... | [
{
"answer_id": 502185,
"author": "Kevin",
"author_id": 26620,
"author_profile": "https://Stackoverflow.com/users/26620",
"pm_score": 4,
"selected": true,
"text": "<p>When you initialize the second array, you only initialize the first three elements. The other elements are initialized to... | 2009/02/02 | [
"https://Stackoverflow.com/questions/502178",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6367/"
] | this is a rather basic java question
I have an array containing String that i want to sort using java.util.Arrays.sort
when i write
```
String[] myArray = {"A","B","C"};
java.util.Arrays.sort(myArray);
```
it gets sorted correctly
however when i have
```
String[] myArray = new String[10];
myArray[0] = "A";
myArr... | When you initialize the second array, you only initialize the first three elements. The other elements are initialized to null and thus can't be sorted. |
502,196 | <p>I'd like to have on my page a <code>div</code> which is centered and has a certain width, but which extends beyond that width if required by the content. I am doing this with the following:</p>
<pre><code><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-str... | [
{
"answer_id": 502214,
"author": "bendewey",
"author_id": 37881,
"author_profile": "https://Stackoverflow.com/users/37881",
"pm_score": 3,
"selected": true,
"text": "<p>Its not a perfect solutions, but I've gotten around some issues of IE6 lack of support for min-width by saying.</p>\n\n... | 2009/02/02 | [
"https://Stackoverflow.com/questions/502196",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5295/"
] | I'd like to have on my page a `div` which is centered and has a certain width, but which extends beyond that width if required by the content. I am doing this with the following:
```
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http:... | Its not a perfect solutions, but I've gotten around some issues of IE6 lack of support for min-width by saying.
```
<style type="text/css">
.container-minwidth {
min-width: 5em;
width: auto !important;
width: 500px; /* IE6 ignores the !important ... |
502,199 | <p>I want to make my WPF application open the default browser and go to a certain web page. How do I do that?</p>
| [
{
"answer_id": 502204,
"author": "Inisheer",
"author_id": 2982,
"author_profile": "https://Stackoverflow.com/users/2982",
"pm_score": 9,
"selected": true,
"text": "<p>For desktop versions of .NET:</p>\n<pre class=\"lang-cs prettyprint-override\"><code>System.Diagnostics.Process.Start(&qu... | 2009/02/02 | [
"https://Stackoverflow.com/questions/502199",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47630/"
] | I want to make my WPF application open the default browser and go to a certain web page. How do I do that? | For desktop versions of .NET:
```cs
System.Diagnostics.Process.Start("http://www.webpage.com");
```
For .NET Core, the default for [`ProcessStartInfo.UseShellExecute`](https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.processstartinfo.useshellexecute) has changed from `true` to `false`, and so you have... |
502,218 | <p>In a simulation server environment where users are allowed to submit their own code to be run by the server, it would clearly be advantageous for any user-submitted code to be run in side a sandbox, not unlike Applets are within a browser. I wanted to be able to leverage the JVM itself, rather than adding another V... | [
{
"answer_id": 502293,
"author": "Kieron",
"author_id": 588,
"author_profile": "https://Stackoverflow.com/users/588",
"pm_score": 1,
"selected": false,
"text": "<p>You will probably need to use a custom <a href=\"http://java.sun.com/javase/6/docs/api/java/lang/SecurityManager.html\" rel=... | 2009/02/02 | [
"https://Stackoverflow.com/questions/502218",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7708/"
] | In a simulation server environment where users are allowed to submit their own code to be run by the server, it would clearly be advantageous for any user-submitted code to be run in side a sandbox, not unlike Applets are within a browser. I wanted to be able to leverage the JVM itself, rather than adding another VM la... | 1. Run the untrusted code in its own thread. This for example prevents problems with infinite loops and such, and makes the future steps easier. Have the main thread wait for the thread to finish, and if takes too long, kill it with Thread.stop. Thread.stop is deprecated, but since the untrusted code shouldn't have acc... |
502,245 | <p>I want to include a silverlight application (.xap file) inside a HTML page.</p>
<p>Using these <a href="http://msdn.microsoft.com/en-us/library/cc189089(VS.95).aspx" rel="nofollow noreferrer">MSDN instructions</a> I create this HTML page:</p>
<pre><code><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "... | [
{
"answer_id": 502268,
"author": "Tim Heuer",
"author_id": 705,
"author_profile": "https://Stackoverflow.com/users/705",
"pm_score": 3,
"selected": true,
"text": "<p>Does the server have the registered MIME type of application/x-silverlight-app for the XAP extension?</p>\n"
},
{
... | 2009/02/02 | [
"https://Stackoverflow.com/questions/502245",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4639/"
] | I want to include a silverlight application (.xap file) inside a HTML page.
Using these [MSDN instructions](http://msdn.microsoft.com/en-us/library/cc189089(VS.95).aspx) I create this HTML page:
```
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xml... | Does the server have the registered MIME type of application/x-silverlight-app for the XAP extension? |
502,250 | <p>How do you bind to an objects method in this scenario in WPF?</p>
<pre class="lang-cs prettyprint-override"><code>public class RootObject
{
public string Name { get; }
public ObservableCollection<ChildObject> GetChildren() {...}
}
public class ChildObject
{
public string Name { get; }
}
</code></... | [
{
"answer_id": 502262,
"author": "Matt Hamilton",
"author_id": 615,
"author_profile": "https://Stackoverflow.com/users/615",
"pm_score": 5,
"selected": false,
"text": "<p>Not sure how well it will work in your scenario, but you can use the <a href=\"http://msdn.microsoft.com/en-us/librar... | 2009/02/02 | [
"https://Stackoverflow.com/questions/502250",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3820/"
] | How do you bind to an objects method in this scenario in WPF?
```cs
public class RootObject
{
public string Name { get; }
public ObservableCollection<ChildObject> GetChildren() {...}
}
public class ChildObject
{
public string Name { get; }
}
```
XAML:
```
<TreeView ItemsSource="some list of RootObject... | Another approach that might work for you is to create a custom [`IValueConverter`](http://msdn.microsoft.com/en-us/library/ms613620.aspx) that takes a method name as a parameter, so that it would be used like this:
```
ItemsSource="{Binding
Converter={StaticResource MethodToValueConverter},
ConverterParameter... |
502,256 | <p>consider this simple servlet sample:</p>
<pre><code>protected void doGet(HttpServletRequest request, HttpServletResponse response){
Cookie cookie = request.getCookie();
// do weird stuff with cookie object
}
</code></pre>
<p>I always wonder.. if you modify the object <code>cookie</code>, is it by object or... | [
{
"answer_id": 502264,
"author": "Kieron",
"author_id": 588,
"author_profile": "https://Stackoverflow.com/users/588",
"pm_score": 2,
"selected": false,
"text": "<p>Java methods get passed an <strong>object reference by value</strong>. So if you change the reference itself, e.g.</p>\n\n<p... | 2009/02/02 | [
"https://Stackoverflow.com/questions/502256",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2226/"
] | consider this simple servlet sample:
```
protected void doGet(HttpServletRequest request, HttpServletResponse response){
Cookie cookie = request.getCookie();
// do weird stuff with cookie object
}
```
I always wonder.. if you modify the object `cookie`, is it by object or by reference? | >
> if you modify the object `cookie`, is it
> by object or by reference?
>
>
>
Depends on what you mean by "modify" here. If you change the value of the reference, i.e. `cookie = someOtherObject`, then the original object itself isn't modified; it's just that you lost your reference to it. However, if you change... |