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 |
|---|---|---|---|---|---|---|
114,211 | <p>Let's say I have a container (std::vector) of pointers used by a multi-threaded application. When adding new pointers to the container, the code is protected using a critical section (boost::mutex). All well and good. The code should be able to return one of these pointers to a thread for processing, but another ... | [
{
"answer_id": 114221,
"author": "Leon Timmermans",
"author_id": 4727,
"author_profile": "https://Stackoverflow.com/users/4727",
"pm_score": 3,
"selected": true,
"text": "<p>For the threading safety of boost::shared_ptr you should check <a href=\"http://www.boost.org/doc/libs/1_36_0/libs... | 2008/09/22 | [
"https://Stackoverflow.com/questions/114211",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9236/"
] | Let's say I have a container (std::vector) of pointers used by a multi-threaded application. When adding new pointers to the container, the code is protected using a critical section (boost::mutex). All well and good. The code should be able to return one of these pointers to a thread for processing, but another separa... | For the threading safety of boost::shared\_ptr you should check [this link](http://www.boost.org/doc/libs/1_36_0/libs/smart_ptr/shared_ptr.htm#ThreadSafety). It's not guarantied to be safe, but on many platforms it works. Modifying the std::vector is not safe AFAIK. |
114,214 | <p>What is the difference between the following class methods?</p>
<p>Is it that one is static and the other is not?</p>
<pre><code>class Test(object):
def method_one(self):
print "Called method_one"
def method_two():
print "Called method_two"
a_test = Test()
a_test.method_one()
a_test.method_two()
</co... | [
{
"answer_id": 114232,
"author": "Justin Poliey",
"author_id": 6967,
"author_profile": "https://Stackoverflow.com/users/6967",
"pm_score": 4,
"selected": false,
"text": "<p>When you call a class member, Python automatically uses a reference to the object as the first parameter. The varia... | 2008/09/22 | [
"https://Stackoverflow.com/questions/114214",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16070/"
] | What is the difference between the following class methods?
Is it that one is static and the other is not?
```
class Test(object):
def method_one(self):
print "Called method_one"
def method_two():
print "Called method_two"
a_test = Test()
a_test.method_one()
a_test.method_two()
``` | In Python, there is a distinction between *bound* and *unbound* methods.
Basically, a call to a member function (like `method_one`), a bound function
```
a_test.method_one()
```
is translated to
```
Test.method_one(a_test)
```
i.e. a call to an unbound method. Because of that, a call to your version of `method_... |
114,222 | <p>With the introduction of .NET 3.5 and the <code>IQueryable<T></code> interface, new patterns will emerge. While I have seen a number of implementations of the Specification pattern, I have not seen many other patterns using this technology. Rob Conery's Storefront application is another concrete example using ... | [
{
"answer_id": 114609,
"author": "Fredrik Kalseth",
"author_id": 1710,
"author_profile": "https://Stackoverflow.com/users/1710",
"pm_score": 3,
"selected": false,
"text": "<p>It has certainly made the repository pattern much simpler to implement as well. You can essentially create a gene... | 2008/09/22 | [
"https://Stackoverflow.com/questions/114222",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/708/"
] | With the introduction of .NET 3.5 and the `IQueryable<T>` interface, new patterns will emerge. While I have seen a number of implementations of the Specification pattern, I have not seen many other patterns using this technology. Rob Conery's Storefront application is another concrete example using `IQueryable<T>` whic... | It has certainly made the repository pattern much simpler to implement as well. You can essentially create a generic repository:
```
public class LinqToSqlRepository : IRepository
{
private readonly DataContext _context;
public LinqToSqlRepository(DataContext context)
{
_context = context;
}
pu... |
114,242 | <p>Previously I have asked to strip text from a field and convert it to an int, this works successfully. But now, I would like to do an INNER JOIN on this new value.</p>
<p>So I have this:</p>
<pre><code>SELECT CONVERT(int, SUBSTRING(accountingTab.id, PATINDEX('%[0-9]%', accountingTab.id), 999))
AS 'memId', userDet... | [
{
"answer_id": 114253,
"author": "Milan Babuškov",
"author_id": 14690,
"author_profile": "https://Stackoverflow.com/users/14690",
"pm_score": 2,
"selected": false,
"text": "<p>Instead of memId, repeat the whole expression.</p>\n"
},
{
"answer_id": 114265,
"author": "Remi Desp... | 2008/09/22 | [
"https://Stackoverflow.com/questions/114242",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1841427/"
] | Previously I have asked to strip text from a field and convert it to an int, this works successfully. But now, I would like to do an INNER JOIN on this new value.
So I have this:
```
SELECT CONVERT(int, SUBSTRING(accountingTab.id, PATINDEX('%[0-9]%', accountingTab.id), 999))
AS 'memId', userDetails.title, userDetai... | If you have to do this, you have design problems. If you're able, I would suggest you need to refactor your table or relationships. |
114,266 | <p>I am getting the following error whenever I click on a postbacking control</p>
<pre><code>HttpException (0x80004005): Validation
of viewstate MAC failed. If this
application is hosted by a Web Farm
or cluster, ensure that configuration
specifies the same validationKey and
validation algorithm. AutoGenerate
cann... | [
{
"answer_id": 114292,
"author": "user20259",
"author_id": 20259,
"author_profile": "https://Stackoverflow.com/users/20259",
"pm_score": 3,
"selected": true,
"text": "<p>There is an article about this here: <a href=\"http://blogs.msdn.com/tom/archive/2008/03/14/validation-of-viewstate-ma... | 2008/09/22 | [
"https://Stackoverflow.com/questions/114266",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4021/"
] | I am getting the following error whenever I click on a postbacking control
```
HttpException (0x80004005): Validation
of viewstate MAC failed. If this
application is hosted by a Web Farm
or cluster, ensure that configuration
specifies the same validationKey and
validation algorithm. AutoGenerate
cannot be used in ... | There is an article about this here: <http://blogs.msdn.com/tom/archive/2008/03/14/validation-of-viewstate-mac-failed-error.aspx> .
The basic problem is that Your page hasn't completed loading before You perform the postback.
A few different solutions are in the article listed above:
1. Set enableEventValidation to ... |
114,284 | <p>First of all, this question regards MySQL 3.23.58, so be advised.</p>
<p>I have 2 tables with the following definition:</p>
<pre><code>Table A: id INT (primary), customer_id INT, offlineid INT
Table B: id INT (primary), name VARCHAR(255)
</code></pre>
<p>Now, table A contains in the range of 65k+ records, while ... | [
{
"answer_id": 114345,
"author": "Neall",
"author_id": 619,
"author_profile": "https://Stackoverflow.com/users/619",
"pm_score": 1,
"selected": false,
"text": "<p>I'm going to guess that your main problem is that you are using such an old version of MySQL. Maybe MySQL 3 doesn't like the ... | 2008/09/22 | [
"https://Stackoverflow.com/questions/114284",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9479/"
] | First of all, this question regards MySQL 3.23.58, so be advised.
I have 2 tables with the following definition:
```
Table A: id INT (primary), customer_id INT, offlineid INT
Table B: id INT (primary), name VARCHAR(255)
```
Now, table A contains in the range of 65k+ records, while table B contains ~40 records. In ... | You could try making sure there are covering indexes defined on each table. A covering index is just an index where each column requested in the select or used in a join is included in the index. This way, the engine only has to read the index entry and doesn't have to also do the corresponding row lookup to get any re... |
114,302 | <p>I'm looking for a list of win32 API in some "database"/XML format. </p>
<p>I'd need it to easily create a "conversion layer" between win32 API and the higher level language I'm using (harbour/xharbour). Since this runs Pcode, it is necessary to transform parameters to C standard...</p>
<p>Instead of doing manual ... | [
{
"answer_id": 114307,
"author": "GEOCHET",
"author_id": 5640,
"author_profile": "https://Stackoverflow.com/users/5640",
"pm_score": 0,
"selected": false,
"text": "<p>About the closest thing I know of would be: <a href=\"http://pinvoke.net/\" rel=\"nofollow noreferrer\">http://pinvoke.ne... | 2008/09/22 | [
"https://Stackoverflow.com/questions/114302",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm looking for a list of win32 API in some "database"/XML format.
I'd need it to easily create a "conversion layer" between win32 API and the higher level language I'm using (harbour/xharbour). Since this runs Pcode, it is necessary to transform parameters to C standard...
Instead of doing manual code write, I'd li... | AFAIK, pinvoke.net only stores text data with the PInvoke definition for the call. Not very useful if what you want is something to use as a pre-parsed database of APIs.
Probably you could create an small parser that will take the include file and translate it to what you need. In that case, I'd recommend using [lcc-w... |
114,339 | <p>If I want to manipulate an HTML tag's properties on the server within an aspx page based on a master page i.e. </p>
<pre><code><a href="#" runat="server" ID="myLink">My Link</a>
</code></pre>
<p>For example to give the link a different class depending on the current page i.e.</p>
<pre><code>if (Path.G... | [
{
"answer_id": 114357,
"author": "Giovanni Galbo",
"author_id": 4050,
"author_profile": "https://Stackoverflow.com/users/4050",
"pm_score": 0,
"selected": false,
"text": "<p>I don't think so. </p>\n\n<p>However, you probably want to keep the original name so that you can manipulate the ... | 2008/09/22 | [
"https://Stackoverflow.com/questions/114339",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12918/"
] | If I want to manipulate an HTML tag's properties on the server within an aspx page based on a master page i.e.
```
<a href="#" runat="server" ID="myLink">My Link</a>
```
For example to give the link a different class depending on the current page i.e.
```
if (Path.GetFileName(Request.PhysicalPath) == "MyPage")
{
m... | AFAIK there is no way.
It shows the actual control tree, which is in this case masterpage-content-control.
However if you add an ID to the masterpage (this.ID = "whatever") then you will see "whatever" instead of ctl00 (which means control index 0). |
114,419 | <p>The following two C# code snippets produce different results (assuming the variable level is used both before and after the recursive call). Why?</p>
<pre><code>public DoStuff(int level)
{
// ...
DoStuff(level++);
// ...
}
</code></pre>
<p>,</p>
<pre><code>public DoStuff(int level)
{
// ...
DoStuff(leve... | [
{
"answer_id": 114427,
"author": "workmad3",
"author_id": 16035,
"author_profile": "https://Stackoverflow.com/users/16035",
"pm_score": 5,
"selected": false,
"text": "<p><strong>level++</strong> will pass <strong>level</strong> into <strong>DoStuff</strong> and then increment <strong>lev... | 2008/09/22 | [
"https://Stackoverflow.com/questions/114419",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1199234/"
] | The following two C# code snippets produce different results (assuming the variable level is used both before and after the recursive call). Why?
```
public DoStuff(int level)
{
// ...
DoStuff(level++);
// ...
}
```
,
```
public DoStuff(int level)
{
// ...
DoStuff(level+1);
// ...
}
```
After reading ... | **level++** will pass **level** into **DoStuff** and then increment **level** for use in the rest of the function. This could be a fairly nasty bug as the recursion will never end (from what is shown **DoStuff** is always being passed the same value). Perhaps **++level** is meant instead, as this is the opposite of **l... |
114,431 | <p>I am trying to display a live word count in the vim statusline. I do this by setting my status line in my .vimrc and inserting a function into it. The idea of this function is to return the number of words in the current buffer. This number is then displayed on the status line. This should work nicely as the statusl... | [
{
"answer_id": 114474,
"author": "Steve Moyer",
"author_id": 17008,
"author_profile": "https://Stackoverflow.com/users/17008",
"pm_score": 3,
"selected": false,
"text": "<p>Keep a count for the current line and a separate count for the rest of the buffer. As you type (or delete) words o... | 2008/09/22 | [
"https://Stackoverflow.com/questions/114431",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20388/"
] | I am trying to display a live word count in the vim statusline. I do this by setting my status line in my .vimrc and inserting a function into it. The idea of this function is to return the number of words in the current buffer. This number is then displayed on the status line. This should work nicely as the statusline... | Here's a usable version of Rodrigo Queiro's idea. It doesn't change the status bar, and it restores the statusmsg variable.
```
function WordCount()
let s:old_status = v:statusmsg
exe "silent normal g\<c-g>"
let s:word_count = str2nr(split(v:statusmsg)[11])
let v:statusmsg = s:old_status
return s:word_count
... |
114,493 | <p>I know the range name of the start of a list - <code>1</code> column wide and <code>x</code> rows deep.</p>
<p>How do I calculate <code>x</code>?</p>
<p>There is more data in the column than just this list. However, this list is contiguous - there is nothing in any of the cells above or below or either side beside... | [
{
"answer_id": 114513,
"author": "GSerg",
"author_id": 11683,
"author_profile": "https://Stackoverflow.com/users/11683",
"pm_score": 5,
"selected": true,
"text": "<pre><code>Function ListRowCount(ByVal FirstCellName as String) as Long\n With thisworkbook.Names(FirstCellName).RefersToR... | 2008/09/22 | [
"https://Stackoverflow.com/questions/114493",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10326/"
] | I know the range name of the start of a list - `1` column wide and `x` rows deep.
How do I calculate `x`?
There is more data in the column than just this list. However, this list is contiguous - there is nothing in any of the cells above or below or either side beside it. | ```
Function ListRowCount(ByVal FirstCellName as String) as Long
With thisworkbook.Names(FirstCellName).RefersToRange
If isempty(.Offset(1,0).value) Then
ListRowCount = 1
Else
ListRowCount = .End(xlDown).row - .row + 1
End If
End With
End Function
```
But if yo... |
114,501 | <p>I want to set a background image for a div, in a way that it is in the upper <strong>RIGHT</strong> of the div, but with a fixed <code>10px</code> distance from top and right.</p>
<p>Here is how I would do that if wanted it in the upper <strong>LEFT</strong> of the div:</p>
<pre>background: url(images/img06.gif) n... | [
{
"answer_id": 114517,
"author": "mathieu",
"author_id": 971,
"author_profile": "https://Stackoverflow.com/users/971",
"pm_score": 3,
"selected": false,
"text": "<p>I don't know if it is possible in pure css, so you can try </p>\n\n<pre><code>background: url(images/img06.gif) no-repeat t... | 2008/09/22 | [
"https://Stackoverflow.com/questions/114501",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6476/"
] | I want to set a background image for a div, in a way that it is in the upper **RIGHT** of the div, but with a fixed `10px` distance from top and right.
Here is how I would do that if wanted it in the upper **LEFT** of the div:
```
background: url(images/img06.gif) no-repeat 10px 10px;
```
Is there anyway to achieve ... | Use the previously mentioned rule along with a top and right margin:
```
background: url(images/img06.gif) no-repeat top right;
margin-top: 10px;
margin-right: 10px;
```
Background images only appear within padding, not margins. If adding the margin isn't an option you may have to resort to another div, although I'd... |
114,504 | <p>Eg. can I write something like this code:</p>
<pre><code>public void InactiveCustomers(IEnumerable<Guid> customerIDs)
{
//...
myAdoCommand.CommandText =
"UPDATE Customer SET Active = 0 WHERE CustomerID in (@CustomerIDs)";
myAdoCommand.Parameters["@CustomerIDs"].Value = customerIDs;
//.... | [
{
"answer_id": 114548,
"author": "Pontus Gagge",
"author_id": 20402,
"author_profile": "https://Stackoverflow.com/users/20402",
"pm_score": -1,
"selected": false,
"text": "<p>Nope. Parameters are like SQL values in obeying <a href=\"http://www.anaesthetist.com/mnm/sql/normal.htm\" rel=\"... | 2008/09/22 | [
"https://Stackoverflow.com/questions/114504",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8547/"
] | Eg. can I write something like this code:
```
public void InactiveCustomers(IEnumerable<Guid> customerIDs)
{
//...
myAdoCommand.CommandText =
"UPDATE Customer SET Active = 0 WHERE CustomerID in (@CustomerIDs)";
myAdoCommand.Parameters["@CustomerIDs"].Value = customerIDs;
//...
}
```
The only ... | Generally the way that you do this is to pass in a comma-separated list of values, and within your stored procedure, parse the list out and insert it into a temp table, which you can then use for joins. As of **Sql Server 2005**, this is standard practice for dealing with parameters that need to hold arrays.
Here's a ... |
114,521 | <p>I am creating a <code>gridView</code> that allows adding new rows by adding the controls necessary for the insert into the <code>FooterTemplate</code>, but when the <code>ObjectDataSource</code> has no records, I add a dummy row as the <code>FooterTemplate</code> is only displayed when there is data.</p>
<p>How can... | [
{
"answer_id": 114589,
"author": "Orion Adrian",
"author_id": 7756,
"author_profile": "https://Stackoverflow.com/users/7756",
"pm_score": 0,
"selected": false,
"text": "<p>This is the incorrect usage of the GridView control. The GridView control has a special InsertRow which is where you... | 2008/09/22 | [
"https://Stackoverflow.com/questions/114521",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2808/"
] | I am creating a `gridView` that allows adding new rows by adding the controls necessary for the insert into the `FooterTemplate`, but when the `ObjectDataSource` has no records, I add a dummy row as the `FooterTemplate` is only displayed when there is data.
How can I hide this dummy row? I have tried setting `e.row.vi... | You could handle the gridview's databound event and hide the dummy row. (Don't forget to assign the event property in the aspx code):
```
protected void GridView1_DataBound(object sender, EventArgs e)
{
if (GridView1.Rows.Count == 1)
GridView1.Rows[0].Visible = false;
}
``` |
114,525 | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="https://stackoverflow.com/questions/336859/javascript-var-functionname-function-vs-function-functionname">JavaScript: var functionName = function() {} vs function functionName() {}</a> </p>
</blockquote>
<p>What's the difference between:</p>
<pr... | [
{
"answer_id": 114573,
"author": "Daniel James",
"author_id": 2434,
"author_profile": "https://Stackoverflow.com/users/2434",
"pm_score": 3,
"selected": false,
"text": "<p>The first one is a named function statement, the second one assigns an anonymous function expression to a variable.<... | 2008/09/22 | [
"https://Stackoverflow.com/questions/114525",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3983/"
] | >
> **Possible Duplicate:**
>
> [JavaScript: var functionName = function() {} vs function functionName() {}](https://stackoverflow.com/questions/336859/javascript-var-functionname-function-vs-function-functionname)
>
>
>
What's the difference between:
```
function sum(x, y) {
return x+y;
}
// and
var sum... | The first is known as a named function where the second is known as an anonymous function.
The key practical difference is in when you can use the sum function. For example:-
```
var z = sum(2, 3);
function sum(x, y) {
return x+y;
}
```
`z` is assigned 5 whereas this:-
```
var z = sum(2, 3);
var sum = function... |
114,527 | <p>I'm really new to .NET, and I still didn't get the hang about how configuration files work.</p>
<p>Every time I search on Google about it I get results about web.config, but I'm writing a Windows Forms application.</p>
<p>I figured out that I need to use the System.Configuration namespace, but the documentation is... | [
{
"answer_id": 114551,
"author": "Geoff",
"author_id": 1097,
"author_profile": "https://Stackoverflow.com/users/1097",
"pm_score": 0,
"selected": false,
"text": "<p>What version of .NET and Visual Studio are you using?</p>\n\n<p>When you created the new project, you should have a fi... | 2008/09/22 | [
"https://Stackoverflow.com/questions/114527",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/727/"
] | I'm really new to .NET, and I still didn't get the hang about how configuration files work.
Every time I search on Google about it I get results about web.config, but I'm writing a Windows Forms application.
I figured out that I need to use the System.Configuration namespace, but the documentation isn't helping.
How... | You want to use an App.Config.
When you add a new item to a project there is something called Applications Configuration file. Add that.
Then you add keys in the configuration/appsettings section
Like:
```
<configuration>
<appSettings>
<add key="MyKey" value="false"/>
```
Access the members by doing
```
Syste... |
114,541 | <p>I want to write a <a href="http://getsongbird.com/" rel="noreferrer">Songbird</a> extension binds the multimedia keys available on all Apple Mac OS X platforms. Unfortunately this isn't an easy google search and I can't find any docs.</p>
<p>Can anyone point me resources on accessing these keys or tell me how to d... | [
{
"answer_id": 115333,
"author": "rami",
"author_id": 9629,
"author_profile": "https://Stackoverflow.com/users/9629",
"pm_score": 0,
"selected": false,
"text": "<p><a href=\"http://www.manpagez.com/man/1/xev/\" rel=\"nofollow noreferrer\"><code>xev</code></a> might help you if you want t... | 2008/09/22 | [
"https://Stackoverflow.com/questions/114541",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15948/"
] | I want to write a [Songbird](http://getsongbird.com/) extension binds the multimedia keys available on all Apple Mac OS X platforms. Unfortunately this isn't an easy google search and I can't find any docs.
Can anyone point me resources on accessing these keys or tell me how to do it?
I have extensive programming exp... | This blog post has a solution:
<http://www.rogueamoeba.com/utm/posts/Article/mediaKeys-2007-09-29-17-00.html>
You basically need to subclass `NSApplication` and override `sendEvent`,
looking for special scan codes. I don't know what songbird is, but if it's
not a real application then I doubt you'll be able to ... |
114,543 | <p>How can I horizontally center a <code><div></code> within another <code><div></code> using CSS?</p>
<pre class="lang-html prettyprint-override"><code><div id="outer">
<div id="inner">Foo foo</div>
</div>
</code></pre>
| [
{
"answer_id": 114549,
"author": "Justin Poliey",
"author_id": 6967,
"author_profile": "https://Stackoverflow.com/users/6967",
"pm_score": 13,
"selected": true,
"text": "<p>You can apply this CSS to the inner <code><div></code>:</p>\n<pre class=\"lang-css prettyprint-override\"><co... | 2008/09/22 | [
"https://Stackoverflow.com/questions/114543",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20403/"
] | How can I horizontally center a `<div>` within another `<div>` using CSS?
```html
<div id="outer">
<div id="inner">Foo foo</div>
</div>
``` | You can apply this CSS to the inner `<div>`:
```css
#inner {
width: 50%;
margin: 0 auto;
}
```
Of course, you don't have to set the `width` to `50%`. Any width less than the containing `<div>` will work. The `margin: 0 auto` is what does the actual centering.
If you are targeting [Internet Explorer 8](https://e... |
114,619 | <p>I have defined a Delphi TTable object with calculated fields, and it is used in a grid on a form. I would like to make a copy of the TTable object, including the calculated fields, open that copy, do some changes to the data with the copy, close the copy, and then refresh the original copy and thusly the grid view. ... | [
{
"answer_id": 114803,
"author": "mj2008",
"author_id": 5544,
"author_profile": "https://Stackoverflow.com/users/5544",
"pm_score": 0,
"selected": false,
"text": "<p>You should be able to select the table on the form, copy it using <kbd>Ctrl</kbd>-<kbd>C</kbd>, then paste it into any tex... | 2008/09/22 | [
"https://Stackoverflow.com/questions/114619",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20408/"
] | I have defined a Delphi TTable object with calculated fields, and it is used in a grid on a form. I would like to make a copy of the TTable object, including the calculated fields, open that copy, do some changes to the data with the copy, close the copy, and then refresh the original copy and thusly the grid view. Is ... | You can use the **TBatchMove** component to copy a table and its structure.
Set the Mode property to specify the desired operation. The Source and Destination properties indicate the datasets whose records are added, deleted, or copied. The online help has additional details.
(Although I reckon you should investigate... |
114,658 | <p>I keep hearing that </p>
<pre><code>catch (Exception ex)
</code></pre>
<p>Is bad practise, however, I often use it in event handlers where an operation may for example go to network, allowing the possibility of many different types of failure. In this case, I catch all exceptions and display the error message to t... | [
{
"answer_id": 114678,
"author": "Armin Ronacher",
"author_id": 19990,
"author_profile": "https://Stackoverflow.com/users/19990",
"pm_score": 2,
"selected": false,
"text": "<p>It's perfectly okay if you re-raise exceptions you can't handle properly. If you just catch the exceptions you ... | 2008/09/22 | [
"https://Stackoverflow.com/questions/114658",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6448/"
] | I keep hearing that
```
catch (Exception ex)
```
Is bad practise, however, I often use it in event handlers where an operation may for example go to network, allowing the possibility of many different types of failure. In this case, I catch all exceptions and display the error message to the user in a message box.
... | The bad practice is
```
catch (Exception ex){}
```
and variants:
```
catch (Exception ex){ return false; }
```
etc.
Catching all exceptions on the top-level and passing them on to the user (by either logging them or displaying them in a message-box, depending on whether you are writing a server- or a client-appl... |
114,725 | <p>I’ve got a problem with Visual Basic (6) in combination with LDAP. When I try to connect to an LDAP store, I always get errors like ‘Bad Pathname’ or ‘Table does not exist’ (depending on what the code looks like).</p>
<p>This is the part of the code I wrote to connect:</p>
<pre><code>path = "LDAP://xx.xxx.xxx.xxx:... | [
{
"answer_id": 114790,
"author": "Darrel Miller",
"author_id": 6819,
"author_profile": "https://Stackoverflow.com/users/6819",
"pm_score": 2,
"selected": false,
"text": "<p>I'm not sure how much help this will be, but I use this code to access Active Directory objects.</p>\n\n<pre><code>... | 2008/09/22 | [
"https://Stackoverflow.com/questions/114725",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I’ve got a problem with Visual Basic (6) in combination with LDAP. When I try to connect to an LDAP store, I always get errors like ‘Bad Pathname’ or ‘Table does not exist’ (depending on what the code looks like).
This is the part of the code I wrote to connect:
```
path = "LDAP://xx.xxx.xxx.xxx:xxx/"
Logging.WriteTo... | I'm not sure how much help this will be, but I use this code to access Active Directory objects.
```
Set oinfo = New ADSystemInfo
sDomain = Split(oinfo.DomainDNSName, ".")
'-- Get Datasets from the Active Directory
'-- Connect to Active Directory in logged in domain
con.Open "Provider=ADsDSOObject;... |
114,728 | <p>One of my DBs have grown closer to permitted size.</p>
<p>Inorder to find out the table containing the max data, i used the following query:</p>
<pre><code>exec sp_MSforeachtable @command1="print '?' exec sp_spaceused '?'"
</code></pre>
<p>It returned the culprit table comprising the max data.</p>
<p>As a next s... | [
{
"answer_id": 114827,
"author": "Casper",
"author_id": 18729,
"author_profile": "https://Stackoverflow.com/users/18729",
"pm_score": 1,
"selected": false,
"text": "<p>An easier approach for all table sizes is to use the stored procedure at <a href=\"http://www.mitchelsellers.com/blogs/a... | 2008/09/22 | [
"https://Stackoverflow.com/questions/114728",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15425/"
] | One of my DBs have grown closer to permitted size.
Inorder to find out the table containing the max data, i used the following query:
```
exec sp_MSforeachtable @command1="print '?' exec sp_spaceused '?'"
```
It returned the culprit table comprising the max data.
As a next step, i want to cleanup the rows based on... | This will give you a list of rows by size, just set @table and @idcol accordingly (as written it'll run against the Northwind sample)
```
declare @table varchar(20)
declare @idcol varchar(10)
declare @sql varchar(1000)
set @table = 'Employees'
set @idcol = 'EmployeeId'
set @sql = 'select ' + @idcol +' , (0'
select @... |
114,733 | <p>Do anyone have good ideas of how to modify the toolbar for the WinForms version of the ReportViewer Toolbar?
That is, I want to remove some buttons and varius, but it looks like the solution is to create a brand new toolbar instead of modifying the one that is there.</p>
<p>Like, I had to remove export to excel, an... | [
{
"answer_id": 114766,
"author": "palehorse",
"author_id": 312,
"author_profile": "https://Stackoverflow.com/users/312",
"pm_score": 0,
"selected": false,
"text": "<p>Generally you are suppose to create your own toolbar if you want to modify it. Your solution for removing buttons will p... | 2008/09/22 | [
"https://Stackoverflow.com/questions/114733",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3308/"
] | Do anyone have good ideas of how to modify the toolbar for the WinForms version of the ReportViewer Toolbar?
That is, I want to remove some buttons and varius, but it looks like the solution is to create a brand new toolbar instead of modifying the one that is there.
Like, I had to remove export to excel, and did it t... | There are a lot of properties to set which buttons would you like to see.
For example [ShowBackButton](http://msdn.microsoft.com/en-us/library/microsoft.reporting.winforms.reportviewer.showbackbutton(VS.80).aspx), [ShowExportButton](http://msdn.microsoft.com/en-us/library/microsoft.reporting.winforms.reportviewer.show... |
114,787 | <p>I'm trying to setup a stress/load test using the WCAT toolkit included in the IIS Resources.</p>
<p>Using LogParser, I've processed a UBR file with configuration. It looks something like this:</p>
<pre><code> [Configuration]
NumClientMachines: 1 # number of distinct client machines to use
NumClientThrea... | [
{
"answer_id": 114863,
"author": "Corey Goldberg",
"author_id": 16148,
"author_profile": "https://Stackoverflow.com/users/16148",
"pm_score": 0,
"selected": false,
"text": "<p>I don't have an answer for you, but have you considered using other tools for your testing? The WCAT tools seem... | 2008/09/22 | [
"https://Stackoverflow.com/questions/114787",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2972/"
] | I'm trying to setup a stress/load test using the WCAT toolkit included in the IIS Resources.
Using LogParser, I've processed a UBR file with configuration. It looks something like this:
```
[Configuration]
NumClientMachines: 1 # number of distinct client machines to use
NumClientThreads: 100 # num... | I'd look at updating to WCat 6.3 - available [here for x86](http://www.iis.net/downloads/default.aspx?tabid=34&i=1466&g=6) and [here for x64](http://www.iis.net/downloads/default.aspx?tabid=34&i=1467&g=6)
They've changed the settings/scenario file strucutures, which is a little painful, but should suit your needs. |
114,804 | <p>I want to write a real-time analysis tool for wireless traffic.</p>
<p>Does anyone know how to read from a promiscuous (or sniffing) device in C? </p>
<p>I know that you need to have root access to do it. I was wondering if anyone knows what functions are necessary to do this. Normal sockets don't seem to make sen... | [
{
"answer_id": 114820,
"author": "GEOCHET",
"author_id": 5640,
"author_profile": "https://Stackoverflow.com/users/5640",
"pm_score": 0,
"selected": false,
"text": "<p>Why wouldn't you use something like <a href=\"http://www.wireshark.org/\" rel=\"nofollow noreferrer\">WireShark</a>?</p>\... | 2008/09/22 | [
"https://Stackoverflow.com/questions/114804",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/542226/"
] | I want to write a real-time analysis tool for wireless traffic.
Does anyone know how to read from a promiscuous (or sniffing) device in C?
I know that you need to have root access to do it. I was wondering if anyone knows what functions are necessary to do this. Normal sockets don't seem to make sense here. | On Linux you use a PF\_PACKET socket to read data from a raw device, such as an ethernet interface running in promiscuous mode:
```
s = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL))
```
This will send copies of every packet received up to your socket. It is quite likely that you don't really want every packet, thou... |
114,814 | <p>In Bash, how do I count the number of non-blank lines of code in a project?</p>
| [
{
"answer_id": 114835,
"author": "Ben Hoffstein",
"author_id": 4482,
"author_profile": "https://Stackoverflow.com/users/4482",
"pm_score": 2,
"selected": false,
"text": "<pre><code>awk '/^[[:space:]]*$/ {++x} END {print x}' \"$testfile\"\n</code></pre>\n"
},
{
"answer_id": 114836... | 2008/09/22 | [
"https://Stackoverflow.com/questions/114814",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10176/"
] | In Bash, how do I count the number of non-blank lines of code in a project? | ```
cat foo.c | sed '/^\s*$/d' | wc -l
```
And if you consider comments blank lines:
```
cat foo.pl | sed '/^\s*#/d;/^\s*$/d' | wc -l
```
Although, that's language dependent. |
114,819 | <p>Consider these classes.</p>
<pre><code>class Base
{
...
};
class Derived : public Base
{
...
};
</code></pre>
<p>this function</p>
<pre><code>void BaseFoo( std::vector<Base*>vec )
{
...
}
</code></pre>
<p>And finally my vector</p>
<pre><code>std::vector<Derived*>derived;
</code></pre>
<p... | [
{
"answer_id": 114833,
"author": "Matt Price",
"author_id": 852,
"author_profile": "https://Stackoverflow.com/users/852",
"pm_score": 3,
"selected": false,
"text": "<p>one option is to use a template</p>\n\n<pre><code>template<typename T>\nvoid BaseFoo( const std::vector<T*>&... | 2008/09/22 | [
"https://Stackoverflow.com/questions/114819",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19863/"
] | Consider these classes.
```
class Base
{
...
};
class Derived : public Base
{
...
};
```
this function
```
void BaseFoo( std::vector<Base*>vec )
{
...
}
```
And finally my vector
```
std::vector<Derived*>derived;
```
I want to pass `derived` to function `BaseFoo`, but the compiler doesn't let me. Ho... | `vector<Base*>` and `vector<Derived*>` are unrelated types, so you can't do this. This is explained in the C++ FAQ [here](http://www.parashift.com/c++-faq-lite/proper-inheritance.html#faq-21.3).
You need to change your variable from a `vector<Derived*>` to a `vector<Base*>` and insert `Derived` objects into it.
Also,... |
114,830 | <p>One of the basic data structures in Python is the dictionary, which allows one to record "keys" for looking up "values" of any type. Is this implemented internally as a hash table? If not, what is it?</p>
| [
{
"answer_id": 114831,
"author": "nosklo",
"author_id": 17160,
"author_profile": "https://Stackoverflow.com/users/17160",
"pm_score": 9,
"selected": true,
"text": "<p>Yes, it is a hash mapping or hash table. You can read a description of python's dict implementation, as written by Tim Pe... | 2008/09/22 | [
"https://Stackoverflow.com/questions/114830",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11575/"
] | One of the basic data structures in Python is the dictionary, which allows one to record "keys" for looking up "values" of any type. Is this implemented internally as a hash table? If not, what is it? | Yes, it is a hash mapping or hash table. You can read a description of python's dict implementation, as written by Tim Peters, [here](http://mail.python.org/pipermail/python-list/2000-March/048085.html "Tim Peters").
That's why you can't use something 'not hashable' as a dict key, like a list:
```
>>> a = {}
>>> b = ... |
114,851 | <p>I have the following code:</p>
<pre><code>ListBox.DataSource = DataSet.Tables("table_name").Select("some_criteria = match")
ListBox.DisplayMember = "name"
</code></pre>
<p>The <a href="http://msdn.microsoft.com/en-us/library/system.data.datatable.select(VS.80).aspx" rel="noreferrer"><code>DataTable.Select()</code>... | [
{
"answer_id": 114887,
"author": "Josh",
"author_id": 11702,
"author_profile": "https://Stackoverflow.com/users/11702",
"pm_score": 6,
"selected": true,
"text": "<p>Use a <a href=\"http://msdn.microsoft.com/en-us/library/hy5b8exc(VS.71).aspx\" rel=\"noreferrer\">DataView</a> instead.</p>... | 2008/09/22 | [
"https://Stackoverflow.com/questions/114851",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5662/"
] | I have the following code:
```
ListBox.DataSource = DataSet.Tables("table_name").Select("some_criteria = match")
ListBox.DisplayMember = "name"
```
The [`DataTable.Select()` method](http://msdn.microsoft.com/en-us/library/system.data.datatable.select(VS.80).aspx) returns an array of [`System.Data.DataRow`](http://ms... | Use a [DataView](http://msdn.microsoft.com/en-us/library/hy5b8exc(VS.71).aspx) instead.
```
ListBox.DataSource = new DataView(DataSet.Tables("table_name"), "some_criteria = match", "name", DataViewRowState.CurrentRows);
ListBox.DisplayMember = "name"
``` |
114,859 | <p>I use a custom Matrix class in my application, and I frequently add multiple matrices:</p>
<pre><code>Matrix result = a + b + c + d; // a, b, c and d are also Matrices
</code></pre>
<p>However, this creates an intermediate matrix for each addition operation. Since this is simple addition, it is possible to avoid t... | [
{
"answer_id": 114881,
"author": "Romain Verdier",
"author_id": 4687,
"author_profile": "https://Stackoverflow.com/users/4687",
"pm_score": 0,
"selected": false,
"text": "<p>It is not possible, using operators.</p>\n"
},
{
"answer_id": 114894,
"author": "David Dibben",
"a... | 2008/09/22 | [
"https://Stackoverflow.com/questions/114859",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/976/"
] | I use a custom Matrix class in my application, and I frequently add multiple matrices:
```
Matrix result = a + b + c + d; // a, b, c and d are also Matrices
```
However, this creates an intermediate matrix for each addition operation. Since this is simple addition, it is possible to avoid the intermediate objects an... | You could limit yourself to a single small intermediate by using lazy evaluation. Something like
```
public class LazyMatrix
{
public static implicit operator Matrix(LazyMatrix l)
{
Matrix m = new Matrix();
foreach (Matrix x in l.Pending)
{
for (int i = 0; i < 2; ++i)
... |
114,872 | <p>Given some JS code like that one here:</p>
<pre><code> for (var i = 0; i < document.getElementsByName('scale_select').length; i++) {
document.getElementsByName('scale_select')[i].onclick = vSetScale;
}
</code></pre>
<p>Would the code be faster if we put the result of getElementsByName into a variable bef... | [
{
"answer_id": 114891,
"author": "nickf",
"author_id": 9021,
"author_profile": "https://Stackoverflow.com/users/9021",
"pm_score": 1,
"selected": false,
"text": "<blockquote>\n <p>In principle, would the code be faster if we put the result of getElementsByName into a variable before the... | 2008/09/22 | [
"https://Stackoverflow.com/questions/114872",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2077/"
] | Given some JS code like that one here:
```
for (var i = 0; i < document.getElementsByName('scale_select').length; i++) {
document.getElementsByName('scale_select')[i].onclick = vSetScale;
}
```
Would the code be faster if we put the result of getElementsByName into a variable before the loop and then use the... | Definitely. The memory required to store that would only be a pointer to a DOM object and that's ***significantly*** less painful than doing a DOM search each time you need to use something!
Idealish code:
```
var scale_select = document.getElementsByName('scale_select');
for (var i = 0; i < scale_select.length; i++)... |
114,914 | <p>We use <a href="http://hudson-ci.org/" rel="noreferrer">Hudson</a> as a continuous integration system to execute automated builds (nightly and based on CVS polling) of a lot of our projects.</p>
<p>Some projects poll CVS every 15 minutes, some others poll every 5 minutes and some poll every hour.</p>
<p>Every few ... | [
{
"answer_id": 114932,
"author": "tzot",
"author_id": 6899,
"author_profile": "https://Stackoverflow.com/users/6899",
"pm_score": 0,
"selected": false,
"text": "<p>Change system limits for per-process maximum open file descriptors? As in <code>ulimit -n</code> for the Java process?</p>\n... | 2008/09/22 | [
"https://Stackoverflow.com/questions/114914",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9518/"
] | We use [Hudson](http://hudson-ci.org/) as a continuous integration system to execute automated builds (nightly and based on CVS polling) of a lot of our projects.
Some projects poll CVS every 15 minutes, some others poll every 5 minutes and some poll every hour.
Every few weeks we'll get a build that fails with the f... | This is Hudson issue 715 (~~<http://issues.hudson-ci.org/browse/HUDSON-715>~~). The current recommendation is to set the 'maximum number of simultaneous polling threads' to keep the polling activity down. |
114,928 | <p>I'm firing off a Java application from inside of a C# <a href="http://en.wikipedia.org/wiki/.NET_Framework" rel="noreferrer">.NET</a> console application. It works fine for the case where the Java application doesn't care what the "default" directory is, but fails for a Java application that only searches the curren... | [
{
"answer_id": 114937,
"author": "Dror Helper",
"author_id": 11361,
"author_profile": "https://Stackoverflow.com/users/11361",
"pm_score": 9,
"selected": true,
"text": "<p>Yes!\nProcessStartInfo Has a property called <em>WorkingDirectory</em>, just use:</p>\n\n<pre><code>...\nusing Syste... | 2008/09/22 | [
"https://Stackoverflow.com/questions/114928",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15689/"
] | I'm firing off a Java application from inside of a C# [.NET](http://en.wikipedia.org/wiki/.NET_Framework) console application. It works fine for the case where the Java application doesn't care what the "default" directory is, but fails for a Java application that only searches the current directory for support files.
... | Yes!
ProcessStartInfo Has a property called *WorkingDirectory*, just use:
```
...
using System.Diagnostics;
...
var startInfo = new ProcessStartInfo();
startInfo.WorkingDirectory = // working directory
// set additional properties
Process proc = Process.Start(startInfo);
``` |
114,983 | <p>Given:</p>
<pre><code>DateTime.UtcNow
</code></pre>
<p>How do I get a string which represents the same value in an <a href="http://en.wikipedia.org/wiki/ISO_8601" rel="noreferrer">ISO 8601</a>-compliant format?</p>
<p>Note that ISO 8601 defines a number of similar formats. The specific format I am looking for is:... | [
{
"answer_id": 114997,
"author": "Iain",
"author_id": 20457,
"author_profile": "https://Stackoverflow.com/users/20457",
"pm_score": 7,
"selected": false,
"text": "<pre><code>DateTime.UtcNow.ToString(\"s\")\n</code></pre>\n\n<p>Returns something like 2008-04-10T06:30:00</p>\n\n<p><code>Ut... | 2008/09/22 | [
"https://Stackoverflow.com/questions/114983",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20457/"
] | Given:
```
DateTime.UtcNow
```
How do I get a string which represents the same value in an [ISO 8601](http://en.wikipedia.org/wiki/ISO_8601)-compliant format?
Note that ISO 8601 defines a number of similar formats. The specific format I am looking for is:
```
yyyy-MM-ddTHH:mm:ssZ
``` | >
> **Note to readers:** Several commenters have pointed out some problems in this answer (related particularly to the first suggestion). Refer to the comments section for more information.
>
>
>
```
DateTime.UtcNow.ToString("yyyy-MM-ddTHH\\:mm\\:ss.fffffffzzz", CultureInfo.InvariantCulture);
```
Using [custom d... |
114,996 | <p>How can we connect a <code>PHP</code> script to <code>MS Access (.mdb)</code> file?</p>
<p>I tried by including following <code>PHP</code> code:</p>
<pre><code>$db_path = $_SERVER['DOCUMENT_ROOT'] . '\WebUpdate\\' . $file_name . '.mdb';
$cfg_dsn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" . $db_path;
$odbcco... | [
{
"answer_id": 115009,
"author": "Galwegian",
"author_id": 3201,
"author_profile": "https://Stackoverflow.com/users/3201",
"pm_score": 4,
"selected": true,
"text": "<p>Here's a sample for a connect and a simple select...</p>\n\n<pre><code><?php\n$db_conn = new COM(\"ADODB.Connection\"... | 2008/09/22 | [
"https://Stackoverflow.com/questions/114996",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6561/"
] | How can we connect a `PHP` script to `MS Access (.mdb)` file?
I tried by including following `PHP` code:
```
$db_path = $_SERVER['DOCUMENT_ROOT'] . '\WebUpdate\\' . $file_name . '.mdb';
$cfg_dsn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" . $db_path;
$odbcconnect = odbc_connect($cfg_dsn, '', '');
```
But it f... | Here's a sample for a connect and a simple select...
```
<?php
$db_conn = new COM("ADODB.Connection");
$connstr = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=". realpath("./Northwind.mdb").";";
$db_conn->open($connstr);
$rS = $db_conn->execute("SELECT * FROM Employees");
$f1 = $rS->Fields(0);
$f2 = $rS->Fields(1)... |
115,008 | <p>How to print line numbers to the log. Say when outputting some information to the log, I also want to print the line number where that output is in the source code. As we can see in the stack trace, it displays the line number where the exception has occurred. Stack trace is available on the exception object.</p>
<... | [
{
"answer_id": 115027,
"author": "Simon Buchan",
"author_id": 20135,
"author_profile": "https://Stackoverflow.com/users/20135",
"pm_score": 7,
"selected": false,
"text": "<p>From <a href=\"https://web.archive.org/web/20100818065334/http://blog.taragana.com:80/index.php/archive/core-java-... | 2008/09/22 | [
"https://Stackoverflow.com/questions/115008",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15177/"
] | How to print line numbers to the log. Say when outputting some information to the log, I also want to print the line number where that output is in the source code. As we can see in the stack trace, it displays the line number where the exception has occurred. Stack trace is available on the exception object.
Other al... | From [Angsuman Chakraborty](https://web.archive.org/web/20100818065334/http://blog.taragana.com:80/index.php/archive/core-java-how-to-get-java-source-code-line-number-file-name-in-code/) (archived) :
```
/** Get the current line number.
* @return int - Current line number.
*/
public static int getLineNumber() {
... |
115,031 | <p>I have an assembly, written in C++\CLI, which uses some of enumerations, provided by .Net. It has such kind of properties: </p>
<pre><code>property System::ServiceProcess::ServiceControllerStatus ^ Status
{
ServiceControllerStatus ^ get()
{
return (ServiceControllerStatus)_status->dwCur... | [
{
"answer_id": 115054,
"author": "Lou Franco",
"author_id": 3937,
"author_profile": "https://Stackoverflow.com/users/3937",
"pm_score": 2,
"selected": false,
"text": "<p>I think enums don't use the ^ -- try removing it from the property declaration and get().</p>\n"
},
{
"answer_... | 2008/09/22 | [
"https://Stackoverflow.com/questions/115031",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6698/"
] | I have an assembly, written in C++\CLI, which uses some of enumerations, provided by .Net. It has such kind of properties:
```
property System::ServiceProcess::ServiceControllerStatus ^ Status
{
ServiceControllerStatus ^ get()
{
return (ServiceControllerStatus)_status->dwCurrentState;
}... | In C++/CLI **^** is like the analagous \* in standard C++. Because enumerations are value types the **^** should not be included otherwise you will see them as **System.Enum**.
Remove the ^ and you will see the correct enumeration on C# side.
```
property System::ServiceProcess::ServiceControllerStatus Status
{
... |
115,039 | <p>Suppose that the <strong>ApplicationSettings</strong> class is a general repository of settings that apply to my application such as TimeoutPeriod, DefaultUnitOfMeasure, HistoryWindowSize, etc... And let's say MyClass makes use of one of those settings - DefaultUnitOfMeasure.</p>
<p>My reading of proper use of Inv... | [
{
"answer_id": 115183,
"author": "Mike Deck",
"author_id": 1247,
"author_profile": "https://Stackoverflow.com/users/1247",
"pm_score": 2,
"selected": false,
"text": "<blockquote>\n <p>Yes, many of my classes end up with a dependency on IoC.Container but that is a dependency that most of... | 2008/09/22 | [
"https://Stackoverflow.com/questions/115039",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5056/"
] | Suppose that the **ApplicationSettings** class is a general repository of settings that apply to my application such as TimeoutPeriod, DefaultUnitOfMeasure, HistoryWindowSize, etc... And let's say MyClass makes use of one of those settings - DefaultUnitOfMeasure.
My reading of proper use of Inversion of Control Contai... | >
> IoC.Container.Resolve("default\_uom");
>
>
>
I see this as a classic anti-pattern, where you are using the IoC container as a service locater - the key issues that result are:
* Your application no longer fails-fast if your container is misconfigured (you'll only know about it the first time it tries to resol... |
115,103 | <p>I am trying to implement position-sensitive zooming inside a <code>JScrollPane</code>. The <code>JScrollPane</code> contains a component with a customized <code>paint</code> that will draw itself inside whatever space it is allocated - so zooming is as easy as using a <code>MouseWheelListener</code> that resizes the... | [
{
"answer_id": 115179,
"author": "Steve Moyer",
"author_id": 17008,
"author_profile": "https://Stackoverflow.com/users/17008",
"pm_score": 1,
"selected": false,
"text": "<p>Your MouseWheelListener also has to locate the cursor, move it to the center of the JScrollPane and adjust the xmin... | 2008/09/22 | [
"https://Stackoverflow.com/questions/115103",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15472/"
] | I am trying to implement position-sensitive zooming inside a `JScrollPane`. The `JScrollPane` contains a component with a customized `paint` that will draw itself inside whatever space it is allocated - so zooming is as easy as using a `MouseWheelListener` that resizes the inner component as required.
But I also want ... | Tested this, seems to work...
```
private void updatePreferredSize(int n, Point p) {
double d = (double) n * 1.08;
d = (n > 0) ? 1 / d : -d;
int w = (int) (getWidth() * d);
int h = (int) (getHeight() * d);
preferredSize.setSize(w, h);
int offX = (int)(p.x * d) - p.x;
int offY = (int)(p.y ... |
115,121 | <p>Does anyone know why there is no <code>respond_to</code> block for generated <code>edit</code> actions? Every other action in typical scaffold controllers has a <code>respond_to</code> block in order to output <code>html</code> and <code>xml</code> formats. Why is the <code>edit</code> action an exception?</p>
<p>I... | [
{
"answer_id": 115201,
"author": "Andrew",
"author_id": 17408,
"author_profile": "https://Stackoverflow.com/users/17408",
"pm_score": 1,
"selected": false,
"text": "<p>Because the edit action will only be called from HTML\nThere is no need for the edit form to be returned in an XML conte... | 2008/09/22 | [
"https://Stackoverflow.com/questions/115121",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20467/"
] | Does anyone know why there is no `respond_to` block for generated `edit` actions? Every other action in typical scaffold controllers has a `respond_to` block in order to output `html` and `xml` formats. Why is the `edit` action an exception?
I'm using the latest version of Ruby on Rails (2.1.1). | Rails handles the 99% case: It's fairly unlikely you'd ever need to do any XML or JSON translations in your Edit action, because non-visually, the Edit action is pretty much just like the Show action. Nonvisual clients that want to update a model in your application can call the controller this way
```
GET /my_models/... |
115,159 | <p>I have been using ASP.NET for years, but I can never remember when using the # and = are appropriate.</p>
<p>For example:</p>
<pre><code><%= Grid.ClientID %>
</code></pre>
<p>or</p>
<pre><code><%# Eval("FullName")%>
</code></pre>
<p>Can someone explain when each should be used so I can keep it strai... | [
{
"answer_id": 115199,
"author": "John Sheehan",
"author_id": 1786,
"author_profile": "https://Stackoverflow.com/users/1786",
"pm_score": 6,
"selected": true,
"text": "<p><%= %> is the equivalent of doing Response.Write(\"\") wherever you place it.</p>\n\n<p><%# %> is for Databindi... | 2008/09/22 | [
"https://Stackoverflow.com/questions/115159",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/417/"
] | I have been using ASP.NET for years, but I can never remember when using the # and = are appropriate.
For example:
```
<%= Grid.ClientID %>
```
or
```
<%# Eval("FullName")%>
```
Can someone explain when each should be used so I can keep it straight in my mind? Is # only used in controls that support databinding? | <%= %> is the equivalent of doing Response.Write("") wherever you place it.
<%# %> is for Databinding and can only be used where databinding is supported (you can use these on the page-level outside a control if you call Page.DataBind() in your codebehind)
[Databinding Expressions Overview](http://msdn.microsoft.com/... |
115,167 | <p>I've been developing a site over the past few weeks using CodeIgniter as the framework. I've been thinking of the best way to accomplish something, which in a lot of other frameworks in other languages is relatively simple: sortable tables. CodeIgniter switches off query strings by default, because your URLs contain... | [
{
"answer_id": 115259,
"author": "Mark Biek",
"author_id": 305,
"author_profile": "https://Stackoverflow.com/users/305",
"pm_score": 0,
"selected": false,
"text": "<p>I recently added this <a href=\"http://tetlaw.id.au/view/blog/table-sorting-with-prototype/\" rel=\"nofollow noreferrer\"... | 2008/09/22 | [
"https://Stackoverflow.com/questions/115167",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I've been developing a site over the past few weeks using CodeIgniter as the framework. I've been thinking of the best way to accomplish something, which in a lot of other frameworks in other languages is relatively simple: sortable tables. CodeIgniter switches off query strings by default, because your URLs contain me... | If you're OK with sorting on the client side, [the Tablesorter plugin for jQuery](http://tablesorter.com/docs) is pretty nice. |
115,210 | <p>I'm processing some data files that are supposed to be valid UTF-8 but aren't, which causes the parser (not under my control) to fail. I'd like to add a stage of pre-validating the data for UTF-8 well-formedness, but I've not yet found a utility to help do this.</p>
<p>There's a <a href="http://www.w3.org/2005/01/y... | [
{
"answer_id": 115241,
"author": "tzot",
"author_id": 6899,
"author_profile": "https://Stackoverflow.com/users/6899",
"pm_score": 3,
"selected": false,
"text": "<p>Use python and str.encode|decode functions.</p>\n\n<pre><code>>>> a=\"γεια\"\n>>> a\n'\\xce\\xb3\\xce\\xb5... | 2008/09/22 | [
"https://Stackoverflow.com/questions/115210",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6716/"
] | I'm processing some data files that are supposed to be valid UTF-8 but aren't, which causes the parser (not under my control) to fail. I'd like to add a stage of pre-validating the data for UTF-8 well-formedness, but I've not yet found a utility to help do this.
There's a [web service](http://www.w3.org/2005/01/yacker... | You can use GNU iconv:
```
$ iconv -f UTF-8 your_file -o /dev/null; echo $?
```
Or with older versions of iconv, such as on macOS:
```
$ iconv -f UTF-8 your_file > /dev/null; echo $?
```
The command will return 0 if the file could be converted successfully, and 1 if not. Additionally, it will print out the byte o... |
115,249 | <p>I am trying to have a logout page where is displays a messages and then redirects to the login page. This is in ASP.net 2.0.</p>
<p>I have this in my <code>Page_Load</code>:</p>
<pre><code>ClientScript.RegisterStartupScript(typeof(Page), "pageredirect", JavascriptRedirect() );
</code></pre>
<p>This is my redirect... | [
{
"answer_id": 115279,
"author": "Lou Franco",
"author_id": 3937,
"author_profile": "https://Stackoverflow.com/users/3937",
"pm_score": 0,
"selected": false,
"text": "<p>Instead of typeof(Page), try typeof(YOURPAGECLASS) -- with YOURPAGECLASS set the name of your page's classname. Page_... | 2008/09/22 | [
"https://Stackoverflow.com/questions/115249",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3208/"
] | I am trying to have a logout page where is displays a messages and then redirects to the login page. This is in ASP.net 2.0.
I have this in my `Page_Load`:
```
ClientScript.RegisterStartupScript(typeof(Page), "pageredirect", JavascriptRedirect() );
```
This is my redirect function:
```
private string JavascriptRed... | By the way: You don't need Javascript to redirect the browser to a page after a certain amount of time. Just use a plain HTML meta Tag in your `<HEAD>` section.
```
<meta http-equiv="refresh" content="5; URL=login.aspx">
```
The number stands for the time in seconds, the URL for the target. |
115,269 | <p>There's something very unsatisfactory about this code:</p>
<pre><code>/*
Given a command string in which the first 8 characters are the command name
padded on the right with whitespace, construct the appropriate kind of
Command object.
*/
public class CommandFactory {
public Command getCommand(String cmd) {
... | [
{
"answer_id": 115289,
"author": "Lou Franco",
"author_id": 3937,
"author_profile": "https://Stackoverflow.com/users/3937",
"pm_score": -1,
"selected": false,
"text": "<p>At the very least, your command should have a getCommandString() -- where StartCommand overrides to return \"START\".... | 2008/09/22 | [
"https://Stackoverflow.com/questions/115269",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7512/"
] | There's something very unsatisfactory about this code:
```
/*
Given a command string in which the first 8 characters are the command name
padded on the right with whitespace, construct the appropriate kind of
Command object.
*/
public class CommandFactory {
public Command getCommand(String cmd) {
cmdNam... | Your map of strings to commands I think is good. You could even factor out the string command name to the constructor (i.e. shouldn't StartCommand know that its command is "START"?) If you could do this, instantiation of your command objects is much simpler:
```
Class c = commandMap.get(cmdName);
if (c != null)
re... |
115,319 | <p>I'm using C# and connecting to a WebService via an auto-generated C# proxy object. The method I'm calling can be long running, and sometimes times out. I get different errors back, sometimes I get a <code>System.Net.WebException</code> or a <code>System.Web.Services.Protocols.SoapException</code>. These exceptions h... | [
{
"answer_id": 115337,
"author": "Vinko Vrsalovic",
"author_id": 5190,
"author_profile": "https://Stackoverflow.com/users/5190",
"pm_score": 4,
"selected": false,
"text": "<p>That means that your consumer is expecting XML from the webservice but the webservice, as your error shows, retur... | 2008/09/22 | [
"https://Stackoverflow.com/questions/115319",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11898/"
] | I'm using C# and connecting to a WebService via an auto-generated C# proxy object. The method I'm calling can be long running, and sometimes times out. I get different errors back, sometimes I get a `System.Net.WebException` or a `System.Web.Services.Protocols.SoapException`. These exceptions have properties I can inte... | This is happening because there is an unhandled exception in your Web service, and the .NET runtime is spitting out its HTML yellow screen of death server error/exception dump page, instead of XML.
Since the consumer of your Web service was expecting a text/xml header and instead got text/html, it throws that error.
... |
115,328 | <p>I have the following class</p>
<pre>
public class Car
{
public Name {get; set;}
}
</pre>
<p>and I want to bind this programmatically to a text box.</p>
<p>How do I do that?</p>
<p>Shooting in the dark:</p>
<pre>
...
Car car = new Car();
TextEdit editBox = new TextEdit();
editBox.DataBinding.Add("Name", car, ... | [
{
"answer_id": 115346,
"author": "Danimal",
"author_id": 2757,
"author_profile": "https://Stackoverflow.com/users/2757",
"pm_score": 4,
"selected": false,
"text": "<p>Without looking at the syntax, I'm pretty sure it's:</p>\n\n<pre><code>editBox.DataBinding.Add(\"Text\", car, \"Name\");\... | 2008/09/22 | [
"https://Stackoverflow.com/questions/115328",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15771/"
] | I have the following class
```
public class Car
{
public Name {get; set;}
}
```
and I want to bind this programmatically to a text box.
How do I do that?
Shooting in the dark:
```
...
Car car = new Car();
TextEdit editBox = new TextEdit();
editBox.DataBinding.Add("Name", car, "Car - Name");
...
```
I get t... | You want
```
editBox.DataBindings.Add("Text", car, "Name");
```
The first parameter is the name of the property on the control that you want to be databound, the second is the data source, the third parameter is the property on the data source that you want to bind to. |
115,399 | <p>My credit card processor requires I send a two-digit year from the credit card expiration date. Here is how I am currently processing:</p>
<ol>
<li>I put a <code>DropDownList</code> of the 4-digit year on the page.</li>
<li>I validate the expiration date in a <code>DateTime</code> field to be sure that the expirati... | [
{
"answer_id": 115419,
"author": "NotMe",
"author_id": 2424,
"author_profile": "https://Stackoverflow.com/users/2424",
"pm_score": 1,
"selected": false,
"text": "<p>At this point, the simplest way is to just truncate the last two digits of the year. For credit cards, having a date in th... | 2008/09/22 | [
"https://Stackoverflow.com/questions/115399",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2535/"
] | My credit card processor requires I send a two-digit year from the credit card expiration date. Here is how I am currently processing:
1. I put a `DropDownList` of the 4-digit year on the page.
2. I validate the expiration date in a `DateTime` field to be sure that the expiration date being passed to the CC processor ... | If you're creating a DateTime object using the expiration dates (month/year), you can use ToString() on your DateTime variable like so:
```
DateTime expirationDate = new DateTime(2008, 1, 31); // random date
string lastTwoDigitsOfYear = expirationDate.ToString("yy");
```
Edit: Be careful with your dates though if yo... |
115,425 | <p>Aside from trying</p>
<pre><code>perldoc <module name>
</code></pre>
<p>individually for any CPAN module that takes my fancy or going through the file system and looking at the directories I have no idea what modules we have installed. </p>
<p>What's the easiest way to just get a big list of every CPAN modu... | [
{
"answer_id": 115439,
"author": "Dan",
"author_id": 17121,
"author_profile": "https://Stackoverflow.com/users/17121",
"pm_score": 5,
"selected": false,
"text": "<pre><code>perldoc perllocal\n</code></pre>\n\n<p>Edit: There's a (little) more info about it in the <a href=\"http://www.cpan... | 2008/09/22 | [
"https://Stackoverflow.com/questions/115425",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3404/"
] | Aside from trying
```
perldoc <module name>
```
individually for any CPAN module that takes my fancy or going through the file system and looking at the directories I have no idea what modules we have installed.
What's the easiest way to just get a big list of every CPAN module installed? From the command line or ... | This is answered in the Perl FAQ, the answer which can be quickly found with `perldoc -q installed`. In short, it comes down to using `ExtUtils::Installed` or using `File::Find`, variants of both of which have been covered previously in this thread.
You can also find the FAQ entry ["How do I find which modules are ins... |
115,426 | <p>I'm looking for an algorithm to detect if two rectangles intersect (one at an arbitrary angle, the other with only vertical/horizontal lines).</p>
<p>Testing if a corner of one is in the other ALMOST works. It fails if the rectangles form a cross-like shape.</p>
<p>It seems like a good idea to avoid using slopes ... | [
{
"answer_id": 115476,
"author": "Brendan Cashman",
"author_id": 5814,
"author_profile": "https://Stackoverflow.com/users/5814",
"pm_score": 0,
"selected": false,
"text": "<p>If you're using Java, all implementations of the Shape interface have an <a href=\"http://java.sun.com/javase/6/d... | 2008/09/22 | [
"https://Stackoverflow.com/questions/115426",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20493/"
] | I'm looking for an algorithm to detect if two rectangles intersect (one at an arbitrary angle, the other with only vertical/horizontal lines).
Testing if a corner of one is in the other ALMOST works. It fails if the rectangles form a cross-like shape.
It seems like a good idea to avoid using slopes of the lines, whic... | The standard method would be to do the **separating axis test** (do a google search on that).
In short:
* Two objects don't intersect if you can find a line that separates the two objects. e.g. the objects / all points of an object are on different sides of the line.
The fun thing is, that it's sufficient to just ch... |
115,428 | <p>I am looking to convert a <code>MySQL timestamp</code> to a epoch time in seconds using <code>PHP</code>, and vice versa. </p>
<p>What's the cleanest way to do this?</p>
| [
{
"answer_id": 115506,
"author": "Harrison Fisk",
"author_id": 16111,
"author_profile": "https://Stackoverflow.com/users/16111",
"pm_score": 3,
"selected": false,
"text": "<p>There are two functions in MySQL which are useful for converting back and forth from the unix epoch time that PHP... | 2008/09/22 | [
"https://Stackoverflow.com/questions/115428",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am looking to convert a `MySQL timestamp` to a epoch time in seconds using `PHP`, and vice versa.
What's the cleanest way to do this? | There are two functions in MySQL which are useful for converting back and forth from the unix epoch time that PHP likes:
[from\_unixtime()](http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_from-unixtime)
[unix\_timestamp()](http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.htm... |
115,431 | <p>Suppose I have some XAML like this:</p>
<pre><code><Window.Resources>
<v:MyClass x:Key="whatever" Text="foo\nbar" />
</Window.Resources>
</code></pre>
<p>Obviously I want a newline character in the MyClass.Text property, but the XAML parser constructs the object with the literal string "foo\nba... | [
{
"answer_id": 115543,
"author": "deepcode.co.uk",
"author_id": 20524,
"author_profile": "https://Stackoverflow.com/users/20524",
"pm_score": 1,
"selected": false,
"text": "<p>Off the top of my head, try;</p>\n\n<ol>\n<li>A custom binding expression perhaps?</li>\n</ol>\n\n<blockquote>\n... | 2008/09/22 | [
"https://Stackoverflow.com/questions/115431",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9591/"
] | Suppose I have some XAML like this:
```
<Window.Resources>
<v:MyClass x:Key="whatever" Text="foo\nbar" />
</Window.Resources>
```
Obviously I want a newline character in the MyClass.Text property, but the XAML parser constructs the object with the literal string "foo\nbar".
Is there (a) a way to convince the pars... | You can use XML character escaping
```
<TextBlock Text="Hello World!"/>
``` |
115,462 | <p>I'm having a little bit of a problem scaling my images to a properly predefined size. I was wondering - since it is purely mathematics, if there's some sort of common logical algorithm that works in every language (PHP, ActionScript, Javascript etc.) to scale images proportionally.</p>
<p>I'm using this at the mome... | [
{
"answer_id": 115487,
"author": "Alex Weinstein",
"author_id": 16668,
"author_profile": "https://Stackoverflow.com/users/16668",
"pm_score": 2,
"selected": false,
"text": "<p>I'd recommend not writing this code yourself; there are myriads of pixel-level details that take a serious while... | 2008/09/22 | [
"https://Stackoverflow.com/questions/115462",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17362/"
] | I'm having a little bit of a problem scaling my images to a properly predefined size. I was wondering - since it is purely mathematics, if there's some sort of common logical algorithm that works in every language (PHP, ActionScript, Javascript etc.) to scale images proportionally.
I'm using this at the moment:
```
... | ```
ratio = MIN( maxWidth / width, maxHeight/ height );
width = ratio * width;
height = ratio * height;
```
Make sure all divides are floating-point. |
115,478 | <p>The following code is in the <code>/Courses/Detail</code> action:</p>
<pre><code> [AcceptVerbs("GET")]
public ActionResult Detail(int id)
{
ViewData["Title"] = "A View Title";
return View(tmdc.GetCourseById(id));
}
</code></pre>
<p>The <code>tmdc.GetCourseById(id)</code> method retur... | [
{
"answer_id": 115704,
"author": "redsquare",
"author_id": 6440,
"author_profile": "https://Stackoverflow.com/users/6440",
"pm_score": 1,
"selected": false,
"text": "<p>You have to wait for the IDE to parse the JavaScript code. Just wait a while and you should see the JavaScript code cha... | 2008/09/22 | [
"https://Stackoverflow.com/questions/115478",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19251/"
] | The following code is in the `/Courses/Detail` action:
```
[AcceptVerbs("GET")]
public ActionResult Detail(int id)
{
ViewData["Title"] = "A View Title";
return View(tmdc.GetCourseById(id));
}
```
The `tmdc.GetCourseById(id)` method returns an instance of type `Course` for the View. In... | I was experiencing the same behavior in Visual Studio 2008, and after spending several minutes trying to get the symbols to load I ended up using a workaround - adding a line with the "debugger;" command in my JavaScript file.
After adding `debugger;` when you then reload the script in Internet Explorer it'll let you ... |
115,488 | <p>I am having difficulty reliably creating / removing event sources during the installation of my .Net Windows Service.</p>
<p>Here is the code from my ProjectInstaller class:</p>
<pre><code>// Create Process Installer
ServiceProcessInstaller spi = new ServiceProcessInstaller();
spi.Account = ServiceAccount.LocalSys... | [
{
"answer_id": 116222,
"author": "stephbu",
"author_id": 12702,
"author_profile": "https://Stackoverflow.com/users/12702",
"pm_score": 3,
"selected": false,
"text": "<p>Couple of things here</p>\n\n<p>Creating Event Logs and Sources on the fly is pretty frowned upon. primarily because o... | 2008/09/22 | [
"https://Stackoverflow.com/questions/115488",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13368/"
] | I am having difficulty reliably creating / removing event sources during the installation of my .Net Windows Service.
Here is the code from my ProjectInstaller class:
```
// Create Process Installer
ServiceProcessInstaller spi = new ServiceProcessInstaller();
spi.Account = ServiceAccount.LocalSystem;
// Create Servi... | The best recommendation would be to not use the Setup Project in Visual Studio. It has very severe limitations.
I had very good results with [WiX](http://wix.sourceforge.net/) |
115,503 | <p>I recently asked a question about Oracle Encryption. Along the way to finding a solution for myself I decided to move the encryption (well, obfuscation) to the application side for certain tasks. </p>
<p>My problem is that the database is already encrypting data a certain way and I need Java code to duplicate tha... | [
{
"answer_id": 115540,
"author": "Mr. Shiny and New 安宇",
"author_id": 7867,
"author_profile": "https://Stackoverflow.com/users/7867",
"pm_score": 3,
"selected": true,
"text": "<p>I found this works:</p>\n\n<pre><code>KeySpec ks = new DESKeySpec(new byte[] {'s','e','c','r','e','t','!','!'... | 2008/09/22 | [
"https://Stackoverflow.com/questions/115503",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7867/"
] | I recently asked a question about Oracle Encryption. Along the way to finding a solution for myself I decided to move the encryption (well, obfuscation) to the application side for certain tasks.
My problem is that the database is already encrypting data a certain way and I need Java code to duplicate that functional... | I found this works:
```
KeySpec ks = new DESKeySpec(new byte[] {'s','e','c','r','e','t','!','!'});
SecretKeyFactory skf = SecretKeyFactory.getInstance("DES");
SecretKey sk = skf.generateSecret(ks);
Cipher c = Cipher.getInstance("DES/CBC/NoPadding");
IvParameterSpec ips = new IvParameterSpec(new byte[] {0,0,0,0,0,0,0,0... |
115,526 | <p>I'm running an c# .net app in an iframe of an asp page on an older site. Accessing the Asp page's session information is somewhat difficult, so I'd like to make my .net app simply verify that it's being called from an approved page, or else immediately halt.</p>
<p>Is there a way for a page to find out the url of i... | [
{
"answer_id": 115533,
"author": "Dan",
"author_id": 17121,
"author_profile": "https://Stackoverflow.com/users/17121",
"pm_score": 5,
"selected": true,
"text": "<pre><code>top.location.href\n</code></pre>\n\n<p>But that will only work if both pages (the iframe and the main page) are bein... | 2008/09/22 | [
"https://Stackoverflow.com/questions/115526",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12382/"
] | I'm running an c# .net app in an iframe of an asp page on an older site. Accessing the Asp page's session information is somewhat difficult, so I'd like to make my .net app simply verify that it's being called from an approved page, or else immediately halt.
Is there a way for a page to find out the url of it's parent... | ```
top.location.href
```
But that will only work if both pages (the iframe and the main page) are being served from the same domain. |
115,548 | <p>This code in JS gives me a popup saying "i think null is a number", which I find slightly disturbing. What am I missing?</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>i... | [
{
"answer_id": 115559,
"author": "gizmo",
"author_id": 9396,
"author_profile": "https://Stackoverflow.com/users/9396",
"pm_score": 2,
"selected": false,
"text": "<p>Null is not NaN, as well as a string is not NaN. isNaN() just test if you really have the NaN object.</p>\n"
},
{
"... | 2008/09/22 | [
"https://Stackoverflow.com/questions/115548",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2077/"
] | This code in JS gives me a popup saying "i think null is a number", which I find slightly disturbing. What am I missing?
```js
if (isNaN(null)) {
alert("null is not a number");
} else {
alert("i think null is a number");
}
```
I'm using Firefox 3. Is that a browser bug?
Other tests:
```js
console.log(null =... | I believe the code is trying to ask, "is `x` numeric?" with the specific case here of `x = null`. The function `isNaN()` can be used to answer this question, but semantically it's referring specifically to the value `NaN`. From Wikipedia for [`NaN`](http://en.wikipedia.org/wiki/NaN):
>
> NaN (**N**ot **a** **N**umbe... |
115,557 | <p>We are struggling to configure our web app to be able to connect with web services via Spring WS. We have tried to use the example from the documentation of client-side Spring-WS, but we end up with a WebServiceTransportException. The XML config looks like this:</p>
<pre><code><bean id="webServiceTemplate" class... | [
{
"answer_id": 150178,
"author": "Symbioxys",
"author_id": 1841427,
"author_profile": "https://Stackoverflow.com/users/1841427",
"pm_score": 1,
"selected": false,
"text": "<p>How do you distinguish these:</p>\n\n<pre><code><constructor-arg value=\"john\"/>\n<constructor-arg valu... | 2008/09/22 | [
"https://Stackoverflow.com/questions/115557",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20529/"
] | We are struggling to configure our web app to be able to connect with web services via Spring WS. We have tried to use the example from the documentation of client-side Spring-WS, but we end up with a WebServiceTransportException. The XML config looks like this:
```
<bean id="webServiceTemplate" class="org.springframe... | Override HttpClient with a constructor that takes the parameters and wire through Spring using constructor-args
```
public MyHttpClient(HttpClientParams params, UsernamePasswordCredentials usernamePasswordCredentials) {
super(params);
getState().setCredentials(AuthScope.ANY, usernamePasswordCre... |
115,573 | <p>I'm sure we all have received the wonderfully vague "Object reference not set to instance of an Object" exception at some time or another. Identifying the object that is the problem is often a tedious task of setting breakpoints and inspecting all members in each statement. </p>
<p>Does anyone have any tricks to e... | [
{
"answer_id": 115599,
"author": "Oliver Mellet",
"author_id": 12001,
"author_profile": "https://Stackoverflow.com/users/12001",
"pm_score": 1,
"selected": false,
"text": "<p>There's really not much you can do besides look at the stack trace; if you're dereferencing multiple object refer... | 2008/09/22 | [
"https://Stackoverflow.com/questions/115573",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16391/"
] | I'm sure we all have received the wonderfully vague "Object reference not set to instance of an Object" exception at some time or another. Identifying the object that is the problem is often a tedious task of setting breakpoints and inspecting all members in each statement.
Does anyone have any tricks to easily and e... | At the point where the NRE is thrown, there is no target object -- that's the point of the exception. The most you can hope for is to trap the file and line number where the exception occurred. If you're having problems identifying which object reference is causing the problem, then you might want to rethink your codin... |
115,643 | <p>PowerShell is definitely in the category of dynamic languages, but would it be considered strongly typed? </p>
| [
{
"answer_id": 115676,
"author": "David Mohundro",
"author_id": 4570,
"author_profile": "https://Stackoverflow.com/users/4570",
"pm_score": 3,
"selected": false,
"text": "<p>It can be if you need it to be.</p>\n\n<p>Like so:</p>\n\n<pre><code>[1] » [int]$x = 5\n[2] » $x\n5\n[3] » $x = 'h... | 2008/09/22 | [
"https://Stackoverflow.com/questions/115643",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3289/"
] | PowerShell is definitely in the category of dynamic languages, but would it be considered strongly typed? | There is a certain amount of confusion around the terminlogy. [This article](http://eli.thegreenplace.net/2006/11/25/a-taxonomy-of-typing-systems/) explains a useful taxonomy of type systems.
PowerShell is dynamically, implicit typed:
```
> $x=100
> $x=dir
```
No type errors - a variable can change its type at runt... |
115,649 | <p>We have various servers that have many directories shared. It's easy enough to look at the share browser to see what the "top level" shares are, but underneath is a jumbled mess of custom permissions, none of which is documented.</p>
<p>I'd like to enumerate all the shares on the domain (definitely all the 'servers... | [
{
"answer_id": 115689,
"author": "Joe Skora",
"author_id": 14057,
"author_profile": "https://Stackoverflow.com/users/14057",
"pm_score": 2,
"selected": true,
"text": "<p>According to the JEdit <a href=\"http://jedit.org/index.php?page=features\" rel=\"nofollow noreferrer\">features page<... | 2008/09/22 | [
"https://Stackoverflow.com/questions/115649",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2590/"
] | We have various servers that have many directories shared. It's easy enough to look at the share browser to see what the "top level" shares are, but underneath is a jumbled mess of custom permissions, none of which is documented.
I'd like to enumerate all the shares on the domain (definitely all the 'servers', local P... | According to the JEdit [features page](http://jedit.org/index.php?page=features) it already supports Objective C. |
115,658 | <p>In my C# application I am using the Microsoft Jet OLEDB data provider to read a CSV file. The connection string looks like this:</p>
<pre><code>Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\Data;Extended Properties="text;HDR=Yes;FMT=Delimited
</code></pre>
<p>I open an ADO.NET OleDbConnection using that connecti... | [
{
"answer_id": 115684,
"author": "MarcE",
"author_id": 7262,
"author_profile": "https://Stackoverflow.com/users/7262",
"pm_score": 4,
"selected": true,
"text": "<p>There's a schema file you can create that would tell ADO.NET how to interpret the CSV - in effect giving it a structure.</p>... | 2008/09/22 | [
"https://Stackoverflow.com/questions/115658",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1016/"
] | In my C# application I am using the Microsoft Jet OLEDB data provider to read a CSV file. The connection string looks like this:
```
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\Data;Extended Properties="text;HDR=Yes;FMT=Delimited
```
I open an ADO.NET OleDbConnection using that connection string and select all t... | There's a schema file you can create that would tell ADO.NET how to interpret the CSV - in effect giving it a structure.
Try this: [http://www.aspdotnetcodes.com/Importing\_CSV\_Database\_Schema.ini.aspx](https://web.archive.org/web/20081009034412/http://www.aspdotnetcodes.com/Importing_CSV_Database_Schema.ini.aspx)
... |
115,665 | <p>I'm using the <code>cacheCounter</code> in <code>CakePHP</code>, which increments a counter for related fields.</p>
<p>Example, I have a Person table a Source table. Person.source_id maps to a row in the Source table. Each person has one Source, and each Source has none or many Person rows.</p>
<p><code>cacheCount... | [
{
"answer_id": 120009,
"author": "Till",
"author_id": 2859,
"author_profile": "https://Stackoverflow.com/users/2859",
"pm_score": -1,
"selected": false,
"text": "<p>See if the \"save\" uses some sort of DBAL call that returns \"affected rows\", usually this is how you can judge if the la... | 2008/09/22 | [
"https://Stackoverflow.com/questions/115665",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43/"
] | I'm using the `cacheCounter` in `CakePHP`, which increments a counter for related fields.
Example, I have a Person table a Source table. Person.source\_id maps to a row in the Source table. Each person has one Source, and each Source has none or many Person rows.
`cacheCounter` is working great when I change the valu... | To monitor changes in a field, you can use this logic in your model with no changes elsewhere required:
```
function beforeSave() {
$this->recursive = -1;
$this->old = $this->find(array($this->primaryKey => $this->id));
if ($this->old){
$changed_fields = array();
foreach ($this->data[$this-... |
115,685 | <p>I once wrote this line in a Java class. This compiled fine in Eclipse but not on the command line. </p>
<p>This is on</p>
<ul>
<li>Eclipse 3.3</li>
<li>JDK 1.5</li>
<li>Windows XP Professional</li>
</ul>
<p>Any clues?</p>
<p>Error given on the command line is:</p>
<pre><code>Icons.java:16: code too large
... | [
{
"answer_id": 115693,
"author": "Joe Skora",
"author_id": 14057,
"author_profile": "https://Stackoverflow.com/users/14057",
"pm_score": 0,
"selected": false,
"text": "<p>Hard to say from what's provided, but guesses are</p>\n\n<ol>\n<li>Different JVM in Eclipse than command line.</li>\n... | 2008/09/22 | [
"https://Stackoverflow.com/questions/115685",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9425/"
] | I once wrote this line in a Java class. This compiled fine in Eclipse but not on the command line.
This is on
* Eclipse 3.3
* JDK 1.5
* Windows XP Professional
Any clues?
Error given on the command line is:
```
Icons.java:16: code too large
public static final byte[] compileIcon = { 71, 73, 70, 56, 57... | Taking from [this forum on Sun's support site](http://forums.sun.com/thread.jspa?threadID=747860&messageID=4278559), no method can be more than 64 KB long:
When you have code (pseudo) like the following...
```
class MyClass
{
private String[] s = { "a", "b", "c"}
public MyClass()
{
}
```
The compiler ends ... |
115,691 | <p>In every MVC framework I've tried (Rails, Merb, Waves, Spring, and Struts), the idea of a Request (and Response) is tied to the HTTP notion of a Request. That is, even if there is an AbstractRequest that is a superclass of Request, the AbstractRequest has things like headers, request method (GET, POST, etc.), and a... | [
{
"answer_id": 115823,
"author": "Philip Rieck",
"author_id": 12643,
"author_profile": "https://Stackoverflow.com/users/12643",
"pm_score": 1,
"selected": false,
"text": "<p>I haven't seen one. The issue is that the request is also tied to the host, and the response is tied to the reque... | 2008/09/22 | [
"https://Stackoverflow.com/questions/115691",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1190/"
] | In every MVC framework I've tried (Rails, Merb, Waves, Spring, and Struts), the idea of a Request (and Response) is tied to the HTTP notion of a Request. That is, even if there is an AbstractRequest that is a superclass of Request, the AbstractRequest has things like headers, request method (GET, POST, etc.), and all o... | You seem to be working mostly with Java and/or Ruby, so forgive me that this answer is based on Perl :-).
I'm very fond of the Catalyst MVC Framework (<http://www.catalystframework.org/>). It delegates the actual mapping of requests (in the general, generic sense) to code via engines. Granted, all the engine classes a... |
115,692 | <p>For example I have such query:</p>
<pre><code>Query q = sess.createQuery("from Cat cat");
List cats = q.list();
</code></pre>
<p>If I try to make something like this it shows the following warning </p>
<pre><code>Type safety: The expression of type List needs unchecked conversion to conform to List<Cat>
L... | [
{
"answer_id": 115714,
"author": "tyshock",
"author_id": 16448,
"author_profile": "https://Stackoverflow.com/users/16448",
"pm_score": 3,
"selected": false,
"text": "<p>In our code we annotate the calling methods with:</p>\n\n<p>@SuppressWarnings(\"unchecked\")</p>\n\n<p>I know it seems ... | 2008/09/22 | [
"https://Stackoverflow.com/questions/115692",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20128/"
] | For example I have such query:
```
Query q = sess.createQuery("from Cat cat");
List cats = q.list();
```
If I try to make something like this it shows the following warning
```
Type safety: The expression of type List needs unchecked conversion to conform to List<Cat>
List<Cat> cats = q.list();
```
Is there a w... | Using `@SuppressWarnings` everywhere, as suggested, is a good way to do it, though it does involve a bit of finger typing each time you call `q.list()`.
There are two other techniques I'd suggest:
**Write a cast-helper**
Simply refactor all your `@SuppressWarnings` into one place:
```
List<Cat> cats = MyHibernateUt... |
115,703 | <p>I have some template code that I would prefer to have stored in a CPP file instead of inline in the header. I know this can be done as long as you know which template types will be used. For example:</p>
<p><strong>.h file</strong></p>
<pre><code>class foo
{
public:
template <typename T>
void do(co... | [
{
"answer_id": 115731,
"author": "Lou Franco",
"author_id": 3937,
"author_profile": "https://Stackoverflow.com/users/3937",
"pm_score": 2,
"selected": false,
"text": "<p>Yes, that's the standard way to do <s>specializiation</s> explicit instantiation. As you stated, you cannot instantia... | 2008/09/22 | [
"https://Stackoverflow.com/questions/115703",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9236/"
] | I have some template code that I would prefer to have stored in a CPP file instead of inline in the header. I know this can be done as long as you know which template types will be used. For example:
**.h file**
```
class foo
{
public:
template <typename T>
void do(const T& t);
};
```
**.cpp file**
```
tem... | The problem you describe can be solved by defining the template in the header, or via the approach you describe above.
I recommend reading the following points from the [C++ FAQ Lite](https://isocpp.org/wiki/faq/templates):
* [Why can’t I separate the definition of my templates class from its declaration and put it ... |
115,720 | <p>Is there a command in classic ASP I can use to tell the browser not to pull the page from it's cache, or, to not cache, or clear the cache of my page?</p>
| [
{
"answer_id": 115734,
"author": "Espo",
"author_id": 2257,
"author_profile": "https://Stackoverflow.com/users/2257",
"pm_score": 0,
"selected": false,
"text": "<p>If you put</p>\n\n<pre><code>Response.Expires = -1\n</code></pre>\n\n<p>in you classic ASP-page it will instruct the browser... | 2008/09/22 | [
"https://Stackoverflow.com/questions/115720",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5836/"
] | Is there a command in classic ASP I can use to tell the browser not to pull the page from it's cache, or, to not cache, or clear the cache of my page? | You can use HTML meta tags:
```
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="Fri, 01 Jan 1999 1:00:00 GMT" />
<meta http-equiv="Last-Modified" content="0" />
<meta http-equiv="Cache-Control" content="no-cache, must-revalidate" />
```
Or you can use ASP response headers:
```
<%... |
115,764 | <p>I have some Python code that creates a Calendar object based on parsed VEvent objects from and iCalendar file.</p>
<p>The calendar object just has a method that adds events as they get parsed.</p>
<p>Now I want to create a factory function that creates a calendar from a file object, path, or URL.</p>
<p>I've been... | [
{
"answer_id": 115777,
"author": "Florian Bösch",
"author_id": 19435,
"author_profile": "https://Stackoverflow.com/users/19435",
"pm_score": 3,
"selected": false,
"text": "<p>It's pythonic not to think about esoteric difference in some pattern you read somewhere and now want to use every... | 2008/09/22 | [
"https://Stackoverflow.com/questions/115764",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2900/"
] | I have some Python code that creates a Calendar object based on parsed VEvent objects from and iCalendar file.
The calendar object just has a method that adds events as they get parsed.
Now I want to create a factory function that creates a calendar from a file object, path, or URL.
I've been using the [iCalendar py... | [**Note**. Be very cautious about separating "Calendar" a collection of events, and "Event" - a single event on a calendar. In your question, it seems like there could be some confusion.]
There are many variations on the Factory design pattern.
1. A stand-alone convenience function (e.g., calendarMaker(data))
2. A se... |
115,773 | <p>I'm using python and CherryPy to create a simple internal website that about 2 people use. I use the built in webserver with CherryPy.quickstart and never messed with the config files. I recently changed machines so I installed the latest Python and cherrypy and when I run the site I can access it from localhost:808... | [
{
"answer_id": 115826,
"author": "nosklo",
"author_id": 17160,
"author_profile": "https://Stackoverflow.com/users/17160",
"pm_score": 5,
"selected": true,
"text": "<p>That depends on how you are running the cherrypy init.</p>\n\n<p>If using cherrypy 3.1 syntax, that wold do it:</p>\n\n<p... | 2008/09/22 | [
"https://Stackoverflow.com/questions/115773",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/852/"
] | I'm using python and CherryPy to create a simple internal website that about 2 people use. I use the built in webserver with CherryPy.quickstart and never messed with the config files. I recently changed machines so I installed the latest Python and cherrypy and when I run the site I can access it from localhost:8080 b... | That depends on how you are running the cherrypy init.
If using cherrypy 3.1 syntax, that wold do it:
```
cherrypy.server.socket_host = 'www.machinename.com'
cherrypy.engine.start()
cherrypy.engine.block()
```
Of course you can have something more fancy, like subclassing the server class, or using config files. Tho... |
115,789 | <p>It's my understanding that nulls are not indexable in DB2, so assuming we have a huge table (Sales) with a date column (sold_on) which is normally a date, but is occasionally (10% of the time) null.</p>
<p>Furthermore, let's assume that it's a legacy application that we can't change, so those nulls are staying ther... | [
{
"answer_id": 115824,
"author": "Jonathan Rupp",
"author_id": 12502,
"author_profile": "https://Stackoverflow.com/users/12502",
"pm_score": 3,
"selected": true,
"text": "<p>I'm no DB2 expert, but if 10% of your values are null, I don't think an index on that column alone will ever help ... | 2008/09/22 | [
"https://Stackoverflow.com/questions/115789",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9056/"
] | It's my understanding that nulls are not indexable in DB2, so assuming we have a huge table (Sales) with a date column (sold\_on) which is normally a date, but is occasionally (10% of the time) null.
Furthermore, let's assume that it's a legacy application that we can't change, so those nulls are staying there and mea... | I'm no DB2 expert, but if 10% of your values are null, I don't think an index on that column alone will ever help your query. 10% is too many to bother using an index for -- it'll just do a table scan. If you were talking about 2-3%, I think it would actually use your index.
Think about how many records are on a page/... |
115,809 | <p>Many beginning programmers write code like this:</p>
<pre><code>sub copy_file ($$) {
my $from = shift;
my $to = shift;
`cp $from $to`;
}
</code></pre>
<p>Is this bad, and why? Should backticks ever be used? If so, how?</p>
| [
{
"answer_id": 115810,
"author": "raldi",
"author_id": 7598,
"author_profile": "https://Stackoverflow.com/users/7598",
"pm_score": 3,
"selected": false,
"text": "<p>Backticks should be used if and only if you need to capture the output of a command. Otherwise, system() should be used. An... | 2008/09/22 | [
"https://Stackoverflow.com/questions/115809",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7598/"
] | Many beginning programmers write code like this:
```
sub copy_file ($$) {
my $from = shift;
my $to = shift;
`cp $from $to`;
}
```
Is this bad, and why? Should backticks ever be used? If so, how? | A few people have already mentioned that you should only use backticks when:
* You need to capture (or supress) the output.
* There exists no built-in function or Perl module to do the same task, or you have a good reason not to use the module or built-in.
* You sanitise your input.
* You check the return value.
Unfo... |
115,813 | <p>I have been trying to produce a statically linked "single binary" version of my game for windows. I want to link with sdl, sdl_image and sdl_mixer which in turn pull in a few support libraries. Unfortunately I haven't found a way to get them all to compile and link using cygwin/mingw/gcc. As far as I can tell all ex... | [
{
"answer_id": 115854,
"author": "Nils Pipenbrinck",
"author_id": 15955,
"author_profile": "https://Stackoverflow.com/users/15955",
"pm_score": 0,
"selected": false,
"text": "<p>That's because the SDL libs are under the LGPL-license.</p>\n\n<p>If you want to static link the libs (you can... | 2008/09/22 | [
"https://Stackoverflow.com/questions/115813",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20555/"
] | I have been trying to produce a statically linked "single binary" version of my game for windows. I want to link with sdl, sdl\_image and sdl\_mixer which in turn pull in a few support libraries. Unfortunately I haven't found a way to get them all to compile and link using cygwin/mingw/gcc. As far as I can tell all exi... | When compiling your project, you need to make just a couple changes to your makefile.
* Instead of `sdl-config --libs`, use `sdl-config --static-libs`
* Surround the use of the above-mentioned `sdl-config --static-libs` with `-Wl,-Bstatic` and `-Wl,-Bdynamic`. This tells GCC to force static linking, but only for the l... |
115,835 | <p>I am looking into an image processing problem for semi-real time detection of certain scenarios. My goal is to have the live video arrive as Motion JPEG frames in my Java code <em>somehow</em>. </p>
<p>I am familiar with the <a href="http://java.sun.com/javase/technologies/desktop/media/jmf/" rel="noreferrer">Jav... | [
{
"answer_id": 117412,
"author": "CMPalmer",
"author_id": 14894,
"author_profile": "https://Stackoverflow.com/users/14894",
"pm_score": -1,
"selected": false,
"text": "<p>Have you ever looked at <a href=\"http://processing.org/\" rel=\"nofollow noreferrer\">Processing.org</a>? It's basic... | 2008/09/22 | [
"https://Stackoverflow.com/questions/115835",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5812/"
] | I am looking into an image processing problem for semi-real time detection of certain scenarios. My goal is to have the live video arrive as Motion JPEG frames in my Java code *somehow*.
I am familiar with the [Java Media Framework](http://java.sun.com/javase/technologies/desktop/media/jmf/) and, sadly, I think we ca... | This JavaCV implementation works fine.
**CODE:**
```
import com.googlecode.javacv.OpenCVFrameGrabber;
import com.googlecode.javacv.cpp.opencv_core.IplImage;
import static com.googlecode.javacv.cpp.opencv_highgui.*;
public class CaptureImage {
private static void captureFrame() {
// 0-default camera, 1 -... |
115,862 | <p>I'm not sure about what's the difference between opening a JS script with </p>
<pre><code><SCRIPT language='JavaScript'>
</code></pre>
<p>or with:</p>
<pre><code><SCRIPT type="text/JavaScript">
</code></pre>
<p>Should JavaScript always be quoted (either with " " or with ' ') or that's not really impo... | [
{
"answer_id": 115871,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": -1,
"selected": false,
"text": "<p>Use both:</p>\n\n<pre><code><script language=\"javascript\" type=\"text/javascript\">\n</code></pre>\n"
},... | 2008/09/22 | [
"https://Stackoverflow.com/questions/115862",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19159/"
] | I'm not sure about what's the difference between opening a JS script with
```
<SCRIPT language='JavaScript'>
```
or with:
```
<SCRIPT type="text/JavaScript">
```
Should JavaScript always be quoted (either with " " or with ' ') or that's not really important?
Thank you for any clarification on this topic! | The language attribute was used in HTML 3.2. HTML 4.0 introduced type (which is consistent with other elements that refer to external media, such as `<style>`) and made it required. It also [deprecated](http://www.w3.org/TR/html401/conform.html#deprecated) language.
Use [type](http://www.w3.org/TR/html401/interact/scr... |
115,866 | <p>Convert mysql timestamp to epoch time in python - is there an easy way to do this?</p>
| [
{
"answer_id": 115903,
"author": "David Singer",
"author_id": 4618,
"author_profile": "https://Stackoverflow.com/users/4618",
"pm_score": 5,
"selected": false,
"text": "<p>Why not let MySQL do the hard work?</p>\n\n<pre><code>select unix_timestamp(fieldname) from tablename;\n</code></pre... | 2008/09/22 | [
"https://Stackoverflow.com/questions/115866",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Convert mysql timestamp to epoch time in python - is there an easy way to do this? | Why not let MySQL do the hard work?
```
select unix_timestamp(fieldname) from tablename;
``` |
115,868 | <p>I'd like to know how to grab the Window title of the current active window (i.e. the one that has focus) using C#. </p>
| [
{
"answer_id": 115891,
"author": "ine",
"author_id": 4965,
"author_profile": "https://Stackoverflow.com/users/4965",
"pm_score": 2,
"selected": false,
"text": "<p>Use the Windows API. Call <code>GetForegroundWindow()</code>.</p>\n\n<p><code>GetForegroundWindow()</code> will give you a ha... | 2008/09/22 | [
"https://Stackoverflow.com/questions/115868",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1039/"
] | I'd like to know how to grab the Window title of the current active window (i.e. the one that has focus) using C#. | See example on how you can do this with full source code here:
<http://www.csharphelp.com/2006/08/get-current-window-handle-and-caption-with-windows-api-in-c/>
```
[DllImport("user32.dll")]
static extern IntPtr GetForegroundWindow();
[DllImport("user32.dll")]
static extern int GetWindowText(IntPtr hWnd, StringBuilde... |
115,916 | <p>I'm trying to convert a VARIANT from VT_DATE to an <strong>invariant</strong> VT_BSTR. The following code works on Windows XP:</p>
<pre><code>VARIANT va;
::VariantInit(&va);
// set the variant to VT_DATE
SYSTEMTIME st;
memset(&st, 0, sizeof(SYSTEMTIME));
st.wYear = 2008;
st.wMonth = 9;
st.wDay = 22;
st.wH... | [
{
"answer_id": 118962,
"author": "Ana Betts",
"author_id": 5728,
"author_profile": "https://Stackoverflow.com/users/5728",
"pm_score": 1,
"selected": false,
"text": "<p>This isn't really an answer, but changing a date to a string <em>isn't</em> a Locale-invariant task - it highly depends... | 2008/09/22 | [
"https://Stackoverflow.com/questions/115916",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2773/"
] | I'm trying to convert a VARIANT from VT\_DATE to an **invariant** VT\_BSTR. The following code works on Windows XP:
```
VARIANT va;
::VariantInit(&va);
// set the variant to VT_DATE
SYSTEMTIME st;
memset(&st, 0, sizeof(SYSTEMTIME));
st.wYear = 2008;
st.wMonth = 9;
st.wDay = 22;
st.wHour = 12;
st.wMinute = 30;
DATE d... | This isn't really an answer, but changing a date to a string *isn't* a Locale-invariant task - it highly depends on the locale. In this case, I'd convert the Variant Time to System Time, then use a sprintf-style function to convert it to a string |
115,928 | <p>I need to have a thread signal another if the user wishes to interrupt execution, however I'm unsure about how to implement the signaling/signal-checking mechanism. I wouldn't like to have a singleton in my project (like a global <code>bool</code>), but is there an alternative?</p>
<p>In <a href="https://stackoverf... | [
{
"answer_id": 115935,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": -1,
"selected": false,
"text": "<p>Look at the System.Runtime.Remoting namespace.</p>\n"
},
{
"answer_id": 115948,
"author": "Statement",... | 2008/09/22 | [
"https://Stackoverflow.com/questions/115928",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4850/"
] | I need to have a thread signal another if the user wishes to interrupt execution, however I'm unsure about how to implement the signaling/signal-checking mechanism. I wouldn't like to have a singleton in my project (like a global `bool`), but is there an alternative?
In [this thread](https://stackoverflow.com/question... | Try out [BackgroundWorker](http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.aspx). It supports progress updates and cancellation of a running task.
If you want one thread to wait until another thread has finished doing its thing, then Monitor.Wait and Monitor.Pulse are good, as is ManualR... |
115,955 | <p>I'm trying to run a LINQ to SQL query that returns a result in a grid view in a search engine style listing. </p>
<p>In the simplified example below, is it possible to populate the collection with a comma-separated list of any children that the parent has (NAMESOFCHILDREN) in a single query?</p>
<pre><code>var fa... | [
{
"answer_id": 115965,
"author": "Amy B",
"author_id": 8155,
"author_profile": "https://Stackoverflow.com/users/8155",
"pm_score": 3,
"selected": true,
"text": "<p>Your joins are going to screw up your cardinality! You don't have a list of Parents!</p>\n\n<p>Here's some untested free-ha... | 2008/09/22 | [
"https://Stackoverflow.com/questions/115955",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2034/"
] | I'm trying to run a LINQ to SQL query that returns a result in a grid view in a search engine style listing.
In the simplified example below, is it possible to populate the collection with a comma-separated list of any children that the parent has (NAMESOFCHILDREN) in a single query?
```
var family = from p in db.Pa... | Your joins are going to screw up your cardinality! You don't have a list of Parents!
Here's some untested free-hand code. Adding the relationships in the Linq designer gives you relationship properties. String.Join will put the list together.
I've added two optional method calls.
*Where ... Any* will filter the pare... |
115,974 | <p>What would be the simplest way to daemonize a python script in Linux ? I need that this works with every flavor of Linux, so it should only use python based tools. </p>
| [
{
"answer_id": 115985,
"author": "moonshadow",
"author_id": 11834,
"author_profile": "https://Stackoverflow.com/users/11834",
"pm_score": 2,
"selected": false,
"text": "<p><a href=\"http://en.wikipedia.org/wiki/Nohup\" rel=\"nofollow noreferrer\">nohup</a> </p>\n\n<p><a href=\"http://cod... | 2008/09/22 | [
"https://Stackoverflow.com/questions/115974",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14262/"
] | What would be the simplest way to daemonize a python script in Linux ? I need that this works with every flavor of Linux, so it should only use python based tools. | See [Stevens](http://www.kohala.com/start/) and also this [lengthy thread on activestate](http://code.activestate.com/recipes/278731/) which I found personally to be both mostly incorrect and much to verbose, and I came up with this:
```
from os import fork, setsid, umask, dup2
from sys import stdin, stdout, stderr
i... |
115,977 | <p>I would very much like to integrate <a href="http://www.logilab.org/857" rel="noreferrer">pylint</a> into the build process for
my python projects, but I have run into one show-stopper: One of the
error types that I find extremely useful--:<code>E1101: *%s %r has no %r
member*</code>--constantly reports errors when... | [
{
"answer_id": 116025,
"author": "Thomas Wouters",
"author_id": 17624,
"author_profile": "https://Stackoverflow.com/users/17624",
"pm_score": 4,
"selected": false,
"text": "<p>Because of how pylint works (it examines the source itself, without letting Python actually execute it) it's ver... | 2008/09/22 | [
"https://Stackoverflow.com/questions/115977",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3446/"
] | I would very much like to integrate [pylint](http://www.logilab.org/857) into the build process for
my python projects, but I have run into one show-stopper: One of the
error types that I find extremely useful--:`E1101: *%s %r has no %r
member*`--constantly reports errors when using common django fields,
for example:
... | Do not disable or weaken Pylint functionality by adding `ignores` or `generated-members`.
Use an actively developed Pylint plugin that **understands** Django.
[This Pylint plugin for Django](https://github.com/landscapeio/pylint-django) works quite well:
```
pip install pylint-django
```
and when running pylin... |
115,983 | <p>How do I add an empty directory (that contains no files) to a Git repository?</p>
| [
{
"answer_id": 115992,
"author": "Andy Lester",
"author_id": 8454,
"author_profile": "https://Stackoverflow.com/users/8454",
"pm_score": 10,
"selected": false,
"text": "<p>You can't. See the <a href=\"https://git.wiki.kernel.org/index.php/GitFaq#Can_I_add_empty_directories.3F\" rel=\"no... | 2008/09/22 | [
"https://Stackoverflow.com/questions/115983",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7473/"
] | How do I add an empty directory (that contains no files) to a Git repository? | Another way to make a directory stay (almost) empty (in the repository) is to create a `.gitignore` file inside that directory that contains these four lines:
```
# Ignore everything in this directory
*
# Except this file
!.gitignore
```
Then you don't have to get the order right the way that you have to do in m104'... |
116,002 | <p>We all know that RAW pointers need to be wrapped in some form of smart pointer to get Exception safe memory management. But when it comes to containers of pointers the issue becomes more thorny.</p>
<p>The std containers insist on the contained object being copyable so this rules out the use of std::auto_ptr, thoug... | [
{
"answer_id": 116045,
"author": "workmad3",
"author_id": 16035,
"author_profile": "https://Stackoverflow.com/users/16035",
"pm_score": 2,
"selected": false,
"text": "<p>Well, overhead is one case.</p>\n\n<p>A vector of shared pointers will do a lot of extraneous copying that involves cr... | 2008/09/22 | [
"https://Stackoverflow.com/questions/116002",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14065/"
] | We all know that RAW pointers need to be wrapped in some form of smart pointer to get Exception safe memory management. But when it comes to containers of pointers the issue becomes more thorny.
The std containers insist on the contained object being copyable so this rules out the use of std::auto\_ptr, though you can... | Boost pointer containers have strict ownership over the resources they hold. A std::vector<boost::shared\_ptr<X>> has shared ownership. There are reasons why that may be necessary, but in case it isn't, I would default to boost::ptr\_vector<X>. YMMV. |
116,032 | <p>I've sometimes had a problem with my field-, table-, view- oder stored procedure names.
Example:</p>
<pre><code> SELECT from, to, rate FROM Table1
</code></pre>
<p>The Problem is that <strong><em>from</em></strong> is a reserved word in SQL-92.
You could put the fieldname in double quotes to fix this, but what i... | [
{
"answer_id": 116033,
"author": "Dan",
"author_id": 17121,
"author_profile": "https://Stackoverflow.com/users/17121",
"pm_score": 2,
"selected": false,
"text": "<p>Easy way: just make sure <em>every</em> field name is quoted.</p>\n\n<p>Edit: Any sensible DB tool worth its salt should be... | 2008/09/22 | [
"https://Stackoverflow.com/questions/116032",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20573/"
] | I've sometimes had a problem with my field-, table-, view- oder stored procedure names.
Example:
```
SELECT from, to, rate FROM Table1
```
The Problem is that ***from*** is a reserved word in SQL-92.
You could put the fieldname in double quotes to fix this, but what if some other db tools wants to read your datab... | Easy way: just make sure *every* field name is quoted.
Edit: Any sensible DB tool worth its salt should be doing the same thing, I have certainly never encountered any problems (outside of my own code, at least!) |
116,038 | <p>How do I read a file into a <code>std::string</code>, i.e., read the whole file at once?</p>
<p>Text or binary mode should be specified by the caller. The solution should be standard-compliant, portable and efficient. It should not needlessly copy the string's data, and it should avoid reallocations of memory while... | [
{
"answer_id": 116083,
"author": "Ben Collins",
"author_id": 3279,
"author_profile": "https://Stackoverflow.com/users/3279",
"pm_score": 5,
"selected": false,
"text": "<p>Use </p>\n\n<pre><code>#include <iostream>\n#include <sstream>\n#include <fstream>\n\nint main()\n{... | 2008/09/22 | [
"https://Stackoverflow.com/questions/116038",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | How do I read a file into a `std::string`, i.e., read the whole file at once?
Text or binary mode should be specified by the caller. The solution should be standard-compliant, portable and efficient. It should not needlessly copy the string's data, and it should avoid reallocations of memory while reading the string.
... | One way is to flush the stream buffer into a separate memory stream, and then convert that to `std::string` (error handling omitted):
```
std::string slurp(std::ifstream& in) {
std::ostringstream sstr;
sstr << in.rdbuf();
return sstr.str();
}
```
This is nicely concise. However, as noted in the question ... |
116,050 | <p>How do I programatically (Using C#) find out what the path is of my My Pictures folder? </p>
<p>Does this work on XP and Vista?</p>
| [
{
"answer_id": 116057,
"author": "neuroguy123",
"author_id": 12529,
"author_profile": "https://Stackoverflow.com/users/12529",
"pm_score": 3,
"selected": false,
"text": "<p>Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);</p>\n"
},
{
"answer_id": 116061,
"auth... | 2008/09/22 | [
"https://Stackoverflow.com/questions/116050",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5147/"
] | How do I programatically (Using C#) find out what the path is of my My Pictures folder?
Does this work on XP and Vista? | The following will return a full-path to the location of the users picture folder (Username\My Documents\My Pictures on XP, Username\Pictures on Vista)
```
Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);
``` |
116,053 | <p>I'd like to show/hide a column at runtime based on a particular condition. I'm using "Print when expression" to conditionally show/hide this column (and it's header) in my report. When the column is hidden, the space it would have occupied is left blank, which is not particularly attractive.</p>
<p>I would prefer i... | [
{
"answer_id": 117847,
"author": "Jacob Schoen",
"author_id": 3340,
"author_profile": "https://Stackoverflow.com/users/3340",
"pm_score": 0,
"selected": false,
"text": "<p>If it is just one column, is it possible to place this column to the far right, and then use the print when expressi... | 2008/09/22 | [
"https://Stackoverflow.com/questions/116053",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2648/"
] | I'd like to show/hide a column at runtime based on a particular condition. I'm using "Print when expression" to conditionally show/hide this column (and it's header) in my report. When the column is hidden, the space it would have occupied is left blank, which is not particularly attractive.
I would prefer if the extr... | In later version (v5 or above) of jasper reports you can use the `jr:table` component and **truly** achieve this (without the use of java code as using dynamic-jasper or dynamic-reports).
The method is using a `<printWhenExpression/>` under the `<jr:column/>`
Example
=======
**Sample Data**
```
+----------------+--... |
116,074 | <p>I just started using SVN, and I have a cache directory that I don't need under source control. How can I ignore the whole directory/folder with SVN?</p>
<p>I am using <a href="https://en.wikipedia.org/wiki/Comparison_of_Subversion_clients#Standalone_Subversion_clients_comparison_table" rel="noreferrer">Versions</a>... | [
{
"answer_id": 116075,
"author": "Jason Cohen",
"author_id": 4926,
"author_profile": "https://Stackoverflow.com/users/4926",
"pm_score": 11,
"selected": true,
"text": "<p>Set the <code>svn:ignore</code> property of the parent directory:</p>\n\n<pre><code>svn propset svn:ignore dirname .\... | 2008/09/22 | [
"https://Stackoverflow.com/questions/116074",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6305/"
] | I just started using SVN, and I have a cache directory that I don't need under source control. How can I ignore the whole directory/folder with SVN?
I am using [Versions](https://en.wikipedia.org/wiki/Comparison_of_Subversion_clients#Standalone_Subversion_clients_comparison_table) and [TextMate](http://en.wikipedia.or... | Set the `svn:ignore` property of the parent directory:
```
svn propset svn:ignore dirname .
```
If you have multiple things to ignore, separate by newlines in the property value. In that case it's easier to edit the property value using an external editor:
```
svn propedit svn:ignore .
``` |
116,090 | <p>I have a scenario where I have to check whether user has already opened Microsoft Word. If he has, then I have to kill the winword.exe process and continue to execute my code. </p>
<p>Does any one have any straight-forward code for killing a process using vb.net or c#?</p>
| [
{
"answer_id": 116098,
"author": "Blair Conrad",
"author_id": 1199,
"author_profile": "https://Stackoverflow.com/users/1199",
"pm_score": 8,
"selected": true,
"text": "<p>You'll want to use the <a href=\"http://msdn.microsoft.com/en-us/library/system.diagnostics.process.kill.aspx\" rel=\... | 2008/09/22 | [
"https://Stackoverflow.com/questions/116090",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13337/"
] | I have a scenario where I have to check whether user has already opened Microsoft Word. If he has, then I have to kill the winword.exe process and continue to execute my code.
Does any one have any straight-forward code for killing a process using vb.net or c#? | You'll want to use the [System.Diagnostics.Process.Kill](http://msdn.microsoft.com/en-us/library/system.diagnostics.process.kill.aspx) method. You can obtain the process you want using
[System.Diagnostics.Proccess.GetProcessesByName](http://msdn.microsoft.com/en-us/library/system.diagnostics.process.getprocessesbyname... |
116,140 | <p>I've got several AssemblyInfo.cs files as part of many projects in a single solution that I'm building automatically as part of TeamCity.</p>
<p>To make the msbuild script more maintainable I'd like to be able to use the AssemblyInfo community task in conjunction with an ItemGroup e.g.</p>
<pre><code><ItemGroup... | [
{
"answer_id": 116182,
"author": "TcKs",
"author_id": 20382,
"author_profile": "https://Stackoverflow.com/users/20382",
"pm_score": 4,
"selected": false,
"text": "<p>We use \"linked\" files in project.\nSolution Explorer -> Add Existin Item -> .. select_file .. -> arrow_on_left_of_add_bu... | 2008/09/22 | [
"https://Stackoverflow.com/questions/116140",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5777/"
] | I've got several AssemblyInfo.cs files as part of many projects in a single solution that I'm building automatically as part of TeamCity.
To make the msbuild script more maintainable I'd like to be able to use the AssemblyInfo community task in conjunction with an ItemGroup e.g.
```
<ItemGroup>
<AllAssemblyInfos... | Try changing the @ to a % as below
```
<ItemGroup>
<AllAssemblyInfos Include="..\**\AssemblyInfo.cs" />
</ItemGroup>
<AssemblyInfo AssemblyTitle="" AssemblyProduct="$(Product)" AssemblyCompany="$(Company)" AssemblyCopyright="$(Copyright)"
ComVisible="false" CLSCompliant="false" CodeLan... |
116,154 | <p>I would like to have something like this:</p>
<pre><code>class Foo {
private:
int bar;
public:
void setBar(int bar);
int getBar() const;
}
class MyDialog : public CDialogImpl<MyDialog> {
BEGIN_MODEL_MAPPING()
MAP_INT_EDITOR(m_editBar, m_model, getBar, setBar);
END_MODEL_MAPPING()
// other met... | [
{
"answer_id": 120133,
"author": "vog",
"author_id": 19163,
"author_profile": "https://Stackoverflow.com/users/19163",
"pm_score": 0,
"selected": false,
"text": "<p>The <a href=\"http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaBindings/CocoaBindings.html\" rel=\"nofollow n... | 2008/09/22 | [
"https://Stackoverflow.com/questions/116154",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14535/"
] | I would like to have something like this:
```
class Foo {
private:
int bar;
public:
void setBar(int bar);
int getBar() const;
}
class MyDialog : public CDialogImpl<MyDialog> {
BEGIN_MODEL_MAPPING()
MAP_INT_EDITOR(m_editBar, m_model, getBar, setBar);
END_MODEL_MAPPING()
// other methods and message map... | The DDX map is just a series of `if` statements, so you can easily write your own DDX macro.
```
#define DDX_MAP_VALIDATED_INT_EDITOR(control, variable, getter, setter, validator)\
if(nCtlID==control.GetDlgCtrlID())\
{\
if(bSaveAndValidate)\
{\
int const value=control.GetDlgItemInt(... |
116,163 | <p>I have a paradox table from a legacy system I need to run a single query on. The field names have spaces in them - i.e. "Street 1". When I try and formulate a query in delphi for only the "Street 1" field, I get an error - Invalid use of keyword. Token: 1, Line Number: 1</p>
<p>Delphi V7 - object pascal, standard... | [
{
"answer_id": 116257,
"author": "Jeremy Mullin",
"author_id": 7893,
"author_profile": "https://Stackoverflow.com/users/7893",
"pm_score": 2,
"selected": false,
"text": "<p>You normally need to quote the field name in this case. For example:</p>\n\n<p>select * from t1 where \"street 1\" ... | 2008/09/22 | [
"https://Stackoverflow.com/questions/116163",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a paradox table from a legacy system I need to run a single query on. The field names have spaces in them - i.e. "Street 1". When I try and formulate a query in delphi for only the "Street 1" field, I get an error - Invalid use of keyword. Token: 1, Line Number: 1
Delphi V7 - object pascal, standard Tquery obje... | You need to prefix the string with the table name in the query.
For example: field name is 'Street 1', table is called customers the select is:
```
SELECT customers."Street 1" FROM customers WHERE ...
``` |
116,188 | <p>I need to do the following for the purposes of paging a query in nHibernate:</p>
<pre><code>Select count(*) from
(Select e.ID,e.Name from Object as e where...)
</code></pre>
<p>I have tried the following, </p>
<pre><code>select count(*) from Object e where e = (Select distinct e.ID,e.Name from ...)
</code></pre>... | [
{
"answer_id": 116285,
"author": "user8456",
"author_id": 8456,
"author_profile": "https://Stackoverflow.com/users/8456",
"pm_score": 0,
"selected": false,
"text": "<p>If you just need <code>e.Id</code>,<code>e.Name</code>:</p>\n\n<p><code>select count(*) from Object where</code>.....</p... | 2008/09/22 | [
"https://Stackoverflow.com/questions/116188",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14833/"
] | I need to do the following for the purposes of paging a query in nHibernate:
```
Select count(*) from
(Select e.ID,e.Name from Object as e where...)
```
I have tried the following,
```
select count(*) from Object e where e = (Select distinct e.ID,e.Name from ...)
```
and I get an nHibernate Exception saying I c... | ```
var session = GetSession();
var criteria = session.CreateCriteria(typeof(Order))
.Add(Restrictions.Eq("Product", product))
.SetProjection(Projections.CountDistinct("Price"));
return (int) criteria.UniqueResult();
``` |
116,276 | <p>I'm used to python, so this is a bit confusing to me. I'm trying to take in input, line-by-line, until a user inputs a certain number. The numbers will be stored in an array to apply some statistical maths to them. Currently, I have a main class, the stats classes, and an "reading" class.</p>
<p>Two Questions:</p>
... | [
{
"answer_id": 116283,
"author": "Jason Cohen",
"author_id": 4926,
"author_profile": "https://Stackoverflow.com/users/4926",
"pm_score": 3,
"selected": false,
"text": "<p>What you need in your loop condition is:</p>\n\n<pre><code>while ( input.get( input.size()-1 ) != end_signal );\n</co... | 2008/09/22 | [
"https://Stackoverflow.com/questions/116276",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10636/"
] | I'm used to python, so this is a bit confusing to me. I'm trying to take in input, line-by-line, until a user inputs a certain number. The numbers will be stored in an array to apply some statistical maths to them. Currently, I have a main class, the stats classes, and an "reading" class.
Two Questions:
1. I can't se... | Answers:
*>1. I can't seem to get the input loop to work out, what's the best practice for doing so.*
I would rather have a simple while loop instead of a do{}while... and place the condition in the while... In my example it read:
*while the read number is not end signal and count is lower than limit: do.*
*>2. Wha... |
116,289 | <p>I have VB6 application , I want to put some good error handling finction in it which can tell me what was the error and exact place when it happened , can anyone suggest the good way to do this </p>
| [
{
"answer_id": 116312,
"author": "Kris Erickson",
"author_id": 3798,
"author_profile": "https://Stackoverflow.com/users/3798",
"pm_score": 5,
"selected": false,
"text": "<p>First of all, go get <a href=\"http://www.mztools.com/v3/mztools3.aspx\" rel=\"noreferrer\">MZTools for Visual Basi... | 2008/09/22 | [
"https://Stackoverflow.com/questions/116289",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14299/"
] | I have VB6 application , I want to put some good error handling finction in it which can tell me what was the error and exact place when it happened , can anyone suggest the good way to do this | ON ERROR GOTO
and the
```
Err
```
object.
There is a tutorial [here](http://web.archive.org/web/20171020040908/http://www.vb6.us:80/tutorials/error-handling). |
116,402 | <p>I was given a task to display when a record in the database was added, however the previous developers never made a field for this, and I can't go back and make up dates for all the existing records. Is there an easy way to extract out a record Creation date from a <code>SQL server 2000</code> query. </p>
<pre><cod... | [
{
"answer_id": 116407,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 5,
"selected": true,
"text": "<p>If it's not stored as a field, the info is <em>lost</em> after the transaction log recycles (typically daily), and m... | 2008/09/22 | [
"https://Stackoverflow.com/questions/116402",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18893/"
] | I was given a task to display when a record in the database was added, however the previous developers never made a field for this, and I can't go back and make up dates for all the existing records. Is there an easy way to extract out a record Creation date from a `SQL server 2000` query.
```
SELECT RECORD_CREATED_D... | If it's not stored as a field, the info is *lost* after the transaction log recycles (typically daily), and maybe even sooner. |
116,403 | <p>Let's say I have a string holding a mess of text and (x)HTML tags. I want to remove all instances of a given tag (and any attributes of that tag), leaving all other tags and text along. What's the best Regex to get this done?</p>
<p>Edited to add: Oh, I appreciate that using a Regex for this particular issue is n... | [
{
"answer_id": 116417,
"author": "Dan",
"author_id": 17121,
"author_profile": "https://Stackoverflow.com/users/17121",
"pm_score": 5,
"selected": true,
"text": "<p>Attempting to parse HTML with regular expressions is generally an <em>extremely</em> bad idea. Use a parser instead, there s... | 2008/09/22 | [
"https://Stackoverflow.com/questions/116403",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19074/"
] | Let's say I have a string holding a mess of text and (x)HTML tags. I want to remove all instances of a given tag (and any attributes of that tag), leaving all other tags and text along. What's the best Regex to get this done?
Edited to add: Oh, I appreciate that using a Regex for this particular issue is not the best ... | Attempting to parse HTML with regular expressions is generally an *extremely* bad idea. Use a parser instead, there should be one available for your chosen language.
You **might** be able to get away with something like this:
```
</?tag[^>]*?>
```
But it depends on exactly what you're doing. For example, that won't... |
116,423 | <p>I've been reading a little about temporary tables in MySQL but I'm an admitted newbie when it comes to databases in general and MySQL in particular. I've looked at some examples and the MySQL documentation on how to create a temporary table, but I'm trying to determine just how temporary tables might benefit my app... | [
{
"answer_id": 116443,
"author": "neuroguy123",
"author_id": 12529,
"author_profile": "https://Stackoverflow.com/users/12529",
"pm_score": 1,
"selected": false,
"text": "<p>I've used them in the past when I needed to create evaluated data. That was before the time of views and sub selec... | 2008/09/22 | [
"https://Stackoverflow.com/questions/116423",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7862/"
] | I've been reading a little about temporary tables in MySQL but I'm an admitted newbie when it comes to databases in general and MySQL in particular. I've looked at some examples and the MySQL documentation on how to create a temporary table, but I'm trying to determine just how temporary tables might benefit my applica... | Temporary tables are often valuable when you have a fairly complicated SELECT you want to perform and then perform a bunch of queries on that...
You can do something like:
```
CREATE TEMPORARY TABLE myTopCustomers
SELECT customers.*,count(*) num from customers join purchases using(customerID)
join items using(... |