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 |
|---|---|---|---|---|---|---|
459,212 | <p>I'm attempting to issue two concurrent AJAX requests. </p>
<p>The first call (/ajax_test1.php) takes a very long time to execute (5 seconds or so).
The second call (/ajax_test2.php) takes a very short time to execute. </p>
<p>The behavior I'm seeing is that I /ajax_test2.php returns and the handler gets called (u... | [
{
"answer_id": 459245,
"author": "AnthonyWJones",
"author_id": 17516,
"author_profile": "https://Stackoverflow.com/users/17516",
"pm_score": 4,
"selected": true,
"text": "<p>This line:-</p>\n\n<pre><code>req = new XMLHttpRequest();\n</code></pre>\n\n<p>should be:-</p>\n\n<pre><code>var r... | 2009/01/19 | [
"https://Stackoverflow.com/questions/459212",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26133/"
] | I'm attempting to issue two concurrent AJAX requests.
The first call (/ajax\_test1.php) takes a very long time to execute (5 seconds or so).
The second call (/ajax\_test2.php) takes a very short time to execute.
The behavior I'm seeing is that I /ajax\_test2.php returns and the handler gets called (updateTwo()) wi... | This line:-
```
req = new XMLHttpRequest();
```
should be:-
```
var req = new XMLHttpRequest();
``` |
459,213 | <p>I have a VB.NET program that I wish to to publish. In the code it references a HTML page that I created. Instead of having the URL hard coded (example: www.test2.com/folder/index.html)</p>
<p>I would like to have it relative to wherever the encoder is installed to (example: /folder/index.html)</p>
<p>How can I d... | [
{
"answer_id": 459466,
"author": "spacemonkeys",
"author_id": 32336,
"author_profile": "https://Stackoverflow.com/users/32336",
"pm_score": 3,
"selected": true,
"text": "<p>In VB.Net you have either </p>\n\n<pre><code>Dim lPath As String = Application.ExecutablePath\n</code></pre>\n\n<p>... | 2009/01/19 | [
"https://Stackoverflow.com/questions/459213",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48654/"
] | I have a VB.NET program that I wish to to publish. In the code it references a HTML page that I created. Instead of having the URL hard coded (example: www.test2.com/folder/index.html)
I would like to have it relative to wherever the encoder is installed to (example: /folder/index.html)
How can I do this?
Thanks! | In VB.Net you have either
```
Dim lPath As String = Application.ExecutablePath
```
Which gives you the full path and app.name (which you can remove) or
```
Dim lPath As String = Application.StartupPath
```
Which gives you the directory the application started up in ..
---
Not sure I know the answer to the cli... |
459,232 | <p>I am, for lack of a better word, a newbie to Localization and resource files. I am trying to localize an application I am working on and I want to do it using resource files and satellite assemblies, but I can't figure out how to do it correctly. Here is what I have so far:</p>
<p>In my project directory: I created... | [
{
"answer_id": 459445,
"author": "baretta",
"author_id": 30052,
"author_profile": "https://Stackoverflow.com/users/30052",
"pm_score": 0,
"selected": false,
"text": "<p>The fallback resources should be placed in LanguageText.dll in the bin folder.\nAlternatively, you may add an System.Re... | 2009/01/19 | [
"https://Stackoverflow.com/questions/459232",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am, for lack of a better word, a newbie to Localization and resource files. I am trying to localize an application I am working on and I want to do it using resource files and satellite assemblies, but I can't figure out how to do it correctly. Here is what I have so far:
In my project directory: I created the files... | You can do it with the help of AssemblyInfo. Go to AssemblyInfo.cs and add the attribute
```
[assembly: NeutralResourcesLanguageAttribute("en-US",UltimateResourceFallbackLocation.Satellite)]
```
Make sure to add using statement `using System.Resources;` at the top. The above line indicates that the neutral resource... |
459,263 | <p><strong>I'd like to specify a Servlet URL pattern to match a URL that ends with a slash ("/") and only a slash.</strong></p>
<p>I understand that the pattern</p>
<pre> /example/path/*</pre>
<p>will match a URL of</p>
<pre> http://example.com/example/path/</pre>
<p>and that this appears to work. However, t... | [
{
"answer_id": 459369,
"author": "Peter Štibraný",
"author_id": 47190,
"author_profile": "https://Stackoverflow.com/users/47190",
"pm_score": 4,
"selected": true,
"text": "<p>It's quite possible that you can't do this by mapping in web.xml.</p>\n\n<p>What you can do is to map servlet to ... | 2009/01/19 | [
"https://Stackoverflow.com/questions/459263",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5343/"
] | **I'd like to specify a Servlet URL pattern to match a URL that ends with a slash ("/") and only a slash.**
I understand that the pattern
```
/example/path/*
```
will match a URL of
```
http://example.com/example/path/
```
and that this appears to work. However, that same pattern would also match URLs of
... | It's quite possible that you can't do this by mapping in web.xml.
What you can do is to map servlet to /mypath/\* and then check part after /mypath/ via request.getPathInto(). If it is "/", run your code. If it isn't, return 404 error. |
459,295 | <p>Does anyone know how to limit the number of values that can be chosen in a multi-select Select And Search Prompt in Cognos 8? Currently the options are one or unlimited, and I want to write a little Javascript that limits a certain prompt to 5 or 10 values? Does anyone know how to accomplish this?</p>
| [
{
"answer_id": 459331,
"author": "Diodeus - James MacFarlane",
"author_id": 12579,
"author_profile": "https://Stackoverflow.com/users/12579",
"pm_score": 1,
"selected": false,
"text": "<p>I'm not sure about what Cognos runs with, but here's a simple way to determine the number of selecte... | 2009/01/19 | [
"https://Stackoverflow.com/questions/459295",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Does anyone know how to limit the number of values that can be chosen in a multi-select Select And Search Prompt in Cognos 8? Currently the options are one or unlimited, and I want to write a little Javascript that limits a certain prompt to 5 or 10 values? Does anyone know how to accomplish this? | I'm not sure about what Cognos runs with, but here's a simple way to determine the number of selected items in a `<select>`.
```
<script type="text/javascript">
function selCheck() {
var sel = document.form1.s1
var checked = 0
for(var x=0;x<sel.length;x++) {
if(sel[x].selected) {
checke... |
459,302 | <p>Are there any jQuery 1.3 animation-transitions that work in both Firefox 3 and IE7?</p>
<p>I have a table with multiple table rows (25 or more), with some of the rows starting hidden (these rows all share a common class; in this example, it's ".hidden"). In the table header is a "Show more" link which is bound via ... | [
{
"answer_id": 459345,
"author": "Francisco Canedo",
"author_id": 54591,
"author_profile": "https://Stackoverflow.com/users/54591",
"pm_score": 2,
"selected": true,
"text": "<p>According to <a href=\"http://docs.jquery.com/Browser_Compatibility\" rel=\"nofollow noreferrer\">jQuery's comp... | 2009/01/19 | [
"https://Stackoverflow.com/questions/459302",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28001/"
] | Are there any jQuery 1.3 animation-transitions that work in both Firefox 3 and IE7?
I have a table with multiple table rows (25 or more), with some of the rows starting hidden (these rows all share a common class; in this example, it's ".hidden"). In the table header is a "Show more" link which is bound via `.click()`... | According to [jQuery's compatibility page](http://docs.jquery.com/Browser_Compatibility) this sort of thing is a bug and should be reported. |
459,304 | <p>I have a DataGridView binded to this table:</p>
<pre><code>[Users]
ID Name
-- ----
11 Qwe
22 Asd
</code></pre>
<p>Grid is direclty binded to typed dataset table.</p>
<p>I have a second table like this:</p>
<pre><code>[Records]
ID UserID Data
-- ------ ----
67 11 ....
68 11 ....
</code></pre>
<p>... | [
{
"answer_id": 459359,
"author": "Lusid",
"author_id": 56855,
"author_profile": "https://Stackoverflow.com/users/56855",
"pm_score": 1,
"selected": false,
"text": "<p>If you are using DataSets/DataTables, then you can do something like this to filter your rows for the second grid:</p>\n\... | 2009/01/19 | [
"https://Stackoverflow.com/questions/459304",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/55818/"
] | I have a DataGridView binded to this table:
```
[Users]
ID Name
-- ----
11 Qwe
22 Asd
```
Grid is direclty binded to typed dataset table.
I have a second table like this:
```
[Records]
ID UserID Data
-- ------ ----
67 11 ....
68 11 ....
```
Records.UserID is connected to Users with a foreign key.... | In the end I had to this:
1. Create a DB class, with a public property (MyDataSetProperty) that returns the typedDataset
2. Create a custom Fill function in DataSet that accepts an Id parameter.
3. Use this function to fill the table in the private typedDataset
this.myTableAdapter.FillCustom(this.myTypedDataset.MyTab... |
459,307 | <p>In my WPF ListBox, I have a style with a ControlTemplate for a ListBoxItem. Inside that ControlTemplate I have a label defined. Based on some details, I need to change the font size of the label. So from my code-behind, I need to determine what the font should be and then I need to set it.</p>
<p>Here is my styl... | [
{
"answer_id": 459417,
"author": "Steven Robbins",
"author_id": 26507,
"author_profile": "https://Stackoverflow.com/users/26507",
"pm_score": 0,
"selected": false,
"text": "<p>You might be able to use a <a href=\"http://msdn.microsoft.com/en-us/library/ms771571.aspx\" rel=\"nofollow nore... | 2009/01/19 | [
"https://Stackoverflow.com/questions/459307",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3047/"
] | In my WPF ListBox, I have a style with a ControlTemplate for a ListBoxItem. Inside that ControlTemplate I have a label defined. Based on some details, I need to change the font size of the label. So from my code-behind, I need to determine what the font should be and then I need to set it.
Here is my style with the Co... | If I understand you correctly, you can probably do something similar to the following, and simply change the FontSize property on the ListBoxItem itself; it will be reflected automatically on your Label. Copy this into VS and see it in action!
```
<Window.Resources>
<Style TargetType="ListBoxItem">
<Setter... |
459,312 | <p>I'm setting up a database using phpMyAdmin. I have two tables (<code>foo</code> and <code>bar</code>), <strong>indexed on their primary keys</strong>. I am trying to create a relational table (<code>foo_bar</code>) between them, using their primary keys as foreign keys.</p>
<p>I created these tables as MyISAM, but h... | [
{
"answer_id": 464521,
"author": "markus",
"author_id": 11995,
"author_profile": "https://Stackoverflow.com/users/11995",
"pm_score": 3,
"selected": false,
"text": "<p>InnoDB allows you to add a new foreign key constraint to a table by using ALTER TABLE:</p>\n\n<pre><code>ALTER TABLE tbl... | 2009/01/19 | [
"https://Stackoverflow.com/questions/459312",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4376/"
] | I'm setting up a database using phpMyAdmin. I have two tables (`foo` and `bar`), **indexed on their primary keys**. I am trying to create a relational table (`foo_bar`) between them, using their primary keys as foreign keys.
I created these tables as MyISAM, but have since changed all three to InnoDB, because I read t... | If you want to use phpMyAdmin to set up relations, you have to do 2 things. First of all, you have to define an index on the foreign key column in the referring table (so foo\_bar.foo\_id, in your case). Then, go to relation view (in the referring table) and select the referred column (so in your case foo.id) and the o... |
459,326 | <p>I have 2 classes, a parent and a child. </p>
<pre><code>
Class Test
Private Test_Text
Private Sub Class_Initialize()
Test_Text = "Hello"
End Sub
Private Sub Class_Terminate()
End Sub
Public Property Get Text
Text = Test_Text
End Property
Public Property ... | [
{
"answer_id": 459340,
"author": "Andrew Hare",
"author_id": 34211,
"author_profile": "https://Stackoverflow.com/users/34211",
"pm_score": 2,
"selected": false,
"text": "<p>Since this is a <code>HAS-A</code> relationship between your two classes then I think you ought to leave it as is. ... | 2009/01/19 | [
"https://Stackoverflow.com/questions/459326",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38695/"
] | I have 2 classes, a parent and a child.
```
Class Test
Private Test_Text
Private Sub Class_Initialize()
Test_Text = "Hello"
End Sub
Private Sub Class_Terminate()
End Sub
Public Property Get Text
Text = Test_Text
End Property
Public Property Let Text(ByVal ... | no - this violates the [Law of Demeter](http://en.wikipedia.org/wiki/Law_of_Demeter); rethink the interface - under what circumstances would someone need to access the Text property of the enclosed Test object in a SubTest object? If these situations make sense, you'll need to expose Text as a property in SubTest.
Giv... |
459,349 | <p>I have an aspx page that uses a master page. On this page I have a group of radio buttons. I need to get at the checked property for each of the elements in the radio button group in javascript. Before the page was converted to use a master page, the following javascript code worked just fine:</p>
<pre><code>if(... | [
{
"answer_id": 459383,
"author": "Corey Downie",
"author_id": 44861,
"author_profile": "https://Stackoverflow.com/users/44861",
"pm_score": 2,
"selected": true,
"text": "<p>If you want to explore the idea of using jQuery rather than straight javascript, this should do the trick for you.<... | 2009/01/19 | [
"https://Stackoverflow.com/questions/459349",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/54064/"
] | I have an aspx page that uses a master page. On this page I have a group of radio buttons. I need to get at the checked property for each of the elements in the radio button group in javascript. Before the page was converted to use a master page, the following javascript code worked just fine:
```
if((!f.rblRegUseVehi... | If you want to explore the idea of using jQuery rather than straight javascript, this should do the trick for you.
```
if ( $('input[id*=rblRegUseVehicles]:checked').length < 0 ) isValid = "false";
```
The selector gets all checked radiobuttons who's id contains 'rblRegUseVehicles'.
**Edit**
If you want to stick ... |
459,355 | <p>I already know how to use the CLLocationManager, so I could do it the hard way, with delegates and all that. </p>
<p>But I'd like to have a convenience method that just gets the current location, once, and blocks until it gets the result.</p>
| [
{
"answer_id": 459834,
"author": "August",
"author_id": 30966,
"author_profile": "https://Stackoverflow.com/users/30966",
"pm_score": 2,
"selected": false,
"text": "<p>There are no \"convenience methods\" unless you code them yourself, but you'd still need to implement the delegate metho... | 2009/01/19 | [
"https://Stackoverflow.com/questions/459355",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/136/"
] | I already know how to use the CLLocationManager, so I could do it the hard way, with delegates and all that.
But I'd like to have a convenience method that just gets the current location, once, and blocks until it gets the result. | What I do is implement a singleton class to manage updates from core location. To access my current location, I do a `CLLocation *myLocation = [[LocationManager sharedInstance] currentLocation];` If you wanted to block the main thread you could do something like this:
```
while ([[LocationManager sharedInstance] locat... |
459,375 | <p>The built-in WPF TreeView control does not allow for multi selection, like a ListBox does. How can I customize the TreeView to allow for multi selection without rewriting it. </p>
| [
{
"answer_id": 2214484,
"author": "Zamboni",
"author_id": 174682,
"author_profile": "https://Stackoverflow.com/users/174682",
"pm_score": 3,
"selected": false,
"text": "<p>When I consider overriding the fundamental behavior of a control, like a treeview, I always like to consider the usa... | 2009/01/19 | [
"https://Stackoverflow.com/questions/459375",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4580/"
] | The built-in WPF TreeView control does not allow for multi selection, like a ListBox does. How can I customize the TreeView to allow for multi selection without rewriting it. | I have a variation on SoMoS implementation that uses an attached property declared on a derivation of the base TreeView control to track the selection state of the TreeViewItems. This keeps the selection tracking on the TreeViewItem element itself, and off of the model object being presented by the tree-view.
This is ... |
459,378 | <p>Is it possible to repeat table headers in Safari on every printed page?</p>
<p>This code works in Firefox but not in Safari:</p>
<pre><code><table>
<thead>
<tr>
<td>Header1</td>
<td>Header2</td>
</tr>
</thead>
<!-- lots of rows --&... | [
{
"answer_id": 460768,
"author": "Ahmed",
"author_id": 56747,
"author_profile": "https://Stackoverflow.com/users/56747",
"pm_score": 0,
"selected": false,
"text": "<p>You may want to consider creating a CSS sheet for the printed version of your page. If you opt for that route, use the \"... | 2009/01/19 | [
"https://Stackoverflow.com/questions/459378",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24587/"
] | Is it possible to repeat table headers in Safari on every printed page?
This code works in Firefox but not in Safari:
```
<table>
<thead>
<tr>
<td>Header1</td>
<td>Header2</td>
</tr>
</thead>
<!-- lots of rows -->
</table>
```
**Edit:**
the following doesn't fix it, therefore it can't be... | To answer my own question:
After googling and getting no correct answer I think that there exists simply no method to accomplish it. Maybe later versions of Safari will include it. |
459,382 | <p>I want to perform following operation in .NET Compact Framework. I am looking for Calling Method type.</p>
<p><a href="http://www.csharp-examples.net/reflection-calling-method-name/" rel="nofollow noreferrer">http://www.csharp-examples.net/reflection-calling-method-name/</a></p>
<p>.NET Compact Framework doesn't s... | [
{
"answer_id": 459444,
"author": "ctacke",
"author_id": 13154,
"author_profile": "https://Stackoverflow.com/users/13154",
"pm_score": 0,
"selected": false,
"text": "<p>As you're finding, the Compact Framework is just that - compact. Not everything from the full framework is available, a... | 2009/01/19 | [
"https://Stackoverflow.com/questions/459382",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I want to perform following operation in .NET Compact Framework. I am looking for Calling Method type.
<http://www.csharp-examples.net/reflection-calling-method-name/>
.NET Compact Framework doesn't support StackFrame class. Also, GetCurrentMethod() is not available in MethodBase class. | Try throwing an exception then check it's StackTrace property.
```
try
{
throw new Exception();
}
catch(Exception ex)
{
Console.Write(ex.StackTrace);
}
```
It will give something like
>
> "at
> NumericTextBoxControl.NumericalInput..ctor()\r\nat
> Custom\_Numeric\_Input.frmTestApplicati... |
459,386 | <p>Is there a way that I can create a function that takes an <code>int</code> template parameter, and have that function give a compile time error if the value passed to the function is less than 10?</p>
<p>The following code does not work, but it shows what I want to accomplish:</p>
<pre><code>template <int numbe... | [
{
"answer_id": 459395,
"author": "Johannes Schaub - litb",
"author_id": 34509,
"author_profile": "https://Stackoverflow.com/users/34509",
"pm_score": 2,
"selected": false,
"text": "<pre><code>template <int number1>\ntypename boost::enable_if_c< (number1 >= 10) >::type \nre... | 2009/01/19 | [
"https://Stackoverflow.com/questions/459386",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3153/"
] | Is there a way that I can create a function that takes an `int` template parameter, and have that function give a compile time error if the value passed to the function is less than 10?
The following code does not work, but it shows what I want to accomplish:
```
template <int number1>
void reportErrorIfLessThan10()
... | If you don't want [Boost C++ Libraries](http://en.wikipedia.org/wiki/Boost_C%2B%2B_Libraries) magic and want bare bones...
```
template<bool> class static_check
{
};
template<> class static_check<false>
{
private: static_check();
};
#define StaticAssert(test) static_check<(test) != 0>()
```
Then use StaticAssert. ... |
459,392 | <p>I'm actually playing around with the <a href="http://www.lastfm.de/api" rel="nofollow noreferrer">last.FM</a> web serivce API which I call via REST. When I get the response I try to convert the result into a XDocument so I could use LINQ to work with it. </p>
<p>But when I pass the result string to the XDocumnet co... | [
{
"answer_id": 459425,
"author": "Sebastian",
"author_id": 56440,
"author_profile": "https://Stackoverflow.com/users/56440",
"pm_score": 1,
"selected": false,
"text": "<p><a href=\"http://jamescrisp.org/2008/08/08/simple-rest-client/\" rel=\"nofollow noreferrer\">http://jamescrisp.org/20... | 2009/01/19 | [
"https://Stackoverflow.com/questions/459392",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19601/"
] | I'm actually playing around with the [last.FM](http://www.lastfm.de/api) web serivce API which I call via REST. When I get the response I try to convert the result into a XDocument so I could use LINQ to work with it.
But when I pass the result string to the XDocumnet constructor an ArgumentException is thrown tellin... | It sounds to me as though you are holding the response in a string. If that is the case, you can try to use the Parse method on XDocument which is for parsing XML out of a string.
```
string myResult = "<?xml blahblahblah>";
XDocument doc = XDocument.Parse(myResult);
```
This may or may not solve your problem. Just ... |
459,411 | <p>I have a set of 10 CSV files, which normally have a an entry of this kind</p>
<pre><code>a,b,c,d
d,e,f,g
</code></pre>
<p>Now due to some error entries in this file have become of this kind</p>
<pre><code>a,b,c,d
d,e,f,g
,,,
h,i,j,k
</code></pre>
<p>Now I want to remove the line with only commas in all the files... | [
{
"answer_id": 459418,
"author": "wnoise",
"author_id": 15464,
"author_profile": "https://Stackoverflow.com/users/15464",
"pm_score": 2,
"selected": false,
"text": "<pre><code>sed 's/,,,/replacement/' < old-file.csv > new-file.csv\n</code></pre>\n\n<p>optionally followed by \n m... | 2009/01/19 | [
"https://Stackoverflow.com/questions/459411",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43756/"
] | I have a set of 10 CSV files, which normally have a an entry of this kind
```
a,b,c,d
d,e,f,g
```
Now due to some error entries in this file have become of this kind
```
a,b,c,d
d,e,f,g
,,,
h,i,j,k
```
Now I want to remove the line with only commas in all the files. These files are on a Linux filesystem.
Any co... | It depends on what you mean by replace. If you mean 'remove', then a trivial variant on @wnoise's solution is:
```
grep -v '^,,,$' old-file.csv > new-file.csv
```
Note that this deletes just those lines with exactly three commas. If you want to delete mal-formed lines with any number of commas (including zero) - and... |
459,427 | <p>I have the following which errors on the "rTemp.Value = vaTemp" line. What am I doing wrong here? Am I on the right track?</p>
<pre><code>Function CreateTempRange(rSource As range) As range
' Declarations
Dim rTemp As range
Dim vaTemp As Variant
Dim wsTemp As Worksheet
Dim wbTemp As Workbook
... | [
{
"answer_id": 460303,
"author": "Mark Nold",
"author_id": 4134,
"author_profile": "https://Stackoverflow.com/users/4134",
"pm_score": 1,
"selected": false,
"text": "<pre><code>Set rTemp = wsTemp.range(\"A1\").Resize(UBound(vaTemp, 1), UBound(vaTemp, 2)\n</code></pre>\n\n<p>There'll be a... | 2009/01/19 | [
"https://Stackoverflow.com/questions/459427",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1946/"
] | I have the following which errors on the "rTemp.Value = vaTemp" line. What am I doing wrong here? Am I on the right track?
```
Function CreateTempRange(rSource As range) As range
' Declarations
Dim rTemp As range
Dim vaTemp As Variant
Dim wsTemp As Worksheet
Dim wbTemp As Workbook
' Open temp ... | ```
Set rTemp = wsTemp.range("A1").Resize(UBound(vaTemp, 1), UBound(vaTemp, 2)
```
There'll be a type mismatch here ... i'm not sure it really makes any sense. ubound(a,2) is used for multi-dimensional arrays not ranges.
I'm guessing you want to take the value in the cell specified then copy it many times depending ... |
459,442 | <p>We are trying to build a Help Desk ticketing system just for intranet. Deciding upon the ASP .NET (C#) with Visual Studio 2008 Express (think we have a full version floating around if we need it). Nothing fancy, couple of pages grabbing NTLM information, system information and storing it along with their problem in ... | [
{
"answer_id": 459450,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 2,
"selected": false,
"text": "<p>The admin is nuts. Access is an <code>in-process</code> database, and as such is not well suited for web sites whe... | 2009/01/19 | [
"https://Stackoverflow.com/questions/459442",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | We are trying to build a Help Desk ticketing system just for intranet. Deciding upon the ASP .NET (C#) with Visual Studio 2008 Express (think we have a full version floating around if we need it). Nothing fancy, couple of pages grabbing NTLM information, system information and storing it along with their problem in a d... | I also suggest using SQL Server, but considering your problem:
What is your problem writing an INSERT query for Access ?
You should make use of the classes that you'll find in the System.Data.OleDb namespace:
* OleDbConnection
* OleDbCommand
Quick'n dirty code (not compiled whatsoever):
```
OleDbConnection conn = ne... |
459,447 | <p>I am attempting to open/collapse sections of my site that are fieldsets with the click event on the legend tag. However I'm going to need to use a wrapInner to add a div inside the fieldset to hide the content...however this also hides the legend (which I definately dont want to do) :-). How can I use wrapInner but ... | [
{
"answer_id": 459469,
"author": "Pim Jager",
"author_id": 35197,
"author_profile": "https://Stackoverflow.com/users/35197",
"pm_score": 2,
"selected": false,
"text": "<pre><code>$('#mainarea fieldset').children(':gt(0)').wrapAll(\"<div class='fieldsetWrapper'></div>\");\n</c... | 2009/01/19 | [
"https://Stackoverflow.com/questions/459447",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am attempting to open/collapse sections of my site that are fieldsets with the click event on the legend tag. However I'm going to need to use a wrapInner to add a div inside the fieldset to hide the content...however this also hides the legend (which I definately dont want to do) :-). How can I use wrapInner but spe... | In response to your comments in Pim's example, you need to loop through the fieldsets
```
$('#mainarea fieldset').each(function(){
$(this).children().not('legend').wrapAll("<div class='fieldsetWrapper'></div>");
});
```
You could probably refactor that to something like this;
```
$('#mainarea fieldset').each(fun... |
459,457 | <p>What is a <em>"stored procedure"</em> and how do they work? </p>
<p>What is the make-up of a stored procedure (things each <em>must</em> have to be a stored procedure)?</p>
| [
{
"answer_id": 459498,
"author": "Dave Swersky",
"author_id": 34796,
"author_profile": "https://Stackoverflow.com/users/34796",
"pm_score": 5,
"selected": false,
"text": "<p>Generally, a stored procedure is a \"SQL Function.\" They have:</p>\n\n<pre><code>-- a name\nCREATE PROCEDURE spG... | 2009/01/19 | [
"https://Stackoverflow.com/questions/459457",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16587/"
] | What is a *"stored procedure"* and how do they work?
What is the make-up of a stored procedure (things each *must* have to be a stored procedure)? | Stored procedures are a batch of SQL statements that can be executed in a couple of ways. Most major DBMs support stored procedures; however, not all do. You will need to verify with your particular DBMS help documentation for specifics. As I am most familiar with SQL Server I will use that as my samples.
To create a... |
459,478 | <p>I've been using Vim for a while, and I can't get proper HTML indentation working in PHP files.</p>
<p>For example, what I want is for each child to be indented one tab more than it's parent, as shown below.</p>
<pre><code><?php
if(isset($sports)) {
//Do something
?>
<div>
<label>Uniform S... | [
{
"answer_id": 459890,
"author": "bobince",
"author_id": 18936,
"author_profile": "https://Stackoverflow.com/users/18936",
"pm_score": 2,
"selected": false,
"text": "<p>php-correct-indenting only cares about your PHP, and assumes the readability of the HTML is of no interest. An XML inde... | 2009/01/19 | [
"https://Stackoverflow.com/questions/459478",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/56872/"
] | I've been using Vim for a while, and I can't get proper HTML indentation working in PHP files.
For example, what I want is for each child to be indented one tab more than it's parent, as shown below.
```
<?php
if(isset($sports)) {
//Do something
?>
<div>
<label>Uniform Size</label>
<ul>
<li class=... | This still bothers me. I only *just* decided that the best work-around (for me personally) is this:
```
:set filetype=html
```
And then highlight your text and hit `=`. BOOM! HTML formatting succes. (Not ideal, I know, but at least it works.) |
459,480 | <p>We are using a programming language that does not have a linear regression function in it. We have already implemented a single variable linear equation:</p>
<blockquote>
<p>y = Ax + B</p>
</blockquote>
<p>and have simply calculated the A and B coefficents from the data using a solution similar to <a href="https... | [
{
"answer_id": 459613,
"author": "duffymo",
"author_id": 37213,
"author_profile": "https://Stackoverflow.com/users/37213",
"pm_score": 2,
"selected": false,
"text": "<p>Yes, it's an easy linear algebra problem if you think of it the way <a href=\"http://videolectures.net/mit18085f07_stra... | 2009/01/19 | [
"https://Stackoverflow.com/questions/459480",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30176/"
] | We are using a programming language that does not have a linear regression function in it. We have already implemented a single variable linear equation:
>
> y = Ax + B
>
>
>
and have simply calculated the A and B coefficents from the data using a solution similar to [this Stack Overflow answer](https://stackover... | so you have three linear equations
```
k = aX1 + bY1 + cZ1
k = aX2 + bY2 + cZ2
k = aX3 + bY3 + cZ3
```
What you can do is rewrite it as matriz
```
| x1 y1 z1 | | a | | k |
| x2 y2 z2 | | b | = | k |
| x3 y3 y3 | | c | | k |
```
to work out `[a b c ]` do the following matrix operation
```
| a | |... |
459,482 | <p>Visual Studio 2008 does a much better job of detecting and adding controls from projects to the toolbox for use in the forms designer. If you have an assembly with a UserControl- or DataSet-derived type, then it will automatically detect and add that control to the toolbox for designing forms. This is <em>slightly</... | [
{
"answer_id": 459497,
"author": "Lusid",
"author_id": 56855,
"author_profile": "https://Stackoverflow.com/users/56855",
"pm_score": 1,
"selected": false,
"text": "<p>Go through the toolbox and for each custom control that you see that you want to hide, add the following attribute above ... | 2009/01/19 | [
"https://Stackoverflow.com/questions/459482",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8668/"
] | Visual Studio 2008 does a much better job of detecting and adding controls from projects to the toolbox for use in the forms designer. If you have an assembly with a UserControl- or DataSet-derived type, then it will automatically detect and add that control to the toolbox for designing forms. This is *slightly* better... | The following attribute should hide it from the toolbox:
```
[ToolboxItem(false)]
```
If you apply it to all the types you don't want to show, it will still show any new ones you create without this attribute. Note, you may have to manually remove the items to start with.
This [blog post](http://www.west-wind.com/W... |
459,483 | <p>I'm still new to the API and I wanted to ask:</p>
<ul>
<li>Can you send a text message programmatically?</li>
<li>Can you access the users contact list programmatically?</li>
</ul>
<p>I'm thinking <strong>no</strong>. I haven't seen anything about text messaging in the API, and I figure the sandboxing that the iP... | [
{
"answer_id": 459500,
"author": "brian",
"author_id": 53224,
"author_profile": "https://Stackoverflow.com/users/53224",
"pm_score": 4,
"selected": true,
"text": "<p>1) I'm afraid you can't send SMS with the iPhone SDK although you can make a link to send an SMS like so:</p>\n\n<pre><cod... | 2009/01/19 | [
"https://Stackoverflow.com/questions/459483",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/568/"
] | I'm still new to the API and I wanted to ask:
* Can you send a text message programmatically?
* Can you access the users contact list programmatically?
I'm thinking **no**. I haven't seen anything about text messaging in the API, and I figure the sandboxing that the iPhone does keeps you away from the phones contact ... | 1) I'm afraid you can't send SMS with the iPhone SDK although you can make a link to send an SMS like so:
```
a href="sms:408-555-5555">408 555 5555</a>
```
2) You can access the contact list with the [Address Book UI framework](http://developer.apple.com/iphone/library/documentation/ContactData/Conceptual... |
459,493 | <p>There are Mac GUI applications which provide a front-end to more geeky commandline tools (often included as a part of the application package). I would like to look at what is happening under the hood of such GUIs.</p>
<p>How to "attach" to an application, monitor it for calls to command line utilities and log a fi... | [
{
"answer_id": 459505,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "<p>You could use dtrace to monitor the exec*() system calls and display the arguments when they're invoked. dtrace is document... | 2009/01/19 | [
"https://Stackoverflow.com/questions/459493",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2025531/"
] | There are Mac GUI applications which provide a front-end to more geeky commandline tools (often included as a part of the application package). I would like to look at what is happening under the hood of such GUIs.
How to "attach" to an application, monitor it for calls to command line utilities and log a filename and... | DTrace can do the job. Based on the discussion I had with Joey Hagedorn in the comments elsewhere on this question, the script that comes with 10.6 can be improved to work with a reasonable number of arguments (50+). Because the script has a lot of repetition, I'll include here a script which outputs the DTrace script ... |
459,503 | <p>Let's say I have the following class structure:</p>
<pre><code>class Car;
class FooCar : public Car;
class BarCar : public Car;
class Engine;
class FooEngine : public Engine;
class BarEngine : public Engine;
</code></pre>
<p>Let's also give a <code>Car</code> a handle to its <code>Engine</code>. A <code>FooCar</... | [
{
"answer_id": 459509,
"author": "Calyth",
"author_id": 45144,
"author_profile": "https://Stackoverflow.com/users/45144",
"pm_score": 2,
"selected": false,
"text": "<p>Would it be possible for the FooCar to use the BarEngine?</p>\n\n<p>If not, you might want to use an AbstractFactory to ... | 2009/01/19 | [
"https://Stackoverflow.com/questions/459503",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46821/"
] | Let's say I have the following class structure:
```
class Car;
class FooCar : public Car;
class BarCar : public Car;
class Engine;
class FooEngine : public Engine;
class BarEngine : public Engine;
```
Let's also give a `Car` a handle to its `Engine`. A `FooCar` will be created with a `FooEngine*` and a `BarCar` wil... | I'm assuming that Car holds an Engine pointer, and that's why you find yourself downcasting.
Take the pointer out of your base class and replace it with a pure virtual get\_engine() function. Then your FooCar and BarCar can hold pointers to the correct engine type.
**(Edit)**
Why this works:
Since the virtual funct... |
459,508 | <p>I'm looking for a good tutorial on writing and designing loops. I understand the basics of loops but nested loops give me a lot of trouble. To give you and idea, the following pattern below was kind of difficult for me to figure out.</p>
<p>1<br>
12<br>
123<br>
1234<br>
12345<br>
123456 </p>
| [
{
"answer_id": 459518,
"author": "Jan Hančič",
"author_id": 185527,
"author_profile": "https://Stackoverflow.com/users/185527",
"pm_score": 0,
"selected": false,
"text": "<p>I don't remember seeing any \"loop design\" centred tutorials when I was learning to program.\nYou will get a gras... | 2009/01/19 | [
"https://Stackoverflow.com/questions/459508",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm looking for a good tutorial on writing and designing loops. I understand the basics of loops but nested loops give me a lot of trouble. To give you and idea, the following pattern below was kind of difficult for me to figure out.
1
12
123
1234
12345
123456 | **Loops**
A loop is a construct that enables a set of instructions to be executed more than once.
There are several loop constructions:
*zero or more*
These loops have the check at the begining of an iteration and as such will be executed 0 or more times. A while loop is an example.
*one or more*
These loops have ... |
459,524 | <p>I'm trying to use an Excel Macro to reformat a spreadsheet exported using OLE-Automation</p>
<p>The following code works OK:</p>
<pre><code>Application.FindFormat.NumberFormat = "#,##0.0000000"
Application.ReplaceFormat.NumberFormat = "#,##0.00"
Cells.Replace What:="", Replacement:="", LookAt:=xlPart, SearchOrder:... | [
{
"answer_id": 459518,
"author": "Jan Hančič",
"author_id": 185527,
"author_profile": "https://Stackoverflow.com/users/185527",
"pm_score": 0,
"selected": false,
"text": "<p>I don't remember seeing any \"loop design\" centred tutorials when I was learning to program.\nYou will get a gras... | 2009/01/19 | [
"https://Stackoverflow.com/questions/459524",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22545/"
] | I'm trying to use an Excel Macro to reformat a spreadsheet exported using OLE-Automation
The following code works OK:
```
Application.FindFormat.NumberFormat = "#,##0.0000000"
Application.ReplaceFormat.NumberFormat = "#,##0.00"
Cells.Replace What:="", Replacement:="", LookAt:=xlPart, SearchOrder:= _
xlByRows, Mat... | **Loops**
A loop is a construct that enables a set of instructions to be executed more than once.
There are several loop constructions:
*zero or more*
These loops have the check at the begining of an iteration and as such will be executed 0 or more times. A while loop is an example.
*one or more*
These loops have ... |
459,530 | <p>Why does the compiler give me the following error message on the provided code: "initializer element is not constant". The corresponding C/C++ code compiles perfectly under gcc.</p>
<pre><code>#import <Foundation/Foundation.h>
const float a = 1;
const float b = a + a; // <- error here
int main (int argc... | [
{
"answer_id": 459611,
"author": "dreamlax",
"author_id": 10320,
"author_profile": "https://Stackoverflow.com/users/10320",
"pm_score": 5,
"selected": true,
"text": "<p>That code will only compile correctly if the <code>const float</code> statements appear somewhere other than the file s... | 2009/01/19 | [
"https://Stackoverflow.com/questions/459530",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/56875/"
] | Why does the compiler give me the following error message on the provided code: "initializer element is not constant". The corresponding C/C++ code compiles perfectly under gcc.
```
#import <Foundation/Foundation.h>
const float a = 1;
const float b = a + a; // <- error here
int main (int argc, const char * argv[]) {... | That code will only compile correctly if the `const float` statements appear somewhere other than the file scope.
It is part of the standard, apparently. It is important that all file-scope declared variables are initialised with constant expressions, not expressions involving constant variables.
You are initialising... |
459,537 | <p>Is there a way to programatically clear the buffer cache on the Mac, preferrably in C?</p>
<p>Basically, I'm looking for the equivalent of the source of 10.5 (and greater)'s <code>purge</code> command. <strong>EDIT:</strong> I now see this is part of the CHUD tools, for which it seems the source isn't directly avai... | [
{
"answer_id": 459565,
"author": "Keltia",
"author_id": 16143,
"author_profile": "https://Stackoverflow.com/users/16143",
"pm_score": 2,
"selected": false,
"text": "<p>You could use <code>sync(2)</code> several times (as in the well-known idiom <code>sync; sync; sync</code>). I can't se... | 2009/01/19 | [
"https://Stackoverflow.com/questions/459537",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49485/"
] | Is there a way to programatically clear the buffer cache on the Mac, preferrably in C?
Basically, I'm looking for the equivalent of the source of 10.5 (and greater)'s `purge` command. **EDIT:** I now see this is part of the CHUD tools, for which it seems the source isn't directly available. However, I'm still looking ... | I've disassembled the function in question (`_utilPurgeDiskBuffers`) from the CHUD framework. The function doesn't seem to be very complex, but since I'm no MacOS programmer, the imports and called sys APIs don't make much sense to me.
The first thing the API does is to call another function, namely `_miscUtilsUserCl... |
459,552 | <p><em>I was having trouble parsing some dodgy HTML with BeautifulSoup. Turns out that the HTMLParser used in newer versions is less tolerant than the SGMLParser used previously.</em></p>
<hr>
<p>Does BeautifulSoup have some kind of debug mode? I'm trying to figure out how to stop it borking on some nasty HTML I'm lo... | [
{
"answer_id": 459642,
"author": "ShreevatsaR",
"author_id": 4958,
"author_profile": "https://Stackoverflow.com/users/4958",
"pm_score": 3,
"selected": true,
"text": "<p>Your problem must be something else; it works fine for me: </p>\n\n<pre><code>In [1]: import BeautifulSoup\n\nIn [2]: ... | 2009/01/19 | [
"https://Stackoverflow.com/questions/459552",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42974/"
] | *I was having trouble parsing some dodgy HTML with BeautifulSoup. Turns out that the HTMLParser used in newer versions is less tolerant than the SGMLParser used previously.*
---
Does BeautifulSoup have some kind of debug mode? I'm trying to figure out how to stop it borking on some nasty HTML I'm loading from a crabb... | Your problem must be something else; it works fine for me:
```
In [1]: import BeautifulSoup
In [2]: c = """<HTML>
...: <HEAD>
...: <TITLE>Title</TITLE>
...: <HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
...: </HEAD>
...: <BODY>
...: ...
...: ...
...: ... |
459,554 | <p>How do i tell if one instance of my program is running?
I thought I could do this with a data file but it would just be messy :(</p>
<p>I want to do this as I only want 1 instance to ever be open at one point.</p>
| [
{
"answer_id": 459561,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 3,
"selected": false,
"text": "<p>The normal solution is to create a <em>named, system-wide</em> <strong>mutex</strong>.</p>\n<ul>\n<li>If you manage t... | 2009/01/19 | [
"https://Stackoverflow.com/questions/459554",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53915/"
] | How do i tell if one instance of my program is running?
I thought I could do this with a data file but it would just be messy :(
I want to do this as I only want 1 instance to ever be open at one point. | You can create a Semaphore and stop execution (put the code into your \*.dpr file) and bring you running application to the screen.
```
var
Semafor: THandle;
begin
{ Don't start twice ... if already running bring this instance to front }
Semafor := CreateSemaphore(nil, 0, 1, 'MY_APPLICATION_IS_RUNNING');
if (... |
459,572 | <p>I'm trying to determine at runtime what the SqlDbType of a sql server table column is.</p>
<p>is there a class that can do that in System.Data.SqlClient or should I do the mapping myself? I can get a string representation back from </p>
<pre><code>SELECT DATA_TYPE, CHARACTER_MAXIMUM_LENGTH
FROM INFORMATION_SCHEMA.... | [
{
"answer_id": 459602,
"author": "rp.",
"author_id": 2536,
"author_profile": "https://Stackoverflow.com/users/2536",
"pm_score": 1,
"selected": false,
"text": "<p>For SQL Server, use the SMO (SQL Server Management Objects).</p>\n\n<p><a href=\"http://www.yukonxml.com/articles/smo/\" rel=... | 2009/01/19 | [
"https://Stackoverflow.com/questions/459572",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46255/"
] | I'm trying to determine at runtime what the SqlDbType of a sql server table column is.
is there a class that can do that in System.Data.SqlClient or should I do the mapping myself? I can get a string representation back from
```
SELECT DATA_TYPE, CHARACTER_MAXIMUM_LENGTH
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABL... | In SQL Server you can use the FMTONLY option. It allows you to run a query without getting any data, just returning the columns.
```
SqlCommand cmd = connection.CreateCommand();
cmd.CommandText = "SET FMTONLY ON; select column from table; SET FMTONLY OFF";
SqlDataReader reader = cmd.ExecuteReader();
SqlDbType type = (... |
459,573 | <p>I have a web service implemented in ASP.NET 2.0 and have pre-compiled it using the aspnet_compiler.</p>
<p>I have no clue now how to deploy it to IIS, can someone point me in the right direction? I am using IIS 6.0 on a Windows Server 2003 machine.</p>
<p>I have placed the pre-compiled files into a virtual directo... | [
{
"answer_id": 459618,
"author": "Robert Wagner",
"author_id": 10784,
"author_profile": "https://Stackoverflow.com/users/10784",
"pm_score": 2,
"selected": false,
"text": "<p>You can either copy the contents of the output directory into the virtual directory on IIS and it should all just... | 2009/01/19 | [
"https://Stackoverflow.com/questions/459573",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1638/"
] | I have a web service implemented in ASP.NET 2.0 and have pre-compiled it using the aspnet\_compiler.
I have no clue now how to deploy it to IIS, can someone point me in the right direction? I am using IIS 6.0 on a Windows Server 2003 machine.
I have placed the pre-compiled files into a virtual directory, when I acces... | You can either copy the contents of the output directory into the virtual directory on IIS and it should all just work. You will need to set up the App Pool and configure the virtual directory for ASP.NET just like a non-compiled website. Make sure you delete everything from the virtual directory (if there was a previo... |
459,574 | <p>I'm working with linq to sql, and therefore need to store my DataContext for future use for each thread (I've read this article: <a href="http://www.west-wind.com/weblog/posts/246222.aspx" rel="nofollow noreferrer">http://www.west-wind.com/weblog/posts/246222.aspx</a>
regarding ways to implement a shared context). ... | [
{
"answer_id": 459601,
"author": "Andrew Hare",
"author_id": 34211,
"author_profile": "https://Stackoverflow.com/users/34211",
"pm_score": 0,
"selected": false,
"text": "<p>Well it sounds like you want to look at <code>Page.Cache</code>. This is a collection that is available at an appl... | 2009/01/19 | [
"https://Stackoverflow.com/questions/459574",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm working with linq to sql, and therefore need to store my DataContext for future use for each thread (I've read this article: <http://www.west-wind.com/weblog/posts/246222.aspx>
regarding ways to implement a shared context). What I want to know though, is how do I create a single key that both the global.asax file ... | Have you considered something like the IContainerAccessor from the Castle.Windsor framework?
Then you can do something like
```
public class GlobalApplication : System.Web.HttpApplication, IContainerAccessor
{
private static readonly WindsorContainer _container = new WindsorContainer(new XmlInterpreter(new... |
459,580 | <p>I would like to call C# service with using PHP, anyone know how to do it? Thanks</p>
| [
{
"answer_id": 459599,
"author": "Eclipse",
"author_id": 8701,
"author_profile": "https://Stackoverflow.com/users/8701",
"pm_score": 3,
"selected": true,
"text": "<p>Create an SOAP XML document that matches up with the WSDL and send it via HTTP POST.\nSee <a href=\"http://www.w3schools.c... | 2009/01/19 | [
"https://Stackoverflow.com/questions/459580",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/52745/"
] | I would like to call C# service with using PHP, anyone know how to do it? Thanks | Create an SOAP XML document that matches up with the WSDL and send it via HTTP POST.
See [here for an example](http://www.w3schools.com/webservices/tempconvert.asmx?op=CelsiusToFahrenheit).
You send this:
```
POST /webservices/tempconvert.asmx HTTP/1.1
Host: www.w3schools.com
Content-Type: application/soap+xml; chars... |
459,589 | <p>I have a <code>TreeView</code> within a <code>UserForm</code> in Excel.
When a Node is selected from the <code>TreeView</code>, a <code>ListBox</code> is populated with data.<br/>
When an item in the <code>ListBox</code> is double-clicked, a separate <code>UserForm</code> is shown which allows the user do to stuff.<... | [
{
"answer_id": 459723,
"author": "Ryan",
"author_id": 29762,
"author_profile": "https://Stackoverflow.com/users/29762",
"pm_score": 1,
"selected": false,
"text": "<p>You have several options. First, when the TreeView UserForm displays the second UserForm, you either need to:</p>\n\n<ol>\... | 2009/01/19 | [
"https://Stackoverflow.com/questions/459589",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23597/"
] | I have a `TreeView` within a `UserForm` in Excel.
When a Node is selected from the `TreeView`, a `ListBox` is populated with data.
When an item in the `ListBox` is double-clicked, a separate `UserForm` is shown which allows the user do to stuff.
Once the user returns back to the `TreeView UserForm`, I want the `N... | I know this is an old question but i had trouble enough finding a decent answer myself so here we go. Index or Key's are not always available. On create I place the fullpath of the node in the node.tag. On double-click I recall the tag value, later on I search the treeview node collection for the tag. To much? not effi... |
459,590 | <pre><code>module Superpower
# instance method
def turn_invisible
...
end
# module method
def Superpower.turn_into_toad
...
end
module Fly
def flap_wings
...
end
end
end
Class Superman
include Superpower
...
def run_away
... | [
{
"answer_id": 459617,
"author": "Keltia",
"author_id": 16143,
"author_profile": "https://Stackoverflow.com/users/16143",
"pm_score": 1,
"selected": false,
"text": "<p>You want to read the documentation on mixins which are a way to workaround the fact that Ruby has only single inheritanc... | 2009/01/19 | [
"https://Stackoverflow.com/questions/459590",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11927/"
] | ```
module Superpower
# instance method
def turn_invisible
...
end
# module method
def Superpower.turn_into_toad
...
end
module Fly
def flap_wings
...
end
end
end
Class Superman
include Superpower
...
def run_away
# ho... | I'm assuming that when you say embedding a module you mean the "Fly" module from your example is embedded in "Superpower".
If that is the case, I would call it a nested module. The only time I would use a Nested Module is when the nested module deals specifically with the main module, such that the code in Fly is dire... |
459,608 | <p>I'm writing a little web app with webpy, and I'm wondering if anyone has any information on a little problem I'm having.</p>
<p>I've written a little ORM system, and it seems to be working pretty well. Ideally I'd like to stitch it in with webpy, but it appears that just using it as is causes thread issues (DB conn... | [
{
"answer_id": 460713,
"author": "codeape",
"author_id": 3571,
"author_profile": "https://Stackoverflow.com/users/3571",
"pm_score": 2,
"selected": false,
"text": "<p>I'll give this one a try. Disclaimer: I have no experience with the web.py framework.</p>\n\n<p>I suggest you try the fol... | 2009/01/19 | [
"https://Stackoverflow.com/questions/459608",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/56349/"
] | I'm writing a little web app with webpy, and I'm wondering if anyone has any information on a little problem I'm having.
I've written a little ORM system, and it seems to be working pretty well. Ideally I'd like to stitch it in with webpy, but it appears that just using it as is causes thread issues (DB connection is ... | We use SQLAlchemy with web.py and use hooks to create and close db connections per request. SQLAlchemy handles pooling, so not every connection is a tcp connection.
The thread local storage you want to use is web.ctx ie. any time you access web.ctx you only see properties set by that thread.
Our code looks something ... |
459,634 | <p>We have an application which we are developing in C#. We store all resources in a central resource DLL, the resource contains images, icons and strings from which we support multiple cultures.</p>
<p>We access the resources from any project in the solution using the following code;</p>
<pre><code>private ResourceM... | [
{
"answer_id": 459645,
"author": "ChrisW",
"author_id": 49942,
"author_profile": "https://Stackoverflow.com/users/49942",
"pm_score": 2,
"selected": false,
"text": "<p>Look at the reference documentation for each of these APIs, to see the list of exceptions which each API can throw.</p>\... | 2009/01/19 | [
"https://Stackoverflow.com/questions/459634",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | We have an application which we are developing in C#. We store all resources in a central resource DLL, the resource contains images, icons and strings from which we support multiple cultures.
We access the resources from any project in the solution using the following code;
```
private ResourceManager ResMan;
ResMan... | Look at the reference documentation for each of these APIs, to see the list of exceptions which each API can throw. |
459,643 | <p>I am writing this java program to find all the prime numbers up to num using the Sieve of Eratosthenes, but when I try to compile, it says I can't use a long var as an array index, and it expects an int var in its place. But I'll be working with large numbers, so I can't use int. What can I do?</p>
<pre><code>impor... | [
{
"answer_id": 459651,
"author": "Uri",
"author_id": 23072,
"author_profile": "https://Stackoverflow.com/users/23072",
"pm_score": 5,
"selected": true,
"text": "<p>I'm not sure why your code would compile to begin with.</p>\n\n<p>You're not supposed to use [] in an array list to access m... | 2009/01/19 | [
"https://Stackoverflow.com/questions/459643",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27090/"
] | I am writing this java program to find all the prime numbers up to num using the Sieve of Eratosthenes, but when I try to compile, it says I can't use a long var as an array index, and it expects an int var in its place. But I'll be working with large numbers, so I can't use int. What can I do?
```
import java.util.*;... | I'm not sure why your code would compile to begin with.
You're not supposed to use [] in an array list to access members. An arraylist is merely a list that is internally stored in an array. You have to use the list get operation (which would still be O(1)). Writing numlist[index] means that you have an array of objec... |
459,649 | <pre><code>typedef void (FunctionSet::* Function)();
class MyFunctionSet : public FunctionSet
{
protected:
void addFunctions()
{
addFunction(Function(&MyFunctionSet::function1));
}
void function1()
{
// Do something.
}
};
</code></pre>
<p>The addFunction method adds the fu... | [
{
"answer_id": 459655,
"author": "mmr",
"author_id": 21981,
"author_profile": "https://Stackoverflow.com/users/21981",
"pm_score": 1,
"selected": false,
"text": "<p>You could overload the addition operator, I suppose.</p>\n"
},
{
"answer_id": 459664,
"author": "Uri",
"aut... | 2009/01/19 | [
"https://Stackoverflow.com/questions/459649",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47064/"
] | ```
typedef void (FunctionSet::* Function)();
class MyFunctionSet : public FunctionSet
{
protected:
void addFunctions()
{
addFunction(Function(&MyFunctionSet::function1));
}
void function1()
{
// Do something.
}
};
```
The addFunction method adds the function to a list in the... | Looks like you assign a member function pointer to a function of the derived class to a member function pointer to a function of the base class. Well, that's forbidden, because it opens up a hole in the type-system. It comes at a surprise (at least for me, the first time i heard that). Read [this answer](https://stacko... |
459,652 | <p>I was looking at C# collection initializers and found the implementation to be very pragmatic but also very unlike anything else in C#</p>
<p>I am able to create code like this:</p>
<pre><code>using System;
using System.Collections;
class Program
{
static void Main()
{
Test test = new Test { 1, 2,... | [
{
"answer_id": 459697,
"author": "Bevan",
"author_id": 30280,
"author_profile": "https://Stackoverflow.com/users/30280",
"pm_score": 8,
"selected": true,
"text": "<p>Your observation is spot on - in fact, it mirrors one made by Mads Torgersen, a Microsoft C# Language PM.</p>\n\n<p>Mads m... | 2009/01/19 | [
"https://Stackoverflow.com/questions/459652",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34211/"
] | I was looking at C# collection initializers and found the implementation to be very pragmatic but also very unlike anything else in C#
I am able to create code like this:
```
using System;
using System.Collections;
class Program
{
static void Main()
{
Test test = new Test { 1, 2, 3 };
}
}
class ... | Your observation is spot on - in fact, it mirrors one made by Mads Torgersen, a Microsoft C# Language PM.
Mads made a post in October 2006 on this subject titled *[What Is a Collection?](http://blogs.msdn.com/madst/archive/2006/10/10/What-is-a-collection_3F00_.aspx)* in which he wrote:
>
> Admitted, we blew it in th... |
459,667 | <p>I would like to have pretty URLs for my tagging system along with all the special characters: <code>+</code>, <code>&</code>, <code>#</code>, <code>%</code>, and <code>=</code>. Is there a way to do this with mod_rewrite without having to double encode the links?</p>
<p>I notice that delicious.com and stackover... | [
{
"answer_id": 459696,
"author": "David Z",
"author_id": 56541,
"author_profile": "https://Stackoverflow.com/users/56541",
"pm_score": 3,
"selected": false,
"text": "<p>I'm not sure I understand what you're asking, but the <code>NE</code> (noescape) flag to Apache's <code>RewriteRule</co... | 2009/01/19 | [
"https://Stackoverflow.com/questions/459667",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4133/"
] | I would like to have pretty URLs for my tagging system along with all the special characters: `+`, `&`, `#`, `%`, and `=`. Is there a way to do this with mod\_rewrite without having to double encode the links?
I notice that delicious.com and stackoverflow seem to be able to handle singly encoded special characters. Wh... | >
> The normal operation of apache/mod\_rewrite doesn't work like this, as it seems to turn the plus signs into spaces.
>
>
>
I don't think that's quite what's happening. Apache is decoding the %2Bs to +s in the path part since + is a valid character there. It does this before letting mod\_rewrite look at the requ... |
459,668 | <p>I'm coming to learn Perl from a Python background where the following hash-to-string conversion is built in to the language:</p>
<pre><code>>>> d = {'a': 1, 'b': 2, 'c': 3}
>>> str(d)
"{'a': 1, 'c': 3, 'b': 2}"
</code></pre>
<p>Is there a builtin and/or module that has a subroutine with output al... | [
{
"answer_id": 459681,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 4,
"selected": false,
"text": "<p>There is the <a href=\"http://search.cpan.org/dist/Data-Dumper/\" rel=\"noreferrer\"><code>Data::Dumper</code></a> mod... | 2009/01/19 | [
"https://Stackoverflow.com/questions/459668",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3594/"
] | I'm coming to learn Perl from a Python background where the following hash-to-string conversion is built in to the language:
```
>>> d = {'a': 1, 'b': 2, 'c': 3}
>>> str(d)
"{'a': 1, 'c': 3, 'b': 2}"
```
Is there a builtin and/or module that has a subroutine with output along the lines of:
```
"('a' => 1, 'b' => 2,... | ```
use Data::Dumper;
local $Data::Dumper::Terse = 1;
my $str = Dumper({a => 1, b => 2, c => 3});
``` |
459,669 | <p>I'm wondering if it's worth the server time when updating a record to retrieve the existing record, loop through the fields checking for changes and only putting the changed fields in the update query? (I am using MySQL & PHP.)</p>
<p>The main reason for doing this is to reduce the size of the update query for ... | [
{
"answer_id": 459682,
"author": "Sam Cogan",
"author_id": 8768,
"author_profile": "https://Stackoverflow.com/users/8768",
"pm_score": 1,
"selected": false,
"text": "<p>The slowest point in your application is always going to be your database access, so if you can speed that up, it’s a g... | 2009/01/19 | [
"https://Stackoverflow.com/questions/459669",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5441/"
] | I'm wondering if it's worth the server time when updating a record to retrieve the existing record, loop through the fields checking for changes and only putting the changed fields in the update query? (I am using MySQL & PHP.)
The main reason for doing this is to reduce the size of the update query for change log pur... | I think it's worth changing - but probably not worth doing a select before insert.
I only update the fields that have changed, it's part of the operation of my DbEntity class which follows an activerecord pattern. It costs little extra to do this because I hold the current record and original records -simply copying w... |
459,674 | <p>I have a problem binding booleans using <code>mysqli_stmt::bind_param</code> in PHP5.</p>
<p>The SQL query is the following:</p>
<pre><code>insert into `nvp_notes` (subject,messageid,receivedate,read) values (?,?,?,?)
</code></pre>
<p>Where 'read' is a tinyint, either 0 or 1, as I've had issues with bit using mysqli... | [
{
"answer_id": 459690,
"author": "Paige Ruten",
"author_id": 813,
"author_profile": "https://Stackoverflow.com/users/813",
"pm_score": 4,
"selected": false,
"text": "<p>You could convert the boolean to a 1 or 0 using <a href=\"http://php.net/intval\" rel=\"noreferrer\">intval()</a> (or c... | 2009/01/19 | [
"https://Stackoverflow.com/questions/459674",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a problem binding booleans using `mysqli_stmt::bind_param` in PHP5.
The SQL query is the following:
```
insert into `nvp_notes` (subject,messageid,receivedate,read) values (?,?,?,?)
```
Where 'read' is a tinyint, either 0 or 1, as I've had issues with bit using mysqli. So the types that I list in bind\_param... | You could convert the boolean to a 1 or 0 using [intval()](http://php.net/intval) (or cast it with *(int)* or *(integer)*). According to [mysqli\_stmt::bind\_param()'s documentation](http://ca.php.net/manual/en/mysqli-stmt.bind-param.php), the only types you may bind are ints, doubles, strings, and blobs. |
459,677 | <p>I am using the <code>String.Split()</code> method in C#. How can I put the resulting <code>string[]</code> into an <code>ArrayList</code> or <code>Stack</code>?</p>
| [
{
"answer_id": 459680,
"author": "Ed S.",
"author_id": 1053,
"author_profile": "https://Stackoverflow.com/users/1053",
"pm_score": 6,
"selected": true,
"text": "<p>You can initialize a <code>List<T></code> with an array (or any other object that implements <code>IEnumerable</code>)... | 2009/01/19 | [
"https://Stackoverflow.com/questions/459677",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/56898/"
] | I am using the `String.Split()` method in C#. How can I put the resulting `string[]` into an `ArrayList` or `Stack`? | You can initialize a `List<T>` with an array (or any other object that implements `IEnumerable`). You should prefer the strongly typed `List<T>` over `ArrayList`.
```
var myList = new List<string>(myString.Split(','));
``` |
459,691 | <p>What is the best way to time a code section with high resolution and portability?</p>
<pre><code>/* Time from here */
ProcessIntenseFunction();
/* to here. */
printf("Time taken %d seconds %d milliseconds", sec, msec);
</code></pre>
<p>Is there a standard library that would have a cross-platform solution?</p>
| [
{
"answer_id": 459703,
"author": "driAn",
"author_id": 50430,
"author_profile": "https://Stackoverflow.com/users/50430",
"pm_score": 1,
"selected": false,
"text": "<p>I use <a href=\"http://www.libsdl.org/cgi/docwiki.cgi/SDL_GetTicks\" rel=\"nofollow noreferrer\">SDL_GetTicks</a> from th... | 2009/01/20 | [
"https://Stackoverflow.com/questions/459691",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2064/"
] | What is the best way to time a code section with high resolution and portability?
```
/* Time from here */
ProcessIntenseFunction();
/* to here. */
printf("Time taken %d seconds %d milliseconds", sec, msec);
```
Is there a standard library that would have a cross-platform solution? | I think this should work:
```
#include <time.h>
clock_t start = clock(), diff;
ProcessIntenseFunction();
diff = clock() - start;
int msec = diff * 1000 / CLOCKS_PER_SEC;
printf("Time taken %d seconds %d milliseconds", msec/1000, msec%1000);
``` |
459,709 | <p>Installing Merb on Ruby Enterprise Edition (OS X) throws this error, any ideas?</p>
<pre><code>sudo gem install merb
ERROR: Error installing merb:
invalid gem format for /opt/ruby-enterprise-1.8.6-20090113/lib/ruby/gems/1.8/cache/ParseTree-3.0.2.gem
</code></pre>
<p>Deleted the gem cache but the problem persiste... | [
{
"answer_id": 459770,
"author": "MatthewFord",
"author_id": 21596,
"author_profile": "https://Stackoverflow.com/users/21596",
"pm_score": 3,
"selected": true,
"text": "<p>Deleting the cache (ruby-enterprise-1.8.6-20090113/lib/ruby/gems/1.8/cache/*) and gem folder in question seems to wo... | 2009/01/20 | [
"https://Stackoverflow.com/questions/459709",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21596/"
] | Installing Merb on Ruby Enterprise Edition (OS X) throws this error, any ideas?
```
sudo gem install merb
ERROR: Error installing merb:
invalid gem format for /opt/ruby-enterprise-1.8.6-20090113/lib/ruby/gems/1.8/cache/ParseTree-3.0.2.gem
```
Deleted the gem cache but the problem persisted. It seemed to manage to ... | Deleting the cache (ruby-enterprise-1.8.6-20090113/lib/ruby/gems/1.8/cache/\*) and gem folder in question seems to work temporarily although now I have this issue with another dependency merb-action-args.. |
459,713 | <p>I wonder if anyone can provide me with the regular expressions needed to parse a string like:</p>
<p>'foo bar "multiple word tag"'</p>
<p>into an array of tags like:</p>
<p>["foo","bar","multiple word tag"]</p>
<p>Thanks</p>
| [
{
"answer_id": 459750,
"author": "JaredPar",
"author_id": 23283,
"author_profile": "https://Stackoverflow.com/users/23283",
"pm_score": -1,
"selected": false,
"text": "<p>A regex will almost certainly not be the solution that you are looking for here. Regex's are useful for parsing a se... | 2009/01/20 | [
"https://Stackoverflow.com/questions/459713",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I wonder if anyone can provide me with the regular expressions needed to parse a string like:
'foo bar "multiple word tag"'
into an array of tags like:
["foo","bar","multiple word tag"]
Thanks | In Ruby
```
scan(/\"([\w ]+)\"|(\w+)/).flatten.compact
```
E.g.
```
"foo bar \"multiple words\" party_like_1999".scan(/\"([\w ]+)\"|(\w+)/).flatten.compact
=> ["foo", "bar", "multiple words", "party_like_1999"]
``` |
459,725 | <p>I am new to functional programming, and now learn Haskell. As an exercise I decided to implement the explicit Euler method for 1D linear diffusion equation. While the code below works correctly, I am not happy about its performance. In fact, I am concerned with memory consumption. I believe that it is related to laz... | [
{
"answer_id": 460253,
"author": "John Mulder",
"author_id": 2242,
"author_profile": "https://Stackoverflow.com/users/2242",
"pm_score": 2,
"selected": false,
"text": "<p>Does forcing \"un-laziness\" using $! help? as per <a href=\"https://stackoverflow.com/questions/412919/how-haskell-t... | 2009/01/20 | [
"https://Stackoverflow.com/questions/459725",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25450/"
] | I am new to functional programming, and now learn Haskell. As an exercise I decided to implement the explicit Euler method for 1D linear diffusion equation. While the code below works correctly, I am not happy about its performance. In fact, I am concerned with memory consumption. I believe that it is related to lazy e... | 1. Lists are not the best datastructure for this type of code (with lots of (++), and (last)). You lose a lot of time constucting and deconstructing lists. I'd use Data.Sequence or arrays, as in C versions.
2. There is no chance for thunks of makeu0 to be garbage-collected, since you need to retain all of them (well, a... |
459,729 | <p>How do I display a list of images using the ListView? I am downloading the images at run time. The total number of images is not fixed.</p>
| [
{
"answer_id": 460927,
"author": "srakyi",
"author_id": 56276,
"author_profile": "https://Stackoverflow.com/users/56276",
"pm_score": 6,
"selected": false,
"text": "<p>I'd start with something like this (and if there is something wrong with my code, I'd of course appreciate any comment):... | 2009/01/20 | [
"https://Stackoverflow.com/questions/459729",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | How do I display a list of images using the ListView? I am downloading the images at run time. The total number of images is not fixed. | I'd start with something like this (and if there is something wrong with my code, I'd of course appreciate any comment):
```
public class ItemsList extends ListActivity {
private ItemsAdapter adapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setConte... |
459,737 | <p>I have two different methods that I want to execute when a user clicks a button. I have them working separately, but when I try to combine the two I get errors. The two ones I have currently are</p>
<pre><code> <%= image_tag('go_button.png',
:id => "search_go_button",
... | [
{
"answer_id": 459941,
"author": "Abie",
"author_id": 53166,
"author_profile": "https://Stackoverflow.com/users/53166",
"pm_score": 1,
"selected": false,
"text": "<p>In the spirit of UJS (even if you're not providing non-javascript functionality here, you can benefit from separating the ... | 2009/01/20 | [
"https://Stackoverflow.com/questions/459737",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have two different methods that I want to execute when a user clicks a button. I have them working separately, but when I try to combine the two I get errors. The two ones I have currently are
```
<%= image_tag('go_button.png',
:id => "search_go_button",
:class => "sea... | In the spirit of UJS (even if you're not providing non-javascript functionality here, you can benefit from separating the javascript from the erb), I would use [Low Pro](http://www.danwebb.net/2006/9/3/low-pro-unobtrusive-scripting-for-prototype) and set these up as behaviors. You'll need to download and include the lo... |
459,739 | <p>DISCLAIMER: The following code is not something I would ever use in a real application. I stumbled on this problem and would like to know what's happening under the hoods.</p>
<p>Let's assume that for some crazy reason we had the following code...</p>
<pre><code>using (System.Net.WebClient webClient = new System.N... | [
{
"answer_id": 459941,
"author": "Abie",
"author_id": 53166,
"author_profile": "https://Stackoverflow.com/users/53166",
"pm_score": 1,
"selected": false,
"text": "<p>In the spirit of UJS (even if you're not providing non-javascript functionality here, you can benefit from separating the ... | 2009/01/20 | [
"https://Stackoverflow.com/questions/459739",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13181/"
] | DISCLAIMER: The following code is not something I would ever use in a real application. I stumbled on this problem and would like to know what's happening under the hoods.
Let's assume that for some crazy reason we had the following code...
```
using (System.Net.WebClient webClient = new System.Net.WebClient())
{
... | In the spirit of UJS (even if you're not providing non-javascript functionality here, you can benefit from separating the javascript from the erb), I would use [Low Pro](http://www.danwebb.net/2006/9/3/low-pro-unobtrusive-scripting-for-prototype) and set these up as behaviors. You'll need to download and include the lo... |
459,743 | <p>Is it safe to assume that <code>NULL</code> always translates to false in C?</p>
<pre><code>void *somePtr = NULL;
if (!somePtr) {
/* This will always be executed? */
}
</code></pre>
<p>Or should an explicit check against the value of <code>NULL</code> be made?</p>
| [
{
"answer_id": 459746,
"author": "akatakritos",
"author_id": 50038,
"author_profile": "https://Stackoverflow.com/users/50038",
"pm_score": 4,
"selected": false,
"text": "<p>It's never safe to assume anything.</p>\n\n<p>An explicit check is also more clear about what you're testing.</p>\n... | 2009/01/20 | [
"https://Stackoverflow.com/questions/459743",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43496/"
] | Is it safe to assume that `NULL` always translates to false in C?
```
void *somePtr = NULL;
if (!somePtr) {
/* This will always be executed? */
}
```
Or should an explicit check against the value of `NULL` be made? | Yes. NULL evaluates to false, since C considers any non-zero value true and any zero value false. NULL is essentially the `zero` address and is treated as such in comparisons, and I believe would be promoted to an int for the boolean check. I would expect that your code is readable to anyone familiar with C although I ... |
459,744 | <p>Lets take a look at the code:</p>
<pre><code>#include <iostream>
#include <fstream>
#include <string>
#include <cstdio>
#include <cstdlib>
using namespace std;
int main()
{
string usrFileStr,
fileStr = "airNames.txt", // declaring string literal
sLine; ... | [
{
"answer_id": 459752,
"author": "Jonathan Leffler",
"author_id": 15168,
"author_profile": "https://Stackoverflow.com/users/15168",
"pm_score": 2,
"selected": false,
"text": "<p>You probably need to clear the error bit on the stream after reading EOF the first time.\nThat is, as well as ... | 2009/01/20 | [
"https://Stackoverflow.com/questions/459744",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40120/"
] | Lets take a look at the code:
```
#include <iostream>
#include <fstream>
#include <string>
#include <cstdio>
#include <cstdlib>
using namespace std;
int main()
{
string usrFileStr,
fileStr = "airNames.txt", // declaring string literal
sLine; // declaring a string obj
fstream ... | You probably need to clear the error bit on the stream after reading EOF the first time.
That is, as well as doing the seek operation. |
459,764 | <p>I'm having significant trouble installing Ruby on Rails. </p>
<p>I installed Ruby with apt-get When I tried installing Ruby Gems, the installer consistently hung indefinitely on installing ri, so I tried installing Ruby from source instead. I had the same problem, so I installed Ruby Gems without ri or RDoc. I don'... | [
{
"answer_id": 459804,
"author": "deizel.",
"author_id": 41874,
"author_profile": "https://Stackoverflow.com/users/41874",
"pm_score": 0,
"selected": false,
"text": "<p>With respect to the <code>getaddrinfo</code> error, this could mean that your machine cannot resolve localhost, or its ... | 2009/01/20 | [
"https://Stackoverflow.com/questions/459764",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm having significant trouble installing Ruby on Rails.
I installed Ruby with apt-get When I tried installing Ruby Gems, the installer consistently hung indefinitely on installing ri, so I tried installing Ruby from source instead. I had the same problem, so I installed Ruby Gems without ri or RDoc. I don't know if ... | I just had this problem myself, and discovered this site:
<http://www.typeoneerror.com/articles/post/updating-rails-error>
Which recommends using the -p switch (it worked for me for both `install` and `update` commands).
I don't see how or why (maybe someone else can explain it?), but it did work for me. Sometimes, ... |
459,777 | <p>I have this showing up all over in my controllers:</p>
<pre><code>if not session[:admin]
flash[:notice] = "You don't have the rights to do #{:action}."
redirect_to :action=>:index
return
end
</code></pre>
<p>And its sibling:</p>
<pre><code>if not session[:user] and not session[:admin]
flash[:notice] = ... | [
{
"answer_id": 459808,
"author": "MatthewFord",
"author_id": 21596,
"author_profile": "https://Stackoverflow.com/users/21596",
"pm_score": 3,
"selected": false,
"text": "<p>Firstly you can do: <code>unless session[:admin]</code> instead of <code>if not ...</code></p>\n\n<p>Then you can h... | 2009/01/20 | [
"https://Stackoverflow.com/questions/459777",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30997/"
] | I have this showing up all over in my controllers:
```
if not session[:admin]
flash[:notice] = "You don't have the rights to do #{:action}."
redirect_to :action=>:index
return
end
```
And its sibling:
```
if not session[:user] and not session[:admin]
flash[:notice] = "You don't have the rights to do #{:acti... | Firstly you can do: `unless session[:admin]` instead of `if not ...`
Then you can have a before filter which calls your method, this method would do your redirect\_to "url" and return.
I have a question, I hope you are not just storing the id of the admin in a session as your the only means of authentication, having ... |
459,783 | <p>I have the need to express simple conditionals as program input. The input must be human readable.</p>
<p>Is XML suited for this?</p>
<p>For example, I have the following conditional statement:</p>
<pre><code>If AnimalType = Leopard And (SourceCountry = Kenya Or TargetCountry = Kenya) Then
ZooKeeper=Jack
Els... | [
{
"answer_id": 459802,
"author": "Eclipse",
"author_id": 8701,
"author_profile": "https://Stackoverflow.com/users/8701",
"pm_score": 2,
"selected": false,
"text": "<p>There's nothing wrong with XML for this, but you could save yourself some overhead with a lighter syntax like a LISP-styl... | 2009/01/20 | [
"https://Stackoverflow.com/questions/459783",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/56908/"
] | I have the need to express simple conditionals as program input. The input must be human readable.
Is XML suited for this?
For example, I have the following conditional statement:
```
If AnimalType = Leopard And (SourceCountry = Kenya Or TargetCountry = Kenya) Then
ZooKeeper=Jack
Else
ZooKeeper=Jill
End If
... | You said you wanted it to be human-readable, and then you presented a nearly impenetrable XML example. I'm not sure what XML is buying you here. A simple parser for a truly human-readable language would probably be a good investment of your time. |
459,796 | <p>I know how you do it from the console, and I know you can execute console commands with php, but would there be a way to recursively dump a database into a file, and then restore it from that file later, just using php? I want it to be able to work on windows and nix servers.</p>
<p>I am guessing it would need to l... | [
{
"answer_id": 459819,
"author": "deizel.",
"author_id": 41874,
"author_profile": "https://Stackoverflow.com/users/41874",
"pm_score": 2,
"selected": false,
"text": "<pre><code>mysql_query(\"SELECT * INTO OUTFILE 'sql/backup.sql' FROM my_table\");\nmysql_query(\"LOAD DATA INFILE 'sql/bac... | 2009/01/20 | [
"https://Stackoverflow.com/questions/459796",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I know how you do it from the console, and I know you can execute console commands with php, but would there be a way to recursively dump a database into a file, and then restore it from that file later, just using php? I want it to be able to work on windows and nix servers.
I am guessing it would need to loop throug... | ```
mysql_query("SELECT * INTO OUTFILE 'sql/backup.sql' FROM my_table");
mysql_query("LOAD DATA INFILE 'sql/backup.sql' INTO TABLE my_table");
``` |
459,820 | <p>I currently have an array of strings, I'm getting a NSString object from this array by calling the <code>-componentsJoinedByString:</code> method. Example:</p>
<pre><code>NSString *someString = [[NSString alloc] initWithString: [myStrings componentsJoinedByString:@","];
</code></pre>
<p>Since <code>-componentsJoin... | [
{
"answer_id": 459827,
"author": "dreamlax",
"author_id": 10320,
"author_profile": "https://Stackoverflow.com/users/10320",
"pm_score": 0,
"selected": false,
"text": "<p>You only need to retain the string returned by <code>componentsJoinedByString:</code> it if it will be used outside th... | 2009/01/20 | [
"https://Stackoverflow.com/questions/459820",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I currently have an array of strings, I'm getting a NSString object from this array by calling the `-componentsJoinedByString:` method. Example:
```
NSString *someString = [[NSString alloc] initWithString: [myStrings componentsJoinedByString:@","];
```
Since `-componentsJoinedByString:` returns me an NSString, I'm a... | The first example you wrote is correct, although in practice it would be clearer just to write `NSString *someString = [[myStrings componentsJoinedByString:@","] copy];` (note that this will be retained, so you will have to release it at some point in the future.
If you're having trouble with memory management, [this ... |
459,824 | <p>I have the following SQL statement</p>
<pre><code>SELECT table1.col1, table2.col2 FROM table1, table2 WHERE table1.t_id = table2.t_id
UNION
SELECT table1.col1 FROM table1 WHERE table1.col4 = null
</code></pre>
<p>Problem is, I this syntax is invalid because the 2nd statement doesn't include the same # of columns a... | [
{
"answer_id": 459828,
"author": "Otávio Décio",
"author_id": 48684,
"author_profile": "https://Stackoverflow.com/users/48684",
"pm_score": 3,
"selected": false,
"text": "<p>Yes, just use a constant such as 1 or ''.</p>\n\n<pre><code>SELECT table1.col1, table2.col2 FROM table1, table2 WH... | 2009/01/20 | [
"https://Stackoverflow.com/questions/459824",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have the following SQL statement
```
SELECT table1.col1, table2.col2 FROM table1, table2 WHERE table1.t_id = table2.t_id
UNION
SELECT table1.col1 FROM table1 WHERE table1.col4 = null
```
Problem is, I this syntax is invalid because the 2nd statement doesn't include the same # of columns as the 1st statement.
I ca... | Yes, just use a constant such as 1 or ''.
```
SELECT table1.col1, table2.col2 FROM table1, table2 WHERE table1.t_id = table2.t_id
UNION
SELECT table1.col1, '' as col2 FROM table1 WHERE table1.col4 = null
``` |
459,871 | <p>How can I best combine JQuery with ASP.NET client side validation model?</p>
<p>I've generally avoided implementing ASP.NET validation model because it always seems overkill for what I was doing. For the site I'm working on now I'm just collecting non critical user data and only need somewhat basic validation. I do... | [
{
"answer_id": 459930,
"author": "Jon Limjap",
"author_id": 372,
"author_profile": "https://Stackoverflow.com/users/372",
"pm_score": 3,
"selected": false,
"text": "<p>ASP.NET webforms and jQuery's validation model is very, very similar, IMHO, in that both are client-side and implementin... | 2009/01/20 | [
"https://Stackoverflow.com/questions/459871",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16940/"
] | How can I best combine JQuery with ASP.NET client side validation model?
I've generally avoided implementing ASP.NET validation model because it always seems overkill for what I was doing. For the site I'm working on now I'm just collecting non critical user data and only need somewhat basic validation. I dont want me... | ASP.NET has many validation controls, one of them is the [`CustomValidator`](http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.customvalidator.aspx).
You can give it a custom JavaScript function that uses jQuery and returns `true` or `false` via argument. You can use this control to display the error... |
459,889 | <p>I have a table inside a cell, and that table is "getting out" of the cell, as see in this screenshot:</p>
<p><a href="http://img.skitch.com/20090120-pe4iykdqpymqaxr96tpubiqn7j.png" rel="nofollow noreferrer">alt text http://img.skitch.com/20090120-pe4iykdqpymqaxr96tpubiqn7j.png</a></p>
<p>I see this on Firefox. Is ... | [
{
"answer_id": 459894,
"author": "Jobo",
"author_id": 51915,
"author_profile": "https://Stackoverflow.com/users/51915",
"pm_score": 1,
"selected": false,
"text": "<p>untested: take out 'margin-left' and use 'padding-left' instead.</p>\n\n<p>or </p>\n\n<p>You could indent your cells value... | 2009/01/20 | [
"https://Stackoverflow.com/questions/459889",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5295/"
] | I have a table inside a cell, and that table is "getting out" of the cell, as see in this screenshot:
[alt text http://img.skitch.com/20090120-pe4iykdqpymqaxr96tpubiqn7j.png](http://img.skitch.com/20090120-pe4iykdqpymqaxr96tpubiqn7j.png)
I see this on Firefox. Is this "normal". How can I fix this?
The code:
```
<!D... | The inner table is being told to be as wide as its container (`width: 100%`), and then to move 3ems away from its left edge: (`margin-left: 3em`)
Switch the innermost TD to have `padding-left` which might help.
But the standard response here is: "oh god why are you doing nested tables you bad bad man!!11" |
459,891 | <p>I've heard that many of the distributed VCSs (git, mercurial, etc) are better at merging than traditional ones like Subversion. What does this mean? What sort of things do they do to make merging better? Could those things be done in a traditional VCS?</p>
<p>Bonus question: does SVN 1.5's merge-tracking level the ... | [
{
"answer_id": 459913,
"author": "BCS",
"author_id": 1343,
"author_profile": "https://Stackoverflow.com/users/1343",
"pm_score": 2,
"selected": false,
"text": "<p>Flippant answer: Why are some programming languages better at text/math than others?</p>\n\n<p>Real answer: because they have... | 2009/01/20 | [
"https://Stackoverflow.com/questions/459891",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4321/"
] | I've heard that many of the distributed VCSs (git, mercurial, etc) are better at merging than traditional ones like Subversion. What does this mean? What sort of things do they do to make merging better? Could those things be done in a traditional VCS?
Bonus question: does SVN 1.5's merge-tracking level the playing fi... | *Most answers seems to be about Subversion, so here you have one about Git (and other DVCS).*
In distributed version control system when you merge one branch into another, you create new **merge commit**, which remembers how you resolved a merge, and **remembers all parents of a merge**. This information was simply la... |
459,898 | <p>I have been over the iPhone Programming Guide several times regarding the behavior of when the event methods are called in an app.</p>
<p>From what the guide says:
touchesBegan is called when a finger first touches the screen.</p>
<p>touchesMoved is called when a finger on the screen moves.</p>
<p>touchesEnded is... | [
{
"answer_id": 459913,
"author": "BCS",
"author_id": 1343,
"author_profile": "https://Stackoverflow.com/users/1343",
"pm_score": 2,
"selected": false,
"text": "<p>Flippant answer: Why are some programming languages better at text/math than others?</p>\n\n<p>Real answer: because they have... | 2009/01/20 | [
"https://Stackoverflow.com/questions/459898",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48311/"
] | I have been over the iPhone Programming Guide several times regarding the behavior of when the event methods are called in an app.
From what the guide says:
touchesBegan is called when a finger first touches the screen.
touchesMoved is called when a finger on the screen moves.
touchesEnded is called when a finger li... | *Most answers seems to be about Subversion, so here you have one about Git (and other DVCS).*
In distributed version control system when you merge one branch into another, you create new **merge commit**, which remembers how you resolved a merge, and **remembers all parents of a merge**. This information was simply la... |
459,921 | <p>Say I create a text element like this:</p>
<pre><code>$firstName = new Zend_Form_Element_Text('firstName');
$firstName->setRequired(true);
</code></pre>
<p><strong>Whats the best way to change the default error message from:</strong></p>
<blockquote>
<p>Value is empty, but a non-empty value
is required</p>... | [
{
"answer_id": 459954,
"author": "typeoneerror",
"author_id": 53653,
"author_profile": "https://Stackoverflow.com/users/53653",
"pm_score": 4,
"selected": false,
"text": "<p>Give this a shot:</p>\n\n<pre><code>$firstName = new Zend_Form_Element_Text('firstName');\n$firstName->setLabel... | 2009/01/20 | [
"https://Stackoverflow.com/questions/459921",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16435/"
] | Say I create a text element like this:
```
$firstName = new Zend_Form_Element_Text('firstName');
$firstName->setRequired(true);
```
**Whats the best way to change the default error message from:**
>
> Value is empty, but a non-empty value
> is required
>
>
>
to a custom message? I read somewhere that to repla... | Give this a shot:
```
$firstName = new Zend_Form_Element_Text('firstName');
$firstName->setLabel('First Name')
->setRequired(true)
->addValidator('NotEmpty', true)
->addErrorMessage('Value is empty, but a non-empty value is required.');
```
The key is that "true" on the validator if you... |
459,942 | <p>I have seen code around with these two styles , I am not not sure if one is better than another (is it just a matter of style)? Do you have any recommendations of why you would choose one over another.</p>
<pre><code> //Example1
class Test {
private:
static const char* const str;
};
const char* con... | [
{
"answer_id": 459950,
"author": "Starkii",
"author_id": 14720,
"author_profile": "https://Stackoverflow.com/users/14720",
"pm_score": 2,
"selected": false,
"text": "<p>Hmmm, a std::string is not the same as a const char *. I usually err on the side of using std::string because it is a ... | 2009/01/20 | [
"https://Stackoverflow.com/questions/459942",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43756/"
] | I have seen code around with these two styles , I am not not sure if one is better than another (is it just a matter of style)? Do you have any recommendations of why you would choose one over another.
```
//Example1
class Test {
private:
static const char* const str;
};
const char* const Test::str = ... | Usually you should prefer `std::string` over plain char pointers. Here, however, the char pointer initialized with the string literal has a significant benefit.
There are two initializations for static data. The one is called static initialization, and the other is called dynamic initialization. For those objects tha... |
459,947 | <p>I have a basic bar chart I'm presenting in flot (5 bars, displaying the % per status).</p>
<pre><code>$.plot($("#placeholder"), [
{
label: 'Failed',
data: [[0,10]],
bars: { show: true }
},
{
label: 'Passed',
data: [[1,15]],
bars: { show: true }
},
... | [
{
"answer_id": 666470,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 5,
"selected": true,
"text": "<p>It doesn't appear you can set the font size via the API, but you can use css to set the size of the tick labels.</p>\n\n<pre... | 2009/01/20 | [
"https://Stackoverflow.com/questions/459947",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4843/"
] | I have a basic bar chart I'm presenting in flot (5 bars, displaying the % per status).
```
$.plot($("#placeholder"), [
{
label: 'Failed',
data: [[0,10]],
bars: { show: true }
},
{
label: 'Passed',
data: [[1,15]],
bars: { show: true }
},
{
labe... | It doesn't appear you can set the font size via the API, but you can use css to set the size of the tick labels.
```
.tickLabel { font-size: 80% }
``` |
459,981 | <p>I need to be able to modify every single link in an HTML document. I know that I need to use the <code>SoupStrainer</code> but I'm not 100% positive on how to implement it. If someone could direct me to a good resource or provide a code example, it'd be very much appreciated.</p>
<p>Thanks.</p>
| [
{
"answer_id": 459991,
"author": "Lusid",
"author_id": 56855,
"author_profile": "https://Stackoverflow.com/users/56855",
"pm_score": 7,
"selected": true,
"text": "<p>Maybe something like this would work? (I don't have a Python interpreter in front of me, unfortunately)</p>\n<pre><code>fr... | 2009/01/20 | [
"https://Stackoverflow.com/questions/459981",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49701/"
] | I need to be able to modify every single link in an HTML document. I know that I need to use the `SoupStrainer` but I'm not 100% positive on how to implement it. If someone could direct me to a good resource or provide a code example, it'd be very much appreciated.
Thanks. | Maybe something like this would work? (I don't have a Python interpreter in front of me, unfortunately)
```
from bs4 import BeautifulSoup
soup = BeautifulSoup('<p>Blah blah blah <a href="http://google.com">Google</a></p>')
for a in soup.findAll('a'):
a['href'] = a['href'].replace("google", "mysite")
result = str(so... |
460,010 | <p>I've recently started work on a new project using PHP5 and want to use their PDO classes for it. The problem is that the MySQL PDO Driver doesn't support rowCount() so there's no way to run a query and then get the number of affected rows, or rows returned, which is a pretty big issue as far as I'm concerned. I was ... | [
{
"answer_id": 660032,
"author": "Imran",
"author_id": 1897,
"author_profile": "https://Stackoverflow.com/users/1897",
"pm_score": 6,
"selected": true,
"text": "<p>You can issue a <code>SELECT FOUND_ROWS()</code> query right after the original <code>SELECT</code> query to get row count.<... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460010",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/56937/"
] | I've recently started work on a new project using PHP5 and want to use their PDO classes for it. The problem is that the MySQL PDO Driver doesn't support rowCount() so there's no way to run a query and then get the number of affected rows, or rows returned, which is a pretty big issue as far as I'm concerned. I was won... | You can issue a `SELECT FOUND_ROWS()` query right after the original `SELECT` query to get row count.
```
$pdo->query("SELECT * FROM users");
$foundRows = $pdo->query("SELECT FOUND_ROWS()")->fetchColumn();
```
See also: [MySQL Docs on FOUND\_ROWS()](http://dev.mysql.com/doc/refman/5.0/en/information-functions.html#f... |
460,011 | <p>I am learning to use polymorphism in C#, but cannot figure out this one. I'm trying to write a class that allows me to get a filtered list of files from a repository. </p>
<p>The repository could be a file system folder or the embedded resources in an arbitrary already-loaded assembly (but it is not the one current... | [
{
"answer_id": 460043,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<pre><code>using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.IO;\n\nnamespace Reposes\... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460011",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30183/"
] | I am learning to use polymorphism in C#, but cannot figure out this one. I'm trying to write a class that allows me to get a filtered list of files from a repository.
The repository could be a file system folder or the embedded resources in an arbitrary already-loaded assembly (but it is not the one currently executi... | You could define pair of interfaces like this:
```
public interface IReadableFile
{
Stream OpenRead();
}
public interface IRepository
{
IEnumerable<IReadableFile> Search(string pattern);
}
```
And have two different implementations of them:
```
public class FolderFile : IReadableFile
{
readonly private... |
460,014 | <p>I'm using a <code>UITableView</code> in my iPhone app, and I have a list of people that belong to a group. I would like it so that when the user clicks on a particular person (thus selecting the cell), the cell grows in height to display several UI controls for editing the properties of that person. </p>
<p>Is this... | [
{
"answer_id": 465696,
"author": "lostInTransit",
"author_id": 46297,
"author_profile": "https://Stackoverflow.com/users/46297",
"pm_score": -1,
"selected": false,
"text": "<p>Get the indexpath of the row selected. Reload the table. In the heightForRowAtIndexPath method of UITableViewDel... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460014",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm using a `UITableView` in my iPhone app, and I have a list of people that belong to a group. I would like it so that when the user clicks on a particular person (thus selecting the cell), the cell grows in height to display several UI controls for editing the properties of that person.
Is this possible? | I found a REALLY SIMPLE solution to this as a side-effect to a `UITableView` I was working on.....
Store the cell height in a variable that reports the original height normally via the `tableView: heightForRowAtIndexPath:`, then when you want to animate a height change, simply change the value of the variable and call... |
460,027 | <p>Is there a VB.NET equivalent to the C#:</p>
<pre><code>public string FirstName { get; set; }
</code></pre>
<p>I know you can do </p>
<pre><code>Public Property name() As String
Get
Return _name.ToString
End Get
Set(ByVal value As String)
_name = value
End Set
End Property
</code></pre>
<... | [
{
"answer_id": 460032,
"author": "Stefan",
"author_id": 19307,
"author_profile": "https://Stackoverflow.com/users/19307",
"pm_score": 8,
"selected": true,
"text": "<p>There is no shorthand for Visual Studio 2008 or prior for VB.NET.</p>\n<p>In Visual Studio 2010 and beyond, you can use t... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460027",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/56692/"
] | Is there a VB.NET equivalent to the C#:
```
public string FirstName { get; set; }
```
I know you can do
```
Public Property name() As String
Get
Return _name.ToString
End Get
Set(ByVal value As String)
_name = value
End Set
End Property
```
But I can't seem to google up an answer on a Vi... | There is no shorthand for Visual Studio 2008 or prior for VB.NET.
In Visual Studio 2010 and beyond, you can use the following shorthand:
```
Public Property FirstName as String
```
This will be handled as your short version in C# is - I think they call it "Auto Property"
See also: [Auto-Implemented Properties (Vis... |
460,059 | <p>Is there a way to guarantee that your system tray icon is removed?</p>
<p>To add the system tray icon you do:</p>
<pre><code>Shell_NotifyIcon(NIM_ADD, &m_tnd);
</code></pre>
<p>To remove the system tray icon you do:</p>
<pre><code>Shell_NotifyIcon(NIM_DELETE, &m_tnd);
</code></pre>
<p>What I want to kno... | [
{
"answer_id": 460073,
"author": "Brian",
"author_id": 18192,
"author_profile": "https://Stackoverflow.com/users/18192",
"pm_score": 2,
"selected": false,
"text": "<p>You could have a separate, simpler (and thus presumably more robust) program which monitors your application. This progr... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460059",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3153/"
] | Is there a way to guarantee that your system tray icon is removed?
To add the system tray icon you do:
```
Shell_NotifyIcon(NIM_ADD, &m_tnd);
```
To remove the system tray icon you do:
```
Shell_NotifyIcon(NIM_DELETE, &m_tnd);
```
What I want to know: what if you application crashes? The icon stays in your syste... | You could have a separate, simpler (and thus presumably more robust) program which monitors your application. This program could actually launch your program and then monitor the process. Yeah, this is a very ugly solution. |
460,070 | <p>I notice sometimes users mistype their email address (in a contact-us form), for example, typing @yahho.com, @yhoo.com, or @yahoo.co instead of @yahoo.com</p>
<p>I feel that this can be corrected on-the-spot with some javascript. Simply check the email address for possible mistakes, such as the ones listed above, s... | [
{
"answer_id": 460083,
"author": "Daniel Schaffer",
"author_id": 2596,
"author_profile": "https://Stackoverflow.com/users/2596",
"pm_score": -1,
"selected": false,
"text": "<p>It might be possible to use a regex, but personally, it would take me way too long to write one I'd be happy wit... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460070",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35364/"
] | I notice sometimes users mistype their email address (in a contact-us form), for example, typing @yahho.com, @yhoo.com, or @yahoo.co instead of @yahoo.com
I feel that this can be corrected on-the-spot with some javascript. Simply check the email address for possible mistakes, such as the ones listed above, so that if ... | Here's a dirty implementation that could kind of get you some simple checks using the [`Levenshtein distance`](http://en.wikipedia.org/wiki/Levenshtein_distance). Credit for the "levenshteinenator" goes to [`this link`](http://andrew.hedges.name/experiments/levenshtein/). You would add whatever popular domains you want... |
460,136 | <p>I have an internet shortcut on my desktop, with the contents looking like this:</p>
<pre><code>[InternetShortcut]
URL=http://www.microsoft.com/isapi/redir.dll?prd=ie&pver=6&ar=IStart
Modified=D03458CE7738C801A2
</code></pre>
<p>I was wondering if there are any tweaks I can do to guarantee that the browser ... | [
{
"answer_id": 460385,
"author": "Riho",
"author_id": 44715,
"author_profile": "https://Stackoverflow.com/users/44715",
"pm_score": 0,
"selected": false,
"text": "<p>I think IE remembers how it was opened last time and then uses those settings.\nYou might find this info from Registry and... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460136",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25915/"
] | I have an internet shortcut on my desktop, with the contents looking like this:
```
[InternetShortcut]
URL=http://www.microsoft.com/isapi/redir.dll?prd=ie&pver=6&ar=IStart
Modified=D03458CE7738C801A2
```
I was wondering if there are any tweaks I can do to guarantee that the browser starts maximized after someone loa... | In short:You can't guarantee that the browser starts maximized from one special internet link. Either all or none internet links start maximized.
But: Someone had a similar problem than this.
Check [this](http://www.eggheadcafe.com/software/aspnet/31821712/ie7-wont-start-maximized.aspx), if it helps you.
---
Edit: o... |
460,137 | <p>Suppose there is a singly linked list whose length is unknown. We want to find the node with M steps to the tail.</p>
<p>For example, the singly list is like this:
(A)->(B)->(C)->(X)->(Y)
and M = 2.
Then the output should be pointer to (C).</p>
<p>When confronting this quiz, my first reaction is to traverse the si... | [
{
"answer_id": 460148,
"author": "jasonmray",
"author_id": 17230,
"author_profile": "https://Stackoverflow.com/users/17230",
"pm_score": 0,
"selected": false,
"text": "<p>Other than your proposed counting-style algorithm, you could use a recursive function similar to:</p>\n\n<pre><code>i... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460137",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26349/"
] | Suppose there is a singly linked list whose length is unknown. We want to find the node with M steps to the tail.
For example, the singly list is like this:
(A)->(B)->(C)->(X)->(Y)
and M = 2.
Then the output should be pointer to (C).
When confronting this quiz, my first reaction is to traverse the singly linked list ... | You should use a circular buffer
Allocate an array of M + 1 pointers, and fill in the (i mod M + 1)th pointer for each node through the list. When you reach the end, look M back in the array (wrapping around if you need to).
That way, you only have N writes!
Here's a hack job sample program in c++
```
node* get_Mth... |
460,140 | <p>I'm looking for a decent, non-lame way to inhibit xscreensaver, kscreensaver, or gnome-screensaver, whichever might be running, preferably in a screensaver-agnostic manner, and it absolutely positively must execute <em>fast</em>.</p>
<p>I've read the <a href="http://www.jwz.org/xscreensaver/faq.html" rel="nofollow n... | [
{
"answer_id": 460885,
"author": "Rolf Rander",
"author_id": 47402,
"author_profile": "https://Stackoverflow.com/users/47402",
"pm_score": 2,
"selected": false,
"text": "<p>Movie-players typically disable screensavers. You could poke around the <a href=\"http://svn.mplayerhq.hu/mplayer/... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460140",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/56951/"
] | I'm looking for a decent, non-lame way to inhibit xscreensaver, kscreensaver, or gnome-screensaver, whichever might be running, preferably in a screensaver-agnostic manner, and it absolutely positively must execute *fast*.
I've read the [xscreensaver FAQ](http://www.jwz.org/xscreensaver/faq.html).
I have a gtk based ... | No, but yes...
There's no nice clean way to do this. In my opinion there should be a mechanism administrated by the X server, which both screensavers and interested applications can voluntarily use to negotiate suppression of any screensaver during the runtime of one or more programs. But no such mechanism yet exists ... |
460,149 | <p>I am working in a project that has two main parts: a class library assembly and the main application. Both are using Castle Windsor for IoC and both manually setup their list of of components in code (to aid refactoring and prevent the need for a config file). Currently the main application has code like this:</p>
... | [
{
"answer_id": 460160,
"author": "Lusid",
"author_id": 56855,
"author_profile": "https://Stackoverflow.com/users/56855",
"pm_score": 2,
"selected": true,
"text": "<p>I'm not sure if I'm understanding exactly the problem you are trying to solve, but my first guess is that you are looking ... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460149",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18437/"
] | I am working in a project that has two main parts: a class library assembly and the main application. Both are using Castle Windsor for IoC and both manually setup their list of of components in code (to aid refactoring and prevent the need for a config file). Currently the main application has code like this:
```
pub... | I'm not sure if I'm understanding exactly the problem you are trying to solve, but my first guess is that you are looking for a way to decouple the need to call the Init method from your main application.
One method I've used in the past is a static constructor on a static class in the class library:
```
static publi... |
460,158 | <p>I am using jQuery, JavaScript and PHP. My <code>Ajax.php</code> file just displays the
data. File <code>test.php</code> has assigns the value to a JavaScript function.</p>
<p>My problem is I am not able to get the values that are assigned by test.php, from <code>getList(data)</code>.</p>
<p>Is anything wrong with ... | [
{
"answer_id": 460170,
"author": "Ates Goral",
"author_id": 23501,
"author_profile": "https://Stackoverflow.com/users/23501",
"pm_score": 0,
"selected": false,
"text": "<pre><code>$.get(\"test.php\", function(data){\n alert(\"Data Loaded: \" + data);\n getList(data);\n});\n</code><... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460158",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44984/"
] | I am using jQuery, JavaScript and PHP. My `Ajax.php` file just displays the
data. File `test.php` has assigns the value to a JavaScript function.
My problem is I am not able to get the values that are assigned by test.php, from `getList(data)`.
Is anything wrong with my logic? What do I do to get the values assigned ... | The below code will output the values you require into [JSON](http://en.wikipedia.org/wiki/JSON) that when reconstructed will resemble your array:
```
<?php
echo json_encode(array(
array(
'STA-VES',
'East',
4500
),
array(
'STA-CRF',
... |
460,164 | <p>I need to convert some files to PDF and then attach them to an email. I'm using Pear Mail for the email side of it and that's fine (mostly--still working out some issues) but as part of this I need to create temporary files. Now I could use the <a href="http://au.php.net/manual/en/function.tempnam.php" rel="norefe... | [
{
"answer_id": 460168,
"author": "Lusid",
"author_id": 56855,
"author_profile": "https://Stackoverflow.com/users/56855",
"pm_score": 8,
"selected": true,
"text": "<p>I've used uniqid() in the past to generate a unique filename, but not actually create the file.</p>\n\n<pre><code>$filenam... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460164",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18393/"
] | I need to convert some files to PDF and then attach them to an email. I'm using Pear Mail for the email side of it and that's fine (mostly--still working out some issues) but as part of this I need to create temporary files. Now I could use the [tempnam()](http://au.php.net/manual/en/function.tempnam.php) function but ... | I've used uniqid() in the past to generate a unique filename, but not actually create the file.
```
$filename = uniqid(rand(), true) . '.pdf';
```
The first parameter can be anything you want, but I used rand() here to make it even a bit more random. Using a set prefix, you could further avoid collisions with other ... |
460,172 | <p>I have a simple html block like:</p>
<pre><code><span id="replies">8</span>
</code></pre>
<p>Using jquery I'm trying to add a 1 to the value (8).</p>
<pre><code>var currentValue = $("#replies").text();
var newValue = currentValue + 1;
$("replies").text(newValue);
</code></pre>
<p>What's happening is ... | [
{
"answer_id": 460176,
"author": "Diodeus - James MacFarlane",
"author_id": 12579,
"author_profile": "https://Stackoverflow.com/users/12579",
"pm_score": 9,
"selected": true,
"text": "<p>parseInt() will force it to be type integer, or will be NaN (not a number) if it cannot perform the c... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460172",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/50711/"
] | I have a simple html block like:
```
<span id="replies">8</span>
```
Using jquery I'm trying to add a 1 to the value (8).
```
var currentValue = $("#replies").text();
var newValue = currentValue + 1;
$("replies").text(newValue);
```
What's happening is it is appearing like:
81
then
811
not 9, which would be t... | parseInt() will force it to be type integer, or will be NaN (not a number) if it cannot perform the conversion.
```
var currentValue = parseInt($("#replies").text(),10);
```
The second paramter (radix) makes sure it is parsed as a decimal number. |
460,174 | <p>I need an algorithm that will convert a GPS coordinate to a screen location on a displayed google map. I would think this would be simple- get the coordinates for the four corners of the displayed map, find the differential and create a scaling factor for a pixel location on the screen. Is this correct or am I mis... | [
{
"answer_id": 460187,
"author": "Kip",
"author_id": 18511,
"author_profile": "https://Stackoverflow.com/users/18511",
"pm_score": 1,
"selected": false,
"text": "<p>The <a href=\"http://code.google.com/apis/maps/\" rel=\"nofollow noreferrer\">Google Maps API</a> lets you do stuff like th... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460174",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38953/"
] | I need an algorithm that will convert a GPS coordinate to a screen location on a displayed google map. I would think this would be simple- get the coordinates for the four corners of the displayed map, find the differential and create a scaling factor for a pixel location on the screen. Is this correct or am I missing ... | Basically you need the code for Transverse Mercator projection (which is used by Google maps and others). Here's a C# snippet I used my [Kosmos](http://igorbrejc.net/kosmoshome) software:
```
public Point2<int> ConvertMapToViewCoords (Point2<double> mapCoords)
{
double x = (mapCoords.X - MapPosition.Longitude) / r... |
460,197 | <p>I'm wondering if it's possible to restore an element's style to it's "default" state, with Javascript or otherwise.</p>
<p>I need to do this because I'm inserting HTML into 3rd party web pages and cannot control what styles they attribute to different elements. For instance, they may have:</p>
<pre><code>div {
... | [
{
"answer_id": 460207,
"author": "localshred",
"author_id": 29690,
"author_profile": "https://Stackoverflow.com/users/29690",
"pm_score": 0,
"selected": false,
"text": "<p>The default styles are defined by each browser, and as you can guess, all the browsers have it styled a bit differen... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460197",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I'm wondering if it's possible to restore an element's style to it's "default" state, with Javascript or otherwise.
I need to do this because I'm inserting HTML into 3rd party web pages and cannot control what styles they attribute to different elements. For instance, they may have:
```
div {
margin: 10px;
paddin... | It appears that someone has already asked this question on SO.
[CSS Reset, default styles for common elements](https://stackoverflow.com/questions/99643/css-reset-default-styles-for-common-elements) |
460,208 | <p>Can someone please explain why this program outputs 0x00000004?</p>
<pre><code>class AndAssignment
{
static void Main()
{
int a = 0x0c;
a &= 0x06;
Console.WriteLine("0x{0:x8}", a);
}
}
/*
Output:
0x00000004
*/
</code></pre>
| [
{
"answer_id": 460220,
"author": "okutane",
"author_id": 53481,
"author_profile": "https://Stackoverflow.com/users/53481",
"pm_score": 5,
"selected": true,
"text": "<p>0x0c = 1100 in binary<br>\n0x06 = 0110 in binary<br>\n& operation is a binary AND which sets a bit to 1 if it's set ... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460208",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Can someone please explain why this program outputs 0x00000004?
```
class AndAssignment
{
static void Main()
{
int a = 0x0c;
a &= 0x06;
Console.WriteLine("0x{0:x8}", a);
}
}
/*
Output:
0x00000004
*/
``` | 0x0c = 1100 in binary
0x06 = 0110 in binary
& operation is a binary AND which sets a bit to 1 if it's set in both operands, so:
0x0c & 0x06 = 1100 & 0110 = 0100 = 0x04
You can use windows calculator to see how integers is presented in different forms (hex and binary in your case). [More info](http://en.wiki... |
460,211 | <p>I would like to know people's thoughts on the best way to do the opposite to <a href="http://haacked.com/archive/2008/10/23/model-binding-to-a-list.aspx" rel="nofollow noreferrer">Phil Haack's Model Binding To A List</a>. I have a form which contains several individual fields as well as form fields which are created... | [
{
"answer_id": 460512,
"author": "Giraffe",
"author_id": 50136,
"author_profile": "https://Stackoverflow.com/users/50136",
"pm_score": 1,
"selected": false,
"text": "<p>Wrapping this up in either a UserControl or your own HtmlHelper extension method would tidy up the view, but essentiall... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460211",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17248/"
] | I would like to know people's thoughts on the best way to do the opposite to [Phil Haack's Model Binding To A List](http://haacked.com/archive/2008/10/23/model-binding-to-a-list.aspx). I have a form which contains several individual fields as well as form fields which are created dynamically using JQuery. This means th... | To complete this I ended up creating a while loop to loop through the form items and then query my data source to hydrate my objects. I have since changed this so that the same code now sits inside a custom modelbinder. Very neat. |
460,223 | <p>This is probably a simple question. Let's say I have a small list with around 20-50 entries or so. Something like:</p>
<pre><code>class Item
{
int ItemNumber;
int OrderNumber;
string Name;
}
stored in something like
List<Item>
</code></pre>
<p>This is stored either in a generic list or array in whe... | [
{
"answer_id": 460226,
"author": "Michael Buen",
"author_id": 11432,
"author_profile": "https://Stackoverflow.com/users/11432",
"pm_score": 0,
"selected": false,
"text": "<pre><code>using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\npublic class C... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460223",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10352/"
] | This is probably a simple question. Let's say I have a small list with around 20-50 entries or so. Something like:
```
class Item
{
int ItemNumber;
int OrderNumber;
string Name;
}
stored in something like
List<Item>
```
This is stored either in a generic list or array in where the OrderNumber goes from 1, ... | Does it have to be a `List<T>`? If not, you might consider using a `SortedList<TKey, TValue>` or a `SortedDictionary<TKey, TValue>`. You could then use the OrderNumber as the key, and just let the collection do the work.
Alterantively, for `List<T>` you can use `List<T>.BinarySearch` with an appropriate `IComparer<T>`... |
460,236 | <p>I have to delete a versioned file my bzr repository using bzr remove command.</p>
<blockquote>
<blockquote>
<blockquote>
<p>bzr remove file_name</p>
</blockquote>
</blockquote>
</blockquote>
<p>it deletes the versioned file (from the file system)</p>
<p>I cannot use bzr commit , (as the file ha... | [
{
"answer_id": 460226,
"author": "Michael Buen",
"author_id": 11432,
"author_profile": "https://Stackoverflow.com/users/11432",
"pm_score": 0,
"selected": false,
"text": "<pre><code>using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\n\npublic class C... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460236",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2220518/"
] | I have to delete a versioned file my bzr repository using bzr remove command.
>
>
> >
> >
> > >
> > > bzr remove file\_name
> > >
> > >
> > >
> >
> >
> >
>
>
>
it deletes the versioned file (from the file system)
I cannot use bzr commit , (as the file has been deleted from the repository)
>
>
> >
>... | Does it have to be a `List<T>`? If not, you might consider using a `SortedList<TKey, TValue>` or a `SortedDictionary<TKey, TValue>`. You could then use the OrderNumber as the key, and just let the collection do the work.
Alterantively, for `List<T>` you can use `List<T>.BinarySearch` with an appropriate `IComparer<T>`... |
460,256 | <p>I have an iframe in a form.
The iframe contains some info that I want deliver to the form parent by instance of Array.
The problem: the Array instance loses it's type and becomes an object!
The iframe function:</p>
<pre><code>function getIDS2() { return new Array(); }
</code></pre>
<p>The parent call code:</p>
<p... | [
{
"answer_id": 460266,
"author": "Darin Dimitrov",
"author_id": 29407,
"author_profile": "https://Stackoverflow.com/users/29407",
"pm_score": 3,
"selected": false,
"text": "<p>Because each page has a global context with its own \"Array\" function, if code on one page passes an array to a... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460256",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/54801/"
] | I have an iframe in a form.
The iframe contains some info that I want deliver to the form parent by instance of Array.
The problem: the Array instance loses it's type and becomes an object!
The iframe function:
```
function getIDS2() { return new Array(); }
```
The parent call code:
```
alert(top.frames["sup_search... | Because each page has a global context with its own "Array" function, if code on one page passes an array to a function on a separate page, the test "array instanceof Array" will fail. For Array you can do this instead:
```
var arr = top.frames["sup_search"].getIDS2();
var isArray = arr && Object.prototype.toString.ca... |
460,263 | <p>I've got this pretty simple HTML page with a jQuery datepicker:</p>
<pre><code> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>jQuery Datepicker</ti... | [
{
"answer_id": 463472,
"author": "Andre Gallo",
"author_id": 14401,
"author_profile": "https://Stackoverflow.com/users/14401",
"pm_score": 4,
"selected": true,
"text": "<p>My problem wasn't about the CSS validity or relative paths .... I was just referencing the wrong version of CSS file... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460263",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14401/"
] | I've got this pretty simple HTML page with a jQuery datepicker:
```
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>jQuery Datepicker</title>
<link rel="stylesheet" href="../... | My problem wasn't about the CSS validity or relative paths .... I was just referencing the wrong version of CSS files for my jQuery-ui version. To all of you that had a similar problem make sure you download the correct theme's version for your jQuery-ui scripts.
Thanks. |
460,264 | <p>I am trying to come up with a validation for a nullable property, like int.</p>
<p>Example</p>
<pre><code>[RangeValidator(0, RangeBoundaryType.Inclusive, 1, RangeBoundaryType.Inclusive)]
int? Age { get; set; }
</code></pre>
<p>However if I set <code>Age</code> to null validation fails because it doesn't fall in t... | [
{
"answer_id": 460284,
"author": "Steven Robbins",
"author_id": 26507,
"author_profile": "https://Stackoverflow.com/users/26507",
"pm_score": 4,
"selected": true,
"text": "<p>You could add the IgnoreNulls attribute:</p>\n\n<pre><code>[IgnoreNulls()]\n[RangeValidator(0, RangeBoundaryType.... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460264",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/53236/"
] | I am trying to come up with a validation for a nullable property, like int.
Example
```
[RangeValidator(0, RangeBoundaryType.Inclusive, 1, RangeBoundaryType.Inclusive)]
int? Age { get; set; }
```
However if I set `Age` to null validation fails because it doesn't fall in the range, I know I need an `[ValidatorCompos... | You could add the IgnoreNulls attribute:
```
[IgnoreNulls()]
[RangeValidator(0, RangeBoundaryType.Inclusive, 1, RangeBoundaryType.Inclusive)]
int? Age { get; set; }
``` |
460,280 | <p>I've created a custom object that I'd like to return in JSON to a javascript method. This object was created as a class in C#. </p>
<p>What's the best way to return this object from a PageMethod ([WebMethod] if you like) to a javascript onPageMethodCallback() function? I need to be able to access the properties ... | [
{
"answer_id": 460471,
"author": "JD Conley",
"author_id": 51769,
"author_profile": "https://Stackoverflow.com/users/51769",
"pm_score": 2,
"selected": false,
"text": "<p>Here's a pretty extensive post on the subject of using JSON serialized WebMethods from an asmx with jQuery. It ought ... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460280",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33253/"
] | I've created a custom object that I'd like to return in JSON to a javascript method. This object was created as a class in C#.
What's the best way to return this object from a PageMethod ([WebMethod] if you like) to a javascript onPageMethodCallback() function? I need to be able to access the properties of this objec... | ASP.NET AJAX on the server side will handle serializing the object for you. For example:
```
public class Name
{
public string FirstName;
public string LastName;
}
[WebMethod]
public Name GetName()
{
Name name = new Name();
name.FirstName = "Dave";
name.LastName = "Ward";
return name;
}
```
You can th... |
460,281 | <p>I have a problem which I think is related to forward declarations, but perhaps not.</p>
<p>Here is the relevant code:</p>
<p>A.h</p>
<pre><code>#ifndef A_H_
#define A_H_
#include "B.h"
class A
{
private:
B b;
public:
A() : b(*this) {}
void bar() {}
};
#endif /*A_H_*... | [
{
"answer_id": 460298,
"author": "Jesse Beder",
"author_id": 112,
"author_profile": "https://Stackoverflow.com/users/112",
"pm_score": 5,
"selected": true,
"text": "<p>You've got a circular reference, so you need to separate B.h. Try something like:</p>\n\n<p>B.h:</p>\n\n<pre><code>#ifnd... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460281",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48096/"
] | I have a problem which I think is related to forward declarations, but perhaps not.
Here is the relevant code:
A.h
```
#ifndef A_H_
#define A_H_
#include "B.h"
class A
{
private:
B b;
public:
A() : b(*this) {}
void bar() {}
};
#endif /*A_H_*/
```
B.h
```
#ifndef B_H_
#define B... | You've got a circular reference, so you need to separate B.h. Try something like:
B.h:
```
#ifndef B_H_
#define B_H_
// don't include A.h here!
class A;
class B
{
private:
A& a;
public:
B(A& a) : a(a) {}
void foo();
};
#endif /*B_H_*/
```
B.cpp:
```
#include "B.h"
#include "A.h"
void... |
460,288 | <p>I have a JSP web server, with pages that all end with the .jsp extension.</p>
<p>How can I hide it in my web server urls without resorting to non-java tricks (e.g., apache rewrite)?</p>
<p>For example:
instead of typing <a href="http://www.sample.com/search.jsp?xxx" rel="noreferrer">http://www.sample.com/search.js... | [
{
"answer_id": 460295,
"author": "Logan Serman",
"author_id": 29595,
"author_profile": "https://Stackoverflow.com/users/29595",
"pm_score": 0,
"selected": false,
"text": "<pre><code>RewriteEngine On\n\nRewriteRule ^([0-9a-zA-Z]+)$ $1.jsp\n</code></pre>\n\n<p>In your .htaccess should rew... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460288",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a JSP web server, with pages that all end with the .jsp extension.
How can I hide it in my web server urls without resorting to non-java tricks (e.g., apache rewrite)?
For example:
instead of typing <http://www.sample.com/search.jsp?xxx>
the user would just type
<http://www.sample.com/search?xxx> | You can create a servlet mapping like this:
```
<servlet-mapping>
<servlet-name>MappingServlet</servlet-name>
<url-pattern>path/*</url-pattern>
</servlet-mapping>
```
The url-pattern must be edited to suit your needs. You need of course to create the servlet in order to map the url to the actual jsp. This tec... |
460,293 | <p>Having the hours and minutes, is there any easier or better way to set it into a Calendar object than:</p>
<pre><code>calendar.set(calendar.get(Calendar.YEAR),
calendar.get(Calendar.MONTH),
calendar.get(Calendar.DAY_OF_MONTH),
hour, minute);
</... | [
{
"answer_id": 460306,
"author": "Rahul",
"author_id": 24424,
"author_profile": "https://Stackoverflow.com/users/24424",
"pm_score": 3,
"selected": false,
"text": "<p>Use <a href=\"https://docs.oracle.com/javase/9/docs/api/java/util/Calendar.html#set-int-int-\" rel=\"nofollow noreferrer\... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460293",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6068/"
] | Having the hours and minutes, is there any easier or better way to set it into a Calendar object than:
```
calendar.set(calendar.get(Calendar.YEAR),
calendar.get(Calendar.MONTH),
calendar.get(Calendar.DAY_OF_MONTH),
hour, minute);
``` | From [here](http://www.java2s.com/Code/JavaAPI/java.util/Calendarsetintfieldintvalue.htm):
```
calendar.set(Calendar.HOUR_OF_DAY, hour);
calendar.set(Calendar.MINUTE, minute);
``` |
460,297 | <p>I've added a file to the 'index' with: </p>
<pre><code>git add myfile.java
</code></pre>
<p>How do I find out the SHA1 of this file?</p>
| [
{
"answer_id": 460315,
"author": "cnu",
"author_id": 1448,
"author_profile": "https://Stackoverflow.com/users/1448",
"pm_score": 5,
"selected": false,
"text": "<pre><code>$ git hash-object myfile.java\n802992c4220de19a90767f3000a79a31b98d0df7\n</code></pre>\n"
},
{
"answer_id": 4... | 2009/01/20 | [
"https://Stackoverflow.com/questions/460297",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/52416/"
] | I've added a file to the 'index' with:
```
git add myfile.java
```
How do I find out the SHA1 of this file? | You want the `-s` option to `git ls-files`. This gives you the mode and sha1 hash of the file in the index.
```
git ls-files -s myfile.java
```
Note that you do not want `git hash-object` as this gives you the sha1 id of the file in the working tree as it currently is, not of the file that you've added to the index.... |