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 |
|---|---|---|---|---|---|---|
157,786 | <p>I am looking for a way in LINQ to match the follow SQL Query.</p>
<pre><code>Select max(uid) as uid, Serial_Number from Table Group BY Serial_Number
</code></pre>
<p>Really looking for some help on this one. The above query gets the max uid of each Serial Number because of the <code>Group By</code> Syntax.</p>
| [
{
"answer_id": 157919,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 8,
"selected": true,
"text": "<pre><code> using (DataContext dc = new DataContext())\n {\n var q = from t in dc.TableTests\n ... | 2008/10/01 | [
"https://Stackoverflow.com/questions/157786",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7644/"
] | I am looking for a way in LINQ to match the follow SQL Query.
```
Select max(uid) as uid, Serial_Number from Table Group BY Serial_Number
```
Really looking for some help on this one. The above query gets the max uid of each Serial Number because of the `Group By` Syntax. | ```
using (DataContext dc = new DataContext())
{
var q = from t in dc.TableTests
group t by t.SerialNumber
into g
select new
{
SerialNumber = g.Key,
... |
157,807 | <p>If you have an API, and you are a UK-based developer with a highly international audience, should your API be </p>
<pre><code>setColour()
</code></pre>
<p>or</p>
<pre><code>setColor()
</code></pre>
<p>(To take one word as a simple example.)</p>
<p>UK-based engineers are often quite defensive about their 'correc... | [
{
"answer_id": 157810,
"author": "Chris",
"author_id": 4742,
"author_profile": "https://Stackoverflow.com/users/4742",
"pm_score": 8,
"selected": true,
"text": "<p>I would tend to use US-English as that has become the norm in other APIs. Speaking as an English programmer, I don't have an... | 2008/10/01 | [
"https://Stackoverflow.com/questions/157807",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/974/"
] | If you have an API, and you are a UK-based developer with a highly international audience, should your API be
```
setColour()
```
or
```
setColor()
```
(To take one word as a simple example.)
UK-based engineers are often quite defensive about their 'correct' spellings but it could be argued that US spelling is ... | I would tend to use US-English as that has become the norm in other APIs. Speaking as an English programmer, I don't have any problem using "color", for example. |
157,827 | <p>My code needs to run all networking routines in a separate NSThread.
I have got a library, which I pass a callback routine for communication:</p>
<pre><code>my thread code
library
my callback (networking)
library
my thread code
</code></pre>
<p>My callback routine must POST some data to an HTTP ser... | [
{
"answer_id": 160422,
"author": "benzado",
"author_id": 10947,
"author_profile": "https://Stackoverflow.com/users/10947",
"pm_score": 0,
"selected": false,
"text": "<p>To answer your mini-question \"start an NSRunLoop?\":</p>\n\n<p>I'm not sure I understand, but it sounds like you are s... | 2008/10/01 | [
"https://Stackoverflow.com/questions/157827",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8030/"
] | My code needs to run all networking routines in a separate NSThread.
I have got a library, which I pass a callback routine for communication:
```
my thread code
library
my callback (networking)
library
my thread code
```
My callback routine must POST some data to an HTTP server (NSURLConnection), wai... | If you need to block until you've done the work and you're already on a separate thread, you could use `+[NSURLConnection sendSynchronousRequest:returningResponse:error:]`. It's a bit blunt though, so if you need more control you'll have to switch to an asynchronous `NSURLRequest` with delegate methods (i.e. callbacks)... |
157,832 | <p>This is sort of SQL newbie question, I think, but here goes.</p>
<p>I have a SQL Query (SQL Server 2005) that I've put together based on an example user-defined function:</p>
<pre><code>SELECT
CASEID,
GetNoteText(CASEID)
FROM
(
SELECT
CASEID
FROM
ATTACHMENTS
GROUP BY
... | [
{
"answer_id": 157842,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 5,
"selected": true,
"text": "<p>When you use a subquery in the FROM clause, you need to give the query a name. Since the name doesn't really matter... | 2008/10/01 | [
"https://Stackoverflow.com/questions/157832",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8151/"
] | This is sort of SQL newbie question, I think, but here goes.
I have a SQL Query (SQL Server 2005) that I've put together based on an example user-defined function:
```
SELECT
CASEID,
GetNoteText(CASEID)
FROM
(
SELECT
CASEID
FROM
ATTACHMENTS
GROUP BY
CASEID
) i
GO
... | When you use a subquery in the FROM clause, you need to give the query a name. Since the name doesn't really matter to you, something simple like 'i' or 'a' is often chosen. But you could put any name there you wanted- there's no significance to 'i' all by itself, and it's certainly not a keyword.
If you have a really... |
157,846 | <p>What is the benefit of using the servletContext as opposed the request in order to obtain a requestDispatcher?</p>
<pre><code>servletContext.getRequestDispatcher(dispatchPath)
</code></pre>
<p>and using </p>
<pre><code>argRequest.getRequestDispatcher(dispatchPath)
</code></pre>
| [
{
"answer_id": 158255,
"author": "skaffman",
"author_id": 21234,
"author_profile": "https://Stackoverflow.com/users/21234",
"pm_score": 3,
"selected": true,
"text": "<p>It's there in the javadocs in black and white</p>\n\n<p><a href=\"http://java.sun.com/javaee/5/docs/api/javax/servlet/S... | 2008/10/01 | [
"https://Stackoverflow.com/questions/157846",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | What is the benefit of using the servletContext as opposed the request in order to obtain a requestDispatcher?
```
servletContext.getRequestDispatcher(dispatchPath)
```
and using
```
argRequest.getRequestDispatcher(dispatchPath)
``` | It's there in the javadocs in black and white
<http://java.sun.com/javaee/5/docs/api/javax/servlet/ServletRequest.html#getRequestDispatcher(java.lang.String)>
>
> The difference between this method and
> ServletContext.getRequestDispatcher(java.lang.String)
> is that this method can take a
> relative path.
>
>
... |
157,856 | <p>Imagine this sample java class:</p>
<pre><code>class A {
void addListener(Listener obj);
void removeListener(Listener obj);
}
class B {
private A a;
B() {
a = new A();
a.addListener(new Listener() {
void listen() {}
}
}
</code></pre>
<p>Do I need to add a final... | [
{
"answer_id": 157884,
"author": "Steve B.",
"author_id": 19479,
"author_profile": "https://Stackoverflow.com/users/19479",
"pm_score": 0,
"selected": false,
"text": "<p>When the B is garbage collected it should allow the A to be garbage collected as well, and therefore any references in... | 2008/10/01 | [
"https://Stackoverflow.com/questions/157856",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3657/"
] | Imagine this sample java class:
```
class A {
void addListener(Listener obj);
void removeListener(Listener obj);
}
class B {
private A a;
B() {
a = new A();
a.addListener(new Listener() {
void listen() {}
}
}
```
Do I need to add a finalize method to B to call a.... | I just found a huge memory leak, so I am going to call the code that created the leak to be *wrong* and my fix that does not leak as *right*.
Here is the old code: (This is a common pattern I have seen all over)
```
class Singleton {
static Singleton getInstance() {...}
void addListener(Listener listener) {..... |
157,873 | <p>I'm having a test hang in our rails app can't figure out which one (since it hangs and doesn't get to the failure report). I found this blog post <a href="http://bmorearty.wordpress.com/2008/06/18/find-tests-more-easily-in-your-testlog/" rel="noreferrer">http://bmorearty.wordpress.com/2008/06/18/find-tests-more-eas... | [
{
"answer_id": 158003,
"author": "mwilliams",
"author_id": 23909,
"author_profile": "https://Stackoverflow.com/users/23909",
"pm_score": -1,
"selected": false,
"text": "<p>What test framework are you using? Test/Unit?</p>\n\n<p>I would take a look at RSpec which would provide a little m... | 2008/10/01 | [
"https://Stackoverflow.com/questions/157873",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3041/"
] | I'm having a test hang in our rails app can't figure out which one (since it hangs and doesn't get to the failure report). I found this blog post <http://bmorearty.wordpress.com/2008/06/18/find-tests-more-easily-in-your-testlog/> which adds a setup hook to print the test name but when I try to do the same thing it give... | If you run test using rake it will work:
```
rake test:units TESTOPTS="-v"
``` |
157,905 | <p>The subject says it all, almost. How do I automatically fix jsp pages so that relative URLs are mapped to the context path instead of the server root? That is, given for example</p>
<pre><code><link rel="stylesheet" type="text/css" href="/css/style.css" />
</code></pre>
<p>how do I set-up things in a way tha... | [
{
"answer_id": 157909,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 4,
"selected": true,
"text": "<p>Look into the <a href=\"http://www.w3schools.com/TAGS/att_base_href.asp\" rel=\"noreferrer\"><code><BASE HREF=\"\"></c... | 2008/10/01 | [
"https://Stackoverflow.com/questions/157905",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6069/"
] | The subject says it all, almost. How do I automatically fix jsp pages so that relative URLs are mapped to the context path instead of the server root? That is, given for example
```
<link rel="stylesheet" type="text/css" href="/css/style.css" />
```
how do I set-up things in a way that maps the css to `my-server/my-... | Look into the [`<BASE HREF="">`](http://www.w3schools.com/TAGS/att_base_href.asp) tag. This is an HTML tag which will mean all links on the page should start with your base URL.
For example, if you specified `<BASE HREF="http://www.example.com/prefix">` and then had `<a href="/link/1.html">` then the link should actua... |
157,923 | <p>I've started to "play around" with PowerShell and am trying to get it to "behave".</p>
<p>One of the things I'd like to do is to customize the PROMPT to be "similar" to what "$M$P$_$+$G" do on MS-Dos:</p>
<p>A quick rundown of what these do:</p>
<p><b>Character</b><b>| Description</b><br>
<b>$m </b> The remote n... | [
{
"answer_id": 157991,
"author": "EBGreen",
"author_id": 1358,
"author_profile": "https://Stackoverflow.com/users/1358",
"pm_score": 1,
"selected": false,
"text": "<p>This will get you the count of the locations on the pushd stack:</p>\n\n<pre><code>$(get-location -Stack).count\n</code><... | 2008/10/01 | [
"https://Stackoverflow.com/questions/157923",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12344/"
] | I've started to "play around" with PowerShell and am trying to get it to "behave".
One of the things I'd like to do is to customize the PROMPT to be "similar" to what "$M$P$\_$+$G" do on MS-Dos:
A quick rundown of what these do:
**Character****| Description**
**$m** The remote name associated with the current dr... | See if this does what you want:
```
function prompt
{
## Get the history. Since the history may be either empty,
## a single item or an array, the @() syntax ensures
## that PowerShell treats it as an array
$history = @(get-history)
## If there are any items in the history, find out the
## Id of the... |
157,924 | <p>I've got a situation where I need to use LINQ's ExecuteCommand method to run an insert.</p>
<p>Something like (simplified for purposes of this question):</p>
<pre><code>object[] oParams = { Guid.NewGuid(), rec.WebMethodID };
TransLogDataContext.ExecuteCommand (
"INSERT INTO dbo.Transaction_Log (ID, WebMethodID) V... | [
{
"answer_id": 157946,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 5,
"selected": true,
"text": "<p>Did some research, and I found this:</p>\n\n<blockquote>\n <p>In my simple testing, it looks like\n the parameters... | 2008/10/01 | [
"https://Stackoverflow.com/questions/157924",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1683/"
] | I've got a situation where I need to use LINQ's ExecuteCommand method to run an insert.
Something like (simplified for purposes of this question):
```
object[] oParams = { Guid.NewGuid(), rec.WebMethodID };
TransLogDataContext.ExecuteCommand (
"INSERT INTO dbo.Transaction_Log (ID, WebMethodID) VALUES ({0}, {1})",
oP... | Did some research, and I found this:
>
> In my simple testing, it looks like
> the parameters passed in the
> ExecuteQuery and ExecuteCommand
> methods are automatically SQL encoded
> based on the value being supplied. So
> if you pass in a string with a '
> character, it will automatically SQL
> escape it to ... |
157,933 | <p>I was able to implement a thread-safe Dictionary in C# by deriving from IDictionary and defining a private SyncRoot object:</p>
<pre><code>public class SafeDictionary<TKey, TValue>: IDictionary<TKey, TValue>
{
private readonly object syncRoot = new object();
private Dictionary<TKey, TValue>... | [
{
"answer_id": 157966,
"author": "Peter Meyer",
"author_id": 1875,
"author_profile": "https://Stackoverflow.com/users/1875",
"pm_score": 2,
"selected": false,
"text": "<p>You don't need to lock the SyncRoot property in your consumer objects. The lock you have within the methods of the d... | 2008/10/01 | [
"https://Stackoverflow.com/questions/157933",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5563/"
] | I was able to implement a thread-safe Dictionary in C# by deriving from IDictionary and defining a private SyncRoot object:
```
public class SafeDictionary<TKey, TValue>: IDictionary<TKey, TValue>
{
private readonly object syncRoot = new object();
private Dictionary<TKey, TValue> d = new Dictionary<TKey, TValu... | As Peter said, you can encapsulate all of the thread safety inside the class. You will need to be careful with any events you expose or add, making sure that they get invoked outside of any locks.
```
public class SafeDictionary<TKey, TValue>: IDictionary<TKey, TValue>
{
private readonly object syncRoot = new obje... |
157,938 | <p>I have got a python script which is creating an ODBC connection. The ODBC connection is generated with a connection string. In this connection string I have to include the username and password for this connection. </p>
<p>Is there an easy way to obscure this password in the file (just that nobody can read the pas... | [
{
"answer_id": 157974,
"author": "Kevin Little",
"author_id": 14028,
"author_profile": "https://Stackoverflow.com/users/14028",
"pm_score": 0,
"selected": false,
"text": "<p>There are several ROT13 utilities written in Python on the 'Net -- just google for them. ROT13 encode the string o... | 2008/10/01 | [
"https://Stackoverflow.com/questions/157938",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3056/"
] | I have got a python script which is creating an ODBC connection. The ODBC connection is generated with a connection string. In this connection string I have to include the username and password for this connection.
Is there an easy way to obscure this password in the file (just that nobody can read the password when ... | [Base64 encoding](https://docs.python.org/3/library/base64.html) is in the standard library and will do to stop shoulder surfers:
```
>>> import base64
>>> print(base64.b64encode("password".encode("utf-8")))
cGFzc3dvcmQ=
>>> print(base64.b64decode("cGFzc3dvcmQ=").decode("utf-8"))
password
``` |
157,944 | <p>Given an array of type <code>Element[]</code>:</p>
<pre><code>Element[] array = {new Element(1), new Element(2), new Element(3)};
</code></pre>
<p>How do I convert this array into an object of type <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/ArrayList.html" rel="noreferrer"><code>... | [
{
"answer_id": 157950,
"author": "Tom",
"author_id": 22850,
"author_profile": "https://Stackoverflow.com/users/22850",
"pm_score": 13,
"selected": true,
"text": "<pre><code>new ArrayList<>(Arrays.asList(array));\n</code></pre>\n"
},
{
"answer_id": 157956,
"author": "Bil... | 2008/10/01 | [
"https://Stackoverflow.com/questions/157944",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/939/"
] | Given an array of type `Element[]`:
```
Element[] array = {new Element(1), new Element(2), new Element(3)};
```
How do I convert this array into an object of type [`ArrayList<Element>`](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/ArrayList.html)?
```
ArrayList<Element> arrayList = ???;
`... | ```
new ArrayList<>(Arrays.asList(array));
``` |
157,959 | <p>When I ssh into a remote production server I would like the colour scheme of my terminal window to change to something brigh and scary, preferably red, to warn me that I am touching a live scary server. </p>
<p>How can I make it automatically detect that I have ssh'ed somewhere, and if that somewhere is on a specif... | [
{
"answer_id": 157983,
"author": "unexist",
"author_id": 18179,
"author_profile": "https://Stackoverflow.com/users/18179",
"pm_score": 1,
"selected": false,
"text": "<p>Why not just changing the shell prompt whenever you are logged in via SSH? There are usually specific shell variables: ... | 2008/10/01 | [
"https://Stackoverflow.com/questions/157959",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7473/"
] | When I ssh into a remote production server I would like the colour scheme of my terminal window to change to something brigh and scary, preferably red, to warn me that I am touching a live scary server.
How can I make it automatically detect that I have ssh'ed somewhere, and if that somewhere is on a specific list, c... | Put following script in `~/bin/ssh` (ensure `~/bin/` is checked before `/usr/bin/` in your PATH):
```
#!/bin/sh
HOSTNAME=`echo $@ | sed s/.*@//`
set_bg () {
osascript -e "tell application \"Terminal\" to set background color of window 1 to $1"
}
on_exit () {
set_bg "{0, 0, 0, 50000}"
}
trap on_exit EXIT
case $... |
158,008 | <p>I'm updating some old AWStats config files to filter out some specific IP ranges. Here's the pertinent section of the config file:</p>
<pre><code># Do not include access from clients that match following criteria.
# If your log file contains IP addresses in host field, you must enter here
# matching IP addresses cr... | [
{
"answer_id": 158086,
"author": "Casper",
"author_id": 18729,
"author_profile": "https://Stackoverflow.com/users/18729",
"pm_score": 0,
"selected": false,
"text": "<p>Does AWStats run if you leave SkipHosts empty? Otherwise, try the commandline utility to check for errors. For example, ... | 2008/10/01 | [
"https://Stackoverflow.com/questions/158008",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/751/"
] | I'm updating some old AWStats config files to filter out some specific IP ranges. Here's the pertinent section of the config file:
```
# Do not include access from clients that match following criteria.
# If your log file contains IP addresses in host field, you must enter here
# matching IP addresses criteria.
# If D... | Assuming that character classes are supported within REGEX[ ]:
```
SkipHosts = "REGEX[^192\.168\.1\.(9[7-9]|10[0-9]|110)$]"
``` |
158,044 | <p>How do I use the UNIX command <code>find</code> to search for files created on a specific date?</p>
| [
{
"answer_id": 158074,
"author": "Jeff MacDonald",
"author_id": 22374,
"author_profile": "https://Stackoverflow.com/users/22374",
"pm_score": 5,
"selected": false,
"text": "<p>You could do this:</p>\n\n<pre><code>find ./ -type f -ls |grep '10 Sep'\n</code></pre>\n\n<p>Example: </p>\n\n<p... | 2008/10/01 | [
"https://Stackoverflow.com/questions/158044",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/473/"
] | How do I use the UNIX command `find` to search for files created on a specific date? | As pointed out by Max, you can't, but checking files modified or accessed is not all that hard. I wrote a [tutorial](http://virtuelvis.com/2008/10/how-to-use-find-to-search-for-files-created-on-a-specific-date/) about this, as late as today. The essence of which is to use `-newerXY` and `! -newerXY`:
Example: To find ... |
158,055 | <p>I am trying to use TemplateToolkit instead of good ole' variable interpolation and my server is giving me a lot of grief. Here are the errors I am getting:</p>
<pre><code>*** 'D:\Inetpub\gic\source\extjs_source.plx' error message at: 2008/09/30 15:27:37 failed to create context: failed to create context: failed to... | [
{
"answer_id": 158063,
"author": "Frew Schmidt",
"author_id": 12448,
"author_profile": "https://Stackoverflow.com/users/12448",
"pm_score": 5,
"selected": true,
"text": "<p>I figured this one out after a long time. Apparently the ActiveState people didn't check much into the package bec... | 2008/10/01 | [
"https://Stackoverflow.com/questions/158055",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12448/"
] | I am trying to use TemplateToolkit instead of good ole' variable interpolation and my server is giving me a lot of grief. Here are the errors I am getting:
```
*** 'D:\Inetpub\gic\source\extjs_source.plx' error message at: 2008/09/30 15:27:37 failed to create context: failed to create context: failed to load Template/... | I figured this one out after a long time. Apparently the ActiveState people didn't check much into the package because it requires Template::Stash::XS, but that's not actually available in PPM. To fix this issue just edit the Template/Config.pm and change Template::Stash::XS to Template::Stash. |
158,070 | <p>I have a hidden DIV which contains a toolbar-like menu.</p>
<p>I have a number of DIVs which are enabled to show the menu DIV when the mouse hovers over them.</p>
<p>Is there a built-in function which will move the menu DIV to the top right of the active (mouse hover) DIV? I'm looking for something like <code>$(me... | [
{
"answer_id": 158176,
"author": "Jacob",
"author_id": 22107,
"author_profile": "https://Stackoverflow.com/users/22107",
"pm_score": 9,
"selected": false,
"text": "<p><strong>tl;dr:</strong> (try it <a href=\"http://jsfiddle.net/wjbuys/QrrpB/\" rel=\"noreferrer\">here</a>)</p>\n\n<p>If y... | 2008/10/01 | [
"https://Stackoverflow.com/questions/158070",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11249/"
] | I have a hidden DIV which contains a toolbar-like menu.
I have a number of DIVs which are enabled to show the menu DIV when the mouse hovers over them.
Is there a built-in function which will move the menu DIV to the top right of the active (mouse hover) DIV? I'm looking for something like `$(menu).position("topright... | **NOTE:** This requires jQuery UI (not just jQuery).
You can now use:
```
$("#my_div").position({
my: "left top",
at: "left bottom",
of: this, // or $("#otherdiv")
collision: "fit"
});
```
For fast positioning (*[jQuery UI/Position](http://api.jqueryui.com/position/)*).
You can... |
158,104 | <p>I've discovered that any time I do the following:</p>
<pre><code>echo '<a href="http://" title="bla">huzzah</a>';
</code></pre>
<p>I end up with the following being rendered to the browser:</p>
<pre><code><a href="http:///" title="bla">huzzah</a>
</code></pre>
<p>This is particularly anno... | [
{
"answer_id": 158115,
"author": "Fire Lancer",
"author_id": 6266,
"author_profile": "https://Stackoverflow.com/users/6266",
"pm_score": 2,
"selected": false,
"text": "<p>Ive never had that, how ecactly are you echoing the link? All the following should work.</p>\n\n<pre><code>echo '<... | 2008/10/01 | [
"https://Stackoverflow.com/questions/158104",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22216/"
] | I've discovered that any time I do the following:
```
echo '<a href="http://" title="bla">huzzah</a>';
```
I end up with the following being rendered to the browser:
```
<a href="http:///" title="bla">huzzah</a>
```
This is particularly annoying when I link to a file with an extension, as it breaks the link.
Any... | Firefox, especially, shows you the html source the way it's seeing it which is rarely the way you've sent it. Clearly something about your link or it's context is making the browser interpret a trailing slash.
I wonder if it's a side effect of the url encoding. If you rawurldecode it will that help. If there are parts... |
158,121 | <p>Using the Sun Java VM 1.5 or 1.6 on Windows, I connect a non-blocking socket. I then fill a <code>ByteBuffer</code> with a message to output, and attempt to <code>write()</code> to the SocketChannel.</p>
<p>I expect the write to complete only partially if the amount to be written is greater than the amount of spac... | [
{
"answer_id": 158144,
"author": "Clay",
"author_id": 16429,
"author_profile": "https://Stackoverflow.com/users/16429",
"pm_score": 0,
"selected": false,
"text": "<p>I'll make a big leap of faith and assume that the underlying network provider for Java is the same as for C...the O/S allo... | 2008/10/01 | [
"https://Stackoverflow.com/questions/158121",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24173/"
] | Using the Sun Java VM 1.5 or 1.6 on Windows, I connect a non-blocking socket. I then fill a `ByteBuffer` with a message to output, and attempt to `write()` to the SocketChannel.
I expect the write to complete only partially if the amount to be written is greater than the amount of space in the socket's TCP output buff... | I managed to reproduce a situation that might be similar to yours. I think, ironically enough, your recipient is consuming the data faster than you're writing it.
```
import java.io.InputStream;
import java.net.ServerSocket;
import java.net.Socket;
public class MyServer {
public static void main(String[] args) thro... |
158,122 | <p>I have what I believe to be a fairly well structured .NET 3.5 forms application (Unit Tests, Dependency Injection, SoC, the forms simply relay input and display output and don't do any logic, yadda yadda) I am just missing the winforms knowledge for how to get this bit to work.</p>
<p>When a connection to the datab... | [
{
"answer_id": 158182,
"author": "Scott Langham",
"author_id": 11898,
"author_profile": "https://Stackoverflow.com/users/11898",
"pm_score": 0,
"selected": false,
"text": "<p>Might it be simpler to keep all the UI work on the main UI thread rather than using the BackgroundWorker? It's tr... | 2008/10/01 | [
"https://Stackoverflow.com/questions/158122",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5056/"
] | I have what I believe to be a fairly well structured .NET 3.5 forms application (Unit Tests, Dependency Injection, SoC, the forms simply relay input and display output and don't do any logic, yadda yadda) I am just missing the winforms knowledge for how to get this bit to work.
When a connection to the database is los... | I'm not sure about the correctness of your overall approach, but to specifically answer your question try changing the MySustainedDialog Hide() function to as follows:
```
public new void Hide()
{
if (this.InvokeRequired)
{
this.BeginInvoke((MethodInvoker)delegate { this.Hide(); });... |
158,124 | <p>It's surprising how difficult it is to find a simple, concise answer to this question:</p>
<ol>
<li>I have a file, foo.zip, on my website</li>
<li>What can I do to find out how many people have accessed this file?</li>
<li>I could use Tomcat calls if necessary</li>
</ol>
| [
{
"answer_id": 158127,
"author": "Chris",
"author_id": 4742,
"author_profile": "https://Stackoverflow.com/users/4742",
"pm_score": 4,
"selected": false,
"text": "<p>The simplest way would probably be instead of linking directly to the file, link to a script which increments a counter and... | 2008/10/01 | [
"https://Stackoverflow.com/questions/158124",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2197/"
] | It's surprising how difficult it is to find a simple, concise answer to this question:
1. I have a file, foo.zip, on my website
2. What can I do to find out how many people have accessed this file?
3. I could use Tomcat calls if necessary | Or you could parse the log file if you don't need the data in realtime.
```
grep foo.zip /path/to/access.log | grep 200 | wc -l
```
In reply to comment:
The log file also contains bytes downloaded, but as someone else pointed out, this may not reflect the correct count if a user cancels the download on the client s... |
158,151 | <p>Is there a one button way to save a screenshot directly to a file in Windows?</p>
<br>
TheSoftwareJedi accurately answered above question for Windows 8 and 10. Below original extra material remains for posterity.
<blockquote>
<p>This is a very important question as the 316K views shows as of 2021.
Asked in 2008, SO... | [
{
"answer_id": 158153,
"author": "Mitchel Sellers",
"author_id": 13279,
"author_profile": "https://Stackoverflow.com/users/13279",
"pm_score": 0,
"selected": false,
"text": "<p>As far as I know in XP, yes you must use some other app to actually save it.</p>\n\n<p>Vista comes with the Sni... | 2008/10/01 | [
"https://Stackoverflow.com/questions/158151",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2197/"
] | Is there a one button way to save a screenshot directly to a file in Windows?
TheSoftwareJedi accurately answered above question for Windows 8 and 10. Below original extra material remains for posterity.
>
> This is a very important question as the 316K views shows as of 2021.
> Asked in 2008, SO closed this questio... | You can code something pretty simple that will hook the PrintScreen and save the capture in a file.
Here is something to start to capture and save to a file. You will just need to hook the key "Print screen".
```cs
using System;
using System.Drawing;
using System.IO;
using System.Drawing.Imaging;
using System.Runtime... |
158,172 | <p>I have some decimal data that I am pushing into a SharePoint list where it is to be viewed. I'd like to restrict the number of significant figures displayed in the result data based on my knowledge of the specific calculation. Sometimes it'll be 3, so 12345 will become 12300 and 0.012345 will become 0.0123. Occas... | [
{
"answer_id": 158810,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": -1,
"selected": false,
"text": "<p>As I remember it \"significant figures\" means the number of digits after the dot separator so 3 significant digits for 0.... | 2008/10/01 | [
"https://Stackoverflow.com/questions/158172",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/404/"
] | I have some decimal data that I am pushing into a SharePoint list where it is to be viewed. I'd like to restrict the number of significant figures displayed in the result data based on my knowledge of the specific calculation. Sometimes it'll be 3, so 12345 will become 12300 and 0.012345 will become 0.0123. Occasionall... | See: [RoundToSignificantFigures](https://stackoverflow.com/questions/374316/round-a-double-to-x-significant-figures-after-decimal-point/374470#374470) by "P Daddy".
I've combined his method with another one I liked.
Rounding to significant figures is a lot easier in TSQL where the rounding method is based on round... |
158,189 | <p><a href="http://www.techonthenet.com/oracle/functions/trunc_date.php]" rel="noreferrer">This page</a> mentions how to trunc a timestamp to minutes/hours/etc. in Oracle.</p>
<p>How would you trunc a timestamp to seconds in the same manner?</p>
| [
{
"answer_id": 158252,
"author": "Tony Andrews",
"author_id": 18747,
"author_profile": "https://Stackoverflow.com/users/18747",
"pm_score": 6,
"selected": true,
"text": "<p>Since the precision of <code>DATE</code> is to the second (and no fractions of seconds), there is no need to <code>... | 2008/10/01 | [
"https://Stackoverflow.com/questions/158189",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/686/"
] | [This page](http://www.techonthenet.com/oracle/functions/trunc_date.php]) mentions how to trunc a timestamp to minutes/hours/etc. in Oracle.
How would you trunc a timestamp to seconds in the same manner? | Since the precision of `DATE` is to the second (and no fractions of seconds), there is no need to `TRUNC` at all.
The data type `TIMESTAMP` allows for fractions of seconds. If you convert it to a `DATE` the fractional seconds will be removed - e.g.
```
select cast(systimestamp as date)
from dual;
``` |
158,209 | <p>curious if anyone might have some insight in how I would do the following to a binary number:</p>
<p>convert </p>
<pre><code> 01+0 -> 10+1 (+ as in regular expressions, one or more)
01 -> 10
10 -> 01
</code></pre>
<p>so,</p>
<pre><code>10101000010100011100
01010100101010100010
</code></pr... | [
{
"answer_id": 158217,
"author": "J.J.",
"author_id": 21204,
"author_profile": "https://Stackoverflow.com/users/21204",
"pm_score": -1,
"selected": false,
"text": "<p>Twidle in C/C++ is ~</p>\n"
},
{
"answer_id": 158258,
"author": "Uhall",
"author_id": 19129,
"author_... | 2008/10/01 | [
"https://Stackoverflow.com/questions/158209",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/157/"
] | curious if anyone might have some insight in how I would do the following to a binary number:
convert
```
01+0 -> 10+1 (+ as in regular expressions, one or more)
01 -> 10
10 -> 01
```
so,
```
10101000010100011100
01010100101010100010
```
and to clarify that this isn't a simple inversion:
```
000... | Let's say x is your variable. Then you'd have:
```
unsigned myBitOperation(unsigned x)
{
return ((x<<1) | (x>>1)) & (~x);
}
``` |
158,219 | <p>I have a C# application that includes the following code:</p>
<pre><code>string file = "relativePath.txt";
//Time elapses...
string contents = File.ReadAllText(file);
</code></pre>
<p>This works fine, most of the time. The file is read relative to the directory that the app was started from. However, in testin... | [
{
"answer_id": 158242,
"author": "OregonGhost",
"author_id": 20363,
"author_profile": "https://Stackoverflow.com/users/20363",
"pm_score": 4,
"selected": true,
"text": "<p>If the file is always in a path relative to the executable assembly, then yes, use Assembly.Location. I mostly use A... | 2008/10/01 | [
"https://Stackoverflow.com/questions/158219",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/96/"
] | I have a C# application that includes the following code:
```
string file = "relativePath.txt";
//Time elapses...
string contents = File.ReadAllText(file);
```
This works fine, most of the time. The file is read relative to the directory that the app was started from. However, in testing, it has been found that if... | If the file is always in a path relative to the executable assembly, then yes, use Assembly.Location. I mostly use Assembly.GetExecutingAssembly if applicable though instead of Assembly.GetEntryAssembly. This means that if you're accessing the file from a DLL, the path will be relative to the DLL path. |
158,232 | <p>After following the instructions in INSTALL.W64 I have two problems:</p>
<ul>
<li>The code is still written to the "out32" folder. I need to be able to link to both 32-bit and 64-bit versions of the library on my workstation, so I don't want the 64-bit versions to clobber the 32-bit libs.</li>
<li>The output is sti... | [
{
"answer_id": 158246,
"author": "kgriffs",
"author_id": 21784,
"author_profile": "https://Stackoverflow.com/users/21784",
"pm_score": 5,
"selected": false,
"text": "<p>To compile the static libraries (both release and debug), this is what you need to do:</p>\n\n<ol>\n<li>Install Perl - ... | 2008/10/01 | [
"https://Stackoverflow.com/questions/158232",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21784/"
] | After following the instructions in INSTALL.W64 I have two problems:
* The code is still written to the "out32" folder. I need to be able to link to both 32-bit and 64-bit versions of the library on my workstation, so I don't want the 64-bit versions to clobber the 32-bit libs.
* The output is still 32-bit! This means... | To compile the static libraries (both release and debug), this is what you need to do:
1. Install Perl - [www.activestate.com](http://www.activestate.com/activeperl/downloads)
2. Run the "Visual Studio 2008 x64 Cross Tools Command Prompt" (Note: The regular command prompt WILL NOT WORK.)
3. Configure with
perl Configu... |
158,241 | <p>What I want to do is to remove all accents and umlauts from a string, turning "lärm" into "larm" or "andré" into "andre". What I tried to do was to utf8_decode the string and then use strtr on it, but since my source file is saved as UTF-8 file, I can't enter the ISO-8859-15 characters for all umlauts - the editor i... | [
{
"answer_id": 158247,
"author": "BlaM",
"author_id": 999,
"author_profile": "https://Stackoverflow.com/users/999",
"pm_score": 1,
"selected": false,
"text": "<p>Okay, found an obvious solution myself, but it's not the best concerning performance...</p>\n\n<pre><code>echo strtr(utf8_deco... | 2008/10/01 | [
"https://Stackoverflow.com/questions/158241",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/999/"
] | What I want to do is to remove all accents and umlauts from a string, turning "lärm" into "larm" or "andré" into "andre". What I tried to do was to utf8\_decode the string and then use strtr on it, but since my source file is saved as UTF-8 file, I can't enter the ISO-8859-15 characters for all umlauts - the editor ins... | ```
iconv("utf-8","ascii//TRANSLIT",$input);
```
Extended [example](http://php.net/manual/en/function.iconv.php#83238) |
158,257 | <p>My app uses a WebRequest at certain points to get pages from itself.</p>
<p>This shouldn't be a problem. It actually works fine on the server, which is a "shared" hosting package with Medium trust. Locally, I use a custom security policy based on Medium trust, which includes the following — copied straight ... | [
{
"answer_id": 158263,
"author": "Sijin",
"author_id": 8884,
"author_profile": "https://Stackoverflow.com/users/8884",
"pm_score": 1,
"selected": false,
"text": "<p>Does it work if you put 127.0.0.1 instead of localhost?</p>\n"
},
{
"answer_id": 158440,
"author": "harpo",
... | 2008/10/01 | [
"https://Stackoverflow.com/questions/158257",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4525/"
] | My app uses a WebRequest at certain points to get pages from itself.
This shouldn't be a problem. It actually works fine on the server, which is a "shared" hosting package with Medium trust. Locally, I use a custom security policy based on Medium trust, which includes the following — copied straight from the default M... | My ignorance. I didn't know that the $OriginHost$ token was replaced using the originUrl attribute of the trust level — I thought it just came from the url of the app. I had originally left this attribute blank.
```
<trust level="CustomMedium" originUrl="http://localhost/" />
``` |
158,268 | <p>Ok I have two modules, each containing a class, the problem is their classes reference each other.</p>
<p>Lets say for example I had a room module and a person module containing CRoom and CPerson.</p>
<p>The CRoom class contains infomation about the room, and a CPerson list of every one in the room.</p>
<p>The CP... | [
{
"answer_id": 158326,
"author": "Brian",
"author_id": 9493,
"author_profile": "https://Stackoverflow.com/users/9493",
"pm_score": 3,
"selected": false,
"text": "<p>Do you actually need to reference the classes at class definition time? ie.</p>\n\n<pre><code> class CRoom(object):\n p... | 2008/10/01 | [
"https://Stackoverflow.com/questions/158268",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6266/"
] | Ok I have two modules, each containing a class, the problem is their classes reference each other.
Lets say for example I had a room module and a person module containing CRoom and CPerson.
The CRoom class contains infomation about the room, and a CPerson list of every one in the room.
The CPerson class however some... | **No need to import CRoom**
You don't use `CRoom` in `person.py`, so don't import it. Due to dynamic binding, Python doesn't need to "see all class definitions at compile time".
If you actually *do* use `CRoom` in `person.py`, then change `from room import CRoom` to `import room` and use module-qualified form `room.C... |
158,279 | <p>I've updated <strong>php.ini</strong> and moved <strong>php_mysql.dll</strong> as explained in <a href="https://stackoverflow.com/questions/11919/how-do-i-get-php-and-mysql-working-on-iis-70#94341">steps 6 and 8 here.</a></p>
<p>I get this error…</p>
<pre>Fatal error: Call to undefined function mysql_connec... | [
{
"answer_id": 158299,
"author": "vIceBerg",
"author_id": 17766,
"author_profile": "https://Stackoverflow.com/users/17766",
"pm_score": 1,
"selected": false,
"text": "<p>In the php.ini file, check if the extention path configuration is valid.</p>\n"
},
{
"answer_id": 158433,
... | 2008/10/01 | [
"https://Stackoverflow.com/questions/158279",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/83/"
] | I've updated **php.ini** and moved **php\_mysql.dll** as explained in [steps 6 and 8 here.](https://stackoverflow.com/questions/11919/how-do-i-get-php-and-mysql-working-on-iis-70#94341)
I get this error…
```
Fatal error: Call to undefined function mysql_connect() in C:\inetpub...
```
MySQL doesn't show up in my **ph... | As the others say these two values in php.ini are crucial.
I have the following in my php.ini: note the trailing slash - not sure if it is needed - but it does work.
```
extension_dir = "H:\apps\php\ext\"
extension=php_mysql.dll
```
Also it is worth ensuring that you only have one copy of php.ini on your machine - ... |
158,283 | <p>I have two vista Business machines. I have IE 7 installed on both. On my first machine (Computer1) if I go to this site (<a href="http://www.quirksmode.org/js/detect.html" rel="nofollow noreferrer">http://www.quirksmode.org/js/detect.html</a>), it says I am using "Explorer 6 on Windows". If I use Computer2 with V... | [
{
"answer_id": 158296,
"author": "Michael Stum",
"author_id": 91,
"author_profile": "https://Stackoverflow.com/users/91",
"pm_score": 1,
"selected": false,
"text": "<p>Can you post the User Agent of both machines? (you can go to some site that displays the user agent, i.e. <a href=\"http... | 2008/10/01 | [
"https://Stackoverflow.com/questions/158283",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11771/"
] | I have two vista Business machines. I have IE 7 installed on both. On my first machine (Computer1) if I go to this site (<http://www.quirksmode.org/js/detect.html>), it says I am using "Explorer 6 on Windows". If I use Computer2 with Vista Business and IE7, it says I am using "Explorer 7 on Windows". Here is a screen [... | ```
Computer1: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; InfoPath.2; .NET CLR 3.5.21022; .NET CLR 3.5.30729; .NET CLR 3.0.30618; MS-RTC LM 8; .NET CLR 1.1.4322) Rick Kierner (11 minutes ago)
Computer2: Moz... |
158,319 | <p>For all major browsers (except IE), the JavaScript <code>onload</code> event doesn’t fire when the page loads as a result of a back button operation — it only fires when the page is first loaded.</p>
<p>Can someone point me at some sample cross-browser code (Firefox, Opera, Safari, IE, …) that solves this problem? ... | [
{
"answer_id": 158360,
"author": "ckramer",
"author_id": 20504,
"author_profile": "https://Stackoverflow.com/users/20504",
"pm_score": 2,
"selected": false,
"text": "<p><a href=\"http://jquery.com/\" rel=\"nofollow noreferrer\">jQuery's</a> <a href=\"http://docs.jquery.com/Events/ready#f... | 2008/10/01 | [
"https://Stackoverflow.com/questions/158319",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24190/"
] | For all major browsers (except IE), the JavaScript `onload` event doesn’t fire when the page loads as a result of a back button operation — it only fires when the page is first loaded.
Can someone point me at some sample cross-browser code (Firefox, Opera, Safari, IE, …) that solves this problem? I’m familiar with Fir... | Guys, I found that JQuery has only one effect: the page is reloaded when the back button is pressed. This has nothing to do with "**ready**".
How does this work? Well, JQuery adds an **onunload** event listener.
```
// http://code.jquery.com/jquery-latest.js
jQuery(window).bind("unload", function() { // ...
```
By ... |
158,324 | <p>I have a basic model in which i have specified some of the fields to validate the presence of. in the create action in the controller i do the standard:</p>
<pre><code>@obj = SomeObject.new(params[:some_obj])
if @obj.save
flash[:notice] = "ok"
redirect...
else
flash[:error] = @obj.errors.full_messages.collec... | [
{
"answer_id": 158499,
"author": "Ryan Bigg",
"author_id": 15245,
"author_profile": "https://Stackoverflow.com/users/15245",
"pm_score": 4,
"selected": true,
"text": "<p>You <code>render :action => :new</code> rather than redirecting.</p>\n"
},
{
"answer_id": 161156,
"auth... | 2008/10/01 | [
"https://Stackoverflow.com/questions/158324",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18811/"
] | I have a basic model in which i have specified some of the fields to validate the presence of. in the create action in the controller i do the standard:
```
@obj = SomeObject.new(params[:some_obj])
if @obj.save
flash[:notice] = "ok"
redirect...
else
flash[:error] = @obj.errors.full_messages.collect { |msg| msg ... | You `render :action => :new` rather than redirecting. |
158,336 | <p>I need to remove temp files on Tomcat startup, the pass to a folder which contains temp files is in applicationContext.xml.</p>
<p>Is there a way to run a method/class only on Tomcat startup?</p>
| [
{
"answer_id": 158358,
"author": "skaffman",
"author_id": 21234,
"author_profile": "https://Stackoverflow.com/users/21234",
"pm_score": 7,
"selected": true,
"text": "<p>You could write a <code>ServletContextListener</code> which calls your method from the <code>contextInitialized()</code... | 2008/10/01 | [
"https://Stackoverflow.com/questions/158336",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23968/"
] | I need to remove temp files on Tomcat startup, the pass to a folder which contains temp files is in applicationContext.xml.
Is there a way to run a method/class only on Tomcat startup? | You could write a `ServletContextListener` which calls your method from the `contextInitialized()` method. You attach the listener to your webapp in web.xml, e.g.
```
<listener>
<listener-class>my.Listener</listener-class>
</listener>
```
and
```
package my;
public class Listener implements javax.servlet.Servle... |
158,343 | <p>I'm trying to do the following:</p>
<ol>
<li>User goes to web page, uploads XLS file</li>
<li>use ADO .NET to open XLS file using JET engine connection to locally uploaded file on web server</li>
</ol>
<p>This all works fine locally (my machine as the client and the web server) - and in fact is working on the cust... | [
{
"answer_id": 159194,
"author": "JustinD",
"author_id": 12063,
"author_profile": "https://Stackoverflow.com/users/12063",
"pm_score": 3,
"selected": true,
"text": "<p>Ok, figured it out -</p>\n\n<p>turns out that even with IIS using impersonation and the TMP/TEMP environment variables b... | 2008/10/01 | [
"https://Stackoverflow.com/questions/158343",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12063/"
] | I'm trying to do the following:
1. User goes to web page, uploads XLS file
2. use ADO .NET to open XLS file using JET engine connection to locally uploaded file on web server
This all works fine locally (my machine as the client and the web server) - and in fact is working on the customer's web server with remote cli... | Ok, figured it out -
turns out that even with IIS using impersonation and the TMP/TEMP environment variables being set to C:\WINDOWS\Temp the ASP.NET process is still running under the ASPNET account and each individual user needed permissions to the Documents and Settings\ASPNET\Local Settings\Temp folder
The other ... |
158,359 | <p>I need to know, from within Powershell, if the current drive is a mapped drive or not.</p>
<p>Unfortunately, Get-PSDrive is not working "as expected":</p>
<pre><code>PS:24 H:\temp
>get-psdrive h
Name Provider Root CurrentLocation
---- -------- ---- ---------------
H Fi... | [
{
"answer_id": 158456,
"author": "Jeff Stong",
"author_id": 2459,
"author_profile": "https://Stackoverflow.com/users/2459",
"pm_score": 4,
"selected": true,
"text": "<p>Use the .NET framework:</p>\n\n<pre><code>PS H:\\> $x = new-object system.io.driveinfo(\"h:\\\")\nPS H:\\> $x.dri... | 2008/10/01 | [
"https://Stackoverflow.com/questions/158359",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12344/"
] | I need to know, from within Powershell, if the current drive is a mapped drive or not.
Unfortunately, Get-PSDrive is not working "as expected":
```
PS:24 H:\temp
>get-psdrive h
Name Provider Root CurrentLocation
---- -------- ---- ---------------
H FileSystem H:\ ... | Use the .NET framework:
```
PS H:\> $x = new-object system.io.driveinfo("h:\")
PS H:\> $x.drivetype
Network
``` |
158,372 | <p>I'm building a simple Todo List application where I want to be able to have multiple lists floating around my desktop that I can label and manage tasks in.</p>
<p>The relevant UIElements in my app are:</p>
<p>Window1 (Window)
TodoList (User Control)
TodoStackCard (User Control)</p>
<p>Window1 looks like this:</p>
<p... | [
{
"answer_id": 158408,
"author": "Michael Brown",
"author_id": 14359,
"author_profile": "https://Stackoverflow.com/users/14359",
"pm_score": 3,
"selected": true,
"text": "<p>You have to call DoDragDrop to initialize the Drag And Drop framework. Jaime Rodriguez provides a guide to Drag an... | 2008/10/01 | [
"https://Stackoverflow.com/questions/158372",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5152/"
] | I'm building a simple Todo List application where I want to be able to have multiple lists floating around my desktop that I can label and manage tasks in.
The relevant UIElements in my app are:
Window1 (Window)
TodoList (User Control)
TodoStackCard (User Control)
Window1 looks like this:
```xml
<Window x:Class="Ta... | You have to call DoDragDrop to initialize the Drag And Drop framework. Jaime Rodriguez provides a guide to Drag and Drop [here](https://web.archive.org/web/20160113133757/http://blogs.msdn.com:80/b/jaimer/archive/2007/07/12/drag-drop-in-wpf-explained-end-to-end.aspx) |
158,382 | <p>For some reason, lately the *.UDL files on many of my client systems are no longer compatible as they were once saved as ANSI files, which is no longer compatible with the expected UNICODE file format. The end result is an error dialog which states "the file is not a valid compound file". </p>
<p>What is the easi... | [
{
"answer_id": 158435,
"author": "gabr",
"author_id": 4997,
"author_profile": "https://Stackoverflow.com/users/4997",
"pm_score": 4,
"selected": true,
"text": "<p>This is very simple to do with my <a href=\"http://gp.17slon.com/gp/gptextfile.htm\" rel=\"noreferrer\">TGpTextFile</a> unit.... | 2008/10/01 | [
"https://Stackoverflow.com/questions/158382",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9217/"
] | For some reason, lately the \*.UDL files on many of my client systems are no longer compatible as they were once saved as ANSI files, which is no longer compatible with the expected UNICODE file format. The end result is an error dialog which states "the file is not a valid compound file".
What is the easiest way to ... | This is very simple to do with my [TGpTextFile](http://gp.17slon.com/gp/gptextfile.htm) unit. I'll put together a short sample and post it here.
It should also be very simple with the new Delphi 2009 - are you maybe using it?
EDIT: This his how you can do it using my stuff in pre-2009 Delphis.
```
var
strAnsi : ... |
158,438 | <p>I have a website where we use Javascript to submit the login form. On Firefox it prompts the user to remember their password, when they login, but on IE7 it doesn't.</p>
<p>After doing some research it looks like the user is only prompted in IE7 when the form is submitted via a Submit control. I've created some s... | [
{
"answer_id": 158469,
"author": "Sijin",
"author_id": 8884,
"author_profile": "https://Stackoverflow.com/users/8884",
"pm_score": 1,
"selected": false,
"text": "<p>Did you try putting in url in the href and attaching a click event handler to submit the form and returning false from the ... | 2008/10/01 | [
"https://Stackoverflow.com/questions/158438",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/869/"
] | I have a website where we use Javascript to submit the login form. On Firefox it prompts the user to remember their password, when they login, but on IE7 it doesn't.
After doing some research it looks like the user is only prompted in IE7 when the form is submitted via a Submit control. I've created some sample html t... | Why not try hooking the form submission this way?
```
<html>
<head>
<title>test autocomplete</title>
<script type="text/javascript">
function submitForm()
{
return true;
}
</script>
</head>
<body>
<form method="GET" act... |
158,457 | <p>So I have a daemon running on a Linux system, and I want to have a record of its activities: a log. The question is, what is the "best" way to accomplish this?</p>
<p>My first idea is to simply open a file and write to it.</p>
<pre><code>FILE* log = fopen("logfile.log", "w");
/* daemon works...needs to write to lo... | [
{
"answer_id": 158471,
"author": "Vinko Vrsalovic",
"author_id": 5190,
"author_profile": "https://Stackoverflow.com/users/5190",
"pm_score": 8,
"selected": true,
"text": "<p>Unix has had for a long while a special logging framework called <a href=\"http://en.wikipedia.org/wiki/Syslog\" r... | 2008/10/01 | [
"https://Stackoverflow.com/questions/158457",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12926/"
] | So I have a daemon running on a Linux system, and I want to have a record of its activities: a log. The question is, what is the "best" way to accomplish this?
My first idea is to simply open a file and write to it.
```
FILE* log = fopen("logfile.log", "w");
/* daemon works...needs to write to log */
fprintf(log, "fo... | Unix has had for a long while a special logging framework called [syslog](http://en.wikipedia.org/wiki/Syslog). Type in your shell
```
man 3 syslog
```
and you'll get the help for the C interface to it.
[Some](http://www.codeproject.com/KB/IP/syslog_client.aspx) [examples](http://www.c.happycodings.com/Gnu-Linux/c... |
158,479 | <p>I have a PDF file, which contains data that we need to import into a database. The files seem to be pdf scans of printed alphanumeric text. Looks like 10 pt. Times New Roman. </p>
<p>Are there any tools or components that can will allow me to recognize and parse this text?</p>
| [
{
"answer_id": 158494,
"author": "Sijin",
"author_id": 8884,
"author_profile": "https://Stackoverflow.com/users/8884",
"pm_score": 1,
"selected": false,
"text": "<p>A quick google search shows this promising result.\n<a href=\"http://www.pdftron.com/net/index.html\" rel=\"nofollow norefe... | 2008/10/01 | [
"https://Stackoverflow.com/questions/158479",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24204/"
] | I have a PDF file, which contains data that we need to import into a database. The files seem to be pdf scans of printed alphanumeric text. Looks like 10 pt. Times New Roman.
Are there any tools or components that can will allow me to recognize and parse this text? | I've used [pdftohtml](http://pdftohtml.sourceforge.net/) to successfully strip tables out of PDF into CSV. It's based on [Xpdf](http://www.foolabs.com/xpdf/portsntools.html), which is a more general purpose tool, that includes [pdftotext](http://en.wikipedia.org/wiki/Pdftotext). I just wrap it as a Process.Start call f... |
158,482 | <p>This question is based on <a href="https://stackoverflow.com/questions/150514/custom-method-in-model-to-return-an-object">another question of mine</a>(thankfully answered).</p>
<p>So if in a model I have this:</p>
<pre><code>def self.find_extended
person = Person.find(:first)
complete_name = person.firstna... | [
{
"answer_id": 158504,
"author": "Ryan Bigg",
"author_id": 15245,
"author_profile": "https://Stackoverflow.com/users/15245",
"pm_score": 1,
"selected": false,
"text": "<p>You could define:</p>\n\n<pre><code>attr_accessor :complete_name\n</code></pre>\n\n<p>in the person model and then ju... | 2008/10/01 | [
"https://Stackoverflow.com/questions/158482",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3718/"
] | This question is based on [another question of mine](https://stackoverflow.com/questions/150514/custom-method-in-model-to-return-an-object)(thankfully answered).
So if in a model I have this:
```
def self.find_extended
person = Person.find(:first)
complete_name = person.firstname + ', ' + person.lastname
... | I think the best way to do this is creation of complete\_name attribute in your Person class:
```
def complete_name
firstname + ', ' + lastname
end
``` |
158,492 | <p>How do I perform a network login, to access a shared driver for instance, programmatically in c#? The same can be achieved by either attempting to open a share through the explorer, or by the net use shell command.</p>
| [
{
"answer_id": 158517,
"author": "Sijin",
"author_id": 8884,
"author_profile": "https://Stackoverflow.com/users/8884",
"pm_score": 0,
"selected": false,
"text": "<p>You'll need to use Windows Identity Impersonation, take a look at these links\n<a href=\"http://blogs.msdn.com/shawnfa/arch... | 2008/10/01 | [
"https://Stackoverflow.com/questions/158492",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13855/"
] | How do I perform a network login, to access a shared driver for instance, programmatically in c#? The same can be achieved by either attempting to open a share through the explorer, or by the net use shell command. | P/Invoke call to [WNetAddConnection2](http://msdn.microsoft.com/en-us/library/aa385413(VS.85).aspx) will do the trick. Look [here](http://cticoder.wordpress.com/2008/08/11/msbuild-custom-task-drive-mapper/) for more info.
```
[DllImport("mpr.dll")]
public static extern int WNetAddConnection2A
(
[MarshalAs(Unma... |
158,508 | <p>I have some formulas in my reports, and to prevent divsion by zero I do like this in the expression field:</p>
<p>=IIF(Fields!F1.Value <> 0, Fields!F2.Value/Fields!F1.Value, 0)</p>
<p>This normally works fine, but when both F1 and F2 are zero, I get "#Error" in the report, and I get this warning: "The Value exp... | [
{
"answer_id": 158527,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 2,
"selected": false,
"text": "<p>IIF() is just a function, and like with any function <em>all</em> the arguments are evaluated <em>before</em> the ... | 2008/10/01 | [
"https://Stackoverflow.com/questions/158508",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3308/"
] | I have some formulas in my reports, and to prevent divsion by zero I do like this in the expression field:
=IIF(Fields!F1.Value <> 0, Fields!F2.Value/Fields!F1.Value, 0)
This normally works fine, but when both F1 and F2 are zero, I get "#Error" in the report, and I get this warning: "The Value expression for the text... | There has to be a prettier way than this, but this should work:
```
=IIF(Fields!F1.Value <> 0, Fields!F2.Value /
IIF(Fields!F1.Value <> 0, Fields!F1.Value, 42), 0)
``` |
158,519 | <p>I need advice on how to handle relatively large set of flags in my SQL2k8 table.</p>
<p>Two question, bear with me please :)</p>
<p>Let's say I have 20 flags I'd like to store for one record.</p>
<p>For example:</p>
<p>CanRead = 0x1
CanWrite = 0x2
CanModify = 0x4
...
and so on to the final flag 2^20</p>
<p>Now,... | [
{
"answer_id": 158560,
"author": "Vinko Vrsalovic",
"author_id": 5190,
"author_profile": "https://Stackoverflow.com/users/5190",
"pm_score": 3,
"selected": false,
"text": "<p>What about</p>\n\n<pre><code>WHERE (Permissions & CanWrite) = CanWrite \nOR (Permissions & CanModify) = C... | 2008/10/01 | [
"https://Stackoverflow.com/questions/158519",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I need advice on how to handle relatively large set of flags in my SQL2k8 table.
Two question, bear with me please :)
Let's say I have 20 flags I'd like to store for one record.
For example:
CanRead = 0x1
CanWrite = 0x2
CanModify = 0x4
...
and so on to the final flag 2^20
Now, if i set the following combination of... | **Don't to that.** It's like saving a CSV string into a memo field and defeating the purpose of a database.
Use a boolean (bit) value for every flag. In this specific sample you're finding everything that can read and can write or modify:
```
WHERE CanRead AND (CanWrite OR CanModify)
```
Simple pure SQL with no cle... |
158,520 | <p>In PowerShell, even if it's possible to know if a drive is a network drive: see <a href="https://stackoverflow.com/questions/158359/in-powershell-how-can-i-determine-if-the-current-drive-is-a-networked-drive-or">In PowerShell, how can I determine if the current drive is a networked drive or not?</a></p>
<p>When I t... | [
{
"answer_id": 158531,
"author": "EBGreen",
"author_id": 1358,
"author_profile": "https://Stackoverflow.com/users/1358",
"pm_score": 3,
"selected": true,
"text": "<p>Try WMI:</p>\n\n<pre><code>Get-WMIObject -query \"Select ProviderName From Win32_LogicalDisk Where DeviceID='H:'\"\n</code... | 2008/10/01 | [
"https://Stackoverflow.com/questions/158520",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12344/"
] | In PowerShell, even if it's possible to know if a drive is a network drive: see [In PowerShell, how can I determine if the current drive is a networked drive or not?](https://stackoverflow.com/questions/158359/in-powershell-how-can-i-determine-if-the-current-drive-is-a-networked-drive-or)
When I try to get the "root" ... | Try WMI:
```
Get-WMIObject -query "Select ProviderName From Win32_LogicalDisk Where DeviceID='H:'"
``` |
158,536 | <p>In an application I'm working on, we have a bunch of custom controls with their ControlTemplates defined in Generic.xaml.</p>
<p>For instance, our custom textbox would look similar to this:</p>
<pre><code><Style TargetType="{x:Type controls:FieldTextBox}">
<Setter Property="Template">
<S... | [
{
"answer_id": 158588,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "<p>Within your control template you can add a Trigger that sets the FocusedElement of the StackPanel's <a href=\"http://msdn.m... | 2008/10/01 | [
"https://Stackoverflow.com/questions/158536",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12999/"
] | In an application I'm working on, we have a bunch of custom controls with their ControlTemplates defined in Generic.xaml.
For instance, our custom textbox would look similar to this:
```
<Style TargetType="{x:Type controls:FieldTextBox}">
<Setter Property="Template">
<Setter.Value>
<ControlTem... | Within your control template you can add a Trigger that sets the FocusedElement of the StackPanel's [FocusManager](http://msdn.microsoft.com/en-us/library/system.windows.input.focusmanager.focusedelement.aspx) to the textbox you want focused. You set the Trigger's property to {TemplateBinding IsFocused} so it fires whe... |
158,539 | <p>break line tag is not working in firefox, neither in chrome. When i see the source of my page i get: </p>
<pre><code><p>Zugang zu Testaccount:</br></br>peter petrelli </br></br>sein Standardpwd.</br></br>peter.heroes.com</p>
</code></pre>
<p>However when i do view se... | [
{
"answer_id": 158542,
"author": "nsanders",
"author_id": 1244,
"author_profile": "https://Stackoverflow.com/users/1244",
"pm_score": 0,
"selected": false,
"text": "<p>It should just be <br>.</p>\n"
},
{
"answer_id": 158549,
"author": "Jason Navarrete",
"author_id":... | 2008/10/01 | [
"https://Stackoverflow.com/questions/158539",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2138/"
] | break line tag is not working in firefox, neither in chrome. When i see the source of my page i get:
```
<p>Zugang zu Testaccount:</br></br>peter petrelli </br></br>sein Standardpwd.</br></br>peter.heroes.com</p>
```
However when i do view selected source, i get:
```
<p>Zugang zu Testaccount: peter petrelli sein... | You're looking for `<br />` instead of `</br>`
Self closing tags such as *br* have the slash at the end of the tag.
Here are the other self-closing tags in XHTML:
* [What are all the valid self-closing tags in XHTML (as implemented by the major browsers)?](https://stackoverflow.com/questions/97522/what-are-all-the-v... |
158,544 | <p>Can you do a better code? I need to check/uncheck all childs according to parent and when an child is checked, check parent, when all childs are unchecked uncheck parent.</p>
<pre><code> $(".parent").children("input").click(function() {
$(this).parent().siblings("input").attr("checked", this.checked);
});
$... | [
{
"answer_id": 159786,
"author": "Hafthor",
"author_id": 4489,
"author_profile": "https://Stackoverflow.com/users/4489",
"pm_score": 2,
"selected": true,
"text": "<pre><code>$(\".parent\").children(\"input\").click(function() {\n $(this).parent().siblings(\"input\").attr(\"checked\", ... | 2008/10/01 | [
"https://Stackoverflow.com/questions/158544",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20683/"
] | Can you do a better code? I need to check/uncheck all childs according to parent and when an child is checked, check parent, when all childs are unchecked uncheck parent.
```
$(".parent").children("input").click(function() {
$(this).parent().siblings("input").attr("checked", this.checked);
});
$(".parent").si... | ```
$(".parent").children("input").click(function() {
$(this).parent().siblings("input").attr("checked", this.checked);
});
$(".parent").siblings("input").click(function() {
$(this).siblings("div").children("input").attr("checked",
this.checked || $(this).siblings("input[checked]").length>0
);
});
... |
158,546 | <p>I'm creating a networked server for a boggle-clone I wrote in python, which accepts users, solves the boards, and scores the player input. The dictionary file I'm using is 1.8MB (the ENABLE2K dictionary), and I need it to be available to several game solver classes. Right now, I have it so that each class iterates... | [
{
"answer_id": 158622,
"author": "Jeremy Brown",
"author_id": 21776,
"author_profile": "https://Stackoverflow.com/users/21776",
"pm_score": 1,
"selected": false,
"text": "<p>Even though it is essentially a singleton at this point, the usual arguments against globals apply. For a pythoni... | 2008/10/01 | [
"https://Stackoverflow.com/questions/158546",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24208/"
] | I'm creating a networked server for a boggle-clone I wrote in python, which accepts users, solves the boards, and scores the player input. The dictionary file I'm using is 1.8MB (the ENABLE2K dictionary), and I need it to be available to several game solver classes. Right now, I have it so that each class iterates thro... | If you create a dictionary.py module, containing code which reads the file and builds a dictionary, this code will only be executed the first time it is imported. Further imports will return a reference to the existing module instance. As such, your classes can:
```
import dictionary
dictionary.words[whatever]
```
... |
158,568 | <p>I have a temporary file with data that's returned as part of a SOAP response via a MTOM binary attachment. I would like to trash it as soon as the method call "ends" (i.e., finishes transferring). What's the best way for me to do this? The best way I can figure out how to do this is to delete them when the sessio... | [
{
"answer_id": 158597,
"author": "Steven M. Cherry",
"author_id": 24193,
"author_profile": "https://Stackoverflow.com/users/24193",
"pm_score": 0,
"selected": false,
"text": "<p>Are you using standard java temp files? If so, you can do this:</p>\n\n<pre><code>File script = File.createTe... | 2008/10/01 | [
"https://Stackoverflow.com/questions/158568",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12979/"
] | I have a temporary file with data that's returned as part of a SOAP response via a MTOM binary attachment. I would like to trash it as soon as the method call "ends" (i.e., finishes transferring). What's the best way for me to do this? The best way I can figure out how to do this is to delete them when the session is d... | I ran into this same problem. The issue is that the JAX-WS stack manages the file. It is not possible to determine in your code when JAX-WS is done with the file so you do not know when to delete it.
In my case, I am using a DataHandler on my object model rather than a file. MyFileResult would have the following field... |
158,585 | <p>I am trying to add a timed delay in a C++ program, and was wondering if anyone has any suggestions on what I can try or information I can look at?</p>
<p>I wish I had more details on how I am implementing this timed delay, but until I have more information on how to add a timed delay I am not sure on how I should e... | [
{
"answer_id": 158589,
"author": "J.J.",
"author_id": 21204,
"author_profile": "https://Stackoverflow.com/users/21204",
"pm_score": 5,
"selected": false,
"text": "<p>Do you want something as simple like:</p>\n<pre><code>#include <unistd.h>\nsleep(3);//sleeps for 3 second\n</code></... | 2008/10/01 | [
"https://Stackoverflow.com/questions/158585",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20229/"
] | I am trying to add a timed delay in a C++ program, and was wondering if anyone has any suggestions on what I can try or information I can look at?
I wish I had more details on how I am implementing this timed delay, but until I have more information on how to add a timed delay I am not sure on how I should even attemp... | [In Win32](https://msdn.microsoft.com/en-us/library/windows/desktop/ms686298(v=vs.85).aspx):
```
#include<windows.h>
Sleep(milliseconds);
```
[In Unix](http://linux.die.net/man/3/usleep):
```
#include<unistd.h>
unsigned int microsecond = 1000000;
usleep(3 * microsecond);//sleeps for 3 second
```
`sleep()` only ta... |
158,628 | <p>I have a function in a native DLL defined as follows:</p>
<pre><code>#include <string>
void SetPath(string path);
</code></pre>
<p>I tried to put this in Microsoft's P/Invoke Interop Assistant, but it chokes on the "string" class (which I think is from MFC?).</p>
<p>I have tried marshaling it as a variety o... | [
{
"answer_id": 158669,
"author": "Andrew Queisser",
"author_id": 18321,
"author_profile": "https://Stackoverflow.com/users/18321",
"pm_score": 4,
"selected": true,
"text": "<p>Looks like you're trying to use the C++ standard library string class. I doubt that will be easy to Marshal. Bet... | 2008/10/01 | [
"https://Stackoverflow.com/questions/158628",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/194/"
] | I have a function in a native DLL defined as follows:
```
#include <string>
void SetPath(string path);
```
I tried to put this in Microsoft's P/Invoke Interop Assistant, but it chokes on the "string" class (which I think is from MFC?).
I have tried marshaling it as a variety of different types (C# String, char[], b... | Looks like you're trying to use the C++ standard library string class. I doubt that will be easy to Marshal. Better to stick with a char \* and Marshal as StringBuilder. That's what I usually do. You'll have to add a wrapper that generates the C++ string for you. |
158,633 | <p>What VBA code is required to perform an HTTP POST from an Excel spreadsheet?</p>
| [
{
"answer_id": 158647,
"author": "Mark Biek",
"author_id": 305,
"author_profile": "https://Stackoverflow.com/users/305",
"pm_score": 3,
"selected": false,
"text": "<p>You can use <code>ServerXMLHTTP</code> in a VBA project by adding a reference to <code>MSXML</code>.</p>\n\n<blockquote>\... | 2008/10/01 | [
"https://Stackoverflow.com/questions/158633",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4023/"
] | What VBA code is required to perform an HTTP POST from an Excel spreadsheet? | ```
Set objHTTP = CreateObject("MSXML2.ServerXMLHTTP")
URL = "http://www.somedomain.com"
objHTTP.Open "POST", URL, False
objHTTP.setRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"
objHTTP.send ""
```
Alternatively, for greater control over the HTTP request you can use [`WinHttp.WinHtt... |
158,634 | <p>Is it possible to do a cast within a LINQ query (for the compiler's sake)?</p>
<p>The following code isn't terrible, but it would be nice to make it into one query:</p>
<pre><code>Content content = dataStore.RootControl as Controls.Content;
List<TabSection> tabList = (from t in content.ChildControls
... | [
{
"answer_id": 158675,
"author": "Chris Ammerman",
"author_id": 2729,
"author_profile": "https://Stackoverflow.com/users/2729",
"pm_score": 6,
"selected": true,
"text": "<p>Try this:</p>\n\n<pre><code>from TabSection t in content.ChildControls\n</code></pre>\n\n<p>Also, even if this were... | 2008/10/01 | [
"https://Stackoverflow.com/questions/158634",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12999/"
] | Is it possible to do a cast within a LINQ query (for the compiler's sake)?
The following code isn't terrible, but it would be nice to make it into one query:
```
Content content = dataStore.RootControl as Controls.Content;
List<TabSection> tabList = (from t in content.ChildControls
select... | Try this:
```
from TabSection t in content.ChildControls
```
Also, even if this were not available (or for a different, future scenario you may encounter), you wouldn't be restricted to converting everything to Lists. Converting to a List causes query evaluation on the spot. But if you removing the ToList call, you ... |
158,651 | <p>You do you manage the same presenter working with different repositories using the MVP pattern? </p>
<p>I just have multiple constructor overloads and the presenter simply uses the one that is suitable for the scenario. </p>
<pre><code>AddCustomerPresenter presenter = new AddCustomerPresenter(this,customerReposito... | [
{
"answer_id": 158788,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "<p>Why not have</p>\n\n<pre><code>IRepository { /* .. */ }\nCustomerRepository : IRepository { /* .. */ }\nArchiveRepository :... | 2008/10/01 | [
"https://Stackoverflow.com/questions/158651",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3797/"
] | You do you manage the same presenter working with different repositories using the MVP pattern?
I just have multiple constructor overloads and the presenter simply uses the one that is suitable for the scenario.
```
AddCustomerPresenter presenter = new AddCustomerPresenter(this,customerRepository);
presenter.AddCu... | Thanks Will!
But CustomerRepository and ArchiveRepository are not related in any way. They are two completely different things. |
158,664 | <p>I have a lot of changes in a working folder, and something screwed up trying to do an update.</p>
<p>Now when I issue an 'svn cleanup' I get:</p>
<pre><code>>svn cleanup .
svn: In directory '.'
svn: Error processing command 'modify-wcprop' in '.'
svn: 'MemPoolTests.cpp' is not under version control
</code></pre... | [
{
"answer_id": 158680,
"author": "Martin Beckett",
"author_id": 10897,
"author_profile": "https://Stackoverflow.com/users/10897",
"pm_score": 5,
"selected": false,
"text": "<p>If all else fails:</p>\n\n<ol>\n<li>Check out into a new folder.</li>\n<li>Copy your modified files over.</li>\n... | 2008/10/01 | [
"https://Stackoverflow.com/questions/158664",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3631/"
] | I have a lot of changes in a working folder, and something screwed up trying to do an update.
Now when I issue an 'svn cleanup' I get:
```
>svn cleanup .
svn: In directory '.'
svn: Error processing command 'modify-wcprop' in '.'
svn: 'MemPoolTests.cpp' is not under version control
```
MemPoolTests.cpp is a new file... | When starting all over is not an option...
I deleted the log file in the `.svn` directory (I also deleted the offending file in `.svn/props-base`), did a cleanup, and resumed my update. |
158,665 | <p>I want to delete all directories and subdirectories under a root directory that are contain "tmp" in their names. This should include any .svn files too. My first guess is to use </p>
<pre><code><delete>
<dirset dir="${root}">
<include name="**/*tmp*" />
</dirset>
</dele... | [
{
"answer_id": 158672,
"author": "Blauohr",
"author_id": 22176,
"author_profile": "https://Stackoverflow.com/users/22176",
"pm_score": 3,
"selected": false,
"text": "<p>try:</p>\n\n<pre><code><delete includeemptydirs=\"true\">\n <fileset dir=\"${root}\">\n <inc... | 2008/10/01 | [
"https://Stackoverflow.com/questions/158665",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4737/"
] | I want to delete all directories and subdirectories under a root directory that are contain "tmp" in their names. This should include any .svn files too. My first guess is to use
```
<delete>
<dirset dir="${root}">
<include name="**/*tmp*" />
</dirset>
</delete>
```
This does not seem to work as y... | Here's the answer that worked for me:
```
<delete includeemptydirs="true">
<fileset dir="${root}" defaultexcludes="false">
<include name="**/*tmp*/**" />
</fileset>
</delete>
```
I had an added complication I needed to remove `.svn` directories too. With `defaultexcludes`, `.*` files were being exclud... |
158,673 | <p>I'd like to check if the current browser supports the onbeforeunload event.
The common javascript way to do this does not seem to work:</p>
<pre><code>if (window.onbeforeunload) {
alert('yes');
}
else {
alert('no');
}
</code></pre>
<p>Actually, it only checks whether some handler has been attached to the e... | [
{
"answer_id": 158738,
"author": "rfunduk",
"author_id": 210,
"author_profile": "https://Stackoverflow.com/users/210",
"pm_score": -1,
"selected": false,
"text": "<p>It would probably be better to just find out by hand which browsers support it and then have your conditional more like:</... | 2008/10/01 | [
"https://Stackoverflow.com/questions/158673",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12111/"
] | I'd like to check if the current browser supports the onbeforeunload event.
The common javascript way to do this does not seem to work:
```
if (window.onbeforeunload) {
alert('yes');
}
else {
alert('no');
}
```
Actually, it only checks whether some handler has been attached to the event.
Is there a way to de... | I wrote about a more-or-less [reliable inference for detecting event support](http://perfectionkills.com/detecting-event-support-without-browser-sniffing/) in modern browsers some time ago. You can see on a demo page that "beforeunload" is supported in at least Safari 4+, FF3.x+ and IE.
**Edit**: This technique is now... |
158,706 | <p>I'm using the Excel interop in C# (<code>ApplicationClass</code>) and have placed the following code in my finally clause:</p>
<pre><code>while (System.Runtime.InteropServices.Marshal.ReleaseComObject(excelSheet) != 0) { }
excelSheet = null;
GC.Collect();
GC.WaitForPendingFinalizers();
</code></pre>
<p>Although th... | [
{
"answer_id": 158751,
"author": "Philip Fourie",
"author_id": 11123,
"author_profile": "https://Stackoverflow.com/users/11123",
"pm_score": 6,
"selected": false,
"text": "<p>This worked for a project I was working on:</p>\n\n<pre><code>excelApp.Quit();\nMarshal.ReleaseComObject (excelWB... | 2008/10/01 | [
"https://Stackoverflow.com/questions/158706",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11989/"
] | I'm using the Excel interop in C# (`ApplicationClass`) and have placed the following code in my finally clause:
```
while (System.Runtime.InteropServices.Marshal.ReleaseComObject(excelSheet) != 0) { }
excelSheet = null;
GC.Collect();
GC.WaitForPendingFinalizers();
```
Although this kind of works, the `Excel.exe` pro... | Excel does not quit because your application is still holding references to COM objects.
**I guess you're invoking at least one member of a COM object without assigning it to a variable.**
For me it was the *excelApp.Worksheets* object which I directly used without assigning it to a variable:
```
Worksheet sheet = e... |
158,710 | <p>I'm trying to use CSS (<strong>under <code>@media print</code></strong>) and JavaScript to print a one-page document with a given piece of text made as large as possible while still fitting inside a given width. The length of the text is not known beforehand, so simply using a fixed-width font is not an option.</p>... | [
{
"answer_id": 158870,
"author": "Herb Caudill",
"author_id": 239663,
"author_profile": "https://Stackoverflow.com/users/239663",
"pm_score": 0,
"selected": false,
"text": "<p>I don't know of a way to do this in CSS. I think your best bet would be to use Javascript: </p>\n\n<ol>\n<li>Put... | 2008/10/01 | [
"https://Stackoverflow.com/questions/158710",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16777/"
] | I'm trying to use CSS (**under `@media print`**) and JavaScript to print a one-page document with a given piece of text made as large as possible while still fitting inside a given width. The length of the text is not known beforehand, so simply using a fixed-width font is not an option.
To put it another way, I'm loo... | Here's some code I ended up using, in case someone might find it useful. All you need to do is make the outer DIV the size you want in inches.
```
function make_big(id) // must be an inline element inside a block-level element
{
var e = document.getElementById(id);
e.style.whiteSpace = 'nowrap';
e.style.te... |
158,716 | <p>The question gives all necessary data: what is an efficient algorithm to generate a sequence of <em>K</em> non-repeating integers within a given interval <em>[0,N-1]</em>. The trivial algorithm (generating random numbers and, before adding them to the sequence, looking them up to see if they were already there) is v... | [
{
"answer_id": 158728,
"author": "Bill the Lizard",
"author_id": 1288,
"author_profile": "https://Stackoverflow.com/users/1288",
"pm_score": 1,
"selected": false,
"text": "<p>Speed up the trivial algorithm by storing the K numbers in a hashing store. Knowing K before you start takes awa... | 2008/10/01 | [
"https://Stackoverflow.com/questions/158716",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15472/"
] | The question gives all necessary data: what is an efficient algorithm to generate a sequence of *K* non-repeating integers within a given interval *[0,N-1]*. The trivial algorithm (generating random numbers and, before adding them to the sequence, looking them up to see if they were already there) is very expensive if ... | The [random module](https://docs.python.org/2/library/random.html#random.sample) from Python library makes it extremely easy and effective:
```
from random import sample
print sample(xrange(N), K)
```
`sample` function returns a list of K unique elements chosen from the given sequence.
`xrange` is a "list emulato... |
158,750 | <p>I am wondering if there is a way to combine multiple images into a single image using only JavaScript. Is this something that Canvas will be able to do. The effect can be done with positing, but can you combine them into a single image for download?</p>
<p><strong>Update Oct 1, 2008:</strong></p>
<p>Thanks for t... | [
{
"answer_id": 158794,
"author": "Daniel Papasian",
"author_id": 7548,
"author_profile": "https://Stackoverflow.com/users/7548",
"pm_score": 1,
"selected": false,
"text": "<p>I don't think you can or would want to do this with client side javascript (\"combing them into a single image fo... | 2008/10/01 | [
"https://Stackoverflow.com/questions/158750",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/415/"
] | I am wondering if there is a way to combine multiple images into a single image using only JavaScript. Is this something that Canvas will be able to do. The effect can be done with positing, but can you combine them into a single image for download?
**Update Oct 1, 2008:**
Thanks for the advice, I was helping someone... | I know this is an old question and the OP found a workaround solution, but this will work if the images and canvas are already part of the HTML page.
```
<img id="img1" src="imgfile1.png">
<img id="img2" src="imgfile2.png">
<canvas id="canvas"></canvas>
<script type="text/javascript">
var img1 = document.getElementBy... |
158,760 | <p>I am looking for any examples or guides to using Linq over WCF (n-tier application). Please specify if you are showing something for Linq-to-SQL or Linq-to-entities. I would like to see usage examples for both. </p>
<p>I am wondering how things like deffered execution works over WCF (if it works at all)? Cyclic ref... | [
{
"answer_id": 158797,
"author": "Mark Cidade",
"author_id": 1659,
"author_profile": "https://Stackoverflow.com/users/1659",
"pm_score": 4,
"selected": true,
"text": "<p>There isn't any LINQ provider that I'm aware of for generic WCF-based queries. <a href=\"http://blogs.msdn.com/astoria... | 2008/10/01 | [
"https://Stackoverflow.com/questions/158760",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19854/"
] | I am looking for any examples or guides to using Linq over WCF (n-tier application). Please specify if you are showing something for Linq-to-SQL or Linq-to-entities. I would like to see usage examples for both.
I am wondering how things like deffered execution works over WCF (if it works at all)? Cyclic references su... | There isn't any LINQ provider that I'm aware of for generic WCF-based queries. [LINQ to ADO.NET Data Services](http://blogs.msdn.com/astoriateam/archive/2007/12/11/linq-to-ado-net-data-services.aspx), however, lets you query an Entity model over WCF/REST.
From [Andy Conrad's blog](http://blogs.msdn.com/aconrad/archive... |
158,778 | <p>Let's say you have a function that returns a date:</p>
<pre><code>Date myFunc(paramA, paramB){
//conditionally return a date?
}
</code></pre>
<p>Is it appropriate to return <code>null</code> from this function? This seems ugly because it forces clients to check for <code>null</code>.</p>
<p>The "null object" ... | [
{
"answer_id": 158784,
"author": "GavinCattell",
"author_id": 21644,
"author_profile": "https://Stackoverflow.com/users/21644",
"pm_score": 3,
"selected": false,
"text": "<p>null is quite acceptable. However if you want to return null on an error, consider throwing an exception instead.<... | 2008/10/01 | [
"https://Stackoverflow.com/questions/158778",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1129162/"
] | Let's say you have a function that returns a date:
```
Date myFunc(paramA, paramB){
//conditionally return a date?
}
```
Is it appropriate to return `null` from this function? This seems ugly because it forces clients to check for `null`.
The "null object" pattern is an implementation pattern that addresses this... | The null object pattern is not for what you are trying to do. That pattern is about creating an object with no functionality in it's implementation that you can pass to a given function that requires an object not being null. An example is [NullProgressMonitor](http://download.eclipse.org/eclipse/downloads/documentatio... |
158,780 | <p>I'm trying to iterate all the controls on a form and enable ClearType font smoothing. Something like this:</p>
<pre><code>procedure TForm4.UpdateControls(AParent: TWinControl);
var
I: Integer;
ACtrl: TControl;
tagLOGFONT: TLogFont;
begin
for I := 0 to AParent.ControlCount-1 do
begin
ACtrl:= AParent.Co... | [
{
"answer_id": 158841,
"author": "gabr",
"author_id": 4997,
"author_profile": "https://Stackoverflow.com/users/4997",
"pm_score": 4,
"selected": true,
"text": "<p>You use TypInfo unit, more specifically methods IsPublishedProp and GetOrdProp.</p>\n\n<p>In your case, it would be something... | 2008/10/01 | [
"https://Stackoverflow.com/questions/158780",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19610/"
] | I'm trying to iterate all the controls on a form and enable ClearType font smoothing. Something like this:
```
procedure TForm4.UpdateControls(AParent: TWinControl);
var
I: Integer;
ACtrl: TControl;
tagLOGFONT: TLogFont;
begin
for I := 0 to AParent.ControlCount-1 do
begin
ACtrl:= AParent.Controls[I];
... | You use TypInfo unit, more specifically methods IsPublishedProp and GetOrdProp.
In your case, it would be something like:
```
if IsPublishedProp(ACtrl, 'Font') then
ModifyFont(TFont(GetOrdProp(ACtrl, 'Font')))
```
A fragment from one of my libraries that should put you on the right path:
```
function ContainsNon... |
158,783 | <p>I really want to be able to have a way to take an app that currently gets its settings using <strong>ConfigurationManager.AppSettings["mysettingkey"]</strong> to actually have those settings come from a centralized database instead of the app.config file. I can make a custom config section for handling this sort of... | [
{
"answer_id": 158813,
"author": "Santiago Palladino",
"author_id": 12791,
"author_profile": "https://Stackoverflow.com/users/12791",
"pm_score": 0,
"selected": false,
"text": "<p>I'm not sure you can override it, but you can try the Add method of AppSettings to add your DB settings when... | 2008/10/01 | [
"https://Stackoverflow.com/questions/158783",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14101/"
] | I really want to be able to have a way to take an app that currently gets its settings using **ConfigurationManager.AppSettings["mysettingkey"]** to actually have those settings come from a centralized database instead of the app.config file. I can make a custom config section for handling this sort of thing, but I rea... | If you don't mind hacking around the framework and you can reasonably assume the .net framework version the application is running on (i.e. it's a web application or an intranet application) then you could try something like this:
```
using System;
using System.Collections.Specialized;
using System.Configuration;
usin... |
158,800 | <p>I have an ASPX page (On server A) which is invoked using NTLM credentials. Part of that page's job is to call an HTML page (On server B) and proxy it back to the client. (The firewall allows access to A, but not to B. The user would normally be allowed access to both servers.). Server B is also not open to anony... | [
{
"answer_id": 158999,
"author": "NotMe",
"author_id": 2424,
"author_profile": "https://Stackoverflow.com/users/2424",
"pm_score": 0,
"selected": false,
"text": "<p>Page.User will get you the Security Principal of the user the page is running under. </p>\n\n<p>From there you should be a... | 2008/10/01 | [
"https://Stackoverflow.com/questions/158800",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10031/"
] | I have an ASPX page (On server A) which is invoked using NTLM credentials. Part of that page's job is to call an HTML page (On server B) and proxy it back to the client. (The firewall allows access to A, but not to B. The user would normally be allowed access to both servers.). Server B is also not open to anonymous ac... | You can certainly obtain the login name of the caller, but not the password. NTLM uses a challenge/response mechanism, so the password is never transmitted. Your server must have access to a password-equivalent (a hash) in order to form the challenge and check the response, but even if you can get hold of it that passw... |
158,818 | <p>First off, let me start off that I am not a .net developer. The reason why I am asking this question is that we rolled out our REST-API and one of our first integration partners is a .net shop.</p>
<p>So basically we assumed that .net would provide some sort of wrapper to create JSON, but the developer in question ... | [
{
"answer_id": 158837,
"author": "John Sheehan",
"author_id": 1786,
"author_profile": "https://Stackoverflow.com/users/1786",
"pm_score": 5,
"selected": true,
"text": "<p>There are a couple first-party and third-party options. <a href=\"http://www.west-wind.com/weblog/posts/442969.aspx\"... | 2008/10/01 | [
"https://Stackoverflow.com/questions/158818",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2859/"
] | First off, let me start off that I am not a .net developer. The reason why I am asking this question is that we rolled out our REST-API and one of our first integration partners is a .net shop.
So basically we assumed that .net would provide some sort of wrapper to create JSON, but the developer in question created th... | There are a couple first-party and third-party options. [Rick Strahl](http://www.west-wind.com/weblog/posts/442969.aspx) has a good overview. [JSON.net](http://james.newtonking.com/pages/json-net.aspx) is the most popular third-party option. |
158,836 | <p>what is a good way to select a random element from a map? C++. It is my understanding that maps don't have random access iterators. The key is a long long and the map is sparsely populated. </p>
| [
{
"answer_id": 158865,
"author": "James Curran",
"author_id": 12725,
"author_profile": "https://Stackoverflow.com/users/12725",
"pm_score": 6,
"selected": false,
"text": "<pre><code>map<...> MyMap;\niterator item = MyMap.begin();\nstd::advance( item, random_0_to_n(MyMap.size()) );\... | 2008/10/01 | [
"https://Stackoverflow.com/questions/158836",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8264/"
] | what is a good way to select a random element from a map? C++. It is my understanding that maps don't have random access iterators. The key is a long long and the map is sparsely populated. | ```
map<...> MyMap;
iterator item = MyMap.begin();
std::advance( item, random_0_to_n(MyMap.size()) );
``` |
158,856 | <p>Is there a way to have a file that is modified / touched whenever the WC is updated to a new revision? Or, as the second-best option, whenever <code>svn update</code> is executed?</p>
<p>Here's the motivation: I want to have the SVN revision number inside my executable. So I have to run SubWCRev as part of the buil... | [
{
"answer_id": 158899,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 3,
"selected": true,
"text": "<ol>\n<li>Get the SubWCRev output into a temporary file</li>\n<li>Compare this file to the current revision-number file</li>\n<... | 2008/10/01 | [
"https://Stackoverflow.com/questions/158856",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7224/"
] | Is there a way to have a file that is modified / touched whenever the WC is updated to a new revision? Or, as the second-best option, whenever `svn update` is executed?
Here's the motivation: I want to have the SVN revision number inside my executable. So I have to run SubWCRev as part of the build. The output file of... | 1. Get the SubWCRev output into a temporary file
2. Compare this file to the current revision-number file
3. Overwrite it with the temp file only if the two are different
4. Delete the temporary file
You might even be able to do this with a .bat file (using `fc`). Something like...
```
REM ***UNTESTED***
FC temp.rev ... |
158,864 | <p>I've read and followed <a href="http://developer.yahoo.com/yui/menu/" rel="nofollow noreferrer">YUI's tutorial</a> for subscribing to Menu events. I also looked through the API and bits of the code for Menu, MenuBar, and Custom Events, but the following <em>refuses</em> to work</p>
<pre><code>// oMenuBar is a Menu... | [
{
"answer_id": 161550,
"author": "Hank Gay",
"author_id": 4203,
"author_profile": "https://Stackoverflow.com/users/4203",
"pm_score": 0,
"selected": false,
"text": "<p>Based on my testing, the following will work:</p>\n\n<pre><code>oMenu.subscribe('keypress', function () { alert(\"I'm yo... | 2008/10/01 | [
"https://Stackoverflow.com/questions/158864",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13200/"
] | I've read and followed [YUI's tutorial](http://developer.yahoo.com/yui/menu/) for subscribing to Menu events. I also looked through the API and bits of the code for Menu, MenuBar, and Custom Events, but the following *refuses* to work
```
// oMenuBar is a MenuBar instance with submenus
var buyMenu = oMenuBar.getSubmen... | Todd Kloots here, author of the YUI Menu widget. When you are subscribing to DOM-based events, the event name is all lower case. So, for the "mouseover" event, subscribe as follows:
buyMenu.subscribe('mouseover', onMouseOver, {foo: 'bar'}, false);
Regarding your keypress event handler: you are subscribing correctly. ... |
158,895 | <p>What needs to be done to have your .NET application show up in Window's system tray as icon?</p>
<p>And how do you handle mousebutton clicks on said icon?</p>
| [
{
"answer_id": 158907,
"author": "Carl",
"author_id": 951280,
"author_profile": "https://Stackoverflow.com/users/951280",
"pm_score": 3,
"selected": false,
"text": "<p>You can add the NotifyIcon component from the toolbox onto your main form.</p>\n\n<p>This has events such as MouseDouble... | 2008/10/01 | [
"https://Stackoverflow.com/questions/158895",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15328/"
] | What needs to be done to have your .NET application show up in Window's system tray as icon?
And how do you handle mousebutton clicks on said icon? | First, add a [NotifyIcon](https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.notifyicon) control to the Form. Then wire up the Notify Icon to do what you want.
If you want it to hide to tray on minimize, try this.
```vb
Private Sub frmMain_Resize(ByVal sender As System.Object, ByVal e As System.EventAr... |
158,914 | <p>I've got some code that resizes an image so I can get a scaled chunk of the center of the image - I use this to take a <code>UIImage</code> and return a small, square representation of an image, similar to what's seen in the album view of the Photos app. (I know I could use a <code>UIImageView</code> and adjust the ... | [
{
"answer_id": 712553,
"author": "HitScan",
"author_id": 9490,
"author_profile": "https://Stackoverflow.com/users/9490",
"pm_score": 8,
"selected": false,
"text": "<p>Update 2014-05-28: I wrote this when iOS 3 or so was the hot new thing, I'm certain there are better ways to do this by n... | 2008/10/01 | [
"https://Stackoverflow.com/questions/158914",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24168/"
] | I've got some code that resizes an image so I can get a scaled chunk of the center of the image - I use this to take a `UIImage` and return a small, square representation of an image, similar to what's seen in the album view of the Photos app. (I know I could use a `UIImageView` and adjust the crop mode to achieve the ... | Update 2014-05-28: I wrote this when iOS 3 or so was the hot new thing, I'm certain there are better ways to do this by now, possibly built-in. As many people have mentioned, this method doesn't take rotation into account; read some additional answers and spread some upvote love around to keep the responses to this que... |
158,933 | <p>I have an array of characters that are Points and I want to take any character and be able to loop through that array and find the top 3 closest (using Point.distance) neighbors. Could anyone give me an idea of how to do this?</p>
| [
{
"answer_id": 159294,
"author": "grapefrukt",
"author_id": 914,
"author_profile": "https://Stackoverflow.com/users/914",
"pm_score": 2,
"selected": false,
"text": "<p>This is a new and improved version of the code I posted last night. It's composed of two classes, the PointTester and th... | 2008/10/01 | [
"https://Stackoverflow.com/questions/158933",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have an array of characters that are Points and I want to take any character and be able to loop through that array and find the top 3 closest (using Point.distance) neighbors. Could anyone give me an idea of how to do this? | This is a new and improved version of the code I posted last night. It's composed of two classes, the PointTester and the TestCase. This time around I was able to test it too!
**We start with the TestCase.as**
```
package {
import flash.geom.Point;
import flash.display.Sprite;
public class TestCase ext... |
158,940 | <p>Is it possible to reset the alternate buffer in a vim session to what it was previously?</p>
<p>By alternate buffer, I mean the one that is referred to by #, i.e. the one that is displayed when you enter cntl-^.</p>
<p>Say I've got two files open main.c and other.c and :ls gives me:</p>
<pre><code> 1 %a "main.... | [
{
"answer_id": 159099,
"author": "graywh",
"author_id": 18038,
"author_profile": "https://Stackoverflow.com/users/18038",
"pm_score": 4,
"selected": true,
"text": "<p>In this case, \"alternate\" just means \"previous\". So, yes, :b2 (or 2 ctrl-6) is probably the easiest way to change wh... | 2008/10/01 | [
"https://Stackoverflow.com/questions/158940",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2974/"
] | Is it possible to reset the alternate buffer in a vim session to what it was previously?
By alternate buffer, I mean the one that is referred to by #, i.e. the one that is displayed when you enter cntl-^.
Say I've got two files open main.c and other.c and :ls gives me:
```
1 %a "main.c" lines 27
2... | In this case, "alternate" just means "previous". So, yes, :b2 (or 2 ctrl-6) is probably the easiest way to change which two buffers will be toggled by ctrl-6.
Also, take a look at the :keepalt command. |
158,941 | <p>How can I to generate an RSS feed of Team Foundation Server commit messages?</p>
<p>In Visual Studio's Source Control Explorer, the "View History" option produces a nice GUI view. Likewise, the command line </p>
<pre><code>tf history /recursive /stopafter:40 .
</code></pre>
<p>produces a nice <em>GUI</em> view.... | [
{
"answer_id": 159917,
"author": "granth",
"author_id": 11210,
"author_profile": "https://Stackoverflow.com/users/11210",
"pm_score": 2,
"selected": false,
"text": "<p><a href=\"http://blogs.msdn.com/abhinaba/archive/2005/12/21/506277.aspx\" rel=\"nofollow noreferrer\">http://blogs.msdn.... | 2008/10/01 | [
"https://Stackoverflow.com/questions/158941",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/150/"
] | How can I to generate an RSS feed of Team Foundation Server commit messages?
In Visual Studio's Source Control Explorer, the "View History" option produces a nice GUI view. Likewise, the command line
```
tf history /recursive /stopafter:40 .
```
produces a nice *GUI* view. I'd like an RSS feed that would supply t... | <http://blogs.msdn.com/abhinaba/archive/2005/12/21/506277.aspx> |
158,968 | <p>Could someone explain to me in simple terms the easiest way to change the indentation behavior of Vim based on the file type? For instance, if I open a Python file it should indent with 2 spaces, but if I open a Powershell script it should use 4 spaces.</p>
| [
{
"answer_id": 158987,
"author": "Paul Tomblin",
"author_id": 3333,
"author_profile": "https://Stackoverflow.com/users/3333",
"pm_score": 6,
"selected": false,
"text": "<p>Put autocmd commands based on the file suffix in your ~/.vimrc</p>\n\n<pre><code>autocmd BufRead,BufNewFile *.c,*.... | 2008/10/01 | [
"https://Stackoverflow.com/questions/158968",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1358/"
] | Could someone explain to me in simple terms the easiest way to change the indentation behavior of Vim based on the file type? For instance, if I open a Python file it should indent with 2 spaces, but if I open a Powershell script it should use 4 spaces. | You can add `.vim` files to be executed whenever vim switches to a particular filetype.
For example, I have a file `~/.vim/after/ftplugin/html.vim` with this contents:
```
setlocal shiftwidth=2
setlocal tabstop=2
```
Which causes vim to use tabs with a width of 2 characters for indenting (the `noexpandtab` option i... |
158,975 | <p>I'm making a request from an <code>UpdatePanel</code> that takes more then 90 seconds. I'm getting this timeout error:</p>
<blockquote>
<p>Microsoft JScript runtime error:
Sys.WebForms.PageRequestManagerTimeoutException: The server request
timed out.</p>
</blockquote>
<p>Does anyone know if there is a way to... | [
{
"answer_id": 158995,
"author": "Bravax",
"author_id": 13911,
"author_profile": "https://Stackoverflow.com/users/13911",
"pm_score": 2,
"selected": false,
"text": "<p>This might be configurable by changing the ASP script timeout in IIS.</p>\n\n<p>It's located in the properties of your w... | 2008/10/01 | [
"https://Stackoverflow.com/questions/158975",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6161/"
] | I'm making a request from an `UpdatePanel` that takes more then 90 seconds. I'm getting this timeout error:
>
> Microsoft JScript runtime error:
> Sys.WebForms.PageRequestManagerTimeoutException: The server request
> timed out.
>
>
>
Does anyone know if there is a way to increase the amount of time before the c... | There is a property on the ScriptManager which allows you to set the time-out in seconds. The default value is 90 seconds.
```
AsyncPostBackTimeout="300"
``` |
158,986 | <p>I am <strong>very</strong> new to the entity framework, so please bear with me...</p>
<p>How can I relate two objects from different contexts together?</p>
<p>The example below throws the following exception:</p>
<blockquote>
<p>System.InvalidOperationException: The
relationship between the two objects
cann... | [
{
"answer_id": 159042,
"author": "Quintin Robinson",
"author_id": 12707,
"author_profile": "https://Stackoverflow.com/users/12707",
"pm_score": 5,
"selected": true,
"text": "<p>You will have to use the same context (you can pass the context to the getdefaultrole method) or rethink the re... | 2008/10/01 | [
"https://Stackoverflow.com/questions/158986",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4050/"
] | I am **very** new to the entity framework, so please bear with me...
How can I relate two objects from different contexts together?
The example below throws the following exception:
>
> System.InvalidOperationException: The
> relationship between the two objects
> cannot be defined because they are
> attached to... | You will have to use the same context (you can pass the context to the getdefaultrole method) or rethink the relationships and extend the entity.
EDIT: Wanted to add this was for the example provided, using asp.net will require you to fully think out your context and relationship designs.
You could simply pass the co... |
158,993 | <p>I need to, preferably in C# - but c++ will do, find a way to filter the list of printers in the windows print dialog for any windows printing.</p>
<p>I have come across WinAPIOverride and have figured I am going to have to write my own dll which overrides the method to get the printers list, then filter it and retu... | [
{
"answer_id": 436837,
"author": "sven",
"author_id": 46,
"author_profile": "https://Stackoverflow.com/users/46",
"pm_score": 2,
"selected": false,
"text": "<p>I don't think that (re)writing a DLL is the easiest method. Why not use <a href=\"http://msdn.microsoft.com/en-us/library/aa3939... | 2008/10/01 | [
"https://Stackoverflow.com/questions/158993",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I need to, preferably in C# - but c++ will do, find a way to filter the list of printers in the windows print dialog for any windows printing.
I have come across WinAPIOverride and have figured I am going to have to write my own dll which overrides the method to get the printers list, then filter it and return it. I w... | I don't think that (re)writing a DLL is the easiest method. Why not use [WMI](http://msdn.microsoft.com/en-us/library/aa393964(VS.85).aspx) to retrieve the wanted [information (printers in this case)](http://msdn.microsoft.com/en-us/library/aa394363.aspx)?
The following code is for retrieving all the locally installed... |
159,006 | <p>Is there a way to find the maximum and minimum defined values of an enum in c++?</p>
| [
{
"answer_id": 159018,
"author": "Jeff Yates",
"author_id": 23234,
"author_profile": "https://Stackoverflow.com/users/23234",
"pm_score": 8,
"selected": true,
"text": "<p>No, there is no way to find the maximum and minimum defined values of any enum in C++. When this kind of information ... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159006",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17693/"
] | Is there a way to find the maximum and minimum defined values of an enum in c++? | No, there is no way to find the maximum and minimum defined values of any enum in C++. When this kind of information is needed, it is often good practice to define a Last and First value. For example,
```
enum MyPretendEnum
{
Apples,
Oranges,
Pears,
Bananas,
First = Apples,
Last = Bananas
};
```
Th... |
159,011 | <p>Here is my question,</p>
<p>Would it be possible, knowing that classic asp support server-side javascript, to be able to generate "server side HTML" to send to the client like
Response.write $(page).html()</p>
<p>Of course it would be great to use jQuery to do it because it's easy to parse complicated structure... | [
{
"answer_id": 159115,
"author": "Svante Svenson",
"author_id": 19707,
"author_profile": "https://Stackoverflow.com/users/19707",
"pm_score": 0,
"selected": false,
"text": "<p>Yes it is possible. No, it wouldn't be fast at all and I don't see any reason for doing it as jQuery is often us... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159011",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1775/"
] | Here is my question,
Would it be possible, knowing that classic asp support server-side javascript, to be able to generate "server side HTML" to send to the client like
Response.write $(page).html()
Of course it would be great to use jQuery to do it because it's easy to parse complicated structure and manipulate th... | I such situations I use an XML DOM as surrogate for the HTML DOM I would have in a browser.
jQuery can manipulating an XML DOM however jQuery expects window to be present in its context. It may be possible to fool jQuery (or tweak it) so that it would work server-side but it could be quite fragile.
Personnally I just... |
159,017 | <p>Is there any way to format a string by name rather than position in C#?</p>
<p>In python, I can do something like this example (shamelessly stolen from <a href="http://docs.python.org/lib/typesseq-strings.html" rel="noreferrer">here</a>):</p>
<pre><code>>>> print '%(language)s has %(#)03d quote types.' % ... | [
{
"answer_id": 159029,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 2,
"selected": false,
"text": "<p>I think the closest you'll get is an indexed format:</p>\n\n<pre><code>String.Format(\"{0} has {1} quote types.\", ... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159017",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2147/"
] | Is there any way to format a string by name rather than position in C#?
In python, I can do something like this example (shamelessly stolen from [here](http://docs.python.org/lib/typesseq-strings.html)):
```
>>> print '%(language)s has %(#)03d quote types.' % \
{'language': "Python", "#": 2}
Python has 002 quot... | There is no built-in method for handling this.
[Here's one method](http://mo.notono.us/2008/07/c-stringinject-format-strings-by-key.html)
```
string myString = "{foo} is {bar} and {yadi} is {yada}".Inject(o);
```
[Here's another](http://james.newtonking.com/archive/2008/03/29/formatwith-2-0-string-formatting-with-n... |
159,038 | <p>Are disabling and enabling foreign key constraints supported in SQL Server? Or is my only option to <strong><code>drop</code></strong> and then <strong>re-<code>create</code></strong> the constraints?</p>
| [
{
"answer_id": 159064,
"author": "ScottStonehouse",
"author_id": 2342,
"author_profile": "https://Stackoverflow.com/users/2342",
"pm_score": 9,
"selected": false,
"text": "<p>(Copied from from <a href=\"http://www.sqljunkies.com/WebLog/roman/archive/2005/01/30/7037.aspx\" rel=\"noreferre... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159038",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4872/"
] | Are disabling and enabling foreign key constraints supported in SQL Server? Or is my only option to **`drop`** and then **re-`create`** the constraints? | If you want to disable all constraints in the database just run this code:
```
-- disable all constraints
EXEC sp_MSforeachtable "ALTER TABLE ? NOCHECK CONSTRAINT all"
```
To switch them back on, run: (the print is optional of course and it is just listing the tables)
```
-- enable all constraints
exec sp_MSforeach... |
159,097 | <p>Is there any way to output the contents of an XDocument without the BOM? When reading the output with Flash, it causes errors.</p>
| [
{
"answer_id": 159162,
"author": "Chris Shaffer",
"author_id": 6744,
"author_profile": "https://Stackoverflow.com/users/6744",
"pm_score": 0,
"selected": false,
"text": "<p>You could probably use System.Text.Encoding.Convert() on the output; Just as something to try, not something I have... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159097",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1786/"
] | Is there any way to output the contents of an XDocument without the BOM? When reading the output with Flash, it causes errors. | If you're writing the XML with an XmlWriter, you can set the Encoding to one that has been initialized to leave out the BOM.
EG: System.Text.UTF8Encoding's constructor takes a boolean to specify whether you want the BOM, so:
```
XmlWriter writer = XmlWriter.Create("foo.xml");
writer.Settings.Encoding = new System.Te... |
159,118 | <p>For example, this regex</p>
<pre><code>(.*)<FooBar>
</code></pre>
<p>will match:</p>
<pre><code>abcde<FooBar>
</code></pre>
<p>But how do I get it to match across multiple lines?</p>
<pre><code>abcde
fghij<FooBar>
</code></pre>
| [
{
"answer_id": 159125,
"author": "nsayer",
"author_id": 13757,
"author_profile": "https://Stackoverflow.com/users/13757",
"pm_score": 1,
"selected": false,
"text": "<p>In the context of use within languages, regular expressions act on strings, not lines. So you should be able to use the ... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159118",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2108/"
] | For example, this regex
```
(.*)<FooBar>
```
will match:
```
abcde<FooBar>
```
But how do I get it to match across multiple lines?
```
abcde
fghij<FooBar>
``` | It depends on the language, but there should be a modifier that you can add to the regex pattern. In PHP it is:
```
/(.*)<FooBar>/s
```
The **s** at the end causes the dot to match *all* characters including newlines. |
159,137 | <p>I need a cross platform method of determining the MAC address of a computer at run time. For windows the 'wmi' module can be used and the only method under Linux I could find was to run ifconfig and run a regex across its output. I don't like using a package that only works on one OS, and parsing the output of ano... | [
{
"answer_id": 159150,
"author": "camflan",
"author_id": 22445,
"author_profile": "https://Stackoverflow.com/users/22445",
"pm_score": 5,
"selected": false,
"text": "<p><code>netifaces</code> is a good module to use for getting the mac address (and other addresses). It's crossplatform an... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159137",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9940/"
] | I need a cross platform method of determining the MAC address of a computer at run time. For windows the 'wmi' module can be used and the only method under Linux I could find was to run ifconfig and run a regex across its output. I don't like using a package that only works on one OS, and parsing the output of another ... | Python 2.5 includes an uuid implementation which (in at least one version) needs the mac address. You can import the mac finding function into your own code easily:
```
from uuid import getnode as get_mac
mac = get_mac()
```
The return value is the mac address as 48 bit integer. |
159,148 | <p>Groovy adds the <code>execute</code> method to <code>String</code> to make executing shells fairly easy;</p>
<pre><code>println "ls".execute().text
</code></pre>
<p>but if an error happens, then there is no resulting output. <strong>Is there an easy way to get both the standard error and standard out?</strong> (... | [
{
"answer_id": 159244,
"author": "Joshua",
"author_id": 6013,
"author_profile": "https://Stackoverflow.com/users/6013",
"pm_score": 6,
"selected": false,
"text": "<p><code>\"ls\".execute()</code> returns a <code>Process</code> object which is why <code>\"ls\".execute().text</code> works.... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159148",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6580/"
] | Groovy adds the `execute` method to `String` to make executing shells fairly easy;
```
println "ls".execute().text
```
but if an error happens, then there is no resulting output. **Is there an easy way to get both the standard error and standard out?** (other than creating a bunch of code to; create two threads to r... | Ok, solved it myself;
```
def sout = new StringBuilder(), serr = new StringBuilder()
def proc = 'ls /badDir'.execute()
proc.consumeProcessOutput(sout, serr)
proc.waitForOrKill(1000)
println "out> $sout\nerr> $serr"
```
displays:
`out> err> ls: cannot access /badDir: No such file or directory` |
159,152 | <p>Is there a way with SVN to check out from a remote repository to another remote location rather than my local file system? Something like:</p>
<pre><code>svn co http://myrepository/svn/project ssh me@otherlocation.net:/var/www/project
</code></pre>
| [
{
"answer_id": 159159,
"author": "noah",
"author_id": 12034,
"author_profile": "https://Stackoverflow.com/users/12034",
"pm_score": 1,
"selected": false,
"text": "<p>Nope. If you want to copy a repository, look into <a href=\"http://svn.collab.net/repos/svn/trunk/notes/svnsync.txt\" rel=... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159152",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/577/"
] | Is there a way with SVN to check out from a remote repository to another remote location rather than my local file system? Something like:
```
svn co http://myrepository/svn/project ssh me@otherlocation.net:/var/www/project
``` | I think you could do:
```
ssh me@other.net 'svn co http://repository/svn/project /var/www/project'
```
This takes advantage of the fact that ssh lets you execute a command remotely. |
159,183 | <p>I want to resize the font of a SPAN element's style until it the SPAN's text is 7.5 inches wide when printed out on paper, but JavaScript only reports the SPAN's clientWidth property in pixels.</p>
<pre><code><span id="test">123456</span>
</code></pre>
<p>And then:</p>
<pre><code>#test {
font-size:1... | [
{
"answer_id": 159199,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 2,
"selected": false,
"text": "<blockquote>\n <p>I've determined experimentally on one\n machine that it uses approximately 90\n DPI as a conversi... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159183",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16777/"
] | I want to resize the font of a SPAN element's style until it the SPAN's text is 7.5 inches wide when printed out on paper, but JavaScript only reports the SPAN's clientWidth property in pixels.
```
<span id="test">123456</span>
```
And then:
```
#test {
font-size:1.2in; /* adjust this for yourself until printout ... | I think this does what you want. But I agree with the other posters, HTML isn't really suited for this sort of thing. Anyway, hope you find this useful.
```
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtm... |
159,190 | <p>In Eclipse, its easy to specify buttons for your toolbar using the ActionSets extension point. However, when I need to specify some items programmatically, I can't get the same look. I don't believe that the framework is using native buttons for these, but so far, I can't find the right recipe to match the Eclipse... | [
{
"answer_id": 211976,
"author": "Herman Lintvelt",
"author_id": 27602,
"author_profile": "https://Stackoverflow.com/users/27602",
"pm_score": 2,
"selected": false,
"text": "<p>Could you perhaps put in an extract of the code you have for adding actions programmatically to the toolbar? I ... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159190",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16476/"
] | In Eclipse, its easy to specify buttons for your toolbar using the ActionSets extension point. However, when I need to specify some items programmatically, I can't get the same look. I don't believe that the framework is using native buttons for these, but so far, I can't find the right recipe to match the Eclipse look... | It's difficult to tell from your question, but it sounds like you may be attempting to add a ControlContribution to the toolbar and returning a Button. This would make the button on the toolbar appear like a native button like you seem to be describing. This would look something like this:
```
IToolBarManager toolBarM... |
159,237 | <p>I'm working in .Net 3.5sp1 in C# for an ASP.Net solution and I'm wondering if there's any way to turn on the Class Name and Method Name drop-downs in the text editor that VB.Net has at the top. It's one of the few things from VB that I actually miss.</p>
<p>Edit: Also, is there any way to get the drop downs to be p... | [
{
"answer_id": 159246,
"author": "casademora",
"author_id": 5619,
"author_profile": "https://Stackoverflow.com/users/5619",
"pm_score": 3,
"selected": true,
"text": "<p>Go To:</p>\n\n<pre><code>Tools -> Options -> Text Editor -> C# -> General -> Navigation Bar\n</code></pr... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159237",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1414/"
] | I'm working in .Net 3.5sp1 in C# for an ASP.Net solution and I'm wondering if there's any way to turn on the Class Name and Method Name drop-downs in the text editor that VB.Net has at the top. It's one of the few things from VB that I actually miss.
Edit: Also, is there any way to get the drop downs to be populated w... | Go To:
```
Tools -> Options -> Text Editor -> C# -> General -> Navigation Bar
```
Make sure it is clicked, and that should show something at the top of your code that has all the classes and methods listed in your file. |
159,266 | <p>So I have something like this:</p>
<pre><code>var xmlStatement:String = "xmlObject.node[3].@thisValue";
</code></pre>
<p>What mystery function do I have to use so that I can execute xmlStatement and get thisValue from that xmlObject? Like....</p>
<pre><code>var attribute:String = mysteryFunction(xmlStatement);
</... | [
{
"answer_id": 159336,
"author": "Christophe Herreman",
"author_id": 17255,
"author_profile": "https://Stackoverflow.com/users/17255",
"pm_score": 4,
"selected": true,
"text": "<p>Unfortunately this is not possible in ActionScript 3. This however might be a solution: <a href=\"http://blo... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159266",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3435/"
] | So I have something like this:
```
var xmlStatement:String = "xmlObject.node[3].@thisValue";
```
What mystery function do I have to use so that I can execute xmlStatement and get thisValue from that xmlObject? Like....
```
var attribute:String = mysteryFunction(xmlStatement);
```
P.S. I know eval() works for acti... | Unfortunately this is not possible in ActionScript 3. This however might be a solution: <http://blog.betabong.com/2008/09/23/e4x-string-parser/> |
159,282 | <pre><code>grant {
permission java.security.AllPermission;
};
</code></pre>
<p>This works.</p>
<pre><code>grant file:///- {
permission java.security.AllPermission;
};
</code></pre>
<p>This does not work. Could someone please explain to me why?</p>
| [
{
"answer_id": 159785,
"author": "David G",
"author_id": 3150,
"author_profile": "https://Stackoverflow.com/users/3150",
"pm_score": 1,
"selected": false,
"text": "<p>The directive \"grant { permission }\" means grant the permission to all code no matter where it came from. In other word... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159282",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | ```
grant {
permission java.security.AllPermission;
};
```
This works.
```
grant file:///- {
permission java.security.AllPermission;
};
```
This does not work. Could someone please explain to me why? | The syntax should be:
```
grant codeBase "file:///-" {
...
};
```
See [the docs](http://java.sun.com/javase/6/docs/technotes/guides/security/PolicyFiles.html). Note the semicolon.
Be very careful assigning permissions to code.
Are you sure the codebase should be a file URL (normal for development, not for produ... |
159,292 | <p>I am using Apache's Velocity templating engine, and I would like to create a custom Directive. That is, I want to be able to write "#doMyThing()" and have it invoke some java code I wrote in order to generate the text.</p>
<p>I know that I can register a custom directive by adding a line</p>
<pre><code>userdirecti... | [
{
"answer_id": 214100,
"author": "Nathan Bubna",
"author_id": 8131,
"author_profile": "https://Stackoverflow.com/users/8131",
"pm_score": 2,
"selected": false,
"text": "<p>Block directives always accept a body and must end with #end when used in a template. e.g. #foreach( $i in $foo ) t... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159292",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14570/"
] | I am using Apache's Velocity templating engine, and I would like to create a custom Directive. That is, I want to be able to write "#doMyThing()" and have it invoke some java code I wrote in order to generate the text.
I know that I can register a custom directive by adding a line
```
userdirective=my.package.here.My... | Block directives always accept a body and must end with #end when used in a template. e.g. #foreach( $i in $foo ) this has a body! #end
Line directives do not have a body or an #end. e.g. #parse( 'foo.vtl' )
You don't need to both with setLocation() at all. The parser uses that.
Any other specifics i can help with?
... |
159,296 | <p>I've got a (poorly written) base class that I want to wrap in a proxy object. The base class resembles the following:</p>
<pre><code>public class BaseClass : SomeOtherBase
{
public BaseClass() {}
public BaseClass(int someValue) {}
//...more code, not important here
}
</code></pre>
<p>and, my proxy rese... | [
{
"answer_id": 159320,
"author": "mattlant",
"author_id": 14642,
"author_profile": "https://Stackoverflow.com/users/14642",
"pm_score": 3,
"selected": false,
"text": "<p>At least 1 ctor has to be called. The only way around it I see is containment. Have the class inside or referencing th... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159296",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5619/"
] | I've got a (poorly written) base class that I want to wrap in a proxy object. The base class resembles the following:
```
public class BaseClass : SomeOtherBase
{
public BaseClass() {}
public BaseClass(int someValue) {}
//...more code, not important here
}
```
and, my proxy resembles:
```
public BaseCla... | If you do not explicitly call any constructor in the base class, the parameterless constructor will be called implicitly. There's no way around it, you cannot instantiate a class without a constructor being called. |
159,317 | <p>When should one do the following?</p>
<pre><code>class Foo : Control
{
protected override void OnClick(EventArgs e)
{
// new code here
}
}
</code></pre>
<p>As opposed to this?</p>
<pre><code>class Foo : Control
{
public Foo()
{
this.Click += new EventHandler(Clicked);
}
... | [
{
"answer_id": 159334,
"author": "Kent Boogaart",
"author_id": 5380,
"author_profile": "https://Stackoverflow.com/users/5380",
"pm_score": 3,
"selected": false,
"text": "<p>Overriding rather than attaching a delegate will result in more efficient code, so it is generally recommended that... | 2008/10/01 | [
"https://Stackoverflow.com/questions/159317",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8505/"
] | When should one do the following?
```
class Foo : Control
{
protected override void OnClick(EventArgs e)
{
// new code here
}
}
```
As opposed to this?
```
class Foo : Control
{
public Foo()
{
this.Click += new EventHandler(Clicked);
}
private void Clicked(object sender,... | Overriding rather than attaching a delegate will result in more efficient code, so it is generally recommended that you always do this where possible. For more information see [this MSDN article](http://msdn.microsoft.com/en-us/library/wkzf914z(VS.71).aspx). Here is a pertinent quote:
>
> The protected OnEventName me... |