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 |
|---|---|---|---|---|---|---|
321,128 | <p>I need to open a password protected shared folder on a network to gain access to an Access 97 database. How do I open the folder and pass in the password?</p>
| [
{
"answer_id": 322092,
"author": "Dirk Vollmar",
"author_id": 40347,
"author_profile": "https://Stackoverflow.com/users/40347",
"pm_score": 2,
"selected": false,
"text": "<p>one solution would be to map the network folder to an available drive letter. You could accomplish that using Wind... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321128",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38349/"
] | I need to open a password protected shared folder on a network to gain access to an Access 97 database. How do I open the folder and pass in the password? | found here <http://www.mredkj.com/vbnet/vbnetmapdrive.html>
```
Public Declare Function WNetAddConnection2 Lib "mpr.dll" Alias "WNetAddConnection2A" _
( ByRef lpNetResource As NETRESOURCE, ByVal lpPassword As String, _
ByVal lpUserName As String, ByVal dwFlags As Integer) As Integer
Public Declare Function WNetCan... |
321,135 | <p>How do I make the computer's internal speaker beep in C# without external speakers?</p>
| [
{
"answer_id": 321144,
"author": "Barry Kelly",
"author_id": 3712,
"author_profile": "https://Stackoverflow.com/users/3712",
"pm_score": 5,
"selected": false,
"text": "<p>The solution would be,</p>\n\n<pre><code>Console.Beep\n</code></pre>\n"
},
{
"answer_id": 321145,
"author... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321135",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1497/"
] | How do I make the computer's internal speaker beep in C# without external speakers? | In .Net 2.0, you can use [`Console.Beep`](https://learn.microsoft.com/en-us/dotnet/api/system.console.beep).
```
// Default beep
Console.Beep();
```
You can also specify the frequency and length of the beep in milliseconds.
```
// Beep at 5000 Hz for 1 second
Console.Beep(5000, 1000);
``` |
321,139 | <p>I have a function that, among other things, takes in an object and a Type, and converts the object into that Type. However, the input object is often a double, and the type some variation of int (uint, long, etc.). I want this to work if a round number is passed in as a double (like 4.0), but to throw an exception... | [
{
"answer_id": 321435,
"author": "Amy B",
"author_id": 8155,
"author_profile": "https://Stackoverflow.com/users/8155",
"pm_score": 4,
"selected": true,
"text": "<p>This seems to do what you ask. I have only tested it for doubles, floats and ints.</p>\n\n<pre><code> public int GetInt(... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321139",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17697/"
] | I have a function that, among other things, takes in an object and a Type, and converts the object into that Type. However, the input object is often a double, and the type some variation of int (uint, long, etc.). I want this to work if a round number is passed in as a double (like 4.0), but to throw an exception if a... | This seems to do what you ask. I have only tested it for doubles, floats and ints.
```
public int GetInt(IConvertible x)
{
int y = Convert.ToInt32(x);
if (Convert.ToDouble(x) != Convert.ToDouble(y))
throw new ArgumentException("Input was not an integer");
return y;
}
``... |
321,143 | <p>For example, never define a macro like this:</p>
<pre><code>#define DANGER 60 + 2
</code></pre>
<p>This can potentially be dangerous when we do an operation like this:</p>
<pre><code>int wrong_value = DANGER * 2; // Expecting 124
</code></pre>
<p>Instead, define like this because you don't know how the user of t... | [
{
"answer_id": 321151,
"author": "EvilTeach",
"author_id": 7734,
"author_profile": "https://Stackoverflow.com/users/7734",
"pm_score": 3,
"selected": false,
"text": "<p>In the expansion, put parenthesis around the arguments, so that if they pass in a expression you will get the intended ... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321143",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7205/"
] | For example, never define a macro like this:
```
#define DANGER 60 + 2
```
This can potentially be dangerous when we do an operation like this:
```
int wrong_value = DANGER * 2; // Expecting 124
```
Instead, define like this because you don't know how the user of the macro may use it:
```
#define HARMLESS (60 + ... | Not only should you put parens around the arguments, you should put parens around the expression returned.
```
#define MIN(a,b) a < b ? a : b // WRONG
int i = MIN(1,2); // works
int i = MIN(1,1+1); // breaks
#define MIN(a,b) (a) < (b) ? (a) : (b) // STILL WRONG
int i = MIN(1,2); // works
int i = MIN(1,1+1... |
321,158 | <p>I'm reading all the files in a single directory and I want to filter on JPG,JPEG,GIF and PNG.</p>
<p>Both capital and small letters. Those are the only files to be accepted.</p>
<p>I am currently using this:</p>
<pre><code>$testPics = takeFiles($picsDir, "([^\s]+(?=\.(jpg|JPG|jpeg|JPEG|png|PNG|gif|GIF))\.\2)");
<... | [
{
"answer_id": 321171,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 6,
"selected": true,
"text": "<p>I think something is wrong with your regex. Try testing regexes here first: <a href=\"https://www.regexpal.com/\" rel=\"nore... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321158",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11795/"
] | I'm reading all the files in a single directory and I want to filter on JPG,JPEG,GIF and PNG.
Both capital and small letters. Those are the only files to be accepted.
I am currently using this:
```
$testPics = takeFiles($picsDir, "([^\s]+(?=\.(jpg|JPG|jpeg|JPEG|png|PNG|gif|GIF))\.\2)");
```
and the function takeFi... | I think something is wrong with your regex. Try testing regexes here first: <https://www.regexpal.com/>
I think this one might work for you:
`/^.*\.(jpg|jpeg|png|gif)$/i`
Note the /i at the end - this is the "case insensitive" flag, saves you having to type out all permutations :) |
321,175 | <p>I have the following code:</p>
<pre><code>var address;
getAddress(0,0);
function getAddress(latlng)
{
if (latlng != null)
{
geocoder.getLocations(latlng,
function(addresses)
{
if(addresses.Status.code == 200)
{
address = addresses.Placemark[0].address.toString();
al... | [
{
"answer_id": 321263,
"author": "Noah Goodrich",
"author_id": 20178,
"author_profile": "https://Stackoverflow.com/users/20178",
"pm_score": 2,
"selected": false,
"text": "<p>I think that your problems are all related to scope. Generally speaking, you don't want to rely on a global decla... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321175",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19929/"
] | I have the following code:
```
var address;
getAddress(0,0);
function getAddress(latlng)
{
if (latlng != null)
{
geocoder.getLocations(latlng,
function(addresses)
{
if(addresses.Status.code == 200)
{
address = addresses.Placemark[0].address.toString();
alert(address); ... | I think that your problems are all related to scope. Generally speaking, you don't want to rely on a global declaration of a variable to be used within the scope of a function.
This should correct any scope issues with your function:
```
var address = getAddress(0,0);
function getAddress(latlng) {
if (latlng !=... |
321,179 | <p>So I have a <code>stored procedure</code> that accepts a product code like <code>1234567890</code>. I want to facilitate a wildcard search option for those products. (i.e. <code>123456*</code>) and have it return all those products that match. What is the best way to do this?</p>
<p>I have in the past used somethin... | [
{
"answer_id": 321254,
"author": "BQ.",
"author_id": 4632,
"author_profile": "https://Stackoverflow.com/users/4632",
"pm_score": 1,
"selected": false,
"text": "<p>What your doing already is about the best you can do.</p>\n\n<p>One optimization you might try is to ensure there's an index ... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321179",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | So I have a `stored procedure` that accepts a product code like `1234567890`. I want to facilitate a wildcard search option for those products. (i.e. `123456*`) and have it return all those products that match. What is the best way to do this?
I have in the past used something like below:
```
SELECT @product_code = R... | What your doing already is about the best you can do.
One optimization you might try is to ensure there's an index on the columns you're allowing this on. SQL Server will still need to do a full scan for the wildcard search, but it'll be only over the specific index rather than the full table.
As always, checking the... |
321,180 | <p>I want to write unit tests with NUnit that hit the database. I'd like to have the database in a consistent state for each test. I thought transactions would allow me to "undo" each test so I searched around and found several articles from 2004-05 on the topic:</p>
<ul>
<li><a href="http://weblogs.asp.net/rosherove/... | [
{
"answer_id": 321238,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 2,
"selected": false,
"text": "<p>I would call these integration tests, but no matter. What I have done for such tests is have my setup methods in th... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321180",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29/"
] | I want to write unit tests with NUnit that hit the database. I'd like to have the database in a consistent state for each test. I thought transactions would allow me to "undo" each test so I searched around and found several articles from 2004-05 on the topic:
* <http://weblogs.asp.net/rosherove/archive/2004/07/12/180... | NUnit now has a [Rollback] attribute, but I prefer to do it a different way. I use the [TransactionScope](http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx) class. There are a couple of ways to use it.
```
[Test]
public void YourTest()
{
using (TransactionScope scope = new Transact... |
321,193 | <p><strong>Problem</strong><br>
I've got a number of Dojo components on a page. When the user tries to tab from an input like component to a grid like component, I get a JavaScript "Can't move focus to control" error. The user base uses IE6. </p>
<p><strong>Solution</strong><br>
The first element in the DojoX Grid l... | [
{
"answer_id": 321200,
"author": "Jaime Garcia",
"author_id": 32812,
"author_profile": "https://Stackoverflow.com/users/32812",
"pm_score": 1,
"selected": false,
"text": "<p>You have to handle the keydown event and listen for character 9 (which is the tab character). To invalidate the ev... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321193",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | **Problem**
I've got a number of Dojo components on a page. When the user tries to tab from an input like component to a grid like component, I get a JavaScript "Can't move focus to control" error. The user base uses IE6.
**Solution**
The first element in the DojoX Grid layout cannot be hidden. If it is hidden,... | **Solution**
The first element in the DojoX Grid layout cannot be hidden. If it is hidden, you get a a JavaScript "Can't move focus to control" error. To fix this, I added a row # that displays. See below.
>
>
> ```
> var gridLayout = [
> new dojox.grid.cells.RowIndex({ name: "row #",
> ... |
321,203 | <p>I am trying to generate some code at runtime using the DynamicMethod class in the Reflection.Emit namespace but for some reason its throwing a "VerificationException". Here is the IL code I am trying to use...</p>
<pre><code>ldarg.1
ldarg.0
ldfld, System.String FirstName
callvirt, Void Write(System.String)
ldarg.1
... | [
{
"answer_id": 321210,
"author": "Rob Walker",
"author_id": 3631,
"author_profile": "https://Stackoverflow.com/users/3631",
"pm_score": 2,
"selected": false,
"text": "<p>Try using the <a href=\"http://msdn.microsoft.com/en-us/library/62bwd2yd(VS.80).aspx\" rel=\"nofollow noreferrer\">pev... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321203",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39648/"
] | I am trying to generate some code at runtime using the DynamicMethod class in the Reflection.Emit namespace but for some reason its throwing a "VerificationException". Here is the IL code I am trying to use...
```
ldarg.1
ldarg.0
ldfld, System.String FirstName
callvirt, Void Write(System.String)
ldarg.1
ldarg.0
ldfld,... | I have found some more help here...
[DebuggerVisualizer for DynamicMethod (Show me the IL)](http://blogs.msdn.com/haibo_luo/archive/2005/10/25/484861.aspx) It's is a debugger visualizer using which you will be able to see the generated IL at runtime!
And even better is [Debugging LCG](http://blogs.msdn.com/yirutang/... |
321,204 | <p>I had a fresh look at Haxe again recently and realized that I had overlooked some of its elegance before. But I guess it lacks some visibility among the developers still.</p>
<p>So my question is, does anybody here use it for production? If so, how do you use it? What are the gotchas or difficulties you encounter? ... | [
{
"answer_id": 321330,
"author": "Andru Luvisi",
"author_id": 5922,
"author_profile": "https://Stackoverflow.com/users/5922",
"pm_score": 4,
"selected": false,
"text": "<p>You might find some useful information in the lists of <a href=\"http://old.haxe.org/com/projects\" rel=\"nofollow n... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321204",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7988/"
] | I had a fresh look at Haxe again recently and realized that I had overlooked some of its elegance before. But I guess it lacks some visibility among the developers still.
So my question is, does anybody here use it for production? If so, how do you use it? What are the gotchas or difficulties you encounter? Do you rec... | I use Haxe to develop all my Flash applications, and I love it. I develop on Linux and with Emacs,
and I really like how I can make Haxe fit within my preferred development environment. I just use
simple Makefiles that look something like:
```
project.swf: Project.hx
haxe project.hxml
```
It's really easy to g... |
321,220 | <p>I am looking for a Visual Studio add-in that would analyze the text around the cursor position and navigate to the corresponding class definition.</p>
<p>For example I have this XML file that is currently open:</p>
<pre><code><object id="abc" type="MyProject.Foo.Bar, MyProject"/>
</code></pre>
<p>If I put t... | [
{
"answer_id": 321357,
"author": "Gishu",
"author_id": 1695,
"author_profile": "https://Stackoverflow.com/users/1695",
"pm_score": 3,
"selected": true,
"text": "<p>Well you could use the '<strong><a href=\"http://msdn.microsoft.com/en-us/library/f5yx24a6(VS.80).aspx\" rel=\"nofollow nore... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321220",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29407/"
] | I am looking for a Visual Studio add-in that would analyze the text around the cursor position and navigate to the corresponding class definition.
For example I have this XML file that is currently open:
```
<object id="abc" type="MyProject.Foo.Bar, MyProject"/>
```
If I put the cursor somewhere between the double ... | Well you could use the '**[Code Definition Window](http://msdn.microsoft.com/en-us/library/f5yx24a6(VS.80).aspx)**' that comes with the VS2008 IDE. When you place your cursor, the Code Def window dynamically updates with the source code for that type. *Works with regular source files.. don't have the IDE at hand to ver... |
321,229 | <p>I would like to be able to fusion an <code>IEnumerable<IEnumerable<T>></code> into <code>IEnumerable<T></code> (i.e. merge all individual collections into one). The <code>Union</code> operators only applies to two collections. Any idea?</p>
| [
{
"answer_id": 321235,
"author": "JaredPar",
"author_id": 23283,
"author_profile": "https://Stackoverflow.com/users/23283",
"pm_score": 8,
"selected": true,
"text": "<p>Try </p>\n\n<pre><code>var it = GetTheNestedCase();\nreturn it.SelectMany(x => x);\n</code></pre>\n\n<p>SelectMany i... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321229",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18858/"
] | I would like to be able to fusion an `IEnumerable<IEnumerable<T>>` into `IEnumerable<T>` (i.e. merge all individual collections into one). The `Union` operators only applies to two collections. Any idea? | Try
```
var it = GetTheNestedCase();
return it.SelectMany(x => x);
```
SelectMany is a LINQ transformation which essentially says "For Each Item in a collection return the elements of a collection". It will turn one element into many (hence SelectMany). It's great for breaking down collections of collections into a... |
321,239 | <p>I'd like to hide a div when user click anywhere on the page outside of that div. How can I do that using raw javascript or jQuery?</p>
| [
{
"answer_id": 321256,
"author": "VonC",
"author_id": 6309,
"author_profile": "https://Stackoverflow.com/users/6309",
"pm_score": 2,
"selected": false,
"text": "<p>First idea, in raw javascript (from <a href=\"http://www.webdeveloper.com/forum/showpost.php?p=465274&postcount=4\" rel=... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321239",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11439/"
] | I'd like to hide a div when user click anywhere on the page outside of that div. How can I do that using raw javascript or jQuery? | Attach a click event to the document to hide the div:
```
$(document).click(function(e) {
$('#somediv').hide();
});
```
Attach a click event to the div to stop clicks on it from propagating to the document:
```
$('#somediv').click(function(e) {
e.stopPropagation();
});
``` |
321,260 | <p>I want to add the current month, and the previous two months to a prompt, for a user to select. </p>
<p>e.g. if this month is <code>2008 Nov</code>, <code>ddlbox</code> should show the following:</p>
<pre><code>112008
102008
092008
</code></pre>
<p>How can I do this? </p>
| [
{
"answer_id": 321303,
"author": "VB For the WIN",
"author_id": 36864,
"author_profile": "https://Stackoverflow.com/users/36864",
"pm_score": 2,
"selected": false,
"text": "<pre><code><asp:DropDownList ID=\"DropDownList1\" runat=\"server\">\n</asp:DropDownList>\n\nfor (int i ... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321260",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I want to add the current month, and the previous two months to a prompt, for a user to select.
e.g. if this month is `2008 Nov`, `ddlbox` should show the following:
```
112008
102008
092008
```
How can I do this? | ```
<asp:DropDownList ID="DropDownList1" runat="server">
</asp:DropDownList>
for (int i = 0; i < 3; i++)
{
ListItem item = new ListItem(string.Format("{0: MM/yyyy}", DateTime.Now.AddMonths(-i)));
DropDownList1.Items.Add(item);
}
```
Try this :) |
321,265 | <p>I have see code like this</p>
<pre><code>Dim s as something = new something
Dim s as new something
</code></pre>
<p>what's the difference? is there any?</p>
| [
{
"answer_id": 321286,
"author": "Ian P",
"author_id": 10853,
"author_profile": "https://Stackoverflow.com/users/10853",
"pm_score": -1,
"selected": false,
"text": "<p>I believe all you're doing is specifically casting something as something.</p>\n"
},
{
"answer_id": 321288,
... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321265",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28647/"
] | I have see code like this
```
Dim s as something = new something
Dim s as new something
```
what's the difference? is there any? | A slight difference.
The first allows you to do:
```
Dim s as ParentType = new InheritedType
```
The second doesn't.
The "advantage" of this is `s` can be a number of different types related to ParentType without it exploding at runtime. |
321,272 | <p>I am trying to validate xml file against schema using <a href="http://search.cpan.org/~samtregar/XML-Validator-Schema/Schema.pm" rel="nofollow noreferrer">XML::Validator::Schema</a>.<br>
But it gives me this error:</p>
<pre><code>Found unexpected <Submission> inside <<<<ROOT>>>>. This... | [
{
"answer_id": 321371,
"author": "MattK",
"author_id": 13774,
"author_profile": "https://Stackoverflow.com/users/13774",
"pm_score": 1,
"selected": false,
"text": "<p>Looks like you don't have a submission element in your xsd.\nI also don't see a return element.\nYou want to define that.... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321272",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am trying to validate xml file against schema using [XML::Validator::Schema](http://search.cpan.org/~samtregar/XML-Validator-Schema/Schema.pm).
But it gives me this error:
```
Found unexpected <Submission> inside <<<<ROOT>>>>. This is not a valid child element. [Ln: 2, Col:119]
```
Note: `<Submission>` is the ... | You have defined several types, but you have not defined any elements (except those defined as sub-components of the types you *have* defined). Not only is `<Submission>` not defined, neither is `<Return>` (which is its immediate child-element) nor any of `<NR4>`, `<NR4Slip>`, etc.
You'll need a series of `<xsd:elemen... |
321,304 | <p>I've written this to try and log onto a forum (phpBB3).</p>
<pre><code>import urllib2, re
import urllib, re
logindata = urllib.urlencode({'username': 'x', 'password': 'y'})
page = urllib.urlopen("http://www.woarl.com/board/ucp.php?mode=login"[logindata])
output = page.read()
</code></pre>
<p>However when I run it ... | [
{
"answer_id": 321316,
"author": "Patrick Desjardins",
"author_id": 13913,
"author_profile": "https://Stackoverflow.com/users/13913",
"pm_score": 1,
"selected": false,
"text": "<p>Your URL string shouldn't be </p>\n\n<pre><code>\"http://www.woarl.com/board/ucp.php?mode=login\"[logindata]... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321304",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33061/"
] | I've written this to try and log onto a forum (phpBB3).
```
import urllib2, re
import urllib, re
logindata = urllib.urlencode({'username': 'x', 'password': 'y'})
page = urllib.urlopen("http://www.woarl.com/board/ucp.php?mode=login"[logindata])
output = page.read()
```
However when I run it it comes up with;
```
Tra... | Your line
```
page = urllib.urlopen("http://www.woarl.com/board/ucp.php?mode=login"[logindata])
```
is semantically invalid Python. Presumably you meant
```
page = urllib.urlopen("http://www.woarl.com/board/ucp.php?mode=login", [logindata])
```
which has a comma separating the arguments. However, what you ACTUALL... |
321,327 | <p>I have a situation where I am using wpf data binding and validation using the ExceptionValidationRule.</p>
<p>Another part of the solution invovles collapsing some panels and showing others.</p>
<p>If a validation exception is set - i.e. the UI is showing a red border around the UI element with the validation prob... | [
{
"answer_id": 321367,
"author": "Sam Meldrum",
"author_id": 16005,
"author_profile": "https://Stackoverflow.com/users/16005",
"pm_score": 1,
"selected": false,
"text": "<p>I have an answer to the problem myself which is to change my button click event which changes the visibility of the... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321327",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16005/"
] | I have a situation where I am using wpf data binding and validation using the ExceptionValidationRule.
Another part of the solution invovles collapsing some panels and showing others.
If a validation exception is set - i.e. the UI is showing a red border around the UI element with the validation problem, and the cont... | If I remember correctly, this is a known issue. We re-templated textbox to include the following:
```
<Setter Property="Validation.ErrorTemplate">
<Setter.Value>
<ControlTemplate>
<ControlTemplate.Resources>
<BooleanToVisibilityConverter x:Key="converter" />
</ControlTem... |
321,348 | <p>Both about <code>-a</code> and <code>-e</code> options in <a href="http://www.gnu.org/software/bash/manual/bashref.html#Bash-Conditional-Expressions" rel="noreferrer">Bash documentation</a> is said:</p>
<pre><code>-a file
True if file exists.
-e file
True if file exists.
</code></pre>
<p>Trying to get wha... | [
{
"answer_id": 321352,
"author": "Johannes Schaub - litb",
"author_id": 34509,
"author_profile": "https://Stackoverflow.com/users/34509",
"pm_score": 7,
"selected": true,
"text": "<p>I researched, and this is quite hairy:</p>\n\n<p><code>-a</code> is deprecated, thus isn't listed in the ... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321348",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15647/"
] | Both about `-a` and `-e` options in [Bash documentation](http://www.gnu.org/software/bash/manual/bashref.html#Bash-Conditional-Expressions) is said:
```
-a file
True if file exists.
-e file
True if file exists.
```
Trying to get what the difference is I ran the following script:
```
resin_dir=/Test/Resin_w... | I researched, and this is quite hairy:
`-a` is deprecated, thus isn't listed in the manpage for `/usr/bin/test` anymore, but still in the one for bash. Use `-e` . For single '[', the bash builtin behaves the same as the `test` bash builtin, which behaves the same as `/usr/bin/[` and `/usr/bin/test` (the one is a symli... |
321,351 | <p>I have a structure which I create a custom constructor to initialize the members to 0's. I've seen in older compilers that when in release mode, without doing a memset to 0, the values are not initialized.</p>
<p>I now want to use this structure in a union, but get errors because it has a non-trivial constructor.<... | [
{
"answer_id": 321366,
"author": "John Dibling",
"author_id": 241536,
"author_profile": "https://Stackoverflow.com/users/241536",
"pm_score": 0,
"selected": false,
"text": "<p>Can you do something like this?</p>\n\n<pre><code>class Outer\n{\npublic:\n Outer()\n {\n memset(&a... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321351",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16496/"
] | I have a structure which I create a custom constructor to initialize the members to 0's. I've seen in older compilers that when in release mode, without doing a memset to 0, the values are not initialized.
I now want to use this structure in a union, but get errors because it has a non-trivial constructor.
So, questi... | Question 1: Default constructors do initialize POD members to 0 according to the C++ standard. See the quoted text below.
Question 2: If a constructor must be specified in a base class, then that class cannot be part of a union.
Finally, you can provide a constructor for your union:
```
union U
{
A a;
B b;
... |
321,355 | <p>How would I set the "overwrite as needed" setting on Event logs other than Application/Security/System? Specifically I'd like to apply this to the Powershell and Windows Powershell Logs, in addition to any other future logs that may be added. This needs to be applied to both server 2003 & 2008.</p>
| [
{
"answer_id": 321415,
"author": "Don Jones",
"author_id": 40405,
"author_profile": "https://Stackoverflow.com/users/40405",
"pm_score": 0,
"selected": false,
"text": "<p>Right now you'd need to use SDM Software's GPO cmdlets. That's the only way from within PowerShell to modify the sett... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321355",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1635/"
] | How would I set the "overwrite as needed" setting on Event logs other than Application/Security/System? Specifically I'd like to apply this to the Powershell and Windows Powershell Logs, in addition to any other future logs that may be added. This needs to be applied to both server 2003 & 2008. | I don't believe their is a GPO for this. But most group policies simply modify the registry.
You could create an adm template that modified the settings, or you could simply write a script to adjust the settings.
```
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog\PowerShell
```
If you are not sure ho... |
321,370 | <p>Can we convert a hex string to a byte array using a built-in function in C# or do I have to make a custom method for this?</p>
| [
{
"answer_id": 321404,
"author": "JaredPar",
"author_id": 23283,
"author_profile": "https://Stackoverflow.com/users/23283",
"pm_score": 10,
"selected": true,
"text": "<p>Here's a nice fun LINQ example.</p>\n\n<pre><code>public static byte[] StringToByteArray(string hex) {\n return Enu... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321370",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39677/"
] | Can we convert a hex string to a byte array using a built-in function in C# or do I have to make a custom method for this? | Here's a nice fun LINQ example.
```
public static byte[] StringToByteArray(string hex) {
return Enumerable.Range(0, hex.Length)
.Where(x => x % 2 == 0)
.Select(x => Convert.ToByte(hex.Substring(x, 2), 16))
.ToArray();
}
``` |
321,375 | <p>I seem to often find myself wanting to store data of more than one type (usually specifically integers and text) in the same column in a MySQL database. I know this is horrible, but the reason it happens is when I'm storing responses that people have made to questions in a questionnaire. Some questions need an integ... | [
{
"answer_id": 321389,
"author": "Ray",
"author_id": 40866,
"author_profile": "https://Stackoverflow.com/users/40866",
"pm_score": 0,
"selected": false,
"text": "<p>Option 2 is the correct, most normalized option.</p>\n"
},
{
"answer_id": 321444,
"author": "Community",
"a... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321375",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11522/"
] | I seem to often find myself wanting to store data of more than one type (usually specifically integers and text) in the same column in a MySQL database. I know this is horrible, but the reason it happens is when I'm storing responses that people have made to questions in a questionnaire. Some questions need an integer ... | [Option 2 is] NOT the most normalized option [as @Ray claims]. The most normalized would have no nullable fields and obviously option 2 would require a null on every row.
At this point in your design you have to think about the usage, the queries you'll do, the reports you'll write. Will you want to do math on all of ... |
321,377 | <p>I'm adding some lazy initialization logic to a const method, which makes the method in fact not const. Is there a way for me to do this without having to remove the "const" from the public interface?</p>
<pre><code>int MyClass::GetSomeInt() const
{
// lazy logic
if (m_bFirstTime)
{
m_bFirstTime... | [
{
"answer_id": 321385,
"author": "e.James",
"author_id": 33686,
"author_profile": "https://Stackoverflow.com/users/33686",
"pm_score": 1,
"selected": false,
"text": "<p>set the m_bFirstTime member to be mutable</p>\n"
},
{
"answer_id": 321387,
"author": "John Dibling",
"a... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321377",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9328/"
] | I'm adding some lazy initialization logic to a const method, which makes the method in fact not const. Is there a way for me to do this without having to remove the "const" from the public interface?
```
int MyClass::GetSomeInt() const
{
// lazy logic
if (m_bFirstTime)
{
m_bFirstTime = false;
... | Make m\_bFirstTime mutable:
```
class MyClass
{
: :
mutable bool m_bFirstTime;
};
```
...but this is also very often an indication of a design flaw. So beware. |
321,378 | <p>This only happens with IE (all versions), on line 1120 in
jquery-1.2.6.js I get the following error:</p>
<pre><code>Line 1120:
Invalid Property Value
</code></pre>
<p>The line in the js file is the following:</p>
<pre><code>elem[name] = value;
</code></pre>
<p>It is inside attr: <code>function( elem, name, value... | [
{
"answer_id": 321416,
"author": "Simon",
"author_id": 33036,
"author_profile": "https://Stackoverflow.com/users/33036",
"pm_score": 3,
"selected": false,
"text": "<p>If <a href=\"http://groups.google.com/group/jquery-en/browse_thread/thread/3ef3a830916b2fbb\" rel=\"nofollow noreferrer\"... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321378",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | This only happens with IE (all versions), on line 1120 in
jquery-1.2.6.js I get the following error:
```
Line 1120:
Invalid Property Value
```
The line in the js file is the following:
```
elem[name] = value;
```
It is inside attr: `function( elem, name, value )`
Does anybody have a problem similar to this? | If [this](http://groups.google.com/group/jquery-en/browse_thread/thread/3ef3a830916b2fbb) is also you, it sounds like you're trying to change the CSS of the element rather than give it an attribute.
If that is the case then try this instead;
```
jQuery.css('color', 'inherit');
``` |
321,403 | <p>How would I go about adding the "Spent Time" as a column to be displayed in the issues list?</p>
| [
{
"answer_id": 329323,
"author": "Joel Meador",
"author_id": 1976,
"author_profile": "https://Stackoverflow.com/users/1976",
"pm_score": 1,
"selected": false,
"text": "<p>Since no one answered, I just poked the source until it yielded results. Then I started a blog to explain how I did ... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321403",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1976/"
] | How would I go about adding the "Spent Time" as a column to be displayed in the issues list? | You can also do this by adding the column at runtime. This will add the spent hours column without modifying the Redmine core. Just drop the following code into a file in lib/
Adapted from:
* [Redmine Budget Plugin](http://github.com/edavis10/redmine-budget-plugin/tree/master/lib/query_patch.rb)
* [Redmine Question P... |
321,412 | <p>Take the following html</p>
<pre><code><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Basic Layout</title>
<style type="text/css">
html,body,div{font-family:Verdana}
#Head{... | [
{
"answer_id": 324589,
"author": "tomjen",
"author_id": 21133,
"author_profile": "https://Stackoverflow.com/users/21133",
"pm_score": 2,
"selected": true,
"text": "<p>It is unlikely that you will find a library to read that file for C# - there aren't that many Unix users who also use C#.... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321412",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Take the following html
```
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Basic Layout</title>
<style type="text/css">
html,body,div{font-family:Verdana}
#Head{border-bottom:solid 10px #369}
#Body{margi... | It is unlikely that you will find a library to read that file for C# - there aren't that many Unix users who also use C#.
What I would do would be either to:
1. Read the Python code, and then port it to C#
2. Find the description of the mbox format online. As it is a Unix system, chances are that the format is just a... |
321,413 | <p>What the difference between <code>LPCSTR</code>, <code>LPCTSTR</code> and <code>LPTSTR</code>?</p>
<p>Why do we need to do this to convert a string into a <code>LV</code> / <code>_ITEM</code> structure variable <code>pszText</code>: </p>
<pre><code>LV_DISPINFO dispinfo;
dispinfo.item.pszText = LPTSTR((LPCTSTR)s... | [
{
"answer_id": 321447,
"author": "Tim",
"author_id": 10755,
"author_profile": "https://Stackoverflow.com/users/10755",
"pm_score": 7,
"selected": false,
"text": "<p>Quick and dirty:</p>\n<p><code>LP</code> == <strong>L</strong>ong <strong>P</strong>ointer. Just think pointer or char*</p... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321413",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41090/"
] | What the difference between `LPCSTR`, `LPCTSTR` and `LPTSTR`?
Why do we need to do this to convert a string into a `LV` / `_ITEM` structure variable `pszText`:
```
LV_DISPINFO dispinfo;
dispinfo.item.pszText = LPTSTR((LPCTSTR)string);
``` | To answer the first part of your question:
`LPCSTR` is a pointer to a const string (LP means [Long Pointer](https://stackoverflow.com/questions/2315311/what-is-a-long-pointer))
`LPCTSTR` is a pointer to a `const TCHAR` string, (`TCHAR` being either a wide char or char depending on whether UNICODE is defined in your p... |
321,417 | <p>I'm trying to set the initial display order of the column headers in a silverlight datagrid by changing the column header DisplayIndex values. If I try to set the column order at page load time, I get an out of range exception. If I set the column order (same routine) at a later time like, in a button click handler,... | [
{
"answer_id": 343664,
"author": "David Padbury",
"author_id": 26401,
"author_profile": "https://Stackoverflow.com/users/26401",
"pm_score": 1,
"selected": false,
"text": "<p>I'm guessing that you've got a problem modifying the DisplayIndex of the columns in the DataGrid from the Page Lo... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321417",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11930/"
] | I'm trying to set the initial display order of the column headers in a silverlight datagrid by changing the column header DisplayIndex values. If I try to set the column order at page load time, I get an out of range exception. If I set the column order (same routine) at a later time like, in a button click handler, it... | I'm guessing that you've got a problem modifying the DisplayIndex of the columns in the DataGrid from the Page Loaded event as they haven't yet been created at this point. You don't say but I assume you're getting the DataGrid to AutoGenerate your columns as otherwise you could just set the DisplayIndex in your XAML wh... |
321,418 | <p>Consider the code:</p>
<pre><code>PreparedStatement ps = null;
ResultSet rs = null;
try {
ps = conn.createStatement(myQueryString);
rs = ps.executeQuery();
// process the results...
} catch (java.sql.SQLException e) {
log.error("an error!", e);
throw new MyAppException("I'm sorry. Your query did not work.... | [
{
"answer_id": 321446,
"author": "Michael Myers",
"author_id": 13531,
"author_profile": "https://Stackoverflow.com/users/13531",
"pm_score": 5,
"selected": true,
"text": "<p>For file I/O, I generally add a try/catch to the finally block. However, you must be careful not to throw any exce... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321418",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1094969/"
] | Consider the code:
```
PreparedStatement ps = null;
ResultSet rs = null;
try {
ps = conn.createStatement(myQueryString);
rs = ps.executeQuery();
// process the results...
} catch (java.sql.SQLException e) {
log.error("an error!", e);
throw new MyAppException("I'm sorry. Your query did not work.");
} finally ... | For file I/O, I generally add a try/catch to the finally block. However, you must be careful not to throw any exceptions from the finally block, since they will cause the original exception (if any) to be lost.
See [this article](http://accu.org/index.php/journals/236) for a more specific example of database connectio... |
321,465 | <p>So I have this app that checks for updates on the server getting a JSON response, each new update is put at the top of my list on a new div that is added via insertBefore using javascript.</p>
<p>All works just fine, but i'd like to add an animation effect when the div is added, i.e. "slowly" move the existing divs... | [
{
"answer_id": 321520,
"author": "dlamblin",
"author_id": 459,
"author_profile": "https://Stackoverflow.com/users/459",
"pm_score": 1,
"selected": false,
"text": "<p>It depends on the JavaScript framework you're using; but look at <a href=\"http://demos.mootools.net/Fx.Slide\" rel=\"nofo... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321465",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23238/"
] | So I have this app that checks for updates on the server getting a JSON response, each new update is put at the top of my list on a new div that is added via insertBefore using javascript.
All works just fine, but i'd like to add an animation effect when the div is added, i.e. "slowly" move the existing divs down, and... | Since you are looking to do it yourself you'll need to use setTimeout to repeatedly change the height of your div. The basic, quick and dirty code looks something like this:
```
var newDiv;
function insertNewDiv() {
// This is called when you realize something was updated
// ...
newDiv = document.creat... |
321,468 | <p>Apology for a lengthy post, but I needed to post some code to illustrate the problem.</p>
<p>Inspired by the question *<a href="https://stackoverflow.com/questions/321299">What is the reason not to use select <em>?</a></em>, I decided to point out some observations of the select * behaviour that I noticed some time... | [
{
"answer_id": 323103,
"author": "gbn",
"author_id": 27535,
"author_profile": "https://Stackoverflow.com/users/27535",
"pm_score": 5,
"selected": true,
"text": "<p><a href=\"http://msdn.microsoft.com/en-us/library/ms187821(SQL.90).aspx\" rel=\"noreferrer\">sp_refreshview</a> to fix the v... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321468",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3241/"
] | Apology for a lengthy post, but I needed to post some code to illustrate the problem.
Inspired by the question \*[What is the reason not to use select *?*](https://stackoverflow.com/questions/321299), I decided to point out some observations of the select \* behaviour that I noticed some time ago.
So let's the code s... | [sp\_refreshview](http://msdn.microsoft.com/en-us/library/ms187821(SQL.90).aspx) to fix the view, or use WITH SCHEMABINDING in the view definition
>
> If a view is not created with the
> SCHEMABINDING clause, sp\_refreshview
> should be run when changes are made to
> the objects underlying the view that
> affect ... |
321,477 | <p>I am printing out a list of college majors we offer, then within each major, we have concentrations for each major.</p>
<p>Our Science Major has the following concentrations: Environmental Science & Forestry, Chiropractic, Chemistry, Biology</p>
<p>Here is a screen shot of what it is doing:
<a href="https://i.... | [
{
"answer_id": 321562,
"author": "strager",
"author_id": 39992,
"author_profile": "https://Stackoverflow.com/users/39992",
"pm_score": 0,
"selected": false,
"text": "<p>Try float: right instead of float: left.</p>\n\n<p>This works for Firefox 2. Doesn't work with (many) other browsers.<... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321477",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26130/"
] | I am printing out a list of college majors we offer, then within each major, we have concentrations for each major.
Our Science Major has the following concentrations: Environmental Science & Forestry, Chiropractic, Chemistry, Biology
Here is a screen shot of what it is doing:
[;</style>
</code></pre>
<p>and</p>
<pre><code><link rel="stylesheet" type="text/css" href="style.... | [
{
"answer_id": 321489,
"author": "Javier",
"author_id": 11649,
"author_profile": "https://Stackoverflow.com/users/11649",
"pm_score": 0,
"selected": false,
"text": "<p>the first one is, in fact, an embedded CSS that refers to another file; while the second one is a direct refer from HTML... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321478",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27090/"
] | I've been reading through a few tutorials about css, and I saw two different ways to state which css file should be used to style the page:
```
<style type="text/css">@import url("style.css");</style>
```
and
```
<link rel="stylesheet" type="text/css" href="style.css" />
```
What's the difference between them? Wh... | There isn't much difference unless you are using **very** old browsers (netscape 4.x and ie 3.x). You can read a complete lowdown on what each means [here](http://webdesign.about.com/od/beginningcss/f/css_import_link.htm).
>
> From a standards viewpoint, there is no difference between linking to an external style she... |
321,494 | <p>I have a cron "time definition"</p>
<pre><code>1 * * * * (every hour at xx:01)
2 5 * * * (every day at 05:02)
0 4 3 * * (every third day of the month at 04:00)
* 2 * * 5 (every minute between 02:00 and 02:59 on fridays)
</code></pre>
<p>And I have an unix timestamp.</p>
<p>Is there an obvious way to find (calcula... | [
{
"answer_id": 321499,
"author": "Ray",
"author_id": 40866,
"author_profile": "https://Stackoverflow.com/users/40866",
"pm_score": 2,
"selected": false,
"text": "<p>Check <a href=\"http://www.phpclasses.org/browse/package/2568.html\" rel=\"noreferrer\">this out</a>:</p>\n\n<blockquote>It... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321494",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/999/"
] | I have a cron "time definition"
```
1 * * * * (every hour at xx:01)
2 5 * * * (every day at 05:02)
0 4 3 * * (every third day of the month at 04:00)
* 2 * * 5 (every minute between 02:00 and 02:59 on fridays)
```
And I have an unix timestamp.
Is there an obvious way to find (calculate) the next time (after that giv... | This is basically doing the reverse of checking if the current time fits the conditions. so something like:
```
//Totaly made up language
next = getTimeNow();
next.addMinutes(1) //so that next is never now
done = false;
while (!done) {
if (cron.minute != '*' && next.minute != cron.minute) {
if (next.minute > cro... |
321,522 | <p>I'm having a weird issue with a particular UITableView in my iPhone devel experience here. If you look at the following screenshot:</p>
<p><a href="http://dl-client.getdropbox.com/u/57676/brokencell.png" rel="nofollow noreferrer">alt text http://dl-client.getdropbox.com/u/57676/brokencell.png</a></p>
<p>you'll not... | [
{
"answer_id": 321937,
"author": "jpm",
"author_id": 35478,
"author_profile": "https://Stackoverflow.com/users/35478",
"pm_score": 0,
"selected": false,
"text": "<p>Are you doing anything special in your -tableView:heightForRowAtIndexPath: method?</p>\n\n<p>It looks to me like the height... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321522",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40882/"
] | I'm having a weird issue with a particular UITableView in my iPhone devel experience here. If you look at the following screenshot:
[alt text http://dl-client.getdropbox.com/u/57676/brokencell.png](http://dl-client.getdropbox.com/u/57676/brokencell.png)
you'll notice a strike through going through the middle of the '... | I've had a similar problem. For me, the single line was caused by a superfluous view that was created but never sized or placed correctly and so was 1 pixel high, floating over everything else. You can also cause this by confusing a UINavigationController about its set of subviews (by adding views directly to its layou... |
321,543 | <p>I am creating a data source for reporting model (SQL Server Reporting Services).
The reports requires a lot of joins and calculations (let's say, calculating financial parameters like money spent on this, that, amount A vs amount B)...all this involves subobjects.</p>
<p>It makes a lot of sense to me to write unit ... | [
{
"answer_id": 321579,
"author": "dr_pepper",
"author_id": 18415,
"author_profile": "https://Stackoverflow.com/users/18415",
"pm_score": 2,
"selected": false,
"text": "<p>I recommend getting started with <a href=\"http://www.mozart-oz.org/\" rel=\"nofollow noreferrer\">mozart</a>. It is... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321543",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38325/"
] | I am creating a data source for reporting model (SQL Server Reporting Services).
The reports requires a lot of joins and calculations (let's say, calculating financial parameters like money spent on this, that, amount A vs amount B)...all this involves subobjects.
It makes a lot of sense to me to write unit tests for ... | There is a lot of excellent material available on the web once you get in the groove, but the links below are (IMO) good starting points (the ones I used).
[Programming with Constraints: An Introduction - (Course website)](https://people.eng.unimelb.edu.au/pstuckey/book/course.html)
[Programming with Constraints: A... |
321,549 | <p>What is the best way to convert a double to a long without casting?</p>
<p>For example:</p>
<pre><code>double d = 394.000;
long l = (new Double(d)).longValue();
System.out.println("double=" + d + ", long=" + l);
</code></pre>
| [
{
"answer_id": 321558,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 8,
"selected": false,
"text": "<p>Assuming you're happy with truncating towards zero, just cast:</p>\n\n<pre><code>double d = 1234.56;\nlong x = (long)... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321549",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | What is the best way to convert a double to a long without casting?
For example:
```
double d = 394.000;
long l = (new Double(d)).longValue();
System.out.println("double=" + d + ", long=" + l);
``` | Assuming you're happy with truncating towards zero, just cast:
```
double d = 1234.56;
long x = (long) d; // x = 1234
```
This will be faster than going via the wrapper classes - and more importantly, it's more readable. Now, if you need rounding other than "always towards zero" you'll need slightly more complicated... |
321,566 | <p>I would like to return all rows from <code>TableA</code> table that does not exists in another table.</p>
<p>e.g. </p>
<pre><code>select bench_id from TableA where bench_id not in (select bench_id from TableB )
</code></pre>
<p>can you please help me write equivalent LINQ query. Here <code>TableA</code> is from... | [
{
"answer_id": 321574,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 2,
"selected": false,
"text": "<p>So if table A is from Excel, are you loading the data into memory first? If so (i.e. you're using LINQ to Objects) th... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321566",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I would like to return all rows from `TableA` table that does not exists in another table.
e.g.
```
select bench_id from TableA where bench_id not in (select bench_id from TableB )
```
can you please help me write equivalent LINQ query. Here `TableA` is from Excel and `TableB` is from a Database
I am loading Exc... | So if table A is from Excel, are you loading the data into memory first? If so (i.e. you're using LINQ to Objects) then I suggest you load the IDs in table B into a set and then use:
```
var query = tableA.Where(entry => !tableBIdSet.Contains(entry.Id));
```
If this isn't appropriate, please give more details.
Conv... |
321,571 | <p>This is probably a simple question, and I'm slightly embarrassed to ask it, but I've been working with this chunk of JavaScript ad code for a while and it's bothered me that it's never really made sense to me and is probably out dated now with modern browsers. My question is, do we need to check for browser types st... | [
{
"answer_id": 321580,
"author": "Ali Afshar",
"author_id": 28380,
"author_profile": "https://Stackoverflow.com/users/28380",
"pm_score": 3,
"selected": false,
"text": "<p>Mostly we use javascript libraries like <a href=\"http://jquery.com/\" rel=\"nofollow noreferrer\">jQuery</a> which ... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321571",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16124/"
] | This is probably a simple question, and I'm slightly embarrassed to ask it, but I've been working with this chunk of JavaScript ad code for a while and it's bothered me that it's never really made sense to me and is probably out dated now with modern browsers. My question is, do we need to check for browser types still... | On the second snippet of code:
it's checking for two things:
* That the browser opening the document supports the document.images portion of the DOM, that the document contains any images, and the browser's UserAgent string (an identifier) contains "Mozilla/2.",
* OR that the UserAgent string contains "WebTV"
in thos... |
321,572 | <p>I have Enitity Type, Name of Primary Key and Guid of Primary Id. I want to get element of such Id in LinqToSql.</p>
<pre><code>model.GetTable<T>().Where(t => here equality );
</code></pre>
<p>I think I need to generate that Expression myself, but I dont know how :(</p>
| [
{
"answer_id": 323699,
"author": "Igor Golodnitsky",
"author_id": 40789,
"author_profile": "https://Stackoverflow.com/users/40789",
"pm_score": 1,
"selected": true,
"text": "<p>I look forward, and after searching through generated by compiler code, in Reflector I found this creation of l... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321572",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40789/"
] | I have Enitity Type, Name of Primary Key and Guid of Primary Id. I want to get element of such Id in LinqToSql.
```
model.GetTable<T>().Where(t => here equality );
```
I think I need to generate that Expression myself, but I dont know how :( | I look forward, and after searching through generated by compiler code, in Reflector I found this creation of lambda.
```
public static T GetById(Guid id)
{
Type entType = typeof(T);
if (!CheckTable(entType)) {
throw new TypeLoadException(string.Format(
"{0} is not... |
321,582 | <p>I've recently written this with help from SO. Now could someone please tell me how to make it actually log onto the board. It brings up everything just in a non logged in format.</p>
<pre><code>import urllib2, re
import urllib, re
logindata = urllib.urlencode({'username': 'x', 'password': 'y'})
page = urllib2.urlo... | [
{
"answer_id": 321601,
"author": "rebra",
"author_id": 2282296,
"author_profile": "https://Stackoverflow.com/users/2282296",
"pm_score": 2,
"selected": false,
"text": "<p>You probably want to look into preserving cookies from the server.</p>\n\n<p><a href=\"http://pycurl.sourceforge.net/... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321582",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33061/"
] | I've recently written this with help from SO. Now could someone please tell me how to make it actually log onto the board. It brings up everything just in a non logged in format.
```
import urllib2, re
import urllib, re
logindata = urllib.urlencode({'username': 'x', 'password': 'y'})
page = urllib2.urlopen("http://www... | Someone recently asked [the same question you're asking](https://stackoverflow.com/questions/301924/python-urlliburllib2httplib-confusion). If you read through the answers to that question you'll see code examples showing you how to stay logged in while browsing a site in a Python script using only stuff in the standar... |
321,585 | <p>I have a site that I am currently working on in ASP.NET 2.0 using the usual WebForm stuff and ASP.NET AJAX 1.0. Is it possible to bind an event to a dynamically created control after the Page.Load event?</p>
<p>I have a table <td> element that I am dynamically creating similarly to this code:</p>
<pre><code>'... | [
{
"answer_id": 321608,
"author": "Kon",
"author_id": 22303,
"author_profile": "https://Stackoverflow.com/users/22303",
"pm_score": 0,
"selected": false,
"text": "<p>You have to add the controls before Page.Load in order to maintain ViewState between postbacks, so use the OnInit event han... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321585",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5862/"
] | I have a site that I am currently working on in ASP.NET 2.0 using the usual WebForm stuff and ASP.NET AJAX 1.0. Is it possible to bind an event to a dynamically created control after the Page.Load event?
I have a table <td> element that I am dynamically creating similarly to this code:
```
' Create Link Button
lnk.ID... | You need to postback the whole page after your data changes in the 'btnClick Event elsewhere on the page'. It sounds like you have an UpdatePanel and it sounds like this is catching the postback of your btnClick event handler. Put the btnClick outside the UpdatePanel or change its triggers so that your btnClick forces ... |
321,622 | <p>How does one read a data file in an iPhone project? For example, lets say I have a static file called "level.dat" that is structured as follows:
obstacles: 10
time: 100
obstacle1: 10,20
...</p>
<p>I would like to read the contents of the file into a NSString then do the parsing. How do I read the contents of a fi... | [
{
"answer_id": 321655,
"author": "Ben Gottlieb",
"author_id": 6694,
"author_profile": "https://Stackoverflow.com/users/6694",
"pm_score": 5,
"selected": true,
"text": "<p>See this answer: <a href=\"https://stackoverflow.com/questions/318341/how-to-fopen-on-the-iphone\">How to fopen() on ... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321622",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21293/"
] | How does one read a data file in an iPhone project? For example, lets say I have a static file called "level.dat" that is structured as follows:
obstacles: 10
time: 100
obstacle1: 10,20
...
I would like to read the contents of the file into a NSString then do the parsing. How do I read the contents of a file into a st... | See this answer: [How to fopen() on the iPhone?](https://stackoverflow.com/questions/318341/how-to-fopen-on-the-iphone) which shows how to get access to resources in your bundle. Once you have the path, just use [NSString stringWithContentsOfFile:encoding:error:].
```
NSString *path = [[NSBundle mainBundle] pathForR... |
321,650 | <p>Given:</p>
<pre><code>FieldInfo field = <some valid string field on type T>;
ParameterExpression targetExp = Expression.Parameter(typeof(T), "target");
ParameterExpression valueExp = Expression.Parameter(typeof(string), "value");
</code></pre>
<p>How do I compile a lambda expression to set the field on the "... | [
{
"answer_id": 321686,
"author": "Barry Kelly",
"author_id": 3712,
"author_profile": "https://Stackoverflow.com/users/3712",
"pm_score": 7,
"selected": true,
"text": "<p><strong>.Net 4.0</strong> : now that there's <code>Expression.Assign</code>, this is easy to do:</p>\n\n<pre><code>Fie... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321650",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18941/"
] | Given:
```
FieldInfo field = <some valid string field on type T>;
ParameterExpression targetExp = Expression.Parameter(typeof(T), "target");
ParameterExpression valueExp = Expression.Parameter(typeof(string), "value");
```
How do I compile a lambda expression to set the field on the "target" parameter to "value"? | **.Net 4.0** : now that there's `Expression.Assign`, this is easy to do:
```
FieldInfo field = typeof(T).GetField("fieldName");
ParameterExpression targetExp = Expression.Parameter(typeof(T), "target");
ParameterExpression valueExp = Expression.Parameter(typeof(string), "value");
// Expression.Property can be used he... |
321,656 | <p>In Qt, when a widget receives focus, how can get a notification about it, so I can execute some custom code? Is there a signal or an event for that?</p>
| [
{
"answer_id": 321677,
"author": "Martin Beckett",
"author_id": 10897,
"author_profile": "https://Stackoverflow.com/users/10897",
"pm_score": 4,
"selected": false,
"text": "<p>There is a \"focusChanged\" signal sent when the focus changes, introduced in Qt 4.1.<br>\nIt has two arguments,... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321656",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | In Qt, when a widget receives focus, how can get a notification about it, so I can execute some custom code? Is there a signal or an event for that? | You can add en `event filter`.
This is an example of an application written with **QtCreator**. This form has a **QComboBox** named ***combobox***.
```
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),ui(new Ui::MainWindow)
{
ui->setupUi(this);
ui->comboBox->installEventFilter(this);
.
... |
321,687 | <p>I have a table with a timestamp field of type datetime. I need to aggregate the data between a defined start and end time into x groups representing time intervals of equal length, where x is supplied as function parameter.</p>
<p>What would be the best way to do this with Hibernate?</p>
<p>EDIT: some explanations... | [
{
"answer_id": 321712,
"author": "toolkit",
"author_id": 3295,
"author_profile": "https://Stackoverflow.com/users/3295",
"pm_score": 2,
"selected": false,
"text": "<p>Hibernate is for mapping between a graph of objects (entities and value-types) and their representation in a relational d... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321687",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33805/"
] | I have a table with a timestamp field of type datetime. I need to aggregate the data between a defined start and end time into x groups representing time intervals of equal length, where x is supplied as function parameter.
What would be the best way to do this with Hibernate?
EDIT: some explanations
mysql Table:
`... | I've tried to solve the same problem. I have to group data by 2-hours interval within one day. In fact, "pure" Hibernate isn't supposed to be used this way. So I added native SQL projection to Hibernate's criteria. For your case it could look like this (I'm using MySQL syntax & functions):
```
int hours = 2; // 2-hour... |
321,701 | <p>I change the FontSize of Text in a Style trigger, this causes the Control containing the text to resize as well. How can I change the Fontsize without affecting the parent's size? </p>
| [
{
"answer_id": 321707,
"author": "Micah",
"author_id": 17744,
"author_profile": "https://Stackoverflow.com/users/17744",
"pm_score": 0,
"selected": false,
"text": "<p>What kind of control are you using? If this is a HeaderedControl like a GroupBox or TabItem then you need to specifically... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321701",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26092/"
] | I change the FontSize of Text in a Style trigger, this causes the Control containing the text to resize as well. How can I change the Fontsize without affecting the parent's size? | A nice trick to isolate an element from its parent layout wise is to place the element in a Canvas
In the markup below there are two copies of your element
The first is hidden and establishes the size of your control
The second is visible but wrapped in a Canvas so its layout size does not affect the parent.
```
<Par... |
321,714 | <p>I am dynamically creating a table which I want to have clickable rows. When the user clicks on one of the rows I want to redirect to a page specific to the item of that row. My question is how on the server side can I wire the "onclick" event to a routine that will then allow me to build a url based on some of the... | [
{
"answer_id": 321717,
"author": "John",
"author_id": 30006,
"author_profile": "https://Stackoverflow.com/users/30006",
"pm_score": 1,
"selected": false,
"text": "<p>I would build the link in the table as an actual anchor tag to your SomePage.aspx (while you're building your table, you s... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321714",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20748/"
] | I am dynamically creating a table which I want to have clickable rows. When the user clicks on one of the rows I want to redirect to a page specific to the item of that row. My question is how on the server side can I wire the "onclick" event to a routine that will then allow me to build a url based on some of the data... | It sounds like your actual goal is simply to display/edit the row on another page. If this is the case, you could simply add a javascript event handler to the table row when you create it.
```
<tr onclick="window.location='DetailPage.aspx?id=<%= IdFromDb %>'">
<!-- etc......-->
</tr>
```
If you use a GridView to... |
321,719 | <p>Say I'm extending a TextBox called CustomTextBox in .net. In certain situations I would like to force a tab to the next TabIndex on the form. Is there a way to do this beyond getting all the controls contained in CustomTextBox's parent, sorting them by their TabIndex, and then focusing the next ordinal one?</p>
| [
{
"answer_id": 321751,
"author": "Zachary Yates",
"author_id": 8360,
"author_profile": "https://Stackoverflow.com/users/8360",
"pm_score": 5,
"selected": true,
"text": "<p>I think you are looking for something like the following method:</p>\n\n<pre><code>form1.SelectNextControl(textBox1,... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321719",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24571/"
] | Say I'm extending a TextBox called CustomTextBox in .net. In certain situations I would like to force a tab to the next TabIndex on the form. Is there a way to do this beyond getting all the controls contained in CustomTextBox's parent, sorting them by their TabIndex, and then focusing the next ordinal one? | I think you are looking for something like the following method:
```
form1.SelectNextControl(textBox1, true, true, true, true);
```
(All the trues are just different options, read the intellisense!)
You did say it is WinForms and not WebForms right? |
321,736 | <p>I have an application that I want to export high-resolution (or rather, high pixel density?) images for printing - for example, I want images that print at 250 dots per inch (DPI), instead of the default, which I understand to be 72 DPI.</p>
<p>I'm using a BufferedImage with a Graphics2D object to draw the image, t... | [
{
"answer_id": 4833697,
"author": "Peter Kofler",
"author_id": 104143,
"author_profile": "https://Stackoverflow.com/users/104143",
"pm_score": 6,
"selected": true,
"text": "<p>Kurt's answer showed the way, still it took me quite some time to get it run, so here is the code that sets DPI ... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321736",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2197/"
] | I have an application that I want to export high-resolution (or rather, high pixel density?) images for printing - for example, I want images that print at 250 dots per inch (DPI), instead of the default, which I understand to be 72 DPI.
I'm using a BufferedImage with a Graphics2D object to draw the image, then ImageI... | Kurt's answer showed the way, still it took me quite some time to get it run, so here is the code that sets DPI when saving a PNG. There is a lot to do to get the proper writers and such...
```
private BufferedImage gridImage;
...
private void saveGridImage(File output) throws IOException {
output.delete();
... |
321,779 | <p>I've seen a number of examples that have a thread procedure that looks like this.</p>
<pre><code> private void ThreadProc()
{
while (serviceStarted)
{
// do some work
Thread.Sleep(new TimeSpan(0, 0, 5));
}
Thread.CurrentThread.Abort();
}
</code></... | [
{
"answer_id": 321823,
"author": "Zachary Yates",
"author_id": 8360,
"author_profile": "https://Stackoverflow.com/users/8360",
"pm_score": 4,
"selected": true,
"text": "<p>Calling <code>Thread.Abort()</code> does raise an exception, and if you're writing code that will be re-used (or par... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321779",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31339/"
] | I've seen a number of examples that have a thread procedure that looks like this.
```
private void ThreadProc()
{
while (serviceStarted)
{
// do some work
Thread.Sleep(new TimeSpan(0, 0, 5));
}
Thread.CurrentThread.Abort();
}
```
Is the `Abort()` ... | Calling `Thread.Abort()` does raise an exception, and if you're writing code that will be re-used (or part of a base library) it's difficult for other developers to handle `ThreadAbortExcpetion`s.
It's explained in this article about [Reliability Best Practices](http://msdn.microsoft.com/en-us/library/ms228970(VS.80)... |
321,787 | <p>I'm trying to encrypt some integers in java using java.security and javax.crypto. </p>
<p>The problem seems to be that the Cipher class only encrypts byte arrays. I can't directly convert an integer to a byte string (or can I?). What is the best way to do this?</p>
<p>Should I convert the integer to a string an... | [
{
"answer_id": 321803,
"author": "jodonnell",
"author_id": 4223,
"author_profile": "https://Stackoverflow.com/users/4223",
"pm_score": 4,
"selected": false,
"text": "<p>You can turn ints into a byte[] using a DataOutputStream, like this:</p>\n\n<pre><code>ByteArrayOutputStream baos = new... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321787",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38663/"
] | I'm trying to encrypt some integers in java using java.security and javax.crypto.
The problem seems to be that the Cipher class only encrypts byte arrays. I can't directly convert an integer to a byte string (or can I?). What is the best way to do this?
Should I convert the integer to a string and the string to byte... | You can turn ints into a byte[] using a DataOutputStream, like this:
```
ByteArrayOutputStream baos = new ByteArrayOutputStream ();
DataOutputStream dos = new DataOutputStream (baos);
dos.writeInt (i);
byte[] data = baos.toByteArray();
// do encryption
```
Then to decrypt it later:
```
byte[] decrypted = decrypt (d... |
321,795 | <p>I have an object that can build itself from an XML string, and write itself out to an XML string. I'd like to write a unit test to test round tripping through XML, but I'm having trouble comparing the two XML versions. Whitespace and attribute order seem to be the issues. Any suggestions for how to do this? This is ... | [
{
"answer_id": 321845,
"author": "andrewrk",
"author_id": 432,
"author_profile": "https://Stackoverflow.com/users/432",
"pm_score": 3,
"selected": false,
"text": "<p>Use <a href=\"http://www.logilab.org/859\" rel=\"noreferrer\">xmldiff</a>, a python tool that figures out the differences ... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321795",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8240/"
] | I have an object that can build itself from an XML string, and write itself out to an XML string. I'd like to write a unit test to test round tripping through XML, but I'm having trouble comparing the two XML versions. Whitespace and attribute order seem to be the issues. Any suggestions for how to do this? This is in ... | First normalize 2 XML, then you can compare them. I've used the following using lxml
```
obj1 = objectify.fromstring(expect)
expect = etree.tostring(obj1)
obj2 = objectify.fromstring(xml)
result = etree.tostring(obj2)
self.assertEquals(expect, result)
``` |
321,801 | <p>I was wondering in C++ if I have an enum can I access the value at the second index? For example I have</p>
<pre><code>enum Test{hi, bye};
</code></pre>
<p>if I want 'hi', can I do something like Test[0], thanks.</p>
| [
{
"answer_id": 321816,
"author": "strager",
"author_id": 39992,
"author_profile": "https://Stackoverflow.com/users/39992",
"pm_score": 2,
"selected": false,
"text": "<p>Enumerations map names to values. In your case, (int)hi would have a value of 0, and (int)bye a value of 1. You can u... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321801",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I was wondering in C++ if I have an enum can I access the value at the second index? For example I have
```
enum Test{hi, bye};
```
if I want 'hi', can I do something like Test[0], thanks. | Yes and no. If your Enum does not have explicit values then it is possible. Without an explicit values, enum values are given numeric values 0-N in order of declaration. For example ...
```
enum Test {
hi, // 0
bye // 1
}
```
This means that indexes just translates into a literal value.
```
Test EnumOfIndex(int... |
321,819 | <p>I'm missing something here, but I've stared at it too long to see it. I've got a simple ListView, with the typical Edit/Update/Cancel buttons. I've got the following set up in my EditITemTemplate when the row goes into edit mode:</p>
<pre><code><EditItemTemplate>
<asp:Label ID="AccountIdLabel" runat="s... | [
{
"answer_id": 321943,
"author": "Kevin Tighe",
"author_id": 39461,
"author_profile": "https://Stackoverflow.com/users/39461",
"pm_score": 0,
"selected": false,
"text": "<p>I think this is because the ItemUpdating event fires before the ListView updates the record. You probably want to ... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321819",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23935/"
] | I'm missing something here, but I've stared at it too long to see it. I've got a simple ListView, with the typical Edit/Update/Cancel buttons. I've got the following set up in my EditITemTemplate when the row goes into edit mode:
```
<EditItemTemplate>
<asp:Label ID="AccountIdLabel" runat="server" Text='<%#Eval("l... | Found it - I had code in the ItemCommand event that was handling other events, but it was doing the GetData() at the end regardless of the command, so basically the data was being refreshed right before the ItemUpdating event fired. I tightened up ItemCommand, and it's now working as expected. |
321,822 | <p>Consider the following Haskell code:</p>
<pre><code>module Expr where
-- Variables are named by strings, assumed to be identifiers:
type Variable = String
-- Representation of expressions:
data Expr = Const Integer
| Var Variable
| Plus Expr Expr
| Minus Expr Expr
... | [
{
"answer_id": 321850,
"author": "Johannes Schaub - litb",
"author_id": 34509,
"author_profile": "https://Stackoverflow.com/users/34509",
"pm_score": 0,
"selected": false,
"text": "<p>Here is everything you need to know for this: <a href=\"http://augustss.blogspot.com/2007/04/overloading... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321822",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41000/"
] | Consider the following Haskell code:
```
module Expr where
-- Variables are named by strings, assumed to be identifiers:
type Variable = String
-- Representation of expressions:
data Expr = Const Integer
| Var Variable
| Plus Expr Expr
| Minus Expr Expr
| Mul... | Rather than call your function toString, it might be preferable to use the [Show type class](http://www.haskell.org/tutorial/stdclasses.html). Then your data type can be used anywhere that an instance of Show can be used. Show is the standard Haskell way of converting "things" into strings.
```
instance Show Expr wher... |
321,827 | <p>I am trying to determine what issues could be caused by using the following serialization surrogate to enable serialization of anonymous functions/delegate/lambdas. </p>
<pre><code>// see http://msdn.microsoft.com/msdnmag/issues/02/09/net/#S3
class NonSerializableSurrogate : ISerializationSurrogate
{
public voi... | [
{
"answer_id": 322391,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 2,
"selected": false,
"text": "<p>The whole idea of serializing a delegate is very risky. Now, an <em>expression</em> might make sense, but even tha... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321827",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3046/"
] | I am trying to determine what issues could be caused by using the following serialization surrogate to enable serialization of anonymous functions/delegate/lambdas.
```
// see http://msdn.microsoft.com/msdnmag/issues/02/09/net/#S3
class NonSerializableSurrogate : ISerializationSurrogate
{
public void GetObjectDat... | Did you see this post that I wrote as a followup to the CountingDemo: <http://dotnet.agilekiwi.com/blog/2007/12/update-on-persistent-iterators.html> ? Unfortunately, Microsoft have confirmed that they probably will change the compiler details (one day), in a way that is likely to cause problems. (e.g. f/when you update... |
321,834 | <p>I have an RSS source:</p>
<pre><code>http://feedity.com/rss.aspx/mr1-kossuth-hu/VVdXUlY
</code></pre>
<pre><code><item>
<title>2008. november 23.</title>
<link>http://www.mr1-kossuth.hu/m3u/0039c36f_3003051.m3u</link>
<description>........</description>... | [
{
"answer_id": 321855,
"author": "Benson",
"author_id": 13816,
"author_profile": "https://Stackoverflow.com/users/13816",
"pm_score": 1,
"selected": false,
"text": "<p>That's the sort of thing that's best done with an <a href=\"http://us.php.net/xslt\" rel=\"nofollow noreferrer\">XSLT</a... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321834",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have an RSS source:
```
http://feedity.com/rss.aspx/mr1-kossuth-hu/VVdXUlY
```
```
<item>
<title>2008. november 23.</title>
<link>http://www.mr1-kossuth.hu/m3u/0039c36f_3003051.m3u</link>
<description>........</description>
<pubDate>Wed, 26 Nov 2008 00:00:00 GMT</pubDate>
</item>
```
... | **This is a simple and pure XSLT 1.0 solution**, consisting of just 47 lines, half of which are closing tags. **The following transformation**:
```
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes"/>
<xsl:param name="pNewLink"
select="'http://... |
321,849 | <p>Is there a good equivalent implementation of <code>strptime()</code> available for Windows? Unfortunately, this POSIX function does not appear to be available.</p>
<p><a href="http://www.opengroup.org/onlinepubs/009695399/functions/strptime.html" rel="noreferrer">Open Group description of strptime</a> - summary: i... | [
{
"answer_id": 321877,
"author": "Adam Rosenfield",
"author_id": 9530,
"author_profile": "https://Stackoverflow.com/users/9530",
"pm_score": 5,
"selected": true,
"text": "<p>An open-source version (BSD license) of <code>strptime()</code> can be found here: <a href=\"http://cvsweb.netbsd.... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321849",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17035/"
] | Is there a good equivalent implementation of `strptime()` available for Windows? Unfortunately, this POSIX function does not appear to be available.
[Open Group description of strptime](http://www.opengroup.org/onlinepubs/009695399/functions/strptime.html) - summary: it converts a text string such as `"MM-DD-YYYY HH:M... | An open-source version (BSD license) of `strptime()` can be found here: [<http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libc/time/strptime.c?rev=HEAD>](http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libc/time/strptime.c?rev=HEAD)
You'll need to add the following declaration to use it:
```
char *strptime(const char * __res... |
321,860 | <p>I have a lot of XML files which have something of the form:</p>
<pre><code><Element fruit="apple" animal="cat" />
</code></pre>
<p>Which I want to be removed from the file.</p>
<p>Using an XSLT stylesheet and the Linux command-line utility xsltproc, how could I do this?</p>
<p>By this point in the script I... | [
{
"answer_id": 322079,
"author": "Dimitre Novatchev",
"author_id": 36305,
"author_profile": "https://Stackoverflow.com/users/36305",
"pm_score": 8,
"selected": true,
"text": "<p>Using one of the most fundamental XSLT design patterns: \"Overriding the <a href=\"https://www.w3.org/TR/1999/... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321860",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4120/"
] | I have a lot of XML files which have something of the form:
```
<Element fruit="apple" animal="cat" />
```
Which I want to be removed from the file.
Using an XSLT stylesheet and the Linux command-line utility xsltproc, how could I do this?
By this point in the script I already have the list of files containing the... | Using one of the most fundamental XSLT design patterns: "Overriding the [**identity transformation**](https://www.w3.org/TR/1999/REC-xslt-19991116#copying)" one will just write the following:
```
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes"/... |
321,861 | <p>I have a ‘page a’ using ‘css a’. This page has margins set in css.
I also have a ‘page b’ using ‘css b’. This page also has margins set in css, of the same size as in ‘css a’ (10px).</p>
<p>Is there any way I can make it so that when I am viewing ‘page a’ on its own it has margins, but when viewed in an iframe on ‘... | [
{
"answer_id": 322079,
"author": "Dimitre Novatchev",
"author_id": 36305,
"author_profile": "https://Stackoverflow.com/users/36305",
"pm_score": 8,
"selected": true,
"text": "<p>Using one of the most fundamental XSLT design patterns: \"Overriding the <a href=\"https://www.w3.org/TR/1999/... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321861",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I have a ‘page a’ using ‘css a’. This page has margins set in css.
I also have a ‘page b’ using ‘css b’. This page also has margins set in css, of the same size as in ‘css a’ (10px).
Is there any way I can make it so that when I am viewing ‘page a’ on its own it has margins, but when viewed in an iframe on ‘page b’ th... | Using one of the most fundamental XSLT design patterns: "Overriding the [**identity transformation**](https://www.w3.org/TR/1999/REC-xslt-19991116#copying)" one will just write the following:
```
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes"/... |
321,864 | <p>Yesterday I had a two-hour technical phone interview (which I passed, woohoo!), but I completely muffed up the following question regarding dynamic binding in Java. And it's doubly puzzling because I used to teach this concept to undergraduates when I was a TA a few years ago, so the prospect that I gave them misin... | [
{
"answer_id": 321884,
"author": "P Arrayah",
"author_id": 33459,
"author_profile": "https://Stackoverflow.com/users/33459",
"pm_score": 2,
"selected": false,
"text": "<p>I think the key lies in the fact that the equals() method doesn't conform to standard: It takes in another Test objec... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321864",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13604/"
] | Yesterday I had a two-hour technical phone interview (which I passed, woohoo!), but I completely muffed up the following question regarding dynamic binding in Java. And it's doubly puzzling because I used to teach this concept to undergraduates when I was a TA a few years ago, so the prospect that I gave them misinform... | Java uses static binding for overloaded methods, and dynamic binding for overridden ones. In your example, the equals method is overloaded (has a different param type than Object.equals()), so the method called is bound to the **reference** type at compile time.
Some discussion [here](http://forums.techarena.in/softwa... |
321,867 | <p>I can't seem to get a custom action working. I might be doing this wrong. Here's what I'm trying to do:</p>
<p>I'd like to run a custom action in my application install (Visual Studio Installer project) that runs an executable. The executable simply does some system.io filecopy tasks, and I've confirmed that the... | [
{
"answer_id": 321892,
"author": "Darin Dimitrov",
"author_id": 29407,
"author_profile": "https://Stackoverflow.com/users/29407",
"pm_score": 4,
"selected": true,
"text": "<p>The exe or library you are adding to the Commit step should contain a class deriving from <a href=\"http://msdn.m... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321867",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33371/"
] | I can't seem to get a custom action working. I might be doing this wrong. Here's what I'm trying to do:
I'd like to run a custom action in my application install (Visual Studio Installer project) that runs an executable. The executable simply does some system.io filecopy tasks, and I've confirmed that the executable w... | The exe or library you are adding to the Commit step should contain a class deriving from [Installer](http://msdn.microsoft.com/en-us/library/system.configuration.install.installer.aspx) and marked with the [RunInstaller](http://msdn.microsoft.com/en-us/library/system.componentmodel.runinstallerattribute.aspx) attribut... |
321,881 | <p>I have the following in a program (written in VB.NET):</p>
<pre><code>Imports Microsoft.Office.Interop.Excel
Public Class Form1
Dim eApp As New Excel.Application
Dim w As Excel.Workbook
w = eApp.Workbooks.Open( "path.xls", ReadOnly:=True)
.. Processing Code ..
//Attempts at killing the excel ap... | [
{
"answer_id": 321915,
"author": "Oscar Cabrero",
"author_id": 14440,
"author_profile": "https://Stackoverflow.com/users/14440",
"pm_score": 2,
"selected": false,
"text": "<p>loop the below line of code until the result is zero or less</p>\n\n<pre><code>System.Runtime.InteropServices.Mar... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321881",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22777/"
] | I have the following in a program (written in VB.NET):
```
Imports Microsoft.Office.Interop.Excel
Public Class Form1
Dim eApp As New Excel.Application
Dim w As Excel.Workbook
w = eApp.Workbooks.Open( "path.xls", ReadOnly:=True)
.. Processing Code ..
//Attempts at killing the excel application
... | I had to do this a while back in NET 1.1, so please forgive the rust.
On the eApp, there was a Hwind (a win32 window handle - <http://msdn.microsoft.com/en-us/library/bb255823.aspx> ) or similar object. I had to use that and a pInvoke (<http://www.pinvoke.net/default.aspx/user32.GetWindowThreadProcessId> ) to get the... |
321,896 | <p>Does anybody know if it is possible <strong>to choose the order of the fields</strong> in Dynamic Data (of course, without customizing the templates of each table) ?</p>
<p>Thanks !</p>
| [
{
"answer_id": 361517,
"author": "a7drew",
"author_id": 4239,
"author_profile": "https://Stackoverflow.com/users/4239",
"pm_score": 1,
"selected": false,
"text": "<p>You can do this by modifying the order of the public properties in your LINQ to SQL file. </p>\n\n<p>For example, I went i... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321896",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37592/"
] | Does anybody know if it is possible **to choose the order of the fields** in Dynamic Data (of course, without customizing the templates of each table) ?
Thanks ! | In .NET 4.0, using the 4.0 release of the Dynamic Data dll, you can set data annotations like so:
```
[Display(Name = " Mission Statement", Order = 30)]
public object MissionStatement { get; set; }
[Display(Name = "Last Mod", Order = 40)]
public object DateModified { get; private set; }
``` |
321,898 | <p>How do you get the name and/or description of an <a href="http://msdn.microsoft.com/en-us/library/ms680657(VS.85).aspx" rel="noreferrer">SEH</a> exception <strong>without</strong> having to hard-code the strings into your application?</p>
<p>I tried to use <code>FormatMessage()</code>, but it truncates the message ... | [
{
"answer_id": 322036,
"author": "John",
"author_id": 13895,
"author_profile": "https://Stackoverflow.com/users/13895",
"pm_score": 1,
"selected": false,
"text": "<p>Does this apply?</p>\n\n<p><a href=\"http://www.winehq.org/pipermail/wine-devel/2001-May/000801.html\" rel=\"nofollow nore... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321898",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36372/"
] | How do you get the name and/or description of an [SEH](http://msdn.microsoft.com/en-us/library/ms680657(VS.85).aspx) exception **without** having to hard-code the strings into your application?
I tried to use `FormatMessage()`, but it truncates the message sometimes, even if you specify to ignore inserts:
```
__asm {... | Structured exception codes are defined through NTSTATUS numbers. Although someone from MS [suggests](https://support.microsoft.com/en-us/kb/259693) using [FormatMessage()](https://msdn.microsoft.com/en-us/library/ms679351(v=vs.85).aspx) to convert NTSTATUS numbers to strings, I would not do this. Flag `FORMAT_MESSAGE_F... |
321,914 | <p>I am new to LINQ. I am trying to find the rows that does not exists in the second data table. </p>
<p>report_list and benchmark both type are : DataTable. Both these datatables are being populated using OleDbCommand,OleDbDataAdapter. I am getting an error "Specified cast is not valid." in foreach ... loop. I woul... | [
{
"answer_id": 322002,
"author": "Rafael Romão",
"author_id": 39281,
"author_profile": "https://Stackoverflow.com/users/39281",
"pm_score": 1,
"selected": false,
"text": "<p>I don't know if I understood your question. Are you trying to get the items that exists in the first table but not... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321914",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I am new to LINQ. I am trying to find the rows that does not exists in the second data table.
report\_list and benchmark both type are : DataTable. Both these datatables are being populated using OleDbCommand,OleDbDataAdapter. I am getting an error "Specified cast is not valid." in foreach ... loop. I would appreciat... | I don't know if I understood your question. Are you trying to get the items that exists in the first table but not in the second?
```
var first = new string[] { "b", "c" };
var second = new string[] { "a", "c" };
//find the itens that exist in "first" but not in "second"
var q = from f in first
where !second.... |
321,921 | <p>I've been using extension methods quite a bit recently and have found a lot of uses for them. The only problem I have is remembering where they are and what namespace to use in order to get the extension methods.</p>
<p>However, I recently had a thought of writing the extension methods in the System namespace, Syst... | [
{
"answer_id": 321934,
"author": "Jeff Yates",
"author_id": 23234,
"author_profile": "https://Stackoverflow.com/users/23234",
"pm_score": 4,
"selected": false,
"text": "<p>You should avoid augmenting namespaces over which you do not have primary control as future changes can break your c... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321921",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5932/"
] | I've been using extension methods quite a bit recently and have found a lot of uses for them. The only problem I have is remembering where they are and what namespace to use in order to get the extension methods.
However, I recently had a thought of writing the extension methods in the System namespace, System.Collect... | From the Framework Design Guidelines (2nd Edition):
DO NOT put extension methods in the same namespace as the extended type, unless it is for adding methods to interfaces, or for dependency management.
While this doesn't explicitly cover your scenario, you should generally avoid extending a Framework namespace (or a... |
321,924 | <p>I currently working on an issue tracker for my company to help them keep track of problems that arise with the network. I am using C# and SQL. </p>
<p>Each issue has about twenty things we need to keep track of(status, work loss, who created it, who's working on it, etc). I need to attach a list of teams affected b... | [
{
"answer_id": 321952,
"author": "cagcowboy",
"author_id": 19629,
"author_profile": "https://Stackoverflow.com/users/19629",
"pm_score": 2,
"selected": false,
"text": "<p>If I understand the question correctly I would create....</p>\n\n<ul>\n<li>ISSUE table containing the 20 so so items<... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321924",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41138/"
] | I currently working on an issue tracker for my company to help them keep track of problems that arise with the network. I am using C# and SQL.
Each issue has about twenty things we need to keep track of(status, work loss, who created it, who's working on it, etc). I need to attach a list of teams affected by the issu... | What you are describing is called a "many-to-many" relationship. A team can be affected by many issues, and likewise an issue can affect many teams.
In SQL database design, this sort of relationship requires a third table, one that contains a reference to each of the other two tables. For example:
```
CREATE TABLE te... |
321,947 | <p>I am trying to replace all occurences of ???some.text.and.dots??? in a html page to add a link on it. I've built this regexp that does it :</p>
<p>\?\?\?([a-z0-9.]*)\?\?\?</p>
<p>However, I would like to exclude any result that is inside a link : "<a ...> ... MY PATTERN ... </a>", and I am a little stu... | [
{
"answer_id": 321967,
"author": "Rob",
"author_id": 34224,
"author_profile": "https://Stackoverflow.com/users/34224",
"pm_score": 0,
"selected": false,
"text": "<p>JavaScript doesn't inherently support look-behind. In order to do this, you'd need to run .match() and then for each of yo... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321947",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41142/"
] | I am trying to replace all occurences of ???some.text.and.dots??? in a html page to add a link on it. I've built this regexp that does it :
\?\?\?([a-z0-9.]\*)\?\?\?
However, I would like to exclude any result that is inside a link : "<a ...> ... MY PATTERN ... </a>", and I am a little stuck as to how to do that, all... | It's not really clear what kind of "HTML" you are working on. If it is HTML *code*, something from an Ajax request maybe, then you can use a regular expression; matching both a link *or* the pattern, and then work out what to do in a callback:
```
var html = document.body.innerHTML;
html = html.replace(/(<a\s.*?>.*?<\... |
321,971 | <p>I'm serializing to XML my class where one of properties has type List<string>.</p>
<pre><code>public class MyClass {
...
public List<string> Properties { get; set; }
...
}
</code></pre>
<p>XML created by serializing this class looks like this:</p>
<pre><code><MyClass>
...
<... | [
{
"answer_id": 321997,
"author": "user7116",
"author_id": 7116,
"author_profile": "https://Stackoverflow.com/users/7116",
"pm_score": 4,
"selected": true,
"text": "<p>Try <a href=\"http://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlarrayitemattribute.aspx\" rel=\"norefer... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321971",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23280/"
] | I'm serializing to XML my class where one of properties has type List<string>.
```
public class MyClass {
...
public List<string> Properties { get; set; }
...
}
```
XML created by serializing this class looks like this:
```
<MyClass>
...
<Properties>
<string>somethinghere</string>
... | Try [XmlArrayItemAttribute](http://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlarrayitemattribute.aspx):
```
using System;
using System.IO;
using System.Xml.Serialization;
using System.Collections.Generic;
public class Program
{
[XmlArrayItem("Property")]
public List<string> Properties = new ... |
321,974 | <p>I'm working on a college assignment where I must verify if a certain clause (as a fact or as a rule) exists in the current clause database.</p>
<p>The idea is to use a rule whose head is verify(+name, +arguments). This rule should be true if in the database exists another rule whose head is name(arguments)</p>
<p... | [
{
"answer_id": 322152,
"author": "Aleksandar Dimitrov",
"author_id": 11797,
"author_profile": "https://Stackoverflow.com/users/11797",
"pm_score": 1,
"selected": false,
"text": "<p>Are you familiar with the concept of unification? What you have to do is: just call a predicate that looks ... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321974",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13828/"
] | I'm working on a college assignment where I must verify if a certain clause (as a fact or as a rule) exists in the current clause database.
The idea is to use a rule whose head is verify(+name, +arguments). This rule should be true if in the database exists another rule whose head is name(arguments)
Any help would be... | Using `call/1` is not a good idea because `call/1` actually calls the goal, but you just want to find out if the fact/rule *exists*, and you don't want to wait after a long calculation that the call might trigger, and you don't want to have something printed on the screen if the called rule in turn calls e.g. `writeln/... |
321,979 | <p>Exactly as the question states: How can you check if a variable in PHP contains a file pointer? Some like <code>is_string()</code> or <code>is_object()</code>.</p>
| [
{
"answer_id": 321988,
"author": "Greg",
"author_id": 24181,
"author_profile": "https://Stackoverflow.com/users/24181",
"pm_score": 2,
"selected": false,
"text": "<p>You can use <a href=\"http://www.php.net/manual/en/function.stream-get-meta-data.php\" rel=\"nofollow noreferrer\"><code>s... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321979",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5441/"
] | Exactly as the question states: How can you check if a variable in PHP contains a file pointer? Some like `is_string()` or `is_object()`. | You can use `get_resource_type()` - <http://us3.php.net/manual/en/function.get-resource-type.php>. The function will return FALSE if its not a resource at all.
```
$fp = fopen("foo", "w");
...
if(get_resource_type($fp) == 'file' || get_resource_type($fp) == 'stream') {
//do what you want here
}
```
The PHP docum... |
321,985 | <p>How do I use GDB to debug a program which do not have debugging symbols on a 32-bit x86 processor? Inspecting the function arguments, local variables, resolving pointers would be useful to know how to do.
The intention is not really to use this for reverse engineering, as I'm sometimes just too lazy to install the d... | [
{
"answer_id": 322015,
"author": "Draemon",
"author_id": 26334,
"author_profile": "https://Stackoverflow.com/users/26334",
"pm_score": 3,
"selected": false,
"text": "<p>Without debugging symbols, you can only debug at the ASM level. Ok you get a <em>bit</em> more information, but you're ... | 2008/11/26 | [
"https://Stackoverflow.com/questions/321985",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14337/"
] | How do I use GDB to debug a program which do not have debugging symbols on a 32-bit x86 processor? Inspecting the function arguments, local variables, resolving pointers would be useful to know how to do.
The intention is not really to use this for reverse engineering, as I'm sometimes just too lazy to install the debu... | To start out, you can do;
```
gdb "whatever"
break __libc_start_main
r
```
that will setup a breakpoint in libc's crt0 code and allow you to break before main, even if the target binary is totally stripped.
That will get you to a running state at a breakpoint before most user code. You can then single step, dissase... |
322,005 | <p>Is it possible?</p>
<p>I have a listview with several gridviewcolumns. The last column has a dynamic header. I dont know what the column header will be at design time. It's actually a number I want to display as a string. </p>
<pre><code> <GridViewColumn Header="{Binding Path=SomeValue}"
... | [
{
"answer_id": 322231,
"author": "Micah",
"author_id": 17744,
"author_profile": "https://Stackoverflow.com/users/17744",
"pm_score": 3,
"selected": true,
"text": "<p>I think your problem is the source of the \"SomeValue\" property. If you are binding to a list of objects, it wouldn't mak... | 2008/11/26 | [
"https://Stackoverflow.com/questions/322005",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6204/"
] | Is it possible?
I have a listview with several gridviewcolumns. The last column has a dynamic header. I dont know what the column header will be at design time. It's actually a number I want to display as a string.
```
<GridViewColumn Header="{Binding Path=SomeValue}"
DisplayMemberBinding="{... | I think your problem is the source of the "SomeValue" property. If you are binding to a list of objects, it wouldn't make sense to have the header determined by a property on that object, because then you could have a different header for every object. Essentially what you are saying is "Bind the header of the column t... |
322,034 | <p>Looking to <strong>improve</strong> my IF statement, and I want to keep my code <b>looking pretty</b></p>
<p>This is what I am currently doing, is it <b>readable</b>, any room for <b>improvement</b>?</p>
<pre><code>SomeObject o = LoadSomeObject();
if( null == o
||
null == o.ID || null == o.Title
||
... | [
{
"answer_id": 322038,
"author": "TravisO",
"author_id": 35116,
"author_profile": "https://Stackoverflow.com/users/35116",
"pm_score": 4,
"selected": true,
"text": "<p>Your verbosity is leading to a less readable code, I think the following format is best:</p>\n\n<pre><code>if ( null == ... | 2008/11/26 | [
"https://Stackoverflow.com/questions/322034",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39677/"
] | Looking to **improve** my IF statement, and I want to keep my code **looking pretty**
This is what I am currently doing, is it **readable**, any room for **improvement**?
```
SomeObject o = LoadSomeObject();
if( null == o
||
null == o.ID || null == o.Title
||
0 == o.ID.Length || 0 == o.Title.Length
... | Your verbosity is leading to a less readable code, I think the following format is best:
```
if ( null == o || null == o.ID || null.Title || 0 == o.ID.Length || 0 == o.Title.Length )
{
// do stuff
}
```
We all have high resolution/widescreen displays for a reason, there's no reason to lock your code at some horrib... |
322,050 | <p>I am trying to make IBM jre to use PCF fonts from default X11 installation on my linux box. In particular adobe-helvetica font. I have toyed to modify fontconfig.properties in jre/lib folder but no matter what I do Java seams to use some other fonts. I guess there is some algorithm how java VM tries to link java log... | [
{
"answer_id": 322038,
"author": "TravisO",
"author_id": 35116,
"author_profile": "https://Stackoverflow.com/users/35116",
"pm_score": 4,
"selected": true,
"text": "<p>Your verbosity is leading to a less readable code, I think the following format is best:</p>\n\n<pre><code>if ( null == ... | 2008/11/26 | [
"https://Stackoverflow.com/questions/322050",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20390/"
] | I am trying to make IBM jre to use PCF fonts from default X11 installation on my linux box. In particular adobe-helvetica font. I have toyed to modify fontconfig.properties in jre/lib folder but no matter what I do Java seams to use some other fonts. I guess there is some algorithm how java VM tries to link java logica... | Your verbosity is leading to a less readable code, I think the following format is best:
```
if ( null == o || null == o.ID || null.Title || 0 == o.ID.Length || 0 == o.Title.Length )
{
// do stuff
}
```
We all have high resolution/widescreen displays for a reason, there's no reason to lock your code at some horrib... |
322,071 | <p>Having a strange issue with some C# code - the Getter method for a property is showing up as virtual when not explicitly marked.</p>
<p>The problem exhibits with the DbKey property on this class (code in full):</p>
<pre><code>public class ProcessingContextKey : BusinessEntityKey, IProcessingContextKey
{
public... | [
{
"answer_id": 322078,
"author": "JaredPar",
"author_id": 23283,
"author_profile": "https://Stackoverflow.com/users/23283",
"pm_score": 5,
"selected": true,
"text": "<p>It's virtual because it implements an interface method. Interface implementation methods are always virtual as far as ... | 2008/11/26 | [
"https://Stackoverflow.com/questions/322071",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30280/"
] | Having a strange issue with some C# code - the Getter method for a property is showing up as virtual when not explicitly marked.
The problem exhibits with the DbKey property on this class (code in full):
```
public class ProcessingContextKey : BusinessEntityKey, IProcessingContextKey
{
public ProcessingContextKey... | It's virtual because it implements an interface method. Interface implementation methods are always virtual as far as the CLR is concerned. |
322,086 | <p>I was wondering if it is possible to declare an array (size not known at this time), as a private member of a class and later set the size in the constructor of the class. For example:</p>
<pre><code>class Test {
int a[];
public:
Test(int size);
};
Test::Test(int size) {
a[size]; // this is wrong, but what can ... | [
{
"answer_id": 322093,
"author": "Uri",
"author_id": 23072,
"author_profile": "https://Stackoverflow.com/users/23072",
"pm_score": 2,
"selected": false,
"text": "<p>First of all, it is generally better to initialize things in the initialization list of the constructor, not in the body of... | 2008/11/26 | [
"https://Stackoverflow.com/questions/322086",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I was wondering if it is possible to declare an array (size not known at this time), as a private member of a class and later set the size in the constructor of the class. For example:
```
class Test {
int a[];
public:
Test(int size);
};
Test::Test(int size) {
a[size]; // this is wrong, but what can i do here?
}
`... | No this is not possible. Array declarations in headers must have constant sized value. Otherwise it's impossible for constructs like "sizeof" to function properly. You'll need to declare the array as a pointer type and use new[] in the constructor. Example.
```
class Test {
int *a;
public:
Test(int size) {
... |
322,089 | <p>I've written an experimental function evaluator that allows me to bind simple functions together such that when the variables change, all functions that rely on those variables (and the functions that rely on those functions, etc.) are updated simultaneously. The way I do this is instead of evaluating the function i... | [
{
"answer_id": 322101,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 4,
"selected": true,
"text": "<p>I've had a similar problem to this in the past.\nMy solution was to push variable names onto a stack as I recursed through t... | 2008/11/26 | [
"https://Stackoverflow.com/questions/322089",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16942/"
] | I've written an experimental function evaluator that allows me to bind simple functions together such that when the variables change, all functions that rely on those variables (and the functions that rely on those functions, etc.) are updated simultaneously. The way I do this is instead of evaluating the function imme... | I've had a similar problem to this in the past.
My solution was to push variable names onto a stack as I recursed through the expressions to check syntax, and pop them as I exited a recursion level.
Before I pushed each variable name onto the stack, I would check if it was already there.
If it was, then this was a cir... |
322,098 | <p>Ok, this is working on windows. My Java app is running and functioning normally</p>
<pre><code>javac -classpath .;ojdbc14.jar -g foo.java
java -classpath .;ojdbc14.jar foo
</code></pre>
<p>However, when I do the same thing on Unix I get this error:
ojdbc14.jar: not found</p>
<p>What am I doing wrong? I know... | [
{
"answer_id": 322100,
"author": "James Schek",
"author_id": 17871,
"author_profile": "https://Stackoverflow.com/users/17871",
"pm_score": 5,
"selected": true,
"text": "<p>Use a colon (\":\") instead of a semicolon (\";\").</p>\n\n<p>See <a href=\"http://java.sun.com/javase/6/docs/techno... | 2008/11/26 | [
"https://Stackoverflow.com/questions/322098",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/685/"
] | Ok, this is working on windows. My Java app is running and functioning normally
```
javac -classpath .;ojdbc14.jar -g foo.java
java -classpath .;ojdbc14.jar foo
```
However, when I do the same thing on Unix I get this error:
ojdbc14.jar: not found
What am I doing wrong? I know the ";" is telling my shell that oj... | Use a colon (":") instead of a semicolon (";").
See [Setting the class path (Solaris and Linux)](http://java.sun.com/javase/6/docs/technotes/tools/solaris/classpath.html) vs [Setting the class path (Windows)](http://java.sun.com/javase/6/docs/technotes/tools/windows/classpath.html) |
322,107 | <p>I'm working on a java program, and I have several vectors defined and filled (from a file) inside a method. I need to return the contents of all the vectors from the method. I have heard you can put them all in one object to return them. Is that possible, and if so, how? If not, do you have any possible solution... | [
{
"answer_id": 322150,
"author": "Robin",
"author_id": 21925,
"author_profile": "https://Stackoverflow.com/users/21925",
"pm_score": 2,
"selected": false,
"text": "<p>First of all, use ArrayList instead of Vector. Then use a Map as your return object, with each value of the entry is one... | 2008/11/26 | [
"https://Stackoverflow.com/questions/322107",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26949/"
] | I'm working on a java program, and I have several vectors defined and filled (from a file) inside a method. I need to return the contents of all the vectors from the method. I have heard you can put them all in one object to return them. Is that possible, and if so, how? If not, do you have any possible solutions for m... | Personnally, I'd scrap that approach completely. It seems like you need a Product class:
```
public class Product {
private String itemName;
private int itemID;
// etc etc
public Product(String itemName, int itemID) {
this.itemName = itemName;
this.itemID = itemID;
// etc etc
... |
322,110 | <p>I'd like to write a script that (under certain conditions) will execute gdb and automatically run some program X with some set of arguments Y. Once the program has finished executing the user should remain at gdb's prompt until s/he explicitly exits it.</p>
<p>One way to do this would be to have the script output t... | [
{
"answer_id": 322120,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p><code>cat F | gdb X</code> should be identical. So you can use anything that produces output and pipe that into gdb instead... | 2008/11/26 | [
"https://Stackoverflow.com/questions/322110",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41162/"
] | I'd like to write a script that (under certain conditions) will execute gdb and automatically run some program X with some set of arguments Y. Once the program has finished executing the user should remain at gdb's prompt until s/he explicitly exits it.
One way to do this would be to have the script output the run com... | If you want to run some commands through GDB and then have it exit or run to completion, just do
```
echo commands | gdb X
```
If you want to leave it at the command prompt after running those commands, you can do
```
(echo commands; cat) | gdb X
```
This results in echoing the commands to GDB, and then you type ... |
322,128 | <p>I think I've declared a Vector with an object correctly. But, I don't know how to access it's members when looping with Iterator.</p>
<p>In my code, the line --->> cout << " " << *Iter;</p>
<p>How do I print the contents of the members? Like *Iter.m_PackLine ???</p>
<p>Not sure if I used the correc... | [
{
"answer_id": 322139,
"author": "Dave",
"author_id": 40495,
"author_profile": "https://Stackoverflow.com/users/40495",
"pm_score": 1,
"selected": false,
"text": "<p>This is the first problem I noticed:</p>\n\n<p><code>std::vector</code> is a template.</p>\n\n<p>You have:</p>\n\n<pre><co... | 2008/11/26 | [
"https://Stackoverflow.com/questions/322128",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39360/"
] | I think I've declared a Vector with an object correctly. But, I don't know how to access it's members when looping with Iterator.
In my code, the line --->> cout << " " << \*Iter;
How do I print the contents of the members? Like \*Iter.m\_PackLine ???
Not sure if I used the correct terminology, but appreciate the he... | ```
cout << " " << *Iter;
```
will only work if `CFileInfo` has an overloaded `operator<<` that can output your struct. You can output individual members of the struct instead like this:
```
cout << " " << Iter->m_PackLine;
```
Alternatively, the following is equivalent to that:
```
cout << " " << (*Iter).m_PackL... |
322,131 | <p>I'm new to ReSharper and am surprised that there isn't a template defined for</p>
<pre><code>public void MethodName(<params>)
{
}
</code></pre>
<p>I realize I could create one, but I would have thought this would have been part of the standard product. Perhaps I'm missing some other shortcut?</p>
| [
{
"answer_id": 322186,
"author": "Matt Campbell",
"author_id": 41110,
"author_profile": "https://Stackoverflow.com/users/41110",
"pm_score": 4,
"selected": true,
"text": "<p>I'm not aware of any such default template, but as you pointed out it's terribly easy to write:</p>\n\n<pre><code>... | 2008/11/26 | [
"https://Stackoverflow.com/questions/322131",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7961/"
] | I'm new to ReSharper and am surprised that there isn't a template defined for
```
public void MethodName(<params>)
{
}
```
I realize I could create one, but I would have thought this would have been part of the standard product. Perhaps I'm missing some other shortcut? | I'm not aware of any such default template, but as you pointed out it's terribly easy to write:
```
public void $METHODNAME$($PARAMS$)
{
$END$
}
```
However, I'm more that a tiny bit perplexed that you're interested in making all your methods both public and void **by default.** |
322,147 | <p>Here's another problem with qt:
I extend a QAbstractTableModel, but I get a compiling error ( I'm using cmake)</p>
<pre><code>// file.h
#ifndef TABLEMODEL_H
#define TABLEMODEL_H
#include <QAbstractTableModel>
class TableModel : public QAbstractTableModel
{
Q_OBJECT
public:
TableModel(QObject *parent = 0);
... | [
{
"answer_id": 322197,
"author": "strager",
"author_id": 39992,
"author_profile": "https://Stackoverflow.com/users/39992",
"pm_score": 2,
"selected": false,
"text": "<p>Make sure you're running your header through MOC, and are linking those MOC object files.</p>\n"
},
{
"answer_i... | 2008/11/26 | [
"https://Stackoverflow.com/questions/322147",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39339/"
] | Here's another problem with qt:
I extend a QAbstractTableModel, but I get a compiling error ( I'm using cmake)
```
// file.h
#ifndef TABLEMODEL_H
#define TABLEMODEL_H
#include <QAbstractTableModel>
class TableModel : public QAbstractTableModel
{
Q_OBJECT
public:
TableModel(QObject *parent = 0);
int rowCount(const Q... | Solved adding to CMakeLists.txt the needed cpp file.
```
set(tutorial_SRCS app.cpp mainWin.cpp tableModel.cpp)
```
When I'll run cmake, the moc\* will be automatically created |
322,155 | <p>The top of my <code>web.xml</code> file looks like this:</p>
<pre><code><?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/w... | [
{
"answer_id": 322185,
"author": "toolkit",
"author_id": 3295,
"author_profile": "https://Stackoverflow.com/users/3295",
"pm_score": 6,
"selected": true,
"text": "<p>Perhaps try:</p>\n\n<pre><code>http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd\n</code></pre>\n\n<p>Instead of:</p>\n\n<... | 2008/11/26 | [
"https://Stackoverflow.com/questions/322155",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/409/"
] | The top of my `web.xml` file looks like this:
```
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd"
version="2.5">... | Perhaps try:
```
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd
```
Instead of:
```
http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd
```
---
Also, the `<!DOCTYPE ...>` is missing:
```
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xml>
<web-app
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://... |
322,173 | <p>I have some Perl code that runs fine outside the debugger:</p>
<pre><code>% perl somefile.pl
</code></pre>
<p>but when I run it inside the debugger:</p>
<pre><code>% perl -d somefile.pl
</code></pre>
<p>it behaves differently.</p>
<p>The files in question (there are several) are part of the test suite for a lar... | [
{
"answer_id": 322214,
"author": "Adam Bellaire",
"author_id": 21632,
"author_profile": "https://Stackoverflow.com/users/21632",
"pm_score": 2,
"selected": false,
"text": "<p>Is it possible you have an RC file or environment variable (<code>PERLDB_OPTS</code>) that is modifying the <code... | 2008/11/26 | [
"https://Stackoverflow.com/questions/322173",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/164/"
] | I have some Perl code that runs fine outside the debugger:
```
% perl somefile.pl
```
but when I run it inside the debugger:
```
% perl -d somefile.pl
```
it behaves differently.
The files in question (there are several) are part of the test suite for a large Perl module (~20K lines of code). The tests do a lot ... | This is a problem with perl5db.pl creating `__DIE__` handlers. If I localize `$SIG{__DIE__}` in your `eval`, things work as you expect.
```
eval {
local $SIG{__DIE__};
die MyEx->new
};
```
If you don't do that, you're getting the handler from DB::dbdie, which uses Carp::longmess. That shouldn't happe... |
322,190 | <p>With ASP.NET 3.5 I can easily bind to an XML file by using an <code>XmlDataSource</code>.</p>
<p>How can I bind to an XML <em>string</em> instead of a <em>file</em>?</p>
| [
{
"answer_id": 322221,
"author": "Dan Blanchard",
"author_id": 5460,
"author_profile": "https://Stackoverflow.com/users/5460",
"pm_score": 1,
"selected": false,
"text": "<p>From the XmlDataSource docs <a href=\"http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.xmldatasour... | 2008/11/26 | [
"https://Stackoverflow.com/questions/322190",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35061/"
] | With ASP.NET 3.5 I can easily bind to an XML file by using an `XmlDataSource`.
How can I bind to an XML *string* instead of a *file*? | Use the [XmlDataSource.Data](http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.xmldatasource.data.aspx) property.
```
XmlDataSource dataSource = new XmlDataSource();
dataSource.Data = "<root><element>Item #1</element><element>Item #2</element></root>";
dataSource.XPath = "root... |
322,208 | <p>I'm reviewing some Spring code, and I see a few bean defs that do not have an id or a name.
The person who did it is not around to ask.
The application is working fine.
I am not familiar what this necessarily means.
Anybody know if this means anything in particular?</p>
| [
{
"answer_id": 322246,
"author": "Jacob Mattison",
"author_id": 1237,
"author_profile": "https://Stackoverflow.com/users/1237",
"pm_score": 3,
"selected": false,
"text": "<p>One possibility is that you can define a bean in place, and so you don't need an id since you don't need to refer ... | 2008/11/26 | [
"https://Stackoverflow.com/questions/322208",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13143/"
] | I'm reviewing some Spring code, and I see a few bean defs that do not have an id or a name.
The person who did it is not around to ask.
The application is working fine.
I am not familiar what this necessarily means.
Anybody know if this means anything in particular? | Some beans are not required to be accessed by other beans in the context file or programmatically. So as mentioned by JacobM, they don't require an id or name as they're not referenced.
Such an example would be a [PropertyPlaceholderConfigurer](http://static.springframework.org/spring/docs/2.5.x/api/org/springframewor... |
322,212 | <p>I'm starting my adventure with Ruby on Rails and as IDE I choose Netbeans. It has bundled server Webrick and it had worked good. But after some changes in my first application it gives me internal error 500 - but nothing shows in console. And older actions give the same result.</p>
<p>How can I find where the probl... | [
{
"answer_id": 322255,
"author": "pbrodka",
"author_id": 33093,
"author_profile": "https://Stackoverflow.com/users/33093",
"pm_score": 0,
"selected": false,
"text": "<p>Answered myself - logs/development.log</p>\n"
},
{
"answer_id": 330804,
"author": "mwilliams",
"author_... | 2008/11/26 | [
"https://Stackoverflow.com/questions/322212",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33093/"
] | I'm starting my adventure with Ruby on Rails and as IDE I choose Netbeans. It has bundled server Webrick and it had worked good. But after some changes in my first application it gives me internal error 500 - but nothing shows in console. And older actions give the same result.
How can I find where the problem is?
I w... | What you can also do is add the following line to your controller "application.rb":
```
ActiveRecord::Base.logger = Logger.new(STDOUT)
```
Then you will get debugging output in WEBrick's "Output" window within Netbeans. |
322,225 | <p>I have a requirement to send some 100 bytes data over internet .My machine is connected to internet.
I can do this with HTTP by sending requests and receiving responses.
But my requirement is just to send data not receive response.
I am thinking of doing this using UDP Client server program. But to do that I need to... | [
{
"answer_id": 322235,
"author": "Toon Krijthe",
"author_id": 18061,
"author_profile": "https://Stackoverflow.com/users/18061",
"pm_score": 2,
"selected": false,
"text": "<p>The big advantage of HTTP is that port 80 is very often open. With other protocols you have to rely on the operato... | 2008/11/26 | [
"https://Stackoverflow.com/questions/322225",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33411/"
] | I have a requirement to send some 100 bytes data over internet .My machine is connected to internet.
I can do this with HTTP by sending requests and receiving responses.
But my requirement is just to send data not receive response.
I am thinking of doing this using UDP Client server program. But to do that I need to ho... | Cheap answer to send 100 bytes of data on the internet.
```
C:\Windows\system32>ping -n 1 -l 100 -4 google.com
Pinging google.com [209.85.171.99] with 100 bytes of data:
Reply from 209.85.171.99: bytes=56 (sent 100) time=174ms TTL=233
Ping statistics for 209.85.171.99:
Packets: Sent = 1, Received = 1, Lost = 0 (... |
322,243 | <p>I've created a UserObject and RoleObject to represent users in my application. I'm trying to use hibernate for CRUD instead of raw JDBC. I've successfully retrieved the information from the data base, but I can not create new users. I get the following error.</p>
<pre><code>org.springframework.web.util.NestedSe... | [
{
"answer_id": 322663,
"author": "Marc Novakowski",
"author_id": 27020,
"author_profile": "https://Stackoverflow.com/users/27020",
"pm_score": 0,
"selected": false,
"text": "<p>The contraint violation on UserRole might be a cause of trying to insert a row with a duplicate key. Maybe exp... | 2008/11/26 | [
"https://Stackoverflow.com/questions/322243",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17337/"
] | I've created a UserObject and RoleObject to represent users in my application. I'm trying to use hibernate for CRUD instead of raw JDBC. I've successfully retrieved the information from the data base, but I can not create new users. I get the following error.
```
org.springframework.web.util.NestedServletException: Re... | You are defining two different relationships inside of your "set" element. What you probably want is just the many-to-many element.
If this still doesn't work, try saving the UserRole itself to see if you can persist it on its own. If you can, then the ConstraintViolationException is being thrown while trying to persi... |
322,260 | <p><a href="http://tomcat.apache.org/tomcat-5.5-doc/deployer-howto.html" rel="noreferrer">Tomcat documentation</a> says: </p>
<p>The locations for Context Descriptors are;</p>
<p>$CATALINA_HOME/conf/[enginename]/[hostname]/context.xml<br>
$CATALINA_HOME/webapps/[webappname]/META-INF/context.xml</p>
<p>On my server, ... | [
{
"answer_id": 322321,
"author": "James Schek",
"author_id": 17871,
"author_profile": "https://Stackoverflow.com/users/17871",
"pm_score": 0,
"selected": false,
"text": "<p>I haven't found any official documentation, but I have observed the load order to be:</p>\n\n<pre><code>1 tomcat_ho... | 2008/11/26 | [
"https://Stackoverflow.com/questions/322260",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28351/"
] | [Tomcat documentation](http://tomcat.apache.org/tomcat-5.5-doc/deployer-howto.html) says:
The locations for Context Descriptors are;
$CATALINA\_HOME/conf/[enginename]/[hostname]/context.xml
$CATALINA\_HOME/webapps/[webappname]/META-INF/context.xml
On my server, I have at least 3 files floating around:
```
1 ...... | For the files you listed, the simple answer assuming you are using all the defaults, the order is (note the **conf**/Catalina/localhost):
```
...tomcat/conf/context.xml
...tomcat/conf/Catalina/localhost/myapp.xml
...tomcat/webapps/myapp/META-INF/context.xml
```
I'm basing this (and the following discussion) on the [... |
322,293 | <p>I have a structured XML file format that needs to be mapped to a flatter XML format. Ordinarily I would create a custom XSLT file for this and have the BizTalk map use it. However, I do like the idea of using the graphical maps where possible - it's all too easy to dive straight into XSLT but not so easy for those f... | [
{
"answer_id": 322292,
"author": "Andrew Rollings",
"author_id": 40410,
"author_profile": "https://Stackoverflow.com/users/40410",
"pm_score": 0,
"selected": false,
"text": "<p>Not strictly an answer to your question, but have you tried it using a sql server based session store? (Search ... | 2008/11/26 | [
"https://Stackoverflow.com/questions/322293",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41169/"
] | I have a structured XML file format that needs to be mapped to a flatter XML format. Ordinarily I would create a custom XSLT file for this and have the BizTalk map use it. However, I do like the idea of using the graphical maps where possible - it's all too easy to dive straight into XSLT but not so easy for those foll... | I finally found the answer to my problem. It's origin are within the application code (like 99% of a programmer's 3rd party tools 'bugs'). I decided to post it anyway in case someone is in a similar scenario.
This code was part of WebServiceRequester class. The web service requester class was instanciated when session... |
322,294 | <p>What is the command-line equivalent of "Switch Port Client User" as found in the p4win gui client? </p>
<p>I am already logged under one port but now I am attempting to connect to a different port on the same server in order to access a separate source control file depot. I assume it would involve using:</p>
<pre>... | [
{
"answer_id": 322332,
"author": "Commodore Jaeger",
"author_id": 4659,
"author_profile": "https://Stackoverflow.com/users/4659",
"pm_score": 4,
"selected": true,
"text": "<p>The P4PORT configuration variable stores the Perforce server name and port number to connect to. You can set this... | 2008/11/26 | [
"https://Stackoverflow.com/questions/322294",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4872/"
] | What is the command-line equivalent of "Switch Port Client User" as found in the p4win gui client?
I am already logged under one port but now I am attempting to connect to a different port on the same server in order to access a separate source control file depot. I assume it would involve using:
```
p4 login
```
... | The P4PORT configuration variable stores the Perforce server name and port number to connect to. You can set this value as an environment variable or, if you're using Windows, in the registry using 'p4 set':
```
p4 set P4PORT=perforce:1669
```
To see what the current value of P4PORT is:
```
> p4 set P4PORT
P4PORT=p... |
322,298 | <p>I'm trying to send an email in html format using JavaMail but it always seems to only display as a text email in Outlook. </p>
<p>Here is my code:</p>
<pre><code>try
{
Properties props = System.getProperties();
props.put("mail.smtp.host", mailserver);
props.put("mail.smtp.from", fromEmail);
props.... | [
{
"answer_id": 322323,
"author": "Ken Gentle",
"author_id": 8709,
"author_profile": "https://Stackoverflow.com/users/8709",
"pm_score": 2,
"selected": false,
"text": "<pre><code>html.setContent(htmlBody, \"text/html\");\nhtml.setHeader(\"MIME-Version\" , \"1.0\" );\nhtml.setHeader(\"Cont... | 2008/11/26 | [
"https://Stackoverflow.com/questions/322298",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39371/"
] | I'm trying to send an email in html format using JavaMail but it always seems to only display as a text email in Outlook.
Here is my code:
```
try
{
Properties props = System.getProperties();
props.put("mail.smtp.host", mailserver);
props.put("mail.smtp.from", fromEmail);
props.put("mail.smtp.auth",... | After a lot of investigation, I've been able to make some significant progress.
Firstly, instead of using JavaMail directly, I recommend using the [Jakarta Commons Email](http://commons.apache.org/email/) library. This really simplifies the issue a lot!
The code is now:
```
HtmlEmail email = new HtmlEmail();
email.... |
322,322 | <p>I have an iterator to a map element, and I would like gdb to show me the values of the "first" and "second" elements of that iterator.
For example:</p>
<pre><code>std::map<int,double> aMap;
...fill map...
std::map<int,double>::const_iterator p = aMap.begin();
</code></pre>
<p>I can use p.first and p.se... | [
{
"answer_id": 322355,
"author": "Johannes Schaub - litb",
"author_id": 34509,
"author_profile": "https://Stackoverflow.com/users/34509",
"pm_score": 4,
"selected": false,
"text": "<p>Here is how i do it:</p>\n\n<pre><code>This GDB was configured as \"i686-pc-linux-gnu\"...\n(gdb) list\n... | 2008/11/26 | [
"https://Stackoverflow.com/questions/322322",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39870/"
] | I have an iterator to a map element, and I would like gdb to show me the values of the "first" and "second" elements of that iterator.
For example:
```
std::map<int,double> aMap;
...fill map...
std::map<int,double>::const_iterator p = aMap.begin();
```
I can use p.first and p.second in the code, but can't see them i... | Here is how i do it:
```
This GDB was configured as "i686-pc-linux-gnu"...
(gdb) list
1 #include <iostream>
2 #include <map>
3
4 int main()
5 {
6 std::map<int, int> a;
7 a[10] = 9;
8 std::map<int, int>::iterator it = a.begin();
9 ++it;
10 }
(gdb) b t... |