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 |
|---|---|---|---|---|---|---|
126,631 | <p>Is it possible to pass a function/callback from javascript to a java applet?</p>
<p>For example i have an applet with a button that when pressed it will call the passed js callback</p>
<pre><code>function onCommand() {
alert('Button pressed from applet');
}
applet.onCommand(onCommand);
</code></pre>
| [
{
"answer_id": 126650,
"author": "moonshadow",
"author_id": 11834,
"author_profile": "https://Stackoverflow.com/users/11834",
"pm_score": 2,
"selected": false,
"text": "<p>You can use <a href=\"http://java.sun.com/j2se/1.5.0/docs/guide/plugin/developer_guide/java_js.html\" rel=\"nofollow... | 2008/09/24 | [
"https://Stackoverflow.com/questions/126631",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20300/"
] | Is it possible to pass a function/callback from javascript to a java applet?
For example i have an applet with a button that when pressed it will call the passed js callback
```
function onCommand() {
alert('Button pressed from applet');
}
applet.onCommand(onCommand);
``` | I tend to use something I derived from the reflection example at the bottom of [this page](http://www.rgagnon.com/javadetails/java-0172.html), as then you don't need to meddle with your classpath to get it to compile
Then I just pass JSON strings around between the applet and javascript |
126,652 | <p>(Oracle) I have to return all records from last 12 months. How to do that in PL/SQL?</p>
<p>EDIT: Sorry, I forgot to explain, I do have a column of DATA type</p>
| [
{
"answer_id": 126684,
"author": "cagcowboy",
"author_id": 19629,
"author_profile": "https://Stackoverflow.com/users/19629",
"pm_score": -1,
"selected": false,
"text": "<pre><code>SELECT *\nFROM table\nWHERE date_column > SYSDATE - 365\n</code></pre>\n"
},
{
"answer_id": 12... | 2008/09/24 | [
"https://Stackoverflow.com/questions/126652",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3221/"
] | (Oracle) I have to return all records from last 12 months. How to do that in PL/SQL?
EDIT: Sorry, I forgot to explain, I do have a column of DATA type | Doing this in PL/SQL is pretty much synonymous with doing it in SQL.
```
SELECT *
FROM table
WHERE date_column >= ADD_MONTHS(TRUNC(SYSDATE),-12)
```
You might like to fiddle around with the TRUNC statement to get exactly the range you want -- I used TRUNC(SYSDATE) which is the same as TRUNC(SYSDATE,'D') -- ie. re... |
126,656 | <p>I am doing a project at the moment, and in the interest of code reuse, I went looking for a library that can perform some probabilistic accept/reject of an item: </p>
<p>i.e., there are three people (a, b c), and each of them have a probability P{i} of getting an item, where p{a} denotes the probability of a. These... | [
{
"answer_id": 127132,
"author": "finalman",
"author_id": 20522,
"author_profile": "https://Stackoverflow.com/users/20522",
"pm_score": 2,
"selected": true,
"text": "<p>Would something like this do? Put all p{i}'s in the array, function will return an index to the person who gets the ite... | 2008/09/24 | [
"https://Stackoverflow.com/questions/126656",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17335/"
] | I am doing a project at the moment, and in the interest of code reuse, I went looking for a library that can perform some probabilistic accept/reject of an item:
i.e., there are three people (a, b c), and each of them have a probability P{i} of getting an item, where p{a} denotes the probability of a. These probabili... | Would something like this do? Put all p{i}'s in the array, function will return an index to the person who gets the item. Executes in O(n).
```
public int selectPerson(float[] probabilies, Random r) {
float t = r.nextFloat();
float p = 0.0f;
for (int i = 0; i < probabilies.length; i++) {
p += prob... |
126,678 | <p>I don't seem to be able to close the OledbDataReader object after reading data from it. Here is the relevant code -</p>
<pre><code>Dim conSyBase As New OleDb.OleDbConnection("Provider=Sybase.ASEOLEDBProvider.2;Server Name=xx.xx.xx.xx;Server Port Address=5000;Initial Catalog=xxxxxxxxxx;User ID=xxxxxxxx;Password=xxxx... | [
{
"answer_id": 126784,
"author": "Mikey",
"author_id": 13347,
"author_profile": "https://Stackoverflow.com/users/13347",
"pm_score": 0,
"selected": false,
"text": "<p>This is a long-shot, but try moving your .Close() and .Dispose() lines in a Finally block of the Try. Like this:</p>\n\n... | 2008/09/24 | [
"https://Stackoverflow.com/questions/126678",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1831/"
] | I don't seem to be able to close the OledbDataReader object after reading data from it. Here is the relevant code -
```
Dim conSyBase As New OleDb.OleDbConnection("Provider=Sybase.ASEOLEDBProvider.2;Server Name=xx.xx.xx.xx;Server Port Address=5000;Initial Catalog=xxxxxxxxxx;User ID=xxxxxxxx;Password=xxxxxxxxx;")
conS... | I found the answer!
Before
```
drSyBase.Close()
```
You need to call the cancel method of the Command object
```
cmdSyBase.Cancel()
```
I believe that this may be specific to Sybase databases |
126,718 | <p>I'm working on a VB6 application and I would like to send a Type as a reference and store it in another form. Is this possible?</p>
<p>Sending it is no problem, I just use the <code>ByRef</code> keyword:</p>
<pre><code>public Sub SetStopToEdit(ByRef currentStop As StopType)
</code></pre>
<p>But when I try to use ... | [
{
"answer_id": 126740,
"author": "Daren Thomas",
"author_id": 2260,
"author_profile": "https://Stackoverflow.com/users/2260",
"pm_score": 1,
"selected": false,
"text": "<p>What is StopType? How is it defined? Is a Type the VB6-Record stuff? If so (and if possible), you should redefine it... | 2008/09/24 | [
"https://Stackoverflow.com/questions/126718",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16047/"
] | I'm working on a VB6 application and I would like to send a Type as a reference and store it in another form. Is this possible?
Sending it is no problem, I just use the `ByRef` keyword:
```
public Sub SetStopToEdit(ByRef currentStop As StopType)
```
But when I try to use Set to store `currentStop` in the receiving ... | You need to refactor it into a class. |
126,737 | <p>After watching The Dark Knight I became rather enthralled with the concept of the Prisoner's Dilemma. There <em>must</em> be an algorithm that that maximizes one's own gain given a situation.</p>
<p>For those that find this foreign: <a href="http://en.wikipedia.org/wiki/Prisoner%27s_dilemma" rel="nofollow noreferre... | [
{
"answer_id": 126763,
"author": "Rik",
"author_id": 5409,
"author_profile": "https://Stackoverflow.com/users/5409",
"pm_score": 2,
"selected": false,
"text": "<p>The whole point of the dilemma is that the optimal solution (both prisoners stay quiet) is dangerous because part of the prob... | 2008/09/24 | [
"https://Stackoverflow.com/questions/126737",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14877/"
] | After watching The Dark Knight I became rather enthralled with the concept of the Prisoner's Dilemma. There *must* be an algorithm that that maximizes one's own gain given a situation.
For those that find this foreign: <http://en.wikipedia.org/wiki/Prisoner%27s_dilemma>
Very, very interesting stuff.
Edit: The questi... | Since there is only one choice to make, and in the absence of any changeable inputs, your algorithm is either going to be:
```
cooperate = true;
```
...or...
```
cooperate = false
```
It's more interesting to find a strategy for the Iterated Prisoner's Dilemma, which is something many people have done. For exampl... |
126,751 | <p>During a long compilation with Visual Studio 2005 (version 8.0.50727.762), I sometimes get the following error in several files in some project: </p>
<pre><code>fatal error C1033: cannot open program database 'v:\temp\apprtctest\win32\release\vc80.pdb'
</code></pre>
<p>(The file mentioned is either <code>vc80.pdb... | [
{
"answer_id": 127103,
"author": "SCFrench",
"author_id": 4928,
"author_profile": "https://Stackoverflow.com/users/4928",
"pm_score": 5,
"selected": false,
"text": "<p>We've seen this a lot at my site too. <a href=\"http://graphics.ethz.ch/~peterkau/coding.php\" rel=\"noreferrer\">This e... | 2008/09/24 | [
"https://Stackoverflow.com/questions/126751",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7224/"
] | During a long compilation with Visual Studio 2005 (version 8.0.50727.762), I sometimes get the following error in several files in some project:
```
fatal error C1033: cannot open program database 'v:\temp\apprtctest\win32\release\vc80.pdb'
```
(The file mentioned is either `vc80.pdb` or `vc80.idb` in the project's... | It is possible that an antivirus or a similar program is touching the pdb file on write - an antivirus is the most likely suspect in this scenario. I'm afraid that I can only give you some general pointers, based on my past experience in setting nightly builds in our shop. Some of these may sound trivial, but I'm inclu... |
126,756 | <p>Can anybody suggest programming examples that illustrate recursive functions? There are the usual old horses such as <strong><em>Fibonacci series</em></strong> and <strong><em>Towers of Hanoi</em></strong>, but anything besides them would be fun.</p>
| [
{
"answer_id": 126768,
"author": "Geoff",
"author_id": 1097,
"author_profile": "https://Stackoverflow.com/users/1097",
"pm_score": 1,
"selected": false,
"text": "<p>My personal favorite is <a href=\"http://en.wikipedia.org/wiki/Binary_search\" rel=\"nofollow noreferrer\">Binary Search</a... | 2008/09/24 | [
"https://Stackoverflow.com/questions/126756",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4021/"
] | Can anybody suggest programming examples that illustrate recursive functions? There are the usual old horses such as ***Fibonacci series*** and ***Towers of Hanoi***, but anything besides them would be fun. | [This illustration](http://everything2.com/index.pl?node_id=477013) is in English, rather than an actual programming language, but is useful for explaining the process in a non-technical way:
```
A child couldn't sleep, so her mother told a story about a little frog,
who couldn't sleep, so the frog's mother told a ... |
126,759 | <p>I've created an implementation of the <code>QAbstractListModel</code> class in Qt Jambi 4.4 and am finding that using the model with a <code>QListView</code> results in nothing being displayed, however using the model with a <code>QTableView</code> displays the data correctly.</p>
<p>Below is my implementation of <... | [
{
"answer_id": 126768,
"author": "Geoff",
"author_id": 1097,
"author_profile": "https://Stackoverflow.com/users/1097",
"pm_score": 1,
"selected": false,
"text": "<p>My personal favorite is <a href=\"http://en.wikipedia.org/wiki/Binary_search\" rel=\"nofollow noreferrer\">Binary Search</a... | 2008/09/24 | [
"https://Stackoverflow.com/questions/126759",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13678/"
] | I've created an implementation of the `QAbstractListModel` class in Qt Jambi 4.4 and am finding that using the model with a `QListView` results in nothing being displayed, however using the model with a `QTableView` displays the data correctly.
Below is my implementation of `QAbstractListModel`:
```
public class FooL... | [This illustration](http://everything2.com/index.pl?node_id=477013) is in English, rather than an actual programming language, but is useful for explaining the process in a non-technical way:
```
A child couldn't sleep, so her mother told a story about a little frog,
who couldn't sleep, so the frog's mother told a ... |
126,772 | <h2>Background</h2>
<p>I am writing and using a very simple CGI-based (Perl) content management tool for two pro-bono websites. It provides the website administrator with HTML forms for events where they fill the fields (date, place, title, description, links, etc.) and save it. On that form I allow the administrator ... | [
{
"answer_id": 126782,
"author": "Armin Ronacher",
"author_id": 19990,
"author_profile": "https://Stackoverflow.com/users/19990",
"pm_score": 6,
"selected": false,
"text": "<p>Simple fix: Attach a random query string to the image:</p>\n\n<pre><code><img src=\"foo.cgi?random=3235275284... | 2008/09/24 | [
"https://Stackoverflow.com/questions/126772",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7984/"
] | Background
----------
I am writing and using a very simple CGI-based (Perl) content management tool for two pro-bono websites. It provides the website administrator with HTML forms for events where they fill the fields (date, place, title, description, links, etc.) and save it. On that form I allow the administrator t... | Armin Ronacher has the correct idea. The problem is random strings can collide. I would use:
```
<img src="picture.jpg?1222259157.415" alt="">
```
Where "1222259157.415" is the current time on the server.
Generate time by Javascript with `performance.now()` or by Python with `time.time()` |
126,781 | <p>I'm translating a library written in C++ to C#, and the keyword 'union' exists once. In a struct.</p>
<p>What's the correct way of translating it into C#? And what does it do? It looks something like this;</p>
<pre><code>struct Foo {
float bar;
union {
int killroy;
float fubar;
} as;
}... | [
{
"answer_id": 126807,
"author": "Armin Ronacher",
"author_id": 19990,
"author_profile": "https://Stackoverflow.com/users/19990",
"pm_score": 8,
"selected": true,
"text": "<p>You can use explicit field layouts for that:</p>\n\n<pre><code>[StructLayout(LayoutKind.Explicit)] \npublic struc... | 2008/09/24 | [
"https://Stackoverflow.com/questions/126781",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15067/"
] | I'm translating a library written in C++ to C#, and the keyword 'union' exists once. In a struct.
What's the correct way of translating it into C#? And what does it do? It looks something like this;
```
struct Foo {
float bar;
union {
int killroy;
float fubar;
} as;
}
``` | You can use explicit field layouts for that:
```
[StructLayout(LayoutKind.Explicit)]
public struct SampleUnion
{
[FieldOffset(0)] public float bar;
[FieldOffset(4)] public int killroy;
[FieldOffset(4)] public float fubar;
}
```
Untested. The idea is that two variables have the same position in your stru... |
126,794 | <p>I'm trying to write a query that will pull back the two most recent rows from the Bill table where the Estimated flag is true. The catch is that these need to be consecutive bills. </p>
<p>To put it shortly, I need to enter a row in another table if a Bill has been estimated for the last two bill cycles.</p>
<p>I'... | [
{
"answer_id": 126814,
"author": "mattlant",
"author_id": 14642,
"author_profile": "https://Stackoverflow.com/users/14642",
"pm_score": 0,
"selected": false,
"text": "<p>You should be able to do a descensing sorted query on estimated = true and select top 2. I am not the best at SQL so i... | 2008/09/24 | [
"https://Stackoverflow.com/questions/126794",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11780/"
] | I'm trying to write a query that will pull back the two most recent rows from the Bill table where the Estimated flag is true. The catch is that these need to be consecutive bills.
To put it shortly, I need to enter a row in another table if a Bill has been estimated for the last two bill cycles.
I'd like to do this... | Assuming the rows have sequential IDs, something like this may be what you're looking for:
```
select top 1 *
from
Bills b1
inner join Bills b2 on b1.id = b2.id - 1
where
b1.IsEstimate = 1 and b2.IsEstimate = 1
order by
b1.BillDate desc
``` |
126,798 | <p>Does anyone know how to solve this java error?</p>
<pre><code>java.io.IOException: Invalid keystore format
</code></pre>
<p>I get it when I try and access the certificate store from the Java option in control panels. It's stopping me from loading applets that require elevated privileges.</p>
<p><a href="http://im... | [
{
"answer_id": 126902,
"author": "DeeCee",
"author_id": 5895,
"author_profile": "https://Stackoverflow.com/users/5895",
"pm_score": 0,
"selected": false,
"text": "<p>Seems to be a missing certificate or an invalid format.\nDid you already generate a certificate with keytool?</p>\n"
},
... | 2008/09/24 | [
"https://Stackoverflow.com/questions/126798",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/942/"
] | Does anyone know how to solve this java error?
```
java.io.IOException: Invalid keystore format
```
I get it when I try and access the certificate store from the Java option in control panels. It's stopping me from loading applets that require elevated privileges.
[Error Image](http://img72.imageshack.us/my.php?ima... | I was able to reproduce the error by mangling the trusted.certs file at directory
`C:\Documents and Settings\CDay\Application Data\Sun\Java\Deployment\security`.
Deleting the file fixed the problem. |
126,837 | <p>I've got a local .mdf SQL database file that I am using for an integration testing project. Everything works fine on the initial machine I created the project, database, etc. on, but when I try to run the project on another machine I get the following:</p>
<p><em>System.Data.SqlClient.SqlException : A connection wa... | [
{
"answer_id": 126972,
"author": "Scott Marlowe",
"author_id": 1683,
"author_profile": "https://Stackoverflow.com/users/1683",
"pm_score": 3,
"selected": true,
"text": "<p>I'm going to answer my own question as I have the solution.</p>\n\n<p>I was relying on the automatic connection stri... | 2008/09/24 | [
"https://Stackoverflow.com/questions/126837",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1683/"
] | I've got a local .mdf SQL database file that I am using for an integration testing project. Everything works fine on the initial machine I created the project, database, etc. on, but when I try to run the project on another machine I get the following:
*System.Data.SqlClient.SqlException : A connection was successfull... | I'm going to answer my own question as I have the solution.
I was relying on the automatic connection string which had an incorrect "AttachDbFilename" property set to a location that was fine on the original machine but which did not exist on the new machine.
I'm going to have to dynamically build the connection stri... |
126,853 | <p>I saw <a href="http://www.gnegg.ch/2008/09/automatic-language-detection/" rel="nofollow noreferrer">this</a> on reddit, and it reminded me of one of my vim gripes: It shows the UI in German. I want English. But since my OS is set up in German (the standard at our office), I guess vim is actually trying to be helpful... | [
{
"answer_id": 126858,
"author": "Armin Ronacher",
"author_id": 19990,
"author_profile": "https://Stackoverflow.com/users/19990",
"pm_score": 2,
"selected": false,
"text": "<p>Start vim with a changed locale:</p>\n\n<pre><code>LC_ALL=en_GB.utf-8 vim\n</code></pre>\n\n<p>Or export that va... | 2008/09/24 | [
"https://Stackoverflow.com/questions/126853",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2260/"
] | I saw [this](http://www.gnegg.ch/2008/09/automatic-language-detection/) on reddit, and it reminded me of one of my vim gripes: It shows the UI in German. I want English. But since my OS is set up in German (the standard at our office), I guess vim is actually trying to be helpful.
What magic incantations must I perfor... | As Ken noted, you want **[the `:language` command](http://vimdoc.sourceforge.net/htmldoc/mlang.html#:language)**.
Note that putting this in your `.vimrc` or `.gvimrc` won’t help you with the menus in gvim, since their definition is loaded once at startup, very early on, and not re-read again later. So you really do ne... |
126,855 | <p>I have two tables, Users and DoctorVisit</p>
<p>User
- UserID
- Name</p>
<p>DoctorsVisit
- UserID
- Weight
- Date </p>
<p>The doctorVisit table contains all the visits a particular user did to the doctor.
The user's weight is recorded per visit.</p>
<p>Query: Sum up all the Users weight, using the last doctor's... | [
{
"answer_id": 126892,
"author": "JPrescottSanders",
"author_id": 19444,
"author_profile": "https://Stackoverflow.com/users/19444",
"pm_score": 0,
"selected": false,
"text": "<p>This should get you the average weight per user if they have visited:</p>\n\n<pre><code>select user.name, temp... | 2008/09/24 | [
"https://Stackoverflow.com/questions/126855",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have two tables, Users and DoctorVisit
User
- UserID
- Name
DoctorsVisit
- UserID
- Weight
- Date
The doctorVisit table contains all the visits a particular user did to the doctor.
The user's weight is recorded per visit.
Query: Sum up all the Users weight, using the last doctor's visit's numbers. (then divide b... | If I understand your question correctly, you should be able to get the average weight of all users based on their last visit from the following SQL statement. We use a subquery to get the last visit as a filter.
```
SELECT avg(uv.weight) FROM (SELECT weight FROM uservisit uv INNER JOIN
(SELECT userid, MAX(dateVisited)... |
126,870 | <p>I am designing a class that stores (caches) a set of data. I want to lookup a value, if the class contains the value then use it and modify a property of the class. I am concerned about the design of the public interface.<br>
Here is how the class is going to be used:</p>
<pre>
ClassItem *pClassItem = myClass.Loo... | [
{
"answer_id": 126944,
"author": "Mark Brackett",
"author_id": 2199,
"author_profile": "https://Stackoverflow.com/users/2199",
"pm_score": 1,
"selected": false,
"text": "<p>This assumes that you're setting value to the same \"something\" in both the Modify and Add cases:</p>\n\n<pre><cod... | 2008/09/24 | [
"https://Stackoverflow.com/questions/126870",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12663/"
] | I am designing a class that stores (caches) a set of data. I want to lookup a value, if the class contains the value then use it and modify a property of the class. I am concerned about the design of the public interface.
Here is how the class is going to be used:
```
ClassItem *pClassItem = myClass.Lookup(value);... | Two things.
The first solution is close.
Don't however, return `ClassItem *`. Return an "opaque object". An integer index or other hash code that's opaque (meaningless) to the client, but usable by the myClass instance.
Then lookup returns an index, which modify can subsequently use.
```
void *index = myClass.looku... |
126,885 | <p>We have a SQL Server table containing Company Name, Address, and Contact name (among others).</p>
<p>We regularly receive data files from outside sources that require us to match up against this table. Unfortunately, the data is slightly different since it is coming from a completely different system. For example... | [
{
"answer_id": 126903,
"author": "torial",
"author_id": 13990,
"author_profile": "https://Stackoverflow.com/users/13990",
"pm_score": 3,
"selected": true,
"text": "<p>Here's something I wrote for a nearly identical stack (we needed to standardize the manufacturer names for hardware and t... | 2008/09/24 | [
"https://Stackoverflow.com/questions/126885",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2173/"
] | We have a SQL Server table containing Company Name, Address, and Contact name (among others).
We regularly receive data files from outside sources that require us to match up against this table. Unfortunately, the data is slightly different since it is coming from a completely different system. For example, we have "1... | Here's something I wrote for a nearly identical stack (we needed to standardize the manufacturer names for hardware and there were all sorts of variations). This is client side though (VB.Net to be exact) -- and use the Levenshtein distance algorithm (modified for better results):
```
Public Shared Function FindMo... |
126,896 | <p>we are using git-svn to manage branches of an SVN repo. We are facing the following problem: after a number of commits by user X in the branch, user Y would like to use git-svn to merge the changes in branch to trunk. The problem we're seeing is that the commit messages for all the individual merge operations look a... | [
{
"answer_id": 127242,
"author": "richq",
"author_id": 4596,
"author_profile": "https://Stackoverflow.com/users/4596",
"pm_score": 5,
"selected": true,
"text": "<p>The git-svn man page recommends that you <em>don't use merge</em>. \"\"It is recommended that you run git-svn fetch and reba... | 2008/09/24 | [
"https://Stackoverflow.com/questions/126896",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | we are using git-svn to manage branches of an SVN repo. We are facing the following problem: after a number of commits by user X in the branch, user Y would like to use git-svn to merge the changes in branch to trunk. The problem we're seeing is that the commit messages for all the individual merge operations look as i... | The git-svn man page recommends that you *don't use merge*. ""It is recommended that you run git-svn fetch and rebase (not pull or merge)"". Having said that, you can do what you like :-)
There are 2 issues here. First is that svn only stores the *commiter*, not the author of a patch as git does. So when Y commits the... |
126,898 | <p>I ran into a problem a few days ago when I had to introduce C++ files into a Java project. It started with a need to measure the CPU usage of the Java process and it was decided that the way to go was to use JNI to call out to a native library (a shared library on a Unix machine) written in C. The problem was to fin... | [
{
"answer_id": 126922,
"author": "Linor",
"author_id": 3197,
"author_profile": "https://Stackoverflow.com/users/3197",
"pm_score": 0,
"selected": false,
"text": "<p>Personally I'd separate the two, possibly even into their own separate projects, but that's when they are both separate thi... | 2008/09/24 | [
"https://Stackoverflow.com/questions/126898",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21647/"
] | I ran into a problem a few days ago when I had to introduce C++ files into a Java project. It started with a need to measure the CPU usage of the Java process and it was decided that the way to go was to use JNI to call out to a native library (a shared library on a Unix machine) written in C. The problem was to find a... | *"I didn't like this because I have only two C files and it seemed very odd to split the source base at the language level like this"*
Why does it seem odd? Consider this project:
```
project1\src\java
project1\src\cpp
project1\src\python
```
Or, if you decide to split things up into modules:
```
project... |
126,925 | <p>I have an Internet Explorer Browser Helper Object (BHO), written in c#, and in various places I open forms as modal dialogs. Sometimes this works but in some cases it doesn't. The case that I can replicate at present is where IE is running javascript to open other child windows... I guess it's getting a bit confused... | [
{
"answer_id": 126959,
"author": "Rory",
"author_id": 8479,
"author_profile": "https://Stackoverflow.com/users/8479",
"pm_score": 2,
"selected": true,
"text": "<p>It wasn't my intention to answer my own question, but...</p>\n\n<p>It seems that if you pass in the correct IWin32Window to t... | 2008/09/24 | [
"https://Stackoverflow.com/questions/126925",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8479/"
] | I have an Internet Explorer Browser Helper Object (BHO), written in c#, and in various places I open forms as modal dialogs. Sometimes this works but in some cases it doesn't. The case that I can replicate at present is where IE is running javascript to open other child windows... I guess it's getting a bit confused so... | It wasn't my intention to answer my own question, but...
It seems that if you pass in the correct IWin32Window to the ShowDialog() method it works fine. The trick is how to get this. Here's how I did this, where 'siteObject' is the object passed in to the SetSite() method of the BHO:
```
IWebBrowser2 browser = siteOb... |
126,939 | <p>I am using log4net in a C# project, in the production environment, I want to disable all the logging, but when some fatal
error occures it should log all the previous 512 messages in to a file.I have successfully configured this, and it is working fine. It logs the messages in to a file when some fatal error occure... | [
{
"answer_id": 127037,
"author": "rslite",
"author_id": 15682,
"author_profile": "https://Stackoverflow.com/users/15682",
"pm_score": 0,
"selected": false,
"text": "<p>Do you still see the messages in Visual Studio if the application is compiled in release mode? It's possible that log4ne... | 2008/09/24 | [
"https://Stackoverflow.com/questions/126939",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21653/"
] | I am using log4net in a C# project, in the production environment, I want to disable all the logging, but when some fatal
error occures it should log all the previous 512 messages in to a file.I have successfully configured this, and it is working fine. It logs the messages in to a file when some fatal error occures. ... | Remove the [BasicConfigurator.Configure()](http://logging.apache.org/log4net/release/sdk/log4net.Config.BasicConfigurator.Configure_overload_1.html) line. That's what that line does -- adds a ConsoleAppender pointing to Console.Out. |
127,001 | <p>I need to compress portions of our application's network traffic for performance. I presume this means I need to stay away from some of the newer algorithms like bzip2, which I think I have heard is slower.</p>
| [
{
"answer_id": 127011,
"author": "Steve g",
"author_id": 12092,
"author_profile": "https://Stackoverflow.com/users/12092",
"pm_score": 5,
"selected": true,
"text": "<p>You can use <a href=\"https://docs.oracle.com/javase/8/docs/api/java/util/zip/Deflater.html\" rel=\"nofollow noreferrer\... | 2008/09/24 | [
"https://Stackoverflow.com/questions/127001",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18103/"
] | I need to compress portions of our application's network traffic for performance. I presume this means I need to stay away from some of the newer algorithms like bzip2, which I think I have heard is slower. | You can use [Deflater](https://docs.oracle.com/javase/8/docs/api/java/util/zip/Deflater.html)/[Inflater](http://docs.oracle.com/javase/7/docs/api/java/util/zip/Inflater.html) which is built into the JDK. There are also GZIPInputStream and GZIPOutputStream, but it really depends on your exact use.
Edit:
Reading furth... |
127,009 | <p>Suppose I want to implement in C++ a data-structure to store oriented graphs. Arcs will be stored in Nodes thanks to STL containers. I'd like users to be able to iterate over the arcs of a node, in an STL-like way.</p>
<p>The issue I have is that I don't want to expose in the Node class (that will actually be an a... | [
{
"answer_id": 127173,
"author": "Greg Rogers",
"author_id": 5963,
"author_profile": "https://Stackoverflow.com/users/5963",
"pm_score": 0,
"selected": false,
"text": "<p>If you really don't want the client's of that class to know that it uses a vector underneath, but still want them to ... | 2008/09/24 | [
"https://Stackoverflow.com/questions/127009",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4177/"
] | Suppose I want to implement in C++ a data-structure to store oriented graphs. Arcs will be stored in Nodes thanks to STL containers. I'd like users to be able to iterate over the arcs of a node, in an STL-like way.
The issue I have is that I don't want to expose in the Node class (that will actually be an abstract bas... | Try this:
```
class Arc;
class Node {
private:
std::vector<Arc*> incoming_;
public:
typedef std::vector<Arc*>::iterator iterator;
iterator incoming_arcs_begin()
{ return incoming_.begin(); }
};
```
And use Node::iterator in the rest of the code. When/if you change the container, you have to change the typede... |
127,027 | <p>I use a byte to store some flag like <code>10101010</code>, and I would like to know how to verify that a specific bit is at <code>1</code> or <code>0</code>.</p>
| [
{
"answer_id": 127033,
"author": "Patrick Desjardins",
"author_id": 13913,
"author_profile": "https://Stackoverflow.com/users/13913",
"pm_score": 2,
"selected": false,
"text": "<p>You can use an AND operator. The example you have: 10101010 and you want to check the third bit you can do: ... | 2008/09/24 | [
"https://Stackoverflow.com/questions/127027",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21386/"
] | I use a byte to store some flag like `10101010`, and I would like to know how to verify that a specific bit is at `1` or `0`. | Here's a function that can be used to test any `bit`:
```
bool is_bit_set(unsigned value, unsigned bitindex)
{
return (value & (1 << bitindex)) != 0;
}
```
**Explanation**:
The [left shift operator](https://learn.sparkfun.com/tutorials/binary#bitwise-operators) `<<` creates a [bitmask](https://stackoverflow.com... |
127,040 | <p>In Internet Explorer I can use the clipboardData object to access the clipboard. How can I do that in FireFox, Safari and/or Chrome?</p>
| [
{
"answer_id": 127064,
"author": "ine",
"author_id": 4965,
"author_profile": "https://Stackoverflow.com/users/4965",
"pm_score": 6,
"selected": false,
"text": "<p>For security reasons, Firefox doesn't allow you to place text on the clipboard. However, there is a workaround available usin... | 2008/09/24 | [
"https://Stackoverflow.com/questions/127040",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11492/"
] | In Internet Explorer I can use the clipboardData object to access the clipboard. How can I do that in FireFox, Safari and/or Chrome? | There is now a way to easily do this in most modern browsers using
```
document.execCommand('copy');
```
This will copy currently selected text. You can select a textArea or input field using
```
document.getElementById('myText').select();
```
To invisibly copy text you can quickly generate a textArea, modify th... |
127,042 | <p>I've found an <a href="http://chrison.net/UACElevationInManagedCodeStartingElevatedCOMComponents.aspx" rel="noreferrer">article</a> on how to elevate a COM object written in C++ by calling
<code>CoCreateInstanceAsAdmin</code>. But what I have not been able to find or do, is a way to implement a component of my .NET... | [
{
"answer_id": 127690,
"author": "MSalters",
"author_id": 15416,
"author_profile": "https://Stackoverflow.com/users/15416",
"pm_score": 2,
"selected": false,
"text": "<p>The elements of elevation are processes. So, if I understand your question correctly, and you want a way to elevate a ... | 2008/09/24 | [
"https://Stackoverflow.com/questions/127042",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4597/"
] | I've found an [article](http://chrison.net/UACElevationInManagedCodeStartingElevatedCOMComponents.aspx) on how to elevate a COM object written in C++ by calling
`CoCreateInstanceAsAdmin`. But what I have not been able to find or do, is a way to implement a component of my .NET (c#) application as a COM object and then... | Look at [Windows Vista UAC Demo Sample Code](http://www.microsoft.com/downloads/details.aspx?FamilyID=2cd92e43-6cda-478a-9e3b-4f831e899433&DisplayLang=en)
(You also need the [Vista Bridge](http://msdn.microsoft.com/en-us/library/ms756482.aspx) sample for UnsafeNativeMethods.CoGetObject method)
Which gives you C# code... |
127,055 | <p>Is there a way to determine how many capture groups there are in a given regular expression?</p>
<p>I would like to be able to do the follwing:</p>
<pre><code>def groups(regexp, s):
""" Returns the first result of re.findall, or an empty default
>>> groups(r'(\d)(\d)(\d)', '123')
('1', '2', '... | [
{
"answer_id": 127089,
"author": "rslite",
"author_id": 15682,
"author_profile": "https://Stackoverflow.com/users/15682",
"pm_score": 1,
"selected": false,
"text": "<p>First of all if you only need the first result of re.findall it's better to just use re.search that returns a match or N... | 2008/09/24 | [
"https://Stackoverflow.com/questions/127055",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7581/"
] | Is there a way to determine how many capture groups there are in a given regular expression?
I would like to be able to do the follwing:
```
def groups(regexp, s):
""" Returns the first result of re.findall, or an empty default
>>> groups(r'(\d)(\d)(\d)', '123')
('1', '2', '3')
>>> groups(r'(\d)(\d)(... | ```
def num_groups(regex):
return re.compile(regex).groups
``` |
127,076 | <p>In ASP.NET, if I databind a gridview with a array of objects lets say , how can I retrieve and use foo(index) when the user selects the row?</p>
<p>i.e.</p>
<pre><code>dim fooArr() as foo;
gv1.datasource = fooArr;
gv1.databind();
</code></pre>
<p>On Row Select</p>
<pre><code>Private Sub gv1_RowCommand(ByVal sen... | [
{
"answer_id": 127114,
"author": "Stephen Wrighton",
"author_id": 7516,
"author_profile": "https://Stackoverflow.com/users/7516",
"pm_score": 0,
"selected": false,
"text": "<p>in theory the index of the row, should be the index of foo (maybe +1 for header row, you'll need to test). so, y... | 2008/09/24 | [
"https://Stackoverflow.com/questions/127076",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11802/"
] | In ASP.NET, if I databind a gridview with a array of objects lets say , how can I retrieve and use foo(index) when the user selects the row?
i.e.
```
dim fooArr() as foo;
gv1.datasource = fooArr;
gv1.databind();
```
On Row Select
```
Private Sub gv1_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebC... | If you can be sure the order of items in your data source has not changed, you can use the CommandArgument property of the CommandEventArgs.
A more robust method, however,is to use the DataKeys/SelectedDataKey properties of the GridView. The only caveat is that your command must be of type "Select" (so, by default Row... |
127,095 | <p>I'm used to Atlas where the preferred (from what I know) method is to use XML comments such as:</p>
<pre><code>/// <summary>
/// Method to calculate distance between two points
/// </summary>
///
/// <param name="pointA">First point</param>
/// <param name="pointB">... | [
{
"answer_id": 127099,
"author": "Jim Burger",
"author_id": 20164,
"author_profile": "https://Stackoverflow.com/users/20164",
"pm_score": 2,
"selected": false,
"text": "<p>The use of the triple comment in the first example is actually used for external XML documentation tools and (in Vis... | 2008/09/24 | [
"https://Stackoverflow.com/questions/127095",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6350/"
] | I'm used to Atlas where the preferred (from what I know) method is to use XML comments such as:
```
/// <summary>
/// Method to calculate distance between two points
/// </summary>
///
/// <param name="pointA">First point</param>
/// <param name="pointB">Second point</param>
///
function calculatePointDistance(point... | There's [JSDoc](https://jsdoc.app/)
```
/**
* Shape is an abstract base class. It is defined simply
* to have something to inherit from for geometric
* subclasses
* @constructor
*/
function Shape(color){
this.color = color;
}
``` |
127,116 | <p>I was wondering if there was an easy way in SQL to convert an integer to its binary representation and then store it as a varchar.</p>
<p>For example 5 would be converted to "101" and stored as a varchar.</p>
| [
{
"answer_id": 127371,
"author": "Sean",
"author_id": 5446,
"author_profile": "https://Stackoverflow.com/users/5446",
"pm_score": 5,
"selected": true,
"text": "<p>Following could be coded into a function. You would need to trim off leading zeros to meet requirements of your question.</p... | 2008/09/24 | [
"https://Stackoverflow.com/questions/127116",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4779/"
] | I was wondering if there was an easy way in SQL to convert an integer to its binary representation and then store it as a varchar.
For example 5 would be converted to "101" and stored as a varchar. | Following could be coded into a function. You would need to trim off leading zeros to meet requirements of your question.
```
declare @intvalue int
set @intvalue=5
declare @vsresult varchar(64)
declare @inti int
select @inti = 64, @vsresult = ''
while @inti>0
begin
select @vsresult=convert(char(1), @intvalue % ... |
127,124 | <p>How do you resolve an NT style device path, e.g. <code>\Device\CdRom0</code>, to its logical drive letter, e.g. <code>G:\</code> ?</p>
<p>Edit: A Volume Name isn't the same as a Device Path so unfortunately <code>GetVolumePathNamesForVolumeName()</code> won't work.</p>
| [
{
"answer_id": 127158,
"author": "Nick",
"author_id": 1490,
"author_profile": "https://Stackoverflow.com/users/1490",
"pm_score": 1,
"selected": false,
"text": "<p>Maybe you could use GetVolumeNameForMountPoint and iterate through all mount points A:\\ through Z:\\, breaking when you fin... | 2008/09/24 | [
"https://Stackoverflow.com/questions/127124",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14260/"
] | How do you resolve an NT style device path, e.g. `\Device\CdRom0`, to its logical drive letter, e.g. `G:\` ?
Edit: A Volume Name isn't the same as a Device Path so unfortunately `GetVolumePathNamesForVolumeName()` won't work. | Hopefully the following piece of code will give you enough to solve this - after you've initialised it, you just need to iterate through the collection to find your match. You may want to convert everything to upper/lower case before you insert into the collection to help with lookup performance.
```
typedef basic_str... |
127,151 | <p>This is an exercise for the CS guys to shine with the theory.</p>
<p>Imagine you have 2 containers with elements. Folders, URLs, Files, Strings, it really doesn't matter.</p>
<p>What is AN algorithm to calculate the added and the removed?</p>
<p><strong>Notice</strong>: If there are many ways to solve this proble... | [
{
"answer_id": 127207,
"author": "Joe Skora",
"author_id": 14057,
"author_profile": "https://Stackoverflow.com/users/14057",
"pm_score": 1,
"selected": false,
"text": "<p>I have not done this in a while but I believe the algorithm goes like this...</p>\n\n<pre><code>sort left-list and ri... | 2008/09/24 | [
"https://Stackoverflow.com/questions/127151",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8167/"
] | This is an exercise for the CS guys to shine with the theory.
Imagine you have 2 containers with elements. Folders, URLs, Files, Strings, it really doesn't matter.
What is AN algorithm to calculate the added and the removed?
**Notice**: If there are many ways to solve this problem, please post one per answer so it c... | Assuming you have two lists of unique items, and the ordering doesn't matter, you can think of them both as sets rather than lists
If you think of a venn diagram, with list A as one circle and list B as the other, then the intersection of these two is the constant pool.
Remove all the elements in this intersection fr... |
127,152 | <p>I had someting like this in my code (.Net 2.0, MS SQL)</p>
<pre><code>SqlConnection connection = new SqlConnection(@"Data Source=localhost;Initial
Catalog=DataBase;Integrated Security=True");
connection.Open();
SqlCommand cmdInsert = connection.CreateCommand();
SqlTransaction sqlTran = connection.BeginTransa... | [
{
"answer_id": 127175,
"author": "TcKs",
"author_id": 20382,
"author_profile": "https://Stackoverflow.com/users/20382",
"pm_score": 2,
"selected": false,
"text": "<p>Is required the transaction? Using transaction need much more resources than simple commands.</p>\n\n<p>Also If you are su... | 2008/09/24 | [
"https://Stackoverflow.com/questions/127152",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/501/"
] | I had someting like this in my code (.Net 2.0, MS SQL)
```
SqlConnection connection = new SqlConnection(@"Data Source=localhost;Initial
Catalog=DataBase;Integrated Security=True");
connection.Open();
SqlCommand cmdInsert = connection.CreateCommand();
SqlTransaction sqlTran = connection.BeginTransaction();
cmd... | Instead of inserting each record individually, Try using the [SqlBulkCopy](http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlbulkcopy.aspx) class to bulk insert all the records at once.
Create a DataTable and add all your records to the DataTable, and then use [SqlBulkCopy](http://msdn.microsoft.com/en-... |
127,156 | <p>How do I check if an index exists on a table field in MySQL?</p>
<p>I've needed to Google this multiple times, so I'm sharing my Q/A.</p>
| [
{
"answer_id": 127157,
"author": "Sean",
"author_id": 5446,
"author_profile": "https://Stackoverflow.com/users/5446",
"pm_score": 8,
"selected": true,
"text": "<p>Use <code>SHOW INDEX</code> like so:</p>\n\n<pre><code>SHOW INDEX FROM [tablename]\n</code></pre>\n\n<p>Docs: <a href=\"https... | 2008/09/24 | [
"https://Stackoverflow.com/questions/127156",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5446/"
] | How do I check if an index exists on a table field in MySQL?
I've needed to Google this multiple times, so I'm sharing my Q/A. | Use `SHOW INDEX` like so:
```
SHOW INDEX FROM [tablename]
```
Docs: <https://dev.mysql.com/doc/refman/5.0/en/show-index.html> |
127,190 | <p>I'm learning Haskell in the hope that it will help me get closer to functional programming. Previously, I've mostly used languages with C-like syntax, like C, Java, and D.</p>
<p>I have a little question about the coding style of an <code>if</code>/<code>else</code> control block used by the <a href="http://en.wiki... | [
{
"answer_id": 127257,
"author": "Jonathan Tran",
"author_id": 12887,
"author_profile": "https://Stackoverflow.com/users/12887",
"pm_score": 1,
"selected": false,
"text": "<p>You can also use explicit grouping with curly braces. See the layout section of <a href=\"http://www.haskell.org... | 2008/09/24 | [
"https://Stackoverflow.com/questions/127190",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/242644/"
] | I'm learning Haskell in the hope that it will help me get closer to functional programming. Previously, I've mostly used languages with C-like syntax, like C, Java, and D.
I have a little question about the coding style of an `if`/`else` control block used by the [tutorial on Wikibooks](http://en.wikibooks.org/wiki/Ha... | Haskell style is functional, not imperative! Rather than "do this then that," think about combining functions and describing *what* your program will do, not how.
In the game, your program asks the user for a guess. A correct guess is a winner. Otherwise, the user tries again. The game continues until the user guesses... |
127,205 | <p>I have a constructor like as follows:</p>
<pre><code>public Agent(){
this.name = "John";
this.id = 9;
this.setTopWorldAgent(this, "Top_World_Agent", true);
}
</code></pre>
<p>I'm getting a null pointer exception here in the method call. It appears to be because I'm using 'this' as an argument in the ... | [
{
"answer_id": 127219,
"author": "sblundy",
"author_id": 4893,
"author_profile": "https://Stackoverflow.com/users/4893",
"pm_score": 0,
"selected": false,
"text": "<p><code>this</code> is not null, that much is sure. It's been allocated.</p>\n\n<p>That said, there's no need to pass <code... | 2008/09/24 | [
"https://Stackoverflow.com/questions/127205",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a constructor like as follows:
```
public Agent(){
this.name = "John";
this.id = 9;
this.setTopWorldAgent(this, "Top_World_Agent", true);
}
```
I'm getting a null pointer exception here in the method call. It appears to be because I'm using 'this' as an argument in the setTopWorldAgent method. B... | ~~You can pass this to methods, but setTopWorldAgent() cannot be abstract. You can't make a virtual call in the constructor.~~
~~In the constructor of an object, you can call methods defined in that object or base classes, but you cannot expect to call something that will be provided by a derived class, because parts ... |
127,233 | <p>This is in C#, I have a class that I am using from some else's DLL. It does not implement IEnumerable but has 2 methods that pass back a IEnumerator. Is there a way I can use a foreach loop on these. The class I am using is sealed.</p>
| [
{
"answer_id": 127254,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 5,
"selected": true,
"text": "<p><code>foreach</code> does <em>not</em> require <code>IEnumerable</code>, contrary to popular belief. All it require... | 2008/09/24 | [
"https://Stackoverflow.com/questions/127233",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3208/"
] | This is in C#, I have a class that I am using from some else's DLL. It does not implement IEnumerable but has 2 methods that pass back a IEnumerator. Is there a way I can use a foreach loop on these. The class I am using is sealed. | `foreach` does *not* require `IEnumerable`, contrary to popular belief. All it requires is a method `GetEnumerator` that returns any object that has the method `MoveNext` and the get-property `Current` with the appropriate signatures.
/EDIT: In your case, however, you're out of luck. You can trivially wrap your object... |
127,241 | <p>We are developing a .NET 2.0 winform application. The application needs to access <a href="http://ws.lokad.com/" rel="nofollow noreferrer">Web Services</a>. Yet, we are encountering issues with users behind proxies.</p>
<p>Popular windows backup applications (think <a href="http://mozy.com/" rel="nofollow noreferre... | [
{
"answer_id": 127263,
"author": "Paul van Brenk",
"author_id": 1837197,
"author_profile": "https://Stackoverflow.com/users/1837197",
"pm_score": 0,
"selected": false,
"text": "<p>The easiest way is to use the proxy settings from IE Explorer.</p>\n"
},
{
"answer_id": 127284,
... | 2008/09/24 | [
"https://Stackoverflow.com/questions/127241",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18858/"
] | We are developing a .NET 2.0 winform application. The application needs to access [Web Services](http://ws.lokad.com/). Yet, we are encountering issues with users behind proxies.
Popular windows backup applications (think [Mozy](http://mozy.com/)) are providing a moderately complex dialog window dedicated the proxy se... | Put this in your application's config file:
```
<configuration>
<system.net>
<defaultProxy>
<proxy autoDetect="true" />
</defaultProxy>
</system.net>
</configuration>
```
and your application will use the proxy settings from IE. If you can see your web service in IE using the proxy server, you shou... |
127,258 | <p>Greetings!</p>
<p>I'm working on wrapping my head around LINQ. If I had some XML such as this loaded into an XDocument object:</p>
<pre><code><Root>
<GroupA>
<Item attrib1="aaa" attrib2="000" attrib3="true" />
</GroupA>
<GroupB>
<Item attrib1="bbb" attri... | [
{
"answer_id": 127301,
"author": "Chris Wenham",
"author_id": 5548,
"author_profile": "https://Stackoverflow.com/users/5548",
"pm_score": 2,
"selected": false,
"text": "<p>Yes, .Element() only returns the first matching element. You want .Elements() and you need to re-write your query so... | 2008/09/24 | [
"https://Stackoverflow.com/questions/127258",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27870/"
] | Greetings!
I'm working on wrapping my head around LINQ. If I had some XML such as this loaded into an XDocument object:
```
<Root>
<GroupA>
<Item attrib1="aaa" attrib2="000" attrib3="true" />
</GroupA>
<GroupB>
<Item attrib1="bbb" attrib2="111" attrib3="true" />
<Item attrib1="ccc"... | ```
XElement e = XElement.Parse(testStr);
string groupName = "GroupB";
var items = from g in e.Elements(groupName)
from i in g.Elements("Item")
select new {
attr1 = (string)i.Attribute("attrib1"),
attr2 = (string)i.Attribute("attrib2")
... |
127,267 | <p>I am currently starting a project utilizing ASP.NET MVC and would like to use NHaml as my view engine as I love Haml from Rails/Merb. The main issue I face is the laying out of my pages. In Webforms, I would place a ContentPlaceHolder in the head so that other pages can have specific CSS and JavaScript files.</p>
<... | [
{
"answer_id": 499496,
"author": "Parsa",
"author_id": 60996,
"author_profile": "https://Stackoverflow.com/users/60996",
"pm_score": 2,
"selected": false,
"text": "<p>Use the ^ evaluator in the master page, and set it's value in each of the layouts(content pages).<br/></p>\n\n<p>See <a h... | 2008/09/24 | [
"https://Stackoverflow.com/questions/127267",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3412/"
] | I am currently starting a project utilizing ASP.NET MVC and would like to use NHaml as my view engine as I love Haml from Rails/Merb. The main issue I face is the laying out of my pages. In Webforms, I would place a ContentPlaceHolder in the head so that other pages can have specific CSS and JavaScript files.
In Rails... | Use the ^ evaluator in the master page, and set it's value in each of the layouts(content pages).
See [NHaml Samples](http://code.google.com/p/nhaml/source/browse/tags/1.4.0/src/Samples/NHaml.Samples.Mvc/) from it's source on [Google Code](http://code.google.com). |
127,283 | <p>I'm having an annoying problem registering a javascript event from inside a user control within a formview in an Async panel. I go to my formview, and press a button to switch into insert mode. This doesn't do a full page postback. Within insert mode, my user control's page_load event should then register a javascr... | [
{
"answer_id": 127491,
"author": "Dave Anderson",
"author_id": 371,
"author_profile": "https://Stackoverflow.com/users/371",
"pm_score": 1,
"selected": false,
"text": "<p>Have you tried using RegisterClientSideScript? You can always check the key for the script with IsClientSideScriptReg... | 2008/09/24 | [
"https://Stackoverflow.com/questions/127283",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17885/"
] | I'm having an annoying problem registering a javascript event from inside a user control within a formview in an Async panel. I go to my formview, and press a button to switch into insert mode. This doesn't do a full page postback. Within insert mode, my user control's page\_load event should then register a javascript... | Have you tried using RegisterClientSideScript? You can always check the key for the script with IsClientSideScriptRegistered to ensure you don't register it multiple times.
I'm assuming the async panel is doing a partial page past back which doesn't trigger the mechansim to regenerate the startup scripts. Perhaps som... |
127,290 | <p>Is there a side effect in doing this:</p>
<p>C code:</p>
<pre><code>struct foo {
int k;
};
int ret_foo(const struct foo* f){
return f.k;
}
</code></pre>
<p>C++ code:</p>
<pre><code>class bar : public foo {
int my_bar() {
return ret_foo( (foo)this );
}
};
</code></pre>
<p>There's an... | [
{
"answer_id": 127312,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 2,
"selected": false,
"text": "<p>Wow, that's evil.</p>\n\n<blockquote>\n <p>Is this portable across compilers?</p>\n</blockquote>\n\n<p>Most defin... | 2008/09/24 | [
"https://Stackoverflow.com/questions/127290",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21648/"
] | Is there a side effect in doing this:
C code:
```
struct foo {
int k;
};
int ret_foo(const struct foo* f){
return f.k;
}
```
C++ code:
```
class bar : public foo {
int my_bar() {
return ret_foo( (foo)this );
}
};
```
There's an `extern "C"` around the C++ code and each code is insid... | This is entirely legal. In C++, classes and structs are identical concepts, with the exception that all struct members are public by default. That's the only difference. So asking whether you can extend a struct is no different than asking if you can extend a class.
There is one caveat here. There is *no guarantee* of... |
127,316 | <p>I first got an error usign the code below, explaining that "DataGridLinkButton' must be placed inside a form tag with runat=server."</p>
<p>Now I've tried setting AllowSorting to false, as well as removing the sort expression from each column, with the same error. Then I tried creating a new, plain, DataGrid, with... | [
{
"answer_id": 127334,
"author": "Erikk Ross",
"author_id": 18772,
"author_profile": "https://Stackoverflow.com/users/18772",
"pm_score": 2,
"selected": true,
"text": "<p>Add the following empty method to your code. That should fix it. </p>\n\n<pre><code>public override void VerifyRender... | 2008/09/24 | [
"https://Stackoverflow.com/questions/127316",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8741/"
] | I first got an error usign the code below, explaining that "DataGridLinkButton' must be placed inside a form tag with runat=server."
Now I've tried setting AllowSorting to false, as well as removing the sort expression from each column, with the same error. Then I tried creating a new, plain, DataGrid, with the same d... | Add the following empty method to your code. That should fix it.
```
public override void VerifyRenderingInServerForm(Control control)
{
}
``` |
127,318 | <p>I want to programmatically edit file content using windows command line (<a href="http://en.wikipedia.org/wiki/Windows_command_line" rel="noreferrer">cmd.exe</a>). In *nix there is <a href="http://en.wikipedia.org/wiki/Sed" rel="noreferrer">sed</a> for this tasks. Is there any useful native equivalent in windows?</p... | [
{
"answer_id": 127330,
"author": "robintw",
"author_id": 1912,
"author_profile": "https://Stackoverflow.com/users/1912",
"pm_score": 3,
"selected": false,
"text": "<p>You could install Cygwin (<a href=\"http://www.cygwin.com/\" rel=\"noreferrer\">http://www.cygwin.com/</a>) and use sed f... | 2008/09/24 | [
"https://Stackoverflow.com/questions/127318",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2361/"
] | I want to programmatically edit file content using windows command line ([cmd.exe](http://en.wikipedia.org/wiki/Windows_command_line)). In \*nix there is [sed](http://en.wikipedia.org/wiki/Sed) for this tasks. Is there any useful native equivalent in windows? | Today powershell saved me.
For `grep` there is:
```
get-content somefile.txt | where { $_ -match "expression"}
```
or
```
select-string somefile.txt -pattern "expression"
```
and for `sed` there is:
```
get-content somefile.txt | %{$_ -replace "expression","replace"}
```
For more detail about replace PowerShe... |
127,328 | <p>I have a class that defines the names of various constants, e.g.</p>
<pre><code>class Constants {
public static final String ATTR_CURRENT_USER = "current.user";
}
</code></pre>
<p>I would like to use these constants within a JSP <strong>without</strong> using Scriptlet code such as:</p>
<pre><code><%@ page... | [
{
"answer_id": 127384,
"author": "JeeBee",
"author_id": 17832,
"author_profile": "https://Stackoverflow.com/users/17832",
"pm_score": -1,
"selected": false,
"text": "<p>Why do you want to print the value of the constant on the JSP? Surely you are defining them so that in the JSP you can ... | 2008/09/24 | [
"https://Stackoverflow.com/questions/127328",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2648/"
] | I have a class that defines the names of various constants, e.g.
```
class Constants {
public static final String ATTR_CURRENT_USER = "current.user";
}
```
I would like to use these constants within a JSP **without** using Scriptlet code such as:
```
<%@ page import="com.example.Constants" %>
<%= Constants.ATTR... | On application startup, you can add the Constants class to the servletContext and then access it in any jsp page
```
servletContext.setAttribute("Constants", com.example.Constants);
```
and then access it in a jsp page
```
<c:out value="${Constants.ATTR_CURRENT_USER}"/>
```
(you might have to create getters for e... |
127,336 | <p>Outlook saves its client-side rule definitions in a binary blob in a hidden message in the Inbox folder of the default store for a profile. The hidden message is named <em>"Outlook Rules Organizer"</em> with a message class <code>IPM.RuleOrganizer</code>. The binary blob is saved in property 0x6802. The same binary ... | [
{
"answer_id": 127384,
"author": "JeeBee",
"author_id": 17832,
"author_profile": "https://Stackoverflow.com/users/17832",
"pm_score": -1,
"selected": false,
"text": "<p>Why do you want to print the value of the constant on the JSP? Surely you are defining them so that in the JSP you can ... | 2008/09/24 | [
"https://Stackoverflow.com/questions/127336",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21685/"
] | Outlook saves its client-side rule definitions in a binary blob in a hidden message in the Inbox folder of the default store for a profile. The hidden message is named *"Outlook Rules Organizer"* with a message class `IPM.RuleOrganizer`. The binary blob is saved in property 0x6802. The same binary blob is written to th... | On application startup, you can add the Constants class to the servletContext and then access it in any jsp page
```
servletContext.setAttribute("Constants", com.example.Constants);
```
and then access it in a jsp page
```
<c:out value="${Constants.ATTR_CURRENT_USER}"/>
```
(you might have to create getters for e... |
127,386 | <p>In Visual Studio, we've all had "baadf00d", have seen seen "CC" and "CD" when inspecting variables in the debugger in C++ during run-time.</p>
<p>From what I understand, "CC" is in DEBUG mode only to indicate when a memory has been new() or alloc() and unitilialized. While "CD" represents delete'd or free'd memory... | [
{
"answer_id": 127404,
"author": "Mark Ingram",
"author_id": 986,
"author_profile": "https://Stackoverflow.com/users/986",
"pm_score": 9,
"selected": true,
"text": "<p>This link has more information:</p>\n<p><a href=\"https://en.wikipedia.org/wiki/Magic_number_(programming)#Debug_values\... | 2008/09/24 | [
"https://Stackoverflow.com/questions/127386",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7234/"
] | In Visual Studio, we've all had "baadf00d", have seen seen "CC" and "CD" when inspecting variables in the debugger in C++ during run-time.
From what I understand, "CC" is in DEBUG mode only to indicate when a memory has been new() or alloc() and unitilialized. While "CD" represents delete'd or free'd memory. I've only... | This link has more information:
<https://en.wikipedia.org/wiki/Magic_number_(programming)#Debug_values>
```
* 0xABABABAB : Used by Microsoft's HeapAlloc() to mark "no man's land" guard bytes after allocated heap memory
* 0xABADCAFE : A startup to this value to initialize all free memory to catch errant pointers
* 0x... |
127,389 | <p>Today I stumbled about a Problem which seems to be a bug in the Zend-Framework. Given the following route:</p>
<pre><code><test>
<route>citytest/:city</route>
<defaults>
<controller>result</controller>
<action>test</action>
</defaults>... | [
{
"answer_id": 127818,
"author": "troelskn",
"author_id": 18180,
"author_profile": "https://Stackoverflow.com/users/18180",
"pm_score": 1,
"selected": false,
"text": "<p>The u modifier makes the regexp expect utf-8 input. This would suggest that ZF expects utf-8 encoded input, and not IS... | 2008/09/24 | [
"https://Stackoverflow.com/questions/127389",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18606/"
] | Today I stumbled about a Problem which seems to be a bug in the Zend-Framework. Given the following route:
```
<test>
<route>citytest/:city</route>
<defaults>
<controller>result</controller>
<action>test</action>
</defaults>
<reqs>
<city>.+</city>
</reqs>
</test>
```
and t... | The problem is the following:
>
> Using the /u pattern modifier prevents
> words from being mangled but instead
> PCRE skips strings of characters with
> code values greater than 127.
> Therefore, \w will not match a
> multibyte (non-lower ascii) word at
> all (but also won’t return portions of
> it). From the... |
127,391 | <p>I was asked a question in C last night and I did not know the answer since I have not used C much since college so I thought maybe I could find the answer here instead of just forgetting about it.</p>
<p>If a person has a define such as:</p>
<pre><code>#define count 1
</code></pre>
<p>Can that person find the var... | [
{
"answer_id": 127402,
"author": "Remo.D",
"author_id": 16827,
"author_profile": "https://Stackoverflow.com/users/16827",
"pm_score": 0,
"selected": false,
"text": "<p>What do you mean by \"finding\"?</p>\n\n<p>The line </p>\n\n<pre><code>#define count 1\n</code></pre>\n\n<p>defines a sy... | 2008/09/24 | [
"https://Stackoverflow.com/questions/127391",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16354/"
] | I was asked a question in C last night and I did not know the answer since I have not used C much since college so I thought maybe I could find the answer here instead of just forgetting about it.
If a person has a define such as:
```
#define count 1
```
Can that person find the variable name `count` using the 1 th... | The simple answer is no they can't. #Defines like that are dealt with by the preprocessor, and they only point in one direction. Of course the other problem is that even the compiler wouldn't know - as a "1" could point to anything - multiple variables can have the same value at the same time. |
127,395 | <p>Is there a way when creating web services to specify the types to use? Specifically, I want to be able to use the same type on both the client and server to reduce duplication of code.</p>
<p>Over simplified example:</p>
<pre><code> public class Name
{
public string FirstName {get; set;}
pub... | [
{
"answer_id": 127910,
"author": "MusiGenesis",
"author_id": 14606,
"author_profile": "https://Stackoverflow.com/users/14606",
"pm_score": 0,
"selected": false,
"text": "<p>If you want to have a type or structure shared between your web service and your client, add a public struct to you... | 2008/09/24 | [
"https://Stackoverflow.com/questions/127395",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9539/"
] | Is there a way when creating web services to specify the types to use? Specifically, I want to be able to use the same type on both the client and server to reduce duplication of code.
Over simplified example:
```
public class Name
{
public string FirstName {get; set;}
public string Surname { ... | Okay, I see know that this has been an explicit design decision on the part of SOAP so you're not actually supposed to do this. I found the following [page](http://msdn.microsoft.com/en-us/library/ms978594.aspx) that explains why:
>
> **Services share schema and contract,
> not class**. Services interact solely on
> ... |
127,413 | <p>I have user control named DateTimeUC which has two textboxes on its markup:</p>
<pre><code><asp:TextBox ID="dateTextBox" runat="server"></asp:TextBox>
<asp:TextBox ID="timeTextBox" runat="server"></asp:TextBox>
</code></pre>
<p>I am dynamically creating this control in another user control:... | [
{
"answer_id": 127438,
"author": "TcKs",
"author_id": 20382,
"author_profile": "https://Stackoverflow.com/users/20382",
"pm_score": 4,
"selected": true,
"text": "<p>You must use the <code>LoadControl( \"your_user_control_app_relative_path.ascx\" )</code> method instead of \"DateTimeUC uc... | 2008/09/24 | [
"https://Stackoverflow.com/questions/127413",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31505/"
] | I have user control named DateTimeUC which has two textboxes on its markup:
```
<asp:TextBox ID="dateTextBox" runat="server"></asp:TextBox>
<asp:TextBox ID="timeTextBox" runat="server"></asp:TextBox>
```
I am dynamically creating this control in another user control:
```
Controls.Add(GenerateDateTime(parameter));
p... | You must use the `LoadControl( "your_user_control_app_relative_path.ascx" )` method instead of "DateTimeUC uc = new DateTimeUC();" |
127,426 | <p>I have defined an interface in C++, i.e. a class containing only pure virtual functions.</p>
<p>I want to explicitly forbid users of the interface to delete the object through a pointer to the interface, so I declared a protected and non-virtual destructor for the interface, something like:</p>
<pre><code>class IT... | [
{
"answer_id": 127453,
"author": "INS",
"author_id": 13136,
"author_profile": "https://Stackoverflow.com/users/13136",
"pm_score": 0,
"selected": false,
"text": "<p>If the destructor is virtual it makes sure that the base class destructor is also called fore doing the cleanup, otherwise ... | 2008/09/24 | [
"https://Stackoverflow.com/questions/127426",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15622/"
] | I have defined an interface in C++, i.e. a class containing only pure virtual functions.
I want to explicitly forbid users of the interface to delete the object through a pointer to the interface, so I declared a protected and non-virtual destructor for the interface, something like:
```
class ITest{
public:
virt... | It's more or less a bug in the compiler. Note that in more recent versions of the compiler this warning does not get thrown (at least in 4.3 it doesn't). Having the destructor be protected and non-virtual is completely legitimate in your case.
See [here](http://www.gotw.ca/publications/mill18.htm) for an excellent art... |
127,459 | <p>I need to be able to change the users' password through a web page (in a controlled environment).
So, for that, I'm using this code:</p>
<pre><code><?php
$output = shell_exec("sudo -u dummy passwd testUser testUserPassword");
$output2 = shell_exec("dummyPassword");
echo $output;
echo $output2;
echo "done";
?>... | [
{
"answer_id": 127495,
"author": "Jeremy",
"author_id": 1114,
"author_profile": "https://Stackoverflow.com/users/1114",
"pm_score": 2,
"selected": false,
"text": "<p>I'm not familiar enough with PHP to tell you how to fix it, but your problem is that the two <code>shell_exec</code> comma... | 2008/09/24 | [
"https://Stackoverflow.com/questions/127459",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2019426/"
] | I need to be able to change the users' password through a web page (in a controlled environment).
So, for that, I'm using this code:
```
<?php
$output = shell_exec("sudo -u dummy passwd testUser testUserPassword");
$output2 = shell_exec("dummyPassword");
echo $output;
echo $output2;
echo "done";
?>
```
My problem is... | I'm not familiar enough with PHP to tell you how to fix it, but your problem is that the two `shell_exec` commands are entirely separate. It appears as though you're trying to use the second command to pipe input to the first one, but that's not possible. The first command shouldn't return until after that process has ... |
127,477 | <p>In WPF you can setup validation based on errors thrown in your Data Layer during Data Binding using the <code>ExceptionValidationRule</code> or <code>DataErrorValidationRule</code>.</p>
<p>Suppose you had a bunch of controls set up this way and you had a Save button. When the user clicks the Save button, you need ... | [
{
"answer_id": 127526,
"author": "user21243",
"author_id": 21243,
"author_profile": "https://Stackoverflow.com/users/21243",
"pm_score": 0,
"selected": false,
"text": "<p>You can iterate over all your controls tree recursively and check the attached property Validation.HasErrorProperty, ... | 2008/09/24 | [
"https://Stackoverflow.com/questions/127477",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4407/"
] | In WPF you can setup validation based on errors thrown in your Data Layer during Data Binding using the `ExceptionValidationRule` or `DataErrorValidationRule`.
Suppose you had a bunch of controls set up this way and you had a Save button. When the user clicks the Save button, you need to make sure there are no validat... | This post was extremely helpful. Thanks to all who contributed. Here is a LINQ version that you will either love or hate.
```
private void CanExecute(object sender, CanExecuteRoutedEventArgs e)
{
e.CanExecute = IsValid(sender as DependencyObject);
}
private bool IsValid(DependencyObject obj)
{
// The dependen... |
127,492 | <p>I have an EAR file that contains two WARs, war1.war and war2.war. My application.xml file looks like this:</p>
<pre><code><?xml version="1.0" encoding="UTF-8"?>
<application version="5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http:... | [
{
"answer_id": 127548,
"author": "Joseph Daigle",
"author_id": 507,
"author_profile": "https://Stackoverflow.com/users/507",
"pm_score": 0,
"selected": false,
"text": "<p><code>http://localhost:8080//</code> should still be a valid URL that is equivalent to <code>http://localhost:8080/</... | 2008/09/24 | [
"https://Stackoverflow.com/questions/127492",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13455/"
] | I have an EAR file that contains two WARs, war1.war and war2.war. My application.xml file looks like this:
```
<?xml version="1.0" encoding="UTF-8"?>
<application version="5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j... | In Glassfish 3.0.1 you can define the default web application in the administration console:
"Configuration\Virtual Servers\server\Default Web Module".
The drop-down box contains all deployed war modules.
The default web module is then accessible from <http://localhost:8080/>. |
127,514 | <p>I am writing a program which has two panes (via <code>CSplitter</code>), however I am having problems figuring out out to resize the controls in each frame. For simplicity, can someone tell me how I would do it for a basic frame with a single <code>CEdit</code> control? </p>
<p>I'm fairly sure it is to do with the ... | [
{
"answer_id": 127520,
"author": "Rob",
"author_id": 9236,
"author_profile": "https://Stackoverflow.com/users/9236",
"pm_score": 4,
"selected": true,
"text": "<p>When your frame receives an OnSize message it will give you the new width and height - you can simply call the CEdit SetWindow... | 2008/09/24 | [
"https://Stackoverflow.com/questions/127514",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18664/"
] | I am writing a program which has two panes (via `CSplitter`), however I am having problems figuring out out to resize the controls in each frame. For simplicity, can someone tell me how I would do it for a basic frame with a single `CEdit` control?
I'm fairly sure it is to do with the `CEdit::OnSize()` function... Bu... | When your frame receives an OnSize message it will give you the new width and height - you can simply call the CEdit SetWindowPos method passing it these values.
Assume CMyPane is your splitter pane and it contains a CEdit you created in OnCreate called m\_wndEdit:
```
void CMyPane::OnSize(UINT nType, int cx, int cy)... |
127,530 | <p>I'm adding a new field to a list and view. To add the field to the view, I'm using this code:</p>
<pre><code>view.ViewFields.Add("My New Field");
</code></pre>
<p>However this just tacks it on to the end of the view. How do I add the field to a particular column, or rearrange the field order? view.ViewFields is an... | [
{
"answer_id": 127859,
"author": "Alex Angas",
"author_id": 6651,
"author_profile": "https://Stackoverflow.com/users/6651",
"pm_score": 3,
"selected": true,
"text": "<p>I've found removing all items from the list and readding them in the order that I'd like works well (although a little ... | 2008/09/24 | [
"https://Stackoverflow.com/questions/127530",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6651/"
] | I'm adding a new field to a list and view. To add the field to the view, I'm using this code:
```
view.ViewFields.Add("My New Field");
```
However this just tacks it on to the end of the view. How do I add the field to a particular column, or rearrange the field order? view.ViewFields is an SPViewFieldCollection obj... | I've found removing all items from the list and readding them in the order that I'd like works well (although a little drastic). Here is the code I'm using:
```
string[] fieldNames = new string[] { "Title", "My New Field", "Modified", "Created" };
SPViewFieldCollection viewFields = view.ViewFields;
viewFields.DeleteAl... |
127,556 | <p>I have a listbox where the items contain checkboxes:</p>
<pre><code><ListBox Style="{StaticResource CheckBoxListStyle}" Name="EditListBox">
<ListBox.ItemTemplate>
<DataTemplate>
<CheckBox Click="Checkbox_Click" IsChecked="{Binding Path=IsChecked, Mode=TwoWay}" Content="{... | [
{
"answer_id": 127589,
"author": "Kent Boogaart",
"author_id": 5380,
"author_profile": "https://Stackoverflow.com/users/5380",
"pm_score": 4,
"selected": true,
"text": "<p>To begin with, put the content outside the <code>CheckBox</code>:</p>\n\n<pre><code><StackPanel Orientation=\"Hor... | 2008/09/24 | [
"https://Stackoverflow.com/questions/127556",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2284/"
] | I have a listbox where the items contain checkboxes:
```
<ListBox Style="{StaticResource CheckBoxListStyle}" Name="EditListBox">
<ListBox.ItemTemplate>
<DataTemplate>
<CheckBox Click="Checkbox_Click" IsChecked="{Binding Path=IsChecked, Mode=TwoWay}" Content="{Binding Path=DisplayText}" />
... | To begin with, put the content outside the `CheckBox`:
```
<StackPanel Orientation="Horizontal">
<CheckBox IsChecked="{Binding IsChecked}"/>
<TextBlock Text="{Binding DisplayText}"/>
</StackPanel>
```
After that, you will need to ensure that pressing space on a `ListBoxItem` results in the `CheckBox` being c... |
127,587 | <p>I'm trying to use <a href="http://trac.videolan.org/jvlc/" rel="nofollow noreferrer">JVLC</a> but I can't seem to get it work. I've downloaded the jar, I installed <a href="http://www.videolan.org/vlc/" rel="nofollow noreferrer">VLC</a> and passed the -D argument to the JVM telling it where VLC is installed. I also ... | [
{
"answer_id": 127875,
"author": "Kris Kumler",
"author_id": 4281,
"author_profile": "https://Stackoverflow.com/users/4281",
"pm_score": 5,
"selected": false,
"text": "<p>My favorite is the command <code>.cmdtree <file></code> (undocumented, but referenced in previous release notes... | 2008/09/24 | [
"https://Stackoverflow.com/questions/127587",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20459/"
] | I'm trying to use [JVLC](http://trac.videolan.org/jvlc/) but I can't seem to get it work. I've downloaded the jar, I installed [VLC](http://www.videolan.org/vlc/) and passed the -D argument to the JVM telling it where VLC is installed. I also tried:
```
NativeLibrary.addSearchPath("libvlc", "C:\\Program Files\\VideoLA... | My favorite is the command `.cmdtree <file>` (undocumented, but referenced in previous release notes). This can assist in bringing up another window (that can be docked) to display helpful or commonly used commands. This can help make the user much more productive using the tool.
Initially talked about here, with an e... |
127,598 | <p>So, I have Flex project that loads a Module using the ModuleManager - not the module loader. The problem that I'm having is that to load an external asset (like a video or image) the path to load that asset has to be relative to the Module swf...not relative to the swf that loaded the module.</p>
<p>The question i... | [
{
"answer_id": 132670,
"author": "hasseg",
"author_id": 4111,
"author_profile": "https://Stackoverflow.com/users/4111",
"pm_score": 3,
"selected": true,
"text": "<p>You can import <code>mx.core.Application</code> and then use <a href=\"http://livedocs.adobe.com/flex/3/langref/mx/core/App... | 2008/09/24 | [
"https://Stackoverflow.com/questions/127598",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3435/"
] | So, I have Flex project that loads a Module using the ModuleManager - not the module loader. The problem that I'm having is that to load an external asset (like a video or image) the path to load that asset has to be relative to the Module swf...not relative to the swf that loaded the module.
The question is - How can... | You can import `mx.core.Application` and then use [Application.application.url](http://livedocs.adobe.com/flex/3/langref/mx/core/Application.html#url) to get the path of the host application in your module and use that as the basis for building the URLs.
For help in dealing with URLs, see [the URLUtil class in the sta... |
127,606 | <p>I'm trying to generate customized xml files from a template xml file in python. </p>
<p>Conceptually, I want to read in the template xml, remove some elements, change some text attributes, and write the new xml out to a file. I wanted it to work something like this:</p>
<pre><code>conf_base = ConvertXmlToDict('co... | [
{
"answer_id": 127678,
"author": "Torsten Marek",
"author_id": 9567,
"author_profile": "https://Stackoverflow.com/users/9567",
"pm_score": 4,
"selected": false,
"text": "<p>I'm not sure if converting the info set to nested dicts first is easier. Using ElementTree, you can do this:</p>\n\... | 2008/09/24 | [
"https://Stackoverflow.com/questions/127606",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1489/"
] | I'm trying to generate customized xml files from a template xml file in python.
Conceptually, I want to read in the template xml, remove some elements, change some text attributes, and write the new xml out to a file. I wanted it to work something like this:
```
conf_base = ConvertXmlToDict('config-template.xml')
co... | For easy manipulation of XML in python, I like the [Beautiful Soup](http://www.crummy.com/software/BeautifulSoup/) library. It works something like this:
Sample XML File:
```
<root>
<level1>leaf1</level1>
<level2>leaf2</level2>
</root>
```
Python code:
```
from BeautifulSoup import BeautifulStoneSoup, Tag, Nav... |
127,625 | <p>I'm currently working on a class that calculates the difference between two objects. I'm trying to decide what the best design for this class would be. I see two options:</p>
<p>1) Single-use class instance. Takes the objects to diff in the constructor and calculates the diff for that.</p>
<pre><code>public cla... | [
{
"answer_id": 127631,
"author": "kitsune",
"author_id": 13466,
"author_profile": "https://Stackoverflow.com/users/13466",
"pm_score": 0,
"selected": false,
"text": "<p>I'd take numero 2 and reflect on whether I should make this static.</p>\n"
},
{
"answer_id": 127670,
"autho... | 2008/09/24 | [
"https://Stackoverflow.com/questions/127625",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1409/"
] | I'm currently working on a class that calculates the difference between two objects. I'm trying to decide what the best design for this class would be. I see two options:
1) Single-use class instance. Takes the objects to diff in the constructor and calculates the diff for that.
```
public class MyObjDiffer {
publi... | ### Use Object-Oriented Programming
Use option 2, but do *not* make it static.
### The Strategy Pattern
This way, an instance `MyObjDiffer` can be passed to anyone that needs a [Strategy](http://en.wikipedia.org/wiki/Strategy_pattern) for computing the difference between objects.
If, down the road, you find that d... |
127,654 | <p>I'm working on an existing report and I would like to test it with the database. The problem is that the catalog set during the initial report creation no longer exists. I just need to change the catalog parameter to a new database. The report is using a stored proc for its data. It looks like if try and remove ... | [
{
"answer_id": 127674,
"author": "Quintin Robinson",
"author_id": 12707,
"author_profile": "https://Stackoverflow.com/users/12707",
"pm_score": 0,
"selected": false,
"text": "<p>EDIT: Saw your edit, so i'll keep my original post but have to say.. I've never had a crystal report in design... | 2008/09/24 | [
"https://Stackoverflow.com/questions/127654",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2862/"
] | I'm working on an existing report and I would like to test it with the database. The problem is that the catalog set during the initial report creation no longer exists. I just need to change the catalog parameter to a new database. The report is using a stored proc for its data. It looks like if try and remove the pro... | If you just need to do it in the designer then right click in some whitespace and click on Database->set datasource location. From there you can use a current connection or add a new connection. Set a new connection using the new catalog. Then click on your current connection in the top section and click update. Your d... |
127,669 | <p>I have a computer A with two directory trees. The first directory contains the original mod dates that span back several years. The second directory is a copy of the first with a few additional files. There is a second computer be which contains a directory tree which is the same as the second directory on comput... | [
{
"answer_id": 128303,
"author": "The Archetypal Paul",
"author_id": 21755,
"author_profile": "https://Stackoverflow.com/users/21755",
"pm_score": 0,
"selected": false,
"text": "<p>I think rsync (with the right options)\nwill do this - it claims to only send\nfile differences, so presuma... | 2008/09/24 | [
"https://Stackoverflow.com/questions/127669",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9940/"
] | I have a computer A with two directory trees. The first directory contains the original mod dates that span back several years. The second directory is a copy of the first with a few additional files. There is a second computer be which contains a directory tree which is the same as the second directory on computer A (... | The following command will make sure that TEST2 gets the same date assigned that TEST1 has
```
touch -t `stat -t '%Y%m%d%H%M.%S' -f '%Sa' TEST1` TEST2
```
Now instead of using hard-coded values here, you could find the files using "find" utility and then run touch via SSH on the remote machine. However, that means y... |
127,679 | <p>How do I view the grants (access rights) for a given user in MySQL?</p>
| [
{
"answer_id": 127683,
"author": "alanc10n",
"author_id": 14059,
"author_profile": "https://Stackoverflow.com/users/14059",
"pm_score": 6,
"selected": true,
"text": "<pre><code>mysql> show grants for 'user'@'host'\n</code></pre>\n"
},
{
"answer_id": 127710,
"author": "Kevi... | 2008/09/24 | [
"https://Stackoverflow.com/questions/127679",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14059/"
] | How do I view the grants (access rights) for a given user in MySQL? | ```
mysql> show grants for 'user'@'host'
``` |
127,704 | <p>I want to write a function that takes an array of letters as an argument and a number of those letters to select. </p>
<p>Say you provide an array of 8 letters and want to select 3 letters from that. Then you should get:</p>
<pre><code>8! / ((8 - 3)! * 3!) = 56
</code></pre>
<p>Arrays (or words) in return consist... | [
{
"answer_id": 127856,
"author": "nlucaroni",
"author_id": 157,
"author_profile": "https://Stackoverflow.com/users/157",
"pm_score": 10,
"selected": true,
"text": "<p><a href=\"http://portal.acm.org/citation.cfm?id=1036677&dl=&coll=\" rel=\"noreferrer\">Art of Computer Programmin... | 2008/09/24 | [
"https://Stackoverflow.com/questions/127704",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9191/"
] | I want to write a function that takes an array of letters as an argument and a number of those letters to select.
Say you provide an array of 8 letters and want to select 3 letters from that. Then you should get:
```
8! / ((8 - 3)! * 3!) = 56
```
Arrays (or words) in return consisting of 3 letters each. | [Art of Computer Programming Volume 4: Fascicle 3](http://portal.acm.org/citation.cfm?id=1036677&dl=&coll=) has a ton of these that might fit your particular situation better than how I describe.
Gray Codes
----------
An issue that you will come across is of course memory and pretty quickly, you'll have problems by 2... |
127,713 | <p>Why does the following method hang?</p>
<pre>
public void pipe(Reader in, Writer out) {
CharBuffer buf = CharBuffer.allocate(DEFAULT_BUFFER_SIZE);
while( in.read(buf) >= 0 ) {
out.append(buf.flip());
}
}
</pre>
| [
{
"answer_id": 127729,
"author": "Chris Conway",
"author_id": 1412,
"author_profile": "https://Stackoverflow.com/users/1412",
"pm_score": 2,
"selected": true,
"text": "<p>Answering my own question: you have to call <code>buf.clear()</code> between <code>read</code>s. Presumably, <code>re... | 2008/09/24 | [
"https://Stackoverflow.com/questions/127713",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1412/"
] | Why does the following method hang?
```
public void pipe(Reader in, Writer out) {
CharBuffer buf = CharBuffer.allocate(DEFAULT_BUFFER_SIZE);
while( in.read(buf) >= 0 ) {
out.append(buf.flip());
}
}
``` | Answering my own question: you have to call `buf.clear()` between `read`s. Presumably, `read` is hanging because the buffer is full. The correct code is
```
public void pipe(Reader in, Writer out) {
CharBuffer buf = CharBuffer.allocate(DEFAULT_BUFFER_SIZE);
while( in.read(buf) >= 0 ) {
out.append(buf.fl... |
127,728 | <p>I'm working with ASP.NET 3.5.
I have a list box that users must add items to (I've written the code for this). My requirement is that at least one item must be added to the listbox or they cannot submit the form. I have several other validators on the page and they all write to a ValidationSummary control. I would l... | [
{
"answer_id": 127805,
"author": "Jason N. Gaylord",
"author_id": 21318,
"author_profile": "https://Stackoverflow.com/users/21318",
"pm_score": -1,
"selected": false,
"text": "<p>You will want to register your control with the page by sending in the ClientID. Then, you can use Microsoft ... | 2008/09/24 | [
"https://Stackoverflow.com/questions/127728",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm working with ASP.NET 3.5.
I have a list box that users must add items to (I've written the code for this). My requirement is that at least one item must be added to the listbox or they cannot submit the form. I have several other validators on the page and they all write to a ValidationSummary control. I would like... | Drop in a custom validator, Add your desired error message to it, double click on the custom validator to get to the code behind for the event handler, and then you would implement server side like this:
```
protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args)
{
args.IsV... |
127,736 | <p>Greetings, currently I am refactoring one of my programs, and I found an interesting problem.</p>
<p>I have Transitions in an automata. Transitions always have a start-state and an end-state. Some Transitions have a label, which encodes a certain Action that must be performed upon traversal. No label means no actio... | [
{
"answer_id": 128005,
"author": "Mark Roddy",
"author_id": 9940,
"author_profile": "https://Stackoverflow.com/users/9940",
"pm_score": 0,
"selected": false,
"text": "<p>From the code that was posted, the only difference between Transition and Labeled Transition is the return of get_labl... | 2008/09/24 | [
"https://Stackoverflow.com/questions/127736",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17663/"
] | Greetings, currently I am refactoring one of my programs, and I found an interesting problem.
I have Transitions in an automata. Transitions always have a start-state and an end-state. Some Transitions have a label, which encodes a certain Action that must be performed upon traversal. No label means no action. Some tr... | I think its clear that nobody really understands your question. I would suggest putting it in context and making it shorter. As an example, here's one possible implementation of the state pattern in python, please study it to get an idea.
```
class State(object):
def __init__(self, name):
self.name = name
... |
127,739 | <pre><code> $a = '{ "tag": "<b></b>" }';
echo json_encode( json_decode($a) );
</code></pre>
<p>This outputs:</p>
<pre><code>{"tag":"<b><\/b>"}
</code></pre>
<p>when you would think it would output exactly the input. For some reason json_encode adds an extra slash.</p>
| [
{
"answer_id": 127775,
"author": "Peter Bailey",
"author_id": 8815,
"author_profile": "https://Stackoverflow.com/users/8815",
"pm_score": 5,
"selected": true,
"text": "<p>Because it's part of the JSON standard</p>\n<p><a href=\"http://json.org/\" rel=\"noreferrer\">http://json.org/</a></... | 2008/09/24 | [
"https://Stackoverflow.com/questions/127739",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19087/"
] | ```
$a = '{ "tag": "<b></b>" }';
echo json_encode( json_decode($a) );
```
This outputs:
```
{"tag":"<b><\/b>"}
```
when you would think it would output exactly the input. For some reason json\_encode adds an extra slash. | Because it's part of the JSON standard
<http://json.org/>
>
> char
>
>
>
> ```
> any-Unicode-character-
> except-"-or-\-or-
> control-character
> \"
> \\
> \/ <---- see here?
> \b
> \f
> \n
> \r
> \t
> \u four-hex-digits
>
> ```
>
> |
127,753 | <p>Is there a more concise/standard idiom (e.g., a JDK method) for "piping" an input to an output in Java than the following?</p>
<pre><code>public void pipe(Reader in, Writer out) {
CharBuffer buf = CharBuffer.allocate(DEFAULT_BUFFER_SIZE);
while (in.read(buf) >= 0 ) {
out.append(buf.flip());
... | [
{
"answer_id": 127788,
"author": "Einar",
"author_id": 2964,
"author_profile": "https://Stackoverflow.com/users/2964",
"pm_score": 1,
"selected": false,
"text": "<p>Take a look at <a href=\"http://java.sun.com/javase/6/docs/api/java/io/PipedInputStream.html\" rel=\"nofollow noreferrer\">... | 2008/09/24 | [
"https://Stackoverflow.com/questions/127753",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1412/"
] | Is there a more concise/standard idiom (e.g., a JDK method) for "piping" an input to an output in Java than the following?
```
public void pipe(Reader in, Writer out) {
CharBuffer buf = CharBuffer.allocate(DEFAULT_BUFFER_SIZE);
while (in.read(buf) >= 0 ) {
out.append(buf.flip());
buf.clear();
... | [IOUtils](http://commons.apache.org/io/) from the Apache Commons project has a number of [utilily methods](http://commons.apache.org/io/api-1.4/org/apache/commons/io/IOUtils.html) that do exactly what you need.
`IOUtils.copy(in, out)` will perform a buffered copy of all input to the output. If there is more than one s... |
127,761 | <p>Have you managed to get Aptana Studio debugging to work? I tried following this, but I don't see <code>Windows -> Preferences -> Aptana -> Editors -> PHP -> PHP Interpreters</code> in my menu (I have <code>PHP plugin</code> installed) and any attempt to set up the servers menu gives me "socket error" ... | [
{
"answer_id": 128612,
"author": "Devon",
"author_id": 13850,
"author_profile": "https://Stackoverflow.com/users/13850",
"pm_score": 2,
"selected": false,
"text": "<p>This is not related to Aptana Studio, but if you are looking for a PHP XDebug debugger client on OS X, you can try <a hre... | 2008/09/24 | [
"https://Stackoverflow.com/questions/127761",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/556/"
] | Have you managed to get Aptana Studio debugging to work? I tried following this, but I don't see `Windows -> Preferences -> Aptana -> Editors -> PHP -> PHP Interpreters` in my menu (I have `PHP plugin` installed) and any attempt to set up the servers menu gives me "socket error" when I try to debug. `Xdebug` is install... | I've been using ZendDebugger with Eclipse (on OS X) for a while now and it works great!
Here's the recipe that's worked well for me.
1. install Eclipse PDT via "All in one" package at: <http://www.zend.com/en/community/pdt>
2. install ZendDebugger.so (<http://www.zend.com/en/community/pdt>)
3. configure your php.ini ... |
127,794 | <p>Part of the series of controls I am working on obviously involves me lumping some of them together in to composites. I am rapidly starting to learn that this takes consideration (this is all new to me!) :)</p>
<p>I basically have a <code>StyledWindow</code> control, which is essentially a glorified <code>Panel</code... | [
{
"answer_id": 127824,
"author": "Brad Wilson",
"author_id": 1554,
"author_profile": "https://Stackoverflow.com/users/1554",
"pm_score": 2,
"selected": false,
"text": "<p>I don't see you adding your controls to the Controls collection anywhere, which would explain why they can't access t... | 2008/09/24 | [
"https://Stackoverflow.com/questions/127794",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/832/"
] | Part of the series of controls I am working on obviously involves me lumping some of them together in to composites. I am rapidly starting to learn that this takes consideration (this is all new to me!) :)
I basically have a `StyledWindow` control, which is essentially a glorified `Panel` with ability to do other bits... | Solved!
=======
Right, I was determined to get this cracked today! Here were my thoughts:
* I thought the use of `Panel` was a bit of a hack, so I should remove it and find out how it is really done.
* I didn't want to have to do something like `MyCtl.Controls[0].Controls` to access the controls added to the composit... |
127,803 | <p>I need to parse <a href="https://www.rfc-editor.org/rfc/rfc3339" rel="noreferrer">RFC 3339</a> strings like <code>"2008-09-03T20:56:35.450686Z"</code> into Python's <code>datetime</code> type.</p>
<p>I have found <a href="https://docs.python.org/library/datetime.html#datetime.datetime.strptime" rel="norefe... | [
{
"answer_id": 127825,
"author": "tzot",
"author_id": 6899,
"author_profile": "https://Stackoverflow.com/users/6899",
"pm_score": 5,
"selected": false,
"text": "<p>What is the exact error you get? Is it like the following?</p>\n\n<pre><code>>>> datetime.datetime.strptime(\"2008-... | 2008/09/24 | [
"https://Stackoverflow.com/questions/127803",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/70293/"
] | I need to parse [RFC 3339](https://www.rfc-editor.org/rfc/rfc3339) strings like `"2008-09-03T20:56:35.450686Z"` into Python's `datetime` type.
I have found [`strptime`](https://docs.python.org/library/datetime.html#datetime.datetime.strptime) in the Python standard library, but it is not very convenient.
What is the ... | `isoparse` function from *python-dateutil*
==========================================
The [*python-dateutil*](https://pypi.python.org/pypi/python-dateutil) package has [`dateutil.parser.isoparse`](https://dateutil.readthedocs.io/en/stable/parser.html#dateutil.parser.isoparse) to parse not only RFC 3339 datetime string... |
127,817 | <p>I'm having a little problem and I don't see why, it's easy to go around it, but still I want to understand. </p>
<p>I have the following class :</p>
<pre><code>public class AccountStatement : IAccountStatement
{
public IList<IAccountStatementCharge> StatementCharges { get; set; }
public AccountStat... | [
{
"answer_id": 127840,
"author": "Brad Wilson",
"author_id": 1554,
"author_profile": "https://Stackoverflow.com/users/1554",
"pm_score": 5,
"selected": true,
"text": "<p>This code:</p>\n\n<pre><code>public AccountStatement()\n{\n new AccountStatement(new Period(new NullDate().DateTime... | 2008/09/24 | [
"https://Stackoverflow.com/questions/127817",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7419/"
] | I'm having a little problem and I don't see why, it's easy to go around it, but still I want to understand.
I have the following class :
```
public class AccountStatement : IAccountStatement
{
public IList<IAccountStatementCharge> StatementCharges { get; set; }
public AccountStatement()
{
new A... | This code:
```
public AccountStatement()
{
new AccountStatement(new Period(new NullDate().DateTime,newNullDate().DateTime), 0);
}
```
is undoubtedly not what you wanted. That makes a second instance of AccountStatement and does nothing with it.
I think what you meant was this instead:
```
public AccountStateme... |
127,867 | <p>I have great doubts about this forum, but I am willing to be pleasantly surprised ;) <strong>Kudos and great karma to those who get me back on track.</strong></p>
<p>I am attempting to use the blitz implementation of JavaSpaces (<a href="http://www.dancres.org/blitz/blitz_js.html" rel="nofollow noreferrer">http://w... | [
{
"answer_id": 128250,
"author": "jiriki",
"author_id": 19907,
"author_profile": "https://Stackoverflow.com/users/19907",
"pm_score": 0,
"selected": false,
"text": "<p>Well, your java spaces server does not seem to find the class:</p>\n\n<p>com.sun.jini.mahalo.TxnMgrProxy.</p>\n\n<p>So I... | 2008/09/24 | [
"https://Stackoverflow.com/questions/127867",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21707/"
] | I have great doubts about this forum, but I am willing to be pleasantly surprised ;) **Kudos and great karma to those who get me back on track.**
I am attempting to use the blitz implementation of JavaSpaces (<http://www.dancres.org/blitz/blitz_js.html>) to implement the ComputeFarm example provided at <http://today.j... | So com.sun.jini.mahalo.TxnMgrProxy is contained in some jar, that is contained in your CLASSPATH environment variable.
But probably your are using some script to start the server. And this most probably starts java by specifying a "-classpath" commandline switch which takes precendence over your environment CLASSPATH ... |
127,886 | <p>I'm confused with how views are organized, and it is important to understand this as ASP.NET MVC uses conventions to get everything working right.</p>
<p>Under the views directory, there are subdirectories. Inside these subdirectories are views. I'm assuming that the subdirectories map to controllers, and the con... | [
{
"answer_id": 128045,
"author": "Craig Stuntz",
"author_id": 7714,
"author_profile": "https://Stackoverflow.com/users/7714",
"pm_score": 4,
"selected": true,
"text": "<p>View directory naming and file naming are important, because the ASP.NET MVC framework makes certain assumptions abou... | 2008/09/24 | [
"https://Stackoverflow.com/questions/127886",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm confused with how views are organized, and it is important to understand this as ASP.NET MVC uses conventions to get everything working right.
Under the views directory, there are subdirectories. Inside these subdirectories are views. I'm assuming that the subdirectories map to controllers, and the controllers act... | View directory naming and file naming are important, because the ASP.NET MVC framework makes certain assumptions about them. If you do not conform to these assumptions, then you must write code to let the framework know what you are doing. Generally speaking, you should conform to these assumptions unless you have a go... |
127,899 | <p>i have a control that is organized like this</p>
<p><img src="https://dl-web.getdropbox.com/get/jsstructure.GIF?w=faef1ed3" alt="alt text"></p>
<p>and i want to have the javascript registered on the calling master pages, etc, so that anywhere this control folder is dropped and then registered, it will know how to ... | [
{
"answer_id": 127935,
"author": "TcKs",
"author_id": 20382,
"author_profile": "https://Stackoverflow.com/users/20382",
"pm_score": 1,
"selected": false,
"text": "<p>You can use a helper class with static method:</p>\n\n<pre><code>public static class PageHelper {\n public static void ... | 2008/09/24 | [
"https://Stackoverflow.com/questions/127899",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1748529/"
] | i have a control that is organized like this

and i want to have the javascript registered on the calling master pages, etc, so that anywhere this control folder is dropped and then registered, it will know how to find the URL to the js.
Here i... | You can use a helper class with static method:
```
public static class PageHelper {
public static void RegisterClientScriptIfNeeded( Page page, string key, string url ) {
if( false == page.IsClientScriptBlockRegistered( key )) {
page.ClientScript.RegisterClientScriptInclude( key , ResolveClient... |
127,973 | <p>I've been aware of Steve Yegge's advice to <a href="http://steve.yegge.googlepages.com/effective-emacs#item1" rel="nofollow noreferrer">swap Ctrl and Caps Lock</a> for a while now, although I don't use Emacs. I've just tried swapping them over as an experiment and I'm finding it difficult to adjust. There are severa... | [
{
"answer_id": 127984,
"author": "Harper Shelby",
"author_id": 21196,
"author_profile": "https://Stackoverflow.com/users/21196",
"pm_score": 2,
"selected": false,
"text": "<p>I've done it for quite a while now, and it's natural to me, even though I'm not an Emacs user either (I'm in the ... | 2008/09/24 | [
"https://Stackoverflow.com/questions/127973",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2541/"
] | I've been aware of Steve Yegge's advice to [swap Ctrl and Caps Lock](http://steve.yegge.googlepages.com/effective-emacs#item1) for a while now, although I don't use Emacs. I've just tried swapping them over as an experiment and I'm finding it difficult to adjust. There are several shortcuts that are second nature to me... | I ended up taking the advice in Zach's answer, but I also made `Caps Lock` behave as an `ESC` key if it was held and released on it's own using the AutoHotKey script in this gist: [CapsLockCtrlEscape.ahk](https://gist.github.com/sedm0784/4443120)
I also bound `Ctrl`+`Shift`+`Caps Lock` to `Caps Lock` for the rare occa... |
127,974 | <p>SQL is not my forte, but I'm working on it - thank you for the replies.</p>
<p>I am working on a report that will return the completion percent of services for indiviudals in our contracts. There is a master table "Contracts," each individual Contract can have multiple services from the "services" table, each serv... | [
{
"answer_id": 128017,
"author": "Steven Murawski",
"author_id": 1233,
"author_profile": "https://Stackoverflow.com/users/1233",
"pm_score": 1,
"selected": false,
"text": "<p>You should be able to add in your select the company name and group by that and the service id and ditch the wher... | 2008/09/24 | [
"https://Stackoverflow.com/questions/127974",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21717/"
] | SQL is not my forte, but I'm working on it - thank you for the replies.
I am working on a report that will return the completion percent of services for indiviudals in our contracts. There is a master table "Contracts," each individual Contract can have multiple services from the "services" table, each service has mul... | I'm not sure if I understand the problem, if the result is ok for a service\_contract you canContract Service
```
SELECT con.ContractId,
con.Contract,
conSer.Contract_ServiceID,
conSer.Service,
(SUM(CompletionPercentage)/COUNT(CompletionPercentage)) * 100 as "Percent Complete"
F... |
128,011 | <p>In a <code>CakePHP 1.2</code> app, I'm using </p>
<pre><code><?php $session->flash();?>
</code></pre>
<p>to output messages like "Record edited". It's working great.</p>
<p>However, I want to add a link called "Dismiss" that will fade out the message. I know how to construct the link, but I don't know ho... | [
{
"answer_id": 128033,
"author": "Justin",
"author_id": 43,
"author_profile": "https://Stackoverflow.com/users/43",
"pm_score": 2,
"selected": true,
"text": "<p>Figured this out:\nCreate a new layout in your layouts folder:</p>\n\n<pre><code>layouts/message.ctp\n</code></pre>\n\n<p>In th... | 2008/09/24 | [
"https://Stackoverflow.com/questions/128011",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43/"
] | In a `CakePHP 1.2` app, I'm using
```
<?php $session->flash();?>
```
to output messages like "Record edited". It's working great.
However, I want to add a link called "Dismiss" that will fade out the message. I know how to construct the link, but I don't know how to insert into the output of the flass message.
Th... | Figured this out:
Create a new layout in your layouts folder:
```
layouts/message.ctp
```
In that layout, include the call to output the content:
```
<?php echo $content_for_layout; ?>
```
Then when you set the flash message, specify the layout to use:
```
$this->Session->setFlash('Your record has been created! ... |
128,012 | <p>I want to create a UITableView with varying row heights, and I'm trying to accomplish this by creating UILabels inside the UITableViewCells.</p>
<p>Here's my code so far:</p>
<pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *MyI... | [
{
"answer_id": 128329,
"author": "Airsource Ltd",
"author_id": 18017,
"author_profile": "https://Stackoverflow.com/users/18017",
"pm_score": 5,
"selected": true,
"text": "<p>The UITableViewDelegate defines an optional method heightForRowAtIndexPath, which will get you started. You then n... | 2008/09/24 | [
"https://Stackoverflow.com/questions/128012",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2119/"
] | I want to create a UITableView with varying row heights, and I'm trying to accomplish this by creating UILabels inside the UITableViewCells.
Here's my code so far:
```
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *MyIdentifier = @"EntryCe... | The UITableViewDelegate defines an optional method heightForRowAtIndexPath, which will get you started. You then need to use sizeWithFont.
There is some discussion of your precise problem here:
<http://www.v2ex.com/2008/09/18/how-to-make-uitableviewcell-have-variable-height/>
Text sizing was also discussed in [this ... |
128,016 | <p>I'm writing a custom file selection component. In my UI, first the user clicks a button, which pops a <code>JFileChooser</code>; when it is closed, the absolute path of the selected file is written to a <code>JTextField</code>.</p>
<p>The problem is, absolute paths are usually long, which causes the text field to e... | [
{
"answer_id": 128040,
"author": "davetron5000",
"author_id": 3029,
"author_profile": "https://Stackoverflow.com/users/3029",
"pm_score": 5,
"selected": true,
"text": "<p>It may depend on the layout manager your text field is in. Some layout managers expand and some do not. Some expand... | 2008/09/24 | [
"https://Stackoverflow.com/questions/128016",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15649/"
] | I'm writing a custom file selection component. In my UI, first the user clicks a button, which pops a `JFileChooser`; when it is closed, the absolute path of the selected file is written to a `JTextField`.
The problem is, absolute paths are usually long, which causes the text field to enlarge, making its container too... | It may depend on the layout manager your text field is in. Some layout managers expand and some do not. Some expand only in some cases, others always.
I'm assuming you're doing
```
filedNameTextField = new JTextField(80); // 80 == columns
```
If so, for most reasonable layouts, the field should not change size (at... |
128,028 | <p>We have a project that generates a code snippet that can be used on various other projects. The purpose of the code is to read two parameters from the query string and assign them to the "src" attribute of an iframe.</p>
<p>For example, the page at the URL <a href="http://oursite/Page.aspx?a=1&b=2" rel="nofollo... | [
{
"answer_id": 128044,
"author": "Tigraine",
"author_id": 21699,
"author_profile": "https://Stackoverflow.com/users/21699",
"pm_score": 2,
"selected": false,
"text": "<p>Using a whitelist-approach would be better I guess.\nAvoid only stripping out \"bad\" things. Strip out anything excep... | 2008/09/24 | [
"https://Stackoverflow.com/questions/128028",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21732/"
] | We have a project that generates a code snippet that can be used on various other projects. The purpose of the code is to read two parameters from the query string and assign them to the "src" attribute of an iframe.
For example, the page at the URL <http://oursite/Page.aspx?a=1&b=2> would have JavaScript in it to rea... | Upadte Sep 2022: Most JS runtimes now have a *URL* type which exposes query parameters via the [*searchParams*](https://developer.mozilla.org/en-US/docs/Web/API/URL/searchParams) property.
You need to supply a base URL even if you just want to get URL parameters from a relative URL, but it's better than rolling your ow... |
128,035 | <p>Note: while the use-case described is about using submodules within a project, the same applies to a normal <code>git clone</code> of a repository over HTTP.</p>
<p>I have a project under Git control. I'd like to add a submodule:</p>
<pre><code>git submodule add http://github.com/jscruggs/metric_fu.git vendor/plu... | [
{
"answer_id": 128198,
"author": "sethbc",
"author_id": 21722,
"author_profile": "https://Stackoverflow.com/users/21722",
"pm_score": 6,
"selected": false,
"text": "<p>It looks like you're using a mingw compile of Git on windows (or possibly another one I haven't heard about). There are... | 2008/09/24 | [
"https://Stackoverflow.com/questions/128035",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1190/"
] | Note: while the use-case described is about using submodules within a project, the same applies to a normal `git clone` of a repository over HTTP.
I have a project under Git control. I'd like to add a submodule:
```
git submodule add http://github.com/jscruggs/metric_fu.git vendor/plugins/metric_fu
```
But I get
`... | What finally worked was setting the `http_proxy` environment variable. I had set `HTTP_PROXY` correctly, but git apparently likes the lower-case version better. |
128,038 | <p>I have a Java process that opens a file using a FileReader. How can I prevent another (Java) process from opening this file, or at least notify that second process that the file is already opened? Does this automatically make the second process get an exception if the file is open (which solves my problem) or do I h... | [
{
"answer_id": 128119,
"author": "KC Baltz",
"author_id": 9910,
"author_profile": "https://Stackoverflow.com/users/9910",
"pm_score": 4,
"selected": false,
"text": "<p>If you can use <strong>Java NIO</strong> (<em>JDK 1.4 or greater</em>), then I think you're looking for <code>java.nio.c... | 2008/09/24 | [
"https://Stackoverflow.com/questions/128038",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11906/"
] | I have a Java process that opens a file using a FileReader. How can I prevent another (Java) process from opening this file, or at least notify that second process that the file is already opened? Does this automatically make the second process get an exception if the file is open (which solves my problem) or do I have... | FileChannel.lock is probably what you want.
```
try (
FileInputStream in = new FileInputStream(file);
java.nio.channels.FileLock lock = in.getChannel().lock();
Reader reader = new InputStreamReader(in, charset)
) {
...
}
```
(Disclaimer: Code not compiled and certainly not tested.)
Note the section ... |
128,042 | <p>In Java, I use a class in which some fields can be <code>null</code>. For example:</p>
<pre><code>class Foo {
String bar;
//....
}
</code></pre>
<p>I want to write a BarComparator for this class,</p>
<pre><code> private static class BarComparator
implements Comparator<Foo> {
p... | [
{
"answer_id": 128084,
"author": "cagcowboy",
"author_id": 19629,
"author_profile": "https://Stackoverflow.com/users/19629",
"pm_score": 0,
"selected": false,
"text": "<p>I think early return statements would be the other alternative to lots of ifs</p>\n\n<p>e.g.</p>\n\n<pre><code>if(o1=... | 2008/09/24 | [
"https://Stackoverflow.com/questions/128042",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2797/"
] | In Java, I use a class in which some fields can be `null`. For example:
```
class Foo {
String bar;
//....
}
```
I want to write a BarComparator for this class,
```
private static class BarComparator
implements Comparator<Foo> {
public int compare( final Foo o1, final Foo o2 )
... | I guess you could wrap the call to the field compareTo method with a small static method to sort nulls high or low:
```
static <T extends Comparable<T>> int cp(T a, T b) {
return
a==null ?
(b==null ? 0 : Integer.MIN_VALUE) :
(b==null ? Integer.MAX_VALUE : a.compareTo(b));
}
```
Simple... |
128,083 | <p>I find my self having a repeater control which is being databound to an xml document. My client is now requesting that the Textbox's which are being repeater can be either a Textbox or a Checkbox.</p>
<p>I cannot seem to find an easyway to essentially do the following:</p>
<pre><code>if ((System.Xml.XmlNode)e.Item... | [
{
"answer_id": 128101,
"author": "Tom Ritter",
"author_id": 8435,
"author_profile": "https://Stackoverflow.com/users/8435",
"pm_score": 3,
"selected": true,
"text": "<p>What about something similar to this in your markup in each the textbox and checkbox controls?</p>\n\n<blockquote>\n<pr... | 2008/09/24 | [
"https://Stackoverflow.com/questions/128083",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20032/"
] | I find my self having a repeater control which is being databound to an xml document. My client is now requesting that the Textbox's which are being repeater can be either a Textbox or a Checkbox.
I cannot seem to find an easyway to essentially do the following:
```
if ((System.Xml.XmlNode)e.Item.DataItem.Attributes[... | What about something similar to this in your markup in each the textbox and checkbox controls?
>
>
> ```
> Visible=<%= Eval("type").tostring() == "text") %>
>
> ```
>
> |
128,103 | <p>Given an <code>Item</code> that has been appended to a <code>Form</code>, whats the best way to find out what index that item is at on the Form?</p>
<p><code>Form.append(Item)</code> will give me the index its initially added at, but if I later insert items before that the index will be out of sync.</p>
| [
{
"answer_id": 128355,
"author": "roryf",
"author_id": 270,
"author_profile": "https://Stackoverflow.com/users/270",
"pm_score": 2,
"selected": true,
"text": "<p>This was the best I could come up with:</p>\n\n<pre><code>private int getItemIndex(Item item, Form form) {\n for(int i = 0,... | 2008/09/24 | [
"https://Stackoverflow.com/questions/128103",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/270/"
] | Given an `Item` that has been appended to a `Form`, whats the best way to find out what index that item is at on the Form?
`Form.append(Item)` will give me the index its initially added at, but if I later insert items before that the index will be out of sync. | This was the best I could come up with:
```
private int getItemIndex(Item item, Form form) {
for(int i = 0, size = form.size(); i < size; i++) {
if(form.get(i).equals(item)) {
return i;
}
}
return -1;
}
```
I haven't actually tested this but it should work, I just don't like h... |
128,104 | <p>What is a good implementation of a IsLeapYear function in VBA? </p>
<p><b>Edit: </b>I ran the if-then and the DateSerial implementation with iterations wrapped in a timer, and the DateSerial was quicker on the average by 1-2 ms (5 runs of 300 iterations, with 1 average cell worksheet formula also working).</p>
| [
{
"answer_id": 128105,
"author": "Lance Roberts",
"author_id": 13295,
"author_profile": "https://Stackoverflow.com/users/13295",
"pm_score": 6,
"selected": true,
"text": "<pre><code>Public Function isLeapYear(Yr As Integer) As Boolean \n\n ' returns FALSE if not Leap Year, TRUE if Le... | 2008/09/24 | [
"https://Stackoverflow.com/questions/128104",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13295/"
] | What is a good implementation of a IsLeapYear function in VBA?
**Edit:** I ran the if-then and the DateSerial implementation with iterations wrapped in a timer, and the DateSerial was quicker on the average by 1-2 ms (5 runs of 300 iterations, with 1 average cell worksheet formula also working). | ```
Public Function isLeapYear(Yr As Integer) As Boolean
' returns FALSE if not Leap Year, TRUE if Leap Year
isLeapYear = (Month(DateSerial(Yr, 2, 29)) = 2)
End Function
```
I originally got this function from Chip Pearson's great Excel site.
[Pearson's site](http://www.cpearson.com/excel/MainPage... |
128,162 | <p>My program generates relatively simple PDF documents on request, but I'm having trouble with unicode characters, like kanji or odd math symbols. To write a normal string in PDF, you place it in brackets:</p>
<pre><code>(something)
</code></pre>
<p>There is also the option to escape a character with octal codes:</p... | [
{
"answer_id": 128351,
"author": "Filini",
"author_id": 21162,
"author_profile": "https://Stackoverflow.com/users/21162",
"pm_score": -1,
"selected": false,
"text": "<p>I'm not a PDF expert, and (as Ferruccio said) the PDF specs at Adobe should tell you everything, but a thought popped u... | 2008/09/24 | [
"https://Stackoverflow.com/questions/128162",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1000/"
] | My program generates relatively simple PDF documents on request, but I'm having trouble with unicode characters, like kanji or odd math symbols. To write a normal string in PDF, you place it in brackets:
```
(something)
```
There is also the option to escape a character with octal codes:
```
(\527)
```
but this o... | The simple answer is that there's no simple answer. If you take a look at the PDF specification, you'll see an entire chapter — and a long one at that — devoted to the mechanisms of text display. I implemented all of the PDF support for my company, and handling text was by far the most complex part of exercise. The sol... |
128,190 | <p>I need help logging errors from T-SQL in SQL Server 2000. We need to log errors that we trap, but are having trouble getting the same information we would have had sitting in front of SQL Server Management Studio.</p>
<p>I can get a message without any argument substitution like this:</p>
<pre><code>SELECT MSG.de... | [
{
"answer_id": 128202,
"author": "Kevin Fairchild",
"author_id": 3743,
"author_profile": "https://Stackoverflow.com/users/3743",
"pm_score": 0,
"selected": false,
"text": "<p>Any chance you'll be upgrading to SQL2005 soon? If so, you could probably leverage their TRY/CATCH model to more ... | 2008/09/24 | [
"https://Stackoverflow.com/questions/128190",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/945/"
] | I need help logging errors from T-SQL in SQL Server 2000. We need to log errors that we trap, but are having trouble getting the same information we would have had sitting in front of SQL Server Management Studio.
I can get a message without any argument substitution like this:
```
SELECT MSG.description from master.... | In .Net, retrieving error messages (and anything output from *print* or *raiserror*) from sql server is as simple as setting one property on your SqlConnection ( *.FireInfoMessageEventOnUserErrors = True*) and handling the connection's InfoMessage event. The data received by .Net matches what you get in the *Messages* ... |
128,232 | <p>I am trying to do the following in <code>SQL*PLUS</code> in <code>ORACLE</code>.</p>
<ul>
<li>Create a variable</li>
<li>Pass it as output variable to my method invocation</li>
<li>Print the value from output variable</li>
</ul>
<p>I get</p>
<blockquote>
<p><em>undeclared variable</em></p>
</blockquote>
<p>err... | [
{
"answer_id": 128275,
"author": "cagcowboy",
"author_id": 19629,
"author_profile": "https://Stackoverflow.com/users/19629",
"pm_score": 0,
"selected": false,
"text": "<p>Please can you re-post, but formatting the code with the code tag.... (ie the 101 010 button) I think some extra \"-... | 2008/09/24 | [
"https://Stackoverflow.com/questions/128232",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15425/"
] | I am trying to do the following in `SQL*PLUS` in `ORACLE`.
* Create a variable
* Pass it as output variable to my method invocation
* Print the value from output variable
I get
>
> *undeclared variable*
>
>
>
error. I am trying to create a variable that persists in the session till i close the `SQL*PLUS` window... | It should be OK - check what you did carefully against this:
```
SQL> create procedure myproc (p1 out number)
2 is
3 begin
4 p1 := 42;
5 end;
6 /
Procedure created.
SQL> variable subhandle number
SQL> exec myproc(:subhandle)
PL/SQL procedure successfully completed.
SQL> print subhandle
SUBHANDL... |
128,241 | <p>Here's a question that's been haunting me for a year now. The root question is how do I set the size of an element relative to its parent so that it is inset by N pixels from every edge? Setting the width would be nice, but you don't know the width of the parent, and you want the elements to resize with the window. ... | [
{
"answer_id": 128253,
"author": "Dan",
"author_id": 17121,
"author_profile": "https://Stackoverflow.com/users/17121",
"pm_score": 0,
"selected": false,
"text": "<p>Simply apply some padding to the parent element, and no width on the child element. Assuming they're both <code>display:blo... | 2008/09/24 | [
"https://Stackoverflow.com/questions/128241",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5114/"
] | Here's a question that's been haunting me for a year now. The root question is how do I set the size of an element relative to its parent so that it is inset by N pixels from every edge? Setting the width would be nice, but you don't know the width of the parent, and you want the elements to resize with the window. (Yo... | The [The CSS Box model](http://www.hicksdesign.co.uk/journal/3d-css-box-model) might provide insight for you, but my guess is that you're not going to achieve pixel-perfect layout with CSS alone.
If I understand correctly, you want the parent to be 25% wide and exactly the height of the browser display area. Then you ... |
128,259 | <p>I have a list of data in the following form:</p>
<p><code>[(id\__1_, description, id\_type), (id\__2_, description, id\_type), ... , (id\__n_, description, id\_type))</code></p>
<p>The data are loaded from files that belong to the same group. In each group there could be multiples of the same id, each coming from ... | [
{
"answer_id": 128361,
"author": "S.Lott",
"author_id": 10661,
"author_profile": "https://Stackoverflow.com/users/10661",
"pm_score": 2,
"selected": false,
"text": "<p>Sets don't have keys. The element <strong>is</strong> the key.</p>\n\n<p>If you think you want keys, you have a mapping... | 2008/09/24 | [
"https://Stackoverflow.com/questions/128259",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14107/"
] | I have a list of data in the following form:
`[(id\__1_, description, id\_type), (id\__2_, description, id\_type), ... , (id\__n_, description, id\_type))`
The data are loaded from files that belong to the same group. In each group there could be multiples of the same id, each coming from different files. I don't car... | Sets don't have keys. The element **is** the key.
If you think you want keys, you have a mapping. More-or-less by definition.
Sequential list lookup can be slow, even using a binary search. Mappings use hashes and are fast.
Are you talking about a dictionary like this?
```
{ 'id1': [ ('description1a', 'type1'), ('d... |
128,267 | <p>I'm trying to define a task that emits (using echo) a message when a target completes execution, regardless of whether that target was successful or not. Specifically, the target executes a task to run some unit tests, and I want to emit a message indicating where the results are available:</p>
<pre><code><tar... | [
{
"answer_id": 128323,
"author": "Jay",
"author_id": 20840,
"author_profile": "https://Stackoverflow.com/users/20840",
"pm_score": 3,
"selected": false,
"text": "<p>According to the <a href=\"http://ant.apache.org/manual/Tasks/exec.html\" rel=\"nofollow noreferrer\">Ant docs</a>, there a... | 2008/09/24 | [
"https://Stackoverflow.com/questions/128267",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16977/"
] | I'm trying to define a task that emits (using echo) a message when a target completes execution, regardless of whether that target was successful or not. Specifically, the target executes a task to run some unit tests, and I want to emit a message indicating where the results are available:
```
<target name="mytarget"... | The solution to your problem is to use the `failureProperty` in conjunction with the `haltOnFailure` property of the testng task like this:
```
<target name="mytarget">
<testng outputDir="${results}" failureProperty="tests.failed" haltOnFailure="false" ...>
...
</testng>
<echo>Tests complete. Results availa... |
128,277 | <p><strong>UPDATE</strong></p>
<p>I'm basically binding the query to a WinForms <code>DataGridView</code>. I want the column headers to be appropriate and have spaces when needed. For example, I would want a column header to be <code>First Name</code> instead of <code>FirstName</code>.</p>
<hr>
<p>How do you create ... | [
{
"answer_id": 128286,
"author": "James Hall",
"author_id": 514,
"author_profile": "https://Stackoverflow.com/users/514",
"pm_score": 2,
"selected": false,
"text": "<p>I dont see why you would have to do that, if you are trying to do that for a grid or something, why not just name the he... | 2008/09/24 | [
"https://Stackoverflow.com/questions/128277",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/299/"
] | **UPDATE**
I'm basically binding the query to a WinForms `DataGridView`. I want the column headers to be appropriate and have spaces when needed. For example, I would want a column header to be `First Name` instead of `FirstName`.
---
How do you create your own custom column names in LINQ?
For example:
```
Dim qu... | I solved my own problem but all of your answers were very helpful and pointed me in the right direction.
In my `LINQ` query, if a column name had more than one word I would separate the words with an underscore:
```
Dim query = From u In Users _
Select First_Name = u.FirstName
```
Then, within the `Pain... |
128,279 | <p>I have a <a href="http://en.wikipedia.org/wiki/WiX" rel="nofollow noreferrer">WiX</a> installer and a single custom action (plus undo and rollback) for it which uses a property from the installer. The custom action has to happen after all the files are on the hard disk. It seems that you need 16 entries in the WXS f... | [
{
"answer_id": 144688,
"author": "Paul Lalonde",
"author_id": 5782,
"author_profile": "https://Stackoverflow.com/users/5782",
"pm_score": 2,
"selected": false,
"text": "<p>If you have complex custom actions that need to support rollback, you might consider writing a Wix extension. Exten... | 2008/09/24 | [
"https://Stackoverflow.com/questions/128279",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20686/"
] | I have a [WiX](http://en.wikipedia.org/wiki/WiX) installer and a single custom action (plus undo and rollback) for it which uses a property from the installer. The custom action has to happen after all the files are on the hard disk. It seems that you need 16 entries in the WXS file for this; eight within the root, lik... | I came across the same problem when writing WiX installers. My approach to the problem is mostly like what Mike suggested and I have a blog post *[Implementing WiX custom actions part 2: using custom tables](http://technicaltrack.wordpress.com/2011/06/15/implmenting-wix-custom-actions-part-2-using-custom-tables/)*.
In... |
128,282 | <p>I am currently using the following code to create a web request:</p>
<pre><code>Dim myRequest As WebRequest = WebRequest.Create("http://foo.com/bar")
Dim myResponse As WebResponse = myRequest.GetResponse()
</code></pre>
<p>The problem is that this "locks" up the program until the request is completed (and program ... | [
{
"answer_id": 128289,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 0,
"selected": false,
"text": "<p>myRequest.BeginGetResponse()</p>\n\n<p>You'll also need to call EndGetReponse() when the request is finished (deter... | 2008/09/24 | [
"https://Stackoverflow.com/questions/128282",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9129/"
] | I am currently using the following code to create a web request:
```
Dim myRequest As WebRequest = WebRequest.Create("http://foo.com/bar")
Dim myResponse As WebResponse = myRequest.GetResponse()
```
The problem is that this "locks" up the program until the request is completed (and program will hang if the request n... | You'll use BeginGetResponse to add a AsyncCallback, which basically points to some other method in your code that will be called when the WebRequest returns. There is a good [sample here](http://www.sitepoint.com/forums/showpost.php?p=3753215).
<http://www.sitepoint.com/forums/showpost.php?p=3753215> |