question_id
int64
4
6.31M
answer_id
int64
7
6.31M
title
stringlengths
9
150
question_body
stringlengths
0
28.8k
answer_body
stringlengths
60
27.2k
question_text
stringlengths
40
28.9k
combined_text
stringlengths
124
39.6k
tags
listlengths
1
6
question_score
int64
0
26.3k
answer_score
int64
0
28.8k
view_count
int64
15
14M
answer_count
int64
0
182
favorite_count
int64
0
32
question_creation_date
stringdate
2008-07-31 21:42:52
2011-06-10 18:12:18
answer_creation_date
stringdate
2008-07-31 22:17:57
2011-06-10 18:14:17
54,626
54,637
How do I get an XML file as XML (and not a string) with Ajax in Prototype.js?
This code is from Prototype.js. I've looked at probably 20 different tutorials, and I can't figure out why this is not working. The response I get is null. new Ajax.Request(/path/to / xml / file.xml, { method: "get", contentType: "application/xml", onSuccess: function(transport) { alert(transport.responseXML); } }); If I change the responseXML to responseText, then it alerts to me the XML file as a string. This is not a PHP page serving up XML, but an actual XML file, so I know it is not the response headers.
If transport.responseXML is null but you have a value for transport.responseText then I believe it's because it's not a valid XML file. Edit: I just noticed that in our code here whenever we request an XML file we set the content type to 'text/xml'. I have no idea if that makes a difference or not.
How do I get an XML file as XML (and not a string) with Ajax in Prototype.js? This code is from Prototype.js. I've looked at probably 20 different tutorials, and I can't figure out why this is not working. The response I get is null. new Ajax.Request(/path/to / xml / file.xml, { method: "get", contentType: "application/xml", onSuccess: function(transport) { alert(transport.responseXML); } }); If I change the responseXML to responseText, then it alerts to me the XML file as a string. This is not a PHP page serving up XML, but an actual XML file, so I know it is not the response headers.
TITLE: How do I get an XML file as XML (and not a string) with Ajax in Prototype.js? QUESTION: This code is from Prototype.js. I've looked at probably 20 different tutorials, and I can't figure out why this is not working. The response I get is null. new Ajax.Request(/path/to / xml / file.xml, { method: "get", contentType: "application/xml", onSuccess: function(transport) { alert(transport.responseXML); } }); If I change the responseXML to responseText, then it alerts to me the XML file as a string. This is not a PHP page serving up XML, but an actual XML file, so I know it is not the response headers. ANSWER: If transport.responseXML is null but you have a value for transport.responseText then I believe it's because it's not a valid XML file. Edit: I just noticed that in our code here whenever we request an XML file we set the content type to 'text/xml'. I have no idea if that makes a difference or not.
[ "javascript", "xml", "prototypejs" ]
0
3
1,199
2
0
2008-09-10T16:42:35.700000
2008-09-10T16:44:39.720000
54,658
112,736
Is there a ClientScriptManager.RegisterClientScriptInclude equivalent for CSS
The ClientScriptManager.RegisterClientScriptInclude method allows you to register a JavaScript reference with the Page object (checking for duplicates). Is there an equivalent of this method for CSS references? Similar questions apply for ClientScriptManager.RegisterClientScriptBlock and ClientScriptManager.RegisterClientScriptResource
Short answer: no. You could certainly roll your own functions (as CMPalmer suggests) to take CSS embedded resources (as Gulzar suggests) and embed them on the page. As a best-practice matter, though, I'm not sure why you would want to do this. If you're making a reusable control that has a lot of CSS styling, my advice would be to just hard-code the class names into the standards-compliant output of your control, and ship the control accompanied by a suggested stylesheet. This gives your users/customers the option of overriding your suggested styles to fit their needs, and in general allows them to manage their CSS setup as they see fit. Separating style from markup is a Good Thing - you're already headed down the right path in avoiding the various built-in ASP.NET style attributes, but you should take it all the way and keep the CSS out of your.dll.
Is there a ClientScriptManager.RegisterClientScriptInclude equivalent for CSS The ClientScriptManager.RegisterClientScriptInclude method allows you to register a JavaScript reference with the Page object (checking for duplicates). Is there an equivalent of this method for CSS references? Similar questions apply for ClientScriptManager.RegisterClientScriptBlock and ClientScriptManager.RegisterClientScriptResource
TITLE: Is there a ClientScriptManager.RegisterClientScriptInclude equivalent for CSS QUESTION: The ClientScriptManager.RegisterClientScriptInclude method allows you to register a JavaScript reference with the Page object (checking for duplicates). Is there an equivalent of this method for CSS references? Similar questions apply for ClientScriptManager.RegisterClientScriptBlock and ClientScriptManager.RegisterClientScriptResource ANSWER: Short answer: no. You could certainly roll your own functions (as CMPalmer suggests) to take CSS embedded resources (as Gulzar suggests) and embed them on the page. As a best-practice matter, though, I'm not sure why you would want to do this. If you're making a reusable control that has a lot of CSS styling, my advice would be to just hard-code the class names into the standards-compliant output of your control, and ship the control accompanied by a suggested stylesheet. This gives your users/customers the option of overriding your suggested styles to fit their needs, and in general allows them to manage their CSS setup as they see fit. Separating style from markup is a Good Thing - you're already headed down the right path in avoiding the various built-in ASP.NET style attributes, but you should take it all the way and keep the CSS out of your.dll.
[ "asp.net", "css" ]
13
7
6,394
6
0
2008-09-10T16:50:57.800000
2008-09-22T01:08:38.597000
54,674
54,742
Any good building tools for a C++ project, which can replace make?
i'm wondering if there is any nice and neat tool to replace the GNU Autotools or Make to build a very large C++ project, which are such a complicated thing to use. It is simple to generate all the files that de Autotools require if the project is small, but if the source code is divided in many directories, with multiple third party libraries and many dependencies, you fall into the "Autotools Hell".. thanks for any recommendations
The Google V8 JavaScript Engine is written in C++ and uses SCons, so I guess that's one vote for it.
Any good building tools for a C++ project, which can replace make? i'm wondering if there is any nice and neat tool to replace the GNU Autotools or Make to build a very large C++ project, which are such a complicated thing to use. It is simple to generate all the files that de Autotools require if the project is small, but if the source code is divided in many directories, with multiple third party libraries and many dependencies, you fall into the "Autotools Hell".. thanks for any recommendations
TITLE: Any good building tools for a C++ project, which can replace make? QUESTION: i'm wondering if there is any nice and neat tool to replace the GNU Autotools or Make to build a very large C++ project, which are such a complicated thing to use. It is simple to generate all the files that de Autotools require if the project is small, but if the source code is divided in many directories, with multiple third party libraries and many dependencies, you fall into the "Autotools Hell".. thanks for any recommendations ANSWER: The Google V8 JavaScript Engine is written in C++ and uses SCons, so I guess that's one vote for it.
[ "c++", "build-process", "makefile" ]
22
18
9,397
9
0
2008-09-10T16:54:04.907000
2008-09-10T17:14:33.640000
54,702
55,745
Modifying the AJAX Control Toolkit Dropdown extender
I am using the example on the AJAX website for the DropDownExtender. I'm looking to make the target control (the label) have the DropDown image appear always, instead of just when I hover over it. Is there any way to do this?
This can be done using the following script tag: I found this and some other tips at this dot net curry example. It works but I'd also consider writing a new control based on the drop down extender exposing a property to set the behaviour you want on or off. Writing a new AJAX control isn't too hard, more fiddly than anything.
Modifying the AJAX Control Toolkit Dropdown extender I am using the example on the AJAX website for the DropDownExtender. I'm looking to make the target control (the label) have the DropDown image appear always, instead of just when I hover over it. Is there any way to do this?
TITLE: Modifying the AJAX Control Toolkit Dropdown extender QUESTION: I am using the example on the AJAX website for the DropDownExtender. I'm looking to make the target control (the label) have the DropDown image appear always, instead of just when I hover over it. Is there any way to do this? ANSWER: This can be done using the following script tag: I found this and some other tips at this dot net curry example. It works but I'd also consider writing a new control based on the drop down extender exposing a property to set the behaviour you want on or off. Writing a new AJAX control isn't too hard, more fiddly than anything.
[ "asp.net", "asp.net-ajax", "ajaxcontroltoolkit" ]
3
4
4,294
1
0
2008-09-10T17:02:00.707000
2008-09-11T03:19:07.947000
54,703
54,750
Should I choose scripting or compiled code for small tasks?
I'm a Java programmer, and I like my compiler, static analysis tools and unit testing frameworks as tools that help me quickly deliver robust and efficient code. The JRE is pretty much everywhere I would work, too. Given that situation, I can't see a reason why I would ever choose to use shell scripting, vb scripting etc, no matter how small the task is if I wear one of my other hats like my cool black sysadmin fedora. I don't wear the other hats too often, under what circumstances should I choose scripting over writing compiled code?
Whatever you think will be most efficient for you! I had a co-worker who seemed to use a different language for every task; Perl for quick text processing, PHP for small internal web applications,.NET for our main product, cygwin for filesystem stuff. He preferred to use the technology which was most specific to the task at hand. Personally, I find that context switching between technologies is painful. My day-to-day work is in.NET, so that's pretty much the terms I think in. For most tasks I find it more efficient to knock something up in C# using SnippetCompiler than I would to hack around in PowerShell or a scripting environment.
Should I choose scripting or compiled code for small tasks? I'm a Java programmer, and I like my compiler, static analysis tools and unit testing frameworks as tools that help me quickly deliver robust and efficient code. The JRE is pretty much everywhere I would work, too. Given that situation, I can't see a reason why I would ever choose to use shell scripting, vb scripting etc, no matter how small the task is if I wear one of my other hats like my cool black sysadmin fedora. I don't wear the other hats too often, under what circumstances should I choose scripting over writing compiled code?
TITLE: Should I choose scripting or compiled code for small tasks? QUESTION: I'm a Java programmer, and I like my compiler, static analysis tools and unit testing frameworks as tools that help me quickly deliver robust and efficient code. The JRE is pretty much everywhere I would work, too. Given that situation, I can't see a reason why I would ever choose to use shell scripting, vb scripting etc, no matter how small the task is if I wear one of my other hats like my cool black sysadmin fedora. I don't wear the other hats too often, under what circumstances should I choose scripting over writing compiled code? ANSWER: Whatever you think will be most efficient for you! I had a co-worker who seemed to use a different language for every task; Perl for quick text processing, PHP for small internal web applications,.NET for our main product, cygwin for filesystem stuff. He preferred to use the technology which was most specific to the task at hand. Personally, I find that context switching between technologies is painful. My day-to-day work is in.NET, so that's pretty much the terms I think in. For most tasks I find it more efficient to knock something up in C# using SnippetCompiler than I would to hack around in PowerShell or a scripting environment.
[ "testing", "scripting" ]
6
2
304
11
0
2008-09-10T17:02:03.500000
2008-09-10T17:16:07.053000
54,708
54,745
Programmatically accessing Data in an ASP.NET 2.0 Repeater
This is an ASP.Net 2.0 web app. The Item template looks like this, for reference: <%# DataBinder.Eval(Container.DataItem,"field1") %> <%# DataBinder.Eval(Container.DataItem,"field2") %> <%# DataBinder.Eval(Container.DataItem,"field3") %> <%# DataBinder.Eval(Container.DataItem,"field4") %> Using this in codebehind: foreach (RepeaterItem item in rptrFollowupSummary.Items) { string val = ((DataBoundLiteralControl)item.Controls[0]).Text; Trace.Write(val); } I produce this: 23 1/1/2000 -2 11 What I need is the data from Field1 and Field4 I can't seem to get at the data the way I would in say a DataList or a GridView, and I can't seem to come up with anything else on Google or quickly leverage this one to do what I want. The only way I can see to get at the data is going to be using a regex to go and get it (Because a man takes what he wants. He takes it all. And I'm a man, aren't I? Aren't I?). Am I on the right track (not looking for the specific regex to do this; forging that might be a followup question;) ), or am I missing something? The Repeater in this case is set in stone so I can't switch to something more elegant. Once upon a time I did something similar to what Alison Zhou suggested using DataLists, but it's been some time (2+ years) and I just completely forgot about doing it this way. Yeesh, talk about overlooking something obvious... So I did as Alison suggested and it works fine. I don't think the viewstate is an issue here, even though this repeater can get dozens of rows. I can't really speak to the question if doing it that way versus using the instead (but that seems like a fine solution to me otherwise). Obviously the latter is less of a viewstate footprint, but I'm not experienced enough to say when one approach might be preferrable to another without an extreme example in front of me. Alison, one question: why literals and not labels? Euro Micelli, I was trying to avoid a return trip to the database. Since I'm still a little green relative to the rest of the development world, I admit I don't necessarily have a good grasp of how many database trips is "just right". There wouldn't be a performance issue here (I know the app's load enough to know this), but I suppose I was trying to avoid it out of habit, since my boss tends to emphasize fewer trips where possible.
Off the top of my head, you can try something like this: Then, in your code behind, you can access each Literal control as follows: foreach (RepeaterItem item in rptrFollowupSummary.Items) { Literal lit1 = (Literal)item.FindControl("litField1"); string value1 = lit1.Text; Literal lit4 = (Literal)item.FindControl("litField4"); string value4 = lit4.Text; } This will add to your ViewState but it makes it easy to find your controls.
Programmatically accessing Data in an ASP.NET 2.0 Repeater This is an ASP.Net 2.0 web app. The Item template looks like this, for reference: <%# DataBinder.Eval(Container.DataItem,"field1") %> <%# DataBinder.Eval(Container.DataItem,"field2") %> <%# DataBinder.Eval(Container.DataItem,"field3") %> <%# DataBinder.Eval(Container.DataItem,"field4") %> Using this in codebehind: foreach (RepeaterItem item in rptrFollowupSummary.Items) { string val = ((DataBoundLiteralControl)item.Controls[0]).Text; Trace.Write(val); } I produce this: 23 1/1/2000 -2 11 What I need is the data from Field1 and Field4 I can't seem to get at the data the way I would in say a DataList or a GridView, and I can't seem to come up with anything else on Google or quickly leverage this one to do what I want. The only way I can see to get at the data is going to be using a regex to go and get it (Because a man takes what he wants. He takes it all. And I'm a man, aren't I? Aren't I?). Am I on the right track (not looking for the specific regex to do this; forging that might be a followup question;) ), or am I missing something? The Repeater in this case is set in stone so I can't switch to something more elegant. Once upon a time I did something similar to what Alison Zhou suggested using DataLists, but it's been some time (2+ years) and I just completely forgot about doing it this way. Yeesh, talk about overlooking something obvious... So I did as Alison suggested and it works fine. I don't think the viewstate is an issue here, even though this repeater can get dozens of rows. I can't really speak to the question if doing it that way versus using the instead (but that seems like a fine solution to me otherwise). Obviously the latter is less of a viewstate footprint, but I'm not experienced enough to say when one approach might be preferrable to another without an extreme example in front of me. Alison, one question: why literals and not labels? Euro Micelli, I was trying to avoid a return trip to the database. Since I'm still a little green relative to the rest of the development world, I admit I don't necessarily have a good grasp of how many database trips is "just right". There wouldn't be a performance issue here (I know the app's load enough to know this), but I suppose I was trying to avoid it out of habit, since my boss tends to emphasize fewer trips where possible.
TITLE: Programmatically accessing Data in an ASP.NET 2.0 Repeater QUESTION: This is an ASP.Net 2.0 web app. The Item template looks like this, for reference: <%# DataBinder.Eval(Container.DataItem,"field1") %> <%# DataBinder.Eval(Container.DataItem,"field2") %> <%# DataBinder.Eval(Container.DataItem,"field3") %> <%# DataBinder.Eval(Container.DataItem,"field4") %> Using this in codebehind: foreach (RepeaterItem item in rptrFollowupSummary.Items) { string val = ((DataBoundLiteralControl)item.Controls[0]).Text; Trace.Write(val); } I produce this: 23 1/1/2000 -2 11 What I need is the data from Field1 and Field4 I can't seem to get at the data the way I would in say a DataList or a GridView, and I can't seem to come up with anything else on Google or quickly leverage this one to do what I want. The only way I can see to get at the data is going to be using a regex to go and get it (Because a man takes what he wants. He takes it all. And I'm a man, aren't I? Aren't I?). Am I on the right track (not looking for the specific regex to do this; forging that might be a followup question;) ), or am I missing something? The Repeater in this case is set in stone so I can't switch to something more elegant. Once upon a time I did something similar to what Alison Zhou suggested using DataLists, but it's been some time (2+ years) and I just completely forgot about doing it this way. Yeesh, talk about overlooking something obvious... So I did as Alison suggested and it works fine. I don't think the viewstate is an issue here, even though this repeater can get dozens of rows. I can't really speak to the question if doing it that way versus using the instead (but that seems like a fine solution to me otherwise). Obviously the latter is less of a viewstate footprint, but I'm not experienced enough to say when one approach might be preferrable to another without an extreme example in front of me. Alison, one question: why literals and not labels? Euro Micelli, I was trying to avoid a return trip to the database. Since I'm still a little green relative to the rest of the development world, I admit I don't necessarily have a good grasp of how many database trips is "just right". There wouldn't be a performance issue here (I know the app's load enough to know this), but I suppose I was trying to avoid it out of habit, since my boss tends to emphasize fewer trips where possible. ANSWER: Off the top of my head, you can try something like this: Then, in your code behind, you can access each Literal control as follows: foreach (RepeaterItem item in rptrFollowupSummary.Items) { Literal lit1 = (Literal)item.FindControl("litField1"); string value1 = lit1.Text; Literal lit4 = (Literal)item.FindControl("litField4"); string value4 = lit4.Text; } This will add to your ViewState but it makes it easy to find your controls.
[ "asp.net", "repeater", "data-access" ]
4
6
8,306
5
0
2008-09-10T17:03:10.470000
2008-09-10T17:15:19.223000
54,725
380,573
Change the "From:" address in Unix "mail"
Sending a message from the Unix command line using mail TO_ADDR results in an email from $USER@$HOSTNAME. Is there a way to change the "From:" address inserted by mail? For the record, I'm using GNU Mailutils 1.1/1.2 on Ubuntu (but I've seen the same behavior with Fedora and RHEL). [EDIT] $ mail -s Testing chris@example.org Cc: From: foo@bar.org Testing. yields Subject: Testing To: X-Mailer: mail (GNU Mailutils 1.1) Message-Id: From: Date: Wed, 10 Sep 2008 13:17:23 -0400 From: foo@bar.org Testing The "From: foo@bar.org" line is part of the message body, not part of the header.
In my version of mail ( Debian linux 4.0 ) the following options work for controlling the source / reply addresses the -a switch, for additional headers to apply, supplying a From: header on the command line that will be appended to the outgoing mail header the $REPLYTO environment variable specifies a Reply-To: header so the following sequence export REPLYTO=cms-replies@example.com mail -aFrom:cms-sends@example.com -s 'Testing' The result, in my mail clients, is a mail from cms-sends@example.com, which any replies to will default to cms-replies@example.com NB: Mac OS users: you don't have -a, but you do have $REPLYTO NB(2): CentOS users, many commenters have added that you need to use -r not -a NB(3): This answer is at least ten years old(1), please bear that in mind when you're coming in from Google.
Change the "From:" address in Unix "mail" Sending a message from the Unix command line using mail TO_ADDR results in an email from $USER@$HOSTNAME. Is there a way to change the "From:" address inserted by mail? For the record, I'm using GNU Mailutils 1.1/1.2 on Ubuntu (but I've seen the same behavior with Fedora and RHEL). [EDIT] $ mail -s Testing chris@example.org Cc: From: foo@bar.org Testing. yields Subject: Testing To: X-Mailer: mail (GNU Mailutils 1.1) Message-Id: From: Date: Wed, 10 Sep 2008 13:17:23 -0400 From: foo@bar.org Testing The "From: foo@bar.org" line is part of the message body, not part of the header.
TITLE: Change the "From:" address in Unix "mail" QUESTION: Sending a message from the Unix command line using mail TO_ADDR results in an email from $USER@$HOSTNAME. Is there a way to change the "From:" address inserted by mail? For the record, I'm using GNU Mailutils 1.1/1.2 on Ubuntu (but I've seen the same behavior with Fedora and RHEL). [EDIT] $ mail -s Testing chris@example.org Cc: From: foo@bar.org Testing. yields Subject: Testing To: X-Mailer: mail (GNU Mailutils 1.1) Message-Id: From: Date: Wed, 10 Sep 2008 13:17:23 -0400 From: foo@bar.org Testing The "From: foo@bar.org" line is part of the message body, not part of the header. ANSWER: In my version of mail ( Debian linux 4.0 ) the following options work for controlling the source / reply addresses the -a switch, for additional headers to apply, supplying a From: header on the command line that will be appended to the outgoing mail header the $REPLYTO environment variable specifies a Reply-To: header so the following sequence export REPLYTO=cms-replies@example.com mail -aFrom:cms-sends@example.com -s 'Testing' The result, in my mail clients, is a mail from cms-sends@example.com, which any replies to will default to cms-replies@example.com NB: Mac OS users: you don't have -a, but you do have $REPLYTO NB(2): CentOS users, many commenters have added that you need to use -r not -a NB(3): This answer is at least ten years old(1), please bear that in mind when you're coming in from Google.
[ "unix", "email" ]
105
118
291,404
20
0
2008-09-10T17:08:37.867000
2008-12-19T10:09:18.020000
54,754
54,777
How can you do paging with NHibernate?
For example, I want to populate a gridview control in an ASP.NET web page with only the data necessary for the # of rows displayed. How can NHibernate support this?
ICriteria has a SetFirstResult(int i) method, which indicates the index of the first item that you wish to get (basically the first data row in your page). It also has a SetMaxResults(int i) method, which indicates the number of rows you wish to get (i.e., your page size). For example, this criteria object gets the first 10 results of your data grid: criteria.SetFirstResult(0).SetMaxResults(10);
How can you do paging with NHibernate? For example, I want to populate a gridview control in an ASP.NET web page with only the data necessary for the # of rows displayed. How can NHibernate support this?
TITLE: How can you do paging with NHibernate? QUESTION: For example, I want to populate a gridview control in an ASP.NET web page with only the data necessary for the # of rows displayed. How can NHibernate support this? ANSWER: ICriteria has a SetFirstResult(int i) method, which indicates the index of the first item that you wish to get (basically the first data row in your page). It also has a SetMaxResults(int i) method, which indicates the number of rows you wish to get (i.e., your page size). For example, this criteria object gets the first 10 results of your data grid: criteria.SetFirstResult(0).SetMaxResults(10);
[ ".net", "nhibernate", "orm", "pagination" ]
110
113
53,375
8
0
2008-09-10T17:16:53.230000
2008-09-10T17:27:33.860000
54,758
110,029
Getting the back/fwd history of the WebBrowser Control
In C# WinForms, what's the proper way to get the backward/forward history stacks for the System.Windows.Forms.WebBrowser?
Check out http://www.bsalsa.com/downloads.html. This is a series of Delphi components (free source code, you can see an example of this here: http://staruml.cvs.sourceforge.net/staruml/staruml/staruml/components/plastic-components/src/embeddedwb.pas?revision=1.1&view=markup - it's the starUML projects code) and they have, among other things, a way to get at the history, favorites, etc using the IE MSHTML interfaces. It's written in Object Pascal but it shouldn't be too hard to figure out what's going on. If you download the "Embedded Web Browser Components Package" take a look at the stuff in EmbeddedWB_D2005\Source - there's all sorts of goodies there.
Getting the back/fwd history of the WebBrowser Control In C# WinForms, what's the proper way to get the backward/forward history stacks for the System.Windows.Forms.WebBrowser?
TITLE: Getting the back/fwd history of the WebBrowser Control QUESTION: In C# WinForms, what's the proper way to get the backward/forward history stacks for the System.Windows.Forms.WebBrowser? ANSWER: Check out http://www.bsalsa.com/downloads.html. This is a series of Delphi components (free source code, you can see an example of this here: http://staruml.cvs.sourceforge.net/staruml/staruml/staruml/components/plastic-components/src/embeddedwb.pas?revision=1.1&view=markup - it's the starUML projects code) and they have, among other things, a way to get at the history, favorites, etc using the IE MSHTML interfaces. It's written in Object Pascal but it shouldn't be too hard to figure out what's going on. If you download the "Embedded Web Browser Components Package" take a look at the stuff in EmbeddedWB_D2005\Source - there's all sorts of goodies there.
[ "c#", ".net", "winforms", "navigation", "webbrowser-control" ]
5
4
3,067
2
0
2008-09-10T17:17:21.530000
2008-09-21T02:20:47.637000
54,760
57,771
Unfiltering NSPasteboard
Is there a way to unfilter an NSPasteboard for what the source application specifically declared it would provide? I'm attempting to serialize pasteboard data in my application. When another application places an RTF file on a pasteboard and then I ask for the available types, I get eleven different flavors of said RTF, everything from the original RTF to plain strings to dyn.* values. Saving off all that data into a plist or raw data on disk isn't usually a problem as it's pretty small, but when an image of any considerable size is placed on the pasteboard, the resulting output can be tens of times larger than the source data (with multiple flavors of TIFF and PICT data being made available via filtering). I'd like to just be able to save off what the original app made available if possible. John, you are far more observant than myself or the gentleman I work with who's been doing Mac programming since dinosaurs roamed the earth. Neither of us ever noticed the text you highlighted... and I've not a clue why. Starting too long at the problem, apparently. And while I accepted your answer as the correct answer, it doesn't exactly answer my original question. What I was looking for was a way to identify flavors that can become other flavors simply by placing them on the pasteboard AND to know which of these types were originally offered by the provider. While walking the types list will get me the preferred order for the application that provided them, it won't tell me which ones I can safely ignore as they'll be recreated when I refill the pasteboard later. I've come to the conclusion that there isn't a "good" way to do this. [NSPasteboard declaredTypesFromOwner] would be fabulous, but it doesn't exist.
-[NSPasteboard types] will return all the available types for the data on the clipboard, but it should return them "in the order they were declared." The documentation for -[NSPasteboard declareTypes:owner:] says that "the types should be ordered according to the preference of the source application." A properly implemented pasteboard owner should, therefore, declare the richest representation of the content (probably the original content) as the first type; so a reasonable single representation should be: [pb dataForType:[[pb types] objectAtIndex:0]]
Unfiltering NSPasteboard Is there a way to unfilter an NSPasteboard for what the source application specifically declared it would provide? I'm attempting to serialize pasteboard data in my application. When another application places an RTF file on a pasteboard and then I ask for the available types, I get eleven different flavors of said RTF, everything from the original RTF to plain strings to dyn.* values. Saving off all that data into a plist or raw data on disk isn't usually a problem as it's pretty small, but when an image of any considerable size is placed on the pasteboard, the resulting output can be tens of times larger than the source data (with multiple flavors of TIFF and PICT data being made available via filtering). I'd like to just be able to save off what the original app made available if possible. John, you are far more observant than myself or the gentleman I work with who's been doing Mac programming since dinosaurs roamed the earth. Neither of us ever noticed the text you highlighted... and I've not a clue why. Starting too long at the problem, apparently. And while I accepted your answer as the correct answer, it doesn't exactly answer my original question. What I was looking for was a way to identify flavors that can become other flavors simply by placing them on the pasteboard AND to know which of these types were originally offered by the provider. While walking the types list will get me the preferred order for the application that provided them, it won't tell me which ones I can safely ignore as they'll be recreated when I refill the pasteboard later. I've come to the conclusion that there isn't a "good" way to do this. [NSPasteboard declaredTypesFromOwner] would be fabulous, but it doesn't exist.
TITLE: Unfiltering NSPasteboard QUESTION: Is there a way to unfilter an NSPasteboard for what the source application specifically declared it would provide? I'm attempting to serialize pasteboard data in my application. When another application places an RTF file on a pasteboard and then I ask for the available types, I get eleven different flavors of said RTF, everything from the original RTF to plain strings to dyn.* values. Saving off all that data into a plist or raw data on disk isn't usually a problem as it's pretty small, but when an image of any considerable size is placed on the pasteboard, the resulting output can be tens of times larger than the source data (with multiple flavors of TIFF and PICT data being made available via filtering). I'd like to just be able to save off what the original app made available if possible. John, you are far more observant than myself or the gentleman I work with who's been doing Mac programming since dinosaurs roamed the earth. Neither of us ever noticed the text you highlighted... and I've not a clue why. Starting too long at the problem, apparently. And while I accepted your answer as the correct answer, it doesn't exactly answer my original question. What I was looking for was a way to identify flavors that can become other flavors simply by placing them on the pasteboard AND to know which of these types were originally offered by the provider. While walking the types list will get me the preferred order for the application that provided them, it won't tell me which ones I can safely ignore as they'll be recreated when I refill the pasteboard later. I've come to the conclusion that there isn't a "good" way to do this. [NSPasteboard declaredTypesFromOwner] would be fabulous, but it doesn't exist. ANSWER: -[NSPasteboard types] will return all the available types for the data on the clipboard, but it should return them "in the order they were declared." The documentation for -[NSPasteboard declareTypes:owner:] says that "the types should be ordered according to the preference of the source application." A properly implemented pasteboard owner should, therefore, declare the richest representation of the content (probably the original content) as the first type; so a reasonable single representation should be: [pb dataForType:[[pb types] objectAtIndex:0]]
[ "cocoa", "filtering", "pasteboard" ]
5
4
1,161
2
0
2008-09-10T17:20:03.597000
2008-09-11T22:06:49.657000
54,770
54,804
ClickOnce Deployment, system update required Microsoft.mshtml
We have an application that works with MS Office and uses Microsoft.mshtml.dll. We use ClickOnce to deploy the application. The application deploys without issues on most machines, but sometimes we get errors saying "System Update Required, Microsoft.mshtl.dll should be in the GAC". We tried installing the PIA for Office without luck. Since Microsoft.mshtml.dll is a system dependent file we cannot include it in the package and re-distribute it. What would be the best way to deploy the application?
Do you know which version of MS Office you are targeting? These PIAs are very specific to the version of Office. I remember when we were building a smart client application, we used to have Build VM machines, each one targeting a specific version of Outlook. Another hurdle was not being able to specify these PIAs as pre-requisites or bundle them with the app. These PIAs needs to be installed on the client using Office CD ( at least for 2003 version ).
ClickOnce Deployment, system update required Microsoft.mshtml We have an application that works with MS Office and uses Microsoft.mshtml.dll. We use ClickOnce to deploy the application. The application deploys without issues on most machines, but sometimes we get errors saying "System Update Required, Microsoft.mshtl.dll should be in the GAC". We tried installing the PIA for Office without luck. Since Microsoft.mshtml.dll is a system dependent file we cannot include it in the package and re-distribute it. What would be the best way to deploy the application?
TITLE: ClickOnce Deployment, system update required Microsoft.mshtml QUESTION: We have an application that works with MS Office and uses Microsoft.mshtml.dll. We use ClickOnce to deploy the application. The application deploys without issues on most machines, but sometimes we get errors saying "System Update Required, Microsoft.mshtl.dll should be in the GAC". We tried installing the PIA for Office without luck. Since Microsoft.mshtml.dll is a system dependent file we cannot include it in the package and re-distribute it. What would be the best way to deploy the application? ANSWER: Do you know which version of MS Office you are targeting? These PIAs are very specific to the version of Office. I remember when we were building a smart client application, we used to have Build VM machines, each one targeting a specific version of Outlook. Another hurdle was not being able to specify these PIAs as pre-requisites or bundle them with the app. These PIAs needs to be installed on the client using Office CD ( at least for 2003 version ).
[ "clickonce", "microsoft.mshtml" ]
1
1
2,782
4
0
2008-09-10T17:24:56.067000
2008-09-10T17:40:48.040000
54,771
54,778
Website Monitoring Libraries
There has been some talk of Website performance monitoring tools and services on stackoverflow, however, they seem fairly expensive for what they actually do. Are there any good opensource libraries for automating checking/monitoring the availability of a website?
If you just want to know if your server is serving out content or not, take a look at Montastic. I use it, and am pleased. Plus its free! It will ping your site periodically, and if it doesn't get a 200 status, it lets you know.
Website Monitoring Libraries There has been some talk of Website performance monitoring tools and services on stackoverflow, however, they seem fairly expensive for what they actually do. Are there any good opensource libraries for automating checking/monitoring the availability of a website?
TITLE: Website Monitoring Libraries QUESTION: There has been some talk of Website performance monitoring tools and services on stackoverflow, however, they seem fairly expensive for what they actually do. Are there any good opensource libraries for automating checking/monitoring the availability of a website? ANSWER: If you just want to know if your server is serving out content or not, take a look at Montastic. I use it, and am pleased. Plus its free! It will ping your site periodically, and if it doesn't get a 200 status, it lets you know.
[ "monitoring", "web", "polling" ]
6
2
497
4
0
2008-09-10T17:25:19.950000
2008-09-10T17:27:42.753000
54,789
54,817
What is the correct .NET exception to throw when try to insert a duplicate object into a collection?
I have an Asset object that has a property AssignedSoftware, which is a collection. I want to make sure that the same piece of Software is not assigned to an Asset more than once. In Add method I check to see if the Software already exist, and if it does, I want to throw an exception. Is there a standard.NET exception that I should be throwing? Or does best practices dictate I create my own custom exception?
From the Class Library design guidelines for errors ( http://msdn.microsoft.com/en-us/library/8ey5ey87(VS.71).aspx ): In most cases, use the predefined exception types. Only define new exception types for programmatic scenarios, where you expect users of your class library to catch exceptions of this new type and perform a programmatic action based on the exception type itself. This is in lieu of parsing the exception string, which would negatively impact performance and maintenance.... Throw an ArgumentException or create an exception derived from this class if invalid parameters are passed or detected. Throw the InvalidOperationException exception if a call to a property set accessor or method is not appropriate given the object's current state. This seems like an "Object state invalid" scenario to me, so I'd pick InvalidOperationException over ArgumentException: The parameters are valid, but not at this point in the objects life.
What is the correct .NET exception to throw when try to insert a duplicate object into a collection? I have an Asset object that has a property AssignedSoftware, which is a collection. I want to make sure that the same piece of Software is not assigned to an Asset more than once. In Add method I check to see if the Software already exist, and if it does, I want to throw an exception. Is there a standard.NET exception that I should be throwing? Or does best practices dictate I create my own custom exception?
TITLE: What is the correct .NET exception to throw when try to insert a duplicate object into a collection? QUESTION: I have an Asset object that has a property AssignedSoftware, which is a collection. I want to make sure that the same piece of Software is not assigned to an Asset more than once. In Add method I check to see if the Software already exist, and if it does, I want to throw an exception. Is there a standard.NET exception that I should be throwing? Or does best practices dictate I create my own custom exception? ANSWER: From the Class Library design guidelines for errors ( http://msdn.microsoft.com/en-us/library/8ey5ey87(VS.71).aspx ): In most cases, use the predefined exception types. Only define new exception types for programmatic scenarios, where you expect users of your class library to catch exceptions of this new type and perform a programmatic action based on the exception type itself. This is in lieu of parsing the exception string, which would negatively impact performance and maintenance.... Throw an ArgumentException or create an exception derived from this class if invalid parameters are passed or detected. Throw the InvalidOperationException exception if a call to a property set accessor or method is not appropriate given the object's current state. This seems like an "Object state invalid" scenario to me, so I'd pick InvalidOperationException over ArgumentException: The parameters are valid, but not at this point in the objects life.
[ "c#", "exception", "collections" ]
6
5
5,113
5
0
2008-09-10T17:35:36.460000
2008-09-10T17:43:01.700000
54,790
56,113
Is it possible to build MSBuild files (visual studio sln) from the command line in Mono?
Is it possible to build Visual Studio solutions without having to fire up MonoDevelop?
Current status (Mono 2.10, 2011): xbuild is now able to build all versions of Visual Studio / MSBuild projects, including.sln files. Simply run xbuild just as you would execute msbuild on Microsoft.Net Framework. You don't need Monodevelop installed, xbuild comes with the standard Mono installation. If your build uses custom tasks, they should still work if they don't depend on Windows executables (such as rmdir or xcopy ). When you are editing project files, use standard Windows path syntax - they will be converted by xbuild, if necessary. One important caveat to this rule is case sensitivity - don't mix different casings of the same file name. If you have a project that does this, you can enable compatibility mode by invoking MONO_IOMAP=case xbuild foo.sln (or try MONO_IOMAP=all ). Mono has a page describing more advanced MSBuild project porting techniques. Mono 2.0 answer (2008): xbuild is not yet complete (it works quite well with VS2005.csproj files, has problems with VS2008.csproj and does not handle.sln). Mono 2.1 plans to merge the code base of mdtool (MonoDevelop command line build engine) into it, but currently mdtool is a better choice. mdtool build -f:project.sln or man mdtool if you have MonoDevelop installed.
Is it possible to build MSBuild files (visual studio sln) from the command line in Mono? Is it possible to build Visual Studio solutions without having to fire up MonoDevelop?
TITLE: Is it possible to build MSBuild files (visual studio sln) from the command line in Mono? QUESTION: Is it possible to build Visual Studio solutions without having to fire up MonoDevelop? ANSWER: Current status (Mono 2.10, 2011): xbuild is now able to build all versions of Visual Studio / MSBuild projects, including.sln files. Simply run xbuild just as you would execute msbuild on Microsoft.Net Framework. You don't need Monodevelop installed, xbuild comes with the standard Mono installation. If your build uses custom tasks, they should still work if they don't depend on Windows executables (such as rmdir or xcopy ). When you are editing project files, use standard Windows path syntax - they will be converted by xbuild, if necessary. One important caveat to this rule is case sensitivity - don't mix different casings of the same file name. If you have a project that does this, you can enable compatibility mode by invoking MONO_IOMAP=case xbuild foo.sln (or try MONO_IOMAP=all ). Mono has a page describing more advanced MSBuild project porting techniques. Mono 2.0 answer (2008): xbuild is not yet complete (it works quite well with VS2005.csproj files, has problems with VS2008.csproj and does not handle.sln). Mono 2.1 plans to merge the code base of mdtool (MonoDevelop command line build engine) into it, but currently mdtool is a better choice. mdtool build -f:project.sln or man mdtool if you have MonoDevelop installed.
[ "msbuild", "mono" ]
65
70
57,503
4
0
2008-09-10T17:36:00.110000
2008-09-11T09:19:47.753000
54,797
54,798
How do you implement Levenshtein distance in Delphi?
I'm posting this in the spirit of answering your own questions. The question I had was: How can I implement the Levenshtein algorithm for calculating edit-distance between two strings, as described here, in Delphi? Just a note on performance: This thing is very fast. On my desktop (2.33 Ghz dual-core, 2GB ram, WinXP), I can run through an array of 100K strings in less than one second.
function EditDistance(s, t: string): integer; var d: array of array of integer; i,j,cost: integer; begin { Compute the edit-distance between two strings. Algorithm and description may be found at either of these two links: http://en.wikipedia.org/wiki/Levenshtein_distance http://www.google.com/search?q=Levenshtein+distance } //initialize our cost array SetLength(d,Length(s)+1); for i:= Low(d) to High(d) do begin SetLength(d[i],Length(t)+1); end; for i:= Low(d) to High(d) do begin d[i,0]:= i; for j:= Low(d[i]) to High(d[i]) do begin d[0,j]:= j; end; end; //store our costs in a 2-d grid for i:= Low(d)+1 to High(d) do begin for j:= Low(d[i])+1 to High(d[i]) do begin if s[i] = t[j] then begin cost:= 0; end else begin cost:= 1; end; //to use "Min", add "Math" to your uses clause! d[i,j]:= Min(Min( d[i-1,j]+1, //deletion d[i,j-1]+1), //insertion d[i-1,j-1]+cost //substitution ); end; //for j end; //for i //now that we've stored the costs, return the final one Result:= d[Length(s),Length(t)]; //dynamic arrays are reference counted. //no need to deallocate them end;
How do you implement Levenshtein distance in Delphi? I'm posting this in the spirit of answering your own questions. The question I had was: How can I implement the Levenshtein algorithm for calculating edit-distance between two strings, as described here, in Delphi? Just a note on performance: This thing is very fast. On my desktop (2.33 Ghz dual-core, 2GB ram, WinXP), I can run through an array of 100K strings in less than one second.
TITLE: How do you implement Levenshtein distance in Delphi? QUESTION: I'm posting this in the spirit of answering your own questions. The question I had was: How can I implement the Levenshtein algorithm for calculating edit-distance between two strings, as described here, in Delphi? Just a note on performance: This thing is very fast. On my desktop (2.33 Ghz dual-core, 2GB ram, WinXP), I can run through an array of 100K strings in less than one second. ANSWER: function EditDistance(s, t: string): integer; var d: array of array of integer; i,j,cost: integer; begin { Compute the edit-distance between two strings. Algorithm and description may be found at either of these two links: http://en.wikipedia.org/wiki/Levenshtein_distance http://www.google.com/search?q=Levenshtein+distance } //initialize our cost array SetLength(d,Length(s)+1); for i:= Low(d) to High(d) do begin SetLength(d[i],Length(t)+1); end; for i:= Low(d) to High(d) do begin d[i,0]:= i; for j:= Low(d[i]) to High(d[i]) do begin d[0,j]:= j; end; end; //store our costs in a 2-d grid for i:= Low(d)+1 to High(d) do begin for j:= Low(d[i])+1 to High(d[i]) do begin if s[i] = t[j] then begin cost:= 0; end else begin cost:= 1; end; //to use "Min", add "Math" to your uses clause! d[i,j]:= Min(Min( d[i-1,j]+1, //deletion d[i,j-1]+1), //insertion d[i-1,j-1]+cost //substitution ); end; //for j end; //for i //now that we've stored the costs, return the final one Result:= d[Length(s),Length(t)]; //dynamic arrays are reference counted. //no need to deallocate them end;
[ "algorithm", "delphi", "levenshtein-distance", "edit-distance" ]
20
18
5,010
1
0
2008-09-10T17:38:05.193000
2008-09-10T17:38:15.987000
54,808
55,802
How to best merge information, at a server, into a "form", a PDF being generated as the final output
Background: I have a VB6 application I've "inherited" that generates a PDF for the user to review using unsupported Acrobat Reader OCX integration. The program generates an FDF file with the data, then renders the merged result when the FDF is merged with a PDF. It only works correctly with Acrobat Reader 4:-(. Installing a newer version of Acrobat Reader breaks this application, making the users very unhappy. I want to re-architect this app so that it will send the data to be merged to a PDF output generation server. This server will merge the data passed to it onto the form, generate a PDF image of this, and store it, so that any user wishing to view the final result can then simply get the PDF (it is generated just once). If the underlying data is changed, the PDF will be deleted and regenerated next time it is requested. The client program can then have any version of Acrobat Reader they wish, as it will be used exclusively for displaying PDF files (as it was intended). The server will most likely be written in.NET (C#) with Visual Studio 2005, probably as a Web Service... Question: How would others recommend I go about this? Should I use Adobe's Acrobat 9 at the server to do this, puting the data into FDF or Adobe's XML format, and letting Acrobat do the merge? Are there great competitors in the "merge data onto form and output a PDF" space? How do others do this? It has to be API based, no GUI at the server, of course... While some output is generated via FDF/PDF, another part of the application actually sends lines, graphics, and text to the printer (or a form for preview purposes) one page at a time, giving the proper x/y coordinates, font, size, etc. for each, knowing when it is at the end of a page, etc. This code is currently in the program that displays this for the user to review, and it is also in the program that prints the final form to the printer. For consistency between reviewer and printer, I'd like to move this output generation logic to a server as well, either using a good PDF generation API tool or use the code as is and generate a PDF with a PDF printer... and saving this PDF for display by the clients. Googling "Form software" or "fill form software" or similar searches returns sooooooooo much unrelated material, mostly related to UI for users to fill in forms, I just don't know how to properly narrow down my search. This site seems the perfect place to ask such a question, as other programmers must also need to generate similar outputs, and have tried out some great tools. EDIT: I've added PDF tag as well as PDF-generation. Also, my current customer insists on PDF output, but I appreciate the alternative suggestions.
can't help with VB6 solution, can help with.net or java solution on the server. Get iText or iTextSharp from http://www.lowagie.com/iText/. It has a PdfStamper class that can merge a PDF and FDF FDFReader/FDFWriter classes to generate FDF files, get field names out of PDF files, etc...
How to best merge information, at a server, into a "form", a PDF being generated as the final output Background: I have a VB6 application I've "inherited" that generates a PDF for the user to review using unsupported Acrobat Reader OCX integration. The program generates an FDF file with the data, then renders the merged result when the FDF is merged with a PDF. It only works correctly with Acrobat Reader 4:-(. Installing a newer version of Acrobat Reader breaks this application, making the users very unhappy. I want to re-architect this app so that it will send the data to be merged to a PDF output generation server. This server will merge the data passed to it onto the form, generate a PDF image of this, and store it, so that any user wishing to view the final result can then simply get the PDF (it is generated just once). If the underlying data is changed, the PDF will be deleted and regenerated next time it is requested. The client program can then have any version of Acrobat Reader they wish, as it will be used exclusively for displaying PDF files (as it was intended). The server will most likely be written in.NET (C#) with Visual Studio 2005, probably as a Web Service... Question: How would others recommend I go about this? Should I use Adobe's Acrobat 9 at the server to do this, puting the data into FDF or Adobe's XML format, and letting Acrobat do the merge? Are there great competitors in the "merge data onto form and output a PDF" space? How do others do this? It has to be API based, no GUI at the server, of course... While some output is generated via FDF/PDF, another part of the application actually sends lines, graphics, and text to the printer (or a form for preview purposes) one page at a time, giving the proper x/y coordinates, font, size, etc. for each, knowing when it is at the end of a page, etc. This code is currently in the program that displays this for the user to review, and it is also in the program that prints the final form to the printer. For consistency between reviewer and printer, I'd like to move this output generation logic to a server as well, either using a good PDF generation API tool or use the code as is and generate a PDF with a PDF printer... and saving this PDF for display by the clients. Googling "Form software" or "fill form software" or similar searches returns sooooooooo much unrelated material, mostly related to UI for users to fill in forms, I just don't know how to properly narrow down my search. This site seems the perfect place to ask such a question, as other programmers must also need to generate similar outputs, and have tried out some great tools. EDIT: I've added PDF tag as well as PDF-generation. Also, my current customer insists on PDF output, but I appreciate the alternative suggestions.
TITLE: How to best merge information, at a server, into a "form", a PDF being generated as the final output QUESTION: Background: I have a VB6 application I've "inherited" that generates a PDF for the user to review using unsupported Acrobat Reader OCX integration. The program generates an FDF file with the data, then renders the merged result when the FDF is merged with a PDF. It only works correctly with Acrobat Reader 4:-(. Installing a newer version of Acrobat Reader breaks this application, making the users very unhappy. I want to re-architect this app so that it will send the data to be merged to a PDF output generation server. This server will merge the data passed to it onto the form, generate a PDF image of this, and store it, so that any user wishing to view the final result can then simply get the PDF (it is generated just once). If the underlying data is changed, the PDF will be deleted and regenerated next time it is requested. The client program can then have any version of Acrobat Reader they wish, as it will be used exclusively for displaying PDF files (as it was intended). The server will most likely be written in.NET (C#) with Visual Studio 2005, probably as a Web Service... Question: How would others recommend I go about this? Should I use Adobe's Acrobat 9 at the server to do this, puting the data into FDF or Adobe's XML format, and letting Acrobat do the merge? Are there great competitors in the "merge data onto form and output a PDF" space? How do others do this? It has to be API based, no GUI at the server, of course... While some output is generated via FDF/PDF, another part of the application actually sends lines, graphics, and text to the printer (or a form for preview purposes) one page at a time, giving the proper x/y coordinates, font, size, etc. for each, knowing when it is at the end of a page, etc. This code is currently in the program that displays this for the user to review, and it is also in the program that prints the final form to the printer. For consistency between reviewer and printer, I'd like to move this output generation logic to a server as well, either using a good PDF generation API tool or use the code as is and generate a PDF with a PDF printer... and saving this PDF for display by the clients. Googling "Form software" or "fill form software" or similar searches returns sooooooooo much unrelated material, mostly related to UI for users to fill in forms, I just don't know how to properly narrow down my search. This site seems the perfect place to ask such a question, as other programmers must also need to generate similar outputs, and have tried out some great tools. EDIT: I've added PDF tag as well as PDF-generation. Also, my current customer insists on PDF output, but I appreciate the alternative suggestions. ANSWER: can't help with VB6 solution, can help with.net or java solution on the server. Get iText or iTextSharp from http://www.lowagie.com/iText/. It has a PdfStamper class that can merge a PDF and FDF FDFReader/FDFWriter classes to generate FDF files, get field names out of PDF files, etc...
[ ".net", "forms", "pdf", "pdf-generation" ]
3
2
1,986
4
0
2008-09-10T17:41:28.570000
2008-09-11T04:24:58.867000
54,833
54,888
Prevent Multi-Line ASP:Textbox from trimming line feeds
I have the following webform: <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="TestWebApp.Default" %> and each time I post-back the leading line feeds in the textbox are being removed. Is there any way that I can prevent this behavior? I was thinking of creating a custom-control that inherited from the textbox but I wanted to get a sanity check here first.
I ended up doing the following in the btnSubmitClick() public void btnSubmitClick(object sender, EventArgs e) { if (this.txtMultiLine.Text.StartsWith("\r\n")) { this.txtMultiLine.Text = "\r\n" + this.txtMultiLine.Text; } } I must be really tired or sick or something.
Prevent Multi-Line ASP:Textbox from trimming line feeds I have the following webform: <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="TestWebApp.Default" %> and each time I post-back the leading line feeds in the textbox are being removed. Is there any way that I can prevent this behavior? I was thinking of creating a custom-control that inherited from the textbox but I wanted to get a sanity check here first.
TITLE: Prevent Multi-Line ASP:Textbox from trimming line feeds QUESTION: I have the following webform: <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="TestWebApp.Default" %> and each time I post-back the leading line feeds in the textbox are being removed. Is there any way that I can prevent this behavior? I was thinking of creating a custom-control that inherited from the textbox but I wanted to get a sanity check here first. ANSWER: I ended up doing the following in the btnSubmitClick() public void btnSubmitClick(object sender, EventArgs e) { if (this.txtMultiLine.Text.StartsWith("\r\n")) { this.txtMultiLine.Text = "\r\n" + this.txtMultiLine.Text; } } I must be really tired or sick or something.
[ "c#", "asp.net", "textbox", "postback" ]
2
2
2,859
2
0
2008-09-10T17:48:28.023000
2008-09-10T18:05:45.423000
54,837
54,900
Is there a good library for dealing with the Modbus protocol in .NET?
Does anyone know of a good (preferably open source) library for dealing with the Modbus protocol? I have seen a few libraries, but I am looking for some people's personal experiences, not just the top ten Google hits. I figure there has to be at least one other person who deals with PLCs and automation hardware like I do out there. Open to any other materials that might have been a help to you as well...
I have done a lot of communication with devices for the past few years, since I work for a home automation company, but we don't use Modbus. We do communication in a standard and open way using Web Services for Devices(WSD) which is also know as Devices Profile for Web Services(DPWS). During this time at one point, I did hear of a project called NModbus. It is an open source library for working with modbus. I have not used it, but looking at the site and the changesets on Google Code, it looks pretty active. You may want to give it a look and even get involved in. This is the only library that I have heard of that targets.Net.
Is there a good library for dealing with the Modbus protocol in .NET? Does anyone know of a good (preferably open source) library for dealing with the Modbus protocol? I have seen a few libraries, but I am looking for some people's personal experiences, not just the top ten Google hits. I figure there has to be at least one other person who deals with PLCs and automation hardware like I do out there. Open to any other materials that might have been a help to you as well...
TITLE: Is there a good library for dealing with the Modbus protocol in .NET? QUESTION: Does anyone know of a good (preferably open source) library for dealing with the Modbus protocol? I have seen a few libraries, but I am looking for some people's personal experiences, not just the top ten Google hits. I figure there has to be at least one other person who deals with PLCs and automation hardware like I do out there. Open to any other materials that might have been a help to you as well... ANSWER: I have done a lot of communication with devices for the past few years, since I work for a home automation company, but we don't use Modbus. We do communication in a standard and open way using Web Services for Devices(WSD) which is also know as Devices Profile for Web Services(DPWS). During this time at one point, I did hear of a project called NModbus. It is an open source library for working with modbus. I have not used it, but looking at the site and the changesets on Google Code, it looks pretty active. You may want to give it a look and even get involved in. This is the only library that I have heard of that targets.Net.
[ ".net", "open-source", "protocols", "plc", "modbus" ]
21
22
29,580
5
0
2008-09-10T17:49:24.743000
2008-09-10T18:08:23.857000
54,851
54,856
What are some best practices for creating my own custom exception?
In a follow-up to a previous question regarding exceptions, what are best practices for creating a custom exception in.NET? More specifically should you inherit from System.Exception, System.ApplicationException or some other base exception?
Inherit from System.Exception. System.ApplicationException is useless and the design guidelines say " Do not throw or derive from System.ApplicationException." See http://blogs.msdn.com/kcwalina/archive/2006/06/23/644822.aspx
What are some best practices for creating my own custom exception? In a follow-up to a previous question regarding exceptions, what are best practices for creating a custom exception in.NET? More specifically should you inherit from System.Exception, System.ApplicationException or some other base exception?
TITLE: What are some best practices for creating my own custom exception? QUESTION: In a follow-up to a previous question regarding exceptions, what are best practices for creating a custom exception in.NET? More specifically should you inherit from System.Exception, System.ApplicationException or some other base exception? ANSWER: Inherit from System.Exception. System.ApplicationException is useless and the design guidelines say " Do not throw or derive from System.ApplicationException." See http://blogs.msdn.com/kcwalina/archive/2006/06/23/644822.aspx
[ "c#", ".net", "exception" ]
24
16
14,003
5
0
2008-09-10T17:55:01.063000
2008-09-10T17:57:04.413000
54,861
54,967
Better way of opening a Document from Java?
I've been using the following code to open Office Documents, PDF, etc. on my windows machines using Java and it's working fine, except for some reason when a filename has embedded it within it multiple contiguous spaces like "File[SPACE][SPACE]Test.doc". How can I make this work? I'm not averse to canning the whole piece of code... but I'd rather not replace it with a third party library that calls JNI. public static void openDocument(String path) throws IOException { // Make forward slashes backslashes (for windows) // Double quote any path segments with spaces in them path = path.replace("/", "\\").replaceAll( "\\\\([^\\\\\\\\\"]* [^\\\\\\\\\"]*)", "\\\\\\\"$1\""); String command = "C:\\Windows\\System32\\cmd.exe /c start " + path + ""; Runtime.getRuntime().exec(command); } EDIT: When I run it with the errant file windows complains about finding the file. But... when I run the command line directly from the command line it runs just fine.
If you are using Java 6 you can just use the open method of java.awt.Desktop to launch the file using the default application for the current platform.
Better way of opening a Document from Java? I've been using the following code to open Office Documents, PDF, etc. on my windows machines using Java and it's working fine, except for some reason when a filename has embedded it within it multiple contiguous spaces like "File[SPACE][SPACE]Test.doc". How can I make this work? I'm not averse to canning the whole piece of code... but I'd rather not replace it with a third party library that calls JNI. public static void openDocument(String path) throws IOException { // Make forward slashes backslashes (for windows) // Double quote any path segments with spaces in them path = path.replace("/", "\\").replaceAll( "\\\\([^\\\\\\\\\"]* [^\\\\\\\\\"]*)", "\\\\\\\"$1\""); String command = "C:\\Windows\\System32\\cmd.exe /c start " + path + ""; Runtime.getRuntime().exec(command); } EDIT: When I run it with the errant file windows complains about finding the file. But... when I run the command line directly from the command line it runs just fine.
TITLE: Better way of opening a Document from Java? QUESTION: I've been using the following code to open Office Documents, PDF, etc. on my windows machines using Java and it's working fine, except for some reason when a filename has embedded it within it multiple contiguous spaces like "File[SPACE][SPACE]Test.doc". How can I make this work? I'm not averse to canning the whole piece of code... but I'd rather not replace it with a third party library that calls JNI. public static void openDocument(String path) throws IOException { // Make forward slashes backslashes (for windows) // Double quote any path segments with spaces in them path = path.replace("/", "\\").replaceAll( "\\\\([^\\\\\\\\\"]* [^\\\\\\\\\"]*)", "\\\\\\\"$1\""); String command = "C:\\Windows\\System32\\cmd.exe /c start " + path + ""; Runtime.getRuntime().exec(command); } EDIT: When I run it with the errant file windows complains about finding the file. But... when I run the command line directly from the command line it runs just fine. ANSWER: If you are using Java 6 you can just use the open method of java.awt.Desktop to launch the file using the default application for the current platform.
[ "java", "windows", "process" ]
3
5
641
3
0
2008-09-10T17:58:19.370000
2008-09-10T18:36:43.727000
54,866
54,928
Best way to parse Space Separated Text
I have string like this /c SomeText\MoreText "Some Text\More Text\Lol" SomeText I want to tokenize it, however I can't just split on the spaces. I've come up with somewhat ugly parser that works, but I'm wondering if anyone has a more elegant design. This is in C# btw. EDIT: My ugly version, while ugly, is O(N) and may actually be faster than using a RegEx. private string[] tokenize(string input) { string[] tokens = input.Split(' '); List output = new List (); for (int i = 0; i < tokens.Length; i++) { if (tokens[i].StartsWith("\"")) { string temp = tokens[i]; int k = 0; for (k = i + 1; k < tokens.Length; k++) { if (tokens[k].EndsWith("\"")) { temp += " " + tokens[k]; break; } else { temp += " " + tokens[k]; } } output.Add(temp); i = k + 1; } else { output.Add(tokens[i]); } } return output.ToArray(); }
The computer term for what you're doing is lexical analysis; read that for a good summary of this common task. Based on your example, I'm guessing that you want whitespace to separate your words, but stuff in quotation marks should be treated as a "word" without the quotes. The simplest way to do this is to define a word as a regular expression: ([^"^\s]+)\s*|"([^"]+)"\s* This expression states that a "word" is either (1) non-quote, non-whitespace text surrounded by whitespace, or (2) non-quote text surrounded by quotes (followed by some whitespace). Note the use of capturing parentheses to highlight the desired text. Armed with that regex, your algorithm is simple: search your text for the next "word" as defined by the capturing parentheses, and return it. Repeat that until you run out of "words". Here's the simplest bit of working code I could come up with, in VB.NET. Note that we have to check both groups for data since there are two sets of capturing parentheses. Dim token As String Dim r As Regex = New Regex("([^""^\s]+)\s*|""([^""]+)""\s*") Dim m As Match = r.Match("this is a ""test string""") While m.Success token = m.Groups(1).ToString If token.length = 0 And m.Groups.Count > 1 Then token = m.Groups(2).ToString End If m = m.NextMatch End While Note 1: Will's answer, above, is the same idea as this one. Hopefully this answer explains the details behind the scene a little better:)
Best way to parse Space Separated Text I have string like this /c SomeText\MoreText "Some Text\More Text\Lol" SomeText I want to tokenize it, however I can't just split on the spaces. I've come up with somewhat ugly parser that works, but I'm wondering if anyone has a more elegant design. This is in C# btw. EDIT: My ugly version, while ugly, is O(N) and may actually be faster than using a RegEx. private string[] tokenize(string input) { string[] tokens = input.Split(' '); List output = new List (); for (int i = 0; i < tokens.Length; i++) { if (tokens[i].StartsWith("\"")) { string temp = tokens[i]; int k = 0; for (k = i + 1; k < tokens.Length; k++) { if (tokens[k].EndsWith("\"")) { temp += " " + tokens[k]; break; } else { temp += " " + tokens[k]; } } output.Add(temp); i = k + 1; } else { output.Add(tokens[i]); } } return output.ToArray(); }
TITLE: Best way to parse Space Separated Text QUESTION: I have string like this /c SomeText\MoreText "Some Text\More Text\Lol" SomeText I want to tokenize it, however I can't just split on the spaces. I've come up with somewhat ugly parser that works, but I'm wondering if anyone has a more elegant design. This is in C# btw. EDIT: My ugly version, while ugly, is O(N) and may actually be faster than using a RegEx. private string[] tokenize(string input) { string[] tokens = input.Split(' '); List output = new List (); for (int i = 0; i < tokens.Length; i++) { if (tokens[i].StartsWith("\"")) { string temp = tokens[i]; int k = 0; for (k = i + 1; k < tokens.Length; k++) { if (tokens[k].EndsWith("\"")) { temp += " " + tokens[k]; break; } else { temp += " " + tokens[k]; } } output.Add(temp); i = k + 1; } else { output.Add(tokens[i]); } } return output.ToArray(); } ANSWER: The computer term for what you're doing is lexical analysis; read that for a good summary of this common task. Based on your example, I'm guessing that you want whitespace to separate your words, but stuff in quotation marks should be treated as a "word" without the quotes. The simplest way to do this is to define a word as a regular expression: ([^"^\s]+)\s*|"([^"]+)"\s* This expression states that a "word" is either (1) non-quote, non-whitespace text surrounded by whitespace, or (2) non-quote text surrounded by quotes (followed by some whitespace). Note the use of capturing parentheses to highlight the desired text. Armed with that regex, your algorithm is simple: search your text for the next "word" as defined by the capturing parentheses, and return it. Repeat that until you run out of "words". Here's the simplest bit of working code I could come up with, in VB.NET. Note that we have to check both groups for data since there are two sets of capturing parentheses. Dim token As String Dim r As Regex = New Regex("([^""^\s]+)\s*|""([^""]+)""\s*") Dim m As Match = r.Match("this is a ""test string""") While m.Success token = m.Groups(1).ToString If token.length = 0 And m.Groups.Count > 1 Then token = m.Groups(2).ToString End If m = m.NextMatch End While Note 1: Will's answer, above, is the same idea as this one. Hopefully this answer explains the details behind the scene a little better:)
[ "c#", "string", "tokenize" ]
7
16
11,168
6
0
2008-09-10T18:00:12.143000
2008-09-10T18:20:11.923000
54,867
54,873
What is the difference between old style and new style classes in Python?
What is the difference between old style and new style classes in Python? When should I use one or the other?
From New-style and classic classes: Up to Python 2.1, old-style classes were the only flavour available to the user. The concept of (old-style) class is unrelated to the concept of type: if x is an instance of an old-style class, then x.__class__ designates the class of x, but type(x) is always. This reflects the fact that all old-style instances, independently of their class, are implemented with a single built-in type, called instance. New-style classes were introduced in Python 2.2 to unify the concepts of class and type. A new-style class is simply a user-defined type, no more, no less. If x is an instance of a new-style class, then type(x) is typically the same as x.__class__ (although this is not guaranteed – a new-style class instance is permitted to override the value returned for x.__class__ ). The major motivation for introducing new-style classes is to provide a unified object model with a full meta-model. It also has a number of immediate benefits, like the ability to subclass most built-in types, or the introduction of "descriptors", which enable computed properties. For compatibility reasons, classes are still old-style by default. New-style classes are created by specifying another new-style class (i.e. a type) as a parent class, or the "top-level type" object if no other parent is needed. The behaviour of new-style classes differs from that of old-style classes in a number of important details in addition to what type returns. Some of these changes are fundamental to the new object model, like the way special methods are invoked. Others are "fixes" that could not be implemented before for compatibility concerns, like the method resolution order in case of multiple inheritance. Python 3 only has new-style classes. No matter if you subclass from object or not, classes are new-style in Python 3.
What is the difference between old style and new style classes in Python? What is the difference between old style and new style classes in Python? When should I use one or the other?
TITLE: What is the difference between old style and new style classes in Python? QUESTION: What is the difference between old style and new style classes in Python? When should I use one or the other? ANSWER: From New-style and classic classes: Up to Python 2.1, old-style classes were the only flavour available to the user. The concept of (old-style) class is unrelated to the concept of type: if x is an instance of an old-style class, then x.__class__ designates the class of x, but type(x) is always. This reflects the fact that all old-style instances, independently of their class, are implemented with a single built-in type, called instance. New-style classes were introduced in Python 2.2 to unify the concepts of class and type. A new-style class is simply a user-defined type, no more, no less. If x is an instance of a new-style class, then type(x) is typically the same as x.__class__ (although this is not guaranteed – a new-style class instance is permitted to override the value returned for x.__class__ ). The major motivation for introducing new-style classes is to provide a unified object model with a full meta-model. It also has a number of immediate benefits, like the ability to subclass most built-in types, or the introduction of "descriptors", which enable computed properties. For compatibility reasons, classes are still old-style by default. New-style classes are created by specifying another new-style class (i.e. a type) as a parent class, or the "top-level type" object if no other parent is needed. The behaviour of new-style classes differs from that of old-style classes in a number of important details in addition to what type returns. Some of these changes are fundamental to the new object model, like the way special methods are invoked. Others are "fixes" that could not be implemented before for compatibility concerns, like the method resolution order in case of multiple inheritance. Python 3 only has new-style classes. No matter if you subclass from object or not, classes are new-style in Python 3.
[ "python", "class", "oop", "types", "new-style-class" ]
1,129
624
273,172
8
0
2008-09-10T18:01:27.163000
2008-09-10T18:02:43.743000
54,877
54,970
How to use JQuery "after" selector
I can't seem to figure out a good way to do this, but it seems like it should be simple. I have an element that I want to append a div to. Then I have another element that I want to clone and shove into that intermediate div. Here's what I was hoping to do: $("#somediv > ul").after(" ").append($("#someotherdiv").clone()); This seems to be close, but not quite there. The problem with this is that the "append" seems to be operating on the original #somediv > ul selector. This sort of makes sense, but it's not what I wanted. How can I most efficiently select that intermediate div that I added with the after and put my #someotherdiv into it?
Go the other way around and use insertAfter(). $(" ").append($("#someotherdiv").clone()).insertAfter("#somediv > ul") Try to add your generated DOM nodes to the document only after finishing your work. Once the nodes are added to the displayed document, the browser starts listening to any change to refresh the view. Doing all the work before adding the nodes to the displayed document does improve browser performance.
How to use JQuery "after" selector I can't seem to figure out a good way to do this, but it seems like it should be simple. I have an element that I want to append a div to. Then I have another element that I want to clone and shove into that intermediate div. Here's what I was hoping to do: $("#somediv > ul").after(" ").append($("#someotherdiv").clone()); This seems to be close, but not quite there. The problem with this is that the "append" seems to be operating on the original #somediv > ul selector. This sort of makes sense, but it's not what I wanted. How can I most efficiently select that intermediate div that I added with the after and put my #someotherdiv into it?
TITLE: How to use JQuery "after" selector QUESTION: I can't seem to figure out a good way to do this, but it seems like it should be simple. I have an element that I want to append a div to. Then I have another element that I want to clone and shove into that intermediate div. Here's what I was hoping to do: $("#somediv > ul").after(" ").append($("#someotherdiv").clone()); This seems to be close, but not quite there. The problem with this is that the "append" seems to be operating on the original #somediv > ul selector. This sort of makes sense, but it's not what I wanted. How can I most efficiently select that intermediate div that I added with the after and put my #someotherdiv into it? ANSWER: Go the other way around and use insertAfter(). $(" ").append($("#someotherdiv").clone()).insertAfter("#somediv > ul") Try to add your generated DOM nodes to the document only after finishing your work. Once the nodes are added to the displayed document, the browser starts listening to any change to refresh the view. Doing all the work before adding the nodes to the displayed document does improve browser performance.
[ "jquery", "dom", "css-selectors" ]
8
9
6,624
3
0
2008-09-10T18:03:12.777000
2008-09-10T18:37:39.010000
54,889
54,907
As a ASP.NET programmer, do I need to be concerned about email injection attacks?
There are lots of PHP articles about the subject so is this a PHP only problem. I am sending emails using System.Net.Mail after some regular expression checks of course. Similar to http://weblogs.asp.net/scottgu/archive/2005/12/10/432854.aspx
the PHP email injection attack works because of a weakness in the PHP Mail() function. As a.net developer you need not worry.
As a ASP.NET programmer, do I need to be concerned about email injection attacks? There are lots of PHP articles about the subject so is this a PHP only problem. I am sending emails using System.Net.Mail after some regular expression checks of course. Similar to http://weblogs.asp.net/scottgu/archive/2005/12/10/432854.aspx
TITLE: As a ASP.NET programmer, do I need to be concerned about email injection attacks? QUESTION: There are lots of PHP articles about the subject so is this a PHP only problem. I am sending emails using System.Net.Mail after some regular expression checks of course. Similar to http://weblogs.asp.net/scottgu/archive/2005/12/10/432854.aspx ANSWER: the PHP email injection attack works because of a weakness in the PHP Mail() function. As a.net developer you need not worry.
[ "asp.net", "security", "email" ]
7
6
333
3
0
2008-09-10T18:05:54.500000
2008-09-10T18:11:07.843000
54,926
54,927
Make a JPanel not draw its background (Transparent)
Is it possible, in Java, to make a JPanel skip drawing its background thus being transparent except for the components on it?
setOpaque(false) It'll pass off painting the background to its parent, which may draw its own background. You can do a screen capture and then use that to paint the background of the panel.
Make a JPanel not draw its background (Transparent) Is it possible, in Java, to make a JPanel skip drawing its background thus being transparent except for the components on it?
TITLE: Make a JPanel not draw its background (Transparent) QUESTION: Is it possible, in Java, to make a JPanel skip drawing its background thus being transparent except for the components on it? ANSWER: setOpaque(false) It'll pass off painting the background to its parent, which may draw its own background. You can do a screen capture and then use that to paint the background of the panel.
[ "java", "user-interface" ]
26
38
47,722
5
0
2008-09-10T18:18:28.060000
2008-09-10T18:19:21.130000
54,943
54,947
How do I know when to use state based testing versus mock testing?
Which scenarios, areas of an application/system, etc. are best suited for 'classic' state based testing versus using mock objects?
You should be using mocks for dependencies. I don't think that its an either-or; Usually you will create mocks for dependencies, set expectations (whether it is calls or state) on them, then run the unit under test. Then you would check its state, and verify the expectations on the mocks, afterwards.
How do I know when to use state based testing versus mock testing? Which scenarios, areas of an application/system, etc. are best suited for 'classic' state based testing versus using mock objects?
TITLE: How do I know when to use state based testing versus mock testing? QUESTION: Which scenarios, areas of an application/system, etc. are best suited for 'classic' state based testing versus using mock objects? ANSWER: You should be using mocks for dependencies. I don't think that its an either-or; Usually you will create mocks for dependencies, set expectations (whether it is calls or state) on them, then run the unit under test. Then you would check its state, and verify the expectations on the mocks, afterwards.
[ "unit-testing" ]
4
3
1,277
6
0
2008-09-10T18:27:38.897000
2008-09-10T18:29:10.450000
54,952
55,307
Java, UTF-8, and Windows console
We try to use Java and UTF-8 on Windows. The application writes logs on the console, and we would like to use UTF-8 for the logs as our application has internationalized logs. It is possible to configure the JVM so it generates UTF-8, using -Dfile.encoding=UTF-8 as arguments to the JVM. It works fine, but the output on a Windows console is garbled. Then, we can set the code page of the console to 65001 ( chcp 65001 ), but in this case, the.bat files do not work. This means that when we try to launch our application through our script (named start.bat), absolutely nothing happens. The command simple returns: C:\Application> chcp 65001 Activated code page: 65001 C:\Application> start.bat C:\Application> But without chcp 65001, there is no problem, and the application can be launched. Any hints about that?
Try chcp 65001 && start.bat The chcp command changes the code page, and 65001 is the Win32 code page identifier for UTF-8 under Windows 7 and up. A code page, or character encoding, specifies how to convert a Unicode code point to a sequence of bytes or back again.
Java, UTF-8, and Windows console We try to use Java and UTF-8 on Windows. The application writes logs on the console, and we would like to use UTF-8 for the logs as our application has internationalized logs. It is possible to configure the JVM so it generates UTF-8, using -Dfile.encoding=UTF-8 as arguments to the JVM. It works fine, but the output on a Windows console is garbled. Then, we can set the code page of the console to 65001 ( chcp 65001 ), but in this case, the.bat files do not work. This means that when we try to launch our application through our script (named start.bat), absolutely nothing happens. The command simple returns: C:\Application> chcp 65001 Activated code page: 65001 C:\Application> start.bat C:\Application> But without chcp 65001, there is no problem, and the application can be launched. Any hints about that?
TITLE: Java, UTF-8, and Windows console QUESTION: We try to use Java and UTF-8 on Windows. The application writes logs on the console, and we would like to use UTF-8 for the logs as our application has internationalized logs. It is possible to configure the JVM so it generates UTF-8, using -Dfile.encoding=UTF-8 as arguments to the JVM. It works fine, but the output on a Windows console is garbled. Then, we can set the code page of the console to 65001 ( chcp 65001 ), but in this case, the.bat files do not work. This means that when we try to launch our application through our script (named start.bat), absolutely nothing happens. The command simple returns: C:\Application> chcp 65001 Activated code page: 65001 C:\Application> start.bat C:\Application> But without chcp 65001, there is no problem, and the application can be launched. Any hints about that? ANSWER: Try chcp 65001 && start.bat The chcp command changes the code page, and 65001 is the Win32 code page identifier for UTF-8 under Windows 7 and up. A code page, or character encoding, specifies how to convert a Unicode code point to a sequence of bytes or back again.
[ "java", "windows", "utf-8", "console" ]
15
11
23,623
5
0
2008-09-10T18:30:55.253000
2008-09-10T20:55:48.570000
54,953
55,008
Count the number of nodes that match a given XPath expression in XmlSpy
I am using XmlSpy to analyze an xml file, and I want to get a quick count of the number of nodes that match a given xpath. I know how to enter the XPathand get the list of nodes, but I am really just interested in the count. Is it possible to get this? I'm using XmlSpy Professional Edition version 2007 sp2, if it matters.
I just figureed it out. I just needed to put count() around my xpath, like so: count(//my/node)
Count the number of nodes that match a given XPath expression in XmlSpy I am using XmlSpy to analyze an xml file, and I want to get a quick count of the number of nodes that match a given xpath. I know how to enter the XPathand get the list of nodes, but I am really just interested in the count. Is it possible to get this? I'm using XmlSpy Professional Edition version 2007 sp2, if it matters.
TITLE: Count the number of nodes that match a given XPath expression in XmlSpy QUESTION: I am using XmlSpy to analyze an xml file, and I want to get a quick count of the number of nodes that match a given xpath. I know how to enter the XPathand get the list of nodes, but I am really just interested in the count. Is it possible to get this? I'm using XmlSpy Professional Edition version 2007 sp2, if it matters. ANSWER: I just figureed it out. I just needed to put count() around my xpath, like so: count(//my/node)
[ "xml", "xpath", "xmlspy" ]
5
9
9,068
1
0
2008-09-10T18:31:37.870000
2008-09-10T18:50:34.580000
54,955
54,968
What is a prepared statement?
I see a bunch of lines in the.log files in the postgres pg_log directory that say something like: ERROR: prepared statement "pdo_pgsql_stmt_09e097f4" does not exist What are prepared statements, and what kinds of things can cause these error messages to be displayed?
From the documentation: A prepared statement is a server-side object that can be used to optimize performance. When the PREPARE statement is executed, the specifie statement is parsed, rewritten, and planned. When an EXECUTE command is subsequently issued, the prepared statement need only be executed. Thus, the parsing, rewriting, and planning stages are only performed once, instead of every time the statement is executed. Searching the net, I found that the "pdo_pgsql_stmt" command is from some sort of PHP-connection to your database. Maybe this link can help you find a suiteable mailing-list or issue-tracker that you can send your error-messages to? EDIT: I think I found your bug here: http://bugs.php.net/bug.php?id=37870
What is a prepared statement? I see a bunch of lines in the.log files in the postgres pg_log directory that say something like: ERROR: prepared statement "pdo_pgsql_stmt_09e097f4" does not exist What are prepared statements, and what kinds of things can cause these error messages to be displayed?
TITLE: What is a prepared statement? QUESTION: I see a bunch of lines in the.log files in the postgres pg_log directory that say something like: ERROR: prepared statement "pdo_pgsql_stmt_09e097f4" does not exist What are prepared statements, and what kinds of things can cause these error messages to be displayed? ANSWER: From the documentation: A prepared statement is a server-side object that can be used to optimize performance. When the PREPARE statement is executed, the specifie statement is parsed, rewritten, and planned. When an EXECUTE command is subsequently issued, the prepared statement need only be executed. Thus, the parsing, rewriting, and planning stages are only performed once, instead of every time the statement is executed. Searching the net, I found that the "pdo_pgsql_stmt" command is from some sort of PHP-connection to your database. Maybe this link can help you find a suiteable mailing-list or issue-tracker that you can send your error-messages to? EDIT: I think I found your bug here: http://bugs.php.net/bug.php?id=37870
[ "sql", "database", "postgresql", "prepared-statement" ]
3
4
1,847
1
0
2008-09-10T18:32:18.540000
2008-09-10T18:37:08.093000
54,966
55,021
Replacing Windows Explorer With Third Party Tool
How would I go about replacing Windows Explorer with a third party tool such as TotalCommander, explorer++, etc? I would like to have one of those load instead of win explorer when I type "C:\directoryName" into the run window. Is this possible?
From a comment on the first LifeHacker link, How to make x² your default folder application As part of the installation process, x² adds "open with xplorer2" in the context menu for filesystem folders. If you want to have this the default action (so that folders always open in x2 when you click on them) then make sure this is the default verb, either using Folder Options ("file folder" type) or editing the registry: [HKEY_CLASSES_ROOT\Directory\shell] @="open_x2" If you want some slightly different command line options, you can add any of the supported options by editing the following registry key: [HKEY_CLASSES_ROOT\Directory\shell\open\command] @="C:\Program files\zabkat\xplorer2\xplorer2_UC.exe" /T /1 "%1" Notes: Please check your installation folder first: Your installation path may be different. Secondly, your executable may be called xplorer2.exe, if it is the non-Unicode version. Note that "%1" is required (including the quotation marks), and is replaced by the folder path you are trying to open. The /T switch causes no tabs to be restored and the /1 switch puts x² in single pane mode. (You do not have to use these switches, but they make sense). (The above are from xplorer2 user manual)
Replacing Windows Explorer With Third Party Tool How would I go about replacing Windows Explorer with a third party tool such as TotalCommander, explorer++, etc? I would like to have one of those load instead of win explorer when I type "C:\directoryName" into the run window. Is this possible?
TITLE: Replacing Windows Explorer With Third Party Tool QUESTION: How would I go about replacing Windows Explorer with a third party tool such as TotalCommander, explorer++, etc? I would like to have one of those load instead of win explorer when I type "C:\directoryName" into the run window. Is this possible? ANSWER: From a comment on the first LifeHacker link, How to make x² your default folder application As part of the installation process, x² adds "open with xplorer2" in the context menu for filesystem folders. If you want to have this the default action (so that folders always open in x2 when you click on them) then make sure this is the default verb, either using Folder Options ("file folder" type) or editing the registry: [HKEY_CLASSES_ROOT\Directory\shell] @="open_x2" If you want some slightly different command line options, you can add any of the supported options by editing the following registry key: [HKEY_CLASSES_ROOT\Directory\shell\open\command] @="C:\Program files\zabkat\xplorer2\xplorer2_UC.exe" /T /1 "%1" Notes: Please check your installation folder first: Your installation path may be different. Secondly, your executable may be called xplorer2.exe, if it is the non-Unicode version. Note that "%1" is required (including the quotation marks), and is replaced by the folder path you are trying to open. The /T switch causes no tabs to be restored and the /1 switch puts x² in single pane mode. (You do not have to use these switches, but they make sense). (The above are from xplorer2 user manual)
[ "windows", "windows-vista", "file-management" ]
4
3
3,675
2
0
2008-09-10T18:35:47.330000
2008-09-10T18:53:47.833000
54,972
54,984
How to Prevent the "Please tell Microsoft about this problem" Dialog Boxes
We have an error that we can't seem to find and don't have the need/resources to try and track it down. What we do need to do is just keep the freaking "Please tell Microsoft about this problem" dialog boxes from cluttering up the server. It is from an MS-Access error (we think) but I can't find where Access is installed (I don't think it is); there is no MS Office directory on any of the drives. If we could just stop the dialog boxes from appearing that would be great. Thanks. Spec: Window Server 2003 sp2
From http://www.codeproject.com/KB/exception/UnhandledExceptionClass.aspx: If you also want to disable the Windows “Send Error Report” dialog on your computer, right-click on the “My Computer” icon, select “Properties”, switch to the “Advanced” tab, and click on the “Error Reporting” button. In the Options dialog, select the “Disable error reporting” radio button: Compare also http://www.codeproject.com/KB/exception/ExceptionHandling.aspx for general.NET Exception Handling sanity.
How to Prevent the "Please tell Microsoft about this problem" Dialog Boxes We have an error that we can't seem to find and don't have the need/resources to try and track it down. What we do need to do is just keep the freaking "Please tell Microsoft about this problem" dialog boxes from cluttering up the server. It is from an MS-Access error (we think) but I can't find where Access is installed (I don't think it is); there is no MS Office directory on any of the drives. If we could just stop the dialog boxes from appearing that would be great. Thanks. Spec: Window Server 2003 sp2
TITLE: How to Prevent the "Please tell Microsoft about this problem" Dialog Boxes QUESTION: We have an error that we can't seem to find and don't have the need/resources to try and track it down. What we do need to do is just keep the freaking "Please tell Microsoft about this problem" dialog boxes from cluttering up the server. It is from an MS-Access error (we think) but I can't find where Access is installed (I don't think it is); there is no MS Office directory on any of the drives. If we could just stop the dialog boxes from appearing that would be great. Thanks. Spec: Window Server 2003 sp2 ANSWER: From http://www.codeproject.com/KB/exception/UnhandledExceptionClass.aspx: If you also want to disable the Windows “Send Error Report” dialog on your computer, right-click on the “My Computer” icon, select “Properties”, switch to the “Advanced” tab, and click on the “Error Reporting” button. In the Options dialog, select the “Disable error reporting” radio button: Compare also http://www.codeproject.com/KB/exception/ExceptionHandling.aspx for general.NET Exception Handling sanity.
[ "ms-access", "dialog", "windows-server-2003" ]
3
8
10,842
7
0
2008-09-10T18:38:07.077000
2008-09-10T18:43:04.803000
54,978
55,032
Adopting standard libraries
My team has a command parsing library for console apps. Each team around us has their own as well. There isn't anything in the BCL so I suppose this is natural. I've looked at the the module in Mono, which seems solid, and the one on CodePlex looks fine as well. There are probably others out there that will work (and I would love to hear your suggestions). The real question is: how do I get my team, and others around us, to commit to just using one?
Well to be honest, you can't make everyone settle on one solution. You can suggest a solution and point out it's benefits, but eventually the advantages would have to be greater than the inertia that they have built up with their present library. To make them settle on one library you would need to go up the management change until you get to the person that manages all the groups involved. Convince that person why everyone should use one library then let it filter back down. Now that I have said that, why does it matter? Does your team routinely have to work on code from the other teams? Are the other teams using libraries that cause problems for your code? Is this standardization purely for the sake of standardization or is there some specific problem that not standardizing causes?
Adopting standard libraries My team has a command parsing library for console apps. Each team around us has their own as well. There isn't anything in the BCL so I suppose this is natural. I've looked at the the module in Mono, which seems solid, and the one on CodePlex looks fine as well. There are probably others out there that will work (and I would love to hear your suggestions). The real question is: how do I get my team, and others around us, to commit to just using one?
TITLE: Adopting standard libraries QUESTION: My team has a command parsing library for console apps. Each team around us has their own as well. There isn't anything in the BCL so I suppose this is natural. I've looked at the the module in Mono, which seems solid, and the one on CodePlex looks fine as well. There are probably others out there that will work (and I would love to hear your suggestions). The real question is: how do I get my team, and others around us, to commit to just using one? ANSWER: Well to be honest, you can't make everyone settle on one solution. You can suggest a solution and point out it's benefits, but eventually the advantages would have to be greater than the inertia that they have built up with their present library. To make them settle on one library you would need to go up the management change until you get to the person that manages all the groups involved. Convince that person why everyone should use one library then let it filter back down. Now that I have said that, why does it matter? Does your team routinely have to work on code from the other teams? Are the other teams using libraries that cause problems for your code? Is this standardization purely for the sake of standardization or is there some specific problem that not standardizing causes?
[ ".net" ]
2
2
183
6
0
2008-09-10T18:40:33.233000
2008-09-10T18:56:52.820000
54,980
55,046
How do prepared statements work?
I'm writing some DB routines and I'm using prepared statements. My environment is PDO with PHP5. I understand prepared statements primarily provide a performance benefit, as well as some auxiliary bonuses such as not having to manually SQL-escape input data. My question is about the performance part. I have two implementations of a getPrice function below that takes a product id and returns its price. getPrice_A reuses the same PDOStatement object across subsequent calls within the same script execution. Is this necessary or recommended? If so, is there any way to avoid duplicating this extra code across every single get*() in every single model? getPrice_B creates a new PDOStatement object on every call. Will the DBMS recognize this statement has already been prepared and still be able to skip some work? In other words, does this implementation properly take advantage of the performance benefits of prepared statements? Having written all this out and read it over, I imagine getPrice_B is fine and getPrice_A is providing a negligible benefit on top of that, which may or may not be worth the extra complication. I'd still like to hear for sure from someone more knowledgable though. Assume that $pdo is a valid, connected PDO object in the examples below. prepare('SELECT price FROM products WHERE id =?'); } $stmt->execute(array($id)); return $stmt->fetchColumn(0); } static function &getPrice_B($id) { $stmt = $pdo->prepare('SELECT price FROM products WHERE id =?'); $stmt->execute(array($id)); return $stmt->fetchColumn(0); } } // example usage: $price = Product::getPrice(4982); echo "Product 4982 costs $price\n";
From what I understand, prepared statements will reuse the generated SQL plan if it is the same statement, so the database will see the same prepared statement and not have to do the work to figure out how to query the database. I would say the extra work of saving the prepared statement in Product::getPrice_A is not typically very helpful, more because it can obscure the code rather than an issue of performance. When dealing with performance, I feel it's always best to focus on code clarity and then performance when you have real statistics that indicate a problem. I would say "yes, the extra work is unnecessary" (regardless of if it really boosts performance). Also, I am not a very big DB expert, but the performance gain of prepared statements is something I heard from others, and it is at the database level, not the code level (so if the code is actually invoking a parameterized statement on the actual DB, then the DB can do these execution plan caching... though depending on the database, you may get the benefit even without the parameterized statement). Anyways, if you are really worried about (and seeing) database performance issues, you should look into a caching solution... of which I would highly recommend memcached. With such a solution, you can cache your query results and not even hit the database for things you access frequently.
How do prepared statements work? I'm writing some DB routines and I'm using prepared statements. My environment is PDO with PHP5. I understand prepared statements primarily provide a performance benefit, as well as some auxiliary bonuses such as not having to manually SQL-escape input data. My question is about the performance part. I have two implementations of a getPrice function below that takes a product id and returns its price. getPrice_A reuses the same PDOStatement object across subsequent calls within the same script execution. Is this necessary or recommended? If so, is there any way to avoid duplicating this extra code across every single get*() in every single model? getPrice_B creates a new PDOStatement object on every call. Will the DBMS recognize this statement has already been prepared and still be able to skip some work? In other words, does this implementation properly take advantage of the performance benefits of prepared statements? Having written all this out and read it over, I imagine getPrice_B is fine and getPrice_A is providing a negligible benefit on top of that, which may or may not be worth the extra complication. I'd still like to hear for sure from someone more knowledgable though. Assume that $pdo is a valid, connected PDO object in the examples below. prepare('SELECT price FROM products WHERE id =?'); } $stmt->execute(array($id)); return $stmt->fetchColumn(0); } static function &getPrice_B($id) { $stmt = $pdo->prepare('SELECT price FROM products WHERE id =?'); $stmt->execute(array($id)); return $stmt->fetchColumn(0); } } // example usage: $price = Product::getPrice(4982); echo "Product 4982 costs $price\n";
TITLE: How do prepared statements work? QUESTION: I'm writing some DB routines and I'm using prepared statements. My environment is PDO with PHP5. I understand prepared statements primarily provide a performance benefit, as well as some auxiliary bonuses such as not having to manually SQL-escape input data. My question is about the performance part. I have two implementations of a getPrice function below that takes a product id and returns its price. getPrice_A reuses the same PDOStatement object across subsequent calls within the same script execution. Is this necessary or recommended? If so, is there any way to avoid duplicating this extra code across every single get*() in every single model? getPrice_B creates a new PDOStatement object on every call. Will the DBMS recognize this statement has already been prepared and still be able to skip some work? In other words, does this implementation properly take advantage of the performance benefits of prepared statements? Having written all this out and read it over, I imagine getPrice_B is fine and getPrice_A is providing a negligible benefit on top of that, which may or may not be worth the extra complication. I'd still like to hear for sure from someone more knowledgable though. Assume that $pdo is a valid, connected PDO object in the examples below. prepare('SELECT price FROM products WHERE id =?'); } $stmt->execute(array($id)); return $stmt->fetchColumn(0); } static function &getPrice_B($id) { $stmt = $pdo->prepare('SELECT price FROM products WHERE id =?'); $stmt->execute(array($id)); return $stmt->fetchColumn(0); } } // example usage: $price = Product::getPrice(4982); echo "Product 4982 costs $price\n"; ANSWER: From what I understand, prepared statements will reuse the generated SQL plan if it is the same statement, so the database will see the same prepared statement and not have to do the work to figure out how to query the database. I would say the extra work of saving the prepared statement in Product::getPrice_A is not typically very helpful, more because it can obscure the code rather than an issue of performance. When dealing with performance, I feel it's always best to focus on code clarity and then performance when you have real statistics that indicate a problem. I would say "yes, the extra work is unnecessary" (regardless of if it really boosts performance). Also, I am not a very big DB expert, but the performance gain of prepared statements is something I heard from others, and it is at the database level, not the code level (so if the code is actually invoking a parameterized statement on the actual DB, then the DB can do these execution plan caching... though depending on the database, you may get the benefit even without the parameterized statement). Anyways, if you are really worried about (and seeing) database performance issues, you should look into a caching solution... of which I would highly recommend memcached. With such a solution, you can cache your query results and not even hit the database for things you access frequently.
[ "php", "sql", "pdo" ]
5
3
2,049
1
0
2008-09-10T18:41:19.393000
2008-09-10T19:02:42.663000
54,989
55,212
Change windows hostname from command line
Is it possible to change the hostname in Windows 2003 from the command line with out-of-the-box tools?
The netdom.exe command line program can be used. This is available from the Windows XP Support Tools or Server 2003 Support Tools (both on the installation CD). Usage guidelines here
Change windows hostname from command line Is it possible to change the hostname in Windows 2003 from the command line with out-of-the-box tools?
TITLE: Change windows hostname from command line QUESTION: Is it possible to change the hostname in Windows 2003 from the command line with out-of-the-box tools? ANSWER: The netdom.exe command line program can be used. This is available from the Windows XP Support Tools or Server 2003 Support Tools (both on the installation CD). Usage guidelines here
[ "windows", "command-line" ]
35
1
201,294
8
0
2008-09-10T18:45:04.097000
2008-09-10T20:15:41.193000
54,991
55,447
Generating Random Passwords
When a user on our site loses his password and heads off to the Lost Password page we need to give him a new temporary password. I don't really mind how random this is, or if it matches all the "needed" strong password rules, all I want to do is give them a password that they can change later. The application is a Web application written in C#. so I was thinking of being mean and going for the easy route of using part of a Guid. i.e. Guid.NewGuid().ToString("d").Substring(1,8) Suggesstions? thoughts?
There's always System.Web.Security.Membership.GeneratePassword(int length, int numberOfNonAlphanumericCharacters ).
Generating Random Passwords When a user on our site loses his password and heads off to the Lost Password page we need to give him a new temporary password. I don't really mind how random this is, or if it matches all the "needed" strong password rules, all I want to do is give them a password that they can change later. The application is a Web application written in C#. so I was thinking of being mean and going for the easy route of using part of a Guid. i.e. Guid.NewGuid().ToString("d").Substring(1,8) Suggesstions? thoughts?
TITLE: Generating Random Passwords QUESTION: When a user on our site loses his password and heads off to the Lost Password page we need to give him a new temporary password. I don't really mind how random this is, or if it matches all the "needed" strong password rules, all I want to do is give them a password that they can change later. The application is a Web application written in C#. so I was thinking of being mean and going for the easy route of using part of a Guid. i.e. Guid.NewGuid().ToString("d").Substring(1,8) Suggesstions? thoughts? ANSWER: There's always System.Web.Security.Membership.GeneratePassword(int length, int numberOfNonAlphanumericCharacters ).
[ "c#", "passwords", "random" ]
288
666
337,267
35
0
2008-09-10T18:45:15.437000
2008-09-10T22:44:45.250000
54,998
62,220
How Scalable is SQLite?
I recently read this Question about SQLite vs MySQL and the answer pointed out that SQLite doesn't scale well and the official website sort-of confirms this, however. How scalable is SQLite and what are its upper most limits?
Yesterday I released a small site * to track your rep that used a shared SQLite database for all visitors. Unfortunately, even with the modest load that it put on my host it ran quite slowly. This is because the entire database was locked every time someone viewed the page because it contained updates/inserts. I soon switched to MySQL and while I haven't had much time to test it out, it seems much more scaleable than SQLite. I just remember slow page loads and occasionally getting a database locked error when trying to execute queries from the shell in sqlite. That said, I am running another site from SQLite just fine. The difference is that the site is static (i.e. I'm the only one that can change the database) and so it works just fine for concurrent reads. Moral of the story: only use SQLite for websites where updates to the database happen rarely (less often than every page loaded). edit: I just realized that I may not have been fair to SQLite - I didn't index any columns in the SQLite database when I was serving it from a web page. This partially caused the slowdown I was experiencing. However, the observation of database-locking stands - if you have particularly onerous updates, SQLite performance won't match MySQL or Postgres. another edit: Since I posted this almost 3 months ago I've had the opportunity to closely examine the scalability of SQLite, and with a few tricks it can be quite scalable. As I mentioned in my first edit, database indexes dramatically reduce query time, but this is more of a general observation about databases than it is about SQLite. However, there is another trick you can use to speed up SQLite: transactions. Whenever you have to do multiple database writes, put them inside a transaction. Instead of writing to (and locking) the file each and every time a write query is issued, the write will only happen once when the transaction completes. The site that I mention I released in the first paragraph has been switched back to SQLite, and it's running quite smoothly once I tuned my code in a few places. * the site is no longer available
How Scalable is SQLite? I recently read this Question about SQLite vs MySQL and the answer pointed out that SQLite doesn't scale well and the official website sort-of confirms this, however. How scalable is SQLite and what are its upper most limits?
TITLE: How Scalable is SQLite? QUESTION: I recently read this Question about SQLite vs MySQL and the answer pointed out that SQLite doesn't scale well and the official website sort-of confirms this, however. How scalable is SQLite and what are its upper most limits? ANSWER: Yesterday I released a small site * to track your rep that used a shared SQLite database for all visitors. Unfortunately, even with the modest load that it put on my host it ran quite slowly. This is because the entire database was locked every time someone viewed the page because it contained updates/inserts. I soon switched to MySQL and while I haven't had much time to test it out, it seems much more scaleable than SQLite. I just remember slow page loads and occasionally getting a database locked error when trying to execute queries from the shell in sqlite. That said, I am running another site from SQLite just fine. The difference is that the site is static (i.e. I'm the only one that can change the database) and so it works just fine for concurrent reads. Moral of the story: only use SQLite for websites where updates to the database happen rarely (less often than every page loaded). edit: I just realized that I may not have been fair to SQLite - I didn't index any columns in the SQLite database when I was serving it from a web page. This partially caused the slowdown I was experiencing. However, the observation of database-locking stands - if you have particularly onerous updates, SQLite performance won't match MySQL or Postgres. another edit: Since I posted this almost 3 months ago I've had the opportunity to closely examine the scalability of SQLite, and with a few tricks it can be quite scalable. As I mentioned in my first edit, database indexes dramatically reduce query time, but this is more of a general observation about databases than it is about SQLite. However, there is another trick you can use to speed up SQLite: transactions. Whenever you have to do multiple database writes, put them inside a transaction. Instead of writing to (and locking) the file each and every time a write query is issued, the write will only happen once when the transaction completes. The site that I mention I released in the first paragraph has been switched back to SQLite, and it's running quite smoothly once I tuned my code in a few places. * the site is no longer available
[ "sqlite", "scalability" ]
189
442
55,828
9
0
2008-09-10T18:47:58.067000
2008-09-15T11:42:11.557000
55,010
55,581
What's a clean/simple way to ensure the security of a page?
Supposing you have a form that collects and submits sensitive information and you want to ensure it is never accessed via insecure (non-HTTPS) means, how might you best go about enforcing that policy?
I think the most bullet-proof solution is to keep the code inside your SSL document root only. This will ensure that you (or another developer in the future) can't accidentally link to a non-secure version of the form. If you have the form on both HTTP and HTTPS, you might not even notice if the wrong one gets used inadvertently. If this isn't doable, then I would take at least two precautions. Do the Apache URL rewriting, and have a check in your code to make sure the session is encrypted - check the HTTP headers.
What's a clean/simple way to ensure the security of a page? Supposing you have a form that collects and submits sensitive information and you want to ensure it is never accessed via insecure (non-HTTPS) means, how might you best go about enforcing that policy?
TITLE: What's a clean/simple way to ensure the security of a page? QUESTION: Supposing you have a form that collects and submits sensitive information and you want to ensure it is never accessed via insecure (non-HTTPS) means, how might you best go about enforcing that policy? ANSWER: I think the most bullet-proof solution is to keep the code inside your SSL document root only. This will ensure that you (or another developer in the future) can't accidentally link to a non-secure version of the form. If you have the form on both HTTP and HTTPS, you might not even notice if the wrong one gets used inadvertently. If this isn't doable, then I would take at least two precautions. Do the Apache URL rewriting, and have a check in your code to make sure the session is encrypted - check the HTTP headers.
[ "security", "forms", "ssl", "https" ]
3
3
286
5
0
2008-09-10T18:50:47.903000
2008-09-11T00:54:28.823000
55,013
55,031
Should I always use the AndAlso and OrElse operators?
Is there ever a circumstance in which I would not want to use the AndAlso operator rather than the And operator? …or in which I would not want to use the OrElse operator rather than the Or operator?
From MSDN: Short-Circuiting Trade-Offs Short-circuiting can improve performance by not evaluating an expression that cannot alter the result of the logical operation. However, if that expression performs additional actions, short-circuiting skips those actions. For example, if the expression includes a call to a Function procedure, that procedure is not called if the expression is short-circuited, and any additional code contained in the Function does not run. If your program logic depends on any of that additional code, you should probably avoid short-circuiting operators.
Should I always use the AndAlso and OrElse operators? Is there ever a circumstance in which I would not want to use the AndAlso operator rather than the And operator? …or in which I would not want to use the OrElse operator rather than the Or operator?
TITLE: Should I always use the AndAlso and OrElse operators? QUESTION: Is there ever a circumstance in which I would not want to use the AndAlso operator rather than the And operator? …or in which I would not want to use the OrElse operator rather than the Or operator? ANSWER: From MSDN: Short-Circuiting Trade-Offs Short-circuiting can improve performance by not evaluating an expression that cannot alter the result of the logical operation. However, if that expression performs additional actions, short-circuiting skips those actions. For example, if the expression includes a call to a Function procedure, that procedure is not called if the expression is short-circuited, and any additional code contained in the Function does not run. If your program logic depends on any of that additional code, you should probably avoid short-circuiting operators.
[ ".net", "vb.net", "boolean-logic" ]
50
38
6,316
3
0
2008-09-10T18:51:52.487000
2008-09-10T18:56:39.870000
55,035
55,063
Application to Stress Test in a Windows .NET Application
I am developing a Windows.NET application (WinForms) and I need to simulate a stress test of the database and the application ( more than 100 conections). What tools do you recommend?
Tools like AutomatedQA TestComplete allow you to make a script which simulates a user controlling your application. Running multiple scripts at the same time could be your stress test.
Application to Stress Test in a Windows .NET Application I am developing a Windows.NET application (WinForms) and I need to simulate a stress test of the database and the application ( more than 100 conections). What tools do you recommend?
TITLE: Application to Stress Test in a Windows .NET Application QUESTION: I am developing a Windows.NET application (WinForms) and I need to simulate a stress test of the database and the application ( more than 100 conections). What tools do you recommend? ANSWER: Tools like AutomatedQA TestComplete allow you to make a script which simulates a user controlling your application. Running multiple scripts at the same time could be your stress test.
[ ".net", "stress-testing" ]
6
0
2,928
1
0
2008-09-10T18:57:41.163000
2008-09-10T19:12:10.753000
55,039
55,048
Rehsarper 4.0 - Renaming a class does not rename the file
Rehsarper 4.0 - Renaming a class does not rename the file… I probably set something on accident in the options, but I can't find it. Any ideas?
When I do a rename in Resharper there's a checkbox below the textbox where you type the new name that says "Synchronise file name with class name". Check that and the file is renamed too. Be sure you're using Resharper's rename (right-click/Refactor/Rename) rather than Visual Studio's (right-click/Rename), as the latter definitely doesn't rename the file.
Rehsarper 4.0 - Renaming a class does not rename the file Rehsarper 4.0 - Renaming a class does not rename the file… I probably set something on accident in the options, but I can't find it. Any ideas?
TITLE: Rehsarper 4.0 - Renaming a class does not rename the file QUESTION: Rehsarper 4.0 - Renaming a class does not rename the file… I probably set something on accident in the options, but I can't find it. Any ideas? ANSWER: When I do a rename in Resharper there's a checkbox below the textbox where you type the new name that says "Synchronise file name with class name". Check that and the file is renamed too. Be sure you're using Resharper's rename (right-click/Refactor/Rename) rather than Visual Studio's (right-click/Rename), as the latter definitely doesn't rename the file.
[ "visual-studio", "resharper" ]
1
5
636
2
0
2008-09-10T18:59:56.680000
2008-09-10T19:03:32.240000
55,042
55,053
How can I program a simple chat bot AI?
I want to build a bot that asks someone a few simple questions and branches based on the answer. I realize parsing meaning from the human responses will be challenging, but how do you setup the program to deal with the "state" of the conversation? It will be a one-to-one conversation between a human and the bot.
You probably want to look into Markov Chains as the basics for the bot AI. I wrote something a long time ago (the code to which I'm not proud of at all, and needs some mods to run on Python > 1.5) that may be a useful starting place for you: http://sourceforge.net/projects/benzo/ EDIT: Here's a minimal example in Python of a Markov Chain that accepts input from stdin and outputs text based on the probabilities of words succeeding one another in the input. It's optimized for IRC-style chat logs, but running any decent-sized text through it should demonstrate the concepts: import random, sys NONWORD = "\n" STARTKEY = NONWORD, NONWORD MAXGEN=1000 class MarkovChainer(object): def __init__(self): self.state = dict() def input(self, input): word1, word2 = STARTKEY for word3 in input.split(): self.state.setdefault((word1, word2), list()).append(word3) word1, word2 = word2, word3 self.state.setdefault((word1, word2), list()).append(NONWORD) def output(self): output = list() word1, word2 = STARTKEY for i in range(MAXGEN): word3 = random.choice(self.state[(word1,word2)]) if word3 == NONWORD: break output.append(word3) word1, word2 = word2, word3 return " ".join(output) if __name__ == "__main__": c = MarkovChainer() c.input(sys.stdin.read()) print c.output() It's pretty easy from here to plug in persistence and an IRC library and have the basis of the type of bot you're talking about.
How can I program a simple chat bot AI? I want to build a bot that asks someone a few simple questions and branches based on the answer. I realize parsing meaning from the human responses will be challenging, but how do you setup the program to deal with the "state" of the conversation? It will be a one-to-one conversation between a human and the bot.
TITLE: How can I program a simple chat bot AI? QUESTION: I want to build a bot that asks someone a few simple questions and branches based on the answer. I realize parsing meaning from the human responses will be challenging, but how do you setup the program to deal with the "state" of the conversation? It will be a one-to-one conversation between a human and the bot. ANSWER: You probably want to look into Markov Chains as the basics for the bot AI. I wrote something a long time ago (the code to which I'm not proud of at all, and needs some mods to run on Python > 1.5) that may be a useful starting place for you: http://sourceforge.net/projects/benzo/ EDIT: Here's a minimal example in Python of a Markov Chain that accepts input from stdin and outputs text based on the probabilities of words succeeding one another in the input. It's optimized for IRC-style chat logs, but running any decent-sized text through it should demonstrate the concepts: import random, sys NONWORD = "\n" STARTKEY = NONWORD, NONWORD MAXGEN=1000 class MarkovChainer(object): def __init__(self): self.state = dict() def input(self, input): word1, word2 = STARTKEY for word3 in input.split(): self.state.setdefault((word1, word2), list()).append(word3) word1, word2 = word2, word3 self.state.setdefault((word1, word2), list()).append(NONWORD) def output(self): output = list() word1, word2 = STARTKEY for i in range(MAXGEN): word3 = random.choice(self.state[(word1,word2)]) if word3 == NONWORD: break output.append(word3) word1, word2 = word2, word3 return " ".join(output) if __name__ == "__main__": c = MarkovChainer() c.input(sys.stdin.read()) print c.output() It's pretty easy from here to plug in persistence and an IRC library and have the basis of the type of bot you're talking about.
[ "language-agnostic", "artificial-intelligence", "chat", "chatbot" ]
33
24
39,858
11
0
2008-09-10T19:00:40.500000
2008-09-10T19:04:47.463000
55,054
55,057
How to capitalize the first letter of each word in a string in SQL Server
What’s the best way to capitalize the first letter of each word in a string in SQL Server.
From http://www.sql-server-helper.com/functions/initcap.aspx CREATE FUNCTION [dbo].[InitCap] ( @InputString varchar(4000) ) RETURNS VARCHAR(4000) AS BEGIN DECLARE @Index INT DECLARE @Char CHAR(1) DECLARE @PrevChar CHAR(1) DECLARE @OutputString VARCHAR(255) SET @OutputString = LOWER(@InputString) SET @Index = 1 WHILE @Index <= LEN(@InputString) BEGIN SET @Char = SUBSTRING(@InputString, @Index, 1) SET @PrevChar = CASE WHEN @Index = 1 THEN ' ' ELSE SUBSTRING(@InputString, @Index - 1, 1) END IF @PrevChar IN (' ', ';', ':', '!', '?', ',', '.', '_', '-', '/', '&', '''', '(') BEGIN IF @PrevChar!= '''' OR UPPER(@Char)!= 'S' SET @OutputString = STUFF(@OutputString, @Index, 1, UPPER(@Char)) END SET @Index = @Index + 1 END RETURN @OutputString END GO There is a simpler/smaller one here (but doesn't work if any row doesn't have spaces, "Invalid length parameter passed to the RIGHT function."): http://www.devx.com/tips/Tip/17608
How to capitalize the first letter of each word in a string in SQL Server What’s the best way to capitalize the first letter of each word in a string in SQL Server.
TITLE: How to capitalize the first letter of each word in a string in SQL Server QUESTION: What’s the best way to capitalize the first letter of each word in a string in SQL Server. ANSWER: From http://www.sql-server-helper.com/functions/initcap.aspx CREATE FUNCTION [dbo].[InitCap] ( @InputString varchar(4000) ) RETURNS VARCHAR(4000) AS BEGIN DECLARE @Index INT DECLARE @Char CHAR(1) DECLARE @PrevChar CHAR(1) DECLARE @OutputString VARCHAR(255) SET @OutputString = LOWER(@InputString) SET @Index = 1 WHILE @Index <= LEN(@InputString) BEGIN SET @Char = SUBSTRING(@InputString, @Index, 1) SET @PrevChar = CASE WHEN @Index = 1 THEN ' ' ELSE SUBSTRING(@InputString, @Index - 1, 1) END IF @PrevChar IN (' ', ';', ':', '!', '?', ',', '.', '_', '-', '/', '&', '''', '(') BEGIN IF @PrevChar!= '''' OR UPPER(@Char)!= 'S' SET @OutputString = STUFF(@OutputString, @Index, 1, UPPER(@Char)) END SET @Index = @Index + 1 END RETURN @OutputString END GO There is a simpler/smaller one here (but doesn't work if any row doesn't have spaces, "Invalid length parameter passed to the RIGHT function."): http://www.devx.com/tips/Tip/17608
[ "sql", "sql-server", "string" ]
66
92
114,918
15
0
2008-09-10T19:07:08.363000
2008-09-10T19:09:23.647000
55,056
840,596
What's the best Django search app?
I'm building a Django project that needs search functionality, and until there's a django.contrib.search, I have to choose a search app. So, which is the best? By "best" I mean... easy to install / set up has a Django- or at least Python-friendly API can perform reasonably complex searches Here are some apps I've heard of, please suggest others if you know of any: djangosearch django-sphinx I'd also like to avoid using a third-party search engine (like Google SiteSearch), because some of the data I'd like to index is for site members only and should not be public.
Check out Haystack Search - a new model based search abstraction layer that currently supports Xapian, Solr and Whoosh. Looks like it's well supported and documented.
What's the best Django search app? I'm building a Django project that needs search functionality, and until there's a django.contrib.search, I have to choose a search app. So, which is the best? By "best" I mean... easy to install / set up has a Django- or at least Python-friendly API can perform reasonably complex searches Here are some apps I've heard of, please suggest others if you know of any: djangosearch django-sphinx I'd also like to avoid using a third-party search engine (like Google SiteSearch), because some of the data I'd like to index is for site members only and should not be public.
TITLE: What's the best Django search app? QUESTION: I'm building a Django project that needs search functionality, and until there's a django.contrib.search, I have to choose a search app. So, which is the best? By "best" I mean... easy to install / set up has a Django- or at least Python-friendly API can perform reasonably complex searches Here are some apps I've heard of, please suggest others if you know of any: djangosearch django-sphinx I'd also like to avoid using a third-party search engine (like Google SiteSearch), because some of the data I'd like to index is for site members only and should not be public. ANSWER: Check out Haystack Search - a new model based search abstraction layer that currently supports Xapian, Solr and Whoosh. Looks like it's well supported and documented.
[ "python", "django", "search", "search-engine" ]
114
105
52,092
15
0
2008-09-10T19:09:14.600000
2009-05-08T16:10:42.847000
55,060
55,191
Php function argument error suppression, empty() isset() emulation
I'm pretty sure the answer to this question is no, but in case there's some PHP guru is it possible to write a function in a way where invalid arguments or non existent variables can be passed in and php will not error without the use of '@' Much like empty and isset do. You can pass in a variable you just made up and it won't error. ex: empty($someBogusVar); // no error myHappyFunction($someBogusVar); // Php warning / notice
Summing up, the proper answer is no, you shouldn't (see caveat below). There are workarounds already mentioned by many people in this thread, like using reference variables or isset() or empty() in conditions and suppressing notices in PHP configuration. That in addition to the obvious workaround, using @, which you don't want. Summarizing an interesting comment discussion with Gerry: Passing the variable by reference is indeed valid if you check for the value of the variable inside the function and handle undefined or null cases properly. Just don't use reference passing as a way of shutting PHP up (this is where my original shouldn't points to).
Php function argument error suppression, empty() isset() emulation I'm pretty sure the answer to this question is no, but in case there's some PHP guru is it possible to write a function in a way where invalid arguments or non existent variables can be passed in and php will not error without the use of '@' Much like empty and isset do. You can pass in a variable you just made up and it won't error. ex: empty($someBogusVar); // no error myHappyFunction($someBogusVar); // Php warning / notice
TITLE: Php function argument error suppression, empty() isset() emulation QUESTION: I'm pretty sure the answer to this question is no, but in case there's some PHP guru is it possible to write a function in a way where invalid arguments or non existent variables can be passed in and php will not error without the use of '@' Much like empty and isset do. You can pass in a variable you just made up and it won't error. ex: empty($someBogusVar); // no error myHappyFunction($someBogusVar); // Php warning / notice ANSWER: Summing up, the proper answer is no, you shouldn't (see caveat below). There are workarounds already mentioned by many people in this thread, like using reference variables or isset() or empty() in conditions and suppressing notices in PHP configuration. That in addition to the obvious workaround, using @, which you don't want. Summarizing an interesting comment discussion with Gerry: Passing the variable by reference is indeed valid if you check for the value of the variable inside the function and handle undefined or null cases properly. Just don't use reference passing as a way of shutting PHP up (this is where my original shouldn't points to).
[ "php", "error-handling", "error-suppression" ]
10
8
5,442
14
0
2008-09-10T19:09:47.577000
2008-09-10T20:09:21.817000
55,061
55,388
How to jump to a class definition in CodeRush
Just downloaded the CodeRush trial version and I can't easily find the one feature that I really wanted. I would like to be able to start typing a class name and to jump to its definition, sort of like the quick navigator but I want it to search in closed files within my solution as well as open ones. I know R# has that ability, I assume CodeRush does too.
1) Ctrl + Shift + Q (this will bring up the Quick Nav) 2) Start typing the name of the Type, Variable, etc. 3) Hit Enter to select when the target shows in the top of the list If the scope is not already set to "Solution" (you can tell via the drop-down on the right of the Quick Nav), you can hit Alt + Shift + S to set and it will save the state.
How to jump to a class definition in CodeRush Just downloaded the CodeRush trial version and I can't easily find the one feature that I really wanted. I would like to be able to start typing a class name and to jump to its definition, sort of like the quick navigator but I want it to search in closed files within my solution as well as open ones. I know R# has that ability, I assume CodeRush does too.
TITLE: How to jump to a class definition in CodeRush QUESTION: Just downloaded the CodeRush trial version and I can't easily find the one feature that I really wanted. I would like to be able to start typing a class name and to jump to its definition, sort of like the quick navigator but I want it to search in closed files within my solution as well as open ones. I know R# has that ability, I assume CodeRush does too. ANSWER: 1) Ctrl + Shift + Q (this will bring up the Quick Nav) 2) Start typing the name of the Type, Variable, etc. 3) Hit Enter to select when the target shows in the top of the list If the scope is not already set to "Solution" (you can tell via the drop-down on the right of the Quick Nav), you can hit Alt + Shift + S to set and it will save the state.
[ "keyboard-shortcuts", "coderush" ]
2
2
847
2
0
2008-09-10T19:10:04.223000
2008-09-10T21:48:31.067000
55,083
55,177
Display a PDF in WPF Application
Any ideas how to display a PDF file in a WPF Windows Application? I am using the following code to run the browser but the Browser.Navigate method does not do anything! WebBrowser browser = new WebBrowser(); browser.Navigate("http://www.google.com"); this.AddChild(browser); // this is the System.Windows.Window
Oops. this is for a winforms app. Not for WPF. I will post this anyway. try this private AxAcroPDFLib.AxAcroPDF axAcroPDF1; this.axAcroPDF1 = new AxAcroPDFLib.AxAcroPDF(); this.axAcroPDF1.Dock = System.Windows.Forms.DockStyle.Fill; this.axAcroPDF1.Enabled = true; this.axAcroPDF1.Name = "axAcroPDF1"; this.axAcroPDF1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axAcroPDF1.OcxState"))); axAcroPDF1.LoadFile(DownloadedFullFileName); axAcroPDF1.Visible = true;
Display a PDF in WPF Application Any ideas how to display a PDF file in a WPF Windows Application? I am using the following code to run the browser but the Browser.Navigate method does not do anything! WebBrowser browser = new WebBrowser(); browser.Navigate("http://www.google.com"); this.AddChild(browser); // this is the System.Windows.Window
TITLE: Display a PDF in WPF Application QUESTION: Any ideas how to display a PDF file in a WPF Windows Application? I am using the following code to run the browser but the Browser.Navigate method does not do anything! WebBrowser browser = new WebBrowser(); browser.Navigate("http://www.google.com"); this.AddChild(browser); // this is the System.Windows.Window ANSWER: Oops. this is for a winforms app. Not for WPF. I will post this anyway. try this private AxAcroPDFLib.AxAcroPDF axAcroPDF1; this.axAcroPDF1 = new AxAcroPDFLib.AxAcroPDF(); this.axAcroPDF1.Dock = System.Windows.Forms.DockStyle.Fill; this.axAcroPDF1.Enabled = true; this.axAcroPDF1.Name = "axAcroPDF1"; this.axAcroPDF1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axAcroPDF1.OcxState"))); axAcroPDF1.LoadFile(DownloadedFullFileName); axAcroPDF1.Visible = true;
[ "wpf", "pdf" ]
28
9
107,759
9
0
2008-09-10T19:19:52.997000
2008-09-10T20:04:59.020000
55,093
55,149
How to deal with arrays (declared on the stack) in C++?
I have a class to parse a matrix that keeps the result in an array member: class Parser {... double matrix_[4][4]; }; The user of this class needs to call an API function (as in, a function I have no control over, so I can't just change its interface to make things work more easily) that looks like this: void api_func(const double matrix[4][4]); The only way I have come up with for the caller to pass the array result to the function is by making the member public: void myfunc() { Parser parser;... api_func(parser.matrix_); } Is this the only way to do things? I'm astounded by how inflexible multidimensional arrays declared like this are. I thought matrix_ would essentially be the same as a double** and I could cast (safely) between the two. As it turns out, I can't even find an unsafe way to cast between the things. Say I add an accessor to the Parser class: void* Parser::getMatrix() { return (void*)matrix_; } This will compile, but I can't use it, because there doesn't seem to be a way to cast back to the weirdo array type: // A smorgasbord of syntax errors... api_func((double[][])parser.getMatrix()); api_func((double[4][4])parser.getMatrix()); api_func((double**)parser.getMatrix()); // cast works but it's to the wrong type The error is: error C2440: 'type cast': cannot convert from 'void *' to 'const double [4][4]'...with an intriguing addendum: There are no conversions to array types, although there are conversions to references or pointers to arrays I can't determine how to cast to a reference or pointer to array either, albeit that it probably won't help me here. To be sure, at this point the matter is purely academic, as the void* casts are hardly cleaner than a single class member left public!
Here's a nice, clean way: class Parser { public: typedef double matrix[4][4]; //... const matrix& getMatrix() const { return matrix_; } //... private: matrix matrix_; }; Now you're working with a descriptive type name rather than an array, but since it's a typedef the compiler will still allow passing it to the unchangeable API function that takes the base type.
How to deal with arrays (declared on the stack) in C++? I have a class to parse a matrix that keeps the result in an array member: class Parser {... double matrix_[4][4]; }; The user of this class needs to call an API function (as in, a function I have no control over, so I can't just change its interface to make things work more easily) that looks like this: void api_func(const double matrix[4][4]); The only way I have come up with for the caller to pass the array result to the function is by making the member public: void myfunc() { Parser parser;... api_func(parser.matrix_); } Is this the only way to do things? I'm astounded by how inflexible multidimensional arrays declared like this are. I thought matrix_ would essentially be the same as a double** and I could cast (safely) between the two. As it turns out, I can't even find an unsafe way to cast between the things. Say I add an accessor to the Parser class: void* Parser::getMatrix() { return (void*)matrix_; } This will compile, but I can't use it, because there doesn't seem to be a way to cast back to the weirdo array type: // A smorgasbord of syntax errors... api_func((double[][])parser.getMatrix()); api_func((double[4][4])parser.getMatrix()); api_func((double**)parser.getMatrix()); // cast works but it's to the wrong type The error is: error C2440: 'type cast': cannot convert from 'void *' to 'const double [4][4]'...with an intriguing addendum: There are no conversions to array types, although there are conversions to references or pointers to arrays I can't determine how to cast to a reference or pointer to array either, albeit that it probably won't help me here. To be sure, at this point the matter is purely academic, as the void* casts are hardly cleaner than a single class member left public!
TITLE: How to deal with arrays (declared on the stack) in C++? QUESTION: I have a class to parse a matrix that keeps the result in an array member: class Parser {... double matrix_[4][4]; }; The user of this class needs to call an API function (as in, a function I have no control over, so I can't just change its interface to make things work more easily) that looks like this: void api_func(const double matrix[4][4]); The only way I have come up with for the caller to pass the array result to the function is by making the member public: void myfunc() { Parser parser;... api_func(parser.matrix_); } Is this the only way to do things? I'm astounded by how inflexible multidimensional arrays declared like this are. I thought matrix_ would essentially be the same as a double** and I could cast (safely) between the two. As it turns out, I can't even find an unsafe way to cast between the things. Say I add an accessor to the Parser class: void* Parser::getMatrix() { return (void*)matrix_; } This will compile, but I can't use it, because there doesn't seem to be a way to cast back to the weirdo array type: // A smorgasbord of syntax errors... api_func((double[][])parser.getMatrix()); api_func((double[4][4])parser.getMatrix()); api_func((double**)parser.getMatrix()); // cast works but it's to the wrong type The error is: error C2440: 'type cast': cannot convert from 'void *' to 'const double [4][4]'...with an intriguing addendum: There are no conversions to array types, although there are conversions to references or pointers to arrays I can't determine how to cast to a reference or pointer to array either, albeit that it probably won't help me here. To be sure, at this point the matter is purely academic, as the void* casts are hardly cleaner than a single class member left public! ANSWER: Here's a nice, clean way: class Parser { public: typedef double matrix[4][4]; //... const matrix& getMatrix() const { return matrix_; } //... private: matrix matrix_; }; Now you're working with a descriptive type name rather than an array, but since it's a typedef the compiler will still allow passing it to the unchangeable API function that takes the base type.
[ "c++", "arrays" ]
15
16
2,522
5
0
2008-09-10T19:27:04.430000
2008-09-10T19:53:16.443000
55,099
55,309
Find checkout history for SVN working folder
We have an intranet site backed by SVN, such that the site is a checkout out copy of the repository (working folder used only by IIS). Something on the site has been causing problems today, and I want to know how to find out what was checked out to that working folder in the last 48 hours. Update: If there's an option I need to turn on to enable this in the future, what is it? Also, as a corollary question, if I have to use the file creation time, how can I do that quickly in a recursive manner for a large folder? If I have to check creation times, then this question will be helpful to the solution as well.
All the code in the web folder should be backed by SVN commits, shouldn't it? If this is the case you should easily be able to track the problem down just by looking through your SVN logs at the last few changes that got committed. svn info will tell you which revision the working copy currently is at, so you know where to start looking Once you track down the commit with the bug in it, you can use svn blame to find the person that did it, and explain to them what they overlooked and how they caused the bug. Then you can make them buy everyone lunch for screwing up the site. If you have locally modified/added any files which aren't in SVN, then svn stat and svn diff will show you what those changes are, so you can figure out if they are causing the problem too. You should then revert those changes so your working copy is a clean checkout, or commit the changes into the repository. There's nothing worse than trying to track down a bug in your code only to find out 3 hours later that the bug is not actually in any of your code, but in some stupid local tweak someone made in the working copy that never got committed:-(
Find checkout history for SVN working folder We have an intranet site backed by SVN, such that the site is a checkout out copy of the repository (working folder used only by IIS). Something on the site has been causing problems today, and I want to know how to find out what was checked out to that working folder in the last 48 hours. Update: If there's an option I need to turn on to enable this in the future, what is it? Also, as a corollary question, if I have to use the file creation time, how can I do that quickly in a recursive manner for a large folder? If I have to check creation times, then this question will be helpful to the solution as well.
TITLE: Find checkout history for SVN working folder QUESTION: We have an intranet site backed by SVN, such that the site is a checkout out copy of the repository (working folder used only by IIS). Something on the site has been causing problems today, and I want to know how to find out what was checked out to that working folder in the last 48 hours. Update: If there's an option I need to turn on to enable this in the future, what is it? Also, as a corollary question, if I have to use the file creation time, how can I do that quickly in a recursive manner for a large folder? If I have to check creation times, then this question will be helpful to the solution as well. ANSWER: All the code in the web folder should be backed by SVN commits, shouldn't it? If this is the case you should easily be able to track the problem down just by looking through your SVN logs at the last few changes that got committed. svn info will tell you which revision the working copy currently is at, so you know where to start looking Once you track down the commit with the bug in it, you can use svn blame to find the person that did it, and explain to them what they overlooked and how they caused the bug. Then you can make them buy everyone lunch for screwing up the site. If you have locally modified/added any files which aren't in SVN, then svn stat and svn diff will show you what those changes are, so you can figure out if they are causing the problem too. You should then revert those changes so your working copy is a clean checkout, or commit the changes into the repository. There's nothing worse than trying to track down a bug in your code only to find out 3 hours later that the bug is not actually in any of your code, but in some stupid local tweak someone made in the working copy that never got committed:-(
[ "svn", "tortoisesvn" ]
4
2
7,533
4
0
2008-09-10T19:32:35.510000
2008-09-10T20:56:39.240000
55,101
55,254
How can I return an anonymous type from a method?
I have a Linq query that I want to call from multiple places: var myData = from a in db.MyTable where a.MyValue == "A" select new { a.Key, a.MyValue }; How can I create a method, put this code in it, and then call it? public??? GetSomeData() { // my Linq query }
IQueryable and IEnumerable both work. But you want to use a type specific version, IQueryable < T > or IEnumerable < T >. So you'll want to create a type to keep the data. var myData = from a in db.MyTable where a.MyValue == "A" select new MyType { Key = a.Key, Value = a.MyValue };
How can I return an anonymous type from a method? I have a Linq query that I want to call from multiple places: var myData = from a in db.MyTable where a.MyValue == "A" select new { a.Key, a.MyValue }; How can I create a method, put this code in it, and then call it? public??? GetSomeData() { // my Linq query }
TITLE: How can I return an anonymous type from a method? QUESTION: I have a Linq query that I want to call from multiple places: var myData = from a in db.MyTable where a.MyValue == "A" select new { a.Key, a.MyValue }; How can I create a method, put this code in it, and then call it? public??? GetSomeData() { // my Linq query } ANSWER: IQueryable and IEnumerable both work. But you want to use a type specific version, IQueryable < T > or IEnumerable < T >. So you'll want to create a type to keep the data. var myData = from a in db.MyTable where a.MyValue == "A" select new MyType { Key = a.Key, Value = a.MyValue };
[ "c#", "linq", "data-structures", "parameter-passing" ]
13
10
9,048
4
0
2008-09-10T19:33:28.347000
2008-09-10T20:32:44.787000
55,113
55,117
How do I convert a .docx to html using asp.net?
Word 2007 saves its documents in.docx format which is really a zip file with a bunch of stuff in it including an xml file with the document. I want to be able to take a.docx file and drop it into a folder in my asp.net web app and have the code open the.docx file and render the (xml part of the) document as a web page. I've been searching the web for more information on this but so far haven't found much. My questions are: Would you (a) use XSLT to transform the XML to HTML, or (b) use xml manipulation libraries in.net (such as XDocument and XElement in 3.5) to convert to HTML or (c) other? Do you know of any open source libraries/projects that have done this that I could use as a starting point? Thanks!
Try this post? I don't know but might be what you are looking for.
How do I convert a .docx to html using asp.net? Word 2007 saves its documents in.docx format which is really a zip file with a bunch of stuff in it including an xml file with the document. I want to be able to take a.docx file and drop it into a folder in my asp.net web app and have the code open the.docx file and render the (xml part of the) document as a web page. I've been searching the web for more information on this but so far haven't found much. My questions are: Would you (a) use XSLT to transform the XML to HTML, or (b) use xml manipulation libraries in.net (such as XDocument and XElement in 3.5) to convert to HTML or (c) other? Do you know of any open source libraries/projects that have done this that I could use as a starting point? Thanks!
TITLE: How do I convert a .docx to html using asp.net? QUESTION: Word 2007 saves its documents in.docx format which is really a zip file with a bunch of stuff in it including an xml file with the document. I want to be able to take a.docx file and drop it into a folder in my asp.net web app and have the code open the.docx file and render the (xml part of the) document as a web page. I've been searching the web for more information on this but so far haven't found much. My questions are: Would you (a) use XSLT to transform the XML to HTML, or (b) use xml manipulation libraries in.net (such as XDocument and XElement in 3.5) to convert to HTML or (c) other? Do you know of any open source libraries/projects that have done this that I could use as a starting point? Thanks! ANSWER: Try this post? I don't know but might be what you are looking for.
[ "asp.net", "xml", "xslt", "openxml" ]
8
4
16,226
5
0
2008-09-10T19:36:39.447000
2008-09-10T19:37:40.100000
55,114
55,182
Where does RegexBuddy store its working data between uses?
Ok, so I'm an idiot. So I was working on a regex that took way to long to craft. After perfecting it, I upgraded my work machine with a blazing fast hard drive and realized that I never saved the regex anywhere and simply used RegexBuddy's autosave to store it. Dumb dumb dumb. I sent a copy of the regex to a coworker but now he can't find it (or the record of our communication). My best hope of finding the regex is to find it in RegexBuddy on the old hard drive. RegexBuddy automatically saves whatever you were working on each time you close it. I've done some preliminary searches to try to determine where it actually saves that working data but I'm having no success. This question is the result of my dumb behavior but I thought it was a good chance to finally ask a question here.
On my XP box, it was in the registry here: HKEY_CURRENT_USER\Software\JGsoft\RegexBuddy3\History There were two REG_BINARY keys called Action0 and Action1 that had hex data containing my two regexes from the history. The test data that I was testing the regex against was here: C:\Documents and Settings\ \Application Data\JGsoft\RegexBuddy 3
Where does RegexBuddy store its working data between uses? Ok, so I'm an idiot. So I was working on a regex that took way to long to craft. After perfecting it, I upgraded my work machine with a blazing fast hard drive and realized that I never saved the regex anywhere and simply used RegexBuddy's autosave to store it. Dumb dumb dumb. I sent a copy of the regex to a coworker but now he can't find it (or the record of our communication). My best hope of finding the regex is to find it in RegexBuddy on the old hard drive. RegexBuddy automatically saves whatever you were working on each time you close it. I've done some preliminary searches to try to determine where it actually saves that working data but I'm having no success. This question is the result of my dumb behavior but I thought it was a good chance to finally ask a question here.
TITLE: Where does RegexBuddy store its working data between uses? QUESTION: Ok, so I'm an idiot. So I was working on a regex that took way to long to craft. After perfecting it, I upgraded my work machine with a blazing fast hard drive and realized that I never saved the regex anywhere and simply used RegexBuddy's autosave to store it. Dumb dumb dumb. I sent a copy of the regex to a coworker but now he can't find it (or the record of our communication). My best hope of finding the regex is to find it in RegexBuddy on the old hard drive. RegexBuddy automatically saves whatever you were working on each time you close it. I've done some preliminary searches to try to determine where it actually saves that working data but I'm having no success. This question is the result of my dumb behavior but I thought it was a good chance to finally ask a question here. ANSWER: On my XP box, it was in the registry here: HKEY_CURRENT_USER\Software\JGsoft\RegexBuddy3\History There were two REG_BINARY keys called Action0 and Action1 that had hex data containing my two regexes from the history. The test data that I was testing the regex against was here: C:\Documents and Settings\ \Application Data\JGsoft\RegexBuddy 3
[ "regexbuddy" ]
6
9
791
2
0
2008-09-10T19:36:47.620000
2008-09-10T20:06:57.953000
55,140
327,907
Database engines Comparison - Windows Mobile
What are the different database options on Windows Mobile available? I have used CEDB and EDB for linear dataset needs. I have heard of SQL server 2005 Mobile edition. But what are the advantages over others (if there is any)
I've found both sqllite and codebase to be easy to implement and install. Easier (and more stable) than the Microsoft options, which seem to be in serious flux.
Database engines Comparison - Windows Mobile What are the different database options on Windows Mobile available? I have used CEDB and EDB for linear dataset needs. I have heard of SQL server 2005 Mobile edition. But what are the advantages over others (if there is any)
TITLE: Database engines Comparison - Windows Mobile QUESTION: What are the different database options on Windows Mobile available? I have used CEDB and EDB for linear dataset needs. I have heard of SQL server 2005 Mobile edition. But what are the advantages over others (if there is any) ANSWER: I've found both sqllite and codebase to be easy to implement and install. Easier (and more stable) than the Microsoft options, which seem to be in serious flux.
[ "sql-server", "windows-mobile", "pocketpc", "sql-server-mobile" ]
4
5
720
6
0
2008-09-10T19:51:03.157000
2008-11-29T19:37:33.767000
55,147
55,156
Embed a File Chooser in a UserControl / Form
I've inherited a desktop application which has a custom.NET file chooser that is embedded in a control, but it has some issues. I'd like to replace it with a non-custom File Chooser (like the OpenFileDialog ). However, for a variety of reasons it needs to be embedded in the parent control not a popup dialog. Is there a control I'm missing, or does MS only provide the popup dialog out of the box?
The.Net control is a thin wrapper for the common dialog built into windows, and that is a dialog. So there is no way to embed it as though it were a control.
Embed a File Chooser in a UserControl / Form I've inherited a desktop application which has a custom.NET file chooser that is embedded in a control, but it has some issues. I'd like to replace it with a non-custom File Chooser (like the OpenFileDialog ). However, for a variety of reasons it needs to be embedded in the parent control not a popup dialog. Is there a control I'm missing, or does MS only provide the popup dialog out of the box?
TITLE: Embed a File Chooser in a UserControl / Form QUESTION: I've inherited a desktop application which has a custom.NET file chooser that is embedded in a control, but it has some issues. I'd like to replace it with a non-custom File Chooser (like the OpenFileDialog ). However, for a variety of reasons it needs to be embedded in the parent control not a popup dialog. Is there a control I'm missing, or does MS only provide the popup dialog out of the box? ANSWER: The.Net control is a thin wrapper for the common dialog built into windows, and that is a dialog. So there is no way to embed it as though it were a control.
[ "c#", ".net", "winforms" ]
1
1
3,815
2
0
2008-09-10T19:52:21.983000
2008-09-10T19:55:50.227000
55,159
55,172
In SQL Server is it possible to get "id" of a record when Insert is executed?
In SQL Server 2005 I have an "id" field in a table that has the "Is Identity" property set to 'Yes'. So, when an Insert is executed on that table the "id" gets set automatically to the next incrementing integer. Is there an easy way when the Insert is executed to get what the "id" was set to without having to do a Select statement right after the Insert? duplicate of: Best way to get identity of inserted row?
In.Net at least, you can send multiple queries to the server in one go. I do this in my app: command.CommandText = "INSERT INTO [Employee] (Name) VALUES (@Name); SELECT SCOPE_IDENTITY()"; int id = (int)command.ExecuteScalar(); Works like a charm.
In SQL Server is it possible to get "id" of a record when Insert is executed? In SQL Server 2005 I have an "id" field in a table that has the "Is Identity" property set to 'Yes'. So, when an Insert is executed on that table the "id" gets set automatically to the next incrementing integer. Is there an easy way when the Insert is executed to get what the "id" was set to without having to do a Select statement right after the Insert? duplicate of: Best way to get identity of inserted row?
TITLE: In SQL Server is it possible to get "id" of a record when Insert is executed? QUESTION: In SQL Server 2005 I have an "id" field in a table that has the "Is Identity" property set to 'Yes'. So, when an Insert is executed on that table the "id" gets set automatically to the next incrementing integer. Is there an easy way when the Insert is executed to get what the "id" was set to without having to do a Select statement right after the Insert? duplicate of: Best way to get identity of inserted row? ANSWER: In.Net at least, you can send multiple queries to the server in one go. I do this in my app: command.CommandText = "INSERT INTO [Employee] (Name) VALUES (@Name); SELECT SCOPE_IDENTITY()"; int id = (int)command.ExecuteScalar(); Works like a charm.
[ "sql-server", "identity" ]
12
32
43,785
7
0
2008-09-10T19:56:54.470000
2008-09-10T20:02:45.407000
55,179
55,189
Why all the Linq To Entities Hate?
I've noticed that there seems to be quite a bit of hostility towards Linq To Entities particularly from the Alt.Net folks. I understand the resistance to more "drag and drop" programming, but from my understanding, Linq To Entities doesn't require it. We're currently using Linq to SQL, and we are using the DBML document to define it (once you get more than a dozen or so tables, the designer is pretty useless.) So why wouldn't the same approach work for Linq To Entities?
I don't think it's a hate for the idea of it per se. It's just that people don't like the implementation of it. http://efvote.wufoo.com/forms/ado-net-entity-framework-vote-of-no-confidence/
Why all the Linq To Entities Hate? I've noticed that there seems to be quite a bit of hostility towards Linq To Entities particularly from the Alt.Net folks. I understand the resistance to more "drag and drop" programming, but from my understanding, Linq To Entities doesn't require it. We're currently using Linq to SQL, and we are using the DBML document to define it (once you get more than a dozen or so tables, the designer is pretty useless.) So why wouldn't the same approach work for Linq To Entities?
TITLE: Why all the Linq To Entities Hate? QUESTION: I've noticed that there seems to be quite a bit of hostility towards Linq To Entities particularly from the Alt.Net folks. I understand the resistance to more "drag and drop" programming, but from my understanding, Linq To Entities doesn't require it. We're currently using Linq to SQL, and we are using the DBML document to define it (once you get more than a dozen or so tables, the designer is pretty useless.) So why wouldn't the same approach work for Linq To Entities? ANSWER: I don't think it's a hate for the idea of it per se. It's just that people don't like the implementation of it. http://efvote.wufoo.com/forms/ado-net-entity-framework-vote-of-no-confidence/
[ "linq-to-entities" ]
6
5
1,753
6
0
2008-09-10T20:05:02.983000
2008-09-10T20:09:11.287000
55,203
55,242
How do I insert text into a textbox after popping up another window to request information?
I have an asp.net web page written in C#. Using some javascript I popup another.aspx page which has a few controls that are filled in and from which I create a small snippet of text. When the user clicks OK on that dialog box I want to insert that piece of text into a textbox on the page that initial "popped up" the dialog/popup page. I'm guessing that this will involve javascript which is not a strong point of mine. How do I do this?
You will have to do something like: parent.opener.document.getElemenyById('ParentTextBox').value = "New Text";
How do I insert text into a textbox after popping up another window to request information? I have an asp.net web page written in C#. Using some javascript I popup another.aspx page which has a few controls that are filled in and from which I create a small snippet of text. When the user clicks OK on that dialog box I want to insert that piece of text into a textbox on the page that initial "popped up" the dialog/popup page. I'm guessing that this will involve javascript which is not a strong point of mine. How do I do this?
TITLE: How do I insert text into a textbox after popping up another window to request information? QUESTION: I have an asp.net web page written in C#. Using some javascript I popup another.aspx page which has a few controls that are filled in and from which I create a small snippet of text. When the user clicks OK on that dialog box I want to insert that piece of text into a textbox on the page that initial "popped up" the dialog/popup page. I'm guessing that this will involve javascript which is not a strong point of mine. How do I do this? ANSWER: You will have to do something like: parent.opener.document.getElemenyById('ParentTextBox').value = "New Text";
[ "c#", "asp.net", "javascript" ]
1
6
1,668
2
0
2008-09-10T20:14:01.667000
2008-09-10T20:27:05.783000
55,206
55,215
What is the operator precedence order in Visual Basic 6.0?
What is the operator precedence order in Visual Basic 6.0 (VB6)? In particular, for the logical operators.
Arithmetic Operation Precedence Order ^ - (unary negation) *, / \ Mod +, - (binary addition/subtraction) & Comparison Operation Precedence Order = <> < > <= >= Like, Is Logical Operation Precedence Order Not And Or Xor Eqv Imp Source: Sams Teach Yourself Visual Basic 6 in 24 Hours — Appendix A: Operator Precedence
What is the operator precedence order in Visual Basic 6.0? What is the operator precedence order in Visual Basic 6.0 (VB6)? In particular, for the logical operators.
TITLE: What is the operator precedence order in Visual Basic 6.0? QUESTION: What is the operator precedence order in Visual Basic 6.0 (VB6)? In particular, for the logical operators. ANSWER: Arithmetic Operation Precedence Order ^ - (unary negation) *, / \ Mod +, - (binary addition/subtraction) & Comparison Operation Precedence Order = <> < > <= >= Like, Is Logical Operation Precedence Order Not And Or Xor Eqv Imp Source: Sams Teach Yourself Visual Basic 6 in 24 Hours — Appendix A: Operator Precedence
[ "vb6", "operators", "operator-precedence" ]
17
18
13,646
3
0
2008-09-10T20:14:07.983000
2008-09-10T20:16:37.463000
55,218
55,324
Unique key generation
I looking for a way, specifically in PHP that I will be guaranteed to always get a unique key. I have done the following: strtolower(substr(crypt(time()), 0, 7)); But I have found that once in a while I end up with a duplicate key (rarely, but often enough). I have also thought of doing: strtolower(substr(crypt(uniqid(rand(), true)), 0, 7)); But according to the PHP website, uniqid() could, if uniqid() is called twice in the same microsecond, it could generate the same key. I'm thinking that the addition of rand() that it rarely would, but still possible. After the lines mentioned above I am also remove characters such as L and O so it's less confusing for the user. This maybe part of the cause for the duplicates, but still necessary. One option I have a thought of is creating a website that will generate the key, storing it in a database, ensuring it's completely unique. Any other thoughts? Are there any websites out there that already do this that have some kind of API or just return the key. I found http://userident.com but I'm not sure if the keys will be completely unique. This needs to run in the background without any user input.
There are only 3 ways to generate unique values, rather they be passwords, user IDs, etc.: Use an effective GUID generator - these are long and cannot be shrunk. If you only use part you FAIL. At least part of the number is sequentially generated off of a single sequence. You can add fluff or encoding to make it look less sequential. Advantage is they start short - disadvantage is they require a single source. The work around for the single source limitation is to have numbered sources, so you include the [source #] + [seq #] and then each source can generate its own sequence. Generate them via some other means and then check them against the single history of previously generated values. Any other method is not guaranteed. Keep in mind, fundamentally you are generating a binary number (it is a computer), but then you can encode it in Hexadecimal, Decimal, Base64, or a word list. Pick an encoding that fits your usage. Usually for user entered data you want some variation of Base32 (which you hinted at). Note about GUIDS: They gain their strength of uniqueness from their length and the method used to generate them. Anything less than 128-bits is not secure. Beyond random number generation there are characteristics that go into a GUID to make it more unique. Keep in mind they are only practically unique, not completely unique. It is possible, although practically impossible to have a duplicate. Updated Note about GUIDS: Since writing this I learned that many GUID generators use a cryptographically secure random number generator (difficult or impossible to predict the next number generated, and a not likely to repeat). There are actually 5 different UUID algorithms. Algorithm 4 is what Microsoft currently uses for the Windows GUID generation API. A GUID is Microsoft's implementation of the UUID standard. Update: If you want 7 to 16 characters then you need to use either method 2 or 3. Bottom line: Frankly there is no such thing as completely unique. Even if you went with a sequential generator you would eventually run out of storage using all the atoms in the universe, thus looping back on yourself and repeating. Your only hope would be the heat death of the universe before reaching that point. Even the best random number generator has a possibility of repeating equal to the total size of the random number you are generating. Take a quarter for example. It is a completely random bit generator, and its odds of repeating are 1 in 2. So it all comes down to your threshold of uniqueness. You can have 100% uniqueness in 8 digits for 1,099,511,627,776 numbers by using a sequence and then base32 encoding it. Any other method that does not involve checking against a list of past numbers only has odds equal to n/1,099,511,627,776 (where n=number of previous numbers generated) of not being unique.
Unique key generation I looking for a way, specifically in PHP that I will be guaranteed to always get a unique key. I have done the following: strtolower(substr(crypt(time()), 0, 7)); But I have found that once in a while I end up with a duplicate key (rarely, but often enough). I have also thought of doing: strtolower(substr(crypt(uniqid(rand(), true)), 0, 7)); But according to the PHP website, uniqid() could, if uniqid() is called twice in the same microsecond, it could generate the same key. I'm thinking that the addition of rand() that it rarely would, but still possible. After the lines mentioned above I am also remove characters such as L and O so it's less confusing for the user. This maybe part of the cause for the duplicates, but still necessary. One option I have a thought of is creating a website that will generate the key, storing it in a database, ensuring it's completely unique. Any other thoughts? Are there any websites out there that already do this that have some kind of API or just return the key. I found http://userident.com but I'm not sure if the keys will be completely unique. This needs to run in the background without any user input.
TITLE: Unique key generation QUESTION: I looking for a way, specifically in PHP that I will be guaranteed to always get a unique key. I have done the following: strtolower(substr(crypt(time()), 0, 7)); But I have found that once in a while I end up with a duplicate key (rarely, but often enough). I have also thought of doing: strtolower(substr(crypt(uniqid(rand(), true)), 0, 7)); But according to the PHP website, uniqid() could, if uniqid() is called twice in the same microsecond, it could generate the same key. I'm thinking that the addition of rand() that it rarely would, but still possible. After the lines mentioned above I am also remove characters such as L and O so it's less confusing for the user. This maybe part of the cause for the duplicates, but still necessary. One option I have a thought of is creating a website that will generate the key, storing it in a database, ensuring it's completely unique. Any other thoughts? Are there any websites out there that already do this that have some kind of API or just return the key. I found http://userident.com but I'm not sure if the keys will be completely unique. This needs to run in the background without any user input. ANSWER: There are only 3 ways to generate unique values, rather they be passwords, user IDs, etc.: Use an effective GUID generator - these are long and cannot be shrunk. If you only use part you FAIL. At least part of the number is sequentially generated off of a single sequence. You can add fluff or encoding to make it look less sequential. Advantage is they start short - disadvantage is they require a single source. The work around for the single source limitation is to have numbered sources, so you include the [source #] + [seq #] and then each source can generate its own sequence. Generate them via some other means and then check them against the single history of previously generated values. Any other method is not guaranteed. Keep in mind, fundamentally you are generating a binary number (it is a computer), but then you can encode it in Hexadecimal, Decimal, Base64, or a word list. Pick an encoding that fits your usage. Usually for user entered data you want some variation of Base32 (which you hinted at). Note about GUIDS: They gain their strength of uniqueness from their length and the method used to generate them. Anything less than 128-bits is not secure. Beyond random number generation there are characteristics that go into a GUID to make it more unique. Keep in mind they are only practically unique, not completely unique. It is possible, although practically impossible to have a duplicate. Updated Note about GUIDS: Since writing this I learned that many GUID generators use a cryptographically secure random number generator (difficult or impossible to predict the next number generated, and a not likely to repeat). There are actually 5 different UUID algorithms. Algorithm 4 is what Microsoft currently uses for the Windows GUID generation API. A GUID is Microsoft's implementation of the UUID standard. Update: If you want 7 to 16 characters then you need to use either method 2 or 3. Bottom line: Frankly there is no such thing as completely unique. Even if you went with a sequential generator you would eventually run out of storage using all the atoms in the universe, thus looping back on yourself and repeating. Your only hope would be the heat death of the universe before reaching that point. Even the best random number generator has a possibility of repeating equal to the total size of the random number you are generating. Take a quarter for example. It is a completely random bit generator, and its odds of repeating are 1 in 2. So it all comes down to your threshold of uniqueness. You can have 100% uniqueness in 8 digits for 1,099,511,627,776 numbers by using a sequence and then base32 encoding it. Any other method that does not involve checking against a list of past numbers only has odds equal to n/1,099,511,627,776 (where n=number of previous numbers generated) of not being unique.
[ "php", "web-services", "security", "passwords" ]
12
19
16,715
13
0
2008-09-10T20:17:03
2008-09-10T21:06:12.557000
55,223
63,451
How do I implement a HTML cache for a PHP site?
What is the best way of implementing a cache for a PHP site? Obviously, there are some things that shouldn't be cached (for example search queries), but I want to find a good solution that will make sure that I avoid the 'digg effect'. I know there is WP-Cache for WordPress, but I'm writing a custom solution that isn't built on WP. I'm interested in either writing my own cache (if it's simple enough), or you could point me to a nice, light framework. I don't know much Apache though, so if it was a PHP framework then it would be a better fit. Thanks.
If a proxy cache is out of the question, and you're serving complete HTML files, you'll get the best performance by bypassing PHP altogether. Study how WP Super Cache works. Uncached pages are copied to a cache folder with similar URL structure as your site. On later requests, mod_rewrite notes the existence of the cached file and serves it instead. other RewriteCond directives are used to make sure commenters/logged in users see live PHP requests, but the majority of visitors will be served by Apache directly.
How do I implement a HTML cache for a PHP site? What is the best way of implementing a cache for a PHP site? Obviously, there are some things that shouldn't be cached (for example search queries), but I want to find a good solution that will make sure that I avoid the 'digg effect'. I know there is WP-Cache for WordPress, but I'm writing a custom solution that isn't built on WP. I'm interested in either writing my own cache (if it's simple enough), or you could point me to a nice, light framework. I don't know much Apache though, so if it was a PHP framework then it would be a better fit. Thanks.
TITLE: How do I implement a HTML cache for a PHP site? QUESTION: What is the best way of implementing a cache for a PHP site? Obviously, there are some things that shouldn't be cached (for example search queries), but I want to find a good solution that will make sure that I avoid the 'digg effect'. I know there is WP-Cache for WordPress, but I'm writing a custom solution that isn't built on WP. I'm interested in either writing my own cache (if it's simple enough), or you could point me to a nice, light framework. I don't know much Apache though, so if it was a PHP framework then it would be a better fit. Thanks. ANSWER: If a proxy cache is out of the question, and you're serving complete HTML files, you'll get the best performance by bypassing PHP altogether. Study how WP Super Cache works. Uncached pages are copied to a cache folder with similar URL structure as your site. On later requests, mod_rewrite notes the existence of the cached file and serves it instead. other RewriteCond directives are used to make sure commenters/logged in users see live PHP requests, but the majority of visitors will be served by Apache directly.
[ "php", "html", "caching" ]
12
7
8,266
8
0
2008-09-10T20:20:46.470000
2008-09-15T14:34:35.870000
55,256
55,289
Files on Windows and Contiguous Sectors
Is there a way to guarantee that a file on Windows (using the NTFS file system) will use contiguous sectors on the hard disk? In other words, the first chunk of the file will be stored in a certain sector, the second chunk of the file will be stored in the next sector, and so on. I should add that I want to be able to create this file programmatically, so I'd rather not just ask the user to defrag their harddrive after creating this file. If there is a way to programmatically defrag just the file that I create, then that would be OK too.
I would start here: http://technet.microsoft.com/en-us/sysinternals/bb897428.aspx and follow Mark's documentation of the defrag stuff: http://technet.microsoft.com/en-us/sysinternals/bb897427.aspx
Files on Windows and Contiguous Sectors Is there a way to guarantee that a file on Windows (using the NTFS file system) will use contiguous sectors on the hard disk? In other words, the first chunk of the file will be stored in a certain sector, the second chunk of the file will be stored in the next sector, and so on. I should add that I want to be able to create this file programmatically, so I'd rather not just ask the user to defrag their harddrive after creating this file. If there is a way to programmatically defrag just the file that I create, then that would be OK too.
TITLE: Files on Windows and Contiguous Sectors QUESTION: Is there a way to guarantee that a file on Windows (using the NTFS file system) will use contiguous sectors on the hard disk? In other words, the first chunk of the file will be stored in a certain sector, the second chunk of the file will be stored in the next sector, and so on. I should add that I want to be able to create this file programmatically, so I'd rather not just ask the user to defrag their harddrive after creating this file. If there is a way to programmatically defrag just the file that I create, then that would be OK too. ANSWER: I would start here: http://technet.microsoft.com/en-us/sysinternals/bb897428.aspx and follow Mark's documentation of the defrag stuff: http://technet.microsoft.com/en-us/sysinternals/bb897427.aspx
[ "windows", "filesystems" ]
4
7
1,079
3
0
2008-09-10T20:34:45.283000
2008-09-10T20:45:32.853000
55,273
111,222
What are the advantages of VistaDB
I have seen the references to VistaDB over the years and with tools like SQLite, Firebird, MS SQL et. al. I have never had a reason to consider it. What are the benefits of paying for VistaDB vs using another technology? Things I have thought of: 1. Compact Framework Support. SQLite+MSSQL support the CF. 2. Need migration path to a 'more robust' system. Firebird+MSSQL. 3. Need more advanced features such as triggers. Firebird+MSSQL
The VistaDB client runtime is free. The runtime will never "expire at 3am" as you put it. Only the developer tools are licensed in that manner. You need 1 license per developer, simple. We even offer a really inexpensive Lite version with no Visual Studio tools. Some other benefits 100% managed code - there are no interop or other unmanaged calls in the engine. This is a big deal to some, and others couldn't care less. No registry access required - Most other in proc databases require registry access to look for parent controls, or permissions. VistaDB only does what you tell it to do, and will even run in Medium Trust. XCopy deployment for runtime and your database (single file). You can xcopy you application, the runtime, and your database and run. Nothing to install or configure on the machine, no special privileges needed (we can run in Medium Trust or higher). Isolated storage - You can put your entire database into Isolated Storage and run it from there directly. This makes it very easy to build secure click once applications that write databases in a domain friendly way for corporate environments. There is no need to store the user data on a shared drive or worry about permission mapping. CLR Triggers / CLR Procs - You can write CLR Code and use them as Triggers or Stored Procs. We have just recently introduced changes to make it even easier to maintain a single CLR Assembly that can run in both VistaDB and SQL Server 2005/2008. T-SQL Procs - VistaDB T-SQL Procs are compatible with SQL Server 2005/2008. Any procedure that works in our engine will run in SQL Server. That does not mean anything that runs there will port to us. We are a subset of the functionality in SQL Server. But we are also the only way to run T-SQL Procs without SQL Server (SQL CE can't do it). I personally think one of the biggest features is the ability to upsize to SQL Server later. All of the VistaDB types, syntax, and CLR Procs, T-SQL procs, etc all will run on SQL Server. (You can't take everything from SQL Server down to VistaDB though, it is a subset) 32/64 bit Deployment - VistaDB is a single assembly deployment that runs both 32 and 64 bit without changes. SQL CE requires two different runtimes depending upon the OS, and cannot run under IIS at all. Access has no 64 bit runtime, and the most recent 32 bit runtime can only be deployed through MSI. The 32 bit version of Windows has the runtime, the 64 bit version does not. Relational Integrity - VistaDB also actually enforces your constraints and Foreign Keys. You can specific cascade update, and delete operations. The person who commented we are like SQLITE is wrong in this regard. They parse constraints, but do not enforce them. EDIT: They do have support for FK's now in SQLite. But they are not compiled in by default, and do not use the same syntax as SQL Server. Medium Trust - The ability to run on a medium trust web server is another feature that many will not care about, but it is a big deal. Many third party controls can't even run in Medium Trust. We can run the complete engine within Medium Trust because of our commitment to 100% managed code and least permission required. - Full disclosure - I am the owner of VistaDB so I may be biased.:)
What are the advantages of VistaDB I have seen the references to VistaDB over the years and with tools like SQLite, Firebird, MS SQL et. al. I have never had a reason to consider it. What are the benefits of paying for VistaDB vs using another technology? Things I have thought of: 1. Compact Framework Support. SQLite+MSSQL support the CF. 2. Need migration path to a 'more robust' system. Firebird+MSSQL. 3. Need more advanced features such as triggers. Firebird+MSSQL
TITLE: What are the advantages of VistaDB QUESTION: I have seen the references to VistaDB over the years and with tools like SQLite, Firebird, MS SQL et. al. I have never had a reason to consider it. What are the benefits of paying for VistaDB vs using another technology? Things I have thought of: 1. Compact Framework Support. SQLite+MSSQL support the CF. 2. Need migration path to a 'more robust' system. Firebird+MSSQL. 3. Need more advanced features such as triggers. Firebird+MSSQL ANSWER: The VistaDB client runtime is free. The runtime will never "expire at 3am" as you put it. Only the developer tools are licensed in that manner. You need 1 license per developer, simple. We even offer a really inexpensive Lite version with no Visual Studio tools. Some other benefits 100% managed code - there are no interop or other unmanaged calls in the engine. This is a big deal to some, and others couldn't care less. No registry access required - Most other in proc databases require registry access to look for parent controls, or permissions. VistaDB only does what you tell it to do, and will even run in Medium Trust. XCopy deployment for runtime and your database (single file). You can xcopy you application, the runtime, and your database and run. Nothing to install or configure on the machine, no special privileges needed (we can run in Medium Trust or higher). Isolated storage - You can put your entire database into Isolated Storage and run it from there directly. This makes it very easy to build secure click once applications that write databases in a domain friendly way for corporate environments. There is no need to store the user data on a shared drive or worry about permission mapping. CLR Triggers / CLR Procs - You can write CLR Code and use them as Triggers or Stored Procs. We have just recently introduced changes to make it even easier to maintain a single CLR Assembly that can run in both VistaDB and SQL Server 2005/2008. T-SQL Procs - VistaDB T-SQL Procs are compatible with SQL Server 2005/2008. Any procedure that works in our engine will run in SQL Server. That does not mean anything that runs there will port to us. We are a subset of the functionality in SQL Server. But we are also the only way to run T-SQL Procs without SQL Server (SQL CE can't do it). I personally think one of the biggest features is the ability to upsize to SQL Server later. All of the VistaDB types, syntax, and CLR Procs, T-SQL procs, etc all will run on SQL Server. (You can't take everything from SQL Server down to VistaDB though, it is a subset) 32/64 bit Deployment - VistaDB is a single assembly deployment that runs both 32 and 64 bit without changes. SQL CE requires two different runtimes depending upon the OS, and cannot run under IIS at all. Access has no 64 bit runtime, and the most recent 32 bit runtime can only be deployed through MSI. The 32 bit version of Windows has the runtime, the 64 bit version does not. Relational Integrity - VistaDB also actually enforces your constraints and Foreign Keys. You can specific cascade update, and delete operations. The person who commented we are like SQLITE is wrong in this regard. They parse constraints, but do not enforce them. EDIT: They do have support for FK's now in SQLite. But they are not compiled in by default, and do not use the same syntax as SQL Server. Medium Trust - The ability to run on a medium trust web server is another feature that many will not care about, but it is a big deal. Many third party controls can't even run in Medium Trust. We can run the complete engine within Medium Trust because of our commitment to 100% managed code and least permission required. - Full disclosure - I am the owner of VistaDB so I may be biased.:)
[ "sql-server", "database", "sqlite", "firebird", "vistadb" ]
12
26
9,289
4
0
2008-09-10T20:40:27.687000
2008-09-21T15:24:12.323000
55,296
55,389
How exactly do you configure httpOnly Cookies in ASP Classic?
I'm looking to implement httpOnly in my legacy ASP classic sites. Anyone knows how to do it?
Response.AddHeader "Set-Cookie", "mycookie=yo; HttpOnly" Other options like expires, path and secure can be also added in this way. I don't know of any magical way to change your whole cookies collection, but I could be wrong about that.
How exactly do you configure httpOnly Cookies in ASP Classic? I'm looking to implement httpOnly in my legacy ASP classic sites. Anyone knows how to do it?
TITLE: How exactly do you configure httpOnly Cookies in ASP Classic? QUESTION: I'm looking to implement httpOnly in my legacy ASP classic sites. Anyone knows how to do it? ANSWER: Response.AddHeader "Set-Cookie", "mycookie=yo; HttpOnly" Other options like expires, path and secure can be also added in this way. I don't know of any magical way to change your whole cookies collection, but I could be wrong about that.
[ "security", "asp-classic", "httponly" ]
13
13
35,444
6
0
2008-09-10T20:49:52.470000
2008-09-10T21:49:08.193000
55,297
75,703
asp consuming a web service, what do do with recordset object?
Currently I run an classic (old) ASP webpage with recordset object used directly in bad old spagethi code fasion. I'm thinking of implementing a data layer in asp.net as web serivce to improve manageability. This is also a first step towards upgrading the website to asp.net. The site itself remains ASP for the moment... Can anybody recommend a good way of replacing the recordset object type with a web service compatible type (like an array or something)? What do I replace below with?: set objRS = oConn.execute(SQL) while not objRS.eof... name = Cstr(objRS(1))... wend and also mutliple recordsets can be replaced with? I'm talking: set objRS = objRs.nextRecordset Anybody went through this and can recommend? @AdditionalInfo - you asked for it:-) Let me start at the beginning. Existing Situation is: I have an old ASP website with classical hierachical content (header, section, subsection, content) pulled out of database via stored procedures and content pages are in database also (a link to html file). Now bad thing is, ASP code everywhere spread over many.asp files all doing their own database connections, reading, writing (u have to register for content). Recently we had problems with SQL injection attacks so I was called to fix it. I could go change all the.asp pages to prevent sql injection but that would be madness. So I thought build a data layer - all pages using this layer to access database. Once place to fix and update db access code. Coming to that decision I thought asp.net upgrade isn'f far away, why not start using asp.net for the data layer? This way it can be re-used when upgrading the site. That brings me to the questions above!
If you wanted to stick with Classic ASP then I would suggest creating a Database handling object via ASP Classes then just use that object to do your recordset creations. This would centralize your database handling code and make it so that you only have to handle SQL Injection attacks in a single location. A simple example. Class clsDatabase Private Sub Class_Initialize() If Session("Debug") Then Response.Write "Database Initialized " End Sub Private Sub Class_Terminate() If Session("Debug") Then Response.Write "Database Terminated " End Sub Public Function Run(SQL) Set RS = CreateObject("ADODB.Recordset") RS.CursorLocation = adUseClient RS.Open SQLValidate(SQL), Application("Data"), adOpenKeyset, adLockReadOnly, adCmdText Set Run = RS Set RS = nothing End Function Public Function SQLValidate(SQL) SQLValidate = SQL SQLValidate = Replace(SQLValidate, "--", "", 1, -1, 1) SQLValidate = Replace(SQLValidate, ";", "", 1, -1, 1) SQLValidate = Replace(SQLValidate, "SP_", "", 1, -1, 1) SQLValidate = Replace(SQLValidate, "@@", "", 1, -1, 1) SQLValidate = Replace(SQLValidate, " DECLARE", "", 1, -1, 1) SQLValidate = Replace(SQLValidate, "EXEC", "", 1, -1, 1) SQLValidate = Replace(SQLValidate, " DROP", "", 1, -1, 1) SQLValidate = Replace(SQLValidate, " CREATE", "", 1, -1, 1) SQLValidate = Replace(SQLValidate, " GRANT", "", 1, -1, 1) SQLValidate = Replace(SQLValidate, " XP_", "", 1, -1, 1) SQLValidate = Replace(SQLValidate, "CHAR(124)", "", 1, -1, 1) End Function End Class Then to use this you would change your calls to: Set oData = new clsDatabase Set Recordset = oData.Run("SELECT field FROM table WHERE something = another") Set oData = nothing Of course you can expand the basic class to handle parametrized stored procedures or what not and more validations etc.
asp consuming a web service, what do do with recordset object? Currently I run an classic (old) ASP webpage with recordset object used directly in bad old spagethi code fasion. I'm thinking of implementing a data layer in asp.net as web serivce to improve manageability. This is also a first step towards upgrading the website to asp.net. The site itself remains ASP for the moment... Can anybody recommend a good way of replacing the recordset object type with a web service compatible type (like an array or something)? What do I replace below with?: set objRS = oConn.execute(SQL) while not objRS.eof... name = Cstr(objRS(1))... wend and also mutliple recordsets can be replaced with? I'm talking: set objRS = objRs.nextRecordset Anybody went through this and can recommend? @AdditionalInfo - you asked for it:-) Let me start at the beginning. Existing Situation is: I have an old ASP website with classical hierachical content (header, section, subsection, content) pulled out of database via stored procedures and content pages are in database also (a link to html file). Now bad thing is, ASP code everywhere spread over many.asp files all doing their own database connections, reading, writing (u have to register for content). Recently we had problems with SQL injection attacks so I was called to fix it. I could go change all the.asp pages to prevent sql injection but that would be madness. So I thought build a data layer - all pages using this layer to access database. Once place to fix and update db access code. Coming to that decision I thought asp.net upgrade isn'f far away, why not start using asp.net for the data layer? This way it can be re-used when upgrading the site. That brings me to the questions above!
TITLE: asp consuming a web service, what do do with recordset object? QUESTION: Currently I run an classic (old) ASP webpage with recordset object used directly in bad old spagethi code fasion. I'm thinking of implementing a data layer in asp.net as web serivce to improve manageability. This is also a first step towards upgrading the website to asp.net. The site itself remains ASP for the moment... Can anybody recommend a good way of replacing the recordset object type with a web service compatible type (like an array or something)? What do I replace below with?: set objRS = oConn.execute(SQL) while not objRS.eof... name = Cstr(objRS(1))... wend and also mutliple recordsets can be replaced with? I'm talking: set objRS = objRs.nextRecordset Anybody went through this and can recommend? @AdditionalInfo - you asked for it:-) Let me start at the beginning. Existing Situation is: I have an old ASP website with classical hierachical content (header, section, subsection, content) pulled out of database via stored procedures and content pages are in database also (a link to html file). Now bad thing is, ASP code everywhere spread over many.asp files all doing their own database connections, reading, writing (u have to register for content). Recently we had problems with SQL injection attacks so I was called to fix it. I could go change all the.asp pages to prevent sql injection but that would be madness. So I thought build a data layer - all pages using this layer to access database. Once place to fix and update db access code. Coming to that decision I thought asp.net upgrade isn'f far away, why not start using asp.net for the data layer? This way it can be re-used when upgrading the site. That brings me to the questions above! ANSWER: If you wanted to stick with Classic ASP then I would suggest creating a Database handling object via ASP Classes then just use that object to do your recordset creations. This would centralize your database handling code and make it so that you only have to handle SQL Injection attacks in a single location. A simple example. Class clsDatabase Private Sub Class_Initialize() If Session("Debug") Then Response.Write "Database Initialized " End Sub Private Sub Class_Terminate() If Session("Debug") Then Response.Write "Database Terminated " End Sub Public Function Run(SQL) Set RS = CreateObject("ADODB.Recordset") RS.CursorLocation = adUseClient RS.Open SQLValidate(SQL), Application("Data"), adOpenKeyset, adLockReadOnly, adCmdText Set Run = RS Set RS = nothing End Function Public Function SQLValidate(SQL) SQLValidate = SQL SQLValidate = Replace(SQLValidate, "--", "", 1, -1, 1) SQLValidate = Replace(SQLValidate, ";", "", 1, -1, 1) SQLValidate = Replace(SQLValidate, "SP_", "", 1, -1, 1) SQLValidate = Replace(SQLValidate, "@@", "", 1, -1, 1) SQLValidate = Replace(SQLValidate, " DECLARE", "", 1, -1, 1) SQLValidate = Replace(SQLValidate, "EXEC", "", 1, -1, 1) SQLValidate = Replace(SQLValidate, " DROP", "", 1, -1, 1) SQLValidate = Replace(SQLValidate, " CREATE", "", 1, -1, 1) SQLValidate = Replace(SQLValidate, " GRANT", "", 1, -1, 1) SQLValidate = Replace(SQLValidate, " XP_", "", 1, -1, 1) SQLValidate = Replace(SQLValidate, "CHAR(124)", "", 1, -1, 1) End Function End Class Then to use this you would change your calls to: Set oData = new clsDatabase Set Recordset = oData.Run("SELECT field FROM table WHERE something = another") Set oData = nothing Of course you can expand the basic class to handle parametrized stored procedures or what not and more validations etc.
[ "asp.net", "web-services", "asp-classic" ]
1
1
2,572
7
0
2008-09-10T20:50:32.093000
2008-09-16T18:56:44.110000
55,313
55,712
Automatic code quality tool for Ruby?
One thing I really miss about Java is the tool support. FindBugs, Checkstyle and PMD made for a holy trinity of code quality metrics and automatic bug checking. Is there anything that will check for simple bugs and / or style violations of Ruby code? Bonus points if I can adapt it for frameworks such as Rails so that Rails idioms are adhered to.
I've recently started looking for something like this for Ruby. What I've run across so far: Saikuro Roodi Flog These might be places to start. Unfortunately I haven't used any of the three enough yet to offer a good opinion.
Automatic code quality tool for Ruby? One thing I really miss about Java is the tool support. FindBugs, Checkstyle and PMD made for a holy trinity of code quality metrics and automatic bug checking. Is there anything that will check for simple bugs and / or style violations of Ruby code? Bonus points if I can adapt it for frameworks such as Rails so that Rails idioms are adhered to.
TITLE: Automatic code quality tool for Ruby? QUESTION: One thing I really miss about Java is the tool support. FindBugs, Checkstyle and PMD made for a holy trinity of code quality metrics and automatic bug checking. Is there anything that will check for simple bugs and / or style violations of Ruby code? Bonus points if I can adapt it for frameworks such as Rails so that Rails idioms are adhered to. ANSWER: I've recently started looking for something like this for Ruby. What I've run across so far: Saikuro Roodi Flog These might be places to start. Unfortunately I haven't used any of the three enough yet to offer a good opinion.
[ "ruby-on-rails", "ruby", "code-analysis" ]
37
17
11,256
9
0
2008-09-10T21:00:07.390000
2008-09-11T02:41:16.743000
55,317
55,412
OpenGl And Flickering
When objects from a CallList intersect the near plane I get a flicker..., what can I do? Im using OpenGL and SDL. Yes it is double buffered.
It sounds like you're getting z-fighting. "Z-fighting is a phenomenon in 3D rendering that occurs when two or more primitives have similar values in the z-buffer, and is particularly prevalent with coplanar polygons. The effect causes pseudo-random pixels to be rendered with the color of one polygon or another in a non-deterministic manner, varying as the scene is animated, causing one polygon to "win" the z test, then another, and so on." (From wikipedia ) You can get more information about the problem in the OpenGL FAQ. glPolygonOffset might help, but you can also get yourself into trouble with it. Tom Forsyth has a good explanation in his FAQ Note: It talks about ZBIAS, but that's just the DirectX equivilent.
OpenGl And Flickering When objects from a CallList intersect the near plane I get a flicker..., what can I do? Im using OpenGL and SDL. Yes it is double buffered.
TITLE: OpenGl And Flickering QUESTION: When objects from a CallList intersect the near plane I get a flicker..., what can I do? Im using OpenGL and SDL. Yes it is double buffered. ANSWER: It sounds like you're getting z-fighting. "Z-fighting is a phenomenon in 3D rendering that occurs when two or more primitives have similar values in the z-buffer, and is particularly prevalent with coplanar polygons. The effect causes pseudo-random pixels to be rendered with the color of one polygon or another in a non-deterministic manner, varying as the scene is animated, causing one polygon to "win" the z test, then another, and so on." (From wikipedia ) You can get more information about the problem in the OpenGL FAQ. glPolygonOffset might help, but you can also get yourself into trouble with it. Tom Forsyth has a good explanation in his FAQ Note: It talks about ZBIAS, but that's just the DirectX equivilent.
[ "opengl" ]
1
5
6,960
4
0
2008-09-10T21:02:52.733000
2008-09-10T22:07:24.747000
55,322
83,069
JVM choices on Windows Mobile
What are the JVM implementations available on Windows Mobile? Esmertec JBed is the one on my WinMo phone. Wondering how many other JVM vendors are in this zone. Are there any comparison or benchmarking data available?
JVM Choices for Windows CE in general (including Pocket PC and Windows Mobile): CrE-ME Mysaifu Skelmir CEEJ If you're looking to have a common code base between WinMo and Symbina, you might also look at Red Five Labs. They have a Symbian runtime that allows you to run COmpact Framework apps, so you could have a CF codebase that works on both. I evaluated the early betas of Red Five's offering, but haven't used it since, so I can't attest to the quality or coverage.
JVM choices on Windows Mobile What are the JVM implementations available on Windows Mobile? Esmertec JBed is the one on my WinMo phone. Wondering how many other JVM vendors are in this zone. Are there any comparison or benchmarking data available?
TITLE: JVM choices on Windows Mobile QUESTION: What are the JVM implementations available on Windows Mobile? Esmertec JBed is the one on my WinMo phone. Wondering how many other JVM vendors are in this zone. Are there any comparison or benchmarking data available? ANSWER: JVM Choices for Windows CE in general (including Pocket PC and Windows Mobile): CrE-ME Mysaifu Skelmir CEEJ If you're looking to have a common code base between WinMo and Symbina, you might also look at Red Five Labs. They have a Symbian runtime that allows you to run COmpact Framework apps, so you could have a CF codebase that works on both. I evaluated the early betas of Red Five's offering, but haven't used it since, so I can't attest to the quality or coverage.
[ "windows-mobile", "jvm" ]
8
7
16,047
8
0
2008-09-10T21:05:06.677000
2008-09-17T13:18:46.707000
55,323
56,645
ASP.NET Web Application Build Output - How do I include all deployment files?
When I build my ASP.NET web application I get a.dll file with the code for the website in it (which is great) but the website also needs all the.aspx files and friends, and these need to be placed in the correct directory structure. How can I get this all in one directory as the result of each build? Trying to pick the right files out of the source directory is a pain. The end result should be xcopy deployable. Update: I don't want to have to manually use the Publish command which I'm aware of. I want the full set of files required by the application to be the build output - this means I also get the full set of files in one place from running MSBuild.
One solution appears to be Web Deployment Projects (WDPs), an add-on for Visual Studio (and msbuild) available that builds a web project to a directory and can optionally merge assemblies and alter the web.config file. The output of building a WDP is all the files necessary to deploy the site in one directory. More information about Web Deployment Projects: Announcement on webdevtools MSDN blog for WDP 2008 ScottGu introduction to WDP 2005 The only disadvantage to this solution is the requirement on an add-on which must be available on the build machine. Still, it's good enough for now!
ASP.NET Web Application Build Output - How do I include all deployment files? When I build my ASP.NET web application I get a.dll file with the code for the website in it (which is great) but the website also needs all the.aspx files and friends, and these need to be placed in the correct directory structure. How can I get this all in one directory as the result of each build? Trying to pick the right files out of the source directory is a pain. The end result should be xcopy deployable. Update: I don't want to have to manually use the Publish command which I'm aware of. I want the full set of files required by the application to be the build output - this means I also get the full set of files in one place from running MSBuild.
TITLE: ASP.NET Web Application Build Output - How do I include all deployment files? QUESTION: When I build my ASP.NET web application I get a.dll file with the code for the website in it (which is great) but the website also needs all the.aspx files and friends, and these need to be placed in the correct directory structure. How can I get this all in one directory as the result of each build? Trying to pick the right files out of the source directory is a pain. The end result should be xcopy deployable. Update: I don't want to have to manually use the Publish command which I'm aware of. I want the full set of files required by the application to be the build output - this means I also get the full set of files in one place from running MSBuild. ANSWER: One solution appears to be Web Deployment Projects (WDPs), an add-on for Visual Studio (and msbuild) available that builds a web project to a directory and can optionally merge assemblies and alter the web.config file. The output of building a WDP is all the files necessary to deploy the site in one directory. More information about Web Deployment Projects: Announcement on webdevtools MSDN blog for WDP 2008 ScottGu introduction to WDP 2005 The only disadvantage to this solution is the requirement on an add-on which must be available on the build machine. Still, it's good enough for now!
[ "asp.net", "deployment", "build-process", "build-automation" ]
4
5
4,786
9
0
2008-09-10T21:06:06.050000
2008-09-11T14:15:42.033000
55,340
55,504
Bespoke SQL Server 'encoding' sproc - is there a neater way of doing this?
I'm just wondering if there's a better way of doing this in SQL Server 2005. Effectively, I'm taking an originator_id (a number between 0 and 99) and a 'next_element' (it's really just a sequential counter between 1 and 999,999). We are trying to create a 6-character 'code' from them. The originator_id is multiplied up by a million, and then the counter added in, giving us a number between 0 and 99,999,999. Then we convert this into a 'base 32' string - a fake base 32, where we're really just using 0-9 and A-Z but with a few of the more confusing alphanums removed for clarity (I, O, S, Z). To do this, we just divide the number up by powers of 32, at each stage using the result we get for each power as an index for a character from our array of selected character. Thus, an originator ID of 61 and NextCodeElement of 9 gives a code of '1T5JA9' (61 * 1,000,000) + 9 = 61,000,009 61,000,009 div (5^32 = 33,554,432) = 1 = '1' 27,445,577 div (4^32 = 1,048,576) = 26 = 'T' 182,601 div (3^32 = 32,768) = 5 = '5' 18,761 div (2^32 = 1,024) = 18 = 'J' 329 div (1^32 = 32) = 10 = 'A' 9 div (0^32 = 1) = 9 = '9' so my code is 1T5JA9 Previously I've had this algorithm working (in Delphi) but now I really need to be able to recreate it in SQL Server 2005. Obviously I don't quite have the same functions to hand that I have in Delphi, but this is my take on the routine. It works, and I can generate codes (or reconstruct codes back into their components) just fine. But it looks a bit long-winded, and I'm not sure that the trick of selecting the result of a division into an int (ie casting it, really) is necessarily 'right' - is there a better SQLS approach to this kind of thing? CREATE procedure dummy_RP_CREATE_CODE @NextCodeElement int, @OriginatorID int, @code varchar(6) output as begin declare @raw_num int; declare @bcelems char(32); declare @chr int; select @bcelems='0123456789ABCDEFGHJKLMNPQRTUVWXY'; select @code=''; -- add in the originator_id, scaled into place select @raw_num = (@OriginatorID * 1000000) + @NextCodeElement; -- now to convert this to a 6-char code -- 5^32 select @chr = @raw_num / 33554432; select @raw_num = @raw_num - (@chr * 33554432); select @code = @code + SUBSTRING(@bcelems, 1 + @chr, 1); -- 4^32 select @chr = @raw_num / 1048576; select @raw_num = @raw_num - (@chr * 1048576); select @code = @code + SUBSTRING(@bcelems, 1 + @chr, 1); -- 3^32 select @chr = @raw_num / 32768; select @raw_num = @raw_num - (@chr * 32768); select @code = @code + SUBSTRING(@bcelems, 1 + @chr, 1); -- 2^32 select @chr = @raw_num / 1024; select @raw_num = @raw_num - (@chr * 1024); select @code = @code + SUBSTRING(@bcelems, 1 + @chr, 1); -- 1^32 select @chr = @raw_num / 32; select @raw_num = @raw_num - (@chr * 32); select @code = @code + SUBSTRING(@bcelems, 1 + @chr, 1); -- 0^32 select @code = @code + SUBSTRING(@bcelems, 1 + @raw_num, 1); -- that's it! end; I'm not desperately concerned about optimisation unless this method is actually an order of magnitude (or so) worse than any alternative. The code only ever gets executed in small bursts, maybe generating 20 or 30 codes every 10 minutes or so. Because of the large range of numbers I don't want to pre-calculate the codes into a huge table (only small pockets of the overall code range will be used in any given installation). However, I'm sure there's probably a tidier way of achieving the same result - particularly those divisions and subtractions. Any constructive criticism, observations or suggestions would be most welcome.
Seeing as it's SQL Server 2005, any reason not to use a CLR stored procedure? You could use your CLR language of choice then and it'd probably be a relatively direct port of your existing Delphi code.
Bespoke SQL Server 'encoding' sproc - is there a neater way of doing this? I'm just wondering if there's a better way of doing this in SQL Server 2005. Effectively, I'm taking an originator_id (a number between 0 and 99) and a 'next_element' (it's really just a sequential counter between 1 and 999,999). We are trying to create a 6-character 'code' from them. The originator_id is multiplied up by a million, and then the counter added in, giving us a number between 0 and 99,999,999. Then we convert this into a 'base 32' string - a fake base 32, where we're really just using 0-9 and A-Z but with a few of the more confusing alphanums removed for clarity (I, O, S, Z). To do this, we just divide the number up by powers of 32, at each stage using the result we get for each power as an index for a character from our array of selected character. Thus, an originator ID of 61 and NextCodeElement of 9 gives a code of '1T5JA9' (61 * 1,000,000) + 9 = 61,000,009 61,000,009 div (5^32 = 33,554,432) = 1 = '1' 27,445,577 div (4^32 = 1,048,576) = 26 = 'T' 182,601 div (3^32 = 32,768) = 5 = '5' 18,761 div (2^32 = 1,024) = 18 = 'J' 329 div (1^32 = 32) = 10 = 'A' 9 div (0^32 = 1) = 9 = '9' so my code is 1T5JA9 Previously I've had this algorithm working (in Delphi) but now I really need to be able to recreate it in SQL Server 2005. Obviously I don't quite have the same functions to hand that I have in Delphi, but this is my take on the routine. It works, and I can generate codes (or reconstruct codes back into their components) just fine. But it looks a bit long-winded, and I'm not sure that the trick of selecting the result of a division into an int (ie casting it, really) is necessarily 'right' - is there a better SQLS approach to this kind of thing? CREATE procedure dummy_RP_CREATE_CODE @NextCodeElement int, @OriginatorID int, @code varchar(6) output as begin declare @raw_num int; declare @bcelems char(32); declare @chr int; select @bcelems='0123456789ABCDEFGHJKLMNPQRTUVWXY'; select @code=''; -- add in the originator_id, scaled into place select @raw_num = (@OriginatorID * 1000000) + @NextCodeElement; -- now to convert this to a 6-char code -- 5^32 select @chr = @raw_num / 33554432; select @raw_num = @raw_num - (@chr * 33554432); select @code = @code + SUBSTRING(@bcelems, 1 + @chr, 1); -- 4^32 select @chr = @raw_num / 1048576; select @raw_num = @raw_num - (@chr * 1048576); select @code = @code + SUBSTRING(@bcelems, 1 + @chr, 1); -- 3^32 select @chr = @raw_num / 32768; select @raw_num = @raw_num - (@chr * 32768); select @code = @code + SUBSTRING(@bcelems, 1 + @chr, 1); -- 2^32 select @chr = @raw_num / 1024; select @raw_num = @raw_num - (@chr * 1024); select @code = @code + SUBSTRING(@bcelems, 1 + @chr, 1); -- 1^32 select @chr = @raw_num / 32; select @raw_num = @raw_num - (@chr * 32); select @code = @code + SUBSTRING(@bcelems, 1 + @chr, 1); -- 0^32 select @code = @code + SUBSTRING(@bcelems, 1 + @raw_num, 1); -- that's it! end; I'm not desperately concerned about optimisation unless this method is actually an order of magnitude (or so) worse than any alternative. The code only ever gets executed in small bursts, maybe generating 20 or 30 codes every 10 minutes or so. Because of the large range of numbers I don't want to pre-calculate the codes into a huge table (only small pockets of the overall code range will be used in any given installation). However, I'm sure there's probably a tidier way of achieving the same result - particularly those divisions and subtractions. Any constructive criticism, observations or suggestions would be most welcome.
TITLE: Bespoke SQL Server 'encoding' sproc - is there a neater way of doing this? QUESTION: I'm just wondering if there's a better way of doing this in SQL Server 2005. Effectively, I'm taking an originator_id (a number between 0 and 99) and a 'next_element' (it's really just a sequential counter between 1 and 999,999). We are trying to create a 6-character 'code' from them. The originator_id is multiplied up by a million, and then the counter added in, giving us a number between 0 and 99,999,999. Then we convert this into a 'base 32' string - a fake base 32, where we're really just using 0-9 and A-Z but with a few of the more confusing alphanums removed for clarity (I, O, S, Z). To do this, we just divide the number up by powers of 32, at each stage using the result we get for each power as an index for a character from our array of selected character. Thus, an originator ID of 61 and NextCodeElement of 9 gives a code of '1T5JA9' (61 * 1,000,000) + 9 = 61,000,009 61,000,009 div (5^32 = 33,554,432) = 1 = '1' 27,445,577 div (4^32 = 1,048,576) = 26 = 'T' 182,601 div (3^32 = 32,768) = 5 = '5' 18,761 div (2^32 = 1,024) = 18 = 'J' 329 div (1^32 = 32) = 10 = 'A' 9 div (0^32 = 1) = 9 = '9' so my code is 1T5JA9 Previously I've had this algorithm working (in Delphi) but now I really need to be able to recreate it in SQL Server 2005. Obviously I don't quite have the same functions to hand that I have in Delphi, but this is my take on the routine. It works, and I can generate codes (or reconstruct codes back into their components) just fine. But it looks a bit long-winded, and I'm not sure that the trick of selecting the result of a division into an int (ie casting it, really) is necessarily 'right' - is there a better SQLS approach to this kind of thing? CREATE procedure dummy_RP_CREATE_CODE @NextCodeElement int, @OriginatorID int, @code varchar(6) output as begin declare @raw_num int; declare @bcelems char(32); declare @chr int; select @bcelems='0123456789ABCDEFGHJKLMNPQRTUVWXY'; select @code=''; -- add in the originator_id, scaled into place select @raw_num = (@OriginatorID * 1000000) + @NextCodeElement; -- now to convert this to a 6-char code -- 5^32 select @chr = @raw_num / 33554432; select @raw_num = @raw_num - (@chr * 33554432); select @code = @code + SUBSTRING(@bcelems, 1 + @chr, 1); -- 4^32 select @chr = @raw_num / 1048576; select @raw_num = @raw_num - (@chr * 1048576); select @code = @code + SUBSTRING(@bcelems, 1 + @chr, 1); -- 3^32 select @chr = @raw_num / 32768; select @raw_num = @raw_num - (@chr * 32768); select @code = @code + SUBSTRING(@bcelems, 1 + @chr, 1); -- 2^32 select @chr = @raw_num / 1024; select @raw_num = @raw_num - (@chr * 1024); select @code = @code + SUBSTRING(@bcelems, 1 + @chr, 1); -- 1^32 select @chr = @raw_num / 32; select @raw_num = @raw_num - (@chr * 32); select @code = @code + SUBSTRING(@bcelems, 1 + @chr, 1); -- 0^32 select @code = @code + SUBSTRING(@bcelems, 1 + @raw_num, 1); -- that's it! end; I'm not desperately concerned about optimisation unless this method is actually an order of magnitude (or so) worse than any alternative. The code only ever gets executed in small bursts, maybe generating 20 or 30 codes every 10 minutes or so. Because of the large range of numbers I don't want to pre-calculate the codes into a huge table (only small pockets of the overall code range will be used in any given installation). However, I'm sure there's probably a tidier way of achieving the same result - particularly those divisions and subtractions. Any constructive criticism, observations or suggestions would be most welcome. ANSWER: Seeing as it's SQL Server 2005, any reason not to use a CLR stored procedure? You could use your CLR language of choice then and it'd probably be a relatively direct port of your existing Delphi code.
[ "sql-server", "t-sql" ]
1
3
601
2
0
2008-09-10T21:15:12.173000
2008-09-10T23:44:26.123000
55,342
55,359
How can I kill all sessions connecting to my oracle database?
I need to quickly (and forcibly) kill off all external sessions connecting to my oracle database without the supervision of and administrator. I don't want to just lock the database and let the users quit gracefully. How would I script this?
This answer is heavily influenced by a conversation here: http://www.tek-tips.com/viewthread.cfm?qid=1395151&page=3 ALTER SYSTEM ENABLE RESTRICTED SESSION; begin for x in ( select Sid, Serial#, machine, program from v$session where machine <> 'MyDatabaseServerName' ) loop execute immediate 'Alter System Kill Session '''|| x.Sid || ',' || x.Serial# || ''' IMMEDIATE'; end loop; end; I skip killing sessions originating on the database server to avoid killing off Oracle's connections to itself.
How can I kill all sessions connecting to my oracle database? I need to quickly (and forcibly) kill off all external sessions connecting to my oracle database without the supervision of and administrator. I don't want to just lock the database and let the users quit gracefully. How would I script this?
TITLE: How can I kill all sessions connecting to my oracle database? QUESTION: I need to quickly (and forcibly) kill off all external sessions connecting to my oracle database without the supervision of and administrator. I don't want to just lock the database and let the users quit gracefully. How would I script this? ANSWER: This answer is heavily influenced by a conversation here: http://www.tek-tips.com/viewthread.cfm?qid=1395151&page=3 ALTER SYSTEM ENABLE RESTRICTED SESSION; begin for x in ( select Sid, Serial#, machine, program from v$session where machine <> 'MyDatabaseServerName' ) loop execute immediate 'Alter System Kill Session '''|| x.Sid || ',' || x.Serial# || ''' IMMEDIATE'; end loop; end; I skip killing sessions originating on the database server to avoid killing off Oracle's connections to itself.
[ "oracle", "session", "sqlplus", "kill", "database-administration" ]
30
46
137,569
10
0
2008-09-10T21:16:10.613000
2008-09-10T21:27:44.500000
55,350
55,813
"Background" task in palm OS
I'm trying to create a Palm OS app to check a web site every X minutes or hours, and provide a notification when a piece of data is available. I know that this kind of thing can be done on the new Palm's - for example, my Centro can have email or web sites download when the application isn't on top - but I don't know how to do it. Can anyone point me in the right direction?
This is possible to do but very difficult. There are several steps you'll have to take. First off, this only works on Palm OS 5 and is sketchy on some of the early Palm OS 5 devices. The latest devices are better but not perfect. Next, you will need to create an alarm for your application using AlmSetAlarm. This is how you accomplish the "every X minutes or hours" part. When the alarm fires, your application will get a sysAppLaunchCmdAlarmTriggered launch code, even if it's not already running. If you only want to do something simple and quick, you can do it in response to the launch code and you're done. After you do your stuff in the alarm launch code, be sure to set up the next alarm so that you continue to be called. Important notes: You cannot access global variables when responding this launch code! Depending on the setup in your compiler, you probably also won't be able to access certain C++ features, like virtual functions (which internally use global variables). There is a setting you can set in Codewarrior that will help with this, but I'm not too familiar with it. You should architect your code so that it doesn't need globals; for example, you can use FtrSet and FtrGet to store bits of global data that you might need. Finally, you will only be able to access a single 64KB code segment of 68000 machine code. Inter-segment jumps don't work properly without globals set up. You can get around a lot of these restrictions by moving the majority of your code to a PNOlet, but that's an entirely different and more complicated topic. If you want to do something more complicated that could take a while (e.g. load a web page or download email), it is strongly recommended not to do it during the alarm launch code. You could do something in the sysAppLaunchCmdDisplayAlarm launch code and display a form to the user allowing them to cancel. But this is bound to get annoying quickly. Better for the user experience (but much more complicated) is to become a background application. This is a bit of black magic and is not really well supported, but it is possible. There are basically three steps to becoming a background application: Protect your application database using DmDatabaseProtect. This will ensure that your application is locked down so it can't be deleted. Lock your code segment using MemHandleLock and MemHandleSetOwner (set the owner to 0). This will ensure that your code is loaded into memory and won't be moved. Register for some notifications. For example, the sysNotifyIdleTimeEvent is a great notification to use to do some periodic background processing. Once you set this up, you can exit from the alarm launch code and then wait for your notifications to fire. You will then do all of your background processing when your notification handlers are called. Also make sure that if you allocate any system objects (memory, handles, file handles, etc.), you set their owner to 0 (system) if you expect them to persist after you return from your notification handler. Otherwise the system will clean them up. If you do this, be super careful to avoid memory and resource leaks!! They will never get cleaned up when the owner is set to 0! To leave background mode, simply do the reverse: unregister for notifications, unlock your code segment, and unprotect your application database. If you do any network operations in the background, be sure that you set the sockets to non-blocking mode and deal correctly with that! Otherwise you will block the foreground application and cause problems.
"Background" task in palm OS I'm trying to create a Palm OS app to check a web site every X minutes or hours, and provide a notification when a piece of data is available. I know that this kind of thing can be done on the new Palm's - for example, my Centro can have email or web sites download when the application isn't on top - but I don't know how to do it. Can anyone point me in the right direction?
TITLE: "Background" task in palm OS QUESTION: I'm trying to create a Palm OS app to check a web site every X minutes or hours, and provide a notification when a piece of data is available. I know that this kind of thing can be done on the new Palm's - for example, my Centro can have email or web sites download when the application isn't on top - but I don't know how to do it. Can anyone point me in the right direction? ANSWER: This is possible to do but very difficult. There are several steps you'll have to take. First off, this only works on Palm OS 5 and is sketchy on some of the early Palm OS 5 devices. The latest devices are better but not perfect. Next, you will need to create an alarm for your application using AlmSetAlarm. This is how you accomplish the "every X minutes or hours" part. When the alarm fires, your application will get a sysAppLaunchCmdAlarmTriggered launch code, even if it's not already running. If you only want to do something simple and quick, you can do it in response to the launch code and you're done. After you do your stuff in the alarm launch code, be sure to set up the next alarm so that you continue to be called. Important notes: You cannot access global variables when responding this launch code! Depending on the setup in your compiler, you probably also won't be able to access certain C++ features, like virtual functions (which internally use global variables). There is a setting you can set in Codewarrior that will help with this, but I'm not too familiar with it. You should architect your code so that it doesn't need globals; for example, you can use FtrSet and FtrGet to store bits of global data that you might need. Finally, you will only be able to access a single 64KB code segment of 68000 machine code. Inter-segment jumps don't work properly without globals set up. You can get around a lot of these restrictions by moving the majority of your code to a PNOlet, but that's an entirely different and more complicated topic. If you want to do something more complicated that could take a while (e.g. load a web page or download email), it is strongly recommended not to do it during the alarm launch code. You could do something in the sysAppLaunchCmdDisplayAlarm launch code and display a form to the user allowing them to cancel. But this is bound to get annoying quickly. Better for the user experience (but much more complicated) is to become a background application. This is a bit of black magic and is not really well supported, but it is possible. There are basically three steps to becoming a background application: Protect your application database using DmDatabaseProtect. This will ensure that your application is locked down so it can't be deleted. Lock your code segment using MemHandleLock and MemHandleSetOwner (set the owner to 0). This will ensure that your code is loaded into memory and won't be moved. Register for some notifications. For example, the sysNotifyIdleTimeEvent is a great notification to use to do some periodic background processing. Once you set this up, you can exit from the alarm launch code and then wait for your notifications to fire. You will then do all of your background processing when your notification handlers are called. Also make sure that if you allocate any system objects (memory, handles, file handles, etc.), you set their owner to 0 (system) if you expect them to persist after you return from your notification handler. Otherwise the system will clean them up. If you do this, be super careful to avoid memory and resource leaks!! They will never get cleaned up when the owner is set to 0! To leave background mode, simply do the reverse: unregister for notifications, unlock your code segment, and unprotect your application database. If you do any network operations in the background, be sure that you set the sockets to non-blocking mode and deal correctly with that! Otherwise you will block the foreground application and cause problems.
[ "palm-os", "garnet-os" ]
4
7
399
1
0
2008-09-10T21:19:39.340000
2008-09-11T04:37:39.507000
55,360
87,364
__doPostBack is not working in firefox
The __doPostBack is not working in firefox 3 (have not checked 2). Everything is working great in IE 6&7 and it even works in Chrome?? It's a simple asp:LinkButton with an OnClick event The javascript confirm is firing so I know the javascript is working, it's specirically the __doPostBack event. There is a lot more going on on the page, just didn't know if it's work it to post the entire page. I enable the control on the page load event. Any ideas? I hope this is the correct way to do this, but I found the answer. I figured I'd put it up here rather then in a stackoverflow "answer" Seems it had something to do with nesting ajax toolkit UpdatePanel. When I removed the top level panel it was fixed. Hope this helps if anyone else has the same problem. I still don't know what specifically was causing the problem, but that was the solution for me.
Check your User Agent string. This same thing happened to me one time and I realized it was because I was testing out some pages as "googlebot". The JavaScript that is generated depends on knowing what the user agent is. From http://support.mozilla.com/tiki-view_forum_thread.php?locale=tr&comments_parentId=160492&forumId=1: To reset your user agent string type about:config into the location bar and press enter. This brings up a list of preferences. Enter general.useragent into the filter box, this should show a few preferences (probably 4 of them). If any have the status user set, right-click on the preference and choose Reset
__doPostBack is not working in firefox The __doPostBack is not working in firefox 3 (have not checked 2). Everything is working great in IE 6&7 and it even works in Chrome?? It's a simple asp:LinkButton with an OnClick event The javascript confirm is firing so I know the javascript is working, it's specirically the __doPostBack event. There is a lot more going on on the page, just didn't know if it's work it to post the entire page. I enable the control on the page load event. Any ideas? I hope this is the correct way to do this, but I found the answer. I figured I'd put it up here rather then in a stackoverflow "answer" Seems it had something to do with nesting ajax toolkit UpdatePanel. When I removed the top level panel it was fixed. Hope this helps if anyone else has the same problem. I still don't know what specifically was causing the problem, but that was the solution for me.
TITLE: __doPostBack is not working in firefox QUESTION: The __doPostBack is not working in firefox 3 (have not checked 2). Everything is working great in IE 6&7 and it even works in Chrome?? It's a simple asp:LinkButton with an OnClick event The javascript confirm is firing so I know the javascript is working, it's specirically the __doPostBack event. There is a lot more going on on the page, just didn't know if it's work it to post the entire page. I enable the control on the page load event. Any ideas? I hope this is the correct way to do this, but I found the answer. I figured I'd put it up here rather then in a stackoverflow "answer" Seems it had something to do with nesting ajax toolkit UpdatePanel. When I removed the top level panel it was fixed. Hope this helps if anyone else has the same problem. I still don't know what specifically was causing the problem, but that was the solution for me. ANSWER: Check your User Agent string. This same thing happened to me one time and I realized it was because I was testing out some pages as "googlebot". The JavaScript that is generated depends on knowing what the user agent is. From http://support.mozilla.com/tiki-view_forum_thread.php?locale=tr&comments_parentId=160492&forumId=1: To reset your user agent string type about:config into the location bar and press enter. This brings up a list of preferences. Enter general.useragent into the filter box, this should show a few preferences (probably 4 of them). If any have the status user set, right-click on the preference and choose Reset
[ "c#", "asp.net" ]
3
5
16,485
14
0
2008-09-10T21:28:13.907000
2008-09-17T20:35:43.083000
55,365
56,008
How can I get Emacs' key bindings in Python's IDLE?
I use Emacs primarily for coding Python but sometimes I use IDLE. Is there a way to change the key bindings easily in IDLE to match Emacs?
IDLE provides Emacs keybindings without having to install other software. Open up the menu item Options -> Configure IDLE... Go to Keys tab In the drop down menu on the right side of the dialog change the select to "IDLE Classic Unix" It's not the true emacs key bindings but you get the basics like movement, saving/opening,...
How can I get Emacs' key bindings in Python's IDLE? I use Emacs primarily for coding Python but sometimes I use IDLE. Is there a way to change the key bindings easily in IDLE to match Emacs?
TITLE: How can I get Emacs' key bindings in Python's IDLE? QUESTION: I use Emacs primarily for coding Python but sometimes I use IDLE. Is there a way to change the key bindings easily in IDLE to match Emacs? ANSWER: IDLE provides Emacs keybindings without having to install other software. Open up the menu item Options -> Configure IDLE... Go to Keys tab In the drop down menu on the right side of the dialog change the select to "IDLE Classic Unix" It's not the true emacs key bindings but you get the basics like movement, saving/opening,...
[ "python", "emacs", "ide", "keyboard" ]
6
6
2,153
3
0
2008-09-10T21:32:47.140000
2008-09-11T08:18:07.027000
55,369
55,396
Reading VC++ CArchive Binary Format (or Java reading (CObArray))
Is there any clear documentation on the binary formats used to serialize the various MFC data structures? I've been able to view some of my own classes in a hex editor and use Java's ByteBuffer class to read them in (with automatic endianness conversions, etc). However, I am currently running into issues while trying to bring over the CObArray data, as there seems to be a rather large header that is opaque to me, and it is unclear how it is persisting object type information. Is there a set of online documentation that would be helpful for this? Or some sample Java code from someone that has dealt with this in the past?
Since MFC ships with source code I would create a test MFC application that serializes a CObArray and step through the serialization code. This should give you all the information you need.
Reading VC++ CArchive Binary Format (or Java reading (CObArray)) Is there any clear documentation on the binary formats used to serialize the various MFC data structures? I've been able to view some of my own classes in a hex editor and use Java's ByteBuffer class to read them in (with automatic endianness conversions, etc). However, I am currently running into issues while trying to bring over the CObArray data, as there seems to be a rather large header that is opaque to me, and it is unclear how it is persisting object type information. Is there a set of online documentation that would be helpful for this? Or some sample Java code from someone that has dealt with this in the past?
TITLE: Reading VC++ CArchive Binary Format (or Java reading (CObArray)) QUESTION: Is there any clear documentation on the binary formats used to serialize the various MFC data structures? I've been able to view some of my own classes in a hex editor and use Java's ByteBuffer class to read them in (with automatic endianness conversions, etc). However, I am currently running into issues while trying to bring over the CObArray data, as there seems to be a rather large header that is opaque to me, and it is unclear how it is persisting object type information. Is there a set of online documentation that would be helpful for this? Or some sample Java code from someone that has dealt with this in the past? ANSWER: Since MFC ships with source code I would create a test MFC application that serializes a CObArray and step through the serialization code. This should give you all the information you need.
[ "java", "visual-c++", "serialization", "mfc", "carchive" ]
3
3
2,140
2
0
2008-09-10T21:33:48.480000
2008-09-10T21:53:09.323000
55,375
55,435
Extending an enum via inheritance
I know this rather goes against the idea of enums, but is it possible to extend enums in C#/Java? I mean "extend" in both the sense of adding new values to an enum, but also in the OO sense of inheriting from an existing enum. I assume it's not possible in Java, as it only got them fairly recently (Java 5?). C# seems more forgiving of people that want to do crazy things, though, so I thought it might be possible some way. Presumably it could be hacked up via reflection (not that you'd every actually use that method)? I'm not necessarily interested in implementing any given method, it just provoked my curiosity when it occurred to me:-)
The reason you can't extend Enums is because it would lead to problems with polymorphism. Say you have an enum MyEnum with values A, B, and C, and extend it with value D as MyExtEnum. Suppose a method expects a myEnum value somewhere, for instance as a parameter. It should be legal to supply a MyExtEnum value, because it's a subtype, but now what are you going to do when it turns out the value is D? To eliminate this problem, extending enums is illegal
Extending an enum via inheritance I know this rather goes against the idea of enums, but is it possible to extend enums in C#/Java? I mean "extend" in both the sense of adding new values to an enum, but also in the OO sense of inheriting from an existing enum. I assume it's not possible in Java, as it only got them fairly recently (Java 5?). C# seems more forgiving of people that want to do crazy things, though, so I thought it might be possible some way. Presumably it could be hacked up via reflection (not that you'd every actually use that method)? I'm not necessarily interested in implementing any given method, it just provoked my curiosity when it occurred to me:-)
TITLE: Extending an enum via inheritance QUESTION: I know this rather goes against the idea of enums, but is it possible to extend enums in C#/Java? I mean "extend" in both the sense of adding new values to an enum, but also in the OO sense of inheriting from an existing enum. I assume it's not possible in Java, as it only got them fairly recently (Java 5?). C# seems more forgiving of people that want to do crazy things, though, so I thought it might be possible some way. Presumably it could be hacked up via reflection (not that you'd every actually use that method)? I'm not necessarily interested in implementing any given method, it just provoked my curiosity when it occurred to me:-) ANSWER: The reason you can't extend Enums is because it would lead to problems with polymorphism. Say you have an enum MyEnum with values A, B, and C, and extend it with value D as MyExtEnum. Suppose a method expects a myEnum value somewhere, for instance as a parameter. It should be legal to supply a MyExtEnum value, because it's a subtype, but now what are you going to do when it turns out the value is D? To eliminate this problem, extending enums is illegal
[ "c#", "java", ".net" ]
101
115
108,577
15
0
2008-09-10T21:39:21.477000
2008-09-10T22:29:39.640000
55,391
55,424
Python regular expression for HTML parsing
I want to grab the value of a hidden input field in HTML. I want to write a regular expression in Python that will return the value of fooId, given that I know the line in the HTML follows the format Can someone provide an example in Python to parse the HTML for the value?
For this particular case, BeautifulSoup is harder to write than a regex, but it is much more robust... I'm just contributing with the BeautifulSoup example, given that you already know which regexp to use:-) from BeautifulSoup import BeautifulSoup #Or retrieve it from the web, etc. html_data = open('/yourwebsite/page.html','r').read() #Create the soup object from the HTML data soup = BeautifulSoup(html_data) fooId = soup.find('input',name='fooId',type='hidden') #Find the proper tag value = fooId.attrs[2][1] #The value of the third attribute of the desired tag #or index it directly via fooId['value']
Python regular expression for HTML parsing I want to grab the value of a hidden input field in HTML. I want to write a regular expression in Python that will return the value of fooId, given that I know the line in the HTML follows the format Can someone provide an example in Python to parse the HTML for the value?
TITLE: Python regular expression for HTML parsing QUESTION: I want to grab the value of a hidden input field in HTML. I want to write a regular expression in Python that will return the value of fooId, given that I know the line in the HTML follows the format Can someone provide an example in Python to parse the HTML for the value? ANSWER: For this particular case, BeautifulSoup is harder to write than a regex, but it is much more robust... I'm just contributing with the BeautifulSoup example, given that you already know which regexp to use:-) from BeautifulSoup import BeautifulSoup #Or retrieve it from the web, etc. html_data = open('/yourwebsite/page.html','r').read() #Create the soup object from the HTML data soup = BeautifulSoup(html_data) fooId = soup.find('input',name='fooId',type='hidden') #Find the proper tag value = fooId.attrs[2][1] #The value of the third attribute of the desired tag #or index it directly via fooId['value']
[ "python", "regex", "web-scraping", "beautifulsoup" ]
11
27
27,539
7
0
2008-09-10T21:49:53.900000
2008-09-10T22:16:24.273000
55,403
319,096
Have you successfully used a GPGPU?
I am interested to know whether anyone has written an application that takes advantage of a GPGPU by using, for example, nVidia CUDA. If so, what issues did you find and what performance gains did you achieve compared with a standard CPU?
I have been doing gpgpu development with ATI's stream SDK instead of Cuda. What kind of performance gain you will get depends on a lot of factors, but the most important is the numeric intensity. (That is, the ratio of compute operations to memory references.) A BLAS level-1 or BLAS level-2 function like adding two vectors only does 1 math operation for each 3 memory references, so the NI is (1/3). This is always run slower with CAL or Cuda than just doing in on the cpu. The main reason is the time it takes to transfer the data from the cpu to the gpu and back. For a function like FFT, there are O(N log N) computations and O(N) memory references, so the NI is O(log N). If N is very large, say 1,000,000 it will likely be faster to do it on the gpu; If N is small, say 1,000 it will almost certainly be slower. For a BLAS level-3 or LAPACK function like LU decomposition of a matrix, or finding its eigenvalues, there are O( N^3) computations and O(N^2) memory references, so the NI is O(N). For very small arrays, say N is a few score, this will still be faster to do on the cpu, but as N increases, the algorithm very quickly goes from memory-bound to compute-bound and the performance increase on the gpu rises very quickly. Anything involving complex arithemetic has more computations than scalar arithmetic, which usually doubles the NI and increases gpu performance. (source: earthlink.net ) Here is the performance of CGEMM -- complex single precision matrix-matrix multiplication done on a Radeon 4870.
Have you successfully used a GPGPU? I am interested to know whether anyone has written an application that takes advantage of a GPGPU by using, for example, nVidia CUDA. If so, what issues did you find and what performance gains did you achieve compared with a standard CPU?
TITLE: Have you successfully used a GPGPU? QUESTION: I am interested to know whether anyone has written an application that takes advantage of a GPGPU by using, for example, nVidia CUDA. If so, what issues did you find and what performance gains did you achieve compared with a standard CPU? ANSWER: I have been doing gpgpu development with ATI's stream SDK instead of Cuda. What kind of performance gain you will get depends on a lot of factors, but the most important is the numeric intensity. (That is, the ratio of compute operations to memory references.) A BLAS level-1 or BLAS level-2 function like adding two vectors only does 1 math operation for each 3 memory references, so the NI is (1/3). This is always run slower with CAL or Cuda than just doing in on the cpu. The main reason is the time it takes to transfer the data from the cpu to the gpu and back. For a function like FFT, there are O(N log N) computations and O(N) memory references, so the NI is O(log N). If N is very large, say 1,000,000 it will likely be faster to do it on the gpu; If N is small, say 1,000 it will almost certainly be slower. For a BLAS level-3 or LAPACK function like LU decomposition of a matrix, or finding its eigenvalues, there are O( N^3) computations and O(N^2) memory references, so the NI is O(N). For very small arrays, say N is a few score, this will still be faster to do on the cpu, but as N increases, the algorithm very quickly goes from memory-bound to compute-bound and the performance increase on the gpu rises very quickly. Anything involving complex arithemetic has more computations than scalar arithmetic, which usually doubles the NI and increases gpu performance. (source: earthlink.net ) Here is the performance of CGEMM -- complex single precision matrix-matrix multiplication done on a Radeon 4870.
[ "cuda", "gpgpu", "hpc" ]
19
29
3,671
10
0
2008-09-10T21:59:23.363000
2008-11-25T22:18:40.460000
55,411
60,353
Path.GetTempFileName -- Directory name is invalid
Running into a problem where on certain servers we get an error that the directory name is invalid when using Path.GetTempFileName. Further investigation shows that it is trying to write a file to c:\Documents and Setting\computername\aspnet\local settings\temp (found by using Path.GetTempPath). This folder exists so I'm assuming this must be a permissions issue with respect to the asp.net account. I've been told by some that Path.GetTempFileName should be pointing to C:\Windows\Microsoft.NET\Framework\v2.0.50727\temporaryasp.net files. I've also been told that this problem may be due to the order in which IIS and.NET where installed on the server. I've done the typical 'aspnet_regiis -i' and checked security on the folders etc. At this point I'm stuck. Can anyone shed some light on this? **Update:**Turns out that providing 'IUSR_ComputerName' access to the folder does the trick. Is that the correct procedure? I don't seem to recall doing that in the past, and obviously, want to follow best practices to maintain security. This is, after all, part of a file upload process.
This is probably a combination of impersonation and a mismatch of different authentication methods occurring. There are many pieces; I'll try to go over them one by one. Impersonation is a technique to "temporarily" switch the user account under which a thread is running. Essentially, the thread briefly gains the same rights and access -- no more, no less -- as the account that is being impersonated. As soon as the thread is done creating the web page, it "reverts" back to the original account and gets ready for the next call. This technique is used to access resources that only the user logged into your web site has access to. Hold onto the concept for a minute. Now, by default ASP.NET runs a web site under a local account called ASPNET. Again, by default, only the ASPNET account and members of the Administrators group can write to that folder. Your temporary folder is under that account's purview. This is the second piece of the puzzle. Impersonation doesn't happen on its own. It needs to be turn on intentionally in your web.config. If the setting is missing or set to false, your code will execute pure and simply under the ASPNET account mentioned above. Given your error message, I'm positive that you have impersonation=true. There is nothing wrong with that! Impersonation has advantages and disadvantages that go beyond this discussion. There is one question left: when you use impersonation, which account gets impersonated? Unless you specify the account in the web.config ( full syntax of the identity element here ), the account impersonated is the one that the IIS handed over to ASP.NET. And that depends on how the user has authenticated (or not) into the site. That is your third and final piece. The IUSR_ComputerName account is a low-rights account created by IIS. By default, this account is the account under which a web call runs if the user could not be authenticated. That is, the user comes in as an "anonymous". In summary, this is what is happening to you: Your user is trying to access the web site, and IIS could not authenticate the person for some reason. Because Anonymous access is ON, (or you would not see IUSRComputerName accessing the temp folder), IIS allows the user in anyway, but as a generic user. Your ASP.NET code runs and impersonates this generic IUSR___ComputerName "guest" account; only now the code doesn't have access to the things that the ASPNET account had access to, including its own temporary folder. Granting IUSR_ComputerName WRITE access to the folder makes your symptoms go away. But that just the symptoms. You need to review why is the person coming as "Anonymous/Guest"? There are two likely scenarios: a) You intended to use IIS for authentication, but the authentication settings in IIS for some of your servers are wrong. In that case, you need to disable Anonymous access on those servers so that the usual authentication mechanisms take place. Note that you might still need to grant to your users access to that temporary folder, or use another folder instead, one to which your users already have access. I have worked with this scenario many times, and quite frankly it gives you less headaches to forgo the Temp folder; create a dedicated folder in the server, set the proper permissions, and set its location in web.config. b) You didn't want to authenticate people anyway, or you wanted to use ASP.NET Forms Authentication (which uses IIS's Anonymous access to bypass checks in IIS and lets ASP.NET handle the authentication directly) This case is a bit more complicated. You should go to IIS and disable all forms of authentication other than "Anonymous Access". Note that you can't do that in the developer's box, because the debugger needs Integrated Authentication to be enabled. So your debugging box will behave a bit different than the real server; just be aware of that. Then, you need to decide whether you should turn impersonation OFF, or conversely, to specify the account to impersonate in the web.config. Do the first if your web server doesn't need outside resources (like a database). Do the latter if your web site does need to run under an account that has access to a database (or some other outside resource). You have two more alternatives to specify the account to impersonate. One, you could go to IIS and change the "anonymous" account to be one with access to the resource instead of the one IIS manages for you. The second alternative is to stash the account and password encrypted in the registry. That step is a bit complicated and also goes beyond the scope of this discussion. Good luck!
Path.GetTempFileName -- Directory name is invalid Running into a problem where on certain servers we get an error that the directory name is invalid when using Path.GetTempFileName. Further investigation shows that it is trying to write a file to c:\Documents and Setting\computername\aspnet\local settings\temp (found by using Path.GetTempPath). This folder exists so I'm assuming this must be a permissions issue with respect to the asp.net account. I've been told by some that Path.GetTempFileName should be pointing to C:\Windows\Microsoft.NET\Framework\v2.0.50727\temporaryasp.net files. I've also been told that this problem may be due to the order in which IIS and.NET where installed on the server. I've done the typical 'aspnet_regiis -i' and checked security on the folders etc. At this point I'm stuck. Can anyone shed some light on this? **Update:**Turns out that providing 'IUSR_ComputerName' access to the folder does the trick. Is that the correct procedure? I don't seem to recall doing that in the past, and obviously, want to follow best practices to maintain security. This is, after all, part of a file upload process.
TITLE: Path.GetTempFileName -- Directory name is invalid QUESTION: Running into a problem where on certain servers we get an error that the directory name is invalid when using Path.GetTempFileName. Further investigation shows that it is trying to write a file to c:\Documents and Setting\computername\aspnet\local settings\temp (found by using Path.GetTempPath). This folder exists so I'm assuming this must be a permissions issue with respect to the asp.net account. I've been told by some that Path.GetTempFileName should be pointing to C:\Windows\Microsoft.NET\Framework\v2.0.50727\temporaryasp.net files. I've also been told that this problem may be due to the order in which IIS and.NET where installed on the server. I've done the typical 'aspnet_regiis -i' and checked security on the folders etc. At this point I'm stuck. Can anyone shed some light on this? **Update:**Turns out that providing 'IUSR_ComputerName' access to the folder does the trick. Is that the correct procedure? I don't seem to recall doing that in the past, and obviously, want to follow best practices to maintain security. This is, after all, part of a file upload process. ANSWER: This is probably a combination of impersonation and a mismatch of different authentication methods occurring. There are many pieces; I'll try to go over them one by one. Impersonation is a technique to "temporarily" switch the user account under which a thread is running. Essentially, the thread briefly gains the same rights and access -- no more, no less -- as the account that is being impersonated. As soon as the thread is done creating the web page, it "reverts" back to the original account and gets ready for the next call. This technique is used to access resources that only the user logged into your web site has access to. Hold onto the concept for a minute. Now, by default ASP.NET runs a web site under a local account called ASPNET. Again, by default, only the ASPNET account and members of the Administrators group can write to that folder. Your temporary folder is under that account's purview. This is the second piece of the puzzle. Impersonation doesn't happen on its own. It needs to be turn on intentionally in your web.config. If the setting is missing or set to false, your code will execute pure and simply under the ASPNET account mentioned above. Given your error message, I'm positive that you have impersonation=true. There is nothing wrong with that! Impersonation has advantages and disadvantages that go beyond this discussion. There is one question left: when you use impersonation, which account gets impersonated? Unless you specify the account in the web.config ( full syntax of the identity element here ), the account impersonated is the one that the IIS handed over to ASP.NET. And that depends on how the user has authenticated (or not) into the site. That is your third and final piece. The IUSR_ComputerName account is a low-rights account created by IIS. By default, this account is the account under which a web call runs if the user could not be authenticated. That is, the user comes in as an "anonymous". In summary, this is what is happening to you: Your user is trying to access the web site, and IIS could not authenticate the person for some reason. Because Anonymous access is ON, (or you would not see IUSRComputerName accessing the temp folder), IIS allows the user in anyway, but as a generic user. Your ASP.NET code runs and impersonates this generic IUSR___ComputerName "guest" account; only now the code doesn't have access to the things that the ASPNET account had access to, including its own temporary folder. Granting IUSR_ComputerName WRITE access to the folder makes your symptoms go away. But that just the symptoms. You need to review why is the person coming as "Anonymous/Guest"? There are two likely scenarios: a) You intended to use IIS for authentication, but the authentication settings in IIS for some of your servers are wrong. In that case, you need to disable Anonymous access on those servers so that the usual authentication mechanisms take place. Note that you might still need to grant to your users access to that temporary folder, or use another folder instead, one to which your users already have access. I have worked with this scenario many times, and quite frankly it gives you less headaches to forgo the Temp folder; create a dedicated folder in the server, set the proper permissions, and set its location in web.config. b) You didn't want to authenticate people anyway, or you wanted to use ASP.NET Forms Authentication (which uses IIS's Anonymous access to bypass checks in IIS and lets ASP.NET handle the authentication directly) This case is a bit more complicated. You should go to IIS and disable all forms of authentication other than "Anonymous Access". Note that you can't do that in the developer's box, because the debugger needs Integrated Authentication to be enabled. So your debugging box will behave a bit different than the real server; just be aware of that. Then, you need to decide whether you should turn impersonation OFF, or conversely, to specify the account to impersonate in the web.config. Do the first if your web server doesn't need outside resources (like a database). Do the latter if your web site does need to run under an account that has access to a database (or some other outside resource). You have two more alternatives to specify the account to impersonate. One, you could go to IIS and change the "anonymous" account to be one with access to the resource instead of the one IIS manages for you. The second alternative is to stash the account and password encrypted in the registry. That step is a bit complicated and also goes beyond the scope of this discussion. Good luck!
[ "c#", "asp.net", "iis" ]
10
18
14,142
5
0
2008-09-10T22:06:40.477000
2008-09-13T05:56:29.970000
55,414
82,710
ASP.NET MVC versus the Zeitgeist
ASP.NET MVC seems to be making a pretty big entrance. Can anyone summarize how its MVC implementation stacks up against popular MVC frameworks for other languages? (I'm thinking specifically of Rails and Zend Framework, though there are obviously lots.) Observations on learning curve, common terminology, ease of use and feelgood factor welcome. (For the sake of a little background, I've been avoiding using ASP.NET for some time because I really hate the webforms approach, but Jeff's prolific praise on the podcast has almost convinced me to give it a go.)
I'm just getting into ASP.NET MVC, so these are some early thoughts comparing it to Rails: Mostly manages to stick with static typing, at the expense of a little extra code. This will either give you the warm fuzzies or make you feel slightly shackled depending on how you feel about dynamic typing. For instance, you can have your views expect particular typed data (and so get compile-time checking of your views). Better separation of bits of the framework. So there's no prescribed data access mechanism such as ActiveRecord in Rails; you're free to choose your own. LINQ feels similar if you want something cheap, if a bit more verbose. You can use the non-WebForms parts of ASP.NET like caching and authentication. Still playing feature catch-up. Preview 5 brought AcceptVerbs, model updaters (similar to Ruby's hash.merge) and more ways to bind forms to models. Feels like there's still more to come before they check off most of the feature set that Rails has. I'm still missing a little of Rails' freedom and elegance (much of which is down to Ruby, I guess), but ASP.NET MVC really does feel quite close.
ASP.NET MVC versus the Zeitgeist ASP.NET MVC seems to be making a pretty big entrance. Can anyone summarize how its MVC implementation stacks up against popular MVC frameworks for other languages? (I'm thinking specifically of Rails and Zend Framework, though there are obviously lots.) Observations on learning curve, common terminology, ease of use and feelgood factor welcome. (For the sake of a little background, I've been avoiding using ASP.NET for some time because I really hate the webforms approach, but Jeff's prolific praise on the podcast has almost convinced me to give it a go.)
TITLE: ASP.NET MVC versus the Zeitgeist QUESTION: ASP.NET MVC seems to be making a pretty big entrance. Can anyone summarize how its MVC implementation stacks up against popular MVC frameworks for other languages? (I'm thinking specifically of Rails and Zend Framework, though there are obviously lots.) Observations on learning curve, common terminology, ease of use and feelgood factor welcome. (For the sake of a little background, I've been avoiding using ASP.NET for some time because I really hate the webforms approach, but Jeff's prolific praise on the podcast has almost convinced me to give it a go.) ANSWER: I'm just getting into ASP.NET MVC, so these are some early thoughts comparing it to Rails: Mostly manages to stick with static typing, at the expense of a little extra code. This will either give you the warm fuzzies or make you feel slightly shackled depending on how you feel about dynamic typing. For instance, you can have your views expect particular typed data (and so get compile-time checking of your views). Better separation of bits of the framework. So there's no prescribed data access mechanism such as ActiveRecord in Rails; you're free to choose your own. LINQ feels similar if you want something cheap, if a bit more verbose. You can use the non-WebForms parts of ASP.NET like caching and authentication. Still playing feature catch-up. Preview 5 brought AcceptVerbs, model updaters (similar to Ruby's hash.merge) and more ways to bind forms to models. Feels like there's still more to come before they check off most of the feature set that Rails has. I'm still missing a little of Rails' freedom and elegance (much of which is down to Ruby, I guess), but ASP.NET MVC really does feel quite close.
[ "asp.net-mvc", "model-view-controller", "zend-framework" ]
5
7
635
2
0
2008-09-10T22:11:24.583000
2008-09-17T12:42:58.790000
55,434
55,445
How to parse relative time?
This question is the other side of the question asking, " How do I calculate relative time? ". Given some human input for a relative time, how can you parse it? By default you would offset from DateTime.Now(), but could optionally offset from another DateTime. (Prefer answers in C#) Example input: "in 20 minutes" "5 hours ago" "3h 2m" "next week" Edit: Let's suppose we can define some limits on the input. This sort of code would be a useful thing to have out on the web.
That's building a DSL (Domain specific language) for date handling. I don't know if somebody has done one for.NET but the construction of a DSL is fairly straightforward: Define the language precisely, which input forms you will accept and what will you do with ambiguities Construct the grammar for the language Build the finite state machine that parses your language into an actionable AST You can do all that by yourself (with the help of the Dragon Book, for instance) or with the help of tools to the effect, as shown in this link. Just by thinking hard about the possibilities you have a good chance, with the help of good UI examples, of covering more than half of the actual inputs your application will receive. If you aim to accept everything a human could possibly type, you can record the input determined as ambiguous and then add them to the grammar, whenever they can be interpreted, as there are things that will be inherently ambiguous.
How to parse relative time? This question is the other side of the question asking, " How do I calculate relative time? ". Given some human input for a relative time, how can you parse it? By default you would offset from DateTime.Now(), but could optionally offset from another DateTime. (Prefer answers in C#) Example input: "in 20 minutes" "5 hours ago" "3h 2m" "next week" Edit: Let's suppose we can define some limits on the input. This sort of code would be a useful thing to have out on the web.
TITLE: How to parse relative time? QUESTION: This question is the other side of the question asking, " How do I calculate relative time? ". Given some human input for a relative time, how can you parse it? By default you would offset from DateTime.Now(), but could optionally offset from another DateTime. (Prefer answers in C#) Example input: "in 20 minutes" "5 hours ago" "3h 2m" "next week" Edit: Let's suppose we can define some limits on the input. This sort of code would be a useful thing to have out on the web. ANSWER: That's building a DSL (Domain specific language) for date handling. I don't know if somebody has done one for.NET but the construction of a DSL is fairly straightforward: Define the language precisely, which input forms you will accept and what will you do with ambiguities Construct the grammar for the language Build the finite state machine that parses your language into an actionable AST You can do all that by yourself (with the help of the Dragon Book, for instance) or with the help of tools to the effect, as shown in this link. Just by thinking hard about the possibilities you have a good chance, with the help of good UI examples, of covering more than half of the actual inputs your application will receive. If you aim to accept everything a human could possibly type, you can record the input determined as ambiguous and then add them to the grammar, whenever they can be interpreted, as there are things that will be inherently ambiguous.
[ "c#", "parsing", "time", "language-agnostic" ]
12
3
2,640
5
0
2008-09-10T22:27:51.143000
2008-09-10T22:39:07.120000
55,437
55,441
Using Microsoft's Application Blocks
I haven't done a lot of.NET programming, but I've examined a few of the application blocks published by Microsoft's Patterns and Practices group. I was wondering how these are typically used: Linked directly into applications Source added into applications and built with them, perhaps with some customization's Sample code used as reference while writing application-specific code I'm sure all three of these usages are common, but what are the most typical usage patterns? Are there a few particular application blocks that are used by "everyone?" Note: This question is related to, but not the same as Enterprise Library Application Blocks OR Home Grown Framework?.
I usually put the source into my project, and then I can get better intellisense (and a better understanding of them). I don't tend to customize them at all though. I like to have them stock so I can just distribute the stock binaries anytime I need them.
Using Microsoft's Application Blocks I haven't done a lot of.NET programming, but I've examined a few of the application blocks published by Microsoft's Patterns and Practices group. I was wondering how these are typically used: Linked directly into applications Source added into applications and built with them, perhaps with some customization's Sample code used as reference while writing application-specific code I'm sure all three of these usages are common, but what are the most typical usage patterns? Are there a few particular application blocks that are used by "everyone?" Note: This question is related to, but not the same as Enterprise Library Application Blocks OR Home Grown Framework?.
TITLE: Using Microsoft's Application Blocks QUESTION: I haven't done a lot of.NET programming, but I've examined a few of the application blocks published by Microsoft's Patterns and Practices group. I was wondering how these are typically used: Linked directly into applications Source added into applications and built with them, perhaps with some customization's Sample code used as reference while writing application-specific code I'm sure all three of these usages are common, but what are the most typical usage patterns? Are there a few particular application blocks that are used by "everyone?" Note: This question is related to, but not the same as Enterprise Library Application Blocks OR Home Grown Framework?. ANSWER: I usually put the source into my project, and then I can get better intellisense (and a better understanding of them). I don't tend to customize them at all though. I like to have them stock so I can just distribute the stock binaries anytime I need them.
[ ".net", "design-patterns", "application-blocks" ]
4
2
2,074
6
0
2008-09-10T22:30:38.217000
2008-09-10T22:35:48.190000
55,440
55,446
Checking Inheritance with templates in C++
I've a class which is a wrapper class(serves as a common interface) around another class implementing the functionality required. So my code looks like this. template class WrapperClass { // the code goes here } Now, how do I make sure that ImplementationClass can be derived from a set of classes only, similar to java's generics syntax?
It's verbose, but you can do it like this: #include #include struct base {}; template class WrapperClass; template class WrapperClass >::type> {}; struct derived: base {}; struct not_derived {}; int main() { WrapperClass x; // Compile error here: WrapperClass y; } This requires a compiler with good support for the standard (most recent compilers should be fine but old versions of Visual C++ won't be). For more information, see the Boost.Enable_If documentation. As Ferruccio said, a simpler but less powerful implementation: #include #include struct base {}; template class WrapperClass { BOOST_STATIC_ASSERT(( boost::is_base_of::value)); };
Checking Inheritance with templates in C++ I've a class which is a wrapper class(serves as a common interface) around another class implementing the functionality required. So my code looks like this. template class WrapperClass { // the code goes here } Now, how do I make sure that ImplementationClass can be derived from a set of classes only, similar to java's generics syntax?
TITLE: Checking Inheritance with templates in C++ QUESTION: I've a class which is a wrapper class(serves as a common interface) around another class implementing the functionality required. So my code looks like this. template class WrapperClass { // the code goes here } Now, how do I make sure that ImplementationClass can be derived from a set of classes only, similar to java's generics syntax? ANSWER: It's verbose, but you can do it like this: #include #include struct base {}; template class WrapperClass; template class WrapperClass >::type> {}; struct derived: base {}; struct not_derived {}; int main() { WrapperClass x; // Compile error here: WrapperClass y; } This requires a compiler with good support for the standard (most recent compilers should be fine but old versions of Visual C++ won't be). For more information, see the Boost.Enable_If documentation. As Ferruccio said, a simpler but less powerful implementation: #include #include struct base {}; template class WrapperClass { BOOST_STATIC_ASSERT(( boost::is_base_of::value)); };
[ "java", "c++", "templates" ]
2
7
654
3
0
2008-09-10T22:35:06.913000
2008-09-10T22:43:38.140000
55,448
55,476
What’s the best approach when migrating legacy projects across versions of visual studio?
I've been thinking about the number of projects we have in-house that are still being developed using visual studio 6 and how best to migrate them forward onto visual studio 2008. The projects range in flavours of C/C++ and VB. Is it better to let VS2008 convert the work-spaces into solutions, fix any compile errors and be on your merry way? Or, is it better to start with a clean solution and migrate code across project by project discarding dead code along the way?
The Microsoft p&p team has recommended some strategies that answers this. Basically they recommend something like the project by project approach you mention. Of course, they're assuming a neatly architected application that has no nasty, dark corners from which late nights of coding and copious amounts of coffee spring from. It doesn't hurt to let VS2008 convert the project for you and see how much effort is required to fix the errors.
What’s the best approach when migrating legacy projects across versions of visual studio? I've been thinking about the number of projects we have in-house that are still being developed using visual studio 6 and how best to migrate them forward onto visual studio 2008. The projects range in flavours of C/C++ and VB. Is it better to let VS2008 convert the work-spaces into solutions, fix any compile errors and be on your merry way? Or, is it better to start with a clean solution and migrate code across project by project discarding dead code along the way?
TITLE: What’s the best approach when migrating legacy projects across versions of visual studio? QUESTION: I've been thinking about the number of projects we have in-house that are still being developed using visual studio 6 and how best to migrate them forward onto visual studio 2008. The projects range in flavours of C/C++ and VB. Is it better to let VS2008 convert the work-spaces into solutions, fix any compile errors and be on your merry way? Or, is it better to start with a clean solution and migrate code across project by project discarding dead code along the way? ANSWER: The Microsoft p&p team has recommended some strategies that answers this. Basically they recommend something like the project by project approach you mention. Of course, they're assuming a neatly architected application that has no nasty, dark corners from which late nights of coding and copious amounts of coffee spring from. It doesn't hurt to let VS2008 convert the project for you and see how much effort is required to fix the errors.
[ "visual-studio", "migration", "legacy" ]
4
3
287
2
0
2008-09-10T22:45:20.367000
2008-09-10T23:09:39.887000
55,449
55,509
Can you "ignore" a file in Perforce?
I sometimes use the feature 'Reconcile Offline Work...' found in Perforce's P4V IDE to sync up any files that I have been working on while disconnected from the P4 depot. It launches another window that performs a 'Folder Diff'. I have files I never want to check in to source control (like ones found in bin folder such as DLLs, code generated output, etc.) Is there a way to filter those files/folders out from appearing as "new" that might be added. They tend to clutter up the list of files that I am actually interested in. Does P4 have the equivalent of Subversion's 'ignore file' feature?
As of version 2012.1, Perforce supports the P4IGNORE environment variable. I updated my answer to this question about ignoring directories with an explanation of how it works. Then I noticed this answer, which is now superfluous I guess. Assuming you have a client named "CLIENT", a directory named "foo" (located at your project root), and you wish to ignore all.dll files in that directory tree, you can add the following lines to your workspace view to accomplish this: -//depot/foo/*.dll //CLIENT/foo/*.dll -//depot/foo/.../*.dll //CLIENT/foo/.../*.dll The first line removes them from the directory "foo" and the second line removes them from all sub directories. Now, when you 'Reconcile Offline Work...', all the.dll files will be moved into "Excluded Files" folders at the bottom of the folder diff display. They will be out of your way, but can still view and manipulate them if you really need to. You can also do it another way, which will reduce your "Excluded Files" folder to just one, but you won't be able to manipulate any of the files it contains because the path will be corrupt (but if you just want them out of your way, it doesn't matter). -//depot/foo.../*.dll //CLIENT/foo.../*.dll
Can you "ignore" a file in Perforce? I sometimes use the feature 'Reconcile Offline Work...' found in Perforce's P4V IDE to sync up any files that I have been working on while disconnected from the P4 depot. It launches another window that performs a 'Folder Diff'. I have files I never want to check in to source control (like ones found in bin folder such as DLLs, code generated output, etc.) Is there a way to filter those files/folders out from appearing as "new" that might be added. They tend to clutter up the list of files that I am actually interested in. Does P4 have the equivalent of Subversion's 'ignore file' feature?
TITLE: Can you "ignore" a file in Perforce? QUESTION: I sometimes use the feature 'Reconcile Offline Work...' found in Perforce's P4V IDE to sync up any files that I have been working on while disconnected from the P4 depot. It launches another window that performs a 'Folder Diff'. I have files I never want to check in to source control (like ones found in bin folder such as DLLs, code generated output, etc.) Is there a way to filter those files/folders out from appearing as "new" that might be added. They tend to clutter up the list of files that I am actually interested in. Does P4 have the equivalent of Subversion's 'ignore file' feature? ANSWER: As of version 2012.1, Perforce supports the P4IGNORE environment variable. I updated my answer to this question about ignoring directories with an explanation of how it works. Then I noticed this answer, which is now superfluous I guess. Assuming you have a client named "CLIENT", a directory named "foo" (located at your project root), and you wish to ignore all.dll files in that directory tree, you can add the following lines to your workspace view to accomplish this: -//depot/foo/*.dll //CLIENT/foo/*.dll -//depot/foo/.../*.dll //CLIENT/foo/.../*.dll The first line removes them from the directory "foo" and the second line removes them from all sub directories. Now, when you 'Reconcile Offline Work...', all the.dll files will be moved into "Excluded Files" folders at the bottom of the folder diff display. They will be out of your way, but can still view and manipulate them if you really need to. You can also do it another way, which will reduce your "Excluded Files" folder to just one, but you won't be able to manipulate any of the files it contains because the path will be corrupt (but if you just want them out of your way, it doesn't matter). -//depot/foo.../*.dll //CLIENT/foo.../*.dll
[ "version-control", "perforce", "ignore" ]
104
60
64,153
11
0
2008-09-10T22:45:31.193000
2008-09-10T23:48:48.123000
55,451
55,477
Which C# project type would you use to redevelop a MFC C++ activex control?
Looking at the C# project templates in VS2008 and the offerings are WPF User Control Library, WPF Custom Control Library and Windows Forms Control Library. Which of these would you use if you wanted to move a legacy active control written in c++ into the world of C# and.NET?
It sounds like you are trying to do several different things all at once: Migrate your code to building in a newer version of visual studio. Migrate your use of technology to a newer technology (ActiveX to.net) Migrate your language (c++ to c#). If you have a small codebase you are probably as well to start from scratch and port functionality into the new codebase as required. For a larger codebase you need to realize that this is an expensive task both in effort and defect rate. An order might be: Import your code into the newer version of visual studio. Get it compiling. Review the project settings for each project. Refactor your code to isolate the mfc and activex code as much as possible. Follow good refactoring practices especially if don't have many unit tests before you start. Consider replacing your ActiveX layer with.net. Consider which GUI toolkit is best for replacing MFC. Language - consider moving first to managed c++. Consider moving from managed c++ to c#. Most importantly be able to justify doing all of the above!
Which C# project type would you use to redevelop a MFC C++ activex control? Looking at the C# project templates in VS2008 and the offerings are WPF User Control Library, WPF Custom Control Library and Windows Forms Control Library. Which of these would you use if you wanted to move a legacy active control written in c++ into the world of C# and.NET?
TITLE: Which C# project type would you use to redevelop a MFC C++ activex control? QUESTION: Looking at the C# project templates in VS2008 and the offerings are WPF User Control Library, WPF Custom Control Library and Windows Forms Control Library. Which of these would you use if you wanted to move a legacy active control written in c++ into the world of C# and.NET? ANSWER: It sounds like you are trying to do several different things all at once: Migrate your code to building in a newer version of visual studio. Migrate your use of technology to a newer technology (ActiveX to.net) Migrate your language (c++ to c#). If you have a small codebase you are probably as well to start from scratch and port functionality into the new codebase as required. For a larger codebase you need to realize that this is an expensive task both in effort and defect rate. An order might be: Import your code into the newer version of visual studio. Get it compiling. Review the project settings for each project. Refactor your code to isolate the mfc and activex code as much as possible. Follow good refactoring practices especially if don't have many unit tests before you start. Consider replacing your ActiveX layer with.net. Consider which GUI toolkit is best for replacing MFC. Language - consider moving first to managed c++. Consider moving from managed c++ to c#. Most importantly be able to justify doing all of the above!
[ "c#", "c++", "visual-studio", "code-migration" ]
0
2
453
3
0
2008-09-10T22:47:35.650000
2008-09-10T23:10:50.900000
55,460
55,528
What is the possible mimetype hierarchy of an email message?
I'm working with a snippet of code that recursively calls itself and tries to pull out a MIME Type part of text/html from an email (if it exists) for further processing. The "text/html" could exist inside other content such as multipart/alternative, so I'm trying to find out if there is a defined hierarchy for email MIME Types. Anybody know if there is and what it is? i.e. what types can parent other types?
In theory, only multipart/ and message/ can parent other types (per RFC2046).
What is the possible mimetype hierarchy of an email message? I'm working with a snippet of code that recursively calls itself and tries to pull out a MIME Type part of text/html from an email (if it exists) for further processing. The "text/html" could exist inside other content such as multipart/alternative, so I'm trying to find out if there is a defined hierarchy for email MIME Types. Anybody know if there is and what it is? i.e. what types can parent other types?
TITLE: What is the possible mimetype hierarchy of an email message? QUESTION: I'm working with a snippet of code that recursively calls itself and tries to pull out a MIME Type part of text/html from an email (if it exists) for further processing. The "text/html" could exist inside other content such as multipart/alternative, so I'm trying to find out if there is a defined hierarchy for email MIME Types. Anybody know if there is and what it is? i.e. what types can parent other types? ANSWER: In theory, only multipart/ and message/ can parent other types (per RFC2046).
[ "mime-types", "html-email", "email", "email-validation" ]
0
1
409
2
0
2008-09-10T22:57:22.647000
2008-09-11T00:03:34.190000
55,463
55,475
Should I use one big SQL Select statement or several small ones?
I'm building a PHP page with data sent from MySQL. Is it better to have 1 SELECT query with 4 table joins, or 4 small SELECT queries with no table join; I do select from an ID Which is faster and what is the pro/con of each method? I only need one row from each tables.
You should run a profiling tool if you're truly worried cause it depends on many things and it can vary but as a rule its better to have fewer queries being compiled and fewer round trips to the database. Make sure you filter things as well as you can using your where and join on clauses. But honestly, it usually doesn't matter since you're probably not going to be hit all that hard compared to what the database can do, so unless optimization is your spec you should not do it prematurely and do whats simplest.
Should I use one big SQL Select statement or several small ones? I'm building a PHP page with data sent from MySQL. Is it better to have 1 SELECT query with 4 table joins, or 4 small SELECT queries with no table join; I do select from an ID Which is faster and what is the pro/con of each method? I only need one row from each tables.
TITLE: Should I use one big SQL Select statement or several small ones? QUESTION: I'm building a PHP page with data sent from MySQL. Is it better to have 1 SELECT query with 4 table joins, or 4 small SELECT queries with no table join; I do select from an ID Which is faster and what is the pro/con of each method? I only need one row from each tables. ANSWER: You should run a profiling tool if you're truly worried cause it depends on many things and it can vary but as a rule its better to have fewer queries being compiled and fewer round trips to the database. Make sure you filter things as well as you can using your where and join on clauses. But honestly, it usually doesn't matter since you're probably not going to be hit all that hard compared to what the database can do, so unless optimization is your spec you should not do it prematurely and do whats simplest.
[ "php", "mysql", "performance", "optimization" ]
18
20
17,558
7
0
2008-09-10T23:02:40.653000
2008-09-10T23:08:36.490000
55,482
57,801
Uninstall Command Fails Only in Release Mode
I'm able to successfully uninstall a third-party application via the command line and via a custom Inno Setup installer. Command line Execution: MSIEXEC.exe /x {14D74337-01C2-4F8F-B44B-67FC613E5B1F} /qn Inno Setup Command: [Run] Filename: msiexec.exe; Flags: runhidden waituntilterminated; Parameters: "/x {{14D74337-01C2-4F8F-B44B-67FC613E5B1F} /qn"; StatusMsg: "Uninstalling Service..."; I am also able to uninstall the application programmatically when executing the following C# code in debug mode. C# Code: string fileName = "MSIEXEC.exe"; string arguments = "/x {14D74337-01C2-4F8F-B44B-67FC613E5B1F} /qn"; ProcessStartInfo psi = new ProcessStartInfo(fileName, arguments) { CreateNoWindow = true, UseShellExecute = false, RedirectStandardOutput = true }; Process process = Process.Start(psi); string errorMsg = process.StandardOutput.ReadToEnd(); process.WaitForExit(); The same C# code, however, produces the following failure output when run as a compiled, deployed Windows Service: "This action is only valid for products that are currently installed." Additional Comments: The Windows Service which is issuing the uninstall command is running on the same machine as the code being tested in Debug Mode. The Windows Service is running/logged on as the Local system account. I have consulted my application logs and I have validated that the executed command arguments are thhe same in both debug and release mode. I have consulted the Event Viewer but it doesn't offer any clues. Thoughts? Any help would be greatly appreciated. Thanks.
Thanks to those offering help. This appears to be a permissions issue. I have updated my service to run under an Administrator account and it was able to successfully uninstall the third-party application. To Orion's point, though the Local System account is a powerful account that has full access to the system -- http://technet.microsoft.com/en-us/library/cc782435.aspx -- it doesn't seem to have the necessary rights to perform the uninstall. [See additional comments for full story regarding the LocalSystem being able to uninstall application for which it installed.]
Uninstall Command Fails Only in Release Mode I'm able to successfully uninstall a third-party application via the command line and via a custom Inno Setup installer. Command line Execution: MSIEXEC.exe /x {14D74337-01C2-4F8F-B44B-67FC613E5B1F} /qn Inno Setup Command: [Run] Filename: msiexec.exe; Flags: runhidden waituntilterminated; Parameters: "/x {{14D74337-01C2-4F8F-B44B-67FC613E5B1F} /qn"; StatusMsg: "Uninstalling Service..."; I am also able to uninstall the application programmatically when executing the following C# code in debug mode. C# Code: string fileName = "MSIEXEC.exe"; string arguments = "/x {14D74337-01C2-4F8F-B44B-67FC613E5B1F} /qn"; ProcessStartInfo psi = new ProcessStartInfo(fileName, arguments) { CreateNoWindow = true, UseShellExecute = false, RedirectStandardOutput = true }; Process process = Process.Start(psi); string errorMsg = process.StandardOutput.ReadToEnd(); process.WaitForExit(); The same C# code, however, produces the following failure output when run as a compiled, deployed Windows Service: "This action is only valid for products that are currently installed." Additional Comments: The Windows Service which is issuing the uninstall command is running on the same machine as the code being tested in Debug Mode. The Windows Service is running/logged on as the Local system account. I have consulted my application logs and I have validated that the executed command arguments are thhe same in both debug and release mode. I have consulted the Event Viewer but it doesn't offer any clues. Thoughts? Any help would be greatly appreciated. Thanks.
TITLE: Uninstall Command Fails Only in Release Mode QUESTION: I'm able to successfully uninstall a third-party application via the command line and via a custom Inno Setup installer. Command line Execution: MSIEXEC.exe /x {14D74337-01C2-4F8F-B44B-67FC613E5B1F} /qn Inno Setup Command: [Run] Filename: msiexec.exe; Flags: runhidden waituntilterminated; Parameters: "/x {{14D74337-01C2-4F8F-B44B-67FC613E5B1F} /qn"; StatusMsg: "Uninstalling Service..."; I am also able to uninstall the application programmatically when executing the following C# code in debug mode. C# Code: string fileName = "MSIEXEC.exe"; string arguments = "/x {14D74337-01C2-4F8F-B44B-67FC613E5B1F} /qn"; ProcessStartInfo psi = new ProcessStartInfo(fileName, arguments) { CreateNoWindow = true, UseShellExecute = false, RedirectStandardOutput = true }; Process process = Process.Start(psi); string errorMsg = process.StandardOutput.ReadToEnd(); process.WaitForExit(); The same C# code, however, produces the following failure output when run as a compiled, deployed Windows Service: "This action is only valid for products that are currently installed." Additional Comments: The Windows Service which is issuing the uninstall command is running on the same machine as the code being tested in Debug Mode. The Windows Service is running/logged on as the Local system account. I have consulted my application logs and I have validated that the executed command arguments are thhe same in both debug and release mode. I have consulted the Event Viewer but it doesn't offer any clues. Thoughts? Any help would be greatly appreciated. Thanks. ANSWER: Thanks to those offering help. This appears to be a permissions issue. I have updated my service to run under an Administrator account and it was able to successfully uninstall the third-party application. To Orion's point, though the Local System account is a powerful account that has full access to the system -- http://technet.microsoft.com/en-us/library/cc782435.aspx -- it doesn't seem to have the necessary rights to perform the uninstall. [See additional comments for full story regarding the LocalSystem being able to uninstall application for which it installed.]
[ "c#", "installation", "service" ]
4
2
1,510
5
0
2008-09-10T23:16:32.867000
2008-09-11T22:24:15.837000
55,487
55,582
Find the settings JNDI is using for error reporting
I've got a J2SE application that I am maintaining uses JNDI. (It uses JNDI to find it's J2EE application server.) It has pretty poor error reporting of failure to find the JNDI server. I've been looking around fora way to display which server the InitialContext is trying to talk to. Has anyone got a neat way to do this?
Reporting the value for InitialContext.getEnvironment().get(Context.PROVIDER_URL) might be helpful.
Find the settings JNDI is using for error reporting I've got a J2SE application that I am maintaining uses JNDI. (It uses JNDI to find it's J2EE application server.) It has pretty poor error reporting of failure to find the JNDI server. I've been looking around fora way to display which server the InitialContext is trying to talk to. Has anyone got a neat way to do this?
TITLE: Find the settings JNDI is using for error reporting QUESTION: I've got a J2SE application that I am maintaining uses JNDI. (It uses JNDI to find it's J2EE application server.) It has pretty poor error reporting of failure to find the JNDI server. I've been looking around fora way to display which server the InitialContext is trying to talk to. Has anyone got a neat way to do this? ANSWER: Reporting the value for InitialContext.getEnvironment().get(Context.PROVIDER_URL) might be helpful.
[ "java", "jndi" ]
1
1
168
1
0
2008-09-10T23:27:17.880000
2008-09-11T00:54:43.333000
55,502
55,507
Return collection as read-only
I have an object in a multi-threaded environment that maintains a collection of information, e.g.: public IList Data { get { return data; } } I currently have return data; wrapped by a ReaderWriterLockSlim to protect the collection from sharing violations. However, to be doubly sure, I'd like to return the collection as read-only, so that the calling code is unable to make changes to the collection, only view what's already there. Is this at all possible?
If your underlying data is stored as list you can use List(T).AsReadOnly method. If your data can be enumerated, you can use Enumerable.ToList method to cast your collection to List and call AsReadOnly on it.
Return collection as read-only I have an object in a multi-threaded environment that maintains a collection of information, e.g.: public IList Data { get { return data; } } I currently have return data; wrapped by a ReaderWriterLockSlim to protect the collection from sharing violations. However, to be doubly sure, I'd like to return the collection as read-only, so that the calling code is unable to make changes to the collection, only view what's already there. Is this at all possible?
TITLE: Return collection as read-only QUESTION: I have an object in a multi-threaded environment that maintains a collection of information, e.g.: public IList Data { get { return data; } } I currently have return data; wrapped by a ReaderWriterLockSlim to protect the collection from sharing violations. However, to be doubly sure, I'd like to return the collection as read-only, so that the calling code is unable to make changes to the collection, only view what's already there. Is this at all possible? ANSWER: If your underlying data is stored as list you can use List(T).AsReadOnly method. If your data can be enumerated, you can use Enumerable.ToList method to cast your collection to List and call AsReadOnly on it.
[ "c#", ".net", "multithreading", "collections", "concurrency" ]
22
33
26,603
7
0
2008-09-10T23:43:35.577000
2008-09-10T23:47:57.783000
55,503
55,575
How do I logout of multiple asp.net applications?
I have a main asp.net app, which is written in asp.net 1.1. Runnning underneath the application are several 2.0 apps. To completely logout a user can I just logout of the 1.1 app with FormsAuthentication.SignOut or is it more complicated than that?
What you are looking to do is called Single Sign On and Single Sign Off. There are differences based on how you have the applications set up. I will try to clarify where those differences come into play. To implement single sign on and single sign off you need to make the cookie name, protection, and path attributes the same between all the applications. Next you need to add the machine keys and they need to be the same between all your applications. Are you using second or third level domains for the applications? If so you will need to do a little bit more by adding the domain to the cookie: protected void Login(string userName, string password) { System.Web.HttpCookie cookie = FormsAuthentication.GetAuthCookie(userName, False); cookie.Domain = "domain1.com"; cookie.Expires = DateTime.Now.AddDays(30); Response.AppendCookie(cookie); } Now to do single sign off, calling FormsAuthentication.SignOut may not be enough. The next best thing is to set the cookie expiration to a past date. This will ensure that the cookie will not be used again for authentication. protected void Logout(string userName) { System.Web.HttpCookie cookie = FormsAuthentication.GetAuthCookie(userName, False); cookie.Domain = "domain1.com"; cookie.Expires = DateTime.Now.AddDays(-1); Response.AppendCookie(cookie); } I am taking into consideration you are using the same database for all the applications. If the applications use a separate database for registration and authentication, then we will need to do some more. Just let me know if this is the case. Otherwise this should work for you.
How do I logout of multiple asp.net applications? I have a main asp.net app, which is written in asp.net 1.1. Runnning underneath the application are several 2.0 apps. To completely logout a user can I just logout of the 1.1 app with FormsAuthentication.SignOut or is it more complicated than that?
TITLE: How do I logout of multiple asp.net applications? QUESTION: I have a main asp.net app, which is written in asp.net 1.1. Runnning underneath the application are several 2.0 apps. To completely logout a user can I just logout of the 1.1 app with FormsAuthentication.SignOut or is it more complicated than that? ANSWER: What you are looking to do is called Single Sign On and Single Sign Off. There are differences based on how you have the applications set up. I will try to clarify where those differences come into play. To implement single sign on and single sign off you need to make the cookie name, protection, and path attributes the same between all the applications. Next you need to add the machine keys and they need to be the same between all your applications. Are you using second or third level domains for the applications? If so you will need to do a little bit more by adding the domain to the cookie: protected void Login(string userName, string password) { System.Web.HttpCookie cookie = FormsAuthentication.GetAuthCookie(userName, False); cookie.Domain = "domain1.com"; cookie.Expires = DateTime.Now.AddDays(30); Response.AppendCookie(cookie); } Now to do single sign off, calling FormsAuthentication.SignOut may not be enough. The next best thing is to set the cookie expiration to a past date. This will ensure that the cookie will not be used again for authentication. protected void Logout(string userName) { System.Web.HttpCookie cookie = FormsAuthentication.GetAuthCookie(userName, False); cookie.Domain = "domain1.com"; cookie.Expires = DateTime.Now.AddDays(-1); Response.AppendCookie(cookie); } I am taking into consideration you are using the same database for all the applications. If the applications use a separate database for registration and authentication, then we will need to do some more. Just let me know if this is the case. Otherwise this should work for you.
[ "asp.net", "authentication", "forms-authentication", "asp.net-1.1" ]
3
5
3,264
4
0
2008-09-10T23:44:04.377000
2008-09-11T00:51:29.737000
55,506
55,546
How do I conditionally create a stored procedure in SQL Server?
As part of my integration strategy, I have a few SQL scripts that run in order to update the database. The first thing all of these scripts do is check to see if they need to run, e.g.: if @version <> @expects begin declare @error varchar(100); set @error = 'Invalid version. Your version is ' + convert(varchar, @version) + '. This script expects version ' + convert(varchar, @expects) + '.'; raiserror(@error, 10, 1); end else begin...sql statements here... end Works great! Except if I need to add a stored procedure. The "create proc" command must be the only command in a batch of sql commands. Putting a "create proc" in my IF statement causes this error: 'CREATE/ALTER PROCEDURE' must be the first statement in a query batch. Ouch! How do I put the CREATE PROC command in my script, and have it only execute if it needs to?
Here's what I came up with: Wrap it in an EXEC(), like so: if @version <> @expects begin...snip... end else begin exec('CREATE PROC MyProc AS SELECT ''Victory!'''); end Works like a charm!
How do I conditionally create a stored procedure in SQL Server? As part of my integration strategy, I have a few SQL scripts that run in order to update the database. The first thing all of these scripts do is check to see if they need to run, e.g.: if @version <> @expects begin declare @error varchar(100); set @error = 'Invalid version. Your version is ' + convert(varchar, @version) + '. This script expects version ' + convert(varchar, @expects) + '.'; raiserror(@error, 10, 1); end else begin...sql statements here... end Works great! Except if I need to add a stored procedure. The "create proc" command must be the only command in a batch of sql commands. Putting a "create proc" in my IF statement causes this error: 'CREATE/ALTER PROCEDURE' must be the first statement in a query batch. Ouch! How do I put the CREATE PROC command in my script, and have it only execute if it needs to?
TITLE: How do I conditionally create a stored procedure in SQL Server? QUESTION: As part of my integration strategy, I have a few SQL scripts that run in order to update the database. The first thing all of these scripts do is check to see if they need to run, e.g.: if @version <> @expects begin declare @error varchar(100); set @error = 'Invalid version. Your version is ' + convert(varchar, @version) + '. This script expects version ' + convert(varchar, @expects) + '.'; raiserror(@error, 10, 1); end else begin...sql statements here... end Works great! Except if I need to add a stored procedure. The "create proc" command must be the only command in a batch of sql commands. Putting a "create proc" in my IF statement causes this error: 'CREATE/ALTER PROCEDURE' must be the first statement in a query batch. Ouch! How do I put the CREATE PROC command in my script, and have it only execute if it needs to? ANSWER: Here's what I came up with: Wrap it in an EXEC(), like so: if @version <> @expects begin...snip... end else begin exec('CREATE PROC MyProc AS SELECT ''Victory!'''); end Works like a charm!
[ "sql-server", "stored-procedures" ]
25
25
22,665
11
0
2008-09-10T23:45:27.617000
2008-09-11T00:16:51.100000
55,510
55,548
When do function-level static variables get allocated/initialized?
I'm quite confident that globally declared variables get allocated (and initialized, if applicable) at program start time. int globalgarbage; unsigned int anumber = 42; But what about static ones defined within a function? void doSomething() { static bool globalish = true; //... } When is the space for globalish allocated? I'm guessing when the program starts. But does it get initialized then too? Or is it initialized when doSomething() is first called?
I was curious about this so I wrote the following test program and compiled it with g++ version 4.1.2. include #include using namespace std; class test { public: test(const char *name): _name(name) { cout << _name << " created" << endl; } ~test() { cout << _name << " destroyed" << endl; } string _name; }; test t("global variable"); void f() { static test t("static variable"); test t2("Local variable"); cout << "Function executed" << endl; } int main() { test t("local to main"); cout << "Program start" << endl; f(); cout << "Program end" << endl; return 0; } The results were not what I expected. The constructor for the static object was not called until the first time the function was called. Here is the output: global variable created local to main created Program start static variable created Local variable created Function executed Local variable destroyed Program end local to main destroyed static variable destroyed global variable destroyed
When do function-level static variables get allocated/initialized? I'm quite confident that globally declared variables get allocated (and initialized, if applicable) at program start time. int globalgarbage; unsigned int anumber = 42; But what about static ones defined within a function? void doSomething() { static bool globalish = true; //... } When is the space for globalish allocated? I'm guessing when the program starts. But does it get initialized then too? Or is it initialized when doSomething() is first called?
TITLE: When do function-level static variables get allocated/initialized? QUESTION: I'm quite confident that globally declared variables get allocated (and initialized, if applicable) at program start time. int globalgarbage; unsigned int anumber = 42; But what about static ones defined within a function? void doSomething() { static bool globalish = true; //... } When is the space for globalish allocated? I'm guessing when the program starts. But does it get initialized then too? Or is it initialized when doSomething() is first called? ANSWER: I was curious about this so I wrote the following test program and compiled it with g++ version 4.1.2. include #include using namespace std; class test { public: test(const char *name): _name(name) { cout << _name << " created" << endl; } ~test() { cout << _name << " destroyed" << endl; } string _name; }; test t("global variable"); void f() { static test t("static variable"); test t2("Local variable"); cout << "Function executed" << endl; } int main() { test t("local to main"); cout << "Program start" << endl; f(); cout << "Program end" << endl; return 0; } The results were not what I expected. The constructor for the static object was not called until the first time the function was called. Here is the output: global variable created local to main created Program start static variable created Local variable created Function executed Local variable destroyed Program end local to main destroyed static variable destroyed global variable destroyed
[ "c++", "variables" ]
109
108
83,004
8
0
2008-09-10T23:49:09.107000
2008-09-11T00:18:08.460000
55,517
55,645
Very slow compile times on Visual Studio 2005
We are getting very slow compile times, which can take upwards of 20+ minutes on dual core 2GHz, 2G Ram machines. A lot of this is due to the size of our solution which has grown to 70+ projects, as well as VSS which is a bottle neck in itself when you have a lot of files. (swapping out VSS is not an option unfortunately, so I don't want this to descend into a VSS bash) We are looking at merging projects. We are also looking at having multiple solutions to achieve greater separation of concerns and quicker compile times for each element of the application. This I can see will become a DLL hell as we try to keep things in synch. I am interested to know how other teams have dealt with this scaling issue, what do you do when your code base reaches a critical mass that you are wasting half the day watching the status bar deliver compile messages. UPDATE I neglected to mention this is a C# solution. Thanks for all the C++ suggestions, but it's been a few years since I've had to worry about headers. EDIT: Nice suggestions that have helped so far (not saying there aren't other nice suggestions below, just what has helped) New 3GHz laptop - the power of lost utilization works wonders when whinging to management Disable Anti Virus during compile 'Disconnecting' from VSS (actually the network) during compile - I may get us to remove VS-VSS integration altogether and stick to using the VSS UI Still not rip-snorting through a compile, but every bit helps. Orion did mention in a comment that generics may have a play also. From my tests there does appear to be a minimal performance hit, but not high enough to sure - compile times can be inconsistent due to disc activity. Due to time limitations, my tests didn't include as many Generics, or as much code, as would appear in live system, so that may accumulate. I wouldn't avoid using generics where they are supposed to be used, just for compile time performance WORKAROUND We are testing the practice of building new areas of the application in new solutions, importing in the latest dlls as required, them integrating them into the larger solution when we are happy with them. We may also do them same to existing code by creating temporary solutions that just encapsulate the areas we need to work on, and throwing them away after reintegrating the code. We need to weigh up the time it will take to reintegrate this code against the time we gain by not having Rip Van Winkle like experiences with rapid recompiling during development.
The Chromium.org team listed several options for accelerating the build (at this point about half-way down the page): In decreasing order of speedup: Install Microsoft hotfix 935225. Install Microsoft hotfix 947315. Use a true multicore processor (ie. an Intel Core Duo 2; not a Pentium 4 HT). Use 3 parallel builds. In Visual Studio 2005, you will find the option in Tools > Options... > Projects and Solutions > Build and Run > maximum number of parallel project builds. Disable your anti-virus software for.ilk,.pdb,.cc,.h files and only check for viruses on modify. Disable scanning the directory where your sources reside. Don't do anything stupid. Store and build the Chromium code on a second hard drive. It won't really speed up the build but at least your computer will stay responsive when you do gclient sync or a build. Defragment your hard drive regularly. Disable virtual memory.
Very slow compile times on Visual Studio 2005 We are getting very slow compile times, which can take upwards of 20+ minutes on dual core 2GHz, 2G Ram machines. A lot of this is due to the size of our solution which has grown to 70+ projects, as well as VSS which is a bottle neck in itself when you have a lot of files. (swapping out VSS is not an option unfortunately, so I don't want this to descend into a VSS bash) We are looking at merging projects. We are also looking at having multiple solutions to achieve greater separation of concerns and quicker compile times for each element of the application. This I can see will become a DLL hell as we try to keep things in synch. I am interested to know how other teams have dealt with this scaling issue, what do you do when your code base reaches a critical mass that you are wasting half the day watching the status bar deliver compile messages. UPDATE I neglected to mention this is a C# solution. Thanks for all the C++ suggestions, but it's been a few years since I've had to worry about headers. EDIT: Nice suggestions that have helped so far (not saying there aren't other nice suggestions below, just what has helped) New 3GHz laptop - the power of lost utilization works wonders when whinging to management Disable Anti Virus during compile 'Disconnecting' from VSS (actually the network) during compile - I may get us to remove VS-VSS integration altogether and stick to using the VSS UI Still not rip-snorting through a compile, but every bit helps. Orion did mention in a comment that generics may have a play also. From my tests there does appear to be a minimal performance hit, but not high enough to sure - compile times can be inconsistent due to disc activity. Due to time limitations, my tests didn't include as many Generics, or as much code, as would appear in live system, so that may accumulate. I wouldn't avoid using generics where they are supposed to be used, just for compile time performance WORKAROUND We are testing the practice of building new areas of the application in new solutions, importing in the latest dlls as required, them integrating them into the larger solution when we are happy with them. We may also do them same to existing code by creating temporary solutions that just encapsulate the areas we need to work on, and throwing them away after reintegrating the code. We need to weigh up the time it will take to reintegrate this code against the time we gain by not having Rip Van Winkle like experiences with rapid recompiling during development.
TITLE: Very slow compile times on Visual Studio 2005 QUESTION: We are getting very slow compile times, which can take upwards of 20+ minutes on dual core 2GHz, 2G Ram machines. A lot of this is due to the size of our solution which has grown to 70+ projects, as well as VSS which is a bottle neck in itself when you have a lot of files. (swapping out VSS is not an option unfortunately, so I don't want this to descend into a VSS bash) We are looking at merging projects. We are also looking at having multiple solutions to achieve greater separation of concerns and quicker compile times for each element of the application. This I can see will become a DLL hell as we try to keep things in synch. I am interested to know how other teams have dealt with this scaling issue, what do you do when your code base reaches a critical mass that you are wasting half the day watching the status bar deliver compile messages. UPDATE I neglected to mention this is a C# solution. Thanks for all the C++ suggestions, but it's been a few years since I've had to worry about headers. EDIT: Nice suggestions that have helped so far (not saying there aren't other nice suggestions below, just what has helped) New 3GHz laptop - the power of lost utilization works wonders when whinging to management Disable Anti Virus during compile 'Disconnecting' from VSS (actually the network) during compile - I may get us to remove VS-VSS integration altogether and stick to using the VSS UI Still not rip-snorting through a compile, but every bit helps. Orion did mention in a comment that generics may have a play also. From my tests there does appear to be a minimal performance hit, but not high enough to sure - compile times can be inconsistent due to disc activity. Due to time limitations, my tests didn't include as many Generics, or as much code, as would appear in live system, so that may accumulate. I wouldn't avoid using generics where they are supposed to be used, just for compile time performance WORKAROUND We are testing the practice of building new areas of the application in new solutions, importing in the latest dlls as required, them integrating them into the larger solution when we are happy with them. We may also do them same to existing code by creating temporary solutions that just encapsulate the areas we need to work on, and throwing them away after reintegrating the code. We need to weigh up the time it will take to reintegrate this code against the time we gain by not having Rip Van Winkle like experiences with rapid recompiling during development. ANSWER: The Chromium.org team listed several options for accelerating the build (at this point about half-way down the page): In decreasing order of speedup: Install Microsoft hotfix 935225. Install Microsoft hotfix 947315. Use a true multicore processor (ie. an Intel Core Duo 2; not a Pentium 4 HT). Use 3 parallel builds. In Visual Studio 2005, you will find the option in Tools > Options... > Projects and Solutions > Build and Run > maximum number of parallel project builds. Disable your anti-virus software for.ilk,.pdb,.cc,.h files and only check for viruses on modify. Disable scanning the directory where your sources reside. Don't do anything stupid. Store and build the Chromium code on a second hard drive. It won't really speed up the build but at least your computer will stay responsive when you do gclient sync or a build. Defragment your hard drive regularly. Disable virtual memory.
[ "c#", "visual-studio", "compilation" ]
133
74
88,157
34
0
2008-09-10T23:56:00.353000
2008-09-11T01:34:44.267000
55,531
55,544
How do I calculate the "cost" of a crash?
Background: Some time ago, I built a system for recording and categorizing application crashes for one of our internal programs. At the time, I used a combination of frequency and aggregated lost time (the time between the program launch and the crash) for prioritizing types of crashes. It worked reasonably well. Now, The Powers That Be want solid numbers on the cost of each type of crash being worked on. Or at least, numbers that look solid. I suppose I could use the aggregate lost time, multiplied by some plausible figure, but it seems dodgy. Question: Are there any established methods of calculating the real-world cost of application crashes? Or failing that, published studies speculating on such costs? Consensus Accuracy is impossible, but an estimate based on uptime should suffice if it is applied consistently and its limitations clearly documented. Thanks, Matt, Orion, for taking time to answer this.
I've not seen any studies, but a reasonable heuristic would be something like: ( Time since last application save when crash occurred + Time to restart application ) * Average hourly rate of application operator. The estimation gets more complex if the crashes have some impact on external customers such, or might delay other things (i.e. create a bottle neck such that another person winds up sitting around waiting because some else's application crashed). That said, your 'powers that be' may well be happy with a very rough estimate so long as it's applied consistently and they can see how it is changing over time.
How do I calculate the "cost" of a crash? Background: Some time ago, I built a system for recording and categorizing application crashes for one of our internal programs. At the time, I used a combination of frequency and aggregated lost time (the time between the program launch and the crash) for prioritizing types of crashes. It worked reasonably well. Now, The Powers That Be want solid numbers on the cost of each type of crash being worked on. Or at least, numbers that look solid. I suppose I could use the aggregate lost time, multiplied by some plausible figure, but it seems dodgy. Question: Are there any established methods of calculating the real-world cost of application crashes? Or failing that, published studies speculating on such costs? Consensus Accuracy is impossible, but an estimate based on uptime should suffice if it is applied consistently and its limitations clearly documented. Thanks, Matt, Orion, for taking time to answer this.
TITLE: How do I calculate the "cost" of a crash? QUESTION: Background: Some time ago, I built a system for recording and categorizing application crashes for one of our internal programs. At the time, I used a combination of frequency and aggregated lost time (the time between the program launch and the crash) for prioritizing types of crashes. It worked reasonably well. Now, The Powers That Be want solid numbers on the cost of each type of crash being worked on. Or at least, numbers that look solid. I suppose I could use the aggregate lost time, multiplied by some plausible figure, but it seems dodgy. Question: Are there any established methods of calculating the real-world cost of application crashes? Or failing that, published studies speculating on such costs? Consensus Accuracy is impossible, but an estimate based on uptime should suffice if it is applied consistently and its limitations clearly documented. Thanks, Matt, Orion, for taking time to answer this. ANSWER: I've not seen any studies, but a reasonable heuristic would be something like: ( Time since last application save when crash occurred + Time to restart application ) * Average hourly rate of application operator. The estimation gets more complex if the crashes have some impact on external customers such, or might delay other things (i.e. create a bottle neck such that another person winds up sitting around waiting because some else's application crashed). That said, your 'powers that be' may well be happy with a very rough estimate so long as it's applied consistently and they can see how it is changing over time.
[ "crash", "statistics", "crash-reports" ]
11
11
1,511
4
0
2008-09-11T00:05:58.053000
2008-09-11T00:15:33.037000
55,532
55,660
Casting between multi- and single-dimentional arrays
This came up from this answer to a previous question of mine. Is it guaranteed for the compiler to treat array[4][4] the same as array[16]? For instance, would either of the below calls to api_func() be safe? void api_func(const double matrix[4][4]); //... { typedef double Matrix[4][4]; double* array1 = new double[16]; double array2[16]; //... api_func(reinterpret_cast (array1)); api_func(reinterpret_cast (array2)); }
From the C++ standard, referring to the sizeof operator: When applied to an array, the result is the total number of bytes in the array. This implies that the size of an array of n elements is n times the size of an element. From this, I'd say that double[4][4] and double[16] would have to have the same underlying representation. I.e., given sizeof(double[4]) = 4*sizeof(double) and sizeof(double[4][4]) = 4*sizeof(double[4]) then we have sizeof(double[4][4]) = 4*4*sizeof(double) = 16*sizeof(double) = sizeof(double[16]) I think a standards-compliant compiler would have to implement these the same, and I think that this isn't something that a compiler would accidentally break. The standard way of implementing multi-dimensional arrays works as expected. Breaking the standard would require extra work, for likely no benefit. The C++ standard also states that an array consists of contiguously-allocated elements, which eliminates the possibility of doing anything strange using pointers and padding.
Casting between multi- and single-dimentional arrays This came up from this answer to a previous question of mine. Is it guaranteed for the compiler to treat array[4][4] the same as array[16]? For instance, would either of the below calls to api_func() be safe? void api_func(const double matrix[4][4]); //... { typedef double Matrix[4][4]; double* array1 = new double[16]; double array2[16]; //... api_func(reinterpret_cast (array1)); api_func(reinterpret_cast (array2)); }
TITLE: Casting between multi- and single-dimentional arrays QUESTION: This came up from this answer to a previous question of mine. Is it guaranteed for the compiler to treat array[4][4] the same as array[16]? For instance, would either of the below calls to api_func() be safe? void api_func(const double matrix[4][4]); //... { typedef double Matrix[4][4]; double* array1 = new double[16]; double array2[16]; //... api_func(reinterpret_cast (array1)); api_func(reinterpret_cast (array2)); } ANSWER: From the C++ standard, referring to the sizeof operator: When applied to an array, the result is the total number of bytes in the array. This implies that the size of an array of n elements is n times the size of an element. From this, I'd say that double[4][4] and double[16] would have to have the same underlying representation. I.e., given sizeof(double[4]) = 4*sizeof(double) and sizeof(double[4][4]) = 4*sizeof(double[4]) then we have sizeof(double[4][4]) = 4*4*sizeof(double) = 16*sizeof(double) = sizeof(double[16]) I think a standards-compliant compiler would have to implement these the same, and I think that this isn't something that a compiler would accidentally break. The standard way of implementing multi-dimensional arrays works as expected. Breaking the standard would require extra work, for likely no benefit. The C++ standard also states that an array consists of contiguously-allocated elements, which eliminates the possibility of doing anything strange using pointers and padding.
[ "c++", "arrays" ]
3
3
595
6
0
2008-09-11T00:06:58.097000
2008-09-11T01:42:11.113000
55,556
55,634
Characters to avoid in automatically generated passwords
I need to generate some passwords, I want to avoid characters that can be confused for each other. Is there a definitive list of characters I should avoid? my current list is il10o8B3Evu![]{} Are there any other pairs of characters that are easy to confuse? for special characters I was going to limit myself to those under the number keys, though I know that this differs depending on your keyboards nationality! As a rider question, I would like my passwords to be 'wordlike'do you have a favoured algorithm for that? Thanks:)
Here are the character sets that Steve Gibson uses for his "Perfect Paper Password" system. They are "characters to allow" rather than "characters to avoid", but they seem pretty reasonable for what you want: A standard set of 64 characters!#%+23456789:=?@ABCDEFGHJKLMNPRS TUVWXYZabcdefghijkmnopqrstuvwxyz A larger set of 88 characters!"#$%&'()*+,-./23456789:;<=>?@ABCDEFGHJKLMNO PRSTUVWXYZ[\]^_abcdefghijkmnopqrstuvwxyz{|}~ For pronounceable passwords, I'm not familiar with the algorithms but you might want to look at APG and pwgen as a starting point.
Characters to avoid in automatically generated passwords I need to generate some passwords, I want to avoid characters that can be confused for each other. Is there a definitive list of characters I should avoid? my current list is il10o8B3Evu![]{} Are there any other pairs of characters that are easy to confuse? for special characters I was going to limit myself to those under the number keys, though I know that this differs depending on your keyboards nationality! As a rider question, I would like my passwords to be 'wordlike'do you have a favoured algorithm for that? Thanks:)
TITLE: Characters to avoid in automatically generated passwords QUESTION: I need to generate some passwords, I want to avoid characters that can be confused for each other. Is there a definitive list of characters I should avoid? my current list is il10o8B3Evu![]{} Are there any other pairs of characters that are easy to confuse? for special characters I was going to limit myself to those under the number keys, though I know that this differs depending on your keyboards nationality! As a rider question, I would like my passwords to be 'wordlike'do you have a favoured algorithm for that? Thanks:) ANSWER: Here are the character sets that Steve Gibson uses for his "Perfect Paper Password" system. They are "characters to allow" rather than "characters to avoid", but they seem pretty reasonable for what you want: A standard set of 64 characters!#%+23456789:=?@ABCDEFGHJKLMNPRS TUVWXYZabcdefghijkmnopqrstuvwxyz A larger set of 88 characters!"#$%&'()*+,-./23456789:;<=>?@ABCDEFGHJKLMNO PRSTUVWXYZ[\]^_abcdefghijkmnopqrstuvwxyz{|}~ For pronounceable passwords, I'm not familiar with the algorithms but you might want to look at APG and pwgen as a starting point.
[ "security", "passwords", "user-experience" ]
33
54
22,574
11
0
2008-09-11T00:27:50.060000
2008-09-11T01:24:43.760000
55,572
55,599
live asp.net web.config settings
I've only recently started working with asp.net and c#. Is there a standard practice set of web.config settings for a live final website? There seem to be a ton of options available and I'm looking to streamline performance, close possible security holes and other unnecessary options.
Tip/Trick: Automating Dev, QA, Staging, and Production Web.Config Settings with VS 2005
live asp.net web.config settings I've only recently started working with asp.net and c#. Is there a standard practice set of web.config settings for a live final website? There seem to be a ton of options available and I'm looking to streamline performance, close possible security holes and other unnecessary options.
TITLE: live asp.net web.config settings QUESTION: I've only recently started working with asp.net and c#. Is there a standard practice set of web.config settings for a live final website? There seem to be a ton of options available and I'm looking to streamline performance, close possible security holes and other unnecessary options. ANSWER: Tip/Trick: Automating Dev, QA, Staging, and Production Web.Config Settings with VS 2005
[ "asp.net", "security", "web-config" ]
5
3
742
4
0
2008-09-11T00:48:10.743000
2008-09-11T01:04:59.220000
55,574
55,610
Learning Ruby on Rails
As it stands now, I'm a Java and C# developer. The more and more I look at Ruby on Rails, the more I really want to learn it. What have you found to be the best route to learn RoR? Would it be easier to develop on Windows, or should I just run a virtual machine with Linux? Is there an IDE that can match the robustness of Visual Studio? Any programs to develop that give a good overhead of what to do? Any good books? Seriously, any tips/tricks/rants would be awesome.
I've been moving from C# in my professional career to looking at Ruby and RoR in my personal life, and I've found linux to be slightly more appealing personally for development. Particularly now that I've started using git, the implementation is cleaner on linux. Currently I'm dual booting and getting closer to running Ubuntu full time. I'm using gedit with various plugins for the development environment. And as of late 2010, I'm making the push to use Vim for development, even over Textmate on OS X. A large amount of the Rails developers are using (gasp) Macs, which has actually got me thinking in that direction. Although I haven't tried it, Ruby in Steel gives you a Ruby IDE inside the Visual Studio world, and IronRuby is the.NET flavor of Ruby, if you're interested. As far as books are concerned, the Programming Ruby (also known as the Pickaxe) book from the Pragmatic Programmers is the de-facto for learning Ruby. I bit the bullet and purchased that book and Agile Web Development with Rails; both books have been excellent. Peepcode screencasts and PDF books have also been great for getting started; at $9 per screencast it's hard to go wrong. I actually bought a 5-pack. Also check out the following: Official Rails Guides Railscasts railsapi.com or Ruby on Rails - APIdock The Ruby Show Rails for Zombies Softies on Rails - Ruby on Rails for.NET Developers Rails Podcast Rails Best Practices I've burned through the backlog of Rails and Rails Envy podcasts in the past month and they have provided wonderful insight into lots of topics, even regarding software development in general.
Learning Ruby on Rails As it stands now, I'm a Java and C# developer. The more and more I look at Ruby on Rails, the more I really want to learn it. What have you found to be the best route to learn RoR? Would it be easier to develop on Windows, or should I just run a virtual machine with Linux? Is there an IDE that can match the robustness of Visual Studio? Any programs to develop that give a good overhead of what to do? Any good books? Seriously, any tips/tricks/rants would be awesome.
TITLE: Learning Ruby on Rails QUESTION: As it stands now, I'm a Java and C# developer. The more and more I look at Ruby on Rails, the more I really want to learn it. What have you found to be the best route to learn RoR? Would it be easier to develop on Windows, or should I just run a virtual machine with Linux? Is there an IDE that can match the robustness of Visual Studio? Any programs to develop that give a good overhead of what to do? Any good books? Seriously, any tips/tricks/rants would be awesome. ANSWER: I've been moving from C# in my professional career to looking at Ruby and RoR in my personal life, and I've found linux to be slightly more appealing personally for development. Particularly now that I've started using git, the implementation is cleaner on linux. Currently I'm dual booting and getting closer to running Ubuntu full time. I'm using gedit with various plugins for the development environment. And as of late 2010, I'm making the push to use Vim for development, even over Textmate on OS X. A large amount of the Rails developers are using (gasp) Macs, which has actually got me thinking in that direction. Although I haven't tried it, Ruby in Steel gives you a Ruby IDE inside the Visual Studio world, and IronRuby is the.NET flavor of Ruby, if you're interested. As far as books are concerned, the Programming Ruby (also known as the Pickaxe) book from the Pragmatic Programmers is the de-facto for learning Ruby. I bit the bullet and purchased that book and Agile Web Development with Rails; both books have been excellent. Peepcode screencasts and PDF books have also been great for getting started; at $9 per screencast it's hard to go wrong. I actually bought a 5-pack. Also check out the following: Official Rails Guides Railscasts railsapi.com or Ruby on Rails - APIdock The Ruby Show Rails for Zombies Softies on Rails - Ruby on Rails for.NET Developers Rails Podcast Rails Best Practices I've burned through the backlog of Rails and Rails Envy podcasts in the past month and they have provided wonderful insight into lots of topics, even regarding software development in general.
[ "ruby-on-rails", "ruby" ]
241
205
191,736
56
0
2008-09-11T00:50:59.520000
2008-09-11T01:11:52.683000
55,576
240,739
ASP.Net: If I have the Session ID, Can I get the Session object?
This question is related to this one, though I think I was a little too long-winded there to really get a good answer. I'll keep this brief. I'm working on a web handler (ashx) that accepts a form post from an aspx page. When the handler receives this form post, in order to do what it needs to do, it needs to know the user who is logged in (User.Identity.Name), but I can't rely on cookies being sent by the browser. I know I can get the Session.SessionID and place it in a hidden form field, but once my handler receives the form post, how can I use that SessionID to figure out the logged-in user's identity? I'm using the StateServer mode for session state.
Jonas posted a great answer to this question here: Can I put an ASP.Net session ID in a hidden form field?
ASP.Net: If I have the Session ID, Can I get the Session object? This question is related to this one, though I think I was a little too long-winded there to really get a good answer. I'll keep this brief. I'm working on a web handler (ashx) that accepts a form post from an aspx page. When the handler receives this form post, in order to do what it needs to do, it needs to know the user who is logged in (User.Identity.Name), but I can't rely on cookies being sent by the browser. I know I can get the Session.SessionID and place it in a hidden form field, but once my handler receives the form post, how can I use that SessionID to figure out the logged-in user's identity? I'm using the StateServer mode for session state.
TITLE: ASP.Net: If I have the Session ID, Can I get the Session object? QUESTION: This question is related to this one, though I think I was a little too long-winded there to really get a good answer. I'll keep this brief. I'm working on a web handler (ashx) that accepts a form post from an aspx page. When the handler receives this form post, in order to do what it needs to do, it needs to know the user who is logged in (User.Identity.Name), but I can't rely on cookies being sent by the browser. I know I can get the Session.SessionID and place it in a hidden form field, but once my handler receives the form post, how can I use that SessionID to figure out the logged-in user's identity? I'm using the StateServer mode for session state. ANSWER: Jonas posted a great answer to this question here: Can I put an ASP.Net session ID in a hidden form field?
[ "asp.net", "session" ]
14
1
17,833
4
0
2008-09-11T00:52:25.053000
2008-10-27T17:30:51.733000
55,577
55,578
How can I test my web pages in Microsoft Internet Explorer on a Mac?
I want to test the web pages I create in all the modern versions of Internet Explorer (6, 7 and 8 beta) but I work mainly on a Mac and often don't have direct access to a PC.
Update: Microsoft now provide virtual machine images for various versions of IE that are ready to use on all of the major OS X virtualisation platforms ( VirtualBox, VMWare Fusion, and Parallels ). Download the appropriate image from: https://developer.microsoft.com/en-us/microsoft-edge/tools/vms/ On an Intel based Mac you can run Windows within a virtual machine. You will need one virtual machine for each version of IE you want to test against. The instructions below include free and legal virtualisation software and Windows disk images. Download some virtual machine software. The developer disk images we're going to use are will work with either VMWare Fusion or Sun Virtual Box. VMWare has more features but costs $80, Virtual Box on the other hand is more basic but is free for most users (see Virtual Box licensing FAQ for details). Download the IE developer disk images, which are free from Microsoft: http://www.microsoft.com/downloads/... Extract the disk images using cabextract which is available from MacPorts or as source code (Thanks to Clinton ). Download Q.app from http://www.kju-app.org/ and put it in your /Applications folder (you will need it to convert the disk images into a format VMWare/Virtual Box can use) At this point, the process depends on which VM software you're using. Virtual Box users Open a Terminal.app on your Mac (you can find it in /Applications/Utilities) and run the following sequence of commands, replacing input.vhd with the name of the VHD file you're starting from and output.vdi with the name you want your final disk image to have: /Applications/Q.app/Contents/MacOS/qemu-img convert -O raw -f vpc "input.vhd" temp.bin VBoxManage convertdd temp.bin "output.vdi" rm temp.bin mv "output.vdi" ~/Library/VirtualBox/VDI/ VBoxManage modifyvdi "output.vdi" compact Start Virtual Box and create a new virtual machine Select the new VDI file you've just created as the boot hard disk VMWare fusion users Open a Terminal.app on your Mac (you can find it in /Applications/Utilities) and run the following commands, replacing input.vhd and output.vmdk with the name of the VHD file you're working on and the name you want your resulting disk image to have: /Applications/Q.app/Contents/MacOS/qemu-img convert -O vmdk -f vpc "input.vhd" "output.vmdk" mv "output.vmdk" ~/Documents/Virtual\ Machines.localized/ This will probably take a while (It takes around 30 minutes per disk image on my 2.4GHz Core 2 Duo MacBook w/ 2Gb RAM). Start VMWare Fusion and create a new virtual machine In the advanced disk options select "use and existing disk" and find the VMDK file you just created
How can I test my web pages in Microsoft Internet Explorer on a Mac? I want to test the web pages I create in all the modern versions of Internet Explorer (6, 7 and 8 beta) but I work mainly on a Mac and often don't have direct access to a PC.
TITLE: How can I test my web pages in Microsoft Internet Explorer on a Mac? QUESTION: I want to test the web pages I create in all the modern versions of Internet Explorer (6, 7 and 8 beta) but I work mainly on a Mac and often don't have direct access to a PC. ANSWER: Update: Microsoft now provide virtual machine images for various versions of IE that are ready to use on all of the major OS X virtualisation platforms ( VirtualBox, VMWare Fusion, and Parallels ). Download the appropriate image from: https://developer.microsoft.com/en-us/microsoft-edge/tools/vms/ On an Intel based Mac you can run Windows within a virtual machine. You will need one virtual machine for each version of IE you want to test against. The instructions below include free and legal virtualisation software and Windows disk images. Download some virtual machine software. The developer disk images we're going to use are will work with either VMWare Fusion or Sun Virtual Box. VMWare has more features but costs $80, Virtual Box on the other hand is more basic but is free for most users (see Virtual Box licensing FAQ for details). Download the IE developer disk images, which are free from Microsoft: http://www.microsoft.com/downloads/... Extract the disk images using cabextract which is available from MacPorts or as source code (Thanks to Clinton ). Download Q.app from http://www.kju-app.org/ and put it in your /Applications folder (you will need it to convert the disk images into a format VMWare/Virtual Box can use) At this point, the process depends on which VM software you're using. Virtual Box users Open a Terminal.app on your Mac (you can find it in /Applications/Utilities) and run the following sequence of commands, replacing input.vhd with the name of the VHD file you're starting from and output.vdi with the name you want your final disk image to have: /Applications/Q.app/Contents/MacOS/qemu-img convert -O raw -f vpc "input.vhd" temp.bin VBoxManage convertdd temp.bin "output.vdi" rm temp.bin mv "output.vdi" ~/Library/VirtualBox/VDI/ VBoxManage modifyvdi "output.vdi" compact Start Virtual Box and create a new virtual machine Select the new VDI file you've just created as the boot hard disk VMWare fusion users Open a Terminal.app on your Mac (you can find it in /Applications/Utilities) and run the following commands, replacing input.vhd and output.vmdk with the name of the VHD file you're working on and the name you want your resulting disk image to have: /Applications/Q.app/Contents/MacOS/qemu-img convert -O vmdk -f vpc "input.vhd" "output.vmdk" mv "output.vmdk" ~/Documents/Virtual\ Machines.localized/ This will probably take a while (It takes around 30 minutes per disk image on my 2.4GHz Core 2 Duo MacBook w/ 2Gb RAM). Start VMWare Fusion and create a new virtual machine In the advanced disk options select "use and existing disk" and find the VMDK file you just created
[ "internet-explorer", "macos", "testing" ]
35
59
18,000
14
0
2008-09-11T00:53:06.707000
2008-09-11T00:53:35.130000