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 |
|---|---|---|---|---|---|---|
59,819 | <p>I would like to be able to define and use a custom type in some of my PowerShell scripts. For example, let's pretend I had a need for an object that had the following structure:</p>
<pre><code>Contact
{
string First
string Last
string Phone
}
</code></pre>
<p>How would I go about creating this so that ... | [
{
"answer_id": 59887,
"author": "David Mohundro",
"author_id": 4570,
"author_profile": "https://Stackoverflow.com/users/4570",
"pm_score": 2,
"selected": false,
"text": "<p>There is the concept of PSObject and Add-Member that you could use.</p>\n\n<pre><code>$contact = New-Object PSObjec... | 2008/09/12 | [
"https://Stackoverflow.com/questions/59819",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4916/"
] | I would like to be able to define and use a custom type in some of my PowerShell scripts. For example, let's pretend I had a need for an object that had the following structure:
```
Contact
{
string First
string Last
string Phone
}
```
How would I go about creating this so that I could use it in function... | Prior to PowerShell 3
---------------------
PowerShell's Extensible Type System didn't originally let you create concrete types you can test against the way you did in your parameter. If you don't need that test, you're fine with any of the other methods mentioned above.
If you want an actual type that you can cast ... |
59,825 | <p>Suppose the following:</p>
<pre><code>>>> s = set([1, 2, 3])
</code></pre>
<p>How do I get a value (any value) out of <code>s</code> without doing <code>s.pop()</code>? I want to leave the item in the set until I am sure I can remove it - something I can only be sure of after an asynchronous call to anoth... | [
{
"answer_id": 59841,
"author": "Blair Conrad",
"author_id": 1199,
"author_profile": "https://Stackoverflow.com/users/1199",
"pm_score": 11,
"selected": true,
"text": "<p>Two options that don't require copying the whole set:</p>\n\n<pre><code>for e in s:\n break\n# e is now an element... | 2008/09/12 | [
"https://Stackoverflow.com/questions/59825",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2260/"
] | Suppose the following:
```
>>> s = set([1, 2, 3])
```
How do I get a value (any value) out of `s` without doing `s.pop()`? I want to leave the item in the set until I am sure I can remove it - something I can only be sure of after an asynchronous call to another host.
Quick and dirty:
```
>>> elem = s.pop()
>>> s.... | Two options that don't require copying the whole set:
```
for e in s:
break
# e is now an element from s
```
Or...
```
e = next(iter(s))
```
But in general, sets don't support indexing or slicing. |
59,832 | <p>I am currently calling the following line of code:</p>
<pre><code>java.net.URL connection_url = new java.net.URL("http://<ip address>:<port>/path");
</code></pre>
<p>and I get the exception above when it executes. Any ideas as to why this is happening?</p>
| [
{
"answer_id": 59851,
"author": "jjnguy",
"author_id": 2598,
"author_profile": "https://Stackoverflow.com/users/2598",
"pm_score": 2,
"selected": false,
"text": "<p>As a side note, you should be using <a href=\"http://java.sun.com/javase/6/docs/api/java/net/URI.html\" rel=\"nofollow nore... | 2008/09/12 | [
"https://Stackoverflow.com/questions/59832",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2328/"
] | I am currently calling the following line of code:
```
java.net.URL connection_url = new java.net.URL("http://<ip address>:<port>/path");
```
and I get the exception above when it executes. Any ideas as to why this is happening? | Your code works perfectly fine for me:
```
public static void main(String[] args) {
try {
java.net.URL connection_url = new java.net.URL("http://:/path");
System.out.println("Instantiated new URL: " + connection_url);
}
catch (MalformedURLException e) {
e.printStackTrace();
}
}
... |
59,838 | <p>What command checks if a directory exists or not within a Bash shell script?</p>
| [
{
"answer_id": 59839,
"author": "Grundlefleck",
"author_id": 4120,
"author_profile": "https://Stackoverflow.com/users/4120",
"pm_score": 13,
"selected": true,
"text": "<p>To check if a directory exists:</p>\n<pre><code>if [ -d "$DIRECTORY" ]; then\n echo "$DIRECTORY does ... | 2008/09/12 | [
"https://Stackoverflow.com/questions/59838",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4120/"
] | What command checks if a directory exists or not within a Bash shell script? | To check if a directory exists:
```
if [ -d "$DIRECTORY" ]; then
echo "$DIRECTORY does exist."
fi
```
To check if a directory does not exist:
```
if [ ! -d "$DIRECTORY" ]; then
echo "$DIRECTORY does not exist."
fi
```
---
However, as [Jon Ericson](https://stackoverflow.com/users/1438/jon-ericson) points out,... |
59,840 | <p>I found a bug in the Contains statement in Linq (not sure if it is really in Linq or Linq to SQL) and want to know if anyone else has seen this and if there is a fix or workaround.</p>
<p>If the querysource you do the contains with has more than 10 items in it, it does not pass the items correctly to the SQL query.... | [
{
"answer_id": 59854,
"author": "Carlton Jenke",
"author_id": 1215,
"author_profile": "https://Stackoverflow.com/users/1215",
"pm_score": 2,
"selected": true,
"text": "<p>The more I look at it, and after running more tests, I'm thinking the bug may be in the Sql Server Query Visualizer p... | 2008/09/12 | [
"https://Stackoverflow.com/questions/59840",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1215/"
] | I found a bug in the Contains statement in Linq (not sure if it is really in Linq or Linq to SQL) and want to know if anyone else has seen this and if there is a fix or workaround.
If the querysource you do the contains with has more than 10 items in it, it does not pass the items correctly to the SQL query. It is har... | The more I look at it, and after running more tests, I'm thinking the bug may be in the Sql Server Query Visualizer plugin for Visual Studio, not actually in Linq to SQL itself. So it is not nearly as bad a situation as I thought - the query will return the right results, but you can't trust what the Visualizer is show... |
59,850 | <p>I'd like to create a spring bean that holds the value of a double. Something like:</p>
<pre><code><bean id="doubleValue" value="3.7"/>
</code></pre>
| [
{
"answer_id": 59852,
"author": "ScArcher2",
"author_id": 1310,
"author_profile": "https://Stackoverflow.com/users/1310",
"pm_score": 0,
"selected": false,
"text": "<p>Why don't you just use a <strong>Double</strong>? any reason?</p>\n"
},
{
"answer_id": 59875,
"author": "Pav... | 2008/09/12 | [
"https://Stackoverflow.com/questions/59850",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6180/"
] | I'd like to create a spring bean that holds the value of a double. Something like:
```
<bean id="doubleValue" value="3.7"/>
``` | Declare it like this:
```
<bean id="doubleValue" class="java.lang.Double">
<constructor-arg index="0" value="3.7"/>
</bean>
```
And use like this:
```
<bean id="someOtherBean" ...>
<property name="value" ref="doubleValue"/>
</bean>
``` |
59,857 | <p>Should I use a dedicated network channel between the database and the application server?</p>
<p>...or... </p>
<p>Connecting both in the switch along with all other computer nodes makes no diference at all?</p>
<p>The matter is <strong>performance!</strong></p>
| [
{
"answer_id": 59852,
"author": "ScArcher2",
"author_id": 1310,
"author_profile": "https://Stackoverflow.com/users/1310",
"pm_score": 0,
"selected": false,
"text": "<p>Why don't you just use a <strong>Double</strong>? any reason?</p>\n"
},
{
"answer_id": 59875,
"author": "Pav... | 2008/09/12 | [
"https://Stackoverflow.com/questions/59857",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1100/"
] | Should I use a dedicated network channel between the database and the application server?
...or...
Connecting both in the switch along with all other computer nodes makes no diference at all?
The matter is **performance!** | Declare it like this:
```
<bean id="doubleValue" class="java.lang.Double">
<constructor-arg index="0" value="3.7"/>
</bean>
```
And use like this:
```
<bean id="someOtherBean" ...>
<property name="value" ref="doubleValue"/>
</bean>
``` |
59,880 | <p>Conventional wisdom states that stored procedures are always faster. So, since they're always faster, use them <strong>ALL THE TIME</strong>.</p>
<p>I am pretty sure this is grounded in some historical context where this was once the case. Now, I'm not advocating that Stored Procs are not needed, but I want to know... | [
{
"answer_id": 59883,
"author": "Ryan Lanciaux",
"author_id": 1385358,
"author_profile": "https://Stackoverflow.com/users/1385358",
"pm_score": 1,
"selected": false,
"text": "<p>I don't know that they are faster. I like using ORM for data access (to not re-invent the wheel) but I realize... | 2008/09/12 | [
"https://Stackoverflow.com/questions/59880",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5619/"
] | Conventional wisdom states that stored procedures are always faster. So, since they're always faster, use them **ALL THE TIME**.
I am pretty sure this is grounded in some historical context where this was once the case. Now, I'm not advocating that Stored Procs are not needed, but I want to know in what cases stored p... | >
> **NOTE** that this is a general look at stored procedures not regulated to a specific
> DBMS. Some DBMS (and even, different
> versions of the same DBMS!) may operate
> contrary to this, so you'll want to
> double-check with your target DBMS
> before assuming all of this still holds.
>
>
> I've been a Sybas... |
59,895 | <p>How do I get the path of the directory in which a <a href="http://en.wikipedia.org/wiki/Bash_%28Unix_shell%29" rel="noreferrer">Bash</a> script is located, <em>inside</em> that script?</p>
<p>I want to use a Bash script as a launcher for another application. I want to change the working directory to the one where th... | [
{
"answer_id": 59916,
"author": "matt b",
"author_id": 4249,
"author_profile": "https://Stackoverflow.com/users/4249",
"pm_score": 10,
"selected": false,
"text": "<p>Use <code>dirname "$0"</code>:</p>\n<pre><code>#!/usr/bin/env bash\n\necho "The script you are running has ... | 2008/09/12 | [
"https://Stackoverflow.com/questions/59895",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2908/"
] | How do I get the path of the directory in which a [Bash](http://en.wikipedia.org/wiki/Bash_%28Unix_shell%29) script is located, *inside* that script?
I want to use a Bash script as a launcher for another application. I want to change the working directory to the one where the Bash script is located, so I can operate o... | ```
#!/usr/bin/env bash
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
```
is a useful one-liner which will give you the full directory name of the script no matter where it is being called from.
It will work as long as the last component of the path used to find the script is not a... |
59,896 | <p>I have a page that uses </p>
<pre><code>$(id).show("highlight", {}, 2000);
</code></pre>
<p>to highlight an element when I start a ajax request, that might fail so that I want to use something like</p>
<pre><code>$(id).show("highlight", {color: "#FF0000"}, 2000);
</code></pre>
<p>in the error handler. The proble... | [
{
"answer_id": 59904,
"author": "Ryan Lanciaux",
"author_id": 1385358,
"author_profile": "https://Stackoverflow.com/users/1385358",
"pm_score": 5,
"selected": true,
"text": "<p>From the jQuery docs: </p>\n\n<p><a href=\"http://docs.jquery.com/Effects/stop\" rel=\"nofollow noreferrer\">ht... | 2008/09/12 | [
"https://Stackoverflow.com/questions/59896",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6093/"
] | I have a page that uses
```
$(id).show("highlight", {}, 2000);
```
to highlight an element when I start a ajax request, that might fail so that I want to use something like
```
$(id).show("highlight", {color: "#FF0000"}, 2000);
```
in the error handler. The problem is that if the first highlight haven't finished... | From the jQuery docs:
<http://docs.jquery.com/Effects/stop>
>
> *Stop the currently-running animation on the matched elements.*...
>
>
> When `.stop()` is called on an element, the currently-running animation (if any) is immediately stopped. If, for instance, an element is being hidden with `.slideUp()` when `.st... |
59,986 | <p>I have a simple type that explicitly implemets an Interface.</p>
<pre><code>public interface IMessageHeader
{
string FromAddress { get; set; }
string ToAddress { get; set; }
}
[Serializable]
public class MessageHeader:IMessageHeader
{
private string from;
private string to;
[XmlAttribute("From")]
... | [
{
"answer_id": 59992,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": -1,
"selected": false,
"text": "<p>You can create an abstract base class the implements IMessageHeader and also inherits MarshalByRefObject</p>\n"
}... | 2008/09/12 | [
"https://Stackoverflow.com/questions/59986",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1647/"
] | I have a simple type that explicitly implemets an Interface.
```
public interface IMessageHeader
{
string FromAddress { get; set; }
string ToAddress { get; set; }
}
[Serializable]
public class MessageHeader:IMessageHeader
{
private string from;
private string to;
[XmlAttribute("From")]
string IMess... | You cannot serialize IMessageHeader because you can't do Activator.CreateInstance(typeof(IMessageHeader)) which is what serialization is going to do under the covers. You need a concrete type.
You can do typeof(MessageHeader) or you could say, have an instance of MessageHeader and do
```
XmlSerializer serializer = n... |
60,000 | <p>In C++, can member function pointers be used to point to derived (or even base) class members? </p>
<p>EDIT:
Perhaps an example will help. Suppose we have a hierarchy of three classes <code>X</code>, <code>Y</code>, <code>Z</code> in order of inheritance.
<code>Y</code> therefore has a base class <code>X</code> a... | [
{
"answer_id": 60010,
"author": "Steve Duitsman",
"author_id": 4575,
"author_profile": "https://Stackoverflow.com/users/4575",
"pm_score": 1,
"selected": false,
"text": "<p>I believe so. Since the function pointer uses the signature to identify itself, the base/derived behavior would re... | 2008/09/12 | [
"https://Stackoverflow.com/questions/60000",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1077/"
] | In C++, can member function pointers be used to point to derived (or even base) class members?
EDIT:
Perhaps an example will help. Suppose we have a hierarchy of three classes `X`, `Y`, `Z` in order of inheritance.
`Y` therefore has a base class `X` and a derived class `Z`.
Now we can define a member function poin... | C++03 std, [§4.11 2 Pointer to member conversions](http://www.open-std.org/jtc1/sc22/WG21/docs/wp/html/nov97-2/conv.html#conv.mem):
>
> An rvalue of type “pointer to member of B of type *cv* T,” where B is a class type, can be converted to an rvalue of type “pointer to member of D of type *cv* T,” where D is a derive... |
60,019 | <p>I am wanting to use ActiveScaffold to create <em>assignment</em> records for several <em>students</em> in a single step. The records will all contain identical data, with the exception of the student_id.</p>
<p>I was able to override the default form and replace the dropdown box for selecting the student name with... | [
{
"answer_id": 60366,
"author": "Can Berk Güder",
"author_id": 2119,
"author_profile": "https://Stackoverflow.com/users/2119",
"pm_score": 0,
"selected": false,
"text": "<p>if your assingnments have <code>has_many :students</code> or <code>has_and_belongs_to_many :students</code>, then y... | 2008/09/12 | [
"https://Stackoverflow.com/questions/60019",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3764/"
] | I am wanting to use ActiveScaffold to create *assignment* records for several *students* in a single step. The records will all contain identical data, with the exception of the student\_id.
I was able to override the default form and replace the dropdown box for selecting the student name with a multi-select box - wh... | I suppose you have defined your multi-select box adding :multiple => true to html parameters of select\_tag. Then, in the controller, you need to access the list of names selected, what you can do like this:
```
params[:students].collect{|student| insert_student(student, params[:assignment_id]) }
```
With collect ap... |
60,030 | <p>In Firefox you can enter the following into the awesome bar and hit enter:</p>
<pre><code>javascript:self.resizeTo(1024,768);
</code></pre>
<p>How do you do the same thing in IE?</p>
| [
{
"answer_id": 60038,
"author": "Ross",
"author_id": 2025,
"author_profile": "https://Stackoverflow.com/users/2025",
"pm_score": 2,
"selected": false,
"text": "<p>Try:</p>\n\n<pre><code>javascript:resizeTo(1024,768);\n</code></pre>\n\n<p>This works in IE7 at least.</p>\n"
},
{
"a... | 2008/09/12 | [
"https://Stackoverflow.com/questions/60030",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1496/"
] | In Firefox you can enter the following into the awesome bar and hit enter:
```
javascript:self.resizeTo(1024,768);
```
How do you do the same thing in IE? | ```
javascript:resizeTo(1024,768);
vbscript:resizeto(1024,768)
```
Will work in IE7, But consider using something like
```
javascript:moveTo(0,0);resizeTo(1024,768);
```
because IE7 doesn't allow the window to "resize" beyond the screen borders. If you work on a 1024,768 desktop, this is what happens...* Firefox: 10... |
60,032 | <p>How do I get the key of the current element in a <code>foreach</code> loop in C#?</p>
<p>For example:</p>
<h2>PHP</h2>
<pre><code>foreach ($array as $key => $value)
{
echo("$value is assigned to key: $key");
}
</code></pre>
<h3>What I'm trying to do in C#:</h3>
<pre><code>int[] values = { 5, 14, 29, 49, ... | [
{
"answer_id": 60035,
"author": "Jonathan Allen",
"author_id": 5274,
"author_profile": "https://Stackoverflow.com/users/5274",
"pm_score": 2,
"selected": false,
"text": "<p>Alas there is no built-in way to do this. Either use a for loop or create a temp variable that you increment on eac... | 2008/09/12 | [
"https://Stackoverflow.com/questions/60032",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2025/"
] | How do I get the key of the current element in a `foreach` loop in C#?
For example:
PHP
---
```
foreach ($array as $key => $value)
{
echo("$value is assigned to key: $key");
}
```
### What I'm trying to do in C#:
```
int[] values = { 5, 14, 29, 49, 99, 150, 999 };
foreach (int val in values)
{
if(search ... | [Grauenwolf's way](https://stackoverflow.com/questions/60032/getting-the-array-key-in-a-foreach-loop#60035) is the most straightforward and performant way of doing this with an array:
>
> Either use a for loop or create a temp variable that you increment on each pass.
>
>
>
Which would of course look like this:
... |
60,033 | <p>I want to make a copy of an ActiveRecord object, changing a single field in the process (in addition to the <strong>id</strong>). What is the simplest way to accomplish this?</p>
<p>I realize I could create a new record, and then iterate over each of the fields copying the data field-by-field - but I figured there ... | [
{
"answer_id": 60053,
"author": "Michael Sepcot",
"author_id": 6033,
"author_profile": "https://Stackoverflow.com/users/6033",
"pm_score": 10,
"selected": true,
"text": "<p>To get a copy, use the <a href=\"https://api.rubyonrails.org/classes/ActiveRecord/Core.html#method-i-dup\" rel=\"no... | 2008/09/12 | [
"https://Stackoverflow.com/questions/60033",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3764/"
] | I want to make a copy of an ActiveRecord object, changing a single field in the process (in addition to the **id**). What is the simplest way to accomplish this?
I realize I could create a new record, and then iterate over each of the fields copying the data field-by-field - but I figured there must be an easier way t... | To get a copy, use the [dup](https://api.rubyonrails.org/classes/ActiveRecord/Core.html#method-i-dup) (or clone for < rails 3.1+) method:
```
#rails >= 3.1
new_record = old_record.dup
# rails < 3.1
new_record = old_record.clone
```
Then you can change whichever fields you want.
[ActiveRecord overrides the built-in... |
60,034 | <p>I am writing a batch file script using Windows command-line environment and want to change each occurrence of some text in a file (ex. "FOO") with another (ex. "BAR"). What is the simplest way to do that? Any built in functions?</p>
| [
{
"answer_id": 60055,
"author": "Ferruccio",
"author_id": 4086,
"author_profile": "https://Stackoverflow.com/users/4086",
"pm_score": 5,
"selected": false,
"text": "<p>I don't think there's a way to do it with any built-in commands. I would suggest you download something like <a href=\"h... | 2008/09/12 | [
"https://Stackoverflow.com/questions/60034",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4872/"
] | I am writing a batch file script using Windows command-line environment and want to change each occurrence of some text in a file (ex. "FOO") with another (ex. "BAR"). What is the simplest way to do that? Any built in functions? | A lot of the answers here helped point me in the right direction, however none were suitable for me, so I am posting my solution.
I have Windows 7, which comes with PowerShell built-in. Here is the script I used to find/replace all instances of text in a file:
```
powershell -Command "(gc myFile.txt) -replace 'foo', ... |
60,046 | <p>I'm embedding the Google Maps Flash API in Flex and it runs fine locally with the watermark on it, etc. When I upload it to the server (flex.mydomain.com) I get a sandbox security error listed below: </p>
<pre><code>SecurityError: Error #2121: Security sandbox violation: Loader.content: http://mydomain.com/main.... | [
{
"answer_id": 60453,
"author": "Till",
"author_id": 2859,
"author_profile": "https://Stackoverflow.com/users/2859",
"pm_score": 2,
"selected": false,
"text": "<p>This sounds like a <code>crossdomain.xml</code> related problem. I did a quick search and there seems to be many people with ... | 2008/09/12 | [
"https://Stackoverflow.com/questions/60046",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4760/"
] | I'm embedding the Google Maps Flash API in Flex and it runs fine locally with the watermark on it, etc. When I upload it to the server (flex.mydomain.com) I get a sandbox security error listed below:
```
SecurityError: Error #2121: Security sandbox violation: Loader.content: http://mydomain.com/main.swf?Fri, 12 Sep 2... | This sounds like a `crossdomain.xml` related problem. I did a quick search and there seems to be many people with the same issue. Some proxy requests through XMLHttpRequest etc..
[Issue 406: Add crossdomain.xml for Google Accounts](http://code.google.com/p/gdata-issues/issues/detail?id=406) |
60,051 | <p>My question is pertaining to the best practice for accessing a child object's parent. So let's say a class instantiates another class, that class instance is now referenced with an object. From that child object, what is the best way to reference back to the parent object? Currently I know of a couple ways that I us... | [
{
"answer_id": 60074,
"author": "dagorym",
"author_id": 171,
"author_profile": "https://Stackoverflow.com/users/171",
"pm_score": 2,
"selected": false,
"text": "<p>I've always used your second method, passing a pointer to the parent object to the child and storing that pointer in a membe... | 2008/09/12 | [
"https://Stackoverflow.com/questions/60051",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1945/"
] | My question is pertaining to the best practice for accessing a child object's parent. So let's say a class instantiates another class, that class instance is now referenced with an object. From that child object, what is the best way to reference back to the parent object? Currently I know of a couple ways that I use o... | It's generally good to have the class as it's own instance and reduce tight coupling to something else (as in this case, it's parent). If you do something like parent.doSomething() it's not possible to use that class in container that doesn't have the doSometing() method. I think it's definitely better to pass in whate... |
60,098 | <p>I wrote a simple web service in C# using SharpDevelop (which I just got and I love).</p>
<p>The client wanted it in VB, and fortunately there's a Convert To VB.NET feature. It's great. Translated all the code, and it builds. (I've been a "Notepad" guy for a long time, so I may seem a little old-fashioned.)</p>
... | [
{
"answer_id": 60108,
"author": "FlySwat",
"author_id": 1965,
"author_profile": "https://Stackoverflow.com/users/1965",
"pm_score": 0,
"selected": false,
"text": "<pre><code><%@ WebService Class=\"flightinfo.Soap,flightinfo\" %>\n</code></pre>\n\n<p>What is the name of your class?<... | 2008/09/12 | [
"https://Stackoverflow.com/questions/60098",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4525/"
] | I wrote a simple web service in C# using SharpDevelop (which I just got and I love).
The client wanted it in VB, and fortunately there's a Convert To VB.NET feature. It's great. Translated all the code, and it builds. (I've been a "Notepad" guy for a long time, so I may seem a little old-fashioned.)
But I get this er... | In VB.NET, namespace declarations are relative to the default namespace of the project. So if the default namespace for the project is set to X.Y, everithyng between `Namespace Z` and `End Namespace` will be in the X.Y.Z namespace.
In C# you have to provide the full namespace name, regardless of the default namespace o... |
60,160 | <p>Does Java have a built-in way to escape arbitrary text so that it can be included in a regular expression? For example, if my users enter "$5", I'd like to match that exactly rather than a "5" after the end of input.</p>
| [
{
"answer_id": 60161,
"author": "Mike Stone",
"author_id": 122,
"author_profile": "https://Stackoverflow.com/users/122",
"pm_score": 10,
"selected": true,
"text": "<p>Since <a href=\"http://download.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html#quote(java.lang.String)\" rel=\... | 2008/09/12 | [
"https://Stackoverflow.com/questions/60160",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2338/"
] | Does Java have a built-in way to escape arbitrary text so that it can be included in a regular expression? For example, if my users enter "$5", I'd like to match that exactly rather than a "5" after the end of input. | Since [Java 1.5, yes](http://download.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html#quote(java.lang.String)):
```
Pattern.quote("$5");
``` |
60,168 | <p>Here is an example of what I've got going on:</p>
<pre><code>CREATE TABLE Parent (id BIGINT NOT NULL,
PRIMARY KEY (id)) ENGINE=InnoDB;
CREATE TABLE Child (id BIGINT NOT NULL,
parentid BIGINT NOT NULL,
PRIMARY KEY (id),
KEY (parentid),
CONSTRAINT fk_parent FOREIGN KEY (parentid) REFERENCES Parent (id) ON ... | [
{
"answer_id": 60185,
"author": "Apocalisp",
"author_id": 3434,
"author_profile": "https://Stackoverflow.com/users/3434",
"pm_score": 3,
"selected": false,
"text": "<p>In the simpler case, what happens if a record is deleted from Child and it has a referencing Uncle? That's unspecified, ... | 2008/09/12 | [
"https://Stackoverflow.com/questions/60168",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6198/"
] | Here is an example of what I've got going on:
```
CREATE TABLE Parent (id BIGINT NOT NULL,
PRIMARY KEY (id)) ENGINE=InnoDB;
CREATE TABLE Child (id BIGINT NOT NULL,
parentid BIGINT NOT NULL,
PRIMARY KEY (id),
KEY (parentid),
CONSTRAINT fk_parent FOREIGN KEY (parentid) REFERENCES Parent (id) ON DELETE CASCADE... | The parent deletion is triggering the child deletion as you stated and I don't know why it goes to the child table before the uncle table. I imagine you would have to look at the dbms code to know for sure, but im sure there is an algorithm that picks which tables to cascade to first.
The system does not really 'figur... |
60,174 | <p>If user input is inserted without modification into an SQL query, then the application becomes vulnerable to <a href="https://stackoverflow.com/a/332367/">SQL injection</a>, like in the following example:</p>
<pre class="lang-php prettyprint-override"><code>$unsafe_variable = $_POST['user_input'];
mysql_query("IN... | [
{
"answer_id": 60180,
"author": "Kibbee",
"author_id": 1862,
"author_profile": "https://Stackoverflow.com/users/1862",
"pm_score": 10,
"selected": false,
"text": "<p>I'd recommend using <a href=\"http://ca3.php.net/manual/en/book.pdo.php\" rel=\"noreferrer\">PDO</a> (PHP Data Objects) to... | 2008/09/12 | [
"https://Stackoverflow.com/questions/60174",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/428190/"
] | If user input is inserted without modification into an SQL query, then the application becomes vulnerable to [SQL injection](https://stackoverflow.com/a/332367/), like in the following example:
```php
$unsafe_variable = $_POST['user_input'];
mysql_query("INSERT INTO `table` (`column`) VALUES ('$unsafe_variable')");
... | The *correct* way to avoid SQL injection attacks, no matter which database you use, is to **separate the data from SQL**, so that data stays data and will **never be interpreted** as commands by the SQL parser. It is possible to create an SQL statement with correctly formatted data parts, but if you don't *fully* under... |
60,204 | <p>I was going to ask a question here about whether or not my design for some users/roles database tables was acceptable, but after some research I came across this question:</p>
<p><a href="/questions/1451/what-is-the-best-way-to-handle-multiple-permission-types">What is the best way to handle multiple permission typ... | [
{
"answer_id": 60206,
"author": "Josef",
"author_id": 5581,
"author_profile": "https://Stackoverflow.com/users/5581",
"pm_score": 2,
"selected": false,
"text": "<p>Actually, this is how we determine authority within a fairly large web application that I'm the DBA for. </p>\n\n<p>If you a... | 2008/09/13 | [
"https://Stackoverflow.com/questions/60204",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I was going to ask a question here about whether or not my design for some users/roles database tables was acceptable, but after some research I came across this question:
[What is the best way to handle multiple permission types?](/questions/1451/what-is-the-best-way-to-handle-multiple-permission-types)
It sounds li... | You use bitwise operations. The pseudo-code would be something like:
```
bool HasPermission(User user, Permission permission) {
return (user.Permission & permission) != 0;
}
void SetPermission(User user, Permission permission) {
user.Permission |= permission;
}
void ClearPermission(User user, Permission perm... |
60,208 | <p>I want to write a function in Python that returns different fixed values based on the value of an input index. </p>
<p>In other languages I would use a <code>switch</code> or <code>case</code> statement, but Python does not appear to have a <code>switch</code> statement. What are the recommended Python solutions ... | [
{
"answer_id": 60211,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 12,
"selected": true,
"text": "<p>The original answer below was written in 2008. Since then, Python 3.10 (2021) introduced the <a href=\"https://www.pyth... | 2008/09/13 | [
"https://Stackoverflow.com/questions/60208",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4907/"
] | I want to write a function in Python that returns different fixed values based on the value of an input index.
In other languages I would use a `switch` or `case` statement, but Python does not appear to have a `switch` statement. What are the recommended Python solutions in this scenario? | The original answer below was written in 2008. Since then, Python 3.10 (2021) introduced the [`match`-`case`](https://www.python.org/dev/peps/pep-0634/) statement which provides a first-class implementation of a "switch" for Python. For example:
```
def f(x):
match x:
case 'a':
return 1
... |
60,221 | <p>I have always wondered how people update a previous line in a command line. a great example of this is when using the wget command in linux. It creates an ASCII loading bar of sorts that looks like this:</p>
<blockquote>
<p>[======> &nbs... | [
{
"answer_id": 60226,
"author": "hazzen",
"author_id": 5066,
"author_profile": "https://Stackoverflow.com/users/5066",
"pm_score": 7,
"selected": true,
"text": "<p>There are two ways I know of to do this:</p>\n\n<ul>\n<li>Use the backspace escape character ('\\b') to erase your line</li>... | 2008/09/13 | [
"https://Stackoverflow.com/questions/60221",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2128/"
] | I have always wondered how people update a previous line in a command line. a great example of this is when using the wget command in linux. It creates an ASCII loading bar of sorts that looks like this:
>
> [======> ] 37%
>
>
>
and of course the loading bar moves and the percent changes, But i... | There are two ways I know of to do this:
* Use the backspace escape character ('\b') to erase your line
* Use the `curses` package, if your programming language of choice has bindings for it.
And a Google revealed [ANSI Escape Codes](http://en.wikipedia.org/wiki/ANSI_escape_code), which appear to be a good way. For r... |
60,244 | <p>I need to join two binary files with a <code>*.bat</code> script on Windows.</p>
<p>How can I achieve that?</p>
| [
{
"answer_id": 60248,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 7,
"selected": false,
"text": "<p>You can use <code>copy /b</code> like this:</p>\n\n<pre><code>copy /b file1+file2 destfile\n</code></pre>\n"
},
{
... | 2008/09/13 | [
"https://Stackoverflow.com/questions/60244",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2313/"
] | I need to join two binary files with a `*.bat` script on Windows.
How can I achieve that? | Windows `type` command works similarly to UNIX `cat`.
**Example 1:**
```
type file1 file2 > file3
```
is equivalent of:
```
cat file1 file2 > file3
```
**Example 2:**
```
type *.vcf > all_in_one.vcf
```
This command will merge all the vcards into one. |
60,259 | <p>Every sample that I have seen uses static XML in the xmldataprovider source, which is then used to databind UI controls using XPath binding.
Idea is to edit a dynamic XML (structure known to the developer during coding), using the WPF UI.</p>
<p>Has anyone found a way to load a dynamic xml string (for example load... | [
{
"answer_id": 60398,
"author": "Mauro",
"author_id": 2208,
"author_profile": "https://Stackoverflow.com/users/2208",
"pm_score": 1,
"selected": false,
"text": "<p>using your webservice get your XML and create an XML Document from it, You can then set the Source of your xmlDataProvider t... | 2008/09/13 | [
"https://Stackoverflow.com/questions/60259",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1747/"
] | Every sample that I have seen uses static XML in the xmldataprovider source, which is then used to databind UI controls using XPath binding.
Idea is to edit a dynamic XML (structure known to the developer during coding), using the WPF UI.
Has anyone found a way to load a dynamic xml string (for example load it from a... | Here is some code I used to load a XML file from disk and bind it to a TreeView. I removed some of the normal tests for conciseness. The XML in the example is an OPML file.
```
XmlDataProvider provider = new XmlDataProvider();
if (provider != null)
{
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
doc.... |
60,260 | <p>I've been working through <a href="http://gigamonkeys.com/book" rel="nofollow noreferrer">Practical Common Lisp</a> and as an exercise decided to write a macro to determine if a number is a multiple of another number:</p>
<p><code>(defmacro multp (value factor)<br>
`(= (rem ,value ,factor) 0))</code></p>
<p>so... | [
{
"answer_id": 60267,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 5,
"selected": true,
"text": "<p>Siebel gives an extensive rundown (for simple cases anyway) of possible sources of leaks, and there aren't any of those here.... | 2008/09/13 | [
"https://Stackoverflow.com/questions/60260",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5303/"
] | I've been working through [Practical Common Lisp](http://gigamonkeys.com/book) and as an exercise decided to write a macro to determine if a number is a multiple of another number:
`(defmacro multp (value factor)
`(= (rem ,value ,factor) 0))`
so that :
`(multp 40 10)`
evaluates to true whilst
`(multp 40 13)`
does... | Siebel gives an extensive rundown (for simple cases anyway) of possible sources of leaks, and there aren't any of those here. Both `value` and `factor` are evaluated only once and in order, and `rem` doesn't have any side effects.
This is not good Lisp though, because there's no reason to use a macro in this case. A f... |
60,269 | <p>How do I implement a draggable tab using Java Swing? Instead of the static JTabbedPane I would like to drag-and-drop a tab to different position to rearrange the tabs.</p>
<p><strong>EDIT</strong>: <a href="http://java.sun.com/docs/books/tutorial/uiswing/dnd/index.html" rel="noreferrer">The Java Tutorials - Drag an... | [
{
"answer_id": 60279,
"author": "jodonnell",
"author_id": 4223,
"author_profile": "https://Stackoverflow.com/users/4223",
"pm_score": 3,
"selected": false,
"text": "<p>Found this code out there on the <a href=\"http://java-swing-tips.blogspot.com/2008/04/drag-and-drop-tabs-in-jtabbedpane... | 2008/09/13 | [
"https://Stackoverflow.com/questions/60269",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3827/"
] | How do I implement a draggable tab using Java Swing? Instead of the static JTabbedPane I would like to drag-and-drop a tab to different position to rearrange the tabs.
**EDIT**: [The Java Tutorials - Drag and Drop and Data Transfer](http://java.sun.com/docs/books/tutorial/uiswing/dnd/index.html). | I liked [Terai Atsuhiro san's DnDTabbedPane](http://java-swing-tips.blogspot.com/2008/04/drag-and-drop-tabs-in-jtabbedpane.html), but I wanted more from it. The original Terai implementation transfered tabs within the TabbedPane, but it would be nicer if I could drag from one TabbedPane to another.
Inspired by @[Tom](... |
60,278 | <p>In all the Git tutorials I've read they say that you can do:</p>
<pre><code>git init
git add .
git commit
</code></pre>
<p>When I do that I get a big text file opened up. None of the tutorials seem to address this, so I don't know what to do with the file or what to put in it if anything.</p>
| [
{
"answer_id": 60283,
"author": "Ben Collins",
"author_id": 3279,
"author_profile": "https://Stackoverflow.com/users/3279",
"pm_score": 3,
"selected": false,
"text": "<p>The <code>git commit</code> command will open up the editor specified in the <code>EDITOR</code> environment variable ... | 2008/09/13 | [
"https://Stackoverflow.com/questions/60278",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | In all the Git tutorials I've read they say that you can do:
```
git init
git add .
git commit
```
When I do that I get a big text file opened up. None of the tutorials seem to address this, so I don't know what to do with the file or what to put in it if anything. | You're meant to put the commit message in this text file, then save and quit.
You can change the default text editor that git uses with this command:
```
git config --global core.editor "nano"
```
You have to change nano to whatever command would normally open your text editor. |
60,290 | <p>Is there a way to change the appearance of an icon (ie. contrast / luminosity) when I hover the cursor, without requiring a second image file (or without requiring a hidden portion of the image)?</p>
| [
{
"answer_id": 60294,
"author": "Flame",
"author_id": 5387,
"author_profile": "https://Stackoverflow.com/users/5387",
"pm_score": 1,
"selected": false,
"text": "<p>The way I usually see things done with smaller images such as buttons it that only a certain portion of the image is shown. ... | 2008/09/13 | [
"https://Stackoverflow.com/questions/60290",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3764/"
] | Is there a way to change the appearance of an icon (ie. contrast / luminosity) when I hover the cursor, without requiring a second image file (or without requiring a hidden portion of the image)? | [Here's some good information about image opacity and transparency with CSS](http://www.w3schools.com/css/css_image_transparency.asp).
So to make an image with opacity 50%, you'd do this:
```
<img src="image.png" style="opacity: 0.5; filter: alpha(opacity=50)" />
```
The **opacity:** part is how Firefox does it, an... |
60,293 | <p>I have a little problem with a Listview.</p>
<p>I can load it with listview items fine, but when I set the background color it doesn't draw the color all the way to the left side of the row [The listViewItems are loaded with ListViewSubItems to make a grid view, only the first column shows the error]. There is a a... | [
{
"answer_id": 60300,
"author": "moobaa",
"author_id": 3569,
"author_profile": "https://Stackoverflow.com/users/3569",
"pm_score": 1,
"selected": false,
"text": "<p>(Prior to the Edit...)</p>\n\n<p>I've just tried setting the BackColor on a System.Windows.Forms.ListView, and the color is... | 2008/09/13 | [
"https://Stackoverflow.com/questions/60293",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1327/"
] | I have a little problem with a Listview.
I can load it with listview items fine, but when I set the background color it doesn't draw the color all the way to the left side of the row [The listViewItems are loaded with ListViewSubItems to make a grid view, only the first column shows the error]. There is a a narrow str... | Ah! I see now :}
You want hacky? I present unto you the following:
```
...
lv.OwnerDraw = true;
lv.DrawItem += new DrawListViewItemEventHandler( lv_DrawItem );
...
void lv_DrawItem( object sender, DrawListViewItemEventArgs e )
{
Rectangle foo = e.Bounds;
foo.Offset( -10, 0 );
e.Graphics.F... |
60,302 | <p>If I start a process via Java's <a href="http://java.sun.com/javase/6/docs/api/java/lang/ProcessBuilder.html" rel="noreferrer">ProcessBuilder</a> class, I have full access to that process's standard in, standard out, and standard error streams as Java <code>InputStreams</code> and <code>OutputStreams</code>. However... | [
{
"answer_id": 60578,
"author": "John Meagher",
"author_id": 3535,
"author_profile": "https://Stackoverflow.com/users/3535",
"pm_score": 5,
"selected": true,
"text": "<p>You will need to copy the <a href=\"http://java.sun.com/javase/6/docs/api/java/lang/Process.html\" rel=\"noreferrer\">... | 2008/09/13 | [
"https://Stackoverflow.com/questions/60302",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5696/"
] | If I start a process via Java's [ProcessBuilder](http://java.sun.com/javase/6/docs/api/java/lang/ProcessBuilder.html) class, I have full access to that process's standard in, standard out, and standard error streams as Java `InputStreams` and `OutputStreams`. However, I can't find a way to seamlessly connect those stre... | You will need to copy the [Process](http://java.sun.com/javase/6/docs/api/java/lang/Process.html) out, err, and input streams to the System versions. The easiest way to do that is using the [IOUtils](http://commons.apache.org/io/api-release/org/apache/commons/io/IOUtils.html) class from the Commons IO package. The [cop... |
60,352 | <p>If all of my <code>__init__.py</code> files are empty, do I have to store them into version control, or is there a way to make <code>distutils</code> create empty <code>__init__.py</code> files during installation?</p>
| [
{
"answer_id": 60431,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 3,
"selected": false,
"text": "<p>In Python, <code>__init__.py</code> files actually have a meaning! They mean that the folder they are in is a Python module.... | 2008/09/13 | [
"https://Stackoverflow.com/questions/60352",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2679/"
] | If all of my `__init__.py` files are empty, do I have to store them into version control, or is there a way to make `distutils` create empty `__init__.py` files during installation? | Is there a reason you want to *avoid* putting empty `__init__.py` files in version control? If you do this you won't be able to `import` your packages from the source directory wihout first running distutils.
If you really want to, I suppose you can create `__init__.py` in `setup.py`. It has to be *before* running `di... |
60,369 | <p>I'm currently playing around with <a href="http://pear.php.net/package/HTML_QuickForm" rel="noreferrer">HTML_QuickForm</a> for generating forms in PHP. It seems kind of limited in that it's hard to insert my own javascript or customizing the display and grouping of certain elements.</p>
<p>Are there any alternativ... | [
{
"answer_id": 60372,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 4,
"selected": true,
"text": "<p>If you find it hard to insert Javascript into the form elements, consider using a JavaScript framework such as <a hr... | 2008/09/13 | [
"https://Stackoverflow.com/questions/60369",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4883/"
] | I'm currently playing around with [HTML\_QuickForm](http://pear.php.net/package/HTML_QuickForm) for generating forms in PHP. It seems kind of limited in that it's hard to insert my own javascript or customizing the display and grouping of certain elements.
Are there any alternatives to QuickForm that might provide mor... | If you find it hard to insert Javascript into the form elements, consider using a JavaScript framework such as [Prototype](http://www.prototypejs.org/) or [jQuery](http://jquery.com/). There, you can centralize the task of injecting event handling into form controls.
By that, I mean that you won't need to insert event... |
60,409 | <p>I know in php you can embed variables inside variables, like:</p>
<pre><code><? $var1 = "I\'m including {$var2} in this variable.."; ?>
</code></pre>
<p>But I was wondering how, and if it was possible to include a function inside a variable.
I know I could just write:</p>
<pre><code><?php
$var1 = "I\'m i... | [
{
"answer_id": 60420,
"author": "Jason Weathered",
"author_id": 3736,
"author_profile": "https://Stackoverflow.com/users/3736",
"pm_score": 6,
"selected": true,
"text": "<p>Function calls within strings are supported since PHP5 by having a variable containing the name of the function to ... | 2008/09/13 | [
"https://Stackoverflow.com/questions/60409",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4867/"
] | I know in php you can embed variables inside variables, like:
```
<? $var1 = "I\'m including {$var2} in this variable.."; ?>
```
But I was wondering how, and if it was possible to include a function inside a variable.
I know I could just write:
```
<?php
$var1 = "I\'m including ";
$var1 .= somefunc();
$var1 = " in ... | Function calls within strings are supported since PHP5 by having a variable containing the name of the function to call:
```
<?
function somefunc($stuff)
{
$output = "<b>{$stuff}</b>";
return $output;
}
$somefunc='somefunc';
echo "foo {$somefunc("bar")} baz";
?>
```
will output "`foo <b>bar</b> baz`".
I fin... |
60,422 | <p>As part of a JavaScript Profiler for IE 6/7 I needed to load a custom debugger that I created into IE. I got this working fine on XP, but couldn't get it working on Vista (full story here: <a href="http://damianblog.com/2008/09/09/tracejs-v2-rip/" rel="nofollow noreferrer">http://damianblog.com/2008/09/09/tracejs-v... | [
{
"answer_id": 60468,
"author": "millenomi",
"author_id": 6061,
"author_profile": "https://Stackoverflow.com/users/6061",
"pm_score": 0,
"selected": false,
"text": "<p>I'm not familiar with these interfaces, but unexpected failures in Vista may require being past a UAC prompt. Have you t... | 2008/09/13 | [
"https://Stackoverflow.com/questions/60422",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3390/"
] | As part of a JavaScript Profiler for IE 6/7 I needed to load a custom debugger that I created into IE. I got this working fine on XP, but couldn't get it working on Vista (full story here: <http://damianblog.com/2008/09/09/tracejs-v2-rip/>).
The call to GetProviderProcessData is failing on Vista. Anyone have any sugge... | It would help to know what the error result was.
Possible problems I can think of:
If your getting permission denied, your most likely missing some requried [Privilege](http://msdn.microsoft.com/en-us/library/aa375728(VS.85).aspx) in your ACL. New ones are sometimes not doceumented well, check the latest Platform SDK... |
60,438 | <p>I am using jQuery. I call a JavaScript function with next html:</p>
<pre><code><li><span><a href="javascript:uncheckEl('tagVO-$id')">$tagname</a></span></li>
</code></pre>
<p>I would like to remove the <code>li</code> element and I thought this would be easy with the <code>$(thi... | [
{
"answer_id": 60449,
"author": "Till",
"author_id": 2859,
"author_profile": "https://Stackoverflow.com/users/2859",
"pm_score": 3,
"selected": true,
"text": "<p>Try something like this (e.g. to hide the <code><li></code>):</p>\n\n<pre><code>function unCheckEl(id, ref) {\n (...)\n... | 2008/09/13 | [
"https://Stackoverflow.com/questions/60438",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2138/"
] | I am using jQuery. I call a JavaScript function with next html:
```
<li><span><a href="javascript:uncheckEl('tagVO-$id')">$tagname</a></span></li>
```
I would like to remove the `li` element and I thought this would be easy with the `$(this)` object. This is my JavaScript function:
```
function uncheckEl(id) {
... | Try something like this (e.g. to hide the `<li>`):
```
function unCheckEl(id, ref) {
(...)
$(ref).parent().parent().hide(); // this should be your <li>
}
```
And your link:
```
<a href="javascript:uncheckEl('tagVO-$id', \$(this))">
```
`$(this)` is not present inside your function, because how is it supposed ... |
60,455 | <p>Is it possible to to take a screenshot of a webpage with JavaScript and then submit that back to the server?</p>
<p>I'm not so concerned with browser security issues. etc. as the implementation would be for <a href="http://msdn.microsoft.com/en-us/library/ms536471(vs.85).aspx" rel="noreferrer">HTA</a>. But is it po... | [
{
"answer_id": 60471,
"author": "Till",
"author_id": 2859,
"author_profile": "https://Stackoverflow.com/users/2859",
"pm_score": 1,
"selected": false,
"text": "<p>You can achieve that using HTA and <a href=\"http://en.wikipedia.org/wiki/VBScript\" rel=\"nofollow noreferrer\">VBScript</a>... | 2008/09/13 | [
"https://Stackoverflow.com/questions/60455",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1915/"
] | Is it possible to to take a screenshot of a webpage with JavaScript and then submit that back to the server?
I'm not so concerned with browser security issues. etc. as the implementation would be for [HTA](http://msdn.microsoft.com/en-us/library/ms536471(vs.85).aspx). But is it possible? | I have done this for an HTA by using an ActiveX control. It was pretty easy to build the control in VB6 to take the screenshot. I had to use the keybd\_event API call because SendKeys can't do PrintScreen. Here's the code for that:
```
Declare Sub keybd_event Lib "user32" _
(ByVal bVk As Byte, ByVal bScan As Byte, ByV... |
60,456 | <p>I have this in a page :</p>
<pre><code><textarea id="taEditableContent" runat="server" rows="5"></textarea>
<ajaxToolkit:DynamicPopulateExtender ID="dpeEditPopulate" runat="server" TargetControlID="taEditableContent"
ClearContentsDuringUpdate="true" PopulateTriggerControlID="hLink" ServicePat... | [
{
"answer_id": 60490,
"author": "Ricky Supit",
"author_id": 4191,
"author_profile": "https://Stackoverflow.com/users/4191",
"pm_score": 0,
"selected": false,
"text": "<p>Try to add the following style on textarea: <strong>style=\"white-space: pre\"</strong></p>\n"
},
{
"answer_id... | 2008/09/13 | [
"https://Stackoverflow.com/questions/60456",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3263/"
] | I have this in a page :
```
<textarea id="taEditableContent" runat="server" rows="5"></textarea>
<ajaxToolkit:DynamicPopulateExtender ID="dpeEditPopulate" runat="server" TargetControlID="taEditableContent"
ClearContentsDuringUpdate="true" PopulateTriggerControlID="hLink" ServicePath="/Content.asmx"
Ser... | The problem is that the white space is ignored by default when the XML is processed. Try to add the `xml:space="preserve"` attribute to the string element. You'll also need to define the xml prefix as `xmlns:xml="http://www.w3.org/XML/1998/namespace"`. |
60,470 | <p>If I'm running a signed Java applet. Can I load additional classes from remote sources, in the same domain or maybe even the same host, and run them?</p>
<p>I'd like to do this without changing pages or even stopping the current applet. Of course, the total size of all classes is too large to load them all at once.... | [
{
"answer_id": 60574,
"author": "John Smithers",
"author_id": 1069,
"author_profile": "https://Stackoverflow.com/users/1069",
"pm_score": 0,
"selected": false,
"text": "<p>Sounds like it should be possible (but I've never done it). Have you already had a look at Remote Method Invocation ... | 2008/09/13 | [
"https://Stackoverflow.com/questions/60470",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | If I'm running a signed Java applet. Can I load additional classes from remote sources, in the same domain or maybe even the same host, and run them?
I'd like to do this without changing pages or even stopping the current applet. Of course, the total size of all classes is too large to load them all at once.
Is there... | I think classes are lazy loaded in applets. being loaded on demand.
Anyway, if the classes are outside of a jar you can simply use the applet classloader and load them by name. Ex:
```
ClassLoader loader = this.getClass().getClassLoader();
Class clazz = loader.loadClass("acme.AppletAddon");
```
If you want to load ... |
60,507 | <p>Say I have:</p>
<pre><code>void Render(void(*Call)())
{
D3dDevice->BeginScene();
Call();
D3dDevice->EndScene();
D3dDevice->Present(0,0,0,0);
}
</code></pre>
<p>This is fine as long as the function I want to use to render is a function or a <code>static</code> member function:</p>
<pre><co... | [
{
"answer_id": 60512,
"author": "mweerden",
"author_id": 4285,
"author_profile": "https://Stackoverflow.com/users/4285",
"pm_score": 2,
"selected": false,
"text": "<p>You can make a wrapper function <code>void Wrap(T *t)</code> that just calls <code>t->Call()</code> and have <code>Ren... | 2008/09/13 | [
"https://Stackoverflow.com/questions/60507",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6266/"
] | Say I have:
```
void Render(void(*Call)())
{
D3dDevice->BeginScene();
Call();
D3dDevice->EndScene();
D3dDevice->Present(0,0,0,0);
}
```
This is fine as long as the function I want to use to render is a function or a `static` member function:
```
Render(MainMenuRender);
Render(MainMenu::Render);
```... | There are a lot of ways to skin this cat, including templates. My favorite is [Boost.function](http://www.boost.org/doc/libs/1_36_0/doc/html/function.html) as I've found it to be the most flexible in the long run. Also read up on [Boost.bind](http://www.boost.org/doc/libs/1_36_0/libs/bind/bind.html) for binding to memb... |
60,558 | <p>I need to do some emulation of some old DOS or mainframe terminals in Flex. Something like the image below for example.</p>
<p><img src="https://i.stack.imgur.com/qFtvP.png" alt="alt text"></p>
<p>The different coloured text is easy enough, but the ability to do different background colours, such as the yellow bac... | [
{
"answer_id": 60564,
"author": "Adam Davis",
"author_id": 2915,
"author_profile": "https://Stackoverflow.com/users/2915",
"pm_score": 1,
"selected": false,
"text": "<p>The font is fixed width and height, so making a background bitmap dynamically isn't difficult, and is probably the quic... | 2008/09/13 | [
"https://Stackoverflow.com/questions/60558",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6277/"
] | I need to do some emulation of some old DOS or mainframe terminals in Flex. Something like the image below for example.

The different coloured text is easy enough, but the ability to do different background colours, such as the yellow background is beyond the capabilit... | Use [`TextField.getCharBoundaries`](http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/text/TextField.html) to get a rectangle of the first and last characters in the areas where you want a background. From these rectangles you can construct a rectangle that spans the whole area. Use this to draw the backg... |
60,570 | <p>Backgrounder:</p>
<p>The <a href="http://en.wikipedia.org/wiki/Opaque_pointer" rel="noreferrer">PIMPL Idiom</a> (Pointer to IMPLementation) is a technique for implementation hiding in which a public class wraps a structure or class that cannot be seen outside the library the public class is part of.</p>
<p>This hi... | [
{
"answer_id": 60575,
"author": "Phil Wright",
"author_id": 6276,
"author_profile": "https://Stackoverflow.com/users/6276",
"pm_score": 2,
"selected": false,
"text": "<p>Placing the call to the impl->Purr inside the .cpp file means that in the future you could do something completely ... | 2008/09/13 | [
"https://Stackoverflow.com/questions/60570",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/445087/"
] | Backgrounder:
The [PIMPL Idiom](http://en.wikipedia.org/wiki/Opaque_pointer) (Pointer to IMPLementation) is a technique for implementation hiding in which a public class wraps a structure or class that cannot be seen outside the library the public class is part of.
This hides internal implementation details and data ... | * Because you want `Purr()` to be able to use private members of `CatImpl`. `Cat::Purr()` would not be allowed such an access without a `friend` declaration.
* Because you then don't mix responsibilities: one class implements, one class forwards. |
60,573 | <p>Using C# .NET 2.0, I have a composite data class that does have the <code>[Serializable]</code> attribute on it. I am creating an <code>XMLSerializer</code> class and passing that into the constructor:</p>
<pre><code>XmlSerializer serializer = new XmlSerializer(typeof(DataClass));
</code></pre>
<p>I am getting an... | [
{
"answer_id": 60581,
"author": "Lamar",
"author_id": 3566,
"author_profile": "https://Stackoverflow.com/users/3566",
"pm_score": 10,
"selected": true,
"text": "<p>Look at the inner exception that you are getting. It will tell you which field/property it is having trouble serializing. ... | 2008/09/13 | [
"https://Stackoverflow.com/questions/60573",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4653/"
] | Using C# .NET 2.0, I have a composite data class that does have the `[Serializable]` attribute on it. I am creating an `XMLSerializer` class and passing that into the constructor:
```
XmlSerializer serializer = new XmlSerializer(typeof(DataClass));
```
I am getting an exception saying:
>
> There was an error refl... | Look at the inner exception that you are getting. It will tell you which field/property it is having trouble serializing.
You can exclude fields/properties from xml serialization by decorating them with the [`[XmlIgnore]`](https://learn.microsoft.com/en-us/dotnet/api/system.xml.serialization.xmlignoreattribute) attri... |
60,585 | <p>I'm running PHP, Apache, and Windows. I do not have a domain setup, so I would like my website's forms-based authentication to use the local user accounts database built in to Windows (I think it's called SAM).</p>
<p>I know that if Active Directory is setup, you can use the PHP LDAP module to connect and authenti... | [
{
"answer_id": 61062,
"author": "Allain Lalonde",
"author_id": 2443,
"author_profile": "https://Stackoverflow.com/users/2443",
"pm_score": 0,
"selected": false,
"text": "<p>Good Question!</p>\n\n<p>I've given this some thought... and I can't think of a good solution. What I can think of... | 2008/09/13 | [
"https://Stackoverflow.com/questions/60585",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2581/"
] | I'm running PHP, Apache, and Windows. I do not have a domain setup, so I would like my website's forms-based authentication to use the local user accounts database built in to Windows (I think it's called SAM).
I know that if Active Directory is setup, you can use the PHP LDAP module to connect and authenticate in you... | I haven't found a simple solution either. There are examples using CreateObject and the WinNT ADSI provider. But eventually they all bump into [User authentication issues with the Active Directory Service Interfaces WinNT provider](http://support.microsoft.com/kb/218497). I'm not 100% sure but I *guess* the WSH/network... |
60,590 | <p>On a PHP-based web site, I want to send users a download package after they have filled out a short form. The site-initiated download should be similar to sites like download.com, which say "your download will begin in a moment."</p>
<p>A couple of <strong>possible approaches</strong> I know about, and browser comp... | [
{
"answer_id": 60598,
"author": "aib",
"author_id": 1088,
"author_profile": "https://Stackoverflow.com/users/1088",
"pm_score": 0,
"selected": false,
"text": "<p>How about changing the location to point to the new file? (e.g. by changing window.location)</p>\n"
},
{
"answer_id": ... | 2008/09/13 | [
"https://Stackoverflow.com/questions/60590",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4376/"
] | On a PHP-based web site, I want to send users a download package after they have filled out a short form. The site-initiated download should be similar to sites like download.com, which say "your download will begin in a moment."
A couple of **possible approaches** I know about, and browser compatibility (based on a q... | You can also do a meta refresh, which most browsers support. Download.com places one in a noscript tag.
```
<meta http-equiv="refresh" content="5;url=/download.php?doc=123.zip"/>
``` |
60,607 | <p>What are the pros/cons of doing either way. Is there One Right Way(tm) ?</p>
| [
{
"answer_id": 60631,
"author": "Nick Stinemates",
"author_id": 4960,
"author_profile": "https://Stackoverflow.com/users/4960",
"pm_score": 2,
"selected": false,
"text": "<p>It depends on the situation. I tend to use Exceptions when I am writing business logic/application internals, and ... | 2008/09/13 | [
"https://Stackoverflow.com/questions/60607",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | What are the pros/cons of doing either way. Is there One Right Way(tm) ? | If you want to use exceptions instead of errors for your entire application, you can do it with [ErrorException](http://php.net/ErrorException) and a custom error handler (see the ErrorException page for a sample error handler). The only downside to this method is that non-fatal errors will still throw exceptions, whic... |
60,645 | <p>Is it possible to use overlapped I/O with an anonymous pipe? CreatePipe() does not have any way of specifying FILE_FLAG_OVERLAPPED, so I assume ReadFile() will block, even if I supply an OVERLAPPED-structure. </p>
| [
{
"answer_id": 60681,
"author": "ChrisN",
"author_id": 3853,
"author_profile": "https://Stackoverflow.com/users/3853",
"pm_score": 4,
"selected": false,
"text": "<p>No. As explained <a href=\"http://msdn.microsoft.com/en-us/library/aa365141%28VS.85%29.aspx\" rel=\"noreferrer\">here</a>, ... | 2008/09/13 | [
"https://Stackoverflow.com/questions/60645",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3923/"
] | Is it possible to use overlapped I/O with an anonymous pipe? CreatePipe() does not have any way of specifying FILE\_FLAG\_OVERLAPPED, so I assume ReadFile() will block, even if I supply an OVERLAPPED-structure. | Here is an implementation for an anonymous pipe function with the possibility to specify FILE\_FLAG\_OVERLAPPED:
```
/******************************************************************************\
* This is a part of the Microsoft Source Code Samples.
* Copyright 1995 - 1997 Microsoft Corporation.
* ... |
60,653 | <p>Is global memory initialized in C++? And if so, how?</p>
<p>(Second) clarification:</p>
<p>When a program starts up, what is in the memory space which will become global memory, prior to primitives being initialized? I'm trying to understand if it is zeroed out, or garbage for example.</p>
<p>The situation is: ca... | [
{
"answer_id": 60655,
"author": "Brian R. Bondy",
"author_id": 3153,
"author_profile": "https://Stackoverflow.com/users/3153",
"pm_score": 4,
"selected": true,
"text": "<p>Yes global primitives are initialized to NULL.</p>\n\n<p>Example:</p>\n\n<pre><code>int x;\n\nint main(int argc, cha... | 2008/09/13 | [
"https://Stackoverflow.com/questions/60653",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2167252/"
] | Is global memory initialized in C++? And if so, how?
(Second) clarification:
When a program starts up, what is in the memory space which will become global memory, prior to primitives being initialized? I'm trying to understand if it is zeroed out, or garbage for example.
The situation is: can a singleton reference ... | Yes global primitives are initialized to NULL.
Example:
```
int x;
int main(int argc, char**argv)
{
assert(x == 0);
int y;
//assert(y == 0); <-- wrong can't assume this.
}
```
You cannot make any assumptions about classes, structs, arrays, blocks of memory on the heap...
It's safest just to always initializ... |
60,664 | <p>is it possible to display ⇓ entity in ie6? It is being display in every browser but not IE 6.I am writing markup such as: </p>
<pre><code><span>&#8659;</span>
</code></pre>
| [
{
"answer_id": 60679,
"author": "ConroyP",
"author_id": 2287,
"author_profile": "https://Stackoverflow.com/users/2287",
"pm_score": 4,
"selected": true,
"text": "<p>According to <a href=\"https://web.archive.org/web/20080221144246/http://www.ackadia.com:80/web-design/character-code/chara... | 2008/09/13 | [
"https://Stackoverflow.com/questions/60664",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2138/"
] | is it possible to display ⇓ entity in ie6? It is being display in every browser but not IE 6.I am writing markup such as:
```
<span>⇓</span>
``` | According to [this page](https://web.archive.org/web/20080221144246/http://www.ackadia.com:80/web-design/character-code/character-code-symbols.php), that symbol doesn't show in IE6 at all.
```
Symbol Character Numeric Description
⇓ ⇓ ⇓ Down double arrow - - * Doesn't show with MS IE6
```
I... |
60,672 | <p>I want to implement an ISAPI filter like feature using HttpModule in IIS7 running under IIS Integrated Request Processing Pipeline mode.</p>
<p>The goal is to look at the incoming request at the Web Server level, and inject some custom HttpHeaders into the request. <code>(for ex: HTTP\_EAUTH\_ID)</code></p>
<p>And... | [
{
"answer_id": 60696,
"author": "Joel Martinez",
"author_id": 5416,
"author_profile": "https://Stackoverflow.com/users/5416",
"pm_score": 0,
"selected": false,
"text": "<p>I believe the server variables list only contains the headers sent from the browser to the server.</p>\n"
},
{
... | 2008/09/13 | [
"https://Stackoverflow.com/questions/60672",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1647/"
] | I want to implement an ISAPI filter like feature using HttpModule in IIS7 running under IIS Integrated Request Processing Pipeline mode.
The goal is to look at the incoming request at the Web Server level, and inject some custom HttpHeaders into the request. `(for ex: HTTP\_EAUTH\_ID)`
And later in the page lifecycle... | [HttpRequest.ServerVariables](http://msdn.microsoft.com/en-us/library/system.web.httprequest.servervariables.aspx) Property is a read-only collection. So, you cannot directly modify that. I would suggest storing your custom data in [httpcontext](http://www.odetocode.com/Articles/111.aspx) (or global application object ... |
60,673 | <p>What guidelines do you follow to improve the general quality of your code? Many people have rules about how to write C++ code that (supposedly) make it harder to make mistakes. I've seen people <em>insist</em> that every <code>if</code> statement is followed by a brace block (<code>{...}</code>).</p>
<p>I'm interes... | [
{
"answer_id": 60682,
"author": "DShook",
"author_id": 370,
"author_profile": "https://Stackoverflow.com/users/370",
"pm_score": 0,
"selected": false,
"text": "<p>make sure you indent properly</p>\n"
},
{
"answer_id": 60687,
"author": "MP24",
"author_id": 6206,
"autho... | 2008/09/13 | [
"https://Stackoverflow.com/questions/60673",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1304/"
] | What guidelines do you follow to improve the general quality of your code? Many people have rules about how to write C++ code that (supposedly) make it harder to make mistakes. I've seen people *insist* that every `if` statement is followed by a brace block (`{...}`).
I'm interested in what guidelines other people fol... | A few of my personal favorites:
Strive to write code that is [const correct](http://www.parashift.com/c++-faq-lite/const-correctness.html). You will enlist the compiler to help weed out easy to fix but sometimes painful bugs. Your code will also tell a story of what you had in mind at the time you wrote it -- valuable... |
60,680 | <p>I'm writing a small web server in Python, using BaseHTTPServer and a custom subclass of BaseHTTPServer.BaseHTTPRequestHandler. Is it possible to make this listen on more than one port?</p>
<p>What I'm doing now:</p>
<pre><code>class MyRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
def doGET
[...]
clas... | [
{
"answer_id": 60753,
"author": "Eli Courtwright",
"author_id": 1694,
"author_profile": "https://Stackoverflow.com/users/1694",
"pm_score": 6,
"selected": true,
"text": "<p>Sure; just start two different servers on two different ports in two different threads that each use the same handl... | 2008/09/13 | [
"https://Stackoverflow.com/questions/60680",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4321/"
] | I'm writing a small web server in Python, using BaseHTTPServer and a custom subclass of BaseHTTPServer.BaseHTTPRequestHandler. Is it possible to make this listen on more than one port?
What I'm doing now:
```
class MyRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
def doGET
[...]
class ThreadingHTTPServer... | Sure; just start two different servers on two different ports in two different threads that each use the same handler. Here's a complete, working example that I just wrote and tested. If you run this code then you'll be able to get a Hello World webpage at both <http://localhost:1111/> and <http://localhost:2222/>
```... |
60,683 | <p>Can you have a multicolumn listview control where one of the columns is a checkbox? Example code or links would be greatly appreciated.</p>
<p>I am using visual studio 2005</p>
| [
{
"answer_id": 60695,
"author": "Winter",
"author_id": 6227,
"author_profile": "https://Stackoverflow.com/users/6227",
"pm_score": 4,
"selected": true,
"text": "<p>Allan Anderson created a custom control to let you do this.\nYou can find it here: <a href=\"http://www.codeproject.com/KB/l... | 2008/09/13 | [
"https://Stackoverflow.com/questions/60683",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4653/"
] | Can you have a multicolumn listview control where one of the columns is a checkbox? Example code or links would be greatly appreciated.
I am using visual studio 2005 | Allan Anderson created a custom control to let you do this.
You can find it here: <http://www.codeproject.com/KB/list/aa_listview.aspx>
Here's some example code for that control:
```
GlacialList mylist = new GlacialList();
mylist.Columns.Add( "Column1", 100 ); // this can also be added
// through the... |
60,684 | <p><strong><em>Edit:</em></strong> This question had been tagged "Tolstoy" in appreciation of the quality and length of my writing:) Just reading the first and the last paragraph should be enough:) If you tend to select and move code with the mouse, the stuff in middle could be interesting to you.</p>
<p>This questio... | [
{
"answer_id": 60697,
"author": "jfs",
"author_id": 4279,
"author_profile": "https://Stackoverflow.com/users/4279",
"pm_score": 2,
"selected": false,
"text": "<p>In Emacs:</p>\n\n<ul>\n<li>kill-line C-k </li>\n<li>transpose-lines C-x C-t</li>\n</ul>\n\n<p>C-a C-k C-k -- kill whole line i... | 2008/09/13 | [
"https://Stackoverflow.com/questions/60684",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6103/"
] | ***Edit:*** This question had been tagged "Tolstoy" in appreciation of the quality and length of my writing:) Just reading the first and the last paragraph should be enough:) If you tend to select and move code with the mouse, the stuff in middle could be interesting to you.
This question is about how you use text edi... | In Emacs:
* kill-line C-k
* transpose-lines C-x C-t
C-a C-k C-k -- kill whole line including newline (or `kill-whole-line` by C-S-backspace).
C-u <number> C-k -- kill <number> of lines (including newlines).
C-y -- yank back the most recently killed text (aka paste) |
60,685 | <p>What follows is a regular expression I have written to match multi-line pre-processor macros in C / C++ code. I'm by no means a regular expressions guru, so I'd welcome any advice on how I can make this better.</p>
<p>Here's the regex:</p>
<pre><code>\s*#define(.*\\\n)+[\S]+(?!\\)
</code></pre>
<p>It should match... | [
{
"answer_id": 60723,
"author": "Douglas Leeder",
"author_id": 3978,
"author_profile": "https://Stackoverflow.com/users/3978",
"pm_score": 4,
"selected": true,
"text": "<p>This is a simple test program I knocked up:</p>\n\n<pre><code>#!/usr/bin/env python\n\nTEST1=\"\"\"\n#include \"Foo.... | 2008/09/13 | [
"https://Stackoverflow.com/questions/60685",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1304/"
] | What follows is a regular expression I have written to match multi-line pre-processor macros in C / C++ code. I'm by no means a regular expressions guru, so I'd welcome any advice on how I can make this better.
Here's the regex:
```
\s*#define(.*\\\n)+[\S]+(?!\\)
```
It should match all of this:
```
#define foo(x)... | This is a simple test program I knocked up:
```
#!/usr/bin/env python
TEST1="""
#include "Foo.h"
#define bar foo\\
x
#include "Bar.h"
"""
TEST2="""
#define bar foo
#define x 1 \\
12 \\
2 \\\\ 3
Foobar
"""
TEST3="""
#define foo(x) if(x) \\
doSomething(x)
"""
TEST4="""
#define foo(x) if(x) \\
doSomething... |
60,736 | <p>I have a laptop running Ubuntu that I would like to act as a Subversion server. Both for myself to commit to locally, and for others remotely. What are the steps required to get this working? Please include steps to:</p>
<ul>
<li>Get and configure Apache, and necessary modules (I know there are other ways to create... | [
{
"answer_id": 60741,
"author": "UnkwnTech",
"author_id": 115,
"author_profile": "https://Stackoverflow.com/users/115",
"pm_score": -1,
"selected": false,
"text": "<p>For Apache:</p>\n\n<pre><code>sudo apt-get -yq install apache2\n</code></pre>\n\n<p>For SSH:</p>\n\n<pre><code>sudo apt-g... | 2008/09/13 | [
"https://Stackoverflow.com/questions/60736",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4120/"
] | I have a laptop running Ubuntu that I would like to act as a Subversion server. Both for myself to commit to locally, and for others remotely. What are the steps required to get this working? Please include steps to:
* Get and configure Apache, and necessary modules (I know there are other ways to create a SVN server,... | Steps I've taken to make my laptop a Subversion server. Credit must go to [AlephZarro](http://alephzarro.com/blog/) for his directions [here](http://alephzarro.com/blog/2007/01/07/installation-of-subversion-on-ubuntu-with-apache-ssl-and-basicauth/). I now have a working SVN server (which has currently only been tested ... |
60,751 | <p>Currently my app uses just Direct3D9 for graphics, however in the future I' m planning to extend this to D3D10 and possibly OpenGL. The question is how can I do this in a tidy way?</p>
<p>At present there are various Render methods in my code</p>
<pre><code>void Render(boost::function<void()> &Call)
{
... | [
{
"answer_id": 60790,
"author": "Tobi",
"author_id": 5422,
"author_profile": "https://Stackoverflow.com/users/5422",
"pm_score": 4,
"selected": true,
"text": "<p>Define an interface that is sufficient for your application's graphic output demands. Then implement this interface for every ... | 2008/09/13 | [
"https://Stackoverflow.com/questions/60751",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6266/"
] | Currently my app uses just Direct3D9 for graphics, however in the future I' m planning to extend this to D3D10 and possibly OpenGL. The question is how can I do this in a tidy way?
At present there are various Render methods in my code
```
void Render(boost::function<void()> &Call)
{
D3dDevice->BeginScene();
... | Define an interface that is sufficient for your application's graphic output demands. Then implement this interface for every renderer you want to support.
```
class IRenderer {
public:
virtual ~IRenderer() {}
virtual void RenderModel(CModel* model) = 0;
virtual void DrawScreenQuad(int x1, int y1, int x2... |
60,764 | <p>Why is it so hard to do this in Java? If you want to have any kind of module system you need to be able to load JAR files dynamically. I'm told there's a way of doing it by writing your own <code>ClassLoader</code>, but that's a lot of work for something that should (in my mind at least) be as easy as calling a meth... | [
{
"answer_id": 60766,
"author": "Allain Lalonde",
"author_id": 2443,
"author_profile": "https://Stackoverflow.com/users/2443",
"pm_score": 7,
"selected": false,
"text": "<p>The following solution is hackish, as it uses reflection to bypass encapsulation, but it works flawlessly:</p>\n\n<... | 2008/09/13 | [
"https://Stackoverflow.com/questions/60764",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2443/"
] | Why is it so hard to do this in Java? If you want to have any kind of module system you need to be able to load JAR files dynamically. I'm told there's a way of doing it by writing your own `ClassLoader`, but that's a lot of work for something that should (in my mind at least) be as easy as calling a method with a JAR ... | The reason it's hard is security. Classloaders are meant to be immutable; you shouldn't be able to willy-nilly add classes to it at runtime. I'm actually very surprised that works with the system classloader. Here's how you do it making your own child classloader:
```
URLClassLoader child = new URLClassLoader(
... |
60,768 | <p>I am trying to dynamicaly compile code using CodeDom. I can load other assemblies, but I cannot load System.Data.Linq.dll. I get an error:</p>
<p>Metadata file 'System.Data.Linq.dll' could not be found</p>
<p>My code looks like:</p>
<pre><code>CompilerParameters compilerParams = new CompilerParameters();
compile... | [
{
"answer_id": 60781,
"author": "Curt Hagenlocher",
"author_id": 533,
"author_profile": "https://Stackoverflow.com/users/533",
"pm_score": 3,
"selected": true,
"text": "<p>That may be because this assembly is stored in a different location than mscorlib is. It should work if you provide... | 2008/09/13 | [
"https://Stackoverflow.com/questions/60768",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5189/"
] | I am trying to dynamicaly compile code using CodeDom. I can load other assemblies, but I cannot load System.Data.Linq.dll. I get an error:
Metadata file 'System.Data.Linq.dll' could not be found
My code looks like:
```
CompilerParameters compilerParams = new CompilerParameters();
compilerParams.CompilerOptions = "/t... | That may be because this assembly is stored in a different location than mscorlib is. It should work if you provide a full path to the assembly. The most convenient way to get the full path is to let the .NET loader do the work for you. I would try something like this:
```
compilerParams.ReferencedAssemblies.Add(typeo... |
60,779 | <p>Trying to do this sort of thing...</p>
<pre><code>WHERE username LIKE '%$str%'
</code></pre>
<p>...but using bound parameters to prepared statements in PDO. e.g.:</p>
<pre><code>$query = $db->prepare("select * from comments where comment like :search");
$query->bindParam(':search', $str);
$query->execute... | [
{
"answer_id": 60782,
"author": "Polsonby",
"author_id": 137,
"author_profile": "https://Stackoverflow.com/users/137",
"pm_score": 5,
"selected": true,
"text": "<p>Ah. Found a comment on php.net that reminded me of the answer; you need to wildcard your value before the bindParam is evalu... | 2008/09/13 | [
"https://Stackoverflow.com/questions/60779",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/137/"
] | Trying to do this sort of thing...
```
WHERE username LIKE '%$str%'
```
...but using bound parameters to prepared statements in PDO. e.g.:
```
$query = $db->prepare("select * from comments where comment like :search");
$query->bindParam(':search', $str);
$query->execute();
```
I've tried numerous permutations of ... | Ah. Found a comment on php.net that reminded me of the answer; you need to wildcard your value before the bindParam is evaluated, and not worry about quoting it. So for example this works fine:
```
$str = "%$str%";
$query = $db->prepare("select * from comments where comment like :search");
$query->bindParam(':search',... |
60,785 | <p>How can I show a grey transparent overlay in C#?<br>
It should overlay other process which are not owned by the application doing the overlay.</p>
| [
{
"answer_id": 60782,
"author": "Polsonby",
"author_id": 137,
"author_profile": "https://Stackoverflow.com/users/137",
"pm_score": 5,
"selected": true,
"text": "<p>Ah. Found a comment on php.net that reminded me of the answer; you need to wildcard your value before the bindParam is evalu... | 2008/09/13 | [
"https://Stackoverflow.com/questions/60785",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44972/"
] | How can I show a grey transparent overlay in C#?
It should overlay other process which are not owned by the application doing the overlay. | Ah. Found a comment on php.net that reminded me of the answer; you need to wildcard your value before the bindParam is evaluated, and not worry about quoting it. So for example this works fine:
```
$str = "%$str%";
$query = $db->prepare("select * from comments where comment like :search");
$query->bindParam(':search',... |
60,802 | <p>I'm having trouble ordering by more than one field in my Linq to NHibernate query. Does anyone either know what might be wrong or if there is a work around?</p>
<p>Code:</p>
<pre><code>IQueryable<AgendaItem> items = _agendaRepository.GetAgendaItems(location)
.Where(item => item.Minutes.Contains(query) ... | [
{
"answer_id": 61081,
"author": "John Boker",
"author_id": 2847,
"author_profile": "https://Stackoverflow.com/users/2847",
"pm_score": 0,
"selected": false,
"text": "<p>although i dont think it'd make a difference, what happens if you do your linq like this:</p>\n\n<p>(from i in items or... | 2008/09/13 | [
"https://Stackoverflow.com/questions/60802",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2595/"
] | I'm having trouble ordering by more than one field in my Linq to NHibernate query. Does anyone either know what might be wrong or if there is a work around?
Code:
```
IQueryable<AgendaItem> items = _agendaRepository.GetAgendaItems(location)
.Where(item => item.Minutes.Contains(query) || item.Description.Contains(q... | This looks to me like a bug with Linq to NHybernate. One possible workaround is to convert to an array before sorting. A potentially big downside is that you can't limit the results using Skip() and Take() before enumerating, so this may not be sufficient for you.
```
var results = items
.ToArray()
.OrderBy(item... |
60,805 | <p>How do I select one or more random rows from a table using SQLAlchemy? </p>
| [
{
"answer_id": 60811,
"author": "Fire Lancer",
"author_id": 6266,
"author_profile": "https://Stackoverflow.com/users/6266",
"pm_score": -1,
"selected": false,
"text": "<p>Theres a couple of ways through SQL, depending on which data base is being used.</p>\n\n<p>(I think SQLAlchemy can us... | 2008/09/13 | [
"https://Stackoverflow.com/questions/60805",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1448/"
] | How do I select one or more random rows from a table using SQLAlchemy? | This is very much a database-specific issue.
I know that PostgreSQL, SQLite, MySQL, and Oracle have the ability to order by a random function, so you can use this in SQLAlchemy:
```
from sqlalchemy.sql.expression import func, select
select.order_by(func.random()) # for PostgreSQL, SQLite
select.order_by(func.rand(... |
60,820 | <p>Does anyone know of a way to find out how much memory an instance of an object is taking?</p>
<p>For example, if I have an instance of the following object:</p>
<pre><code>TestClass tc = new TestClass();
</code></pre>
<p>Is there a way to find out how much memory the instance <code>tc</code> is taking?</p>
<p>Th... | [
{
"answer_id": 60829,
"author": "Lars Truijens",
"author_id": 1242,
"author_profile": "https://Stackoverflow.com/users/1242",
"pm_score": 2,
"selected": false,
"text": "<p>I have good experiences with <a href=\"http://memprofiler.com/\" rel=\"nofollow noreferrer\">MemProfiler</a>. It giv... | 2008/09/13 | [
"https://Stackoverflow.com/questions/60820",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6301/"
] | Does anyone know of a way to find out how much memory an instance of an object is taking?
For example, if I have an instance of the following object:
```
TestClass tc = new TestClass();
```
Is there a way to find out how much memory the instance `tc` is taking?
The reason for asking, is that although C# has built ... | If you are not trying to do it in code itself, which I'm assuming based on your ANTS reference, try taking a look at CLRProfiler (currently v2.0). It's free and if you don't mind the rather simplistic UI, it can provide valuable information. It will give you a in-depth overview of all kinds of stats. I used it a while ... |
60,825 | <p>I am working on a web application, where I transfer data from the server to the browser in XML.</p>
<p>Since I'm danish, I quickly run into problems with the characters <code>æøå</code>.</p>
<p>I know that in html, I use the <code>"&amp;aelig;&amp;oslash;&amp;aring;"</code> for <code>æøå</code>.</p>
<... | [
{
"answer_id": 60832,
"author": "chryss",
"author_id": 5169,
"author_profile": "https://Stackoverflow.com/users/5169",
"pm_score": 0,
"selected": false,
"text": "<p>This works as expected for me:</p>\n\n<pre><code>alert(\"&aelig;&oslash;&aring;\");\n</code></pre>\n\n<p>... cr... | 2008/09/13 | [
"https://Stackoverflow.com/questions/60825",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1090/"
] | I am working on a web application, where I transfer data from the server to the browser in XML.
Since I'm danish, I quickly run into problems with the characters `æøå`.
I know that in html, I use the `"&aelig;&oslash;&aring;"` for `æøå`.
however, as soon as the chars pass through JavaScript, I get black ... | Just specifying UTF-8 in the header is not enough. I'd bet you haven't saved your file as UTF-8. Any reasonably advanced text editor will have this option. Try that and I'm sure it'll work! |
60,874 | <p>I know a few advanced ways, to change directories. <code>pushd</code> and <code>popd</code> (directory stack) or <code>cd -</code> (change to last directory).</p>
<p>But I am looking for quick way to achieve the following:</p>
<p>Say, I am in a rather deep dir:</p>
<pre><code>/this/is/a/very/deep/directory/struct... | [
{
"answer_id": 60887,
"author": "dF.",
"author_id": 3002,
"author_profile": "https://Stackoverflow.com/users/3002",
"pm_score": 4,
"selected": true,
"text": "<p>Do you mean that the path names are the same, and only one directory name changes (\"a\" becomes \"another\")? In that case:</p... | 2008/09/13 | [
"https://Stackoverflow.com/questions/60874",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1870/"
] | I know a few advanced ways, to change directories. `pushd` and `popd` (directory stack) or `cd -` (change to last directory).
But I am looking for quick way to achieve the following:
Say, I am in a rather deep dir:
```
/this/is/a/very/deep/directory/structure/with\ lot\ of\ nasty/names
```
and I want to switch to ... | Do you mean that the path names are the same, and only one directory name changes ("a" becomes "another")? In that case:
```
cd ${PWD/a/another}
```
will switch to the other directory. `$PWD` holds your current directory, and `${var/foo/bar}` gives you `$var` with the string 'foo' replaced by 'bar'. |
60,877 | <p>I have a query where I wish to retrieve the oldest X records. At present my query is something like the following:</p>
<pre><code>SELECT Id, Title, Comments, CreatedDate
FROM MyTable
WHERE CreatedDate > @OlderThanDate
ORDER BY CreatedDate DESC
</code></pre>
<p>I know that normally I would remove the 'DESC' key... | [
{
"answer_id": 60882,
"author": "Jason Punyon",
"author_id": 6212,
"author_profile": "https://Stackoverflow.com/users/6212",
"pm_score": 6,
"selected": true,
"text": "<p>Why not just use a subquery?</p>\n\n<pre><code>SELECT T1.* \nFROM\n(SELECT TOP X Id, Title, Comments, CreatedDate\nFRO... | 2008/09/13 | [
"https://Stackoverflow.com/questions/60877",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5086/"
] | I have a query where I wish to retrieve the oldest X records. At present my query is something like the following:
```
SELECT Id, Title, Comments, CreatedDate
FROM MyTable
WHERE CreatedDate > @OlderThanDate
ORDER BY CreatedDate DESC
```
I know that normally I would remove the 'DESC' keyword to switch the order of th... | Why not just use a subquery?
```
SELECT T1.*
FROM
(SELECT TOP X Id, Title, Comments, CreatedDate
FROM MyTable
WHERE CreatedDate > @OlderThanDate
ORDER BY CreatedDate) T1
ORDER BY CreatedDate DESC
``` |
60,893 | <p>In my application I have <code>TextBox</code> in a <code>FormView</code> bound to a <code>LinqDataSource</code> like so:</p>
<pre><code><asp:TextBox ID="MyTextBox" runat="server"
Text='<%# Bind("MyValue") %>' AutoPostBack="True"
ontextchanged="MyTextBox_TextChanged" />
prote... | [
{
"answer_id": 60902,
"author": "maccullt",
"author_id": 4945,
"author_profile": "https://Stackoverflow.com/users/4945",
"pm_score": 1,
"selected": false,
"text": "<p>I find Robert Martin's <a href=\"http://butunclebob.com/ArticleS.UncleBob.TheThreeRulesOfTdd\" rel=\"nofollow noreferrer\... | 2008/09/13 | [
"https://Stackoverflow.com/questions/60893",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/317/"
] | In my application I have `TextBox` in a `FormView` bound to a `LinqDataSource` like so:
```
<asp:TextBox ID="MyTextBox" runat="server"
Text='<%# Bind("MyValue") %>' AutoPostBack="True"
ontextchanged="MyTextBox_TextChanged" />
protected void MyTextBox_TextChanged(object sender, EventArgs e)... | There was an interesting discussion of Technical Debt based on your definition of done on HanselMinutes a couple of weeks ago -- [What is Done](http://www.hanselminutes.com/default.aspx?showID=137). The basics of the show were that if you re-define 'Done' to increase perceived velocity, then you will amass Technical De... |
60,910 | <p>I've recently had a need to do a bit of lisp editing and I found the nifty Ready Lisp package for OS X, which is great, except Aquamacs automatically uses a proportional font (which is idiotic, IMHO) and I want to change it to a monospace font. However, I'm not really much of an EMACS user, and the preferences menu ... | [
{
"answer_id": 60940,
"author": "Blair Conrad",
"author_id": 1199,
"author_profile": "https://Stackoverflow.com/users/1199",
"pm_score": 3,
"selected": false,
"text": "<p>From the <a href=\"http://www.emacswiki.org/cgi-bin/wiki/AquamacsFAQ#toc7\" rel=\"noreferrer\">EmacsWiki Aquamacs FAQ... | 2008/09/13 | [
"https://Stackoverflow.com/questions/60910",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/85/"
] | I've recently had a need to do a bit of lisp editing and I found the nifty Ready Lisp package for OS X, which is great, except Aquamacs automatically uses a proportional font (which is idiotic, IMHO) and I want to change it to a monospace font. However, I'm not really much of an EMACS user, and the preferences menu in ... | This is what I have in my .emacs for OS X:
```
(set-default-font "-apple-bitstream vera sans mono-medium-r-normal--0-0-0-0-m-0-mac-roman")
```
Now, I'm not sure Bitstream Vera comes standard on OS X, so you may have to either download it or choose a different font. You can search the X font names by running `(x-list... |
60,919 | <p>Can I use this approach efficiently?</p>
<pre><code>using(SqlCommand cmd = new SqlCommand("GetSomething", new SqlConnection(Config.ConnectionString))
{
cmd.Connection.Open();
// set up parameters and CommandType to StoredProcedure etc. etc.
cmd.ExecuteNonQuery();
}
</code></pre>
<p>My concern is : Will... | [
{
"answer_id": 60934,
"author": "Ryan Farley",
"author_id": 1627,
"author_profile": "https://Stackoverflow.com/users/1627",
"pm_score": 8,
"selected": true,
"text": "<p>No, Disposing of the <code>SqlCommand</code> will not effect the Connection. A better approach would be to also wrap th... | 2008/09/13 | [
"https://Stackoverflow.com/questions/60919",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1796/"
] | Can I use this approach efficiently?
```
using(SqlCommand cmd = new SqlCommand("GetSomething", new SqlConnection(Config.ConnectionString))
{
cmd.Connection.Open();
// set up parameters and CommandType to StoredProcedure etc. etc.
cmd.ExecuteNonQuery();
}
```
My concern is : Will the Dispose method of the... | No, Disposing of the `SqlCommand` will not effect the Connection. A better approach would be to also wrap the `SqlConnection` in a using block as well:
```
using (SqlConnection conn = new SqlConnection(connstring))
{
conn.Open();
using (SqlCommand cmd = new SqlCommand(cmdstring, conn))
{
cmd.Execu... |
60,942 | <p>I'd like to redirect the stdout of process proc1 to two processes proc2 and proc3:</p>
<pre><code> proc2 -> stdout
/
proc1
\
proc3 -> stdout
</code></pre>
<p>I tried</p>
<pre><code> proc1 | (proc2 & proc3)
</code></pre>
<p>but it doesn't seem to work, i.e.</p>
<pre><co... | [
{
"answer_id": 60955,
"author": "dF.",
"author_id": 3002,
"author_profile": "https://Stackoverflow.com/users/3002",
"pm_score": 8,
"selected": true,
"text": "<p><sup><em>Editor's note</em>:<br>\n - <code>>(…)</code> is a <a href=\"http://mywiki.wooledge.org/ProcessSubstitution\" rel=\... | 2008/09/13 | [
"https://Stackoverflow.com/questions/60942",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4085/"
] | I'd like to redirect the stdout of process proc1 to two processes proc2 and proc3:
```
proc2 -> stdout
/
proc1
\
proc3 -> stdout
```
I tried
```
proc1 | (proc2 & proc3)
```
but it doesn't seem to work, i.e.
```
echo 123 | (tr 1 a & tr 1 b)
```
writes
```
b23
```
to stdou... | *Editor's note*:
- `>(…)` is a [*process substitution*](http://mywiki.wooledge.org/ProcessSubstitution) that is a *nonstandard shell feature* of *some* POSIX-compatible shells: `bash`, `ksh`, `zsh`.
- This answer accidentally sends the output process substitution's output through the pipeline *too*: `echo 123 |... |
60,944 | <p>The below HTML/CSS/Javascript (jQuery) code displays the <code>#makes</code> select box. Selecting an option displays the <code>#models</code> select box with relevant options. The <code>#makes</code> select box sits off-center and the <code>#models</code> select box fills the empty space when it is displayed. </p>
... | [
{
"answer_id": 61009,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>Floating the select boxes changes their display properties to \"block\". If you have no reason to float them, simply remove ... | 2008/09/13 | [
"https://Stackoverflow.com/questions/60944",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2755/"
] | The below HTML/CSS/Javascript (jQuery) code displays the `#makes` select box. Selecting an option displays the `#models` select box with relevant options. The `#makes` select box sits off-center and the `#models` select box fills the empty space when it is displayed.
How do you style the form so that the `#makes` sel... | It's not entirely clear from your question what layout you're trying to achieve, but judging by that fact that you have applied "float:left" to the select elements, it looks like you want the select elements to appear side by side. If this is the case, you can achieve this by doing the following:
* To centrally align ... |
60,977 | <p>Sometimes I have to work on code that moves the computer clock forward. In this case some .cpp or .h files get their latest modification date set to the future time.</p>
<p>Later on, when my clock is fixed, and I compile my sources, system rebuilds most of the project because some of the latest modification dates a... | [
{
"answer_id": 60984,
"author": "Michael Neale",
"author_id": 699,
"author_profile": "https://Stackoverflow.com/users/699",
"pm_score": 0,
"selected": false,
"text": "<p>I don't use windows - but surely there is something like awk or grep that you can use to find the \"future\" timestamp... | 2008/09/13 | [
"https://Stackoverflow.com/questions/60977",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3153/"
] | Sometimes I have to work on code that moves the computer clock forward. In this case some .cpp or .h files get their latest modification date set to the future time.
Later on, when my clock is fixed, and I compile my sources, system rebuilds most of the project because some of the latest modification dates are in the ... | If this was my problem, I'd look for ways to avoid mucking with the system time. Isolating the code under unit tests, or a virtual machine, or something.
However, because I love [PowerShell](https://stackoverflow.com/questions/52487/the-most-amazing-pieces-of-software-in-the-world#53414):
```
Get-ChildItem -r . |
... |
61,000 | <p>I am wondering what directory structure are commonly used in development projects. I mean with the idea of facilitating builds, deploys release, and etc.</p>
<p>I recently used a <a href="http://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html" rel="nofollow noreferrer">Maven... | [
{
"answer_id": 61003,
"author": "Fernando Barrocal",
"author_id": 2274,
"author_profile": "https://Stackoverflow.com/users/2274",
"pm_score": 0,
"selected": false,
"text": "<p>I just found a interesting document about Directory structures on Zend website:<br>\n<a href=\"http://framework.... | 2008/09/14 | [
"https://Stackoverflow.com/questions/61000",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2274/"
] | I am wondering what directory structure are commonly used in development projects. I mean with the idea of facilitating builds, deploys release, and etc.
I recently used a [Maven structure](http://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html) for a java project, but I am not ... | After a couple years working with different structures I recently found a structure that hols most variations for me:
```
/project_name (everything goes here)
/web (htdocs)
/img
/css
/app (usually some framework or sensitive code)
/lib (externa libs)
/vendor_1
... |
61,002 | <p>I'd like to script, preferably in rake, the following actions into a single command:</p>
<ol>
<li>Get the version of my local git repository.</li>
<li>Git pull the latest code.</li>
<li>Git diff from the version I extracted in step #1 to what is now in my local repository.</li>
</ol>
<p>In other words, I want to g... | [
{
"answer_id": 61004,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 4,
"selected": false,
"text": "<p>This is very similar to a question I asked about <a href=\"https://stackoverflow.com/questions/53569/how-to-get-the-cha... | 2008/09/14 | [
"https://Stackoverflow.com/questions/61002",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4061/"
] | I'd like to script, preferably in rake, the following actions into a single command:
1. Get the version of my local git repository.
2. Git pull the latest code.
3. Git diff from the version I extracted in step #1 to what is now in my local repository.
In other words, I want to get the latest code form the central rep... | You could do this fairly simply with refspecs.
```
git pull origin
git diff @{1}..
```
That will give you a diff of the current branch as it existed before and after the pull. Note that if the pull doesn't actually update the current branch, the diff will give you the wrong results. Another option is to explicitly r... |
61,005 | <p>What are the best file permission settings for PHP scripts? Any suggestions on ways to figure out the minimum required permissions?</p>
| [
{
"answer_id": 61004,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 4,
"selected": false,
"text": "<p>This is very similar to a question I asked about <a href=\"https://stackoverflow.com/questions/53569/how-to-get-the-cha... | 2008/09/14 | [
"https://Stackoverflow.com/questions/61005",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/814/"
] | What are the best file permission settings for PHP scripts? Any suggestions on ways to figure out the minimum required permissions? | You could do this fairly simply with refspecs.
```
git pull origin
git diff @{1}..
```
That will give you a diff of the current branch as it existed before and after the pull. Note that if the pull doesn't actually update the current branch, the diff will give you the wrong results. Another option is to explicitly r... |
61,051 | <p>You can use more than one css class in an HTML tag in current web browsers, e.g.:</p>
<pre><code><div class="style1 style2 style3">foo bar</div>
</code></pre>
<p>This hasn't always worked; with which versions did the major browsers begin correctly supporting this feature?</p>
| [
{
"answer_id": 61053,
"author": "Wayne Kao",
"author_id": 3284,
"author_profile": "https://Stackoverflow.com/users/3284",
"pm_score": 1,
"selected": false,
"text": "<p>Apparently IE 6 doesn't handle these correctly if you have CSS selectors that contain multiple class names:\n<a href=\"h... | 2008/09/14 | [
"https://Stackoverflow.com/questions/61051",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3283/"
] | You can use more than one css class in an HTML tag in current web browsers, e.g.:
```
<div class="style1 style2 style3">foo bar</div>
```
This hasn't always worked; with which versions did the major browsers begin correctly supporting this feature? | @Wayne Kao - IE6 has no problem reading more than one class name on an element, and applying styles that belong to each class. What the article is referring to is creating new styles based on the combination of class names.
```
<div class="bold italic">content</div>
.bold {
font-weight: 800;
}
.italic {
font-sty... |
61,084 | <p>I'm trying to create a sitemap using Linq to Xml, but am getting an empty namespace attribute, which I would like to get rid of. e.g.</p>
<pre><code>XNamespace ns = "http://www.sitemaps.org/schemas/sitemap/0.9";
XDocument xdoc = new XDocument(new XDeclaration("1.0", "utf-8", "true"),
new XElement(ns + "urlset"... | [
{
"answer_id": 61106,
"author": "Anheledir",
"author_id": 5703,
"author_profile": "https://Stackoverflow.com/users/5703",
"pm_score": 2,
"selected": false,
"text": "<p>If one element uses a namespace, they all must use one. In case you don't define one on your own the framework will add ... | 2008/09/14 | [
"https://Stackoverflow.com/questions/61084",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4449/"
] | I'm trying to create a sitemap using Linq to Xml, but am getting an empty namespace attribute, which I would like to get rid of. e.g.
```
XNamespace ns = "http://www.sitemaps.org/schemas/sitemap/0.9";
XDocument xdoc = new XDocument(new XDeclaration("1.0", "utf-8", "true"),
new XElement(ns + "urlset",
new XEl... | The "more correct way" would be:
```
XDocument xdoc = new XDocument(new XDeclaration("1.0", "utf-8", "true"),
new XElement(ns + "urlset",
new XElement(ns + "url",
new XElement(ns + "loc", "http://www.example.com/page"),
new XElement(ns + "lastmod", "2008-09-14"))));
```
Same as your code, but with the "ns +"... |
61,085 | <p>I've been trying to use SQLite with the PDO wrapper in PHP with mixed success. I can read from the database fine, but none of my updates are being committed to the database when I view the page in the browser. Curiously, running the script from my shell does update the database. I suspected file permissions as the c... | [
{
"answer_id": 61102,
"author": "Tom Martin",
"author_id": 5303,
"author_profile": "https://Stackoverflow.com/users/5303",
"pm_score": 1,
"selected": false,
"text": "<p>I think PHP commonly runs as the user \"nodody\". Not sure about on Mac though. If Mac has whoami you could try <code... | 2008/09/14 | [
"https://Stackoverflow.com/questions/61085",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/658/"
] | I've been trying to use SQLite with the PDO wrapper in PHP with mixed success. I can read from the database fine, but none of my updates are being committed to the database when I view the page in the browser. Curiously, running the script from my shell does update the database. I suspected file permissions as the culp... | Kyle, in order for PDO/Sqlite to work you need write permission to directory where your database resides.
Also, I see you perform multiple selects in loop. This may be ok if you are building something small and not heavy loaded. Otherwise I'd suggest building single query that returns multiple rows and process them in... |
61,088 | <p><strong>What "Hidden Features" of JavaScript do you think every programmer should know?</strong></p>
<p>After having seen the excellent quality of the answers to the following questions I thought it was time to ask it for JavaScript.</p>
<ul>
<li><a href="https://stackoverflow.com/questions/954327/">Hidden Feature... | [
{
"answer_id": 61094,
"author": "Gulzar Nazim",
"author_id": 4337,
"author_profile": "https://Stackoverflow.com/users/4337",
"pm_score": 8,
"selected": false,
"text": "<p>Functions are first class citizens in JavaScript:</p>\n\n<pre><code>var passFunAndApply = function (fn,x,y,z) { retur... | 2008/09/14 | [
"https://Stackoverflow.com/questions/61088",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2443/"
] | **What "Hidden Features" of JavaScript do you think every programmer should know?**
After having seen the excellent quality of the answers to the following questions I thought it was time to ask it for JavaScript.
* [Hidden Features of HTML](https://stackoverflow.com/questions/954327/)
* [Hidden Features of CSS](http... | You don't need to define any parameters for a function. You can just use the function's `arguments` array-like object.
```
function sum() {
var retval = 0;
for (var i = 0, len = arguments.length; i < len; ++i) {
retval += arguments[i];
}
return retval;
}
sum(1, 2, 3) // returns 6
``` |
61,110 | <p>I need advice on how to have my C# console application display text to the user through the standard output while still being able access it later on. The actual feature I would like to implement is to dump the entire output buffer to a text file at the end of program execution.</p>
<p>The workaround I use while I ... | [
{
"answer_id": 61119,
"author": "Jason Cohen",
"author_id": 4926,
"author_profile": "https://Stackoverflow.com/users/4926",
"pm_score": 3,
"selected": false,
"text": "<p>I don't think there's anything wrong with your approach.</p>\n\n<p>If you wanted reusable code, consider implementing ... | 2008/09/14 | [
"https://Stackoverflow.com/questions/61110",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4850/"
] | I need advice on how to have my C# console application display text to the user through the standard output while still being able access it later on. The actual feature I would like to implement is to dump the entire output buffer to a text file at the end of program execution.
The workaround I use while I don't find... | The perfect solution for this is to use [log4net](http://logging.apache.org/log4net/) with a console appender and a file appender. There are many other appenders available as well. It also allows you to turn the different appenders off and on at runtime. |
61,143 | <p>Can someone show me how to implement a recursive lambda expression to traverse a tree structure in C#. </p>
| [
{
"answer_id": 61149,
"author": "DevelopingChris",
"author_id": 1220,
"author_profile": "https://Stackoverflow.com/users/1220",
"pm_score": 1,
"selected": false,
"text": "<p>Assuming a mythical object TreeItem, that conatins a Children collection to represent your hierarchy.</p>\n\n<pre>... | 2008/09/14 | [
"https://Stackoverflow.com/questions/61143",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5360/"
] | Can someone show me how to implement a recursive lambda expression to traverse a tree structure in C#. | Ok, I found some free time finally.
Here we go:
```
class TreeNode
{
public string Value { get; set;}
public List<TreeNode> Nodes { get; set;}
public TreeNode()
{
Nodes = new List<TreeNode>();
}
}
Action<TreeNode> traverse = null;
traverse = (n) => { Console.WriteLine(n.Value); n.Nod... |
61,150 | <p>My motto for Java is "just because Java has static blocks, it doesn't mean that you should be using them." Jokes aside, there are a lot of tricks in Java that make testing a nightmare. Two of the most I hate are Anonymous Classes and Static Blocks. We have a lot of legacy code that make use of Static Blocks and thes... | [
{
"answer_id": 61153,
"author": "Justin Standard",
"author_id": 92,
"author_profile": "https://Stackoverflow.com/users/92",
"pm_score": 3,
"selected": false,
"text": "<p>Sounds to me like you are treating a symptom: poor design with dependencies on static initialization. Maybe some refa... | 2008/09/14 | [
"https://Stackoverflow.com/questions/61150",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3087/"
] | My motto for Java is "just because Java has static blocks, it doesn't mean that you should be using them." Jokes aside, there are a lot of tricks in Java that make testing a nightmare. Two of the most I hate are Anonymous Classes and Static Blocks. We have a lot of legacy code that make use of Static Blocks and these a... | When I run into this problem, I usually do the same thing you describe, except I make the static method protected so I can invoke it manually. On top of this, I make sure that the method can be invoked multiple times without problems (otherwise it is no better than the static initializer as far as the tests go).
This ... |
61,155 | <p>I'm trying to place this menu on the left hand side of the page:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="left-menu" style="left: 123px; top: 355... | [
{
"answer_id": 61157,
"author": "Paige Ruten",
"author_id": 813,
"author_profile": "https://Stackoverflow.com/users/813",
"pm_score": 2,
"selected": false,
"text": "<p>I think you're supposed to use the <strong>float</strong> property for positioning things like that. <a href=\"http://cs... | 2008/09/14 | [
"https://Stackoverflow.com/questions/61155",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4298/"
] | I'm trying to place this menu on the left hand side of the page:
```html
<div class="left-menu" style="left: 123px; top: 355px">
<ul>
<li> Categories </li>
<li> Weapons </li>
<li> Armor </li>
<li> Manuals </li>
<li> Sustenance </li>
<li> Test </li>
... | `float` is indeed the right property to achieve this. However, the example given by bmatthews68 can be improved. The most important thing about floating boxes is that they *must* specify an explicit width. This can be rather inconvenient but this is the way CSS works. However, notice that `px` is a unit of measure that... |
61,176 | <p>I want to access messages in Gmail from a Java application using <a href="http://www.ing.iac.es/~docs/external/java/javamail/javadocs/index.html" rel="nofollow noreferrer">JavaMail</a> and <a href="https://en.wikipedia.org/wiki/Internet_Message_Access_Protocol" rel="nofollow noreferrer">IMAP</a>. Why am I getting a ... | [
{
"answer_id": 61179,
"author": "Brian Matthews",
"author_id": 1969,
"author_profile": "https://Stackoverflow.com/users/1969",
"pm_score": 2,
"selected": false,
"text": "<p>You have to connect to GMail using SSL only. Setting the following properties will force that for you. </p>\n\n<pre... | 2008/09/14 | [
"https://Stackoverflow.com/questions/61176",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2512222/"
] | I want to access messages in Gmail from a Java application using [JavaMail](http://www.ing.iac.es/~docs/external/java/javamail/javadocs/index.html) and [IMAP](https://en.wikipedia.org/wiki/Internet_Message_Access_Protocol). Why am I getting a *[SocketTimeoutException](https://docs.oracle.com/javase/7/docs/api/java/net/... | Using imaps was a great suggestion. Neither of the answers provided just worked for me, so I googled some more and found something that worked. Here's how my code looks now.
```
Properties props = System.getProperties();
props.setProperty("mail.store.protocol", "imaps");
try {
Session session = Session.getDefaultIns... |
61,212 | <p>How do I delete untracked local files from the current working tree?</p>
| [
{
"answer_id": 61213,
"author": "Espo",
"author_id": 2257,
"author_profile": "https://Stackoverflow.com/users/2257",
"pm_score": 7,
"selected": false,
"text": "<p><a href=\"http://www.kernel.org/pub/software/scm/git/docs/git-clean.html\" rel=\"noreferrer\">git-clean</a> is what you are l... | 2008/09/14 | [
"https://Stackoverflow.com/questions/61212",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4883/"
] | How do I delete untracked local files from the current working tree? | >
> [git-clean](https://git-scm.com/docs/git-clean) - Remove untracked files from the working tree
> ----------------------------------------------------------------------------------------------
>
>
> ### Synopsis
>
>
>
> ```
> git clean [-d] [-f] [-i] [-n] [-q] [-e <pattern>] [-x | -X] [--] <path>…
>
> ```
> ... |
61,217 | <p>This question is a follow up to my <a href="https://stackoverflow.com/questions/56279/export-aspx-to-html">previous question</a> about getting the HTML from an ASPX page. I decided to try using the webclient object, but the problem is that I get the login page's HTML because login is required. I tried "logging in" u... | [
{
"answer_id": 61221,
"author": "Fire Lancer",
"author_id": 6266,
"author_profile": "https://Stackoverflow.com/users/6266",
"pm_score": 1,
"selected": false,
"text": "<p>Well does opening the page in a brower with \"Login.aspx?UserName=&Password=\" normaly work?<br>\nSome pages may n... | 2008/09/14 | [
"https://Stackoverflow.com/questions/61217",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/278/"
] | This question is a follow up to my [previous question](https://stackoverflow.com/questions/56279/export-aspx-to-html) about getting the HTML from an ASPX page. I decided to try using the webclient object, but the problem is that I get the login page's HTML because login is required. I tried "logging in" using the webcl... | Just pass valid login parameters to a given URI. Should help you out.
**If you don't have login information you shouldn't be trying to circumvent it.**
```
public static string HttpPost( string URI, string Parameters )
{
System.Net.WebRequest req = System.Net.WebRequest.Create( URI );
req.Con... |
61,219 | <p>I've just started skimming 'Debugging MS .Net 2.0 Applications' by John Robbins, and have become confused by his evangelism for Debug.Assert(...).</p>
<p>He points out that well-implemented Asserts store the state, somewhat, of an error condition, e.g.:</p>
<pre><code>Debug.Assert(i > 3, "i > 3", "This means... | [
{
"answer_id": 61223,
"author": "aku",
"author_id": 1196,
"author_profile": "https://Stackoverflow.com/users/1196",
"pm_score": 2,
"selected": false,
"text": "<p>IMO it's a loss of development time only. Properly implemented exception gives you a clear picture of what happened. I saw <em... | 2008/09/14 | [
"https://Stackoverflow.com/questions/61219",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6004/"
] | I've just started skimming 'Debugging MS .Net 2.0 Applications' by John Robbins, and have become confused by his evangelism for Debug.Assert(...).
He points out that well-implemented Asserts store the state, somewhat, of an error condition, e.g.:
```
Debug.Assert(i > 3, "i > 3", "This means I got a bad parameter");
... | Assertions are not for parameter checking. Parameter checking should always be done (and precisely according to what pre-conditions are specified in your documentation and/or specification), and the `ArgumentOutOfRangeException` thrown as necessary.
Assertions are for testing for "impossible" situations, i.e., things ... |
61,227 | <p>If I have: </p>
<pre><code>signed char * p;
</code></pre>
<p>and I do a comparison:</p>
<pre><code>if ( *p == 0xFF )
break;
</code></pre>
<p>it will never catch 0XFF, but if I replace it with -1 it will:</p>
<pre><code>if ( *p == (signed char)0xFF )
break;
</code></pre>
<p>How can this happen? Is it some... | [
{
"answer_id": 61229,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 6,
"selected": true,
"text": "<p>The value <code>0xFF</code> is a signed int value. C will promote the <code>*p</code> to an <code>int</code> when doing ... | 2008/09/14 | [
"https://Stackoverflow.com/questions/61227",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2566/"
] | If I have:
```
signed char * p;
```
and I do a comparison:
```
if ( *p == 0xFF )
break;
```
it will never catch 0XFF, but if I replace it with -1 it will:
```
if ( *p == (signed char)0xFF )
break;
```
How can this happen? Is it something with the sign flag? I though that `0xFF == -1 == 255`. | The value `0xFF` is a signed int value. C will promote the `*p` to an `int` when doing the comparison, so the first if statement is equivalent to:
```
if( -1 == 255 ) break;
```
which is of course false. By using `(signed char)0xFF` the statement is equivalent to:
```
if( -1 == -1 ) break;
```
which works as you ... |
61,233 | <p>What is the best way to shred XML data into various database columns? So far I have mainly been using the nodes and value functions like so:</p>
<pre><code>INSERT INTO some_table (column1, column2, column3)
SELECT
Rows.n.value('(@column1)[1]', 'varchar(20)'),
Rows.n.value('(@column2)[1]', 'nvarchar(100)'),
Rows.n.v... | [
{
"answer_id": 61246,
"author": "aku",
"author_id": 1196,
"author_profile": "https://Stackoverflow.com/users/1196",
"pm_score": 2,
"selected": false,
"text": "<p>I'm not sure what is the best method. I used OPENXML construction:</p>\n\n<pre><code>INSERT INTO Test\nSELECT Id, Data \nFROM ... | 2008/09/14 | [
"https://Stackoverflow.com/questions/61233",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5769/"
] | What is the best way to shred XML data into various database columns? So far I have mainly been using the nodes and value functions like so:
```
INSERT INTO some_table (column1, column2, column3)
SELECT
Rows.n.value('(@column1)[1]', 'varchar(20)'),
Rows.n.value('(@column2)[1]', 'nvarchar(100)'),
Rows.n.value('(@column... | Stumbled across this question whilst having a very similar problem, I'd been running a query processing a 7.5MB XML file (~approx 10,000 nodes) for around 3.5~4 hours before finally giving up.
However, after a little more research I found that having typed the XML using a schema and created an XML Index (I'd bulk inse... |
61,256 | <p>I have a problem with a little .Net web application which uses the Amazon webservice. With the integrated Visual Studio web server everything works fine. But after deploying it to the IIS on the same computer i get the following error message:</p>
<pre><code>Ein Verbindungsversuch ist fehlgeschlagen, da die Gegenst... | [
{
"answer_id": 61296,
"author": "Brad Bruce",
"author_id": 5008,
"author_profile": "https://Stackoverflow.com/users/5008",
"pm_score": 0,
"selected": false,
"text": "<p>IIS is a destination. The configuration issue is in whatever is doing the call (acting like a client). If you are usi... | 2008/09/14 | [
"https://Stackoverflow.com/questions/61256",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6297/"
] | I have a problem with a little .Net web application which uses the Amazon webservice. With the integrated Visual Studio web server everything works fine. But after deploying it to the IIS on the same computer i get the following error message:
```
Ein Verbindungsversuch ist fehlgeschlagen, da die Gegenstelle nach
eine... | Proxy use can be configured in the web.config.
The system.net/defaultProxy element will let you specify whether a proxy is used by default or provide a bypass list.
For more info see: [<http://msdn.microsoft.com/en-us/library/kd3cf2ex.aspx>](http://msdn.microsoft.com/en-us/library/kd3cf2ex.aspx) |
61,262 | <p>Here's the problem, you include multiple assemblies and add 'using namespaceX' at the top of your code file.<br>
Now you want to create a class or use a symbol which is defined in multiple namespaces,
e.g. <code>System.Windows.Controls.Image</code> & <code>System.Drawing.Image</code></p>
<p>Now unless you use ... | [
{
"answer_id": 61264,
"author": "aku",
"author_id": 1196,
"author_profile": "https://Stackoverflow.com/users/1196",
"pm_score": 6,
"selected": true,
"text": "<p>Use alias</p>\n<pre><code>using System.Windows.Controls;\nusing Drawing = System.Drawing;\n\n...\n\nImage img = ... //System.Wi... | 2008/09/14 | [
"https://Stackoverflow.com/questions/61262",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1695/"
] | Here's the problem, you include multiple assemblies and add 'using namespaceX' at the top of your code file.
Now you want to create a class or use a symbol which is defined in multiple namespaces,
e.g. `System.Windows.Controls.Image` & `System.Drawing.Image`
Now unless you use the fully qualified name, there will ... | Use alias
```
using System.Windows.Controls;
using Drawing = System.Drawing;
...
Image img = ... //System.Windows.Controls.Image
Drawing.Image img2 = ... //System.Drawing.Image
```
[C# using directive](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/using-directive) |
61,278 | <p>What method do you use when you want to get performance data about specific code paths?</p>
| [
{
"answer_id": 61279,
"author": "Motti",
"author_id": 3848,
"author_profile": "https://Stackoverflow.com/users/3848",
"pm_score": 5,
"selected": true,
"text": "<p>This method has several limitations, but I still find it very useful. I'll list the limitations (I know of) up front and let ... | 2008/09/14 | [
"https://Stackoverflow.com/questions/61278",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3848/"
] | What method do you use when you want to get performance data about specific code paths? | This method has several limitations, but I still find it very useful. I'll list the limitations (I know of) up front and let whoever wants to use it do so at their own risk.
1. The original version I posted over-reported time spent in recursive calls (as pointed out in the comments to the answer).
2. It's not thread s... |
61,307 | <p>I have a VB.net test application that clicks a link that opens the Microsoft Word application window and displays the document. How do I locate the Word application window so that I can grab some text from it?</p>
| [
{
"answer_id": 61279,
"author": "Motti",
"author_id": 3848,
"author_profile": "https://Stackoverflow.com/users/3848",
"pm_score": 5,
"selected": true,
"text": "<p>This method has several limitations, but I still find it very useful. I'll list the limitations (I know of) up front and let ... | 2008/09/14 | [
"https://Stackoverflow.com/questions/61307",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2665/"
] | I have a VB.net test application that clicks a link that opens the Microsoft Word application window and displays the document. How do I locate the Word application window so that I can grab some text from it? | This method has several limitations, but I still find it very useful. I'll list the limitations (I know of) up front and let whoever wants to use it do so at their own risk.
1. The original version I posted over-reported time spent in recursive calls (as pointed out in the comments to the answer).
2. It's not thread s... |
61,339 | <p>I am trying to retrieve a user on Sharepoint's user photo through the WSS 3.0 object model. I have been browsing the web for solutions, but so far I've been unable to find a way to do it. Is it possible, and if so how?</p>
| [
{
"answer_id": 61452,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "<p>Ah, You have to use the UserProfileManager class.\nMore information here: <a href=\"http://msdn.microsoft.com/en-us/library/... | 2008/09/14 | [
"https://Stackoverflow.com/questions/61339",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am trying to retrieve a user on Sharepoint's user photo through the WSS 3.0 object model. I have been browsing the web for solutions, but so far I've been unable to find a way to do it. Is it possible, and if so how? | Here is a code snippet that should help get the job done for you. You may need to do some additional validation to avoid any exceptions (ensuring the profile actually exists, ensuring the image URL actually exists, etc...):
```
//get current profile manager
UserProfileManager objUserProfileManager = new UserPr... |
61,341 | <p>I remember back in the day with the old borland DOS compiler you could do something like this:</p>
<pre><code>asm {
mov ax,ex
etc etc...
}
</code></pre>
<p>Is there a semi-platform independent way to do this now? I have a need to make a BIOS call, so if there was a way to do this without asm code, that would be ... | [
{
"answer_id": 61344,
"author": "Espo",
"author_id": 2257,
"author_profile": "https://Stackoverflow.com/users/2257",
"pm_score": 3,
"selected": false,
"text": "<p>A good start would be reading this article which talk about inline assembly in C/C++:</p>\n\n<p><a href=\"http://www.codeproj... | 2008/09/14 | [
"https://Stackoverflow.com/questions/61341",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6062/"
] | I remember back in the day with the old borland DOS compiler you could do something like this:
```
asm {
mov ax,ex
etc etc...
}
```
Is there a semi-platform independent way to do this now? I have a need to make a BIOS call, so if there was a way to do this without asm code, that would be equally useful to me. | Using [GCC](http://www.ibiblio.org/gferg/ldp/GCC-Inline-Assembly-HOWTO.html)
```
__asm__("movl %edx, %eax\n\t"
"addl $2, %eax\n\t");
```
Using [VC++](http://msdn.microsoft.com/en-us/library/4ks26t93(VS.71).aspx)
```
__asm {
mov eax, edx
add eax, 2
}
``` |
61,357 | <p>Should I still be using tables anyway?</p>
<p>The table code I'd be replacing is:</p>
<pre><code><table>
<tr>
<td>Name</td><td>Value</td>
</tr>
...
</table>
</code></pre>
<p>From what I've been reading I should have something like</p>
<pre><code... | [
{
"answer_id": 61360,
"author": "Espo",
"author_id": 2257,
"author_profile": "https://Stackoverflow.com/users/2257",
"pm_score": 3,
"selected": false,
"text": "<p>I think tables are best used for tabular data, which it seems you have there.</p>\n\n<p>If you do not want to use tables, the... | 2008/09/14 | [
"https://Stackoverflow.com/questions/61357",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1122/"
] | Should I still be using tables anyway?
The table code I'd be replacing is:
```
<table>
<tr>
<td>Name</td><td>Value</td>
</tr>
...
</table>
```
From what I've been reading I should have something like
```
<label class="name">Name</label><label class="value">Value</value><br />
...
```
Ideas an... | I think that definition lists are pretty close semantically to name/value pairs.
```
<dl>
<dt>Name</dt>
<dd>Value</dd>
</dl>
```
[Definition lists - misused or misunderstood?](http://www.maxdesign.com.au/presentation/definition) |