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
16,199
16,304
Web App - Dashboard Type GUI - Interface
I'm looking to create a dashboard type gui for a web application. I'm looking for the user to be able to drag and drop different elements (probably either image buttons, anchor tags, or maybe just divs) to different (defined) places and be able to save their setup (in a cookie or on the server). I'm working with c# in the.Net 2.0 framework. I've tried using mootools but their recent update has left their drag/drop capabilities un-useful for me. I'm looking for a bit of direction because I know there is something out there that is just what I'm looking for so I wont have to build from scratch. Thanks.
I have been looking at this kind of functionality myself recently and have decided on using jQuery with the help of jQuery UI. I came across a large amount of information that also suggested Yahoo UI (YUI), I had already started learning jQuery due to the AJAX support that it offers, so I stuck with it. jQuery UI Site jQuery UI Documentation Example of a drag and drop screen layout with jQuery UI Introduction to jQuery UI If you decide to use the YUI javascript library, here is a link to a vast amount of videos to help get you started. http://developer.yahoo.com/yui/theater/
Web App - Dashboard Type GUI - Interface I'm looking to create a dashboard type gui for a web application. I'm looking for the user to be able to drag and drop different elements (probably either image buttons, anchor tags, or maybe just divs) to different (defined) places and be able to save their setup (in a cookie or on the server). I'm working with c# in the.Net 2.0 framework. I've tried using mootools but their recent update has left their drag/drop capabilities un-useful for me. I'm looking for a bit of direction because I know there is something out there that is just what I'm looking for so I wont have to build from scratch. Thanks.
TITLE: Web App - Dashboard Type GUI - Interface QUESTION: I'm looking to create a dashboard type gui for a web application. I'm looking for the user to be able to drag and drop different elements (probably either image buttons, anchor tags, or maybe just divs) to different (defined) places and be able to save their setup (in a cookie or on the server). I'm working with c# in the.Net 2.0 framework. I've tried using mootools but their recent update has left their drag/drop capabilities un-useful for me. I'm looking for a bit of direction because I know there is something out there that is just what I'm looking for so I wont have to build from scratch. Thanks. ANSWER: I have been looking at this kind of functionality myself recently and have decided on using jQuery with the help of jQuery UI. I came across a large amount of information that also suggested Yahoo UI (YUI), I had already started learning jQuery due to the AJAX support that it offers, so I stuck with it. jQuery UI Site jQuery UI Documentation Example of a drag and drop screen layout with jQuery UI Introduction to jQuery UI If you decide to use the YUI javascript library, here is a link to a vast amount of videos to help get you started. http://developer.yahoo.com/yui/theater/
[ "c#", "asp.net", "javascript", "user-interface" ]
4
4
3,990
5
0
2008-08-19T13:57:33.820000
2008-08-19T14:44:28.747000
16,209
16,238
Displaying Version Information in a Web Service
Can anyone suggest a way of getting version information into a Web Service? (VB.NET) I would like to dynamically use the assembly version in the title or description, but the attributes require constants. Is manually writing the version info as a string the only way of displaying the information on the.asmx page?
Yeah, attributes cannot have anything but constants in them, so you cannot use reflection to get the version number. The WebServiceAttribute class is sealed too, so you cannot inherit it and do what you want from there. A solution might be to use some kind of placeholder text as the Name, and set up an MsBuild task to replace it with the version number when building the project.
Displaying Version Information in a Web Service Can anyone suggest a way of getting version information into a Web Service? (VB.NET) I would like to dynamically use the assembly version in the title or description, but the attributes require constants. Is manually writing the version info as a string the only way of displaying the information on the.asmx page?
TITLE: Displaying Version Information in a Web Service QUESTION: Can anyone suggest a way of getting version information into a Web Service? (VB.NET) I would like to dynamically use the assembly version in the title or description, but the attributes require constants. Is manually writing the version info as a string the only way of displaying the information on the.asmx page? ANSWER: Yeah, attributes cannot have anything but constants in them, so you cannot use reflection to get the version number. The WebServiceAttribute class is sealed too, so you cannot inherit it and do what you want from there. A solution might be to use some kind of placeholder text as the Name, and set up an MsBuild task to replace it with the version number when building the project.
[ "vb.net", "web-services", "versions" ]
2
1
1,696
3
0
2008-08-19T14:02:01.237000
2008-08-19T14:15:36.373000
16,233
16,255
Fonts on the Web
The collection of fonts available to a web developer is depressingly limited. I remember reading long ago about TrueDoc, as a way of shipping fonts alongside a website - but it seems to have languished. Has anybody used this, or something similar? Is it supported by enough browsers? Am I missing a good solution? Note that a responsible web developer does not use fonts that are only available on Windows (and especially ones that are only available on Vista), nor do they use a technology that isn't supported by at least the majority of browsers. Update: As several people have pointed out, there's nothing wrong with providing a list of fallback fonts for people who don't have the specific font you use. I do in fact always do this, and didn't mean to suggest that this was wrong. While my question was badly phrased, what I meant was that a designer should not make too many assumptions about what the client will have available. You should plan for how all users will see your site, not just for people using your own preferred setup.
Safari, and to a lesser extent, Firefox 3 have support for @font-face in CSS, which lets you use custom fonts. You need to have the appropriate licence to distribute the font files though. These articles explain it in more detail: http://www.css3.info/preview/web-fonts-with-font-face/ http://www.alistapart.com/articles/cssatten http://www.sitepoint.com/blogs/2008/07/30/custom-web-fonts-pick-your-poison/
Fonts on the Web The collection of fonts available to a web developer is depressingly limited. I remember reading long ago about TrueDoc, as a way of shipping fonts alongside a website - but it seems to have languished. Has anybody used this, or something similar? Is it supported by enough browsers? Am I missing a good solution? Note that a responsible web developer does not use fonts that are only available on Windows (and especially ones that are only available on Vista), nor do they use a technology that isn't supported by at least the majority of browsers. Update: As several people have pointed out, there's nothing wrong with providing a list of fallback fonts for people who don't have the specific font you use. I do in fact always do this, and didn't mean to suggest that this was wrong. While my question was badly phrased, what I meant was that a designer should not make too many assumptions about what the client will have available. You should plan for how all users will see your site, not just for people using your own preferred setup.
TITLE: Fonts on the Web QUESTION: The collection of fonts available to a web developer is depressingly limited. I remember reading long ago about TrueDoc, as a way of shipping fonts alongside a website - but it seems to have languished. Has anybody used this, or something similar? Is it supported by enough browsers? Am I missing a good solution? Note that a responsible web developer does not use fonts that are only available on Windows (and especially ones that are only available on Vista), nor do they use a technology that isn't supported by at least the majority of browsers. Update: As several people have pointed out, there's nothing wrong with providing a list of fallback fonts for people who don't have the specific font you use. I do in fact always do this, and didn't mean to suggest that this was wrong. While my question was badly phrased, what I meant was that a designer should not make too many assumptions about what the client will have available. You should plan for how all users will see your site, not just for people using your own preferred setup. ANSWER: Safari, and to a lesser extent, Firefox 3 have support for @font-face in CSS, which lets you use custom fonts. You need to have the appropriate licence to distribute the font files though. These articles explain it in more detail: http://www.css3.info/preview/web-fonts-with-font-face/ http://www.alistapart.com/articles/cssatten http://www.sitepoint.com/blogs/2008/07/30/custom-web-fonts-pick-your-poison/
[ "html", "css", "fonts" ]
26
20
9,338
10
0
2008-08-19T14:13:18.560000
2008-08-19T14:22:04.720000
16,248
35,683
Getting the subversion repository number into code
I'd like to implement a way of recording the version of a project within code, so that it can be used when testing and to help track bugs. It seems the best version number to use would just be the current revision number from Subversion. Is there an easy way to hook this number into a (C++ in my case) header file or something, which I can then get at in code? I guess this is a post commit hook or something? Does anyone have any experience of implementing this (with code to share, please?), or can suggest a better alternative? Thanks.
While nifty, the revision keyword trick only updates the file when it's changed in that revision - if you don't change the file, then it will continue to reflect the old revision. If you want the software to always reflect the overall revision number, then you'll have to delve into the relevant SVN entries file and extract it, which isn't too difficult (it's an XML file). Wikipedia does this on their version page to indicate the revision of the software that's running live; the code is here - look for the getSvnRevision() method.
Getting the subversion repository number into code I'd like to implement a way of recording the version of a project within code, so that it can be used when testing and to help track bugs. It seems the best version number to use would just be the current revision number from Subversion. Is there an easy way to hook this number into a (C++ in my case) header file or something, which I can then get at in code? I guess this is a post commit hook or something? Does anyone have any experience of implementing this (with code to share, please?), or can suggest a better alternative? Thanks.
TITLE: Getting the subversion repository number into code QUESTION: I'd like to implement a way of recording the version of a project within code, so that it can be used when testing and to help track bugs. It seems the best version number to use would just be the current revision number from Subversion. Is there an easy way to hook this number into a (C++ in my case) header file or something, which I can then get at in code? I guess this is a post commit hook or something? Does anyone have any experience of implementing this (with code to share, please?), or can suggest a better alternative? Thanks. ANSWER: While nifty, the revision keyword trick only updates the file when it's changed in that revision - if you don't change the file, then it will continue to reflect the old revision. If you want the software to always reflect the overall revision number, then you'll have to delve into the relevant SVN entries file and extract it, which isn't too difficult (it's an XML file). Wikipedia does this on their version page to indicate the revision of the software that's running live; the code is here - look for the getSvnRevision() method.
[ "svn", "debugging", "testing", "revision", "versions" ]
41
14
49,244
7
0
2008-08-19T14:19:06.227000
2008-08-30T04:23:00.737000
16,265
16,335
LINQ to SQL Mapping From Money to Double
I'm working with LINQ for the first time and wanted to get the Mapping to work when I have a money type in SQL, but my domain object property is of type double. How can I express this in the XML file, or in code so that the mapping does not throw the usual "invalid cast" exception?
In the DBML XML file, you can set the Expression attribute of a Column element to something like this:
LINQ to SQL Mapping From Money to Double I'm working with LINQ for the first time and wanted to get the Mapping to work when I have a money type in SQL, but my domain object property is of type double. How can I express this in the XML file, or in code so that the mapping does not throw the usual "invalid cast" exception?
TITLE: LINQ to SQL Mapping From Money to Double QUESTION: I'm working with LINQ for the first time and wanted to get the Mapping to work when I have a money type in SQL, but my domain object property is of type double. How can I express this in the XML file, or in code so that the mapping does not throw the usual "invalid cast" exception? ANSWER: In the DBML XML file, you can set the Expression attribute of a Column element to something like this:
[ "linq", "linq-to-sql", "orm" ]
1
1
1,983
3
0
2008-08-19T14:27:08.737000
2008-08-19T14:53:49.383000
16,298
16,311
How to redirect siteA to siteB with A or CNAME records
I have 2 hosts and I would like to point a subdomain on host one to a subdomain on host two: subdomain.hostone.com --> subdomain.hosttwo.com I added a CNAME record to host one that points to subdomain.hosttwo.com but all I get is a ' 400 Bad Request ' Error. Can anyone see what I'm doing wrong?
Try changing it to "subdomain -> subdomain.hosttwo.com" The CNAME is an alias for a certain domain, so when you go to the control panel for hostone.com, you shouldn't have to enter the whole name into the CNAME alias. As far as the error you are getting, can you log onto subdomain.hostwo.com and check the logs?
How to redirect siteA to siteB with A or CNAME records I have 2 hosts and I would like to point a subdomain on host one to a subdomain on host two: subdomain.hostone.com --> subdomain.hosttwo.com I added a CNAME record to host one that points to subdomain.hosttwo.com but all I get is a ' 400 Bad Request ' Error. Can anyone see what I'm doing wrong?
TITLE: How to redirect siteA to siteB with A or CNAME records QUESTION: I have 2 hosts and I would like to point a subdomain on host one to a subdomain on host two: subdomain.hostone.com --> subdomain.hosttwo.com I added a CNAME record to host one that points to subdomain.hosttwo.com but all I get is a ' 400 Bad Request ' Error. Can anyone see what I'm doing wrong? ANSWER: Try changing it to "subdomain -> subdomain.hosttwo.com" The CNAME is an alias for a certain domain, so when you go to the control panel for hostone.com, you shouldn't have to enter the whole name into the CNAME alias. As far as the error you are getting, can you log onto subdomain.hostwo.com and check the logs?
[ "dns", "web-hosting", "cname" ]
46
14
209,742
7
0
2008-08-19T14:42:29.440000
2008-08-19T14:46:12.677000
16,306
16,318
How to get only directory name from SaveFileDialog.FileName
What would be the easiest way to separate the directory name from the file name when dealing with SaveFileDialog.FileName in C#?
Use: System.IO.Path.GetDirectoryName(saveDialog.FileName) (and the corresponding System.IO.Path.GetFileName ). The Path class is really rather useful.
How to get only directory name from SaveFileDialog.FileName What would be the easiest way to separate the directory name from the file name when dealing with SaveFileDialog.FileName in C#?
TITLE: How to get only directory name from SaveFileDialog.FileName QUESTION: What would be the easiest way to separate the directory name from the file name when dealing with SaveFileDialog.FileName in C#? ANSWER: Use: System.IO.Path.GetDirectoryName(saveDialog.FileName) (and the corresponding System.IO.Path.GetFileName ). The Path class is really rather useful.
[ "c#", "string", "parsing" ]
7
15
5,217
4
0
2008-08-19T14:44:59.667000
2008-08-19T14:49:07.553000
16,330
33,604
How do I handle page flow in MVC (particularly asp.net)
If you had to provide a wizard like form entry experience in mvc how would you abstract the page flow?
Investigate the post-redirect-get pattern. http://weblogs.asp.net/mhawley/archive/tags/MVC/default.aspx http://devlicio.us/blogs/tim_barcz/archive/2008/08/22/prg-pattern-in-the-asp-net-mvc-framework.aspx Use that along with a robust domain model (for tracking steps or form completion state or whatever you call it) and you're golden.
How do I handle page flow in MVC (particularly asp.net) If you had to provide a wizard like form entry experience in mvc how would you abstract the page flow?
TITLE: How do I handle page flow in MVC (particularly asp.net) QUESTION: If you had to provide a wizard like form entry experience in mvc how would you abstract the page flow? ANSWER: Investigate the post-redirect-get pattern. http://weblogs.asp.net/mhawley/archive/tags/MVC/default.aspx http://devlicio.us/blogs/tim_barcz/archive/2008/08/22/prg-pattern-in-the-asp-net-mvc-framework.aspx Use that along with a robust domain model (for tracking steps or form completion state or whatever you call it) and you're golden.
[ "asp.net-mvc" ]
5
9
4,426
5
0
2008-08-19T14:53:06.593000
2008-08-28T23:07:28.550000
16,363
16,390
How do you configure VS2008 to only open one webserver in a solution with multiple projects?
Starting with 2005, VS started this behavior of when starting debugging session it spawns up a webserver for every project in a solution. I have a solution with 15 projects so it takes a while and is a waste of resources. Is there a way to configure it differently besides just using IIS?
Some details here on why it does it and how you can overcome it: http://vishaljoshi.blogspot.com/2007/12/tips-tricks-start-up-options-and.html There are instances when you might have many web applications or web sites in the same solution and you may be actually debugging only one of them... In such scenario it might not be desirable to have multiple instances of ASP.NET Development Server running... VS provides an explicit setting in the property grid of web application/site called Development Web Server - "Always Start When Debugging" which is set to True by default... If you set this Property to be False only one web server instance will be created for the start up web project...
How do you configure VS2008 to only open one webserver in a solution with multiple projects? Starting with 2005, VS started this behavior of when starting debugging session it spawns up a webserver for every project in a solution. I have a solution with 15 projects so it takes a while and is a waste of resources. Is there a way to configure it differently besides just using IIS?
TITLE: How do you configure VS2008 to only open one webserver in a solution with multiple projects? QUESTION: Starting with 2005, VS started this behavior of when starting debugging session it spawns up a webserver for every project in a solution. I have a solution with 15 projects so it takes a while and is a waste of resources. Is there a way to configure it differently besides just using IIS? ANSWER: Some details here on why it does it and how you can overcome it: http://vishaljoshi.blogspot.com/2007/12/tips-tricks-start-up-options-and.html There are instances when you might have many web applications or web sites in the same solution and you may be actually debugging only one of them... In such scenario it might not be desirable to have multiple instances of ASP.NET Development Server running... VS provides an explicit setting in the property grid of web application/site called Development Web Server - "Always Start When Debugging" which is set to True by default... If you set this Property to be False only one web server instance will be created for the start up web project...
[ "visual-studio", "debugging" ]
13
23
3,925
5
0
2008-08-19T15:09:30.663000
2008-08-19T15:20:20.720000
16,396
20,786
Easy way for Crystal Reports to MS SQL Server Reporting Services conversion
Is there a way to easily convert Crystal Reports reports to Reporting Services RDL format? We have quite a few reports that will be needing conversion soon. I know about the manual process (which is basically rebuilding all your reports from scratch in SSRS), but my searches pointed to a few possibilities with automatic conversion "acceleration" with several consulting firms. (As described on.... - link broken). Do any of you have any valid experiences or recomendations regarding this particular issue? Are there any tools around that I do not know about?
I have searched previously for this, with no luck. There does not seem to be any tools available for this conversion, the manual method thereby becomes the only method. And yes, there are consulting firms who will do the manual work for you, but they still do it manually. Crystal Reports and Reporting Services have different architectural styles, making it a difficult task for a conversion tool, so I view it as unlikely that someone will build one anytime soon.
Easy way for Crystal Reports to MS SQL Server Reporting Services conversion Is there a way to easily convert Crystal Reports reports to Reporting Services RDL format? We have quite a few reports that will be needing conversion soon. I know about the manual process (which is basically rebuilding all your reports from scratch in SSRS), but my searches pointed to a few possibilities with automatic conversion "acceleration" with several consulting firms. (As described on.... - link broken). Do any of you have any valid experiences or recomendations regarding this particular issue? Are there any tools around that I do not know about?
TITLE: Easy way for Crystal Reports to MS SQL Server Reporting Services conversion QUESTION: Is there a way to easily convert Crystal Reports reports to Reporting Services RDL format? We have quite a few reports that will be needing conversion soon. I know about the manual process (which is basically rebuilding all your reports from scratch in SSRS), but my searches pointed to a few possibilities with automatic conversion "acceleration" with several consulting firms. (As described on.... - link broken). Do any of you have any valid experiences or recomendations regarding this particular issue? Are there any tools around that I do not know about? ANSWER: I have searched previously for this, with no luck. There does not seem to be any tools available for this conversion, the manual method thereby becomes the only method. And yes, there are consulting firms who will do the manual work for you, but they still do it manually. Crystal Reports and Reporting Services have different architectural styles, making it a difficult task for a conversion tool, so I view it as unlikely that someone will build one anytime soon.
[ "sql-server", "reporting-services", "crystal-reports", "migration" ]
32
17
56,340
7
0
2008-08-19T15:23:17.983000
2008-08-21T18:57:49.067000
16,402
16,416
Easy installation method for windows/ Batch Reference needed?
I have a bunch of files that I need to be able to transport and install quickly. My current method for doing so is moving a flash drive with a readme file of where stuff goes whenever I need to move stuff, which is rather inelegant and cumbersome. My idea for a solution would be to write up a quick script to move files around that I could just click on. I've done some bash scripting before but batch scripting is a little odd to me. Does anyone have a good online reference guide I could use? An alternative soulution I could accept would be a program that makes an installer for you, though I'm a bit against that as I would lose a lot of control. However, I'd be alright with it if it was extremely simple,
Sounds like robocopy tool is exactly what you need. Very powerful replication command-line tool. MS TechNet reference, Wikipedia article about robocopy, Full command switch guide, Batch scripting guide.
Easy installation method for windows/ Batch Reference needed? I have a bunch of files that I need to be able to transport and install quickly. My current method for doing so is moving a flash drive with a readme file of where stuff goes whenever I need to move stuff, which is rather inelegant and cumbersome. My idea for a solution would be to write up a quick script to move files around that I could just click on. I've done some bash scripting before but batch scripting is a little odd to me. Does anyone have a good online reference guide I could use? An alternative soulution I could accept would be a program that makes an installer for you, though I'm a bit against that as I would lose a lot of control. However, I'd be alright with it if it was extremely simple,
TITLE: Easy installation method for windows/ Batch Reference needed? QUESTION: I have a bunch of files that I need to be able to transport and install quickly. My current method for doing so is moving a flash drive with a readme file of where stuff goes whenever I need to move stuff, which is rather inelegant and cumbersome. My idea for a solution would be to write up a quick script to move files around that I could just click on. I've done some bash scripting before but batch scripting is a little odd to me. Does anyone have a good online reference guide I could use? An alternative soulution I could accept would be a program that makes an installer for you, though I'm a bit against that as I would lose a lot of control. However, I'd be alright with it if it was extremely simple, ANSWER: Sounds like robocopy tool is exactly what you need. Very powerful replication command-line tool. MS TechNet reference, Wikipedia article about robocopy, Full command switch guide, Batch scripting guide.
[ "windows", "batch-file", "installation" ]
0
2
355
2
0
2008-08-19T15:26:40.287000
2008-08-19T15:35:27.163000
16,403
16,546
How do you handle white space in your HTML
One of my biggest typographical frustrations about HTML is the way that it mangles conjoined whitespace. For example if I have: Following punctuation rules. With two spaces after the period. One of the two spaces following the period will be considered to be insignificant whitespace and be removed. I can of course, force the whitespace to be significant with: Following punctuation rules. With two spaces after the period. but it just irks me to have to do that and I usually don't bother. Does anyone out there automatically insert significant whitespace into external content submissions that are intended for a web page?
For your specific example, there is no need to worry about it. Web browsers perform typographical rendering and place the correct amount of space between periods and whatever character follows (and it's different depending on the next character, according to kerning rules.) If you want line breaks, isn't really a big deal, is it? Not sure what's worthy of a downmod here... You should not be forcing two spaces after a period, unless you're using a monospace font. For proportional fonts, the rederer kerns the right amount of space after a period. See here and here for detailed discussions.
How do you handle white space in your HTML One of my biggest typographical frustrations about HTML is the way that it mangles conjoined whitespace. For example if I have: Following punctuation rules. With two spaces after the period. One of the two spaces following the period will be considered to be insignificant whitespace and be removed. I can of course, force the whitespace to be significant with: Following punctuation rules. With two spaces after the period. but it just irks me to have to do that and I usually don't bother. Does anyone out there automatically insert significant whitespace into external content submissions that are intended for a web page?
TITLE: How do you handle white space in your HTML QUESTION: One of my biggest typographical frustrations about HTML is the way that it mangles conjoined whitespace. For example if I have: Following punctuation rules. With two spaces after the period. One of the two spaces following the period will be considered to be insignificant whitespace and be removed. I can of course, force the whitespace to be significant with: Following punctuation rules. With two spaces after the period. but it just irks me to have to do that and I usually don't bother. Does anyone out there automatically insert significant whitespace into external content submissions that are intended for a web page? ANSWER: For your specific example, there is no need to worry about it. Web browsers perform typographical rendering and place the correct amount of space between periods and whatever character follows (and it's different depending on the next character, according to kerning rules.) If you want line breaks, isn't really a big deal, is it? Not sure what's worthy of a downmod here... You should not be forcing two spaces after a period, unless you're using a monospace font. For proportional fonts, the rederer kerns the right amount of space after a period. See here and here for detailed discussions.
[ "html", "whitespace" ]
7
6
3,991
8
0
2008-08-19T15:27:31.470000
2008-08-19T16:59:53.047000
16,413
16,444
Parse usable Street Address, City, State, Zip from a string
Problem: I have an address field from an Access database which has been converted to SQL Server 2005. This field has everything all in one field. I need to parse out the address's individual sections into their appropriate fields in a normalized table. I need to do this for approximately 4,000 records, and it needs to be repeatable. Assumptions: Assume an address in the US (for now) assume that the input string will sometimes contain an addressee (the person being addressed) and/or a second street address (i.e. Suite B) states may be abbreviated zip code could be standard 5 digits or zip+4 there are typos in some instances UPDATE: In response to the questions posed, standards were not universally followed; I need need to store the individual values, not just geocode and errors means typo (corrected above) Sample Data: A. P. Croll & Son 2299 Lewes-Georgetown Hwy, Georgetown, DE 19947 11522 Shawnee Road, Greenwood DE 19950 144 Kings Highway, S.W. Dover, DE 19901 Intergrated Const. Services 2 Penns Way Suite 405 New Castle, DE 19720 Humes Realty 33 Bridle Ridge Court, Lewes, DE 19958 Nichols Excavation 2742 Pulaski Hwy Newark, DE 19711 2284 Bryn Zion Road, Smyrna, DE 19904 VEI Dover Crossroads, LLC 1500 Serpentine Road, Suite 100 Baltimore MD 21 580 North Dupont Highway Dover, DE 19901 P.O. Box 778 Dover, DE 19903
I've done a lot of work on this kind of parsing. Because there are errors you won't get 100% accuracy, but there are a few things you can do to get most of the way there, and then do a visual BS test. Here's the general way to go about it. It's not code, because it's pretty academic to write it, there's no weirdness, just lots of string handling. (Now that you've posted some sample data, I've made some minor changes) Work backward. Start from the zip code, which will be near the end, and in one of two known formats: XXXXX or XXXXX-XXXX. If this doesn't appear, you can assume you're in the city, state portion, below. The next thing, before the zip, is going to be the state, and it'll be either in a two-letter format, or as words. You know what these will be, too -- there's only 50 of them. Also, you could soundex the words to help compensate for spelling errors. before that is the city, and it's probably on the same line as the state. You could use a zip-code database to check the city and state based on the zip, or at least use it as a BS detector. The street address will generally be one or two lines. The second line will generally be the suite number if there is one, but it could also be a PO box. It's going to be near-impossible to detect a name on the first or second line, though if it's not prefixed with a number (or if it's prefixed with an "attn:" or "attention to:" it could give you a hint as to whether it's a name or an address line. I hope this helps somewhat.
Parse usable Street Address, City, State, Zip from a string Problem: I have an address field from an Access database which has been converted to SQL Server 2005. This field has everything all in one field. I need to parse out the address's individual sections into their appropriate fields in a normalized table. I need to do this for approximately 4,000 records, and it needs to be repeatable. Assumptions: Assume an address in the US (for now) assume that the input string will sometimes contain an addressee (the person being addressed) and/or a second street address (i.e. Suite B) states may be abbreviated zip code could be standard 5 digits or zip+4 there are typos in some instances UPDATE: In response to the questions posed, standards were not universally followed; I need need to store the individual values, not just geocode and errors means typo (corrected above) Sample Data: A. P. Croll & Son 2299 Lewes-Georgetown Hwy, Georgetown, DE 19947 11522 Shawnee Road, Greenwood DE 19950 144 Kings Highway, S.W. Dover, DE 19901 Intergrated Const. Services 2 Penns Way Suite 405 New Castle, DE 19720 Humes Realty 33 Bridle Ridge Court, Lewes, DE 19958 Nichols Excavation 2742 Pulaski Hwy Newark, DE 19711 2284 Bryn Zion Road, Smyrna, DE 19904 VEI Dover Crossroads, LLC 1500 Serpentine Road, Suite 100 Baltimore MD 21 580 North Dupont Highway Dover, DE 19901 P.O. Box 778 Dover, DE 19903
TITLE: Parse usable Street Address, City, State, Zip from a string QUESTION: Problem: I have an address field from an Access database which has been converted to SQL Server 2005. This field has everything all in one field. I need to parse out the address's individual sections into their appropriate fields in a normalized table. I need to do this for approximately 4,000 records, and it needs to be repeatable. Assumptions: Assume an address in the US (for now) assume that the input string will sometimes contain an addressee (the person being addressed) and/or a second street address (i.e. Suite B) states may be abbreviated zip code could be standard 5 digits or zip+4 there are typos in some instances UPDATE: In response to the questions posed, standards were not universally followed; I need need to store the individual values, not just geocode and errors means typo (corrected above) Sample Data: A. P. Croll & Son 2299 Lewes-Georgetown Hwy, Georgetown, DE 19947 11522 Shawnee Road, Greenwood DE 19950 144 Kings Highway, S.W. Dover, DE 19901 Intergrated Const. Services 2 Penns Way Suite 405 New Castle, DE 19720 Humes Realty 33 Bridle Ridge Court, Lewes, DE 19958 Nichols Excavation 2742 Pulaski Hwy Newark, DE 19711 2284 Bryn Zion Road, Smyrna, DE 19904 VEI Dover Crossroads, LLC 1500 Serpentine Road, Suite 100 Baltimore MD 21 580 North Dupont Highway Dover, DE 19901 P.O. Box 778 Dover, DE 19903 ANSWER: I've done a lot of work on this kind of parsing. Because there are errors you won't get 100% accuracy, but there are a few things you can do to get most of the way there, and then do a visual BS test. Here's the general way to go about it. It's not code, because it's pretty academic to write it, there's no weirdness, just lots of string handling. (Now that you've posted some sample data, I've made some minor changes) Work backward. Start from the zip code, which will be near the end, and in one of two known formats: XXXXX or XXXXX-XXXX. If this doesn't appear, you can assume you're in the city, state portion, below. The next thing, before the zip, is going to be the state, and it'll be either in a two-letter format, or as words. You know what these will be, too -- there's only 50 of them. Also, you could soundex the words to help compensate for spelling errors. before that is the city, and it's probably on the same line as the state. You could use a zip-code database to check the city and state based on the zip, or at least use it as a BS detector. The street address will generally be one or two lines. The second line will generally be the suite number if there is one, but it could also be a PO box. It's going to be near-impossible to detect a name on the first or second line, though if it's not prefixed with a number (or if it's prefixed with an "attn:" or "attention to:" it could give you a hint as to whether it's a name or an address line. I hope this helps somewhat.
[ "string", "parsing", "sql-server-2005", "street-address" ]
133
121
163,624
24
0
2008-08-19T15:34:41.703000
2008-08-19T15:52:05.397000
16,432
18,342
String output: format or concat in C#?
Let's say that you want to output or concat strings. Which of the following styles do you prefer? var p = new { FirstName = "Bill", LastName = "Gates" }; Console.WriteLine("{0} {1}", p.FirstName, p.LastName); Console.WriteLine(p.FirstName + " " + p.LastName); Do you rather use format or do you simply concat strings? What is your favorite? Is one of these hurting your eyes? Do you have any rational arguments to use one and not the other? I'd go for the second one.
Try this code. It's a slightly modified version of your code. I removed Console.WriteLine as it's probably a few orders of magnitude slower than what I'm trying to measure. I'm starting the Stopwatch before the loop and stopping it right after, this way I'm not losing precision if the function takes for example 26.4 ticks to execute. The way you divided the result by some iterations was wrong. See what happens if you have 1,000 milliseconds and 100 milliseconds. In both situations, you will get 0 ms after dividing it by 1,000,000. Code: Stopwatch s = new Stopwatch(); var p = new { FirstName = "Bill", LastName = "Gates" }; int n = 1000000; long fElapsedMilliseconds = 0, fElapsedTicks = 0, cElapsedMilliseconds = 0, cElapsedTicks = 0; string result; s.Start(); for (var i = 0; i < n; i++) result = (p.FirstName + " " + p.LastName); s.Stop(); cElapsedMilliseconds = s.ElapsedMilliseconds; cElapsedTicks = s.ElapsedTicks; s.Reset(); s.Start(); for (var i = 0; i < n; i++) result = string.Format("{0} {1}", p.FirstName, p.LastName); s.Stop(); fElapsedMilliseconds = s.ElapsedMilliseconds; fElapsedTicks = s.ElapsedTicks; s.Reset(); Console.Clear(); Console.WriteLine(n.ToString()+" x result = string.Format(\"{0} {1}\", p.FirstName, p.LastName); took: " + (fElapsedMilliseconds) + "ms - " + (fElapsedTicks) + " ticks"); Console.WriteLine(n.ToString() + " x result = (p.FirstName + \" \" + p.LastName); took: " + (cElapsedMilliseconds) + "ms - " + (cElapsedTicks) + " ticks"); Thread.Sleep(4000); Those are my results: 1000000 x result = string.Format("{0} {1}", p.FirstName, p.LastName); took: 618ms - 2213706 ticks 1000000 x result = (p.FirstName + " " + p.LastName); took: 166ms - 595610 ticks
String output: format or concat in C#? Let's say that you want to output or concat strings. Which of the following styles do you prefer? var p = new { FirstName = "Bill", LastName = "Gates" }; Console.WriteLine("{0} {1}", p.FirstName, p.LastName); Console.WriteLine(p.FirstName + " " + p.LastName); Do you rather use format or do you simply concat strings? What is your favorite? Is one of these hurting your eyes? Do you have any rational arguments to use one and not the other? I'd go for the second one.
TITLE: String output: format or concat in C#? QUESTION: Let's say that you want to output or concat strings. Which of the following styles do you prefer? var p = new { FirstName = "Bill", LastName = "Gates" }; Console.WriteLine("{0} {1}", p.FirstName, p.LastName); Console.WriteLine(p.FirstName + " " + p.LastName); Do you rather use format or do you simply concat strings? What is your favorite? Is one of these hurting your eyes? Do you have any rational arguments to use one and not the other? I'd go for the second one. ANSWER: Try this code. It's a slightly modified version of your code. I removed Console.WriteLine as it's probably a few orders of magnitude slower than what I'm trying to measure. I'm starting the Stopwatch before the loop and stopping it right after, this way I'm not losing precision if the function takes for example 26.4 ticks to execute. The way you divided the result by some iterations was wrong. See what happens if you have 1,000 milliseconds and 100 milliseconds. In both situations, you will get 0 ms after dividing it by 1,000,000. Code: Stopwatch s = new Stopwatch(); var p = new { FirstName = "Bill", LastName = "Gates" }; int n = 1000000; long fElapsedMilliseconds = 0, fElapsedTicks = 0, cElapsedMilliseconds = 0, cElapsedTicks = 0; string result; s.Start(); for (var i = 0; i < n; i++) result = (p.FirstName + " " + p.LastName); s.Stop(); cElapsedMilliseconds = s.ElapsedMilliseconds; cElapsedTicks = s.ElapsedTicks; s.Reset(); s.Start(); for (var i = 0; i < n; i++) result = string.Format("{0} {1}", p.FirstName, p.LastName); s.Stop(); fElapsedMilliseconds = s.ElapsedMilliseconds; fElapsedTicks = s.ElapsedTicks; s.Reset(); Console.Clear(); Console.WriteLine(n.ToString()+" x result = string.Format(\"{0} {1}\", p.FirstName, p.LastName); took: " + (fElapsedMilliseconds) + "ms - " + (fElapsedTicks) + " ticks"); Console.WriteLine(n.ToString() + " x result = (p.FirstName + \" \" + p.LastName); took: " + (cElapsedMilliseconds) + "ms - " + (cElapsedTicks) + " ticks"); Thread.Sleep(4000); Those are my results: 1000000 x result = string.Format("{0} {1}", p.FirstName, p.LastName); took: 618ms - 2213706 ticks 1000000 x result = (p.FirstName + " " + p.LastName); took: 166ms - 595610 ticks
[ "c#", "string", "coding-style", "string.format" ]
184
89
101,454
32
0
2008-08-19T15:46:53.863000
2008-08-20T16:40:14.973000
16,434
129,435
How to test numerical analysis routines?
Are there any good online resources for how to create, maintain and think about writing test routines for numerical analysis code? One of the limitations I can see for something like testing matrix multiplication is that the obvious tests (like having one matrix being the identity) may not fully test the functionality of the code. Also, there is the fact that you are usually dealing with large data structures as well. Does anyone have some good ideas about ways to approach this, or have pointers to good places to look?
It sounds as if you need to think about testing in at least two different ways: Some numerical methods allow for some meta-thinking. For example, invertible operations allow you to set up test cases to see if the result is within acceptable error bounds of the original. For example, matrix M-inverse times the matrix M * random vector V should result in V again, to within some acceptable measure of error. Obviously, this example exercises matrix inverse, matrix multiplication and matrix-vector multiplication. I like chains like these because you can generate quite a lot of random test cases and get statistical coverage that would be a slog to have to write by hand. They don't exercise single operations in isolation, though. Some numerical methods have a closed-form expression of their error. If you can set up a situation with a known solution, you can then compare the difference between the solution and the calculated result, looking for a difference that exceeds these known bounds. Fundamentally, this question illustrates the problem that testing complex methods well requires quite a lot of domain knowledge. Specific references would require a little more specific information about what you're testing. I'd definitely recommend that you at least have Steve Yegge's recommended book list on hand.
How to test numerical analysis routines? Are there any good online resources for how to create, maintain and think about writing test routines for numerical analysis code? One of the limitations I can see for something like testing matrix multiplication is that the obvious tests (like having one matrix being the identity) may not fully test the functionality of the code. Also, there is the fact that you are usually dealing with large data structures as well. Does anyone have some good ideas about ways to approach this, or have pointers to good places to look?
TITLE: How to test numerical analysis routines? QUESTION: Are there any good online resources for how to create, maintain and think about writing test routines for numerical analysis code? One of the limitations I can see for something like testing matrix multiplication is that the obvious tests (like having one matrix being the identity) may not fully test the functionality of the code. Also, there is the fact that you are usually dealing with large data structures as well. Does anyone have some good ideas about ways to approach this, or have pointers to good places to look? ANSWER: It sounds as if you need to think about testing in at least two different ways: Some numerical methods allow for some meta-thinking. For example, invertible operations allow you to set up test cases to see if the result is within acceptable error bounds of the original. For example, matrix M-inverse times the matrix M * random vector V should result in V again, to within some acceptable measure of error. Obviously, this example exercises matrix inverse, matrix multiplication and matrix-vector multiplication. I like chains like these because you can generate quite a lot of random test cases and get statistical coverage that would be a slog to have to write by hand. They don't exercise single operations in isolation, though. Some numerical methods have a closed-form expression of their error. If you can set up a situation with a known solution, you can then compare the difference between the solution and the calculated result, looking for a difference that exceeds these known bounds. Fundamentally, this question illustrates the problem that testing complex methods well requires quite a lot of domain knowledge. Specific references would require a little more specific information about what you're testing. I'd definitely recommend that you at least have Steve Yegge's recommended book list on hand.
[ "testing", "numerical" ]
8
3
1,779
3
0
2008-08-19T15:48:07.857000
2008-09-24T19:47:54.393000
16,447
16,465
Select Query on 2 tables, on different database servers
I am trying to generate a report by querying 2 databases (Sybase) in classic ASP. I have created 2 connection strings: connA for databaseA connB for databaseB Both databases are present on the same server (don't know if this matters) Queries: q1 = SELECT column1 INTO #temp FROM databaseA..table1 WHERE xyz="A" q2 = SELECT columnA,columnB,...,columnZ FROM table2 a #temp b WHERE b.column1=a.columnB followed by: response.Write(rstsql) set rstSQL = CreateObject("ADODB.Recordset") rstSQL.Open q1, connA rstSQL.Open q2, connB When I try to open up this page in a browser, I get error message: Microsoft OLE DB Provider for ODBC Drivers error '80040e37' [DataDirect][ODBC Sybase Wire Protocol driver][SQL Server]#temp not found. Specify owner.objectname or use sp_help to check whether the object exists (sp_help may produce lots of output). Could anyone please help me understand what the problem is and help me fix it? Thanks.
With both queries, it looks like you are trying to insert into #temp. #temp is located on one of the databases (for arguments sake, databaseA). So when you try to insert into #temp from databaseB, it reports that it does not exist. Try changing it from Into #temp From to Into databaseA.dbo.#temp From in both statements. Also, make sure that the connection strings have permissions on the other DB, otherwise this will not work. Update: relating to the temp table going out of scope - if you have one connection string that has permissions on both databases, then you could use this for both queries (while keeping the connection alive). While querying the table in the other DB, be sure to use [DBName].[Owner].[TableName] format when referring to the table.
Select Query on 2 tables, on different database servers I am trying to generate a report by querying 2 databases (Sybase) in classic ASP. I have created 2 connection strings: connA for databaseA connB for databaseB Both databases are present on the same server (don't know if this matters) Queries: q1 = SELECT column1 INTO #temp FROM databaseA..table1 WHERE xyz="A" q2 = SELECT columnA,columnB,...,columnZ FROM table2 a #temp b WHERE b.column1=a.columnB followed by: response.Write(rstsql) set rstSQL = CreateObject("ADODB.Recordset") rstSQL.Open q1, connA rstSQL.Open q2, connB When I try to open up this page in a browser, I get error message: Microsoft OLE DB Provider for ODBC Drivers error '80040e37' [DataDirect][ODBC Sybase Wire Protocol driver][SQL Server]#temp not found. Specify owner.objectname or use sp_help to check whether the object exists (sp_help may produce lots of output). Could anyone please help me understand what the problem is and help me fix it? Thanks.
TITLE: Select Query on 2 tables, on different database servers QUESTION: I am trying to generate a report by querying 2 databases (Sybase) in classic ASP. I have created 2 connection strings: connA for databaseA connB for databaseB Both databases are present on the same server (don't know if this matters) Queries: q1 = SELECT column1 INTO #temp FROM databaseA..table1 WHERE xyz="A" q2 = SELECT columnA,columnB,...,columnZ FROM table2 a #temp b WHERE b.column1=a.columnB followed by: response.Write(rstsql) set rstSQL = CreateObject("ADODB.Recordset") rstSQL.Open q1, connA rstSQL.Open q2, connB When I try to open up this page in a browser, I get error message: Microsoft OLE DB Provider for ODBC Drivers error '80040e37' [DataDirect][ODBC Sybase Wire Protocol driver][SQL Server]#temp not found. Specify owner.objectname or use sp_help to check whether the object exists (sp_help may produce lots of output). Could anyone please help me understand what the problem is and help me fix it? Thanks. ANSWER: With both queries, it looks like you are trying to insert into #temp. #temp is located on one of the databases (for arguments sake, databaseA). So when you try to insert into #temp from databaseB, it reports that it does not exist. Try changing it from Into #temp From to Into databaseA.dbo.#temp From in both statements. Also, make sure that the connection strings have permissions on the other DB, otherwise this will not work. Update: relating to the temp table going out of scope - if you have one connection string that has permissions on both databases, then you could use this for both queries (while keeping the connection alive). While querying the table in the other DB, be sure to use [DBName].[Owner].[TableName] format when referring to the table.
[ "sql", "asp-classic", "vbscript", "sybase" ]
4
4
19,266
3
0
2008-08-19T15:53:19.373000
2008-08-19T15:59:47.833000
16,451
711,398
Calling .NET Web Service (WSE 2/3, WS-Security) from Java
I need to call a web service written in.NET from Java. The web service implements the WS-Security stack (either WSE 2 or WSE 3, it's not clear from the information I have). The information that I received from the service provider included WSDL, a policyCache.config file, some sample C# code, and a sample application that can successfully call the service. This isn't as useful as it sounds because it's not clear how I'm supposed to use this information to write a Java client. If the web service request isn't signed according to the policy then it is rejected by the service. I'm trying to use Apache Axis2 and I can't find any instructions on how I'm supposed to use the policyCahce.config file and the WSDL to generate a client. There are several examples that I have found on the Web but in all cases the authors of the examples had control of both the service and the client and so were able to make tweaks on both sides in order to get it to work. I'm not in that position. Has anyone done this successfully?
This seems to be a popular question so I'll provide an overview of what we did in our situation. It seems that services built in.NET are following an older ws-addressing standard ( http://schemas.xmlsoap.org/ws/2004/03/addressing/ ) and axis2 only understands the newer standard ( http://schemas.xmlsoap.org/ws/2004/08/addressing/ ). In addition, the policyCache.config file provided is in a form that the axis2 rampart module can't understand. So the steps we had to do, in a nutshell: Read the policyCache.config and try to understand it. Then rewrite it into a policy that rampart could understand. (Some updated docs helped.) Configure rampart with this policy. Take the keys that were provided in the.pfx file and convert them to a java key store. There is a utility that comes with Jetty that can do that. Configure rampart with that key store. Write a custom axis2 handler that backward-converts the newer ws-addressing stuff that comes out of axis2 into the older stuff expected by the service. Configure axis2 to use the handler on outgoing messages. In the end it was a lot of configuration and code for something that is supposed to be an open standard supported by the vendors. Although I'm not sure what the alternative is...can you wait for the vendors (or in this case, the one vendor) to make sure that everything will inter-op? As a postscript I'll add that I didn't end up doing the work, it was someone else on my team, but I think I got the salient details correct. The other option that I was considering (before my teammate took over) was to call the WSS4J API directly to construct the SOAP envelope as the.NET service expected it. I think that would have worked too.
Calling .NET Web Service (WSE 2/3, WS-Security) from Java I need to call a web service written in.NET from Java. The web service implements the WS-Security stack (either WSE 2 or WSE 3, it's not clear from the information I have). The information that I received from the service provider included WSDL, a policyCache.config file, some sample C# code, and a sample application that can successfully call the service. This isn't as useful as it sounds because it's not clear how I'm supposed to use this information to write a Java client. If the web service request isn't signed according to the policy then it is rejected by the service. I'm trying to use Apache Axis2 and I can't find any instructions on how I'm supposed to use the policyCahce.config file and the WSDL to generate a client. There are several examples that I have found on the Web but in all cases the authors of the examples had control of both the service and the client and so were able to make tweaks on both sides in order to get it to work. I'm not in that position. Has anyone done this successfully?
TITLE: Calling .NET Web Service (WSE 2/3, WS-Security) from Java QUESTION: I need to call a web service written in.NET from Java. The web service implements the WS-Security stack (either WSE 2 or WSE 3, it's not clear from the information I have). The information that I received from the service provider included WSDL, a policyCache.config file, some sample C# code, and a sample application that can successfully call the service. This isn't as useful as it sounds because it's not clear how I'm supposed to use this information to write a Java client. If the web service request isn't signed according to the policy then it is rejected by the service. I'm trying to use Apache Axis2 and I can't find any instructions on how I'm supposed to use the policyCahce.config file and the WSDL to generate a client. There are several examples that I have found on the Web but in all cases the authors of the examples had control of both the service and the client and so were able to make tweaks on both sides in order to get it to work. I'm not in that position. Has anyone done this successfully? ANSWER: This seems to be a popular question so I'll provide an overview of what we did in our situation. It seems that services built in.NET are following an older ws-addressing standard ( http://schemas.xmlsoap.org/ws/2004/03/addressing/ ) and axis2 only understands the newer standard ( http://schemas.xmlsoap.org/ws/2004/08/addressing/ ). In addition, the policyCache.config file provided is in a form that the axis2 rampart module can't understand. So the steps we had to do, in a nutshell: Read the policyCache.config and try to understand it. Then rewrite it into a policy that rampart could understand. (Some updated docs helped.) Configure rampart with this policy. Take the keys that were provided in the.pfx file and convert them to a java key store. There is a utility that comes with Jetty that can do that. Configure rampart with that key store. Write a custom axis2 handler that backward-converts the newer ws-addressing stuff that comes out of axis2 into the older stuff expected by the service. Configure axis2 to use the handler on outgoing messages. In the end it was a lot of configuration and code for something that is supposed to be an open standard supported by the vendors. Although I'm not sure what the alternative is...can you wait for the vendors (or in this case, the one vendor) to make sure that everything will inter-op? As a postscript I'll add that I didn't end up doing the work, it was someone else on my team, but I think I got the salient details correct. The other option that I was considering (before my teammate took over) was to call the WSS4J API directly to construct the SOAP envelope as the.NET service expected it. I think that would have worked too.
[ "java", ".net", "apache-axis", "ws-security", "wse" ]
23
10
14,127
5
0
2008-08-19T15:54:59.153000
2009-04-02T20:08:38.633000
16,458
137,090
Dynamic Alphabetical Navigation
I'm using ColdFusion to return a result set from a SQL database and turn it into a list. I need some way to generate an alphabetical navigation bar for that list. I have ColdFusion and the jQuery library available. I'm looking to generate something like this: A | B | C |... - A - A - B - B - B - C - D Where clicking on one of the letters drops you down the page to the first item for that letter. Not all 26 letters of the alphabet are necessarily in use.
So, there were plenty of good suggestions, but none did exactly what I wanted. Fortunately I was able to use them to figure out what I really wanted to do. The only thing the following doesn't do is print the last few unused letters (if there are any). That's why I have that cfif statement checking for 'W' as that's the last letter I use, otherwise it should check for Z. SELECT title, url, substr(titles,1,1) as indexLetter FROM list ORDER BY indexLetter,title #ucase(qTitles.indexletter)# | while(chr(linkLetter)!= qTitles.indexletter) { WriteOutput(" " & chr(linkLetter) & " "); IF(linkLetter!= asc('W')){WriteOutput("|");}; ++LinkLetter; } #ucase(qTitles.indexletter)# | #ucase(qTitles.indexletter)# #title#
Dynamic Alphabetical Navigation I'm using ColdFusion to return a result set from a SQL database and turn it into a list. I need some way to generate an alphabetical navigation bar for that list. I have ColdFusion and the jQuery library available. I'm looking to generate something like this: A | B | C |... - A - A - B - B - B - C - D Where clicking on one of the letters drops you down the page to the first item for that letter. Not all 26 letters of the alphabet are necessarily in use.
TITLE: Dynamic Alphabetical Navigation QUESTION: I'm using ColdFusion to return a result set from a SQL database and turn it into a list. I need some way to generate an alphabetical navigation bar for that list. I have ColdFusion and the jQuery library available. I'm looking to generate something like this: A | B | C |... - A - A - B - B - B - C - D Where clicking on one of the letters drops you down the page to the first item for that letter. Not all 26 letters of the alphabet are necessarily in use. ANSWER: So, there were plenty of good suggestions, but none did exactly what I wanted. Fortunately I was able to use them to figure out what I really wanted to do. The only thing the following doesn't do is print the last few unused letters (if there are any). That's why I have that cfif statement checking for 'W' as that's the last letter I use, otherwise it should check for Z. SELECT title, url, substr(titles,1,1) as indexLetter FROM list ORDER BY indexLetter,title #ucase(qTitles.indexletter)# | while(chr(linkLetter)!= qTitles.indexletter) { WriteOutput(" " & chr(linkLetter) & " "); IF(linkLetter!= asc('W')){WriteOutput("|");}; ++LinkLetter; } #ucase(qTitles.indexletter)# | #ucase(qTitles.indexletter)# #title#
[ "javascript", "jquery", "sql", "html", "coldfusion" ]
9
0
3,444
5
0
2008-08-19T15:57:33.827000
2008-09-26T00:25:36.013000
16,460
16,500
Removing N items from a list conditionally
I was writing some ASP.NET control when I came to the scenario where I needed to remove items from a list, only when they matched a certain condition. The RemoveAll method of the generic List class does a good job, but removes all items that match the condition, specified by the predicate. What if I want to only remove a certain number of items specifying the condition? What do you think is the best way to do this?
If you want to specify both a limit for number of items to remove and a condition to select the items to remove, you can use this approach: int limit = 30; // Suppose you want to remove 30 items at most list.RemoveAll(item => ShouldIRemoveThis(item) && limit-- > 0);
Removing N items from a list conditionally I was writing some ASP.NET control when I came to the scenario where I needed to remove items from a list, only when they matched a certain condition. The RemoveAll method of the generic List class does a good job, but removes all items that match the condition, specified by the predicate. What if I want to only remove a certain number of items specifying the condition? What do you think is the best way to do this?
TITLE: Removing N items from a list conditionally QUESTION: I was writing some ASP.NET control when I came to the scenario where I needed to remove items from a list, only when they matched a certain condition. The RemoveAll method of the generic List class does a good job, but removes all items that match the condition, specified by the predicate. What if I want to only remove a certain number of items specifying the condition? What do you think is the best way to do this? ANSWER: If you want to specify both a limit for number of items to remove and a condition to select the items to remove, you can use this approach: int limit = 30; // Suppose you want to remove 30 items at most list.RemoveAll(item => ShouldIRemoveThis(item) && limit-- > 0);
[ ".net" ]
2
8
817
6
0
2008-08-19T15:57:51.300000
2008-08-19T16:19:51.397000
16,473
16,484
Can using lambdas as event handlers cause a memory leak?
Say we have the following method: private MyObject foo = new MyObject(); // and later in the class public void PotentialMemoryLeaker(){ int firedCount = 0; foo.AnEvent += (o,e) => { firedCount++;Console.Write(firedCount);}; foo.MethodThatFiresAnEvent(); } If the class with this method is instantiated and the PotentialMemoryLeaker method is called multiple times, do we leak memory? Is there any way to unhook that lambda event handler after we're done calling MethodThatFiresAnEvent?
Yes, save it to a variable and unhook it. DelegateType evt = (o, e) => { firedCount++; Console.Write(firedCount); }; foo.AnEvent += evt; foo.MethodThatFiresAnEvent(); foo.AnEvent -= evt; And yes, if you don't, you'll leak memory, as you'll hook up a new delegate object each time. You'll also notice this because each time you call this method, it'll dump to the console an increasing number of lines (not just an increasing number, but for one call to MethodThatFiresAnEvent it'll dump any number of items, once for each hooked up anonymous method).
Can using lambdas as event handlers cause a memory leak? Say we have the following method: private MyObject foo = new MyObject(); // and later in the class public void PotentialMemoryLeaker(){ int firedCount = 0; foo.AnEvent += (o,e) => { firedCount++;Console.Write(firedCount);}; foo.MethodThatFiresAnEvent(); } If the class with this method is instantiated and the PotentialMemoryLeaker method is called multiple times, do we leak memory? Is there any way to unhook that lambda event handler after we're done calling MethodThatFiresAnEvent?
TITLE: Can using lambdas as event handlers cause a memory leak? QUESTION: Say we have the following method: private MyObject foo = new MyObject(); // and later in the class public void PotentialMemoryLeaker(){ int firedCount = 0; foo.AnEvent += (o,e) => { firedCount++;Console.Write(firedCount);}; foo.MethodThatFiresAnEvent(); } If the class with this method is instantiated and the PotentialMemoryLeaker method is called multiple times, do we leak memory? Is there any way to unhook that lambda event handler after we're done calling MethodThatFiresAnEvent? ANSWER: Yes, save it to a variable and unhook it. DelegateType evt = (o, e) => { firedCount++; Console.Write(firedCount); }; foo.AnEvent += evt; foo.MethodThatFiresAnEvent(); foo.AnEvent -= evt; And yes, if you don't, you'll leak memory, as you'll hook up a new delegate object each time. You'll also notice this because each time you call this method, it'll dump to the console an increasing number of lines (not just an increasing number, but for one call to MethodThatFiresAnEvent it'll dump any number of items, once for each hooked up anonymous method).
[ "memory-leaks", "lambda", "event-handling" ]
20
16
7,241
5
0
2008-08-19T16:03:46.187000
2008-08-19T16:08:24.663000
16,483
16,534
Convince Firefox to send an If-Modified-Since header over HTTPS
How can I convince Firefox (3.0.1, if it matters) to send an If-Modified-Since header in an HTTPS request? It sends the header if the request uses plain HTTP and my server dutifully honors it. But when I request the same resource from the same server using HTTPS instead (i.e., simply changing the http:// in the URL to https://) then Firefox does not send an If-Modified-Since header at all. Is this behavior mandated by the SSL spec or something? Here are some example HTTP and HTTPS request/response pairs, pulled using the Live HTTP Headers Firefox extension, with some differences in bold: HTTP request/response: http://myserver.com:30000/scripts/site.js GET /scripts/site.js HTTP/1.1 Host: myserver.com:30000 User-Agent: Mozilla/5.0 (...) Gecko/2008070206 Firefox/3.0.1 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 300 Connection: keep-alive If-Modified-Since: Tue, 19 Aug 2008 15:57:30 GMT If-None-Match: "a0501d1-300a-454d22526ae80"-gzip Cache-Control: max-age=0 HTTP/1.x 304 Not Modified Date: Tue, 19 Aug 2008 15:59:23 GMT Server: Apache/2.2.8 (Unix) mod_ssl/2.2.8 OpenSSL/0.9.8 Connection: Keep-Alive Keep-Alive: timeout=5, max=99 Etag: "a0501d1-300a-454d22526ae80"-gzip HTTPS request/response: https://myserver.com:30001/scripts/site.js GET /scripts/site.js HTTP/1.1 Host: myserver.com:30001 User-Agent: Mozilla/5.0 (...) Gecko/2008070206 Firefox/3.0.1 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 300 Connection: keep-alive HTTP/1.x 200 OK Date: Tue, 19 Aug 2008 16:00:14 GMT Server: Apache/2.2.8 (Unix) mod_ssl/2.2.8 OpenSSL/0.9.8 Last-Modified: Tue, 19 Aug 2008 15:57:30 GMT Etag: "a0501d1-300a-454d22526ae80"-gzip Accept-Ranges: bytes Content-Encoding: gzip Content-Length: 3766 Keep-Alive: timeout=5, max=100 Connection: Keep-Alive Content-Type: text/javascript UPDATE: Setting browser.cache.disk_cache_ssl to true did the trick (which is odd because, as Nickolay points out, there's still the memory cache). Adding a "Cache-control: public" header to the response also worked. Thanks!
HTTPS requests are not cached so sending an If-Modified-Since doesn't make any sense. The not caching is a security precaution. The not caching on disk is a security pre-caution, but it seems it indeed affects the If-Modified-Since behavior (glancing over the code). Try setting the Firefox preference (in about:config) browser.cache.disk_cache_ssl to true. If that helps, try sending Cache-Control: public header in your response. UPDATE: Firefox behavior was changed for Gecko 2.0 (Firefox 4) -- HTTPS content is now cached.
Convince Firefox to send an If-Modified-Since header over HTTPS How can I convince Firefox (3.0.1, if it matters) to send an If-Modified-Since header in an HTTPS request? It sends the header if the request uses plain HTTP and my server dutifully honors it. But when I request the same resource from the same server using HTTPS instead (i.e., simply changing the http:// in the URL to https://) then Firefox does not send an If-Modified-Since header at all. Is this behavior mandated by the SSL spec or something? Here are some example HTTP and HTTPS request/response pairs, pulled using the Live HTTP Headers Firefox extension, with some differences in bold: HTTP request/response: http://myserver.com:30000/scripts/site.js GET /scripts/site.js HTTP/1.1 Host: myserver.com:30000 User-Agent: Mozilla/5.0 (...) Gecko/2008070206 Firefox/3.0.1 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 300 Connection: keep-alive If-Modified-Since: Tue, 19 Aug 2008 15:57:30 GMT If-None-Match: "a0501d1-300a-454d22526ae80"-gzip Cache-Control: max-age=0 HTTP/1.x 304 Not Modified Date: Tue, 19 Aug 2008 15:59:23 GMT Server: Apache/2.2.8 (Unix) mod_ssl/2.2.8 OpenSSL/0.9.8 Connection: Keep-Alive Keep-Alive: timeout=5, max=99 Etag: "a0501d1-300a-454d22526ae80"-gzip HTTPS request/response: https://myserver.com:30001/scripts/site.js GET /scripts/site.js HTTP/1.1 Host: myserver.com:30001 User-Agent: Mozilla/5.0 (...) Gecko/2008070206 Firefox/3.0.1 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 300 Connection: keep-alive HTTP/1.x 200 OK Date: Tue, 19 Aug 2008 16:00:14 GMT Server: Apache/2.2.8 (Unix) mod_ssl/2.2.8 OpenSSL/0.9.8 Last-Modified: Tue, 19 Aug 2008 15:57:30 GMT Etag: "a0501d1-300a-454d22526ae80"-gzip Accept-Ranges: bytes Content-Encoding: gzip Content-Length: 3766 Keep-Alive: timeout=5, max=100 Connection: Keep-Alive Content-Type: text/javascript UPDATE: Setting browser.cache.disk_cache_ssl to true did the trick (which is odd because, as Nickolay points out, there's still the memory cache). Adding a "Cache-control: public" header to the response also worked. Thanks!
TITLE: Convince Firefox to send an If-Modified-Since header over HTTPS QUESTION: How can I convince Firefox (3.0.1, if it matters) to send an If-Modified-Since header in an HTTPS request? It sends the header if the request uses plain HTTP and my server dutifully honors it. But when I request the same resource from the same server using HTTPS instead (i.e., simply changing the http:// in the URL to https://) then Firefox does not send an If-Modified-Since header at all. Is this behavior mandated by the SSL spec or something? Here are some example HTTP and HTTPS request/response pairs, pulled using the Live HTTP Headers Firefox extension, with some differences in bold: HTTP request/response: http://myserver.com:30000/scripts/site.js GET /scripts/site.js HTTP/1.1 Host: myserver.com:30000 User-Agent: Mozilla/5.0 (...) Gecko/2008070206 Firefox/3.0.1 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 300 Connection: keep-alive If-Modified-Since: Tue, 19 Aug 2008 15:57:30 GMT If-None-Match: "a0501d1-300a-454d22526ae80"-gzip Cache-Control: max-age=0 HTTP/1.x 304 Not Modified Date: Tue, 19 Aug 2008 15:59:23 GMT Server: Apache/2.2.8 (Unix) mod_ssl/2.2.8 OpenSSL/0.9.8 Connection: Keep-Alive Keep-Alive: timeout=5, max=99 Etag: "a0501d1-300a-454d22526ae80"-gzip HTTPS request/response: https://myserver.com:30001/scripts/site.js GET /scripts/site.js HTTP/1.1 Host: myserver.com:30001 User-Agent: Mozilla/5.0 (...) Gecko/2008070206 Firefox/3.0.1 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 300 Connection: keep-alive HTTP/1.x 200 OK Date: Tue, 19 Aug 2008 16:00:14 GMT Server: Apache/2.2.8 (Unix) mod_ssl/2.2.8 OpenSSL/0.9.8 Last-Modified: Tue, 19 Aug 2008 15:57:30 GMT Etag: "a0501d1-300a-454d22526ae80"-gzip Accept-Ranges: bytes Content-Encoding: gzip Content-Length: 3766 Keep-Alive: timeout=5, max=100 Connection: Keep-Alive Content-Type: text/javascript UPDATE: Setting browser.cache.disk_cache_ssl to true did the trick (which is odd because, as Nickolay points out, there's still the memory cache). Adding a "Cache-control: public" header to the response also worked. Thanks! ANSWER: HTTPS requests are not cached so sending an If-Modified-Since doesn't make any sense. The not caching is a security precaution. The not caching on disk is a security pre-caution, but it seems it indeed affects the If-Modified-Since behavior (glancing over the code). Try setting the Firefox preference (in about:config) browser.cache.disk_cache_ssl to true. If that helps, try sending Cache-Control: public header in your response. UPDATE: Firefox behavior was changed for Gecko 2.0 (Firefox 4) -- HTTPS content is now cached.
[ "firefox", "https" ]
14
14
5,405
2
0
2008-08-19T16:07:50.593000
2008-08-19T16:51:42.157000
16,487
1,449,595
How can I deploy artifacts from a Maven build to the SourceForge File Release System?
I am using SourceForge for some Open Source projects and I want to automate the deployment of releases to the SourceForge File Release System. I use Maven for my builds and the standard SFTP deployment mechanism doesn't seem to work unless you do some manual preparation work. I have come across some old postings on other forums suggesting that the only approach is to write a Wagon specifically for SourceForge. Has anybody had any recent experience with this?
I'm not able to test this to confirm, but I believe it is possible without writing any plugins. You can deploy to SourceForge using SCP, and the maven-deploy-plugin can be configured to use SCP so it should work. You can also deploy your site to SourceForge via SCP. You would configure the SourceForge server in your settings.xml to use a "combined" username with a comma separator. With these credentials: SourceForge username: foo SourceForge user password: secret SourceForge project name: bar Path: /home/frs/project/P/PR/PROJECT_UNIX_NAME/ - Substitute your project UNIX name data for /P/PR/PROJECT_UNIX_NAME The server element would look like this: sourceforge foo,bar secret And the distributionManagement section in your POM would look like this: ssh-repository scpexe://frs.sourceforge.net:/home/frs/project/P/PR/PROJECT_UNIX_NAME Finally declare that ssh-external is to be used: org.apache.maven.wagon wagon-ssh-external 1.0-alpha-5 If this doesn't work, you may be able to use the recommended approach in the site reference above, i.e. create a shell on shell.sourceforge.net with your username and project group: ssh -t, @shell.sf.net create Then use shell.sourceforge.net (instead of web.sourceforge.net) in your site URL in the diestributionManagement section: scp://shell.sourceforge.net/home/frs/project/P/PR/PROJECT_UNIX_NAME/
How can I deploy artifacts from a Maven build to the SourceForge File Release System? I am using SourceForge for some Open Source projects and I want to automate the deployment of releases to the SourceForge File Release System. I use Maven for my builds and the standard SFTP deployment mechanism doesn't seem to work unless you do some manual preparation work. I have come across some old postings on other forums suggesting that the only approach is to write a Wagon specifically for SourceForge. Has anybody had any recent experience with this?
TITLE: How can I deploy artifacts from a Maven build to the SourceForge File Release System? QUESTION: I am using SourceForge for some Open Source projects and I want to automate the deployment of releases to the SourceForge File Release System. I use Maven for my builds and the standard SFTP deployment mechanism doesn't seem to work unless you do some manual preparation work. I have come across some old postings on other forums suggesting that the only approach is to write a Wagon specifically for SourceForge. Has anybody had any recent experience with this? ANSWER: I'm not able to test this to confirm, but I believe it is possible without writing any plugins. You can deploy to SourceForge using SCP, and the maven-deploy-plugin can be configured to use SCP so it should work. You can also deploy your site to SourceForge via SCP. You would configure the SourceForge server in your settings.xml to use a "combined" username with a comma separator. With these credentials: SourceForge username: foo SourceForge user password: secret SourceForge project name: bar Path: /home/frs/project/P/PR/PROJECT_UNIX_NAME/ - Substitute your project UNIX name data for /P/PR/PROJECT_UNIX_NAME The server element would look like this: sourceforge foo,bar secret And the distributionManagement section in your POM would look like this: ssh-repository scpexe://frs.sourceforge.net:/home/frs/project/P/PR/PROJECT_UNIX_NAME Finally declare that ssh-external is to be used: org.apache.maven.wagon wagon-ssh-external 1.0-alpha-5 If this doesn't work, you may be able to use the recommended approach in the site reference above, i.e. create a shell on shell.sourceforge.net with your username and project group: ssh -t, @shell.sf.net create Then use shell.sourceforge.net (instead of web.sourceforge.net) in your site URL in the diestributionManagement section: scp://shell.sourceforge.net/home/frs/project/P/PR/PROJECT_UNIX_NAME/
[ "java", "maven-2", "sourceforge" ]
12
10
8,725
9
0
2008-08-19T16:11:16.297000
2009-09-19T21:33:10.380000
16,491
16,502
Restore database backup over the network
How do you restore a database backup using SQL Server 2005 over the network? I recall doing this before but there was something odd about the way you had to do it.
The database is often running as a service under an account with no network access. If this is the case, then you wouldn't be able to restore directly over the network. Either the backup needs to be copied to the local machine or the database service needs to run as a user with the proper network access.
Restore database backup over the network How do you restore a database backup using SQL Server 2005 over the network? I recall doing this before but there was something odd about the way you had to do it.
TITLE: Restore database backup over the network QUESTION: How do you restore a database backup using SQL Server 2005 over the network? I recall doing this before but there was something odd about the way you had to do it. ANSWER: The database is often running as a service under an account with no network access. If this is the case, then you wouldn't be able to restore directly over the network. Either the backup needs to be copied to the local machine or the database service needs to run as a user with the proper network access.
[ "sql-server", "database", "sql-server-2005", "backup", "restore" ]
51
23
93,054
10
0
2008-08-19T16:13:31.813000
2008-08-19T16:20:53.687000
16,501
16,509
What is a lambda (function)?
For a person without a comp-sci background, what is a lambda in the world of Computer Science?
Lambda comes from the Lambda Calculus and refers to anonymous functions in programming. Why is this cool? It allows you to write quick throw away functions without naming them. It also provides a nice way to write closures. With that power you can do things like this. Python def adder(x): return lambda y: x + y add5 = adder(5) add5(1) 6 As you can see from the snippet of Python, the function adder takes in an argument x, and returns an anonymous function, or lambda, that takes another argument y. That anonymous function allows you to create functions from functions. This is a simple example, but it should convey the power lambdas and closures have. Examples in other languages Perl 5 sub adder { my ($x) = @_; return sub { my ($y) = @_; $x + $y } } my $add5 = adder(5); print &$add5(1) == 6? "ok\n": "not ok\n"; JavaScript var adder = function (x) { return function (y) { return x + y; }; }; add5 = adder(5); add5(1) == 6 JavaScript (ES6) const adder = x => y => x + y; add5 = adder(5); add5(1) == 6 Scheme (define adder (lambda (x) (lambda (y) (+ x y)))) (define add5 (adder 5)) (add5 1) 6 C# 3.5 or higher Func > adder = (int x) => (int y) => x + y; // `int` declarations optional Func add5 = adder(5); var add6 = adder(6); // Using implicit typing Debug.Assert(add5(1) == 6); Debug.Assert(add6(-1) == 5); // Closure example int yEnclosed = 1; Func addWithClosure = (x) => x + yEnclosed; Debug.Assert(addWithClosure(2) == 3); Swift func adder(x: Int) -> (Int) -> Int{ return { y in x + y } } let add5 = adder(5) add5(1) 6 PHP $a = 1; $b = 2; $lambda = fn () => $a + $b; echo $lambda(); Haskell (\x y -> x + y) Java see this post // The following is an example of Predicate: // a functional interface that takes an argument // and returns a boolean primitive type. Predicate pred = x -> x % 2 == 0; // Tests if the parameter is even. boolean result = pred.test(4); // true Lua adder = function(x) return function(y) return x + y end end add5 = adder(5) add5(1) == 6 -- true Kotlin val pred = { x: Int -> x % 2 == 0 } val result = pred(4) // true Ruby Ruby is slightly different in that you cannot call a lambda using the exact same syntax as calling a function, but it still has lambdas. def adder(x) lambda { |y| x + y } end add5 = adder(5) add5[1] == 6 Ruby being Ruby, there is a shorthand for lambdas, so you can define adder this way: def adder(x) -> y { x + y } end R adder <- function(x) { function(y) x + y } add5 <- adder(5) add5(1) #> [1] 6
What is a lambda (function)? For a person without a comp-sci background, what is a lambda in the world of Computer Science?
TITLE: What is a lambda (function)? QUESTION: For a person without a comp-sci background, what is a lambda in the world of Computer Science? ANSWER: Lambda comes from the Lambda Calculus and refers to anonymous functions in programming. Why is this cool? It allows you to write quick throw away functions without naming them. It also provides a nice way to write closures. With that power you can do things like this. Python def adder(x): return lambda y: x + y add5 = adder(5) add5(1) 6 As you can see from the snippet of Python, the function adder takes in an argument x, and returns an anonymous function, or lambda, that takes another argument y. That anonymous function allows you to create functions from functions. This is a simple example, but it should convey the power lambdas and closures have. Examples in other languages Perl 5 sub adder { my ($x) = @_; return sub { my ($y) = @_; $x + $y } } my $add5 = adder(5); print &$add5(1) == 6? "ok\n": "not ok\n"; JavaScript var adder = function (x) { return function (y) { return x + y; }; }; add5 = adder(5); add5(1) == 6 JavaScript (ES6) const adder = x => y => x + y; add5 = adder(5); add5(1) == 6 Scheme (define adder (lambda (x) (lambda (y) (+ x y)))) (define add5 (adder 5)) (add5 1) 6 C# 3.5 or higher Func > adder = (int x) => (int y) => x + y; // `int` declarations optional Func add5 = adder(5); var add6 = adder(6); // Using implicit typing Debug.Assert(add5(1) == 6); Debug.Assert(add6(-1) == 5); // Closure example int yEnclosed = 1; Func addWithClosure = (x) => x + yEnclosed; Debug.Assert(addWithClosure(2) == 3); Swift func adder(x: Int) -> (Int) -> Int{ return { y in x + y } } let add5 = adder(5) add5(1) 6 PHP $a = 1; $b = 2; $lambda = fn () => $a + $b; echo $lambda(); Haskell (\x y -> x + y) Java see this post // The following is an example of Predicate: // a functional interface that takes an argument // and returns a boolean primitive type. Predicate pred = x -> x % 2 == 0; // Tests if the parameter is even. boolean result = pred.test(4); // true Lua adder = function(x) return function(y) return x + y end end add5 = adder(5) add5(1) == 6 -- true Kotlin val pred = { x: Int -> x % 2 == 0 } val result = pred(4) // true Ruby Ruby is slightly different in that you cannot call a lambda using the exact same syntax as calling a function, but it still has lambdas. def adder(x) lambda { |y| x + y } end add5 = adder(5) add5[1] == 6 Ruby being Ruby, there is a shorthand for lambdas, so you can define adder this way: def adder(x) -> y { x + y } end R adder <- function(x) { function(y) x + y } add5 <- adder(5) add5(1) #> [1] 6
[ "lambda", "language-agnostic", "computer-science", "terminology", "theory" ]
849
1,206
394,608
24
0
2008-08-19T16:20:37.650000
2008-08-19T16:27:22.643000
16,517
16,519
Image size for BannerBitmap property in Windows Installer
I'm working on a quick setup program in Visual Studio and wanted to change the banner bitmap. Anyone know off-hand what the ideal (or the required) dimensions are for the new banner image? Thanks.
Found it on MSDN docs for BannerBitmap Property: For best results, you should use a bitmap with dimensions of 500 pixels wide by 70 pixels high.
Image size for BannerBitmap property in Windows Installer I'm working on a quick setup program in Visual Studio and wanted to change the banner bitmap. Anyone know off-hand what the ideal (or the required) dimensions are for the new banner image? Thanks.
TITLE: Image size for BannerBitmap property in Windows Installer QUESTION: I'm working on a quick setup program in Visual Studio and wanted to change the banner bitmap. Anyone know off-hand what the ideal (or the required) dimensions are for the new banner image? Thanks. ANSWER: Found it on MSDN docs for BannerBitmap Property: For best results, you should use a bitmap with dimensions of 500 pixels wide by 70 pixels high.
[ "windows-installer" ]
46
77
25,012
1
0
2008-08-19T16:32:01.417000
2008-08-19T16:33:47.560000
16,529
16,549
Communication between Javascript and the server
I've been developing a "Form Builder" in Javascript, and coming up to the part where I'll be sending the spec for the form back to the server to be stored. The builder maintains an internal data structure that represents the fields, label, options (for select/checkbox/radio), mandatory status, and the general sorting order of the fields. When I want to send this structure back to the server, which format should I communicate it with? Also, when restoring a server-saved form back into my Javascript builder, should I load in the data in the same format it sent it with, or should I rebuild the fields using the builder's createField() functions?
Best practice on this dictates that if you are not planning to use the stored data for anything other than recreating the form then the best method is to send it back in some sort of native format (As mentioned above) With this then you can just load the data back in and requires the least processing of any method.
Communication between Javascript and the server I've been developing a "Form Builder" in Javascript, and coming up to the part where I'll be sending the spec for the form back to the server to be stored. The builder maintains an internal data structure that represents the fields, label, options (for select/checkbox/radio), mandatory status, and the general sorting order of the fields. When I want to send this structure back to the server, which format should I communicate it with? Also, when restoring a server-saved form back into my Javascript builder, should I load in the data in the same format it sent it with, or should I rebuild the fields using the builder's createField() functions?
TITLE: Communication between Javascript and the server QUESTION: I've been developing a "Form Builder" in Javascript, and coming up to the part where I'll be sending the spec for the form back to the server to be stored. The builder maintains an internal data structure that represents the fields, label, options (for select/checkbox/radio), mandatory status, and the general sorting order of the fields. When I want to send this structure back to the server, which format should I communicate it with? Also, when restoring a server-saved form back into my Javascript builder, should I load in the data in the same format it sent it with, or should I rebuild the fields using the builder's createField() functions? ANSWER: Best practice on this dictates that if you are not planning to use the stored data for anything other than recreating the form then the best method is to send it back in some sort of native format (As mentioned above) With this then you can just load the data back in and requires the least processing of any method.
[ "javascript", "server" ]
3
1
1,296
5
0
2008-08-19T16:49:30.913000
2008-08-19T17:01:52.060000
16,550
16,564
Best .NET build tool
Possible Duplicate: NAnt or MSBuild, which one to choose and when? What is the best build tool for.NET? I currently use NAnt but only because I have experience with Ant. Is MSBuild preferred?
We actually use a combination of NAnt and MSBuild with CruiseControl. NAnt is used for script flow control and calls MSBuild to compile projects. After the physical build is triggered, NAnt is used to publish the individual project build outputs to a shared location. I am not sure this is the best process. I think many of us are still looking for a great build tool. One promising thing I heard recently on.NET Rocks, episode 362, is James Kovac's PSake, a build system he based entirely on PowerShell. It sounds really promising since what you can do with PowerShell is fairly limitless in theory.
Best .NET build tool Possible Duplicate: NAnt or MSBuild, which one to choose and when? What is the best build tool for.NET? I currently use NAnt but only because I have experience with Ant. Is MSBuild preferred?
TITLE: Best .NET build tool QUESTION: Possible Duplicate: NAnt or MSBuild, which one to choose and when? What is the best build tool for.NET? I currently use NAnt but only because I have experience with Ant. Is MSBuild preferred? ANSWER: We actually use a combination of NAnt and MSBuild with CruiseControl. NAnt is used for script flow control and calls MSBuild to compile projects. After the physical build is triggered, NAnt is used to publish the individual project build outputs to a shared location. I am not sure this is the best process. I think many of us are still looking for a great build tool. One promising thing I heard recently on.NET Rocks, episode 362, is James Kovac's PSake, a build system he based entirely on PowerShell. It sounds really promising since what you can do with PowerShell is fairly limitless in theory.
[ ".net", "build-process", "nant" ]
43
28
53,475
14
0
2008-08-19T17:02:48.377000
2008-08-19T17:11:37.063000
16,556
23,837
VS.NET Application Diagrams
Have you used VS.NET Architect Edition's Application and System diagrams to start designing a solution? If so, did you find it useful? Did the "automatic implementation" feature work ok?
I used to use it a lot. This designer worked good for stubbing out prototype projects, but ultimately I found myself wasting a lot of time moving the mouse around when I could be typing. It seemed like an awesome idea to be able to print out the class diagrams to show APIs to other developers while I was prototyping, but it proved quite limiting and it looks awful on a non-color printer. Now I just use the text editor and some AutoHotkey macros to get everything done.
VS.NET Application Diagrams Have you used VS.NET Architect Edition's Application and System diagrams to start designing a solution? If so, did you find it useful? Did the "automatic implementation" feature work ok?
TITLE: VS.NET Application Diagrams QUESTION: Have you used VS.NET Architect Edition's Application and System diagrams to start designing a solution? If so, did you find it useful? Did the "automatic implementation" feature work ok? ANSWER: I used to use it a lot. This designer worked good for stubbing out prototype projects, but ultimately I found myself wasting a lot of time moving the mouse around when I could be typing. It seemed like an awesome idea to be able to print out the class diagrams to show APIs to other developers while I was prototyping, but it proved quite limiting and it looks awful on a non-color printer. Now I just use the text editor and some AutoHotkey macros to get everything done.
[ "c#", ".net", "visual-studio", "architecture", "diagram" ]
5
2
412
3
0
2008-08-19T17:05:21.927000
2008-08-23T01:51:04.743000
16,557
16,573
Overriding the equals method vs creating a new method
I have always thought that the.equals() method in java should be overridden to be made specific to the class you have created. In other words to look for equivalence of two different instances rather than two references to the same instance. However I have encountered other programmers who seem to think that the default object behavior should be left alone and a new method created for testing equivalence of two objects of the same class. What are the argument for and against overriding the equals method?
Overriding the equals method is necessary if you want to test equivalence in standard library classes (for example, ensuring a java.util.Set contains unique elements or using objects as keys in java.util.Map objects). Note, if you override equals, ensure you honour the API contract as described in the documentation. For example, ensure you also override Object.hashCode: If two objects are equal according to the equals(Object) method, then calling the hashCode method on each of the two objects must produce the same integer result. EDIT: I didn't post this as a complete answer on the subject, so I'll echo Fredrik Kalseth's statement that overriding equals works best for immutable objects. To quote the API for Map: Note: great care must be exercised if mutable objects are used as map keys. The behavior of a map is not specified if the value of an object is changed in a manner that affects equals comparisons while the object is a key in the map.
Overriding the equals method vs creating a new method I have always thought that the.equals() method in java should be overridden to be made specific to the class you have created. In other words to look for equivalence of two different instances rather than two references to the same instance. However I have encountered other programmers who seem to think that the default object behavior should be left alone and a new method created for testing equivalence of two objects of the same class. What are the argument for and against overriding the equals method?
TITLE: Overriding the equals method vs creating a new method QUESTION: I have always thought that the.equals() method in java should be overridden to be made specific to the class you have created. In other words to look for equivalence of two different instances rather than two references to the same instance. However I have encountered other programmers who seem to think that the default object behavior should be left alone and a new method created for testing equivalence of two objects of the same class. What are the argument for and against overriding the equals method? ANSWER: Overriding the equals method is necessary if you want to test equivalence in standard library classes (for example, ensuring a java.util.Set contains unique elements or using objects as keys in java.util.Map objects). Note, if you override equals, ensure you honour the API contract as described in the documentation. For example, ensure you also override Object.hashCode: If two objects are equal according to the equals(Object) method, then calling the hashCode method on each of the two objects must produce the same integer result. EDIT: I didn't post this as a complete answer on the subject, so I'll echo Fredrik Kalseth's statement that overriding equals works best for immutable objects. To quote the API for Map: Note: great care must be exercised if mutable objects are used as map keys. The behavior of a map is not specified if the value of an object is changed in a manner that affects equals comparisons while the object is a key in the map.
[ "java", "oop" ]
21
19
1,606
7
0
2008-08-19T17:05:26.937000
2008-08-19T17:14:47.760000
16,568
16,777
How to select the nth row in a SQL database table?
I'm interested in learning some (ideally) database agnostic ways of selecting the n th row from a database table. It would also be interesting to see how this can be achieved using the native functionality of the following databases: SQL Server MySQL PostgreSQL SQLite Oracle I am currently doing something like the following in SQL Server 2005, but I'd be interested in seeing other's more agnostic approaches: WITH Ordered AS ( SELECT ROW_NUMBER() OVER (ORDER BY OrderID) AS RowNumber, OrderID, OrderDate FROM Orders) SELECT * FROM Ordered WHERE RowNumber = 1000000 Credit for the above SQL: Firoz Ansari's Weblog Update: See Troels Arvin's answer regarding the SQL standard. Troels, have you got any links we can cite?
There are ways of doing this in optional parts of the standard, but a lot of databases support their own way of doing it. A really good site that talks about this and other things is http://troels.arvin.dk/db/rdbms/#select-limit. Basically, PostgreSQL and MySQL supports the non-standard: SELECT... LIMIT y OFFSET x Oracle, DB2 and MSSQL supports the standard windowing functions: SELECT * FROM ( SELECT ROW_NUMBER() OVER (ORDER BY key ASC) AS rownumber, columns FROM tablename ) AS foo WHERE rownumber <= n (which I just copied from the site linked above since I never use those DBs) Update: As of PostgreSQL 8.4 the standard windowing functions are supported, so expect the second example to work for PostgreSQL as well. Update: SQLite added window functions support in version 3.25.0 on 2018-09-15 so both forms also work in SQLite.
How to select the nth row in a SQL database table? I'm interested in learning some (ideally) database agnostic ways of selecting the n th row from a database table. It would also be interesting to see how this can be achieved using the native functionality of the following databases: SQL Server MySQL PostgreSQL SQLite Oracle I am currently doing something like the following in SQL Server 2005, but I'd be interested in seeing other's more agnostic approaches: WITH Ordered AS ( SELECT ROW_NUMBER() OVER (ORDER BY OrderID) AS RowNumber, OrderID, OrderDate FROM Orders) SELECT * FROM Ordered WHERE RowNumber = 1000000 Credit for the above SQL: Firoz Ansari's Weblog Update: See Troels Arvin's answer regarding the SQL standard. Troels, have you got any links we can cite?
TITLE: How to select the nth row in a SQL database table? QUESTION: I'm interested in learning some (ideally) database agnostic ways of selecting the n th row from a database table. It would also be interesting to see how this can be achieved using the native functionality of the following databases: SQL Server MySQL PostgreSQL SQLite Oracle I am currently doing something like the following in SQL Server 2005, but I'd be interested in seeing other's more agnostic approaches: WITH Ordered AS ( SELECT ROW_NUMBER() OVER (ORDER BY OrderID) AS RowNumber, OrderID, OrderDate FROM Orders) SELECT * FROM Ordered WHERE RowNumber = 1000000 Credit for the above SQL: Firoz Ansari's Weblog Update: See Troels Arvin's answer regarding the SQL standard. Troels, have you got any links we can cite? ANSWER: There are ways of doing this in optional parts of the standard, but a lot of databases support their own way of doing it. A really good site that talks about this and other things is http://troels.arvin.dk/db/rdbms/#select-limit. Basically, PostgreSQL and MySQL supports the non-standard: SELECT... LIMIT y OFFSET x Oracle, DB2 and MSSQL supports the standard windowing functions: SELECT * FROM ( SELECT ROW_NUMBER() OVER (ORDER BY key ASC) AS rownumber, columns FROM tablename ) AS foo WHERE rownumber <= n (which I just copied from the site linked above since I never use those DBs) Update: As of PostgreSQL 8.4 the standard windowing functions are supported, so expect the second example to work for PostgreSQL as well. Update: SQLite added window functions support in version 3.25.0 on 2018-09-15 so both forms also work in SQLite.
[ "mysql", "sql", "database", "oracle", "postgresql" ]
494
407
1,072,263
34
0
2008-08-19T17:13:11.023000
2008-08-19T19:22:15.100000
16,615
22,910
Is FindFirstChangeNotification the best API to use for file system change notification on windows?
I'm new to windows programming and I'm trying to get notified of all changes to the file system (similar to the information that FileMon from SysInternals displays, but via an API). Is a FindFirstChangeNotification for each (non-network, non-substed) drive my best bet or are there other more suitable C/C++ APIs?
FindFirstChangeNotification is fine, but for slightly more ultimate power you should be using ReadDirectoryChangesW. (In fact, it's even recommended in the documentation!) It doesn't require a function pointer, it does require you to manually decode a raw buffer, it uses Unicode file names, but it is generally better and more flexible. On the other hand, if you want to do what FileMon does, you should probably do what FileMon does and use IFS to create and install a file system filter.
Is FindFirstChangeNotification the best API to use for file system change notification on windows? I'm new to windows programming and I'm trying to get notified of all changes to the file system (similar to the information that FileMon from SysInternals displays, but via an API). Is a FindFirstChangeNotification for each (non-network, non-substed) drive my best bet or are there other more suitable C/C++ APIs?
TITLE: Is FindFirstChangeNotification the best API to use for file system change notification on windows? QUESTION: I'm new to windows programming and I'm trying to get notified of all changes to the file system (similar to the information that FileMon from SysInternals displays, but via an API). Is a FindFirstChangeNotification for each (non-network, non-substed) drive my best bet or are there other more suitable C/C++ APIs? ANSWER: FindFirstChangeNotification is fine, but for slightly more ultimate power you should be using ReadDirectoryChangesW. (In fact, it's even recommended in the documentation!) It doesn't require a function pointer, it does require you to manually decode a raw buffer, it uses Unicode file names, but it is generally better and more flexible. On the other hand, if you want to do what FileMon does, you should probably do what FileMon does and use IFS to create and install a file system filter.
[ "c", "windows", "winapi", "file", "notifications" ]
18
22
8,066
4
0
2008-08-19T17:44:27.153000
2008-08-22T17:11:16.007000
16,616
16,622
ArgumentNullException for Integer
In.NET, is it more appropriate to throw an argument null exception for an Integer if the value is Integer.MinValue or Integer = 0 (assuming that 0 is not a valid value)?
Throwing an ArgumentNullException isn't appropriate unless the argument is actually null. Throw an ArgumentOutOfRangeException instead (preferably with a message informing the user what values of int are actually acceptable). ArgumentOutOfRangeException is thrown when a method is invoked and at least one of the arguments passed to the method is not a null reference ( Nothing in Visual Basic) and does not contain a valid value.
ArgumentNullException for Integer In.NET, is it more appropriate to throw an argument null exception for an Integer if the value is Integer.MinValue or Integer = 0 (assuming that 0 is not a valid value)?
TITLE: ArgumentNullException for Integer QUESTION: In.NET, is it more appropriate to throw an argument null exception for an Integer if the value is Integer.MinValue or Integer = 0 (assuming that 0 is not a valid value)? ANSWER: Throwing an ArgumentNullException isn't appropriate unless the argument is actually null. Throw an ArgumentOutOfRangeException instead (preferably with a message informing the user what values of int are actually acceptable). ArgumentOutOfRangeException is thrown when a method is invoked and at least one of the arguments passed to the method is not a null reference ( Nothing in Visual Basic) and does not contain a valid value.
[ ".net" ]
1
8
751
3
0
2008-08-19T17:47:23.230000
2008-08-19T17:50:47.843000
16,634
16,655
What is the best method for checking if a file exists from a SQL Server 2005 stored procedure?
We used the "undocumented" xp_fileexist stored procedure for years in SQL Server 2000 and had no trouble with it. In 2005, it seems that they modified the behavior slightly to always return a 0 if the executing user account is not a sysadmin. It also seems to return a zero if the SQL Server service is running under the LocalSystem account and you are trying to check a file on the network. I'd like to get away from xp_fileexist. Does anyone have a better way to check for the existence of a file at a network location from inside of a stored procedure?
Maybe a CLR stored procedure is what you are looking for. These are generally used when you need to interact with the system in some way.
What is the best method for checking if a file exists from a SQL Server 2005 stored procedure? We used the "undocumented" xp_fileexist stored procedure for years in SQL Server 2000 and had no trouble with it. In 2005, it seems that they modified the behavior slightly to always return a 0 if the executing user account is not a sysadmin. It also seems to return a zero if the SQL Server service is running under the LocalSystem account and you are trying to check a file on the network. I'd like to get away from xp_fileexist. Does anyone have a better way to check for the existence of a file at a network location from inside of a stored procedure?
TITLE: What is the best method for checking if a file exists from a SQL Server 2005 stored procedure? QUESTION: We used the "undocumented" xp_fileexist stored procedure for years in SQL Server 2000 and had no trouble with it. In 2005, it seems that they modified the behavior slightly to always return a 0 if the executing user account is not a sysadmin. It also seems to return a zero if the SQL Server service is running under the LocalSystem account and you are trying to check a file on the network. I'd like to get away from xp_fileexist. Does anyone have a better way to check for the existence of a file at a network location from inside of a stored procedure? ANSWER: Maybe a CLR stored procedure is what you are looking for. These are generally used when you need to interact with the system in some way.
[ "sql-server", "sql-server-2005" ]
4
4
9,789
3
0
2008-08-19T18:01:43.653000
2008-08-19T18:13:13.040000
16,638
16,720
Google Maps API - Problems with class GLatLngBounds
I am having some trouble with the Google Maps API. I have an array which holds a ojbect I created to store points. My array and class: var tPoints = []; function tPoint(name) { var id = name; var points = []; var pointsCount = 0;... this.getHeadPoint = function() { return points[pointsCount-1]; } } tPoint holds an array of GLatLng points. I want to write a function to return a GLatLngBounds object which is extended from the current map bounds to show all the HeadPoints. Heres what I have so far.. function getBounds() { var mBound = map.getBounds(); for (var i = 0; i < tPoints.length; i++) { alert(mBound.getSouthWest().lat() + "," + mBound.getSouthWest().lng()); alert(mBound.getNorthEast().lat() + "," + mBound.getNorthEast().lng()); currPoint = trackMarkers[i].getHeadPoint(); if (!mBound.containsLatLng(currPoint)) { mBound.extend(currPoint); } } return mBound; } Which returns these values for the alert. (Generally over the US) "19.64258,NaN" "52.69636,NaN" "i=0" "19.64258,NaN" "52.69636,-117.20701" "i=1" I don't know why I am getting NaN back. When I use the bounds to get a zoom level I think the NaN value is causing the map.getBoundsZoomLevel(bounds) to return 0 which is incorrect. Am I using GLatLngBounds incorrectly?
The google maps sample is using this code... var bounds = map.getBounds(); var southWest = bounds.getSouthWest(); var northEast = bounds.getNorthEast(); var lngSpan = northEast.lng() - southWest.lng(); var latSpan = northEast.lat() - southWest.lat();...which is putting the SouthWest/NorthEast bounds into a variable before attempting to get the individual lng/lat coordinates. Maybe there is something with the "nested" evaluations causing problems. Have tried the granular approach to see if you get the data you need?
Google Maps API - Problems with class GLatLngBounds I am having some trouble with the Google Maps API. I have an array which holds a ojbect I created to store points. My array and class: var tPoints = []; function tPoint(name) { var id = name; var points = []; var pointsCount = 0;... this.getHeadPoint = function() { return points[pointsCount-1]; } } tPoint holds an array of GLatLng points. I want to write a function to return a GLatLngBounds object which is extended from the current map bounds to show all the HeadPoints. Heres what I have so far.. function getBounds() { var mBound = map.getBounds(); for (var i = 0; i < tPoints.length; i++) { alert(mBound.getSouthWest().lat() + "," + mBound.getSouthWest().lng()); alert(mBound.getNorthEast().lat() + "," + mBound.getNorthEast().lng()); currPoint = trackMarkers[i].getHeadPoint(); if (!mBound.containsLatLng(currPoint)) { mBound.extend(currPoint); } } return mBound; } Which returns these values for the alert. (Generally over the US) "19.64258,NaN" "52.69636,NaN" "i=0" "19.64258,NaN" "52.69636,-117.20701" "i=1" I don't know why I am getting NaN back. When I use the bounds to get a zoom level I think the NaN value is causing the map.getBoundsZoomLevel(bounds) to return 0 which is incorrect. Am I using GLatLngBounds incorrectly?
TITLE: Google Maps API - Problems with class GLatLngBounds QUESTION: I am having some trouble with the Google Maps API. I have an array which holds a ojbect I created to store points. My array and class: var tPoints = []; function tPoint(name) { var id = name; var points = []; var pointsCount = 0;... this.getHeadPoint = function() { return points[pointsCount-1]; } } tPoint holds an array of GLatLng points. I want to write a function to return a GLatLngBounds object which is extended from the current map bounds to show all the HeadPoints. Heres what I have so far.. function getBounds() { var mBound = map.getBounds(); for (var i = 0; i < tPoints.length; i++) { alert(mBound.getSouthWest().lat() + "," + mBound.getSouthWest().lng()); alert(mBound.getNorthEast().lat() + "," + mBound.getNorthEast().lng()); currPoint = trackMarkers[i].getHeadPoint(); if (!mBound.containsLatLng(currPoint)) { mBound.extend(currPoint); } } return mBound; } Which returns these values for the alert. (Generally over the US) "19.64258,NaN" "52.69636,NaN" "i=0" "19.64258,NaN" "52.69636,-117.20701" "i=1" I don't know why I am getting NaN back. When I use the bounds to get a zoom level I think the NaN value is causing the map.getBoundsZoomLevel(bounds) to return 0 which is incorrect. Am I using GLatLngBounds incorrectly? ANSWER: The google maps sample is using this code... var bounds = map.getBounds(); var southWest = bounds.getSouthWest(); var northEast = bounds.getNorthEast(); var lngSpan = northEast.lng() - southWest.lng(); var latSpan = northEast.lat() - southWest.lat();...which is putting the SouthWest/NorthEast bounds into a variable before attempting to get the individual lng/lat coordinates. Maybe there is something with the "nested" evaluations causing problems. Have tried the granular approach to see if you get the data you need?
[ "javascript", "google-maps" ]
3
1
4,622
2
0
2008-08-19T18:04:16.160000
2008-08-19T18:46:25.670000
16,656
16,787
Creating temporary folders
I am working on a program that needs to create a multiple temporary folders for the application. These will not be seen by the user. The app is written in VB.net. I can think of a few ways to do it such as incremental folder name or random numbered folder names, but I was wondering, how other people solve this problem?
Update: Added File.Exists check per comment (2012-Jun-19) Here's what I've used in VB.NET. Essentially the same as presented, except I usually didn't want to create the folder immediately. The advantage to use GetRandomFilename is that it doesn't create a file, so you don't have to clean up if your using the name for something other than a file. Like using it for folder name. Private Function GetTempFolder() As String Dim folder As String = Path.Combine(Path.GetTempPath, Path.GetRandomFileName) Do While Directory.Exists(folder) or File.Exists(folder) folder = Path.Combine(Path.GetTempPath, Path.GetRandomFileName) Loop Return folder End Function Random Filename Example: C:\Documents and Settings\username\Local Settings\Temp\u3z5e0co.tvq Here's a variation using a Guid to get the temp folder name. Private Function GetTempFolderGuid() As String Dim folder As String = Path.Combine(Path.GetTempPath, Guid.NewGuid.ToString) Do While Directory.Exists(folder) or File.Exists(folder) folder = Path.Combine(Path.GetTempPath, Guid.NewGuid.ToString) Loop Return folder End Function guid Example: C:\Documents and Settings\username\Local Settings\Temp\2dbc6db7-2d45-4b75-b27f-0bd492c60496
Creating temporary folders I am working on a program that needs to create a multiple temporary folders for the application. These will not be seen by the user. The app is written in VB.net. I can think of a few ways to do it such as incremental folder name or random numbered folder names, but I was wondering, how other people solve this problem?
TITLE: Creating temporary folders QUESTION: I am working on a program that needs to create a multiple temporary folders for the application. These will not be seen by the user. The app is written in VB.net. I can think of a few ways to do it such as incremental folder name or random numbered folder names, but I was wondering, how other people solve this problem? ANSWER: Update: Added File.Exists check per comment (2012-Jun-19) Here's what I've used in VB.NET. Essentially the same as presented, except I usually didn't want to create the folder immediately. The advantage to use GetRandomFilename is that it doesn't create a file, so you don't have to clean up if your using the name for something other than a file. Like using it for folder name. Private Function GetTempFolder() As String Dim folder As String = Path.Combine(Path.GetTempPath, Path.GetRandomFileName) Do While Directory.Exists(folder) or File.Exists(folder) folder = Path.Combine(Path.GetTempPath, Path.GetRandomFileName) Loop Return folder End Function Random Filename Example: C:\Documents and Settings\username\Local Settings\Temp\u3z5e0co.tvq Here's a variation using a Guid to get the temp folder name. Private Function GetTempFolderGuid() As String Dim folder As String = Path.Combine(Path.GetTempPath, Guid.NewGuid.ToString) Do While Directory.Exists(folder) or File.Exists(folder) folder = Path.Combine(Path.GetTempPath, Guid.NewGuid.ToString) Loop Return folder End Function guid Example: C:\Documents and Settings\username\Local Settings\Temp\2dbc6db7-2d45-4b75-b27f-0bd492c60496
[ ".net", "io" ]
30
28
30,655
13
0
2008-08-19T18:14:14.317000
2008-08-19T19:30:17.737000
16,657
16,679
How to affordably release a Web App
I am a broke college student. I have built a small web app in PHP5 and MySQL, and I already have a domain. What is an affordable way to get it online? A few people have suggested amazon's cloud services, but that seems equivalent to slitting my wrists and watching money slowly trickle out. So suggestions? Hosting companies, CIA drop sites, anything? Update: A lot of suggestions have been for Dreamhost. Their plan allows for 5TB of bandwidth. Could anyone put this in perspective? For instance, how much bandwidth does a site with the kind of traffic StackOverflow get?
I say pay the 50-80 bucks for a real host. The classic "you get what you pay for" is very true for hosting. This will save you time, time you can spend getting those $80.
How to affordably release a Web App I am a broke college student. I have built a small web app in PHP5 and MySQL, and I already have a domain. What is an affordable way to get it online? A few people have suggested amazon's cloud services, but that seems equivalent to slitting my wrists and watching money slowly trickle out. So suggestions? Hosting companies, CIA drop sites, anything? Update: A lot of suggestions have been for Dreamhost. Their plan allows for 5TB of bandwidth. Could anyone put this in perspective? For instance, how much bandwidth does a site with the kind of traffic StackOverflow get?
TITLE: How to affordably release a Web App QUESTION: I am a broke college student. I have built a small web app in PHP5 and MySQL, and I already have a domain. What is an affordable way to get it online? A few people have suggested amazon's cloud services, but that seems equivalent to slitting my wrists and watching money slowly trickle out. So suggestions? Hosting companies, CIA drop sites, anything? Update: A lot of suggestions have been for Dreamhost. Their plan allows for 5TB of bandwidth. Could anyone put this in perspective? For instance, how much bandwidth does a site with the kind of traffic StackOverflow get? ANSWER: I say pay the 50-80 bucks for a real host. The classic "you get what you pay for" is very true for hosting. This will save you time, time you can spend getting those $80.
[ "hosting", "web-applications" ]
4
5
468
8
0
2008-08-19T18:14:23.317000
2008-08-19T18:25:03.560000
16,660
16,761
Internationalization in SSRS
What's the best way to handle translations for stock text in a SSRS. For instance - if I have a report that shows a grid of contents what's the best way to have the correct translation for the header of that grid show up, assuming the culture of the report is set correctly. Put another way - is it possible to do resources in a SSRS report, or am I stuck with storing all that text in the database and querying for it?
AS far as I know, there is no way to localize a report (meaning automating the translation of string litterals)... Like you said,you basically have to use the User!Language global variable to catch the user's settings and then use that to retrieve the appropriate strings from the DB... However, you can adapt the display of currency/numeric/date fields according to the user locale. Also possible is changing the interface of the Report Viewer to match your user's langage. Here are a few links giving tips on how to adapt the locale: http://www.ssw.com.au/Ssw/Standards/Rules/RulesToBetterSQLReportingServices.aspx#LanguageSetting Langage pack for Report Viewer: http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=e3d3071b-d919-4ff9-9696-c11d312a36a0
Internationalization in SSRS What's the best way to handle translations for stock text in a SSRS. For instance - if I have a report that shows a grid of contents what's the best way to have the correct translation for the header of that grid show up, assuming the culture of the report is set correctly. Put another way - is it possible to do resources in a SSRS report, or am I stuck with storing all that text in the database and querying for it?
TITLE: Internationalization in SSRS QUESTION: What's the best way to handle translations for stock text in a SSRS. For instance - if I have a report that shows a grid of contents what's the best way to have the correct translation for the header of that grid show up, assuming the culture of the report is set correctly. Put another way - is it possible to do resources in a SSRS report, or am I stuck with storing all that text in the database and querying for it? ANSWER: AS far as I know, there is no way to localize a report (meaning automating the translation of string litterals)... Like you said,you basically have to use the User!Language global variable to catch the user's settings and then use that to retrieve the appropriate strings from the DB... However, you can adapt the display of currency/numeric/date fields according to the user locale. Also possible is changing the interface of the Report Viewer to match your user's langage. Here are a few links giving tips on how to adapt the locale: http://www.ssw.com.au/Ssw/Standards/Rules/RulesToBetterSQLReportingServices.aspx#LanguageSetting Langage pack for Report Viewer: http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=e3d3071b-d919-4ff9-9696-c11d312a36a0
[ "reporting-services", "internationalization" ]
6
5
3,691
1
0
2008-08-19T18:15:29.617000
2008-08-19T19:14:04.303000
16,716
16,730
OpenID authentication in ASP.NET?
I am starting to build a new web application that will require user accounts. Now that I have an OpenID that I am using for this site I thought it would be cool if I could use OpenID for authentication in my application. Are there any good tutorials on how to integrate OpenID with an ASP.NET site?
See Scott Hanselman's post on using DotNetOpenID in ASP.NET. Andrew Arnott's blog is full of samples on using DotNetOpenID with ASP.NET, including ASP.NET MVC. I recently hooked up DotNetOpenID for the Subtext 2.0 release. It went really smoothly - the code samples included with the DotNetOpenID download are pretty helpful. The one thing I'd recommend is that you just use the library and avoid the ASP.NET control. It uses table based layout (hardcoded) and is pretty difficult to restyle.
OpenID authentication in ASP.NET? I am starting to build a new web application that will require user accounts. Now that I have an OpenID that I am using for this site I thought it would be cool if I could use OpenID for authentication in my application. Are there any good tutorials on how to integrate OpenID with an ASP.NET site?
TITLE: OpenID authentication in ASP.NET? QUESTION: I am starting to build a new web application that will require user accounts. Now that I have an OpenID that I am using for this site I thought it would be cool if I could use OpenID for authentication in my application. Are there any good tutorials on how to integrate OpenID with an ASP.NET site? ANSWER: See Scott Hanselman's post on using DotNetOpenID in ASP.NET. Andrew Arnott's blog is full of samples on using DotNetOpenID with ASP.NET, including ASP.NET MVC. I recently hooked up DotNetOpenID for the Subtext 2.0 release. It went really smoothly - the code samples included with the DotNetOpenID download are pretty helpful. The one thing I'd recommend is that you just use the library and avoid the ASP.NET control. It uses table based layout (hardcoded) and is pretty difficult to restyle.
[ "asp.net", "openid", "dotnetopenauth" ]
29
25
8,665
6
0
2008-08-19T18:44:32.633000
2008-08-19T18:49:27.537000
16,747
25,606
What's the best way to implement field validation using ASP.NET MVC?
I am building a public website using ASP.NET, as part of the deliverable I need to do an Admin Site for data entry of the stuff shown in the public site, I was wondering what techniques or procedures are people using to validate entries using ASP.NET MVC.
Take a look at the JQuery Validation plugin this plugin is amazing,it's clean to implement and has all the features you could ever need, including remote validation via AJAX. Also a sample MVC controller method can be found here which basically uses the JsonResult action type like: public JsonResult CheckUserName(string username) { return Json(CheckValidUsername(username)); }
What's the best way to implement field validation using ASP.NET MVC? I am building a public website using ASP.NET, as part of the deliverable I need to do an Admin Site for data entry of the stuff shown in the public site, I was wondering what techniques or procedures are people using to validate entries using ASP.NET MVC.
TITLE: What's the best way to implement field validation using ASP.NET MVC? QUESTION: I am building a public website using ASP.NET, as part of the deliverable I need to do an Admin Site for data entry of the stuff shown in the public site, I was wondering what techniques or procedures are people using to validate entries using ASP.NET MVC. ANSWER: Take a look at the JQuery Validation plugin this plugin is amazing,it's clean to implement and has all the features you could ever need, including remote validation via AJAX. Also a sample MVC controller method can be found here which basically uses the JsonResult action type like: public JsonResult CheckUserName(string username) { return Json(CheckValidUsername(username)); }
[ "c#", "asp.net-mvc", "validation" ]
45
26
6,276
3
0
2008-08-19T19:02:55.637000
2008-08-25T03:04:28.937000
16,759
16,785
How do you use back-references to PCREs in PHP?
I read this PHP RegEx page, but either I'm missing something, misreading something, or it doesn't work the way they say. I'm guessing it's one of the first two. $str = preg_replace("([|]\d*)", "\1;", $str);
Your regular expression should follow Perl syntax, meaning it has to start and end with the same character (with some exceptions). Also, the back reference should start with a double slash, to get around PHPs double escaping. This should work (with a quick test): $str = "asdfasdf |123123 asdf iakds |302 asdf |11"; $str = preg_replace("/([|]\d*)/", "\\1;", $str); echo $str; // prints "asdfasdf |123123; asdf iakds |302; asdf |11;"
How do you use back-references to PCREs in PHP? I read this PHP RegEx page, but either I'm missing something, misreading something, or it doesn't work the way they say. I'm guessing it's one of the first two. $str = preg_replace("([|]\d*)", "\1;", $str);
TITLE: How do you use back-references to PCREs in PHP? QUESTION: I read this PHP RegEx page, but either I'm missing something, misreading something, or it doesn't work the way they say. I'm guessing it's one of the first two. $str = preg_replace("([|]\d*)", "\1;", $str); ANSWER: Your regular expression should follow Perl syntax, meaning it has to start and end with the same character (with some exceptions). Also, the back reference should start with a double slash, to get around PHPs double escaping. This should work (with a quick test): $str = "asdfasdf |123123 asdf iakds |302 asdf |11"; $str = preg_replace("/([|]\d*)/", "\\1;", $str); echo $str; // prints "asdfasdf |123123; asdf iakds |302; asdf |11;"
[ "php", "regex" ]
3
4
1,396
1
0
2008-08-19T19:11:32.860000
2008-08-19T19:29:00.513000
16,770
16,810
Haskell's algebraic data types
I'm trying to fully understand all of Haskell's concepts. In what ways are algebraic data types similar to generic types, e.g., in C# and Java? And how are they different? What's so algebraic about them anyway? I'm familiar with universal algebra and its rings and fields, but I only have a vague idea of how Haskell's types work.
"Algebraic Data Types" in Haskell support full parametric polymorphism, which is the more technically correct name for generics, as a simple example the list data type: data List a = Cons a (List a) | Nil Is equivalent (as much as is possible, and ignoring non-strict evaluation, etc) to class List { class Cons: List { a head; List tail; } class Nil: List {} } Of course Haskell's type system allows more... interesting use of type parameters but this is just a simple example. With regards to the "Algebraic Type" name, i've honestly never been entirely sure of the exact reason for them being named that, but have assumed that it's due the mathematical underpinnings of the type system. I believe that the reason boils down to the theoretical definition of an ADT being the "product of a set of constructors", however it's been a couple of years since i escaped university so i can no longer remember the specifics. [Edit: Thanks to Chris Conway for pointing out my foolish error, ADT are of course sum types, the constructors providing the product/tuple of fields]
Haskell's algebraic data types I'm trying to fully understand all of Haskell's concepts. In what ways are algebraic data types similar to generic types, e.g., in C# and Java? And how are they different? What's so algebraic about them anyway? I'm familiar with universal algebra and its rings and fields, but I only have a vague idea of how Haskell's types work.
TITLE: Haskell's algebraic data types QUESTION: I'm trying to fully understand all of Haskell's concepts. In what ways are algebraic data types similar to generic types, e.g., in C# and Java? And how are they different? What's so algebraic about them anyway? I'm familiar with universal algebra and its rings and fields, but I only have a vague idea of how Haskell's types work. ANSWER: "Algebraic Data Types" in Haskell support full parametric polymorphism, which is the more technically correct name for generics, as a simple example the list data type: data List a = Cons a (List a) | Nil Is equivalent (as much as is possible, and ignoring non-strict evaluation, etc) to class List { class Cons: List { a head; List tail; } class Nil: List {} } Of course Haskell's type system allows more... interesting use of type parameters but this is just a simple example. With regards to the "Algebraic Type" name, i've honestly never been entirely sure of the exact reason for them being named that, but have assumed that it's due the mathematical underpinnings of the type system. I believe that the reason boils down to the theoretical definition of an ADT being the "product of a set of constructors", however it's been a couple of years since i escaped university so i can no longer remember the specifics. [Edit: Thanks to Chris Conway for pointing out my foolish error, ADT are of course sum types, the constructors providing the product/tuple of fields]
[ "data-structures", "haskell", "types", "functional-programming", "algebraic-data-types" ]
63
23
17,716
8
0
2008-08-19T19:18:41.720000
2008-08-19T19:46:24.647000
16,792
16,806
SQL Server Maximum row size
Came across this error today. Wondering if anyone can tell me what it means: Cannot sort a row of size 9522, which is greater than the allowable maximum of 8094. Is that 8094 bytes? Characters? Fields? Is this a problem joining multiple tables that are exceeding some limit?
In SQL 2000, the row limit is 8K bytes, which is the same size as a page in memory. [Edit] In 2005, the page size is the same (8K), but the database uses pointers on the row in the page to point to other pages that contain larger fields. This allows 2005 to overcome the 8K row size limitation.
SQL Server Maximum row size Came across this error today. Wondering if anyone can tell me what it means: Cannot sort a row of size 9522, which is greater than the allowable maximum of 8094. Is that 8094 bytes? Characters? Fields? Is this a problem joining multiple tables that are exceeding some limit?
TITLE: SQL Server Maximum row size QUESTION: Came across this error today. Wondering if anyone can tell me what it means: Cannot sort a row of size 9522, which is greater than the allowable maximum of 8094. Is that 8094 bytes? Characters? Fields? Is this a problem joining multiple tables that are exceeding some limit? ANSWER: In SQL 2000, the row limit is 8K bytes, which is the same size as a page in memory. [Edit] In 2005, the page size is the same (8K), but the database uses pointers on the row in the page to point to other pages that contain larger fields. This allows 2005 to overcome the 8K row size limitation.
[ "sql-server" ]
11
10
15,004
5
0
2008-08-19T19:32:38.823000
2008-08-19T19:39:20.510000
16,795
16,802
PHPs htmlspecialcharacters equivalent in .NET?
PHP has a great function called htmlspecialcharacters() where you pass it a string and it replaces all of HTML's special characters with their safe equivalents, it's almost a one stop shop for sanitizing input. Very nice right? Well is there an equivalent in any of the.NET libraries? If not, can anyone link to any code samples or libraries that do this well?
Try this. var encodedHtml = HttpContext.Current.Server.HtmlEncode(...);
PHPs htmlspecialcharacters equivalent in .NET? PHP has a great function called htmlspecialcharacters() where you pass it a string and it replaces all of HTML's special characters with their safe equivalents, it's almost a one stop shop for sanitizing input. Very nice right? Well is there an equivalent in any of the.NET libraries? If not, can anyone link to any code samples or libraries that do this well?
TITLE: PHPs htmlspecialcharacters equivalent in .NET? QUESTION: PHP has a great function called htmlspecialcharacters() where you pass it a string and it replaces all of HTML's special characters with their safe equivalents, it's almost a one stop shop for sanitizing input. Very nice right? Well is there an equivalent in any of the.NET libraries? If not, can anyone link to any code samples or libraries that do this well? ANSWER: Try this. var encodedHtml = HttpContext.Current.Server.HtmlEncode(...);
[ "c#", ".net", "php", "asp.net" ]
18
11
12,479
5
0
2008-08-19T19:35:30.080000
2008-08-19T19:37:48.577000
16,804
297,256
Enterprise Reporting Solutions
What options are there in the industry for enterprise reporting? I'm currently using SSRS 2005, and know that there is another version coming out with the new release of MSSQL. But, it seems like it might also be a good time to investigate the market to see what else is out there. What have you encountered? Do you like it/dislike it? Why? Thank you.
I've used Cognos Series 7, Cognos Series 8, Crystal Reports, Business Objects XI R2 WebIntelligence, Reporting Services 2000, Reporting Services 2005, and Reporting Services 2008. Here's my feedback on what I've learned: Reporting Services 2008/2005/2000 PROS Cost: Cheapest enterprise business intelligence solution if you are using MS SQL Server as a back-end. You also have a best-in-class ETL solution at no additional cost if you throw in SSIS. Most Flexible: Most flexible reporting solution I've ever used. It has always met all my business needs, particularly in its latest incarnation. Easily Scalable: We initially used this as a departmental solution supporting about 20 users. We eventually expanded it to cover a few thousand users. Despite having a really bad quality virtual server located in a remote data center, we were able to scale to about 50-100 concurrent user requests. On good hardware at a consulting gig, I was able to scale it to a larger set of concurrent users without any issues. I've also seen implementations where multiple SSRS servers were deployed in different countries and SSIS was used to synch the data in the back-ends. This allowed for solid performance in a distributed manner at almost no additional cost. Source Control Integration: This is CRITICAL to me when developing reports with my business intelligence teams. No other BI suite offers an out-of-box solution for this that I've ever used. Every other platform I used either required purchasing a 3rd party add-in or required you to promote reports between separate development, test, and production environments. Analysis Services: I like the tight integration with Analysis Services between SSRS and SSIS. I've read about instances where Oracle and DB2 quotes include installing a SQL Server 2005 Analysis Services server for OLAP cubes. Discoverability: No system has better discoverability than SSRS. There are more books, forums, articles, and code sites on SSRS than any other BI suite that I've ever used. If I needed to figuire out how to do something in SSRS, I could almost always find it with a few minutes or hours of work. CONS IIS Required for SSRS 2005/2000: Older versions of SSRS required installing IIS on the database server. This was not permissible from an internal controls perspective when I worked at a large bank. We eventually implemented SSRS without authorized approval from IT operations and basically asked for forgiveness later. This is not an issue in SSRS 2008 since IIS is no longer required. Report Builder: The web-based report builder was non-existant in SSRS 2000. The web-based report builder in SSRS 2005 was difficult to use and did not have enough functionality. The web-based report builder in SSRS 2008 is definitely better, but it is still too difficult to use for most business users. Database Bias: It works best with Microsoft SQL Server. It isn't great with Oracle, DB2, and other back-ends. Business Objects XI WebIntelligence PROS Ease of Use: Easiest to use for your average non-BI end-user for developing ad hoc reports. Database Agnostic: Definitely a good solution if you expect to use Oracle, DB2, or another database back-end. Performant: Very fast performance since most of the page navigations are basically file-system operations instead of database-calls. CONS Cost: Number one problem. If I want to scale up my implementation of Business Objects from 30 users to 1000 users, then SAP will make certain to charge you a few hundred thousands of dollars. And that's just for the Business Objects licenses. Add in the fact that you will also need database server licenses, you are now talking about a very expensive system. Of course, that could be the personal justification for getting Business Objects: if you can convince management to purchase a very expensive BI system, then you can probably convince management to pay for a large BI department. No Source Control: Lack of out-of-the-box source control integration leads to errors in accidentally modifying and deploying old report definitions by mistake. The "work-around" for this is promote reports between environments -- a process that I do NOT like to do since it slows down report development and introduces environmental differences variables. No HTML Email Support: You cannot send an HTML email via a schedule. I regularly do this in SSRS. You can buy an expensive 3rd party add-in to do this, but you shouldn't have to spend more money for this functionality. Model Bias: Report development requires universes -- basically a data model. That's fine for ad hoc report development, but I prefer to use stored procedures to have full control of performance. I also like to build flat tables that are then queried to avoid costly complex joins during report run-time. It is silly to have to build universes that just contain flat tables that are only used by one report. You shouldn't have to build a model just to query a table. Store procedure support is also not supported out of the box without hacking the SQL Overrides. Poor Parameter Support: Parameter support is terrible in BOXI WebIntelligence reports. Although I like the meta-data refresh options for general business users, it just isn't robust enough when trying to setup schedules. I almost always have to clone reports and alter the filters slightly which leads to unnecessary report definition duplication. SSRS beats this hands down, particularly since you can make the value and the label have different values -- unlike BOXI. Inadequate Report Linking Support: I wanted to store one report definition in a central folder and then create linked reports for other users. However, I quickly found out end-users needed to have full rights on the parent object to use the object in their own folder. This defeated the entire purpose of using a linked report object. Give me SSRS! Separate CMC: Why do you have to launch another application just to manage your object security? Worse, why isn't the functionality identical between CMC and InfoSys? For example, if you want to setup a scheduled report to retry on failed attempts, then you can specify the number of retries and the retry interval in CMC. However, you can't do this in InfoSys and you can't see the information either. InfoSys allows you to setup event-driven schedules and CMC does not support this feature. Java Version Dependency: BOXI works great on end-user machines so long as they are running the same version of java as the server. However, once a newer version of java is installed on your machine, things starts to break. We're running Java 1.5 on our BOXI R2 server (the default java client) and almost everyone in the company is on Java 1.6. If you use Java 1.6, then prompts can freeze your IE and FoxFire sessions or crash your report builder unexpectedly. Weak Discoverability: Aside from BOB (Business Objects Board), there isn't much out there on the Internet regarding troubleshooting Business Objects problems. Cognos Series 8 PROS Ease of Use: Although BOXI is easier to use for writing simple reports for general business users, Cognos is a close 2nd in this area. Database Agnostic: Like BOXI this is definitely a good solution if you expect to use Oracle, DB2, or another database back-end. FrameWork Manager: This is definitely a best-in-class meta-data repository. BOXI's universe builder wishes it was half as good. This tool is well suited to promoting packages across Development, Test, and Production environments. CONS Cost: Same issue as Business Objects. Similar cost structure. Similar database licensing requirements as well. No Source Control: Same issue as Business Objects. I'm not aware of any 3rd party tools that resolve this issue, but they might exist. Model Bias: Same issue as Business Objects. Has better support for stored procedures in FrameWork Manager, though. Poor Parameter Support: Same issue as Business Objects. Has better support for creating prompt-pages if you can code in Java. Buggy behavior, though, when users click the back-button to return to the prompt-page. SSRS beats this out hands-down. Inadequate Error Handling: Error messages in Cognos are nearly impossible to decipher. They generally give you a long negative number and a stack dump as part of the error message. I don't know how many times we "resolved" these error messages by rebuilding reports from scratch. For some reason, it is pretty easy to corrupt a report definition. No Discoverability: It is very hard to track down any answers on how to troubleshoot problems or to implement functionality in Cognos. There just isn't adequate community support in Internet facing websites for the products. As you can guess from my answer, I believe Microsoft's BI suite is the best platform on the market. However, I must state that most articles I've read on comparisons of BI suites usually do not rate Microsoft's offering as well as SAP's Business Objects and Cognos's Series 8 products. Also, I've also seen Microsoft come out on the bottom in internal reviews of BI Suites in two separate companies after they were review by the reigning CIO's. In both instances, though, it seemed like it all boiled down to wanting to be perceived as a major department that justified a large operating budget.
Enterprise Reporting Solutions What options are there in the industry for enterprise reporting? I'm currently using SSRS 2005, and know that there is another version coming out with the new release of MSSQL. But, it seems like it might also be a good time to investigate the market to see what else is out there. What have you encountered? Do you like it/dislike it? Why? Thank you.
TITLE: Enterprise Reporting Solutions QUESTION: What options are there in the industry for enterprise reporting? I'm currently using SSRS 2005, and know that there is another version coming out with the new release of MSSQL. But, it seems like it might also be a good time to investigate the market to see what else is out there. What have you encountered? Do you like it/dislike it? Why? Thank you. ANSWER: I've used Cognos Series 7, Cognos Series 8, Crystal Reports, Business Objects XI R2 WebIntelligence, Reporting Services 2000, Reporting Services 2005, and Reporting Services 2008. Here's my feedback on what I've learned: Reporting Services 2008/2005/2000 PROS Cost: Cheapest enterprise business intelligence solution if you are using MS SQL Server as a back-end. You also have a best-in-class ETL solution at no additional cost if you throw in SSIS. Most Flexible: Most flexible reporting solution I've ever used. It has always met all my business needs, particularly in its latest incarnation. Easily Scalable: We initially used this as a departmental solution supporting about 20 users. We eventually expanded it to cover a few thousand users. Despite having a really bad quality virtual server located in a remote data center, we were able to scale to about 50-100 concurrent user requests. On good hardware at a consulting gig, I was able to scale it to a larger set of concurrent users without any issues. I've also seen implementations where multiple SSRS servers were deployed in different countries and SSIS was used to synch the data in the back-ends. This allowed for solid performance in a distributed manner at almost no additional cost. Source Control Integration: This is CRITICAL to me when developing reports with my business intelligence teams. No other BI suite offers an out-of-box solution for this that I've ever used. Every other platform I used either required purchasing a 3rd party add-in or required you to promote reports between separate development, test, and production environments. Analysis Services: I like the tight integration with Analysis Services between SSRS and SSIS. I've read about instances where Oracle and DB2 quotes include installing a SQL Server 2005 Analysis Services server for OLAP cubes. Discoverability: No system has better discoverability than SSRS. There are more books, forums, articles, and code sites on SSRS than any other BI suite that I've ever used. If I needed to figuire out how to do something in SSRS, I could almost always find it with a few minutes or hours of work. CONS IIS Required for SSRS 2005/2000: Older versions of SSRS required installing IIS on the database server. This was not permissible from an internal controls perspective when I worked at a large bank. We eventually implemented SSRS without authorized approval from IT operations and basically asked for forgiveness later. This is not an issue in SSRS 2008 since IIS is no longer required. Report Builder: The web-based report builder was non-existant in SSRS 2000. The web-based report builder in SSRS 2005 was difficult to use and did not have enough functionality. The web-based report builder in SSRS 2008 is definitely better, but it is still too difficult to use for most business users. Database Bias: It works best with Microsoft SQL Server. It isn't great with Oracle, DB2, and other back-ends. Business Objects XI WebIntelligence PROS Ease of Use: Easiest to use for your average non-BI end-user for developing ad hoc reports. Database Agnostic: Definitely a good solution if you expect to use Oracle, DB2, or another database back-end. Performant: Very fast performance since most of the page navigations are basically file-system operations instead of database-calls. CONS Cost: Number one problem. If I want to scale up my implementation of Business Objects from 30 users to 1000 users, then SAP will make certain to charge you a few hundred thousands of dollars. And that's just for the Business Objects licenses. Add in the fact that you will also need database server licenses, you are now talking about a very expensive system. Of course, that could be the personal justification for getting Business Objects: if you can convince management to purchase a very expensive BI system, then you can probably convince management to pay for a large BI department. No Source Control: Lack of out-of-the-box source control integration leads to errors in accidentally modifying and deploying old report definitions by mistake. The "work-around" for this is promote reports between environments -- a process that I do NOT like to do since it slows down report development and introduces environmental differences variables. No HTML Email Support: You cannot send an HTML email via a schedule. I regularly do this in SSRS. You can buy an expensive 3rd party add-in to do this, but you shouldn't have to spend more money for this functionality. Model Bias: Report development requires universes -- basically a data model. That's fine for ad hoc report development, but I prefer to use stored procedures to have full control of performance. I also like to build flat tables that are then queried to avoid costly complex joins during report run-time. It is silly to have to build universes that just contain flat tables that are only used by one report. You shouldn't have to build a model just to query a table. Store procedure support is also not supported out of the box without hacking the SQL Overrides. Poor Parameter Support: Parameter support is terrible in BOXI WebIntelligence reports. Although I like the meta-data refresh options for general business users, it just isn't robust enough when trying to setup schedules. I almost always have to clone reports and alter the filters slightly which leads to unnecessary report definition duplication. SSRS beats this hands down, particularly since you can make the value and the label have different values -- unlike BOXI. Inadequate Report Linking Support: I wanted to store one report definition in a central folder and then create linked reports for other users. However, I quickly found out end-users needed to have full rights on the parent object to use the object in their own folder. This defeated the entire purpose of using a linked report object. Give me SSRS! Separate CMC: Why do you have to launch another application just to manage your object security? Worse, why isn't the functionality identical between CMC and InfoSys? For example, if you want to setup a scheduled report to retry on failed attempts, then you can specify the number of retries and the retry interval in CMC. However, you can't do this in InfoSys and you can't see the information either. InfoSys allows you to setup event-driven schedules and CMC does not support this feature. Java Version Dependency: BOXI works great on end-user machines so long as they are running the same version of java as the server. However, once a newer version of java is installed on your machine, things starts to break. We're running Java 1.5 on our BOXI R2 server (the default java client) and almost everyone in the company is on Java 1.6. If you use Java 1.6, then prompts can freeze your IE and FoxFire sessions or crash your report builder unexpectedly. Weak Discoverability: Aside from BOB (Business Objects Board), there isn't much out there on the Internet regarding troubleshooting Business Objects problems. Cognos Series 8 PROS Ease of Use: Although BOXI is easier to use for writing simple reports for general business users, Cognos is a close 2nd in this area. Database Agnostic: Like BOXI this is definitely a good solution if you expect to use Oracle, DB2, or another database back-end. FrameWork Manager: This is definitely a best-in-class meta-data repository. BOXI's universe builder wishes it was half as good. This tool is well suited to promoting packages across Development, Test, and Production environments. CONS Cost: Same issue as Business Objects. Similar cost structure. Similar database licensing requirements as well. No Source Control: Same issue as Business Objects. I'm not aware of any 3rd party tools that resolve this issue, but they might exist. Model Bias: Same issue as Business Objects. Has better support for stored procedures in FrameWork Manager, though. Poor Parameter Support: Same issue as Business Objects. Has better support for creating prompt-pages if you can code in Java. Buggy behavior, though, when users click the back-button to return to the prompt-page. SSRS beats this out hands-down. Inadequate Error Handling: Error messages in Cognos are nearly impossible to decipher. They generally give you a long negative number and a stack dump as part of the error message. I don't know how many times we "resolved" these error messages by rebuilding reports from scratch. For some reason, it is pretty easy to corrupt a report definition. No Discoverability: It is very hard to track down any answers on how to troubleshoot problems or to implement functionality in Cognos. There just isn't adequate community support in Internet facing websites for the products. As you can guess from my answer, I believe Microsoft's BI suite is the best platform on the market. However, I must state that most articles I've read on comparisons of BI suites usually do not rate Microsoft's offering as well as SAP's Business Objects and Cognos's Series 8 products. Also, I've also seen Microsoft come out on the bottom in internal reviews of BI Suites in two separate companies after they were review by the reigning CIO's. In both instances, though, it seemed like it all boiled down to wanting to be perceived as a major department that justified a large operating budget.
[ "sql", "reporting-services", "reporting" ]
38
42
7,644
14
0
2008-08-19T19:38:38.640000
2008-11-17T22:50:31.287000
16,808
16,811
Error viewing csproj property pages in VisualStudio2005
When I goto view the property page for my CSharp test application I get the following error. "An error occurred trying to load the page. COM object that has been seperated from its underlying RCW cannot be used." The only thing that seems to fix it is rebooting my PC!
This is usually caused by a 'rogue' add-in. Try disabling them all, and then re-enabling them checking for the error - so that you can narrow down the culprit.
Error viewing csproj property pages in VisualStudio2005 When I goto view the property page for my CSharp test application I get the following error. "An error occurred trying to load the page. COM object that has been seperated from its underlying RCW cannot be used." The only thing that seems to fix it is rebooting my PC!
TITLE: Error viewing csproj property pages in VisualStudio2005 QUESTION: When I goto view the property page for my CSharp test application I get the following error. "An error occurred trying to load the page. COM object that has been seperated from its underlying RCW cannot be used." The only thing that seems to fix it is rebooting my PC! ANSWER: This is usually caused by a 'rogue' add-in. Try disabling them all, and then re-enabling them checking for the error - so that you can narrow down the culprit.
[ "visual-studio" ]
1
1
676
2
0
2008-08-19T19:42:15.777000
2008-08-19T19:46:58.153000
16,815
16,818
Accessing html parameter in PHP
I'm trying to do a simple test php script for sessions. Basically it increments a counter (stored in $_SESSION ) every time you refresh that page. That works, but I'm trying to have a link to destroy the session which reloads the page with the?destroy=1 parameter. I've tried a couple of if statements to see if that parameter is set and if so to destroy the session but it doesn't seem to work. I've even put an if statement in the main body to pop-up a message if the parameter is set - but it doesn't seem to be picked up. I know I'm doing something silly (I'm a PHP newbie) but I can't seem to find what it is... See code here: Session test "; echo "I am tracking you using the session id ". session_id(). " "; echo "Click here to destroy the session.";?>
I think you put $_POST['destroy'] Instead of $_GET['destroy'] You need to use a form if you'd like to use a $_POST variable. $_GET variables are stored in the URL.
Accessing html parameter in PHP I'm trying to do a simple test php script for sessions. Basically it increments a counter (stored in $_SESSION ) every time you refresh that page. That works, but I'm trying to have a link to destroy the session which reloads the page with the?destroy=1 parameter. I've tried a couple of if statements to see if that parameter is set and if so to destroy the session but it doesn't seem to work. I've even put an if statement in the main body to pop-up a message if the parameter is set - but it doesn't seem to be picked up. I know I'm doing something silly (I'm a PHP newbie) but I can't seem to find what it is... See code here: Session test "; echo "I am tracking you using the session id ". session_id(). " "; echo "Click here to destroy the session.";?>
TITLE: Accessing html parameter in PHP QUESTION: I'm trying to do a simple test php script for sessions. Basically it increments a counter (stored in $_SESSION ) every time you refresh that page. That works, but I'm trying to have a link to destroy the session which reloads the page with the?destroy=1 parameter. I've tried a couple of if statements to see if that parameter is set and if so to destroy the session but it doesn't seem to work. I've even put an if statement in the main body to pop-up a message if the parameter is set - but it doesn't seem to be picked up. I know I'm doing something silly (I'm a PHP newbie) but I can't seem to find what it is... See code here: Session test "; echo "I am tracking you using the session id ". session_id(). " "; echo "Click here to destroy the session.";?> ANSWER: I think you put $_POST['destroy'] Instead of $_GET['destroy'] You need to use a form if you'd like to use a $_POST variable. $_GET variables are stored in the URL.
[ "php", "session" ]
1
6
1,235
5
0
2008-08-19T19:49:54.577000
2008-08-19T19:52:03.930000
16,828
16,837
How do you do a case insensitive search using a pattern modifier using less?
It seems like the only way to do this is to pass the -i parameter in when you initially run less. Does anyone know of some secret hack to make something like this work /something to search for/i
You can also type command -I while less is running. It toggles case sensitivity for searches.
How do you do a case insensitive search using a pattern modifier using less? It seems like the only way to do this is to pass the -i parameter in when you initially run less. Does anyone know of some secret hack to make something like this work /something to search for/i
TITLE: How do you do a case insensitive search using a pattern modifier using less? QUESTION: It seems like the only way to do this is to pass the -i parameter in when you initially run less. Does anyone know of some secret hack to make something like this work /something to search for/i ANSWER: You can also type command -I while less is running. It toggles case sensitivity for searches.
[ "unix", "search", "case-insensitive", "less-unix" ]
355
517
98,027
5
0
2008-08-19T20:00:33.900000
2008-08-19T20:09:09.483000
16,832
16,870
Lightweight source control
I am looking for a lightweight source control system for use on "hobby" projects with only one person (myself) working on the project. Does anyone have any suggestions? Ideally it should interface with Visual Studio either naively or through another plug-in, outside of that, anything that works would be nice to be replace Gmail as source control.
You can use assembla.com to host your project. They offer subversion, git and mercurial hosting. I personally use their subversion hosting for a free and private one-man project. As an added bonus, you also get a wiki and a ticketing system. Which can help you manage your stuff. And the best thing is that you don't have to setup your subversion server and it is hosted off-site. It's really good for a free service. Personnaly, i use TortoiseSVN as my client but it isn't integrated in visual studio. For the integration, you can try VisualSVN (not free) or AnkhSVN (free)
Lightweight source control I am looking for a lightweight source control system for use on "hobby" projects with only one person (myself) working on the project. Does anyone have any suggestions? Ideally it should interface with Visual Studio either naively or through another plug-in, outside of that, anything that works would be nice to be replace Gmail as source control.
TITLE: Lightweight source control QUESTION: I am looking for a lightweight source control system for use on "hobby" projects with only one person (myself) working on the project. Does anyone have any suggestions? Ideally it should interface with Visual Studio either naively or through another plug-in, outside of that, anything that works would be nice to be replace Gmail as source control. ANSWER: You can use assembla.com to host your project. They offer subversion, git and mercurial hosting. I personally use their subversion hosting for a free and private one-man project. As an added bonus, you also get a wiki and a ticketing system. Which can help you manage your stuff. And the best thing is that you don't have to setup your subversion server and it is hosted off-site. It's really good for a free service. Personnaly, i use TortoiseSVN as my client but it isn't integrated in visual studio. For the integration, you can try VisualSVN (not free) or AnkhSVN (free)
[ "version-control" ]
18
14
6,458
16
0
2008-08-19T20:06:55.803000
2008-08-19T20:22:49.097000
16,833
16,856
How do you download and extract a gzipped file with C#?
I need to periodically download, extract and save the contents of http://data.dot.state.mn.us/dds/det_sample.xml.gz to disk. Anyone have experience downloading gzipped files with C#?
To compress: using (FileStream fStream = new FileStream(@"C:\test.docx.gzip", FileMode.Create, FileAccess.Write)) { using (GZipStream zipStream = new GZipStream(fStream, CompressionMode.Compress)) { byte[] inputfile = File.ReadAllBytes(@"c:\test.docx"); zipStream.Write(inputfile, 0, inputfile.Length); } } To Decompress: using (FileStream fInStream = new FileStream(@"c:\test.docx.gz", FileMode.Open, FileAccess.Read)) { using (GZipStream zipStream = new GZipStream(fInStream, CompressionMode.Decompress)) { using (FileStream fOutStream = new FileStream(@"c:\test1.docx", FileMode.Create, FileAccess.Write)) { byte[] tempBytes = new byte[4096]; int i; while ((i = zipStream.Read(tempBytes, 0, tempBytes.Length))!= 0) { fOutStream.Write(tempBytes, 0, i); } } } } Taken from a post I wrote last year that shows how to decompress a gzip file using C# and the built-in GZipStream class. http://blogs.msdn.com/miah/archive/2007/09/05/zipping-files.aspx As for downloading it, you can use the standard WebRequest or WebClient classes in.NET.
How do you download and extract a gzipped file with C#? I need to periodically download, extract and save the contents of http://data.dot.state.mn.us/dds/det_sample.xml.gz to disk. Anyone have experience downloading gzipped files with C#?
TITLE: How do you download and extract a gzipped file with C#? QUESTION: I need to periodically download, extract and save the contents of http://data.dot.state.mn.us/dds/det_sample.xml.gz to disk. Anyone have experience downloading gzipped files with C#? ANSWER: To compress: using (FileStream fStream = new FileStream(@"C:\test.docx.gzip", FileMode.Create, FileAccess.Write)) { using (GZipStream zipStream = new GZipStream(fStream, CompressionMode.Compress)) { byte[] inputfile = File.ReadAllBytes(@"c:\test.docx"); zipStream.Write(inputfile, 0, inputfile.Length); } } To Decompress: using (FileStream fInStream = new FileStream(@"c:\test.docx.gz", FileMode.Open, FileAccess.Read)) { using (GZipStream zipStream = new GZipStream(fInStream, CompressionMode.Decompress)) { using (FileStream fOutStream = new FileStream(@"c:\test1.docx", FileMode.Create, FileAccess.Write)) { byte[] tempBytes = new byte[4096]; int i; while ((i = zipStream.Read(tempBytes, 0, tempBytes.Length))!= 0) { fOutStream.Write(tempBytes, 0, i); } } } } Taken from a post I wrote last year that shows how to decompress a gzip file using C# and the built-in GZipStream class. http://blogs.msdn.com/miah/archive/2007/09/05/zipping-files.aspx As for downloading it, you can use the standard WebRequest or WebClient classes in.NET.
[ "c#", ".net", "gzip" ]
23
29
24,403
6
0
2008-08-19T20:07:43.230000
2008-08-19T20:15:07.007000
16,860
16,894
Getting Started with Unit Testing
Unit testing is, roughly speaking, testing bits of your code in isolation with test code. The immediate advantages that come to mind are: Running the tests becomes automate-able and repeatable You can test at a much more granular level than point-and-click testing via a GUI Rytmis My question is, what are the current "best practices" in terms of tools as well as when and where to use unit testing as part of your daily coding? Lets try to be somewhat language agnostic and cover all the bases.
Ok here's some best practices from some one who doesn't unit test as much as he should...cough. Make sure your tests test one thing and one thing only. Write unit tests as you go. Preferably before you write the code you are testing against. Do not unit test the GUI. Separate your concerns. Minimise the dependencies of your tests. Mock behviour with mocks.
Getting Started with Unit Testing Unit testing is, roughly speaking, testing bits of your code in isolation with test code. The immediate advantages that come to mind are: Running the tests becomes automate-able and repeatable You can test at a much more granular level than point-and-click testing via a GUI Rytmis My question is, what are the current "best practices" in terms of tools as well as when and where to use unit testing as part of your daily coding? Lets try to be somewhat language agnostic and cover all the bases.
TITLE: Getting Started with Unit Testing QUESTION: Unit testing is, roughly speaking, testing bits of your code in isolation with test code. The immediate advantages that come to mind are: Running the tests becomes automate-able and repeatable You can test at a much more granular level than point-and-click testing via a GUI Rytmis My question is, what are the current "best practices" in terms of tools as well as when and where to use unit testing as part of your daily coding? Lets try to be somewhat language agnostic and cover all the bases. ANSWER: Ok here's some best practices from some one who doesn't unit test as much as he should...cough. Make sure your tests test one thing and one thing only. Write unit tests as you go. Preferably before you write the code you are testing against. Do not unit test the GUI. Separate your concerns. Minimise the dependencies of your tests. Mock behviour with mocks.
[ "unit-testing" ]
25
22
6,586
7
0
2008-08-19T20:18:09.993000
2008-08-19T20:33:28.263000
16,873
16,903
Choosing a multiplier for a (string) hash function
Do you have any advice/rules on selecting a multiplier to use in a (multiplicative) hash function. The function is computing the hash value of a string.
You want to use something that is relatively prime to the size of your set. That way, when you loop around, you won't end up on the same numbers you just tried.
Choosing a multiplier for a (string) hash function Do you have any advice/rules on selecting a multiplier to use in a (multiplicative) hash function. The function is computing the hash value of a string.
TITLE: Choosing a multiplier for a (string) hash function QUESTION: Do you have any advice/rules on selecting a multiplier to use in a (multiplicative) hash function. The function is computing the hash value of a string. ANSWER: You want to use something that is relatively prime to the size of your set. That way, when you loop around, you won't end up on the same numbers you just tried.
[ "performance", "algorithm" ]
16
3
2,321
3
0
2008-08-19T20:23:25.723000
2008-08-19T20:36:07.493000
16,891
17,187
VS 2008 - ctrl-tab behavior
As you may know, in VS 2008 ctrl + tab brings up a nifty navigator window with a thumbnail of each file. I love it, but there is one tiny thing that is annoying to me about this feature: the window stays around after releasing the ctrl key. When doing an alt + tab in windows, you can hit tab to get to the item you want (while still holding down the alt key), and then when you find what you want, lifting up on the alt key selects that item. I wish VS 2008 would do the same. For me, when I lift off of ctrl, the window is still there. I have to hit enter to actually select the item. I find this annoying. Does anyone know how to make VS 2008 dismiss the window on the release of the ctrl key?
You probably have the text-to-speech narrator enabled. http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2467648&SiteID=1&mode=1 Just uncheck all checkboxes under "Text-To-Speech" narrator software. --> To open Narrator using the keyboard, press CTRL + ESC, press R, type narrator, and then press Enter. This one drove me crazy for several months until I found this posting.
VS 2008 - ctrl-tab behavior As you may know, in VS 2008 ctrl + tab brings up a nifty navigator window with a thumbnail of each file. I love it, but there is one tiny thing that is annoying to me about this feature: the window stays around after releasing the ctrl key. When doing an alt + tab in windows, you can hit tab to get to the item you want (while still holding down the alt key), and then when you find what you want, lifting up on the alt key selects that item. I wish VS 2008 would do the same. For me, when I lift off of ctrl, the window is still there. I have to hit enter to actually select the item. I find this annoying. Does anyone know how to make VS 2008 dismiss the window on the release of the ctrl key?
TITLE: VS 2008 - ctrl-tab behavior QUESTION: As you may know, in VS 2008 ctrl + tab brings up a nifty navigator window with a thumbnail of each file. I love it, but there is one tiny thing that is annoying to me about this feature: the window stays around after releasing the ctrl key. When doing an alt + tab in windows, you can hit tab to get to the item you want (while still holding down the alt key), and then when you find what you want, lifting up on the alt key selects that item. I wish VS 2008 would do the same. For me, when I lift off of ctrl, the window is still there. I have to hit enter to actually select the item. I find this annoying. Does anyone know how to make VS 2008 dismiss the window on the release of the ctrl key? ANSWER: You probably have the text-to-speech narrator enabled. http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2467648&SiteID=1&mode=1 Just uncheck all checkboxes under "Text-To-Speech" narrator software. --> To open Narrator using the keyboard, press CTRL + ESC, press R, type narrator, and then press Enter. This one drove me crazy for several months until I found this posting.
[ "visual-studio-2008", "ide", "keyboard-shortcuts" ]
9
13
2,158
10
0
2008-08-19T20:32:42.413000
2008-08-19T23:21:07.110000
16,897
17,642
Delphi and COM: TLB and maintenance issues
In the company that i work, we develop all the GUI in C#, but the application kernel is mainly developed in Delphi 5 (for historical reasons), with a lot of components made in COM+. Related to this very specific sort of application a I two questions: Experienced guys in Delphi and/or COM, do you have any workrounds to work with the buggy TLB interface? Some of the bugs are: IDE crashing during edition of a large TLB, lost of methods IDs, TLB corruption, etc. Here, we haven't found any good solution. Actually we tried do upgrade do the new 2007 version. But the new IDE TLB interface has the same bugs that we found before. How do you control TLBs versions? The TLB file is in a binary format and conflict resolutions are very hard to do. We tried to do it exporting the interfaces descriptions to IDL and commiting into CVS, but we didn't found any good way to generate TLBs from IDL using Delphi. Additionaly, the MIDL tool provided by Microsoft, didn't parse correctly the IDL files that we exported from delphi.
I think you should have a good look at Delphi 2009. Delphi 2009 has changes to the COM support, including a text-based replacement for the binary TLB files. You can read more on Chris Bensen's blog.
Delphi and COM: TLB and maintenance issues In the company that i work, we develop all the GUI in C#, but the application kernel is mainly developed in Delphi 5 (for historical reasons), with a lot of components made in COM+. Related to this very specific sort of application a I two questions: Experienced guys in Delphi and/or COM, do you have any workrounds to work with the buggy TLB interface? Some of the bugs are: IDE crashing during edition of a large TLB, lost of methods IDs, TLB corruption, etc. Here, we haven't found any good solution. Actually we tried do upgrade do the new 2007 version. But the new IDE TLB interface has the same bugs that we found before. How do you control TLBs versions? The TLB file is in a binary format and conflict resolutions are very hard to do. We tried to do it exporting the interfaces descriptions to IDL and commiting into CVS, but we didn't found any good way to generate TLBs from IDL using Delphi. Additionaly, the MIDL tool provided by Microsoft, didn't parse correctly the IDL files that we exported from delphi.
TITLE: Delphi and COM: TLB and maintenance issues QUESTION: In the company that i work, we develop all the GUI in C#, but the application kernel is mainly developed in Delphi 5 (for historical reasons), with a lot of components made in COM+. Related to this very specific sort of application a I two questions: Experienced guys in Delphi and/or COM, do you have any workrounds to work with the buggy TLB interface? Some of the bugs are: IDE crashing during edition of a large TLB, lost of methods IDs, TLB corruption, etc. Here, we haven't found any good solution. Actually we tried do upgrade do the new 2007 version. But the new IDE TLB interface has the same bugs that we found before. How do you control TLBs versions? The TLB file is in a binary format and conflict resolutions are very hard to do. We tried to do it exporting the interfaces descriptions to IDL and commiting into CVS, but we didn't found any good way to generate TLBs from IDL using Delphi. Additionaly, the MIDL tool provided by Microsoft, didn't parse correctly the IDL files that we exported from delphi. ANSWER: I think you should have a good look at Delphi 2009. Delphi 2009 has changes to the COM support, including a text-based replacement for the binary TLB files. You can read more on Chris Bensen's blog.
[ "delphi", "com", "typelib", "com-hell" ]
9
11
5,929
5
0
2008-08-19T20:34:13.177000
2008-08-20T09:16:37.427000
16,918
16,951
Beginners Guide to Haskell?
I've been looking for a decent guide to Haskell for some time, but haven't been able to find one that seems interesting enough to read through and/or makes sense. I've had prior exposure to Haskell a few years back, but I can't remember much about it. I remember the "Aha!"-feeling was incredible when I finally got it, and it was actually fun to play with, so I'm looking to rediscover the lost art of Haskell. I'm familiar with Ruby and its functional programming tricks, so I think I'm not completely in the dark. Any links?
Some good places to start are: The Gentle Introduction To Haskell Problem Solving in Haskell Happy Learn Haskell Tutorial Other resources: Interesting blog entry on a Study plan for Haskell via the Wayback Machine HaskellWiki Generic Haskell User Guide (PDF)
Beginners Guide to Haskell? I've been looking for a decent guide to Haskell for some time, but haven't been able to find one that seems interesting enough to read through and/or makes sense. I've had prior exposure to Haskell a few years back, but I can't remember much about it. I remember the "Aha!"-feeling was incredible when I finally got it, and it was actually fun to play with, so I'm looking to rediscover the lost art of Haskell. I'm familiar with Ruby and its functional programming tricks, so I think I'm not completely in the dark. Any links?
TITLE: Beginners Guide to Haskell? QUESTION: I've been looking for a decent guide to Haskell for some time, but haven't been able to find one that seems interesting enough to read through and/or makes sense. I've had prior exposure to Haskell a few years back, but I can't remember much about it. I remember the "Aha!"-feeling was incredible when I finally got it, and it was actually fun to play with, so I'm looking to rediscover the lost art of Haskell. I'm familiar with Ruby and its functional programming tricks, so I think I'm not completely in the dark. Any links? ANSWER: Some good places to start are: The Gentle Introduction To Haskell Problem Solving in Haskell Happy Learn Haskell Tutorial Other resources: Interesting blog entry on a Study plan for Haskell via the Wayback Machine HaskellWiki Generic Haskell User Guide (PDF)
[ "haskell", "functional-programming" ]
122
49
22,234
16
0
2008-08-19T20:44:48.897000
2008-08-19T21:04:10.603000
16,926
330,236
Tool for generating CSS skeleton?
My HTML is all marked up, ready to make it rain CSS. The problem is that I have to go back and find out what all my id and class names are so I can get started. What I need is a tool that parses my HTML and spits out a stylesheet with all the possible elements ready to be styled (maybe even with some defaults). Does such a tool exist?
http://lab.xms.pl/css-generator/ seems to fit the description.
Tool for generating CSS skeleton? My HTML is all marked up, ready to make it rain CSS. The problem is that I have to go back and find out what all my id and class names are so I can get started. What I need is a tool that parses my HTML and spits out a stylesheet with all the possible elements ready to be styled (maybe even with some defaults). Does such a tool exist?
TITLE: Tool for generating CSS skeleton? QUESTION: My HTML is all marked up, ready to make it rain CSS. The problem is that I have to go back and find out what all my id and class names are so I can get started. What I need is a tool that parses my HTML and spits out a stylesheet with all the possible elements ready to be styled (maybe even with some defaults). Does such a tool exist? ANSWER: http://lab.xms.pl/css-generator/ seems to fit the description.
[ "css", "markup" ]
20
3
2,407
9
0
2008-08-19T20:49:47.967000
2008-12-01T07:44:43.330000
16,935
19,782
Ant's <javac> tasks throws StackOverflowException
I'm trying to compile over 100 java classes from different packages from a clean directory (no incremental compiles) using the following ant tasks: Compiling However, the first time I run the compile task I always get a StackOverflowException. If I run the task again the compiler does an incremental build and everything works fine. This is undesirable since we are using CruiseControl to do an automatic daily build and this is causing false build failures. As a quick-and-dirty solution I have created 2 separate tasks, compiling portions of the project in each. I really don't think this solution will hold as more classes are added in the future, and I don't want to be adding new compile tasks every time we hit the "compile limit".
It will be nice to know; what can cause or causes a StackOverflowError during compilation of Java code? It is probable that evaluating the long expression in your java file consumes lots of memory and because this is being done in conjunction with the compilation of other classes, the VM just runs out of stack space. Your generated class is perhaps pushing the legal limits for its contents. See chapter 4.10 Limitations of the Java Virtual Machine in The Java Virtual Machine Specification, Second Edition. Fix 1: refactor the class Since your class is being generated, this might not be an option. Still, it is worth looking at the options your class generation tool offers to see if it can produce something less troublesome. Fix 2: increase the stack size I think Kieron has one solution when he mentions the -Xss argument. javac takes a number of non-standard arguments that will vary between versions and compiler vendors. My compiler: $ javac -version javac 1.6.0_05 To list all the options for it, I'd use these commands: javac -help javac -X javac -J-X I think the stack limit for javac is 512Kb by default. You can increase the stack size for this compiler to 10Mb with this command: javac -J-Xss10M Foo.java You might be able to pass this in an Ant file with a compilerarg element nested in your javac task.
Ant's <javac> tasks throws StackOverflowException I'm trying to compile over 100 java classes from different packages from a clean directory (no incremental compiles) using the following ant tasks: Compiling However, the first time I run the compile task I always get a StackOverflowException. If I run the task again the compiler does an incremental build and everything works fine. This is undesirable since we are using CruiseControl to do an automatic daily build and this is causing false build failures. As a quick-and-dirty solution I have created 2 separate tasks, compiling portions of the project in each. I really don't think this solution will hold as more classes are added in the future, and I don't want to be adding new compile tasks every time we hit the "compile limit".
TITLE: Ant's <javac> tasks throws StackOverflowException QUESTION: I'm trying to compile over 100 java classes from different packages from a clean directory (no incremental compiles) using the following ant tasks: Compiling However, the first time I run the compile task I always get a StackOverflowException. If I run the task again the compiler does an incremental build and everything works fine. This is undesirable since we are using CruiseControl to do an automatic daily build and this is causing false build failures. As a quick-and-dirty solution I have created 2 separate tasks, compiling portions of the project in each. I really don't think this solution will hold as more classes are added in the future, and I don't want to be adding new compile tasks every time we hit the "compile limit". ANSWER: It will be nice to know; what can cause or causes a StackOverflowError during compilation of Java code? It is probable that evaluating the long expression in your java file consumes lots of memory and because this is being done in conjunction with the compilation of other classes, the VM just runs out of stack space. Your generated class is perhaps pushing the legal limits for its contents. See chapter 4.10 Limitations of the Java Virtual Machine in The Java Virtual Machine Specification, Second Edition. Fix 1: refactor the class Since your class is being generated, this might not be an option. Still, it is worth looking at the options your class generation tool offers to see if it can produce something less troublesome. Fix 2: increase the stack size I think Kieron has one solution when he mentions the -Xss argument. javac takes a number of non-standard arguments that will vary between versions and compiler vendors. My compiler: $ javac -version javac 1.6.0_05 To list all the options for it, I'd use these commands: javac -help javac -X javac -J-X I think the stack limit for javac is 512Kb by default. You can increase the stack size for this compiler to 10Mb with this command: javac -J-Xss10M Foo.java You might be able to pass this in an Ant file with a compilerarg element nested in your javac task.
[ "java", "ant" ]
6
5
9,362
7
0
2008-08-19T20:53:53.417000
2008-08-21T12:58:37.930000
16,939
16,967
Difference between a byte array and MemoryStream
I am reading a binary file into a parsing program. I will need to iterate through the file and look for certain markers so I can split the file up and pass those parts into their respective object’s constructors. Is there an advantage to holding the file as a stream, either MemoryStream or FileStream, or should it be converted into a byte[] array? Keith
A byte[] or MemoryStream will both require bringing the entire file into memory. A MemoryStream is really a wrapper around an underlying byte array. The best approach is to have two FileStream (one for input and one for output). Read from the input stream looking for the pattern used to indicate the file should be separated while writing to the current output file. You may want to consider wrapping the input and output files in a BinaryReader and BinaryWriter respectively if they add value to your scenario.
Difference between a byte array and MemoryStream I am reading a binary file into a parsing program. I will need to iterate through the file and look for certain markers so I can split the file up and pass those parts into their respective object’s constructors. Is there an advantage to holding the file as a stream, either MemoryStream or FileStream, or should it be converted into a byte[] array? Keith
TITLE: Difference between a byte array and MemoryStream QUESTION: I am reading a binary file into a parsing program. I will need to iterate through the file and look for certain markers so I can split the file up and pass those parts into their respective object’s constructors. Is there an advantage to holding the file as a stream, either MemoryStream or FileStream, or should it be converted into a byte[] array? Keith ANSWER: A byte[] or MemoryStream will both require bringing the entire file into memory. A MemoryStream is really a wrapper around an underlying byte array. The best approach is to have two FileStream (one for input and one for output). Read from the input stream looking for the pattern used to indicate the file should be separated while writing to the current output file. You may want to consider wrapping the input and output files in a BinaryReader and BinaryWriter respectively if they add value to your scenario.
[ "performance", "comparison" ]
22
30
15,952
2
0
2008-08-19T20:57:24.783000
2008-08-19T21:12:20.040000
16,964
17,024
Creating your own table with CommandArgument buttons in ASP.NET MVC
I'm trying to implement something like this: Port name Current port version New port version Update <% foreach (var ip in Ports) { %> <%= ip.PortName %> <%= ip.CurrentVersion %> <%= ip.NewVersion %> <% } %> The button's CommandArgument property is where my code complains about not being able to resolve symbol ip. Is there any way to do what I'm trying to do? ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­
You don't want to use a Webforms button in ASP.NET MVC. MVC is a completely different way of working, and you no longer have the WebForms abstraction. You have 2 different options you can either replace your asp:Button with an input tag or use a standard hyperlink instead. If you use the input option then you will need to wrap in a form element. The form action should point to a Controller action.
Creating your own table with CommandArgument buttons in ASP.NET MVC I'm trying to implement something like this: Port name Current port version New port version Update <% foreach (var ip in Ports) { %> <%= ip.PortName %> <%= ip.CurrentVersion %> <%= ip.NewVersion %> <% } %> The button's CommandArgument property is where my code complains about not being able to resolve symbol ip. Is there any way to do what I'm trying to do? ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­
TITLE: Creating your own table with CommandArgument buttons in ASP.NET MVC QUESTION: I'm trying to implement something like this: Port name Current port version New port version Update <% foreach (var ip in Ports) { %> <%= ip.PortName %> <%= ip.CurrentVersion %> <%= ip.NewVersion %> <% } %> The button's CommandArgument property is where my code complains about not being able to resolve symbol ip. Is there any way to do what I'm trying to do? ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­ ANSWER: You don't want to use a Webforms button in ASP.NET MVC. MVC is a completely different way of working, and you no longer have the WebForms abstraction. You have 2 different options you can either replace your asp:Button with an input tag or use a standard hyperlink instead. If you use the input option then you will need to wrap in a form element. The form action should point to a Controller action.
[ "asp.net-mvc" ]
0
3
2,169
4
0
2008-08-19T21:10:47.890000
2008-08-19T21:43:38.137000
16,991
17,010
What Ruby IDE do you prefer?
I've been using Eclipse with RDT (not RadRails) a lot lately, and I'm quite happy with it, but I'm wondering if you guys know any decent alternatives. I know NetBeans also supports Ruby these days, but I'm not sure what it has to offer over Eclipse. Please, list any features you think are brilliant or useful when suggesting an IDE, makes it easier to compare. Also, I said Ruby, not Rails. While Rails support is a plus, I prefer things to be none Rails-centric. It should also be available on Linux and optionally Solaris.
Have you tried Aptana? It's based on Eclipse and they have a sweet Rails plugin.
What Ruby IDE do you prefer? I've been using Eclipse with RDT (not RadRails) a lot lately, and I'm quite happy with it, but I'm wondering if you guys know any decent alternatives. I know NetBeans also supports Ruby these days, but I'm not sure what it has to offer over Eclipse. Please, list any features you think are brilliant or useful when suggesting an IDE, makes it easier to compare. Also, I said Ruby, not Rails. While Rails support is a plus, I prefer things to be none Rails-centric. It should also be available on Linux and optionally Solaris.
TITLE: What Ruby IDE do you prefer? QUESTION: I've been using Eclipse with RDT (not RadRails) a lot lately, and I'm quite happy with it, but I'm wondering if you guys know any decent alternatives. I know NetBeans also supports Ruby these days, but I'm not sure what it has to offer over Eclipse. Please, list any features you think are brilliant or useful when suggesting an IDE, makes it easier to compare. Also, I said Ruby, not Rails. While Rails support is a plus, I prefer things to be none Rails-centric. It should also be available on Linux and optionally Solaris. ANSWER: Have you tried Aptana? It's based on Eclipse and they have a sweet Rails plugin.
[ "ruby", "ide", "editor" ]
141
27
426,567
25
0
2008-08-19T21:26:22.150000
2008-08-19T21:35:46.593000
16,998
17,236
Reading "chunked" response with HttpWebResponse
I'm having trouble reading a "chunked" response when using a StreamReader to read the stream returned by GetResponseStream() of a HttpWebResponse: // response is an HttpWebResponse StreamReader reader = new StreamReader(response.GetResponseStream()); string output = reader.ReadToEnd(); // throws exception... When the reader.ReadToEnd() method is called I'm getting the following System.IO.IOException: Unable to read data from the transport connection: The connection was closed. The above code works just fine when server returns a "non-chunked" response. The only way I've been able to get it to work is to use HTTP/1.0 for the initial request (instead of HTTP/1.1, the default) but this seems like a lame work-around. Any ideas? @Chuck Your solution works pretty good. It still throws the same IOExeception on the last Read(). But after inspecting the contents of the StringBuilder it looks like all the data has been received. So perhaps I just need to wrap the Read() in a try-catch and swallow the "error".
Haven't tried it this with a "chunked" response but would something like this work? StringBuilder sb = new StringBuilder(); Byte[] buf = new byte[8192]; Stream resStream = response.GetResponseStream(); string tmpString = null; int count = 0; do { count = resStream.Read(buf, 0, buf.Length); if(count!= 0) { tmpString = Encoding.ASCII.GetString(buf, 0, count); sb.Append(tmpString); } }while (count > 0);
Reading "chunked" response with HttpWebResponse I'm having trouble reading a "chunked" response when using a StreamReader to read the stream returned by GetResponseStream() of a HttpWebResponse: // response is an HttpWebResponse StreamReader reader = new StreamReader(response.GetResponseStream()); string output = reader.ReadToEnd(); // throws exception... When the reader.ReadToEnd() method is called I'm getting the following System.IO.IOException: Unable to read data from the transport connection: The connection was closed. The above code works just fine when server returns a "non-chunked" response. The only way I've been able to get it to work is to use HTTP/1.0 for the initial request (instead of HTTP/1.1, the default) but this seems like a lame work-around. Any ideas? @Chuck Your solution works pretty good. It still throws the same IOExeception on the last Read(). But after inspecting the contents of the StringBuilder it looks like all the data has been received. So perhaps I just need to wrap the Read() in a try-catch and swallow the "error".
TITLE: Reading "chunked" response with HttpWebResponse QUESTION: I'm having trouble reading a "chunked" response when using a StreamReader to read the stream returned by GetResponseStream() of a HttpWebResponse: // response is an HttpWebResponse StreamReader reader = new StreamReader(response.GetResponseStream()); string output = reader.ReadToEnd(); // throws exception... When the reader.ReadToEnd() method is called I'm getting the following System.IO.IOException: Unable to read data from the transport connection: The connection was closed. The above code works just fine when server returns a "non-chunked" response. The only way I've been able to get it to work is to use HTTP/1.0 for the initial request (instead of HTTP/1.1, the default) but this seems like a lame work-around. Any ideas? @Chuck Your solution works pretty good. It still throws the same IOExeception on the last Read(). But after inspecting the contents of the StringBuilder it looks like all the data has been received. So perhaps I just need to wrap the Read() in a try-catch and swallow the "error". ANSWER: Haven't tried it this with a "chunked" response but would something like this work? StringBuilder sb = new StringBuilder(); Byte[] buf = new byte[8192]; Stream resStream = response.GetResponseStream(); string tmpString = null; int count = 0; do { count = resStream.Read(buf, 0, buf.Length); if(count!= 0) { tmpString = Encoding.ASCII.GetString(buf, 0, count); sb.Append(tmpString); } }while (count > 0);
[ "c#", "http", ".net-3.5", ".net-2.0" ]
14
2
24,760
5
0
2008-08-19T21:28:53.097000
2008-08-19T23:54:37.670000
17,017
17,021
How do I parse and convert a DateTime to the RFC 3339 date-time format?
How do I convert a DateTime structure to its equivalent RFC 3339 formatted string representation and/or parse this string representation back to a DateTime structure? The RFC-3339 date-time format is used in a number of specifications such as the Atom Syndication Format.
This is an implementation in C# of how to parse and convert a DateTime to and from its RFC-3339 representation. The only restriction it has is that the DateTime is in Coordinated Universal Time (UTC). using System; using System.Globalization; namespace DateTimeConsoleApplication { /// /// Provides methods for converting structures to and from the equivalent RFC 3339 string representation. /// public static class Rfc3339DateTime { //============================================================ // Private members //============================================================ #region Private Members /// /// Private member to hold array of formats that RFC 3339 date-time representations conform to. /// private static string[] formats = new string[0]; /// /// Private member to hold the DateTime format string for representing a DateTime in the RFC 3339 format. /// private const string format = "yyyy-MM-dd'T'HH:mm:ss.fffK"; #endregion //============================================================ // Public Properties //============================================================ #region Rfc3339DateTimeFormat /// /// Gets the custom format specifier that may be used to represent a in the RFC 3339 format. /// /// A DateTime format string that may be used to represent a in the RFC 3339 format. /// /// /// This method returns a string representation of a that /// is precise to the three most significant digits of the seconds fraction; that is, it represents /// the milliseconds in a date and time value. The is a valid /// date-time format string for use in the method. /// /// public static string Rfc3339DateTimeFormat { get { return format; } } #endregion #region Rfc3339DateTimePatterns /// /// Gets an array of the expected formats for RFC 3339 date-time string representations. /// /// /// An array of the expected formats for RFC 3339 date-time string representations /// that may used in the method. /// public static string[] Rfc3339DateTimePatterns { get { if (formats.Length > 0) { return formats; } else { formats = new string[11]; // Rfc3339DateTimePatterns formats[0] = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK"; formats[1] = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'ffffffK"; formats[2] = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffK"; formats[3] = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'ffffK"; formats[4] = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffK"; formats[5] = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'ffK"; formats[6] = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fK"; formats[7] = "yyyy'-'MM'-'dd'T'HH':'mm':'ssK"; // Fall back patterns formats[8] = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK"; // RoundtripDateTimePattern formats[9] = DateTimeFormatInfo.InvariantInfo.UniversalSortableDateTimePattern; formats[10] = DateTimeFormatInfo.InvariantInfo.SortableDateTimePattern; return formats; } } } #endregion //============================================================ // Public Methods //============================================================ #region Parse(string s) /// /// Converts the specified string representation of a date and time to its equivalent. /// /// A string containing a date and time to convert. /// A equivalent to the date and time contained in. /// /// The string is parsed using formatting information in the object. /// /// is a null reference (Nothing in Visual Basic). /// does not contain a valid RFC 3339 string representation of a date and time. public static DateTime Parse(string s) { //------------------------------------------------------------ // Validate parameter //------------------------------------------------------------ if(s == null) { throw new ArgumentNullException("s"); } DateTime result; if (Rfc3339DateTime.TryParse(s, out result)) { return result; } else { throw new FormatException(String.Format(null, "{0} is not a valid RFC 3339 string representation of a date and time.", s)); } } #endregion #region ToString(DateTime utcDateTime) /// /// Converts the value of the specified object to its equivalent string representation. /// /// The Coordinated Universal Time (UTC) to convert. /// A RFC 3339 string representation of the value of the. /// /// /// This method returns a string representation of the that /// is precise to the three most significant digits of the seconds fraction; that is, it represents /// the milliseconds in a date and time value. /// /// /// While it is possible to display higher precision fractions of a second component of a time value, /// that value may not be meaningful. The precision of date and time values depends on the resolution /// of the system clock. On Windows NT 3.5 and later, and Windows Vista operating systems, the clock's /// resolution is approximately 10-15 milliseconds. /// /// /// The specified object does not represent a Coordinated Universal Time (UTC) value. public static string ToString(DateTime utcDateTime) { if (utcDateTime.Kind!= DateTimeKind.Utc) { throw new ArgumentException("utcDateTime"); } return utcDateTime.ToString(Rfc3339DateTime.Rfc3339DateTimeFormat, DateTimeFormatInfo.InvariantInfo); } #endregion #region TryParse(string s, out DateTime result) /// /// Converts the specified string representation of a date and time to its equivalent. /// /// A string containing a date and time to convert. /// /// When this method returns, contains the value equivalent to the date and time /// contained in, if the conversion succeeded, /// or MinValue if the conversion failed. /// The conversion fails if the s parameter is a null reference (Nothing in Visual Basic), /// or does not contain a valid string representation of a date and time. /// This parameter is passed uninitialized. /// /// true if the parameter was converted successfully; otherwise, false. /// /// The string is parsed using formatting information in the object. /// public static bool TryParse(string s, out DateTime result) { //------------------------------------------------------------ // Attempt to convert string representation //------------------------------------------------------------ bool wasConverted = false; result = DateTime.MinValue; if (!String.IsNullOrEmpty(s)) { DateTime parseResult; if (DateTime.TryParseExact(s, Rfc3339DateTime.Rfc3339DateTimePatterns, DateTimeFormatInfo.InvariantInfo, DateTimeStyles.AdjustToUniversal, out parseResult)) { result = DateTime.SpecifyKind(parseResult, DateTimeKind.Utc); wasConverted = true; } } return wasConverted; } #endregion } }
How do I parse and convert a DateTime to the RFC 3339 date-time format? How do I convert a DateTime structure to its equivalent RFC 3339 formatted string representation and/or parse this string representation back to a DateTime structure? The RFC-3339 date-time format is used in a number of specifications such as the Atom Syndication Format.
TITLE: How do I parse and convert a DateTime to the RFC 3339 date-time format? QUESTION: How do I convert a DateTime structure to its equivalent RFC 3339 formatted string representation and/or parse this string representation back to a DateTime structure? The RFC-3339 date-time format is used in a number of specifications such as the Atom Syndication Format. ANSWER: This is an implementation in C# of how to parse and convert a DateTime to and from its RFC-3339 representation. The only restriction it has is that the DateTime is in Coordinated Universal Time (UTC). using System; using System.Globalization; namespace DateTimeConsoleApplication { /// /// Provides methods for converting structures to and from the equivalent RFC 3339 string representation. /// public static class Rfc3339DateTime { //============================================================ // Private members //============================================================ #region Private Members /// /// Private member to hold array of formats that RFC 3339 date-time representations conform to. /// private static string[] formats = new string[0]; /// /// Private member to hold the DateTime format string for representing a DateTime in the RFC 3339 format. /// private const string format = "yyyy-MM-dd'T'HH:mm:ss.fffK"; #endregion //============================================================ // Public Properties //============================================================ #region Rfc3339DateTimeFormat /// /// Gets the custom format specifier that may be used to represent a in the RFC 3339 format. /// /// A DateTime format string that may be used to represent a in the RFC 3339 format. /// /// /// This method returns a string representation of a that /// is precise to the three most significant digits of the seconds fraction; that is, it represents /// the milliseconds in a date and time value. The is a valid /// date-time format string for use in the method. /// /// public static string Rfc3339DateTimeFormat { get { return format; } } #endregion #region Rfc3339DateTimePatterns /// /// Gets an array of the expected formats for RFC 3339 date-time string representations. /// /// /// An array of the expected formats for RFC 3339 date-time string representations /// that may used in the method. /// public static string[] Rfc3339DateTimePatterns { get { if (formats.Length > 0) { return formats; } else { formats = new string[11]; // Rfc3339DateTimePatterns formats[0] = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK"; formats[1] = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'ffffffK"; formats[2] = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffK"; formats[3] = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'ffffK"; formats[4] = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffK"; formats[5] = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'ffK"; formats[6] = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fK"; formats[7] = "yyyy'-'MM'-'dd'T'HH':'mm':'ssK"; // Fall back patterns formats[8] = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK"; // RoundtripDateTimePattern formats[9] = DateTimeFormatInfo.InvariantInfo.UniversalSortableDateTimePattern; formats[10] = DateTimeFormatInfo.InvariantInfo.SortableDateTimePattern; return formats; } } } #endregion //============================================================ // Public Methods //============================================================ #region Parse(string s) /// /// Converts the specified string representation of a date and time to its equivalent. /// /// A string containing a date and time to convert. /// A equivalent to the date and time contained in. /// /// The string is parsed using formatting information in the object. /// /// is a null reference (Nothing in Visual Basic). /// does not contain a valid RFC 3339 string representation of a date and time. public static DateTime Parse(string s) { //------------------------------------------------------------ // Validate parameter //------------------------------------------------------------ if(s == null) { throw new ArgumentNullException("s"); } DateTime result; if (Rfc3339DateTime.TryParse(s, out result)) { return result; } else { throw new FormatException(String.Format(null, "{0} is not a valid RFC 3339 string representation of a date and time.", s)); } } #endregion #region ToString(DateTime utcDateTime) /// /// Converts the value of the specified object to its equivalent string representation. /// /// The Coordinated Universal Time (UTC) to convert. /// A RFC 3339 string representation of the value of the. /// /// /// This method returns a string representation of the that /// is precise to the three most significant digits of the seconds fraction; that is, it represents /// the milliseconds in a date and time value. /// /// /// While it is possible to display higher precision fractions of a second component of a time value, /// that value may not be meaningful. The precision of date and time values depends on the resolution /// of the system clock. On Windows NT 3.5 and later, and Windows Vista operating systems, the clock's /// resolution is approximately 10-15 milliseconds. /// /// /// The specified object does not represent a Coordinated Universal Time (UTC) value. public static string ToString(DateTime utcDateTime) { if (utcDateTime.Kind!= DateTimeKind.Utc) { throw new ArgumentException("utcDateTime"); } return utcDateTime.ToString(Rfc3339DateTime.Rfc3339DateTimeFormat, DateTimeFormatInfo.InvariantInfo); } #endregion #region TryParse(string s, out DateTime result) /// /// Converts the specified string representation of a date and time to its equivalent. /// /// A string containing a date and time to convert. /// /// When this method returns, contains the value equivalent to the date and time /// contained in, if the conversion succeeded, /// or MinValue if the conversion failed. /// The conversion fails if the s parameter is a null reference (Nothing in Visual Basic), /// or does not contain a valid string representation of a date and time. /// This parameter is passed uninitialized. /// /// true if the parameter was converted successfully; otherwise, false. /// /// The string is parsed using formatting information in the object. /// public static bool TryParse(string s, out DateTime result) { //------------------------------------------------------------ // Attempt to convert string representation //------------------------------------------------------------ bool wasConverted = false; result = DateTime.MinValue; if (!String.IsNullOrEmpty(s)) { DateTime parseResult; if (DateTime.TryParseExact(s, Rfc3339DateTime.Rfc3339DateTimePatterns, DateTimeFormatInfo.InvariantInfo, DateTimeStyles.AdjustToUniversal, out parseResult)) { result = DateTime.SpecifyKind(parseResult, DateTimeKind.Utc); wasConverted = true; } } return wasConverted; } #endregion } }
[ ".net", "datetime", "rfc3339", "atom-feed" ]
57
22
57,113
8
0
2008-08-19T21:40:11.780000
2008-08-19T21:42:45.113000
17,020
17,048
What is the best way to partition terabyte drive in a linux development machine?
I have a new 1 TB drive coming in tomorrow. What is the best way to divide this space for a development workstation? The biggest problem I think I'm going to have is that some partitions (probably /usr) will become to small after a bit of use. Other partitions are probably to huge. The swap drive for example is currently 2GB (2x 1GB RAM), but it is almost never used (only once that I know of).
My standard strategy for normal "utility" boxes is to give them a swap partition twice the size of their RAM, a 1GB /boot partition and leave the rest as one vast partition. Whilst I see why some people want a separate /var, separate /home, etc., if I only have trusted users and I'm not running some production service, I don't think the reasons I've heard to date apply. Instead, I do my best to avoid any resizing, or any partition becoming too small - which is best achieved with one huge partition. As for the size of swap and /boot - if your machine has 4GB memory, you may not want to have double that in swap. It's nonetheless wise to at least have some. Even if you nonetheless have double, you're using a total of 9GB, for 0.9% of your new drive. /boot can be smaller than 1GB, this is just my standard "will not become full, ever" size.
What is the best way to partition terabyte drive in a linux development machine? I have a new 1 TB drive coming in tomorrow. What is the best way to divide this space for a development workstation? The biggest problem I think I'm going to have is that some partitions (probably /usr) will become to small after a bit of use. Other partitions are probably to huge. The swap drive for example is currently 2GB (2x 1GB RAM), but it is almost never used (only once that I know of).
TITLE: What is the best way to partition terabyte drive in a linux development machine? QUESTION: I have a new 1 TB drive coming in tomorrow. What is the best way to divide this space for a development workstation? The biggest problem I think I'm going to have is that some partitions (probably /usr) will become to small after a bit of use. Other partitions are probably to huge. The swap drive for example is currently 2GB (2x 1GB RAM), but it is almost never used (only once that I know of). ANSWER: My standard strategy for normal "utility" boxes is to give them a swap partition twice the size of their RAM, a 1GB /boot partition and leave the rest as one vast partition. Whilst I see why some people want a separate /var, separate /home, etc., if I only have trusted users and I'm not running some production service, I don't think the reasons I've heard to date apply. Instead, I do my best to avoid any resizing, or any partition becoming too small - which is best achieved with one huge partition. As for the size of swap and /boot - if your machine has 4GB memory, you may not want to have double that in swap. It's nonetheless wise to at least have some. Even if you nonetheless have double, you're using a total of 9GB, for 0.9% of your new drive. /boot can be smaller than 1GB, this is just my standard "will not become full, ever" size.
[ "linux", "storage", "disk-partitioning" ]
3
4
5,202
10
0
2008-08-19T21:42:30.667000
2008-08-19T21:58:12.990000
17,032
17,042
Should I *always* favour implictly typed local variables in C# 3.0?
Resharper certainly thinks so, and out of the box it will nag you to convert Dooberry dooberry = new Dooberry(); to var dooberry = new Dooberry(); Is that really considered the best style?
It's of course a matter of style, but I agree with Dare: C# 3.0 Implicit Type Declarations: To var or not to var?. I think using var instead of an explicit type makes your code less readable.In the following code: var result = GetUserID(); What is result? An int, a string, a GUID? Yes, it matters, and no, I shouldn't have to dig through the code to know. It's especially annoying in code samples. Jeff wrote a post on this, saying he favors var. But that guy's crazy! I'm seeing a pattern for stackoverflow success: dig up old CodingHorror posts and (Jeopardy style) phrase them in terms of a question.
Should I *always* favour implictly typed local variables in C# 3.0? Resharper certainly thinks so, and out of the box it will nag you to convert Dooberry dooberry = new Dooberry(); to var dooberry = new Dooberry(); Is that really considered the best style?
TITLE: Should I *always* favour implictly typed local variables in C# 3.0? QUESTION: Resharper certainly thinks so, and out of the box it will nag you to convert Dooberry dooberry = new Dooberry(); to var dooberry = new Dooberry(); Is that really considered the best style? ANSWER: It's of course a matter of style, but I agree with Dare: C# 3.0 Implicit Type Declarations: To var or not to var?. I think using var instead of an explicit type makes your code less readable.In the following code: var result = GetUserID(); What is result? An int, a string, a GUID? Yes, it matters, and no, I shouldn't have to dig through the code to know. It's especially annoying in code samples. Jeff wrote a post on this, saying he favors var. But that guy's crazy! I'm seeing a pattern for stackoverflow success: dig up old CodingHorror posts and (Jeopardy style) phrase them in terms of a question.
[ "c#", "styles", "resharper" ]
30
40
4,304
13
0
2008-08-19T21:49:07.347000
2008-08-19T21:53:38.443000
17,054
17,062
Sockets in Pascal
How do you use network sockets in Pascal? ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­
Here's an example taken from http://www.bastisoft.de/programmierung/pascal/pasinet.html program daytime; { Simple client program } uses sockets, inetaux, myerror; const RemotePort: Word = 13; var Sock: LongInt; sAddr: TInetSockAddr; sin, sout: Text; Line: String; begin if ParamCount = 0 then GenError('Supply IP address as parameter.'); with sAddr do begin Family:= af_inet; Port:= htons(RemotePort); Addr:= StrToAddr(ParamStr(1)); if Addr = 0 then GenError('Not a valid IP address.'); end; Sock:= Socket(af_inet, sock_stream, 0); if Sock = -1 then SockError('Socket: '); if not Connect(Sock, sAddr, sizeof(sAddr)) then SockError('Connect: '); Sock2Text(Sock, sin, sout); Reset(sin); Rewrite(sout); while not eof(sin) do begin Readln(sin, Line); Writeln(Line); end; Close(sin); Close(sout); Shutdown(Sock, 2); end.
Sockets in Pascal How do you use network sockets in Pascal? ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­
TITLE: Sockets in Pascal QUESTION: How do you use network sockets in Pascal? ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­ ANSWER: Here's an example taken from http://www.bastisoft.de/programmierung/pascal/pasinet.html program daytime; { Simple client program } uses sockets, inetaux, myerror; const RemotePort: Word = 13; var Sock: LongInt; sAddr: TInetSockAddr; sin, sout: Text; Line: String; begin if ParamCount = 0 then GenError('Supply IP address as parameter.'); with sAddr do begin Family:= af_inet; Port:= htons(RemotePort); Addr:= StrToAddr(ParamStr(1)); if Addr = 0 then GenError('Not a valid IP address.'); end; Sock:= Socket(af_inet, sock_stream, 0); if Sock = -1 then SockError('Socket: '); if not Connect(Sock, sAddr, sizeof(sAddr)) then SockError('Connect: '); Sock2Text(Sock, sin, sout); Reset(sin); Rewrite(sout); while not eof(sin) do begin Readln(sin, Line); Writeln(Line); end; Close(sin); Close(sout); Shutdown(Sock, 2); end.
[ "sockets", "pascal" ]
3
5
7,930
4
0
2008-08-19T22:02:21.360000
2008-08-19T22:09:15.207000
17,056
18,226
SQL Server Full Text Searching
I'm currently working on an application where we have a SQL-Server database and I need to get a full text search working that allows us to search people's names. Currently the user can enter a into a name field that searches 3 different varchar cols. First, Last, Middle names So say I have 3 rows with the following info. 1 - Phillip - J - Fry 2 - Amy - NULL - Wong 3 - Leo - NULL - Wong If the user enters a name such as 'Fry' it will return row 1. However if they enter Phillip Fry, or Fr, or Phil they get nothing.. and I don't understand why its doing this. If they search for Wong they get rows 2 and 3 if they search for Amy Wong they again get nothing. Currently the query is using CONTAINSTABLE but I have switched that with FREETEXTTABLE, CONTAINS, and FREETEXT without any noticeable differences in the results. The table methods are be preferred because they return the same results but with ranking. Here is the query..... @Name nvarchar(100),.... --""s added to prevent crash if searching on more then one word. DECLARE @SearchString varchar(100) SET @SearchString = '"'+@Name+'"' SELECT Per.Lastname, Per.Firstname, Per.MiddleName FROM Person as Per INNER JOIN CONTAINSTABLE(Person, (LastName, Firstname, MiddleName), @SearchString) AS KEYTBL ON Per.Person_ID = KEYTBL.[KEY] WHERE KEY_TBL.RANK > 2 ORDER BY KEYTBL.RANK DESC;.... Any Ideas...? Why this full text search is not working correctly?
Thanks for the responses guys I finally was able to get it to work. With part of both Biri, and Kibbee's answers. I needed to add * to the string and break it up on spaces in order to work. So in the end I got.... @Name nvarchar(100),.... --""s added to prevent crash if searching on more then one word. DECLARE @SearchString varchar(100) --Added this line SET @SearchString = REPLACE(@Name, ' ', '*" OR "*') SET @SearchString = '"*'+@SearchString+'*"' SELECT Per.Lastname, Per.Firstname, Per.MiddleName FROM Person as Per INNER JOIN CONTAINSTABLE(Person, (LastName, Firstname, MiddleName), @SearchString) AS KEYTBL ON Per.Person_ID = KEYTBL.[KEY] WHERE KEY_TBL.RANK > 2 ORDER BY KEYTBL.RANK DESC;.... There are more fields being searched upon I just simplified it for the question, sorry about that, I didn't think it would effect the answer. It actually searches a column that has a csv of nicknames and a notes column as well. Thanks for the help.
SQL Server Full Text Searching I'm currently working on an application where we have a SQL-Server database and I need to get a full text search working that allows us to search people's names. Currently the user can enter a into a name field that searches 3 different varchar cols. First, Last, Middle names So say I have 3 rows with the following info. 1 - Phillip - J - Fry 2 - Amy - NULL - Wong 3 - Leo - NULL - Wong If the user enters a name such as 'Fry' it will return row 1. However if they enter Phillip Fry, or Fr, or Phil they get nothing.. and I don't understand why its doing this. If they search for Wong they get rows 2 and 3 if they search for Amy Wong they again get nothing. Currently the query is using CONTAINSTABLE but I have switched that with FREETEXTTABLE, CONTAINS, and FREETEXT without any noticeable differences in the results. The table methods are be preferred because they return the same results but with ranking. Here is the query..... @Name nvarchar(100),.... --""s added to prevent crash if searching on more then one word. DECLARE @SearchString varchar(100) SET @SearchString = '"'+@Name+'"' SELECT Per.Lastname, Per.Firstname, Per.MiddleName FROM Person as Per INNER JOIN CONTAINSTABLE(Person, (LastName, Firstname, MiddleName), @SearchString) AS KEYTBL ON Per.Person_ID = KEYTBL.[KEY] WHERE KEY_TBL.RANK > 2 ORDER BY KEYTBL.RANK DESC;.... Any Ideas...? Why this full text search is not working correctly?
TITLE: SQL Server Full Text Searching QUESTION: I'm currently working on an application where we have a SQL-Server database and I need to get a full text search working that allows us to search people's names. Currently the user can enter a into a name field that searches 3 different varchar cols. First, Last, Middle names So say I have 3 rows with the following info. 1 - Phillip - J - Fry 2 - Amy - NULL - Wong 3 - Leo - NULL - Wong If the user enters a name such as 'Fry' it will return row 1. However if they enter Phillip Fry, or Fr, or Phil they get nothing.. and I don't understand why its doing this. If they search for Wong they get rows 2 and 3 if they search for Amy Wong they again get nothing. Currently the query is using CONTAINSTABLE but I have switched that with FREETEXTTABLE, CONTAINS, and FREETEXT without any noticeable differences in the results. The table methods are be preferred because they return the same results but with ranking. Here is the query..... @Name nvarchar(100),.... --""s added to prevent crash if searching on more then one word. DECLARE @SearchString varchar(100) SET @SearchString = '"'+@Name+'"' SELECT Per.Lastname, Per.Firstname, Per.MiddleName FROM Person as Per INNER JOIN CONTAINSTABLE(Person, (LastName, Firstname, MiddleName), @SearchString) AS KEYTBL ON Per.Person_ID = KEYTBL.[KEY] WHERE KEY_TBL.RANK > 2 ORDER BY KEYTBL.RANK DESC;.... Any Ideas...? Why this full text search is not working correctly? ANSWER: Thanks for the responses guys I finally was able to get it to work. With part of both Biri, and Kibbee's answers. I needed to add * to the string and break it up on spaces in order to work. So in the end I got.... @Name nvarchar(100),.... --""s added to prevent crash if searching on more then one word. DECLARE @SearchString varchar(100) --Added this line SET @SearchString = REPLACE(@Name, ' ', '*" OR "*') SET @SearchString = '"*'+@SearchString+'*"' SELECT Per.Lastname, Per.Firstname, Per.MiddleName FROM Person as Per INNER JOIN CONTAINSTABLE(Person, (LastName, Firstname, MiddleName), @SearchString) AS KEYTBL ON Per.Person_ID = KEYTBL.[KEY] WHERE KEY_TBL.RANK > 2 ORDER BY KEYTBL.RANK DESC;.... There are more fields being searched upon I just simplified it for the question, sorry about that, I didn't think it would effect the answer. It actually searches a column that has a csv of nicknames and a notes column as well. Thanks for the help.
[ "sql-server", "search", "full-text-search" ]
13
4
3,926
5
0
2008-08-19T22:04:13.627000
2008-08-20T15:28:21.450000
17,057
17,068
What is the best way to gzip and cache static images in Asp.net mvc
I'm trying to find the best way to speed up the delivery of the static images that compose the design of an mvc site. The images are not gzipped, nor cached in the server or on the client (with content expire). Options are: Find why images are not cached and gzipped direcly from IIS6 Write a specialized http handler Register a special route for static images and write a bynary actionresult method What could be the best solution in terms of performance?
Best solution is to let IIS do it. IIS6 Compression - most likely you need to specify file types to be compressed like.jpg,.png,.gif types, etc. Caching will come from making sure that the correct headers are being sent to the client from code, and i believe there is a setting you can set in IIS that enables it for static content, but i'm not sure on that one.
What is the best way to gzip and cache static images in Asp.net mvc I'm trying to find the best way to speed up the delivery of the static images that compose the design of an mvc site. The images are not gzipped, nor cached in the server or on the client (with content expire). Options are: Find why images are not cached and gzipped direcly from IIS6 Write a specialized http handler Register a special route for static images and write a bynary actionresult method What could be the best solution in terms of performance?
TITLE: What is the best way to gzip and cache static images in Asp.net mvc QUESTION: I'm trying to find the best way to speed up the delivery of the static images that compose the design of an mvc site. The images are not gzipped, nor cached in the server or on the client (with content expire). Options are: Find why images are not cached and gzipped direcly from IIS6 Write a specialized http handler Register a special route for static images and write a bynary actionresult method What could be the best solution in terms of performance? ANSWER: Best solution is to let IIS do it. IIS6 Compression - most likely you need to specify file types to be compressed like.jpg,.png,.gif types, etc. Caching will come from making sure that the correct headers are being sent to the client from code, and i believe there is a setting you can set in IIS that enables it for static content, but i'm not sure on that one.
[ "asp.net", "asp.net-mvc", ".net-2.0", "gzip" ]
4
3
2,313
3
0
2008-08-19T22:05:00.130000
2008-08-19T22:11:31.707000
17,106
28,121
How to generate sample XML documents from their DTD or XSD?
We are developing an application that involves a substantial amount of XML transformations. We do not have any proper input test data per se, only DTD or XSD files. We'd like to generate our test data ourselves from these files. Is there an easy/free way to do that? Edit There are apparently no free tools for this, and I agree that OxygenXML is one of the best tools for this.
I think Oxygen ( http://www.oxygenxml.com/ ) does it as well, but that's another commerical product. It's a nice one, though... I'd strongly recommend it for anyone doing a lot of XML work. It comes in a nice Eclipse plugin, too. I do believe there is a free, fully-featured 30 day trial.
How to generate sample XML documents from their DTD or XSD? We are developing an application that involves a substantial amount of XML transformations. We do not have any proper input test data per se, only DTD or XSD files. We'd like to generate our test data ourselves from these files. Is there an easy/free way to do that? Edit There are apparently no free tools for this, and I agree that OxygenXML is one of the best tools for this.
TITLE: How to generate sample XML documents from their DTD or XSD? QUESTION: We are developing an application that involves a substantial amount of XML transformations. We do not have any proper input test data per se, only DTD or XSD files. We'd like to generate our test data ourselves from these files. Is there an easy/free way to do that? Edit There are apparently no free tools for this, and I agree that OxygenXML is one of the best tools for this. ANSWER: I think Oxygen ( http://www.oxygenxml.com/ ) does it as well, but that's another commerical product. It's a nice one, though... I'd strongly recommend it for anyone doing a lot of XML work. It comes in a nice Eclipse plugin, too. I do believe there is a free, fully-featured 30 day trial.
[ "xml", "xsd", "dtd", "test-data" ]
205
31
276,254
19
0
2008-08-19T22:29:47.840000
2008-08-26T14:05:46.763000
17,108
17,120
Where to start with CruiseControl.NET
I'm setting up my team's source control + build/integration process from scratch. We were using VSS and a tool we created in-house to perform the build process. We decided to move on to a more modern environment. I have the SVN running, and I would like to set a continuous integration process with CruiseControl.NET. Is there a good step-by-step starter guide that will get me started with the best practices of this tool?
Before leveraging CruiseControl to it's fullest extent, you need to create an automated build script that can be run by msbuild or nant. After you get your project building in one step, then you can start integrating CruiseControl into the mix. Here are some resources to help get you started: CruiseControl.net Wiki - A very good resource. CruiseControl.net SourceControl Block - Shows how to use svn with CruiseControl.net with the sourcecontrol block Getting CruiseControl.net, MsBuild, and SVN setup - A resource stepping you through the steps to get everything meshing together.
Where to start with CruiseControl.NET I'm setting up my team's source control + build/integration process from scratch. We were using VSS and a tool we created in-house to perform the build process. We decided to move on to a more modern environment. I have the SVN running, and I would like to set a continuous integration process with CruiseControl.NET. Is there a good step-by-step starter guide that will get me started with the best practices of this tool?
TITLE: Where to start with CruiseControl.NET QUESTION: I'm setting up my team's source control + build/integration process from scratch. We were using VSS and a tool we created in-house to perform the build process. We decided to move on to a more modern environment. I have the SVN running, and I would like to set a continuous integration process with CruiseControl.NET. Is there a good step-by-step starter guide that will get me started with the best practices of this tool? ANSWER: Before leveraging CruiseControl to it's fullest extent, you need to create an automated build script that can be run by msbuild or nant. After you get your project building in one step, then you can start integrating CruiseControl into the mix. Here are some resources to help get you started: CruiseControl.net Wiki - A very good resource. CruiseControl.net SourceControl Block - Shows how to use svn with CruiseControl.net with the sourcecontrol block Getting CruiseControl.net, MsBuild, and SVN setup - A resource stepping you through the steps to get everything meshing together.
[ "continuous-integration", "cruisecontrol.net" ]
4
6
701
6
0
2008-08-19T22:31:40.443000
2008-08-19T22:40:00.187000
17,117
19,609
C++ std::tr2 for VS2005
Is Boost the only way for VS2005 users experience TR2? Also is there a idiot proof way of downloading only the TR2 related packages? I was looking at the boost installer provided by BoostPro Consulting. If I select the options for all the threading options with all the packages for MSVC8 it requires 1.1GB. While I am not short of space, it seems ridiculous that a library needs over a gigabyte of space and it takes BPC a long time to catch up with the current release. What packages do I need? I'm really only interested in those that comprise std::tr2 and can find that out by comparing those on offer to those in from the TR2 report and selecting those from the list but even then it isn't clear what is needed and the fact that it is a version behind annoys me. I know from previous encounters with Boost (1.33.1) that self compiling is a miserable experience: A lot of time wasted to get it started and then a hoard of errors passes across your screen faster than you can read, so what you are left with is an uneasy feeling that something is broken but you don't quite know what. I've never had these problems with any Apache library but that is another rant...
I believe you're actually referring to TR1, rather than TR2. The call for proposals for TR2 is open, but don't expect to see much movement until the new C++ standard is out. Also, although boost is a provider of an implementation of TR1, dinkumware and the GNU FSF are other providers - on VC2005 boost is probably the easiest way to access this functionality. The libraries from boost which are likely to be of most importance are reference smart pointer bind type traits array regular expressions The documentation for building boost has been gradually improving for the last few releases, the current getting started guide is quite detailed. smart pointer and bind, should work from header files, and IMO, these are the most useful elements of TR1.
C++ std::tr2 for VS2005 Is Boost the only way for VS2005 users experience TR2? Also is there a idiot proof way of downloading only the TR2 related packages? I was looking at the boost installer provided by BoostPro Consulting. If I select the options for all the threading options with all the packages for MSVC8 it requires 1.1GB. While I am not short of space, it seems ridiculous that a library needs over a gigabyte of space and it takes BPC a long time to catch up with the current release. What packages do I need? I'm really only interested in those that comprise std::tr2 and can find that out by comparing those on offer to those in from the TR2 report and selecting those from the list but even then it isn't clear what is needed and the fact that it is a version behind annoys me. I know from previous encounters with Boost (1.33.1) that self compiling is a miserable experience: A lot of time wasted to get it started and then a hoard of errors passes across your screen faster than you can read, so what you are left with is an uneasy feeling that something is broken but you don't quite know what. I've never had these problems with any Apache library but that is another rant...
TITLE: C++ std::tr2 for VS2005 QUESTION: Is Boost the only way for VS2005 users experience TR2? Also is there a idiot proof way of downloading only the TR2 related packages? I was looking at the boost installer provided by BoostPro Consulting. If I select the options for all the threading options with all the packages for MSVC8 it requires 1.1GB. While I am not short of space, it seems ridiculous that a library needs over a gigabyte of space and it takes BPC a long time to catch up with the current release. What packages do I need? I'm really only interested in those that comprise std::tr2 and can find that out by comparing those on offer to those in from the TR2 report and selecting those from the list but even then it isn't clear what is needed and the fact that it is a version behind annoys me. I know from previous encounters with Boost (1.33.1) that self compiling is a miserable experience: A lot of time wasted to get it started and then a hoard of errors passes across your screen faster than you can read, so what you are left with is an uneasy feeling that something is broken but you don't quite know what. I've never had these problems with any Apache library but that is another rant... ANSWER: I believe you're actually referring to TR1, rather than TR2. The call for proposals for TR2 is open, but don't expect to see much movement until the new C++ standard is out. Also, although boost is a provider of an implementation of TR1, dinkumware and the GNU FSF are other providers - on VC2005 boost is probably the easiest way to access this functionality. The libraries from boost which are likely to be of most importance are reference smart pointer bind type traits array regular expressions The documentation for building boost has been gradually improving for the last few releases, the current getting started guide is quite detailed. smart pointer and bind, should work from header files, and IMO, these are the most useful elements of TR1.
[ "c++", "boost", "visual-studio-2005", "c++-tr2" ]
6
4
1,607
4
0
2008-08-19T22:35:25.830000
2008-08-21T10:55:26.947000
17,125
1,692,705
What are real life applications of yield?
I know what yield does, and I've seen a few examples, but I can't think of real life applications, have you used it to solve some specific problem? (Ideally some problem that cannot be solved some other way)
I realise this is an old question (pre Jon Skeet?) but I have been considering this question myself just lately. Unfortunately the current answers here (in my opinion) don't mention the most obvious advantage of the yield statement. The biggest benefit of the yield statement is that it allows you to iterate over very large lists with much more efficient memory usage then using say a standard list. For example, let's say you have a database query that returns 1 million rows. You could retrieve all rows using a DataReader and store them in a List, therefore requiring list_size * row_size bytes of memory. Or you could use the yield statement to create an Iterator and only ever store one row in memory at a time. In effect this gives you the ability to provide a "streaming" capability over large sets of data. Moreover, in the code that uses the Iterator, you use a simple foreach loop and can decide to break out from the loop as required. If you do break early, you have not forced the retrieval of the entire set of data when you only needed the first 5 rows (for example). Regarding: Ideally some problem that cannot be solved some other way The yield statement does not give you anything you could not do using your own custom iterator implementation, but it saves you needing to write the often complex code needed. There are very few problems (if any) that can't solved more than one way. Here are a couple of more recent questions and answers that provide more detail: Yield keyword value added? Is yield useful outside of LINQ?
What are real life applications of yield? I know what yield does, and I've seen a few examples, but I can't think of real life applications, have you used it to solve some specific problem? (Ideally some problem that cannot be solved some other way)
TITLE: What are real life applications of yield? QUESTION: I know what yield does, and I've seen a few examples, but I can't think of real life applications, have you used it to solve some specific problem? (Ideally some problem that cannot be solved some other way) ANSWER: I realise this is an old question (pre Jon Skeet?) but I have been considering this question myself just lately. Unfortunately the current answers here (in my opinion) don't mention the most obvious advantage of the yield statement. The biggest benefit of the yield statement is that it allows you to iterate over very large lists with much more efficient memory usage then using say a standard list. For example, let's say you have a database query that returns 1 million rows. You could retrieve all rows using a DataReader and store them in a List, therefore requiring list_size * row_size bytes of memory. Or you could use the yield statement to create an Iterator and only ever store one row in memory at a time. In effect this gives you the ability to provide a "streaming" capability over large sets of data. Moreover, in the code that uses the Iterator, you use a simple foreach loop and can decide to break out from the loop as required. If you do break early, you have not forced the retrieval of the entire set of data when you only needed the first 5 rows (for example). Regarding: Ideally some problem that cannot be solved some other way The yield statement does not give you anything you could not do using your own custom iterator implementation, but it saves you needing to write the often complex code needed. There are very few problems (if any) that can't solved more than one way. Here are a couple of more recent questions and answers that provide more detail: Yield keyword value added? Is yield useful outside of LINQ?
[ "c#", ".net", "yield" ]
15
13
3,267
7
0
2008-08-19T22:45:19.300000
2009-11-07T11:05:37.280000
17,127
67,969
Can you link 68K code compiled with CodeWarrior for Palm OS with code compiled with PRC-Tools (GCC)?
I've got a Palm OS/Garnet 68K application that uses a third-party static library built with CodeWarrior. Can I rebuilt the application using PRC-Tools, the port of GCC for the Palm OS platform and still link with the third-party library?
(Expanding on Ben's original answer... not sure of the exact etiquette for that but I can't edit yet so I'll re-post) No, CodeWarrior uses a different object file format than PRC-Tools. Also, the compiler support libraries are different, so even if the code could be statically linked together, it may use symbols in a different way. However, if you can wrap the third-party static library into a Palm OS shared library using CodeWarrior, then you should be able to call it from PRC-Tools applications. The Palm OS shared library interface works across tools, but shared libraries have limited system support so you'll need to be sure the original code doesn't use global variables for this to work. For more information on shared libraries, see Shared libraries on the Palm Pilot.
Can you link 68K code compiled with CodeWarrior for Palm OS with code compiled with PRC-Tools (GCC)? I've got a Palm OS/Garnet 68K application that uses a third-party static library built with CodeWarrior. Can I rebuilt the application using PRC-Tools, the port of GCC for the Palm OS platform and still link with the third-party library?
TITLE: Can you link 68K code compiled with CodeWarrior for Palm OS with code compiled with PRC-Tools (GCC)? QUESTION: I've got a Palm OS/Garnet 68K application that uses a third-party static library built with CodeWarrior. Can I rebuilt the application using PRC-Tools, the port of GCC for the Palm OS platform and still link with the third-party library? ANSWER: (Expanding on Ben's original answer... not sure of the exact etiquette for that but I can't edit yet so I'll re-post) No, CodeWarrior uses a different object file format than PRC-Tools. Also, the compiler support libraries are different, so even if the code could be statically linked together, it may use symbols in a different way. However, if you can wrap the third-party static library into a Palm OS shared library using CodeWarrior, then you should be able to call it from PRC-Tools applications. The Palm OS shared library interface works across tools, but shared libraries have limited system support so you'll need to be sure the original code doesn't use global variables for this to work. For more information on shared libraries, see Shared libraries on the Palm Pilot.
[ "palm-os", "garnet-os", "codewarrior", "prc-tools" ]
3
4
464
2
0
2008-08-19T22:46:21.157000
2008-09-15T23:37:00.607000
17,170
17,295
When to use IList and when to use List
I know that IList is the interface and List is the concrete type but I still don't know when to use each one. What I'm doing now is if I don't need the Sort or FindAll methods I use the interface. Am I right? Is there a better way to decide when to use the interface or the concrete type?
There are two rules I follow: Accept the most basic type that will work Return the richest type your user will need So when writing a function or method that takes a collection, write it not to take a List, but an IList, an ICollection, or IEnumerable. The generic interfaces will still work even for heterogenous lists because System.Object can be a T too. Doing this will save you headache if you decide to use a Stack or some other data structure further down the road. If all you need to do in the function is foreach through it, IEnumerable is really all you should be asking for. On the other hand, when returning an object out of a function, you want to give the user the richest possible set of operations without them having to cast around. So in that case, if it's a List internally, return a copy as a List.
When to use IList and when to use List I know that IList is the interface and List is the concrete type but I still don't know when to use each one. What I'm doing now is if I don't need the Sort or FindAll methods I use the interface. Am I right? Is there a better way to decide when to use the interface or the concrete type?
TITLE: When to use IList and when to use List QUESTION: I know that IList is the interface and List is the concrete type but I still don't know when to use each one. What I'm doing now is if I don't need the Sort or FindAll methods I use the interface. Am I right? Is there a better way to decide when to use the interface or the concrete type? ANSWER: There are two rules I follow: Accept the most basic type that will work Return the richest type your user will need So when writing a function or method that takes a collection, write it not to take a List, but an IList, an ICollection, or IEnumerable. The generic interfaces will still work even for heterogenous lists because System.Object can be a T too. Doing this will save you headache if you decide to use a Stack or some other data structure further down the road. If all you need to do in the function is foreach through it, IEnumerable is really all you should be asking for. On the other hand, when returning an object out of a function, you want to give the user the richest possible set of operations without them having to cast around. So in that case, if it's a List internally, return a copy as a List.
[ "c#", ".net" ]
211
209
182,582
12
0
2008-08-19T23:09:54.720000
2008-08-20T01:33:16.293000
17,172
17,178
Implementing permissions in PHP
I've tried to do this several times with no luck. After reading this post, it made me interested in doing this again. So can anyone tell me why the following doesn't work?
Use the bitwise OR operator (|) to set bits, use the AND operator (&) to check bits. Your code should look like this: If you don't understand binary and exactly what the bitwise operators do, you should go learn it. You'll understand how to do this much better.
Implementing permissions in PHP I've tried to do this several times with no luck. After reading this post, it made me interested in doing this again. So can anyone tell me why the following doesn't work?
TITLE: Implementing permissions in PHP QUESTION: I've tried to do this several times with no luck. After reading this post, it made me interested in doing this again. So can anyone tell me why the following doesn't work? ANSWER: Use the bitwise OR operator (|) to set bits, use the AND operator (&) to check bits. Your code should look like this: If you don't understand binary and exactly what the bitwise operators do, you should go learn it. You'll understand how to do this much better.
[ "php", "permissions" ]
8
11
1,304
10
0
2008-08-19T23:11:49.613000
2008-08-19T23:17:43.110000
17,175
17,218
What's your top feature request for Silverlight?
I'll take away the obvious one here: mic and webcam support. Other than that, if you ran the Silverlight team, what would your highest priority be for Silverlight v.Next? Disclaimer: If we get some good responses, I'll pass them along to folks I know on the Silverlight team. UPDATE: The best place to report Silverlight feature requests now is the UserVoice site: http://silverlight.uservoice.com/
SQL Compact Edition running on the Silverlight CLR Support for Triggers Support for resource dictionaries Also, since you brought up Webcam I have to plug my Silverlight 2 Webcam Support POC. It's using Flash interop and allows you to capture PNG stills from Silverlight. I guess it's more a fun example of Silverlight, JavaScript and Flash interoperability than a really useful webcam solution. But you can do fun things with it. In my most recent blog post I use the webcam support to capture still pictures for a sliding puzzle game. http://jonas.follesoe.no/WebcamInSilverlight2NdashSlidingPuzzleGame.aspx
What's your top feature request for Silverlight? I'll take away the obvious one here: mic and webcam support. Other than that, if you ran the Silverlight team, what would your highest priority be for Silverlight v.Next? Disclaimer: If we get some good responses, I'll pass them along to folks I know on the Silverlight team. UPDATE: The best place to report Silverlight feature requests now is the UserVoice site: http://silverlight.uservoice.com/
TITLE: What's your top feature request for Silverlight? QUESTION: I'll take away the obvious one here: mic and webcam support. Other than that, if you ran the Silverlight team, what would your highest priority be for Silverlight v.Next? Disclaimer: If we get some good responses, I'll pass them along to folks I know on the Silverlight team. UPDATE: The best place to report Silverlight feature requests now is the UserVoice site: http://silverlight.uservoice.com/ ANSWER: SQL Compact Edition running on the Silverlight CLR Support for Triggers Support for resource dictionaries Also, since you brought up Webcam I have to plug my Silverlight 2 Webcam Support POC. It's using Flash interop and allows you to capture PNG stills from Silverlight. I guess it's more a fun example of Silverlight, JavaScript and Flash interoperability than a really useful webcam solution. But you can do fun things with it. In my most recent blog post I use the webcam support to capture still pictures for a sliding puzzle game. http://jonas.follesoe.no/WebcamInSilverlight2NdashSlidingPuzzleGame.aspx
[ ".net", "silverlight", "silverlight-3.0" ]
12
8
1,900
25
0
2008-08-19T23:16:20.723000
2008-08-19T23:41:34.503000
17,194
17,290
SQL query to compare product sales by month
I have a Monthly Status database view I need to build a report based on. The data in the view looks something like this: Category | Revenue | Yearh | Month Bikes 10 000 2008 1 Bikes 12 000 2008 2 Bikes 12 000 2008 3 Bikes 15 000 2008 1 Bikes 11 000 2007 2 Bikes 11 500 2007 3 Bikes 15 400 2007 4... And so forth The view has a product category, a revenue, a year and a month. I want to create a report comparing 2007 and 2008, showing 0 for the months with no sales. So the report should look something like this: Category | Month | Rev. This Year | Rev. Last Year Bikes 1 10 000 0 Bikes 2 12 000 11 000 Bikes 3 12 000 11 500 Bikes 4 0 15 400 The key thing to notice is how month 1 only has sales in 2008, and therefore is 0 for 2007. Also, month 4 only has no sales in 2008, hence the 0, while it has sales in 2007 and still show up. Also, the report is actually for financial year - so I would love to have empty columns with 0 in both if there was no sales in say month 5 for either 2007 or 2008. The query I got looks something like this: SELECT SP1.Program, SP1.Year, SP1.Month, SP1.TotalRevenue, IsNull(SP2.TotalRevenue, 0) AS LastYearTotalRevenue FROM PVMonthlyStatusReport AS SP1 LEFT OUTER JOIN PVMonthlyStatusReport AS SP2 ON SP1.Program = SP2.Program AND SP2.Year = SP1.Year - 1 AND SP1.Month = SP2.Month WHERE SP1.Program = 'Bikes' AND SP1.Category = @Category AND (SP1.Year >= @FinancialYear AND SP1.Year <= @FinancialYear + 1) AND ((SP1.Year = @FinancialYear AND SP1.Month > 6) OR (SP1.Year = @FinancialYear + 1 AND SP1.Month <= 6)) ORDER BY SP1.Year, SP1.Month The problem with this query is that it would not return the fourth row in my example data above, since we didn't have any sales in 2008, but we actually did in 2007. This is probably a common query/problem, but my SQL is rusty after doing front-end development for so long. Any help is greatly appreciated! Oh, btw, I'm using SQL 2005 for this query so if there are any helpful new features that might help me let me know.
The Case Statement is my best sql friend. You also need a table for time to generate your 0 rev in both months. Assumptions are based on the availability of following tables: sales: Category | Revenue | Yearh | Month and tm: Year | Month (populated with all dates required for reporting) Example 1 without empty rows: select Category,month,SUM(CASE WHEN YEAR = 2008 THEN Revenue ELSE 0 END) this_year,SUM(CASE WHEN YEAR = 2007 THEN Revenue ELSE 0 END) last_year from sales where year in (2008,2007) group by Category,month RETURNS: Category | Month | Rev. This Year | Rev. Last Year Bikes 1 10 000 0 Bikes 2 12 000 11 000 Bikes 3 12 000 11 500 Bikes 4 0 15 400 Example 2 with empty rows: I am going to use a sub query (but others may not) and will return an empty row for every product and year month combo. select fill.Category,fill.month,SUM(CASE WHEN YEAR = 2008 THEN Revenue ELSE 0 END) this_year,SUM(CASE WHEN YEAR = 2007 THEN Revenue ELSE 0 END) last_year from sales Right join (select distinct --try out left, right and cross joins to test results. product,year,month from sales --this ideally would be from a products table cross join tm where year in (2008,2007)) fill where fill.year in (2008,2007) group by fill.Category,fill.month RETURNS: Category | Month | Rev. This Year | Rev. Last Year Bikes 1 10 000 0 Bikes 2 12 000 11 000 Bikes 3 12 000 11 500 Bikes 4 0 15 400 Bikes 5 0 0 Bikes 6 0 0 Bikes 7 0 0 Bikes 8 0 0 Note that most reporting tools will do this crosstab or matrix functionality, and now that i think of it SQL Server 2005 has pivot syntax that will do this as well. Here are some additional resources. CASE https://web.archive.org/web/20210728081626/https://www.4guysfromrolla.com/webtech/102704-1.shtml SQL SERVER 2005 PIVOT http://msdn.microsoft.com/en-us/library/ms177410.aspx
SQL query to compare product sales by month I have a Monthly Status database view I need to build a report based on. The data in the view looks something like this: Category | Revenue | Yearh | Month Bikes 10 000 2008 1 Bikes 12 000 2008 2 Bikes 12 000 2008 3 Bikes 15 000 2008 1 Bikes 11 000 2007 2 Bikes 11 500 2007 3 Bikes 15 400 2007 4... And so forth The view has a product category, a revenue, a year and a month. I want to create a report comparing 2007 and 2008, showing 0 for the months with no sales. So the report should look something like this: Category | Month | Rev. This Year | Rev. Last Year Bikes 1 10 000 0 Bikes 2 12 000 11 000 Bikes 3 12 000 11 500 Bikes 4 0 15 400 The key thing to notice is how month 1 only has sales in 2008, and therefore is 0 for 2007. Also, month 4 only has no sales in 2008, hence the 0, while it has sales in 2007 and still show up. Also, the report is actually for financial year - so I would love to have empty columns with 0 in both if there was no sales in say month 5 for either 2007 or 2008. The query I got looks something like this: SELECT SP1.Program, SP1.Year, SP1.Month, SP1.TotalRevenue, IsNull(SP2.TotalRevenue, 0) AS LastYearTotalRevenue FROM PVMonthlyStatusReport AS SP1 LEFT OUTER JOIN PVMonthlyStatusReport AS SP2 ON SP1.Program = SP2.Program AND SP2.Year = SP1.Year - 1 AND SP1.Month = SP2.Month WHERE SP1.Program = 'Bikes' AND SP1.Category = @Category AND (SP1.Year >= @FinancialYear AND SP1.Year <= @FinancialYear + 1) AND ((SP1.Year = @FinancialYear AND SP1.Month > 6) OR (SP1.Year = @FinancialYear + 1 AND SP1.Month <= 6)) ORDER BY SP1.Year, SP1.Month The problem with this query is that it would not return the fourth row in my example data above, since we didn't have any sales in 2008, but we actually did in 2007. This is probably a common query/problem, but my SQL is rusty after doing front-end development for so long. Any help is greatly appreciated! Oh, btw, I'm using SQL 2005 for this query so if there are any helpful new features that might help me let me know.
TITLE: SQL query to compare product sales by month QUESTION: I have a Monthly Status database view I need to build a report based on. The data in the view looks something like this: Category | Revenue | Yearh | Month Bikes 10 000 2008 1 Bikes 12 000 2008 2 Bikes 12 000 2008 3 Bikes 15 000 2008 1 Bikes 11 000 2007 2 Bikes 11 500 2007 3 Bikes 15 400 2007 4... And so forth The view has a product category, a revenue, a year and a month. I want to create a report comparing 2007 and 2008, showing 0 for the months with no sales. So the report should look something like this: Category | Month | Rev. This Year | Rev. Last Year Bikes 1 10 000 0 Bikes 2 12 000 11 000 Bikes 3 12 000 11 500 Bikes 4 0 15 400 The key thing to notice is how month 1 only has sales in 2008, and therefore is 0 for 2007. Also, month 4 only has no sales in 2008, hence the 0, while it has sales in 2007 and still show up. Also, the report is actually for financial year - so I would love to have empty columns with 0 in both if there was no sales in say month 5 for either 2007 or 2008. The query I got looks something like this: SELECT SP1.Program, SP1.Year, SP1.Month, SP1.TotalRevenue, IsNull(SP2.TotalRevenue, 0) AS LastYearTotalRevenue FROM PVMonthlyStatusReport AS SP1 LEFT OUTER JOIN PVMonthlyStatusReport AS SP2 ON SP1.Program = SP2.Program AND SP2.Year = SP1.Year - 1 AND SP1.Month = SP2.Month WHERE SP1.Program = 'Bikes' AND SP1.Category = @Category AND (SP1.Year >= @FinancialYear AND SP1.Year <= @FinancialYear + 1) AND ((SP1.Year = @FinancialYear AND SP1.Month > 6) OR (SP1.Year = @FinancialYear + 1 AND SP1.Month <= 6)) ORDER BY SP1.Year, SP1.Month The problem with this query is that it would not return the fourth row in my example data above, since we didn't have any sales in 2008, but we actually did in 2007. This is probably a common query/problem, but my SQL is rusty after doing front-end development for so long. Any help is greatly appreciated! Oh, btw, I'm using SQL 2005 for this query so if there are any helpful new features that might help me let me know. ANSWER: The Case Statement is my best sql friend. You also need a table for time to generate your 0 rev in both months. Assumptions are based on the availability of following tables: sales: Category | Revenue | Yearh | Month and tm: Year | Month (populated with all dates required for reporting) Example 1 without empty rows: select Category,month,SUM(CASE WHEN YEAR = 2008 THEN Revenue ELSE 0 END) this_year,SUM(CASE WHEN YEAR = 2007 THEN Revenue ELSE 0 END) last_year from sales where year in (2008,2007) group by Category,month RETURNS: Category | Month | Rev. This Year | Rev. Last Year Bikes 1 10 000 0 Bikes 2 12 000 11 000 Bikes 3 12 000 11 500 Bikes 4 0 15 400 Example 2 with empty rows: I am going to use a sub query (but others may not) and will return an empty row for every product and year month combo. select fill.Category,fill.month,SUM(CASE WHEN YEAR = 2008 THEN Revenue ELSE 0 END) this_year,SUM(CASE WHEN YEAR = 2007 THEN Revenue ELSE 0 END) last_year from sales Right join (select distinct --try out left, right and cross joins to test results. product,year,month from sales --this ideally would be from a products table cross join tm where year in (2008,2007)) fill where fill.year in (2008,2007) group by fill.Category,fill.month RETURNS: Category | Month | Rev. This Year | Rev. Last Year Bikes 1 10 000 0 Bikes 2 12 000 11 000 Bikes 3 12 000 11 500 Bikes 4 0 15 400 Bikes 5 0 0 Bikes 6 0 0 Bikes 7 0 0 Bikes 8 0 0 Note that most reporting tools will do this crosstab or matrix functionality, and now that i think of it SQL Server 2005 has pivot syntax that will do this as well. Here are some additional resources. CASE https://web.archive.org/web/20210728081626/https://www.4guysfromrolla.com/webtech/102704-1.shtml SQL SERVER 2005 PIVOT http://msdn.microsoft.com/en-us/library/ms177410.aspx
[ "sql", "sql-server", "sql-server-2005", "reporting" ]
5
5
71,710
6
0
2008-08-19T23:24:47.460000
2008-08-20T01:28:08.567000
17,225
17,293
How can Perl's system() print the command that it's running?
In Perl, you can execute system commands using system() or `` (backticks). You can even capture the output of the command into a variable. However, this hides the program execution in the background so that the person executing your script can't see it. Normally this is useful but sometimes I want to see what is going on behind the scenes. How do you make it so the commands executed are printed to the terminal, and those programs' output printed to the terminal? This would be the.bat equivalent of "@echo on".
As I understand, system() will print the result of the command, but not assign it. Eg. [daniel@tux /]$ perl -e '$ls = system("ls"); print "Result: $ls\n"' bin dev home lost+found misc net proc sbin srv System tools var boot etc lib media mnt opt root selinux sys tmp usr Result: 0 Backticks will capture the output of the command and not print it: [daniel@tux /]$ perl -e '$ls = `ls`; print "Result: $ls\n"' Result: bin boot dev etc home lib etc... Update: If you want to print the name of the command being system() 'd as well, I think Rudd 's approach is good. Repeated here for consolidation: sub execute { my $cmd = shift; print "$cmd\n"; system($cmd); } my $cmd = $ARGV[0]; execute($cmd);
How can Perl's system() print the command that it's running? In Perl, you can execute system commands using system() or `` (backticks). You can even capture the output of the command into a variable. However, this hides the program execution in the background so that the person executing your script can't see it. Normally this is useful but sometimes I want to see what is going on behind the scenes. How do you make it so the commands executed are printed to the terminal, and those programs' output printed to the terminal? This would be the.bat equivalent of "@echo on".
TITLE: How can Perl's system() print the command that it's running? QUESTION: In Perl, you can execute system commands using system() or `` (backticks). You can even capture the output of the command into a variable. However, this hides the program execution in the background so that the person executing your script can't see it. Normally this is useful but sometimes I want to see what is going on behind the scenes. How do you make it so the commands executed are printed to the terminal, and those programs' output printed to the terminal? This would be the.bat equivalent of "@echo on". ANSWER: As I understand, system() will print the result of the command, but not assign it. Eg. [daniel@tux /]$ perl -e '$ls = system("ls"); print "Result: $ls\n"' bin dev home lost+found misc net proc sbin srv System tools var boot etc lib media mnt opt root selinux sys tmp usr Result: 0 Backticks will capture the output of the command and not print it: [daniel@tux /]$ perl -e '$ls = `ls`; print "Result: $ls\n"' Result: bin boot dev etc home lib etc... Update: If you want to print the name of the command being system() 'd as well, I think Rudd 's approach is good. Repeated here for consolidation: sub execute { my $cmd = shift; print "$cmd\n"; system($cmd); } my $cmd = $ARGV[0]; execute($cmd);
[ "perl", "system" ]
12
10
35,833
6
0
2008-08-19T23:47:00.947000
2008-08-20T01:30:36.597000
17,231
17,367
Why shouldn't I "bet the future of the company" on shell scripts?
I was looking at http://tldp.org/LDP/abs/html/why-shell.html and was struck by: When not to use shell scripts... Mission-critical applications upon which you are betting the future of the company Why not?
Using shell scripts is fine when you're using their strengths. My company has some class 5 soft switches and the call processing code and the provisioning interface is written in java. Everything else is written in KSH - DB dumps for backups, pruning, log file rotation, and all the automated reporting. I would argue that all those support functions, though not directly related to call-path, are mission critical. Especially the DB interaction. If something went wrong with the DB-interaction code and dumped the call routing tables it could put us out of business. But nothing ever does go wrong, because shell scripts are the perfect language for stuff like this. They're small, they're well understood, manipulating files is their strength, and they're stable. It's not like KSH09 is going to be a complete rewrite because someone thinks it should compile to byte code, so it's a stable interface. Frankly, the provisioning interface written in Java goes wonky fairly often and the shell scripts have never messed up that I can remember.
Why shouldn't I "bet the future of the company" on shell scripts? I was looking at http://tldp.org/LDP/abs/html/why-shell.html and was struck by: When not to use shell scripts... Mission-critical applications upon which you are betting the future of the company Why not?
TITLE: Why shouldn't I "bet the future of the company" on shell scripts? QUESTION: I was looking at http://tldp.org/LDP/abs/html/why-shell.html and was struck by: When not to use shell scripts... Mission-critical applications upon which you are betting the future of the company Why not? ANSWER: Using shell scripts is fine when you're using their strengths. My company has some class 5 soft switches and the call processing code and the provisioning interface is written in java. Everything else is written in KSH - DB dumps for backups, pruning, log file rotation, and all the automated reporting. I would argue that all those support functions, though not directly related to call-path, are mission critical. Especially the DB interaction. If something went wrong with the DB-interaction code and dumped the call routing tables it could put us out of business. But nothing ever does go wrong, because shell scripts are the perfect language for stuff like this. They're small, they're well understood, manipulating files is their strength, and they're stable. It's not like KSH09 is going to be a complete rewrite because someone thinks it should compile to byte code, so it's a stable interface. Frankly, the provisioning interface written in Java goes wonky fairly often and the shell scripts have never messed up that I can remember.
[ "bash", "shell", "ksh" ]
5
15
4,325
9
0
2008-08-19T23:50:47.040000
2008-08-20T03:12:01.313000
17,289
17,323
iFrame Best Practices
I have a large, hi-def JavaScript-intensive image banner for a site I'm designing. What is everyone's opinion of using iframes so that you incur the load time only once? Is there a CSS alternative to the iframe? Feel free to preview the site. It is very much a work in progress. ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­
I should also have mentioned that I would like the banner rotation to keep moving. When the visitor clicks on a link, the banner rotation starts over. It would be nice if the "animation" kept rotating, regardless of the page the user visits.Blockquote Well, in that case I would strongly recommend not doing that. The only real way of achieving that is to have the actual website content in the iframe, which means that you suddenly have lots of negative sides to the site: not being able to bookmark urls easily due to the address bar not changing; accessibility concerns; etc I think you'll find that most people won't care that it reloads again. Once a visitor lands on your website, they'll marvel at the wonderful banner immediately, and then will continue to ignore it while they browse your site - until an image they haven't seen appears and distracts them away from your content. Keep the rotation random enough, and with enough images, and people will stop to look at it from whatever page they're on.
iFrame Best Practices I have a large, hi-def JavaScript-intensive image banner for a site I'm designing. What is everyone's opinion of using iframes so that you incur the load time only once? Is there a CSS alternative to the iframe? Feel free to preview the site. It is very much a work in progress. ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­
TITLE: iFrame Best Practices QUESTION: I have a large, hi-def JavaScript-intensive image banner for a site I'm designing. What is everyone's opinion of using iframes so that you incur the load time only once? Is there a CSS alternative to the iframe? Feel free to preview the site. It is very much a work in progress. ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­ ANSWER: I should also have mentioned that I would like the banner rotation to keep moving. When the visitor clicks on a link, the banner rotation starts over. It would be nice if the "animation" kept rotating, regardless of the page the user visits.Blockquote Well, in that case I would strongly recommend not doing that. The only real way of achieving that is to have the actual website content in the iframe, which means that you suddenly have lots of negative sides to the site: not being able to bookmark urls easily due to the address bar not changing; accessibility concerns; etc I think you'll find that most people won't care that it reloads again. Once a visitor lands on your website, they'll marvel at the wonderful banner immediately, and then will continue to ignore it while they browse your site - until an image they haven't seen appears and distracts them away from your content. Keep the rotation random enough, and with enough images, and people will stop to look at it from whatever page they're on.
[ "html", "css", "iframe" ]
8
1
5,156
6
0
2008-08-20T01:28:00.907000
2008-08-20T02:00:59.470000
17,299
17,312
How can I sort an array of double pointers based on the values they point to?
I am trying to build a function in C/C++ to sort an array and replace each value with its "score" or rank. It takes in a double pointer array to an array of ints, and sorts the double pointers based on the dereferenced value of the integers. I have tried quite a few times to make it work, but can't get it down. Once again, it must sort the double pointers based on the values they point to. This is what I have: void SortArray( int ** pArray, int ArrayLength ) { int i, j, flag = 1; // set flag to 1 to begin initial pass int * temp; // holding variable orig with no * for(i = 1; (i <= ArrayLength) && flag; i++) { flag = 0; for (j = 0; j < (ArrayLength -1); j++) { if (*pArray[j+1] > *pArray[j]) // ascending order simply changes to < { temp = &pArray[j]; // swap elements pArray[j] = &pArray[j+1]; pArray[j+1] = &temp flag = 1; // indicates that a swap occurred. } } } }
You're close. You're referencing the address of the array items when you swap, which isn't necessary. The items in the array are pointers, and that's what needs to be swapped. See below: void SortArray( int ** pArray, int ArrayLength ) { int i, j, flag = 1; // set flag to 1 to begin initial pass int * temp; // holding variable orig with no * for(i = ArrayLength - 1; i > 0 && flag; i--) { flag = 0; for (j = 0; j < i; j++) { if (*pArray[j] > *pArray[j+1]) // ascending order simply changes to < { temp = pArray[j]; // swap elements pArray[j] = pArray[j+1]; pArray[j+1] = temp; flag = 1; // indicates that a swap occurred. } } } } Also, check out this lovely blog post on Bubble Sorting in case you're interested (sorry, shameless plug:)). Hope that helps you with your homework;) Edit: Note the subtle "optimisation" where you count back from the array length and only increment up until 'i' in the inner loop. This saves you from needlessly reparsing items that have already been sorted.
How can I sort an array of double pointers based on the values they point to? I am trying to build a function in C/C++ to sort an array and replace each value with its "score" or rank. It takes in a double pointer array to an array of ints, and sorts the double pointers based on the dereferenced value of the integers. I have tried quite a few times to make it work, but can't get it down. Once again, it must sort the double pointers based on the values they point to. This is what I have: void SortArray( int ** pArray, int ArrayLength ) { int i, j, flag = 1; // set flag to 1 to begin initial pass int * temp; // holding variable orig with no * for(i = 1; (i <= ArrayLength) && flag; i++) { flag = 0; for (j = 0; j < (ArrayLength -1); j++) { if (*pArray[j+1] > *pArray[j]) // ascending order simply changes to < { temp = &pArray[j]; // swap elements pArray[j] = &pArray[j+1]; pArray[j+1] = &temp flag = 1; // indicates that a swap occurred. } } } }
TITLE: How can I sort an array of double pointers based on the values they point to? QUESTION: I am trying to build a function in C/C++ to sort an array and replace each value with its "score" or rank. It takes in a double pointer array to an array of ints, and sorts the double pointers based on the dereferenced value of the integers. I have tried quite a few times to make it work, but can't get it down. Once again, it must sort the double pointers based on the values they point to. This is what I have: void SortArray( int ** pArray, int ArrayLength ) { int i, j, flag = 1; // set flag to 1 to begin initial pass int * temp; // holding variable orig with no * for(i = 1; (i <= ArrayLength) && flag; i++) { flag = 0; for (j = 0; j < (ArrayLength -1); j++) { if (*pArray[j+1] > *pArray[j]) // ascending order simply changes to < { temp = &pArray[j]; // swap elements pArray[j] = &pArray[j+1]; pArray[j+1] = &temp flag = 1; // indicates that a swap occurred. } } } } ANSWER: You're close. You're referencing the address of the array items when you swap, which isn't necessary. The items in the array are pointers, and that's what needs to be swapped. See below: void SortArray( int ** pArray, int ArrayLength ) { int i, j, flag = 1; // set flag to 1 to begin initial pass int * temp; // holding variable orig with no * for(i = ArrayLength - 1; i > 0 && flag; i--) { flag = 0; for (j = 0; j < i; j++) { if (*pArray[j] > *pArray[j+1]) // ascending order simply changes to < { temp = pArray[j]; // swap elements pArray[j] = pArray[j+1]; pArray[j+1] = temp; flag = 1; // indicates that a swap occurred. } } } } Also, check out this lovely blog post on Bubble Sorting in case you're interested (sorry, shameless plug:)). Hope that helps you with your homework;) Edit: Note the subtle "optimisation" where you count back from the array length and only increment up until 'i' in the inner loop. This saves you from needlessly reparsing items that have already been sorted.
[ "c++", "c", "arrays", "pointers", "reference" ]
1
5
4,401
5
0
2008-08-20T01:44:58.323000
2008-08-20T01:53:47.837000
17,320
17,345
What areas of specialization within programming would you recommend to a beginner
I am a student studying software development, and I feel programming, in general, is too broad of a subject to try to know everything. To be proficient, you have to decide which areas to focus your learning and understanding. Certain skill sets synergize with each other, like data-driven web development and SQL experience. However, all the win32 API experience in the world may not directly apply to linux development. This leads me to believe, as a beginning programmer, I should start deciding where I want to specialize after I have general understanding of the basic principles of software development. This is a multi-part question really: What are the common specializations within computer programming and software development? Which of these specializations have more long-term value, both as a foundation for other specializations and/or as marketable skills? Which skill sets complement each other? Are there any areas of specialization that hinder your ability of developing other areas of specialization.
Ben, Almost all seasoned programmers are still students in programming. You never stops learning anything when you are a developer. But if you are really starting off on your career then you should be least worried about the specialization thing. All APIs, frameworks and skills that you expect that gives you a long term existence in the field is not going to happen. Technology seems changing a lot and you should be versatile and flexible enough to learn anything. The knowledge you acquire on one platform/api/framework doesn't die off. You can apply the skills to the next greatest platform/api/framework. That being said you should just stop worrying about the future and concentrate on the basics. DataStructures, Algorithm Analysis and Design, Compiler Design, Operating system design are the bare minimum stuff you need. And further you should be willing to go back and read tho books in those field any time in your career. Thats all is required. Good luck. Sorry if I sounded like a big ass advisor; but thats what I think.:-)
What areas of specialization within programming would you recommend to a beginner I am a student studying software development, and I feel programming, in general, is too broad of a subject to try to know everything. To be proficient, you have to decide which areas to focus your learning and understanding. Certain skill sets synergize with each other, like data-driven web development and SQL experience. However, all the win32 API experience in the world may not directly apply to linux development. This leads me to believe, as a beginning programmer, I should start deciding where I want to specialize after I have general understanding of the basic principles of software development. This is a multi-part question really: What are the common specializations within computer programming and software development? Which of these specializations have more long-term value, both as a foundation for other specializations and/or as marketable skills? Which skill sets complement each other? Are there any areas of specialization that hinder your ability of developing other areas of specialization.
TITLE: What areas of specialization within programming would you recommend to a beginner QUESTION: I am a student studying software development, and I feel programming, in general, is too broad of a subject to try to know everything. To be proficient, you have to decide which areas to focus your learning and understanding. Certain skill sets synergize with each other, like data-driven web development and SQL experience. However, all the win32 API experience in the world may not directly apply to linux development. This leads me to believe, as a beginning programmer, I should start deciding where I want to specialize after I have general understanding of the basic principles of software development. This is a multi-part question really: What are the common specializations within computer programming and software development? Which of these specializations have more long-term value, both as a foundation for other specializations and/or as marketable skills? Which skill sets complement each other? Are there any areas of specialization that hinder your ability of developing other areas of specialization. ANSWER: Ben, Almost all seasoned programmers are still students in programming. You never stops learning anything when you are a developer. But if you are really starting off on your career then you should be least worried about the specialization thing. All APIs, frameworks and skills that you expect that gives you a long term existence in the field is not going to happen. Technology seems changing a lot and you should be versatile and flexible enough to learn anything. The knowledge you acquire on one platform/api/framework doesn't die off. You can apply the skills to the next greatest platform/api/framework. That being said you should just stop worrying about the future and concentrate on the basics. DataStructures, Algorithm Analysis and Design, Compiler Design, Operating system design are the bare minimum stuff you need. And further you should be willing to go back and read tho books in those field any time in your career. Thats all is required. Good luck. Sorry if I sounded like a big ass advisor; but thats what I think.:-)
[ "language-agnostic" ]
8
21
8,788
6
0
2008-08-20T01:59:08.710000
2008-08-20T02:20:32.873000
17,352
17,390
What are OpenGL extensions, and what are the benefits/tradeoffs of using them?
In relation to this question on Using OpenGL extensions, what's the purpose of these extension functions? Why would I want to use them? Further, are there any tradeoffs or gotchas associated with using them?
The OpenGL standard allows individual vendors to provide additional functionality through extensions as new technology is created. Extensions may introduce new functions and new constants, and may relax or remove restrictions on existing OpenGL functions. Each vendor has an alphabetic abbreviation that is used in naming their new functions and constants. For example, NVIDIA's abbreviation (NV) is used in defining their proprietary function glCombinerParameterfvNV() and their constant GL_NORMAL_MAP_NV. It may happen that more than one vendor agrees to implement the same extended functionality. In that case, the abbreviation EXT is used. It may further happen that the Architecture Review Board "blesses" the extension. It then becomes known as a standard extension, and the abbreviation ARB is used. The first ARB extension was GL_ARB_multitexture, introduced in version 1.2.1. Following the official extension promotion path, multitexturing is no longer an optionally implemented ARB extension, but has been a part of the OpenGL core API since version 1.3. Before using an extension a program must first determine its availability, and then obtain pointers to any new functions the extension defines. The mechanism for doing this is platform-specific and libraries such as GLEW and GLEE exist to simplify the process.
What are OpenGL extensions, and what are the benefits/tradeoffs of using them? In relation to this question on Using OpenGL extensions, what's the purpose of these extension functions? Why would I want to use them? Further, are there any tradeoffs or gotchas associated with using them?
TITLE: What are OpenGL extensions, and what are the benefits/tradeoffs of using them? QUESTION: In relation to this question on Using OpenGL extensions, what's the purpose of these extension functions? Why would I want to use them? Further, are there any tradeoffs or gotchas associated with using them? ANSWER: The OpenGL standard allows individual vendors to provide additional functionality through extensions as new technology is created. Extensions may introduce new functions and new constants, and may relax or remove restrictions on existing OpenGL functions. Each vendor has an alphabetic abbreviation that is used in naming their new functions and constants. For example, NVIDIA's abbreviation (NV) is used in defining their proprietary function glCombinerParameterfvNV() and their constant GL_NORMAL_MAP_NV. It may happen that more than one vendor agrees to implement the same extended functionality. In that case, the abbreviation EXT is used. It may further happen that the Architecture Review Board "blesses" the extension. It then becomes known as a standard extension, and the abbreviation ARB is used. The first ARB extension was GL_ARB_multitexture, introduced in version 1.2.1. Following the official extension promotion path, multitexturing is no longer an optionally implemented ARB extension, but has been a part of the OpenGL core API since version 1.3. Before using an extension a program must first determine its availability, and then obtain pointers to any new functions the extension defines. The mechanism for doing this is platform-specific and libraries such as GLEW and GLEE exist to simplify the process.
[ "opengl" ]
17
24
5,077
3
0
2008-08-20T02:40:40.953000
2008-08-20T03:43:32.627000
17,370
17,371
Using GLEW to use OpenGL extensions under Windows
I've been using OpenGL extensions on Windows the painful way. Is GLEW the easier way to go? How do I get started with it?
Yes, the OpenGL Extension Wrangler Library (GLEW) is a painless way to use OpenGL extensions on Windows. Here's how to get started on it: Identify the OpenGL extension and the extension APIs you wish to use. OpenGL extensions are listed in the OpenGL Extension Registry. Check if your graphic card supports the extensions you wish to use. Download and install the latest drivers and SDKs for your graphics card. Recent versions of NVIDIA OpenGL SDK ship with GLEW. If you're using this, then you don't need to do some of the following steps. Download GLEW and unzip it. Add the GLEW bin path to your Windows PATH environment variable. Alternatively, you can also place the glew32.dll in a directory where Windows picks up its DLLs. Add the GLEW include path to your compiler's include directory list. Add the GLEW lib path to your compiler's library directory list. Instruct your compiler to use glew32.lib during linking. If you're using Visual C++ compilers then one way to do this is by adding the following line to your code: #pragma comment(lib, "glew32.lib") Add a #include line to your code. Ensure that this is placed above the includes of other GL header files. (You may actually not need the GL header files includes if you include glew.h.) Initialize GLEW using glewInit() after you've initialized GLUT or GL. If it fails, then something is wrong with your setup. if (GLEW_OK!= glewInit()) { // GLEW failed! exit(1); } Check if the extension(s) you wish to use are now available through GLEW. You do this by checking a boolean variable named GLEW _your_extension_name which is exposed by GLEW. Example: if (!GLEW_EXT_framebuffer_object) { exit(1); } That's it! You can now use the OpenGL extension calls in your code just as if they existed naturally for Windows.
Using GLEW to use OpenGL extensions under Windows I've been using OpenGL extensions on Windows the painful way. Is GLEW the easier way to go? How do I get started with it?
TITLE: Using GLEW to use OpenGL extensions under Windows QUESTION: I've been using OpenGL extensions on Windows the painful way. Is GLEW the easier way to go? How do I get started with it? ANSWER: Yes, the OpenGL Extension Wrangler Library (GLEW) is a painless way to use OpenGL extensions on Windows. Here's how to get started on it: Identify the OpenGL extension and the extension APIs you wish to use. OpenGL extensions are listed in the OpenGL Extension Registry. Check if your graphic card supports the extensions you wish to use. Download and install the latest drivers and SDKs for your graphics card. Recent versions of NVIDIA OpenGL SDK ship with GLEW. If you're using this, then you don't need to do some of the following steps. Download GLEW and unzip it. Add the GLEW bin path to your Windows PATH environment variable. Alternatively, you can also place the glew32.dll in a directory where Windows picks up its DLLs. Add the GLEW include path to your compiler's include directory list. Add the GLEW lib path to your compiler's library directory list. Instruct your compiler to use glew32.lib during linking. If you're using Visual C++ compilers then one way to do this is by adding the following line to your code: #pragma comment(lib, "glew32.lib") Add a #include line to your code. Ensure that this is placed above the includes of other GL header files. (You may actually not need the GL header files includes if you include glew.h.) Initialize GLEW using glewInit() after you've initialized GLUT or GL. If it fails, then something is wrong with your setup. if (GLEW_OK!= glewInit()) { // GLEW failed! exit(1); } Check if the extension(s) you wish to use are now available through GLEW. You do this by checking a boolean variable named GLEW _your_extension_name which is exposed by GLEW. Example: if (!GLEW_EXT_framebuffer_object) { exit(1); } That's it! You can now use the OpenGL extension calls in your code just as if they existed naturally for Windows.
[ "opengl", "glew" ]
24
40
46,425
3
0
2008-08-20T03:19:34.400000
2008-08-20T03:19:50.827000
17,373
27,791
How do I open the default mail program with a Subject and Body in a cross-platform way?
How do I open the default mail program with a Subject and Body in a cross-platform way? Unfortunately, this is for a a client app written in Java, not a website. I would like this to work in a cross-platform way (which means Windows and Mac, sorry Linux). I am happy to execute a VBScript in Windows, or AppleScript in OS X. But I have no idea what those scripts should contain. I would love to execute the user's default program vs. just searching for Outlook or whatever. In OS X, I have tried executing the command: open mailto:?subject=MySubject&body=TheBody URL escaping is needed to replace spaces with %20. Updated On Windows, you have to play all sorts of games to get start to run correctly. Here is the proper Java incantation: class Win32 extends OS { public void email(String subject, String body) throws Exception { String cmd = "cmd.exe /c start \"\" \"" + formatMailto(subject, body) + "\""; Runtime.getRuntime().exec(cmd); } }
In Java 1.6 you have a stardard way to open the default mailer of the platform: the Desktop.mail(URI) method.The URI can be used to set all the fields of the mail (sender, recipients, body, subject). You can check a full example of desktop integration in Java 1.6 on Using the Desktop API in Java SE 6
How do I open the default mail program with a Subject and Body in a cross-platform way? How do I open the default mail program with a Subject and Body in a cross-platform way? Unfortunately, this is for a a client app written in Java, not a website. I would like this to work in a cross-platform way (which means Windows and Mac, sorry Linux). I am happy to execute a VBScript in Windows, or AppleScript in OS X. But I have no idea what those scripts should contain. I would love to execute the user's default program vs. just searching for Outlook or whatever. In OS X, I have tried executing the command: open mailto:?subject=MySubject&body=TheBody URL escaping is needed to replace spaces with %20. Updated On Windows, you have to play all sorts of games to get start to run correctly. Here is the proper Java incantation: class Win32 extends OS { public void email(String subject, String body) throws Exception { String cmd = "cmd.exe /c start \"\" \"" + formatMailto(subject, body) + "\""; Runtime.getRuntime().exec(cmd); } }
TITLE: How do I open the default mail program with a Subject and Body in a cross-platform way? QUESTION: How do I open the default mail program with a Subject and Body in a cross-platform way? Unfortunately, this is for a a client app written in Java, not a website. I would like this to work in a cross-platform way (which means Windows and Mac, sorry Linux). I am happy to execute a VBScript in Windows, or AppleScript in OS X. But I have no idea what those scripts should contain. I would love to execute the user's default program vs. just searching for Outlook or whatever. In OS X, I have tried executing the command: open mailto:?subject=MySubject&body=TheBody URL escaping is needed to replace spaces with %20. Updated On Windows, you have to play all sorts of games to get start to run correctly. Here is the proper Java incantation: class Win32 extends OS { public void email(String subject, String body) throws Exception { String cmd = "cmd.exe /c start \"\" \"" + formatMailto(subject, body) + "\""; Runtime.getRuntime().exec(cmd); } } ANSWER: In Java 1.6 you have a stardard way to open the default mailer of the platform: the Desktop.mail(URI) method.The URI can be used to set all the fields of the mail (sender, recipients, body, subject). You can check a full example of desktop integration in Java 1.6 on Using the Desktop API in Java SE 6
[ "java", "windows", "macos", "email" ]
13
10
18,952
9
0
2008-08-20T03:20:02.090000
2008-08-26T11:38:21.250000
17,376
17,414
How would you implement FORM based authentication without a backing database?
I have a PHP script that runs as a CGI program and the HTTP Authenticate header gets eaten and spit out. So I would like to implement some kind of FORM based authentication. As an added constraint, there is no database so no session data can be stored. I am very open to having a master username and password. I just need to protect the application from an intruder who doesn't know these credentials. So how would you implement this? Cookies? I could present the form and if it validates, I can send back a cookie that is a hash of the IP address come secret code. Then I can prevent pages from rendering unless the thing decrypts correctly. But I have no idea how to implement that in PHP.
A few ways you could do this. htaccess -- have your webserver handle securing the pages in question (not exactly cgi form based though). Use cookies and some sort of hashing algorithm (md5 is good enough) to store the passwords in a flat file where each line in the file is username:passwordhash. Make sure to salt your hashes for extra security vs rainbow tables. (This method is a bit naive... be very careful with security if you go this route) use something like a sqlite database just to handle authentication. Sqlite is compact and simple enough that it may still meet your needs even if you don't want a big db backend. Theoretically, you could also store session data in a flat file, even if you can't have a database.
How would you implement FORM based authentication without a backing database? I have a PHP script that runs as a CGI program and the HTTP Authenticate header gets eaten and spit out. So I would like to implement some kind of FORM based authentication. As an added constraint, there is no database so no session data can be stored. I am very open to having a master username and password. I just need to protect the application from an intruder who doesn't know these credentials. So how would you implement this? Cookies? I could present the form and if it validates, I can send back a cookie that is a hash of the IP address come secret code. Then I can prevent pages from rendering unless the thing decrypts correctly. But I have no idea how to implement that in PHP.
TITLE: How would you implement FORM based authentication without a backing database? QUESTION: I have a PHP script that runs as a CGI program and the HTTP Authenticate header gets eaten and spit out. So I would like to implement some kind of FORM based authentication. As an added constraint, there is no database so no session data can be stored. I am very open to having a master username and password. I just need to protect the application from an intruder who doesn't know these credentials. So how would you implement this? Cookies? I could present the form and if it validates, I can send back a cookie that is a hash of the IP address come secret code. Then I can prevent pages from rendering unless the thing decrypts correctly. But I have no idea how to implement that in PHP. ANSWER: A few ways you could do this. htaccess -- have your webserver handle securing the pages in question (not exactly cgi form based though). Use cookies and some sort of hashing algorithm (md5 is good enough) to store the passwords in a flat file where each line in the file is username:passwordhash. Make sure to salt your hashes for extra security vs rainbow tables. (This method is a bit naive... be very careful with security if you go this route) use something like a sqlite database just to handle authentication. Sqlite is compact and simple enough that it may still meet your needs even if you don't want a big db backend. Theoretically, you could also store session data in a flat file, even if you can't have a database.
[ "php", "http", "authentication", "cookies", "cgi" ]
6
5
3,557
4
0
2008-08-20T03:27:08.343000
2008-08-20T04:37:35.243000
17,387
222,016
Privatizing a BlogEngine.Net Installation
I have a blogengine.net install that requires privatization. I'm doing research work at the moment, but I have to keep my blog/journal private until certain conditions are met. How can I privatize my blogEngine.net install so that readers must log in to read my posts?
I use this extension. Just save the file as RequireLogin.cs in your App_Code\Extensions folder and make sure the extension is activated. using System; using System.Data; using System.Configuration; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using BlogEngine.Core; using BlogEngine.Core.Web.Controls; using System.Collections.Generic; /// /// Summary description for PostSecurity /// [Extension("Checks to see if a user can see this blog post.", "1.0", " LavaBlast.com ")] public class RequireLogin { static protected ExtensionSettings settings = null; public RequireLogin() { Post.Serving += new EventHandler (Post_Serving); ExtensionSettings s = new ExtensionSettings("RequireLogin"); // describe specific rules for entering parameters s.Help = "Checks to see if the user has any of those roles before displaying the post. "; s.Help += "You can associate a role with a specific category. "; s.Help += "All posts having this category will require that the user have the role. "; s.Help += "A parameter with only a role without a category will enable to filter all posts to this role. "; ExtensionManager.ImportSettings(s); settings = ExtensionManager.GetSettings("PostSecurity"); } protected void Post_Serving(object sender, ServingEventArgs e) { MembershipUser user = Membership.GetUser(); if(HttpContext.Current.Request.RawUrl.Contains("syndication.axd")) { return; } if (user == null) { HttpContext.Current.Response.Redirect("~/Login.aspx"); } } }
Privatizing a BlogEngine.Net Installation I have a blogengine.net install that requires privatization. I'm doing research work at the moment, but I have to keep my blog/journal private until certain conditions are met. How can I privatize my blogEngine.net install so that readers must log in to read my posts?
TITLE: Privatizing a BlogEngine.Net Installation QUESTION: I have a blogengine.net install that requires privatization. I'm doing research work at the moment, but I have to keep my blog/journal private until certain conditions are met. How can I privatize my blogEngine.net install so that readers must log in to read my posts? ANSWER: I use this extension. Just save the file as RequireLogin.cs in your App_Code\Extensions folder and make sure the extension is activated. using System; using System.Data; using System.Configuration; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using BlogEngine.Core; using BlogEngine.Core.Web.Controls; using System.Collections.Generic; /// /// Summary description for PostSecurity /// [Extension("Checks to see if a user can see this blog post.", "1.0", " LavaBlast.com ")] public class RequireLogin { static protected ExtensionSettings settings = null; public RequireLogin() { Post.Serving += new EventHandler (Post_Serving); ExtensionSettings s = new ExtensionSettings("RequireLogin"); // describe specific rules for entering parameters s.Help = "Checks to see if the user has any of those roles before displaying the post. "; s.Help += "You can associate a role with a specific category. "; s.Help += "All posts having this category will require that the user have the role. "; s.Help += "A parameter with only a role without a category will enable to filter all posts to this role. "; ExtensionManager.ImportSettings(s); settings = ExtensionManager.GetSettings("PostSecurity"); } protected void Post_Serving(object sender, ServingEventArgs e) { MembershipUser user = Membership.GetUser(); if(HttpContext.Current.Request.RawUrl.Contains("syndication.axd")) { return; } if (user == null) { HttpContext.Current.Response.Redirect("~/Login.aspx"); } } }
[ "c#", ".net", "asp.net", "blogs" ]
4
1
1,384
5
0
2008-08-20T03:39:30.857000
2008-10-21T14:10:39.260000
17,434
17,443
When should you use 'friend' in C++?
I have been reading through the C++ FAQ and was curious about the friend declaration. I personally have never used it, however I am interested in exploring the language. What is a good example of using friend? Reading the FAQ a bit longer I like the idea of the << >> operator overloading and adding as a friend of those classes. However I am not sure how this doesn't break encapsulation. When can these exceptions stay within the strictness that is OOP?
Firstly (IMO) don't listen to people who say friend is not useful. It IS useful. In many situations you will have objects with data or functionality that are not intended to be publicly available. This is particularly true of large codebases with many authors who may only be superficially familiar with different areas. There ARE alternatives to the friend specifier, but often they are cumbersome (cpp-level concrete classes/masked typedefs) or not foolproof (comments or function name conventions). Onto the answer; The friend specifier allows the designated class access to protected data or functionality within the class making the friend statement. For example in the below code anyone may ask a child for their name, but only the mother and the child may change the name. You can take this simple example further by considering a more complex class such as a Window. Quite likely a Window will have many function/data elements that should not be publicly accessible, but ARE needed by a related class such as a WindowManager. class Child { //Mother class members can access the private parts of class Child. friend class Mother; public: string name( void ); protected: void setName( string newName ); };
When should you use 'friend' in C++? I have been reading through the C++ FAQ and was curious about the friend declaration. I personally have never used it, however I am interested in exploring the language. What is a good example of using friend? Reading the FAQ a bit longer I like the idea of the << >> operator overloading and adding as a friend of those classes. However I am not sure how this doesn't break encapsulation. When can these exceptions stay within the strictness that is OOP?
TITLE: When should you use 'friend' in C++? QUESTION: I have been reading through the C++ FAQ and was curious about the friend declaration. I personally have never used it, however I am interested in exploring the language. What is a good example of using friend? Reading the FAQ a bit longer I like the idea of the << >> operator overloading and adding as a friend of those classes. However I am not sure how this doesn't break encapsulation. When can these exceptions stay within the strictness that is OOP? ANSWER: Firstly (IMO) don't listen to people who say friend is not useful. It IS useful. In many situations you will have objects with data or functionality that are not intended to be publicly available. This is particularly true of large codebases with many authors who may only be superficially familiar with different areas. There ARE alternatives to the friend specifier, but often they are cumbersome (cpp-level concrete classes/masked typedefs) or not foolproof (comments or function name conventions). Onto the answer; The friend specifier allows the designated class access to protected data or functionality within the class making the friend statement. For example in the below code anyone may ask a child for their name, but only the mother and the child may change the name. You can take this simple example further by considering a more complex class such as a Window. Quite likely a Window will have many function/data elements that should not be publicly accessible, but ARE needed by a related class such as a WindowManager. class Child { //Mother class members can access the private parts of class Child. friend class Mother; public: string name( void ); protected: void setName( string newName ); };
[ "c++", "oop", "encapsulation", "friend" ]
399
372
193,185
31
0
2008-08-20T05:29:32.793000
2008-08-20T05:48:22.717000
17,469
17,589
IE6 - can't load a normal JPG
Try loading this normal.jpg file in Internet Explorer 6.0. I get an error saying the picture won't load. Try it in any other browser and it works fine. What's wrong? The.jpg file is just a normal picture sitting on the web server. I can even create a simple web page: blah and use right click + save target as with IE6 to save it to my desktop, and it's a valid JPG file. However, it won't load in the browser! Why?! I even tried checking the header response and MIME type and it looks fine: andy@debian:~$ telnet www.zodiacwheels.com 80 Trying 72.167.174.247... Connected to zodiacwheels.com. Escape character is '^]'. HEAD /images/wheels/blackout_thumb.jpg HTTP/1.1 Host: www.zodiacwheels.com HTTP/1.1 200 OK Date: Wed, 20 Aug 2008 06:19:04 GMT Server: Apache Last-Modified: Wed, 20 Aug 2008 00:29:36 GMT ETag: "1387402-914ac-48ab6570" Accept-Ranges: bytes Content-Length: 595116 Content-Type: image/jpeg The site needs to be able to work with IE6, how come it won't load a simple.jpg file?
The JPG you uploaded is in CMYK, IE and Firefox versions before 3 can't read these. Open it using Photoshop (or anything similar, I'm sure GIMP would work too) and resave it in RGB. edit: Further Googling makes me suspect that CMYK isn't really a part of the jpeg standard, but can be shoehorned in there. That's why some software does not consider the file valid. It does however open just fine in Photoshop CS3, and shows a cmyk colorspace.
IE6 - can't load a normal JPG Try loading this normal.jpg file in Internet Explorer 6.0. I get an error saying the picture won't load. Try it in any other browser and it works fine. What's wrong? The.jpg file is just a normal picture sitting on the web server. I can even create a simple web page: blah and use right click + save target as with IE6 to save it to my desktop, and it's a valid JPG file. However, it won't load in the browser! Why?! I even tried checking the header response and MIME type and it looks fine: andy@debian:~$ telnet www.zodiacwheels.com 80 Trying 72.167.174.247... Connected to zodiacwheels.com. Escape character is '^]'. HEAD /images/wheels/blackout_thumb.jpg HTTP/1.1 Host: www.zodiacwheels.com HTTP/1.1 200 OK Date: Wed, 20 Aug 2008 06:19:04 GMT Server: Apache Last-Modified: Wed, 20 Aug 2008 00:29:36 GMT ETag: "1387402-914ac-48ab6570" Accept-Ranges: bytes Content-Length: 595116 Content-Type: image/jpeg The site needs to be able to work with IE6, how come it won't load a simple.jpg file?
TITLE: IE6 - can't load a normal JPG QUESTION: Try loading this normal.jpg file in Internet Explorer 6.0. I get an error saying the picture won't load. Try it in any other browser and it works fine. What's wrong? The.jpg file is just a normal picture sitting on the web server. I can even create a simple web page: blah and use right click + save target as with IE6 to save it to my desktop, and it's a valid JPG file. However, it won't load in the browser! Why?! I even tried checking the header response and MIME type and it looks fine: andy@debian:~$ telnet www.zodiacwheels.com 80 Trying 72.167.174.247... Connected to zodiacwheels.com. Escape character is '^]'. HEAD /images/wheels/blackout_thumb.jpg HTTP/1.1 Host: www.zodiacwheels.com HTTP/1.1 200 OK Date: Wed, 20 Aug 2008 06:19:04 GMT Server: Apache Last-Modified: Wed, 20 Aug 2008 00:29:36 GMT ETag: "1387402-914ac-48ab6570" Accept-Ranges: bytes Content-Length: 595116 Content-Type: image/jpeg The site needs to be able to work with IE6, how come it won't load a simple.jpg file? ANSWER: The JPG you uploaded is in CMYK, IE and Firefox versions before 3 can't read these. Open it using Photoshop (or anything similar, I'm sure GIMP would work too) and resave it in RGB. edit: Further Googling makes me suspect that CMYK isn't really a part of the jpeg standard, but can be shoehorned in there. That's why some software does not consider the file valid. It does however open just fine in Photoshop CS3, and shows a cmyk colorspace.
[ "internet-explorer", "image", "rgb", "jpeg", "cmyk" ]
10
29
6,559
6
0
2008-08-20T06:34:31.640000
2008-08-20T08:24:28.270000
17,483
17,486
Is there a way to prevent a method from being overridden in subclasses?
Is anyone aware of a language feature or technique in C++ to prevent a child class from over riding a particular method in the parent class? class Base { public: bool someGuaranteedResult() { return true; } }; class Child: public Base { public: bool someGuaranteedResult() { return false; /* Haha I broke things! */ } }; Even though it's not virtual, this is still allowed (at least in the Metrowerks compiler I'm using), all you get is a compile time warning about hiding non-virtual inherited function X.
A couple of ideas: Make your function private. Do not make your function virtual. This doesn't actually prevent the function from being shadowed by another definition though. Other than that, I'm not aware of a language feature that will lock away your function in such a way which prevents it from being overloaded and still able to be invoked through a pointer/reference to the child class. Good luck!
Is there a way to prevent a method from being overridden in subclasses? Is anyone aware of a language feature or technique in C++ to prevent a child class from over riding a particular method in the parent class? class Base { public: bool someGuaranteedResult() { return true; } }; class Child: public Base { public: bool someGuaranteedResult() { return false; /* Haha I broke things! */ } }; Even though it's not virtual, this is still allowed (at least in the Metrowerks compiler I'm using), all you get is a compile time warning about hiding non-virtual inherited function X.
TITLE: Is there a way to prevent a method from being overridden in subclasses? QUESTION: Is anyone aware of a language feature or technique in C++ to prevent a child class from over riding a particular method in the parent class? class Base { public: bool someGuaranteedResult() { return true; } }; class Child: public Base { public: bool someGuaranteedResult() { return false; /* Haha I broke things! */ } }; Even though it's not virtual, this is still allowed (at least in the Metrowerks compiler I'm using), all you get is a compile time warning about hiding non-virtual inherited function X. ANSWER: A couple of ideas: Make your function private. Do not make your function virtual. This doesn't actually prevent the function from being shadowed by another definition though. Other than that, I'm not aware of a language feature that will lock away your function in such a way which prevents it from being overloaded and still able to be invoked through a pointer/reference to the child class. Good luck!
[ "c++", "overriding", "metrowerks" ]
41
15
23,307
14
0
2008-08-20T06:50:32.910000
2008-08-20T06:53:40.533000
17,500
158,065
Why are DispatcherObject.CheckAccess() and VerifyAccess() hidden from Intellisense?
The System.Windows.Threading.DispatcherObject class (which DependencyObject is based on) contains a useful function, called CheckAccess(), that determines whether or not the code is running on the UI thread. When I wanted to use it yesterday, I was puzzled to find out that Intellisense didn't show the function (nor VerifyAccess(), which throws an exception when not on the UI thread), even though the MSDN library lists it. I decided to investigate the class using Reflector. It seems that the function in question has an EditorBrowsable(EditorBrowsableState.Never) attribute attached to it. The Dispatcher class, which is used by DispatcherObject, has the same attribute attached to CheckAccess() and VerifyAccess(): public abstract class DispatcherObject { //... [EditorBrowsable(EditorBrowsableState.Never)] public bool CheckAccess(); [EditorBrowsable(EditorBrowsableState.Never)] public void VerifyAccess(); //... [EditorBrowsable(EditorBrowsableState.Advanced)] public Dispatcher Dispatcher { get; } } public sealed class Dispatcher { //... [EditorBrowsable(EditorBrowsableState.Never)] public bool CheckAccess(); [EditorBrowsable(EditorBrowsableState.Never)] public void VerifyAccess(); //... } I don't believe that the application of that attribute is random (or a joke), so my question is: why is it there? Should those methods not be called directly? Then why aren't they protected (or internal, like some of the most useful methods in the WPF)?
A Microsoft employee recently stated CheckAccess is used only for "advanced scenarios", so they hid it from Intellisense. "CheckAccess and VerifyAccess have always been marked to be not visible, maybe IntelliSense wasn't respecting it. You can use Reflector to confirm. The idea here is that CheckAccess and VerifyAccess are advances scenarios, that normal developers don't need. However, I do think that EditorBrowsableState.Advanced would have been a more appropriate level." There's a Microsoft Connect case for this shortcoming. Vote for it if it's important to you.
Why are DispatcherObject.CheckAccess() and VerifyAccess() hidden from Intellisense? The System.Windows.Threading.DispatcherObject class (which DependencyObject is based on) contains a useful function, called CheckAccess(), that determines whether or not the code is running on the UI thread. When I wanted to use it yesterday, I was puzzled to find out that Intellisense didn't show the function (nor VerifyAccess(), which throws an exception when not on the UI thread), even though the MSDN library lists it. I decided to investigate the class using Reflector. It seems that the function in question has an EditorBrowsable(EditorBrowsableState.Never) attribute attached to it. The Dispatcher class, which is used by DispatcherObject, has the same attribute attached to CheckAccess() and VerifyAccess(): public abstract class DispatcherObject { //... [EditorBrowsable(EditorBrowsableState.Never)] public bool CheckAccess(); [EditorBrowsable(EditorBrowsableState.Never)] public void VerifyAccess(); //... [EditorBrowsable(EditorBrowsableState.Advanced)] public Dispatcher Dispatcher { get; } } public sealed class Dispatcher { //... [EditorBrowsable(EditorBrowsableState.Never)] public bool CheckAccess(); [EditorBrowsable(EditorBrowsableState.Never)] public void VerifyAccess(); //... } I don't believe that the application of that attribute is random (or a joke), so my question is: why is it there? Should those methods not be called directly? Then why aren't they protected (or internal, like some of the most useful methods in the WPF)?
TITLE: Why are DispatcherObject.CheckAccess() and VerifyAccess() hidden from Intellisense? QUESTION: The System.Windows.Threading.DispatcherObject class (which DependencyObject is based on) contains a useful function, called CheckAccess(), that determines whether or not the code is running on the UI thread. When I wanted to use it yesterday, I was puzzled to find out that Intellisense didn't show the function (nor VerifyAccess(), which throws an exception when not on the UI thread), even though the MSDN library lists it. I decided to investigate the class using Reflector. It seems that the function in question has an EditorBrowsable(EditorBrowsableState.Never) attribute attached to it. The Dispatcher class, which is used by DispatcherObject, has the same attribute attached to CheckAccess() and VerifyAccess(): public abstract class DispatcherObject { //... [EditorBrowsable(EditorBrowsableState.Never)] public bool CheckAccess(); [EditorBrowsable(EditorBrowsableState.Never)] public void VerifyAccess(); //... [EditorBrowsable(EditorBrowsableState.Advanced)] public Dispatcher Dispatcher { get; } } public sealed class Dispatcher { //... [EditorBrowsable(EditorBrowsableState.Never)] public bool CheckAccess(); [EditorBrowsable(EditorBrowsableState.Never)] public void VerifyAccess(); //... } I don't believe that the application of that attribute is random (or a joke), so my question is: why is it there? Should those methods not be called directly? Then why aren't they protected (or internal, like some of the most useful methods in the WPF)? ANSWER: A Microsoft employee recently stated CheckAccess is used only for "advanced scenarios", so they hid it from Intellisense. "CheckAccess and VerifyAccess have always been marked to be not visible, maybe IntelliSense wasn't respecting it. You can use Reflector to confirm. The idea here is that CheckAccess and VerifyAccess are advances scenarios, that normal developers don't need. However, I do think that EditorBrowsableState.Advanced would have been a more appropriate level." There's a Microsoft Connect case for this shortcoming. Vote for it if it's important to you.
[ ".net-3.5", "intellisense" ]
22
9
2,448
2
0
2008-08-20T07:07:30.030000
2008-10-01T14:59:31.647000
17,532
17,542
ASP.NET Custom Controls - Composites
Summary Hi All, OK, further into my adventures with custom controls... In summary, here is that I have learned of three main "classes" of custom controls. Please feel free to correct me if any of this is wrong! UserControls - Which inherit from UserControl and are contained within an ASCX file. These are pretty limited in what they can do, but are a quick and light way to get some UI commonality with designer support. Custom Composite Controls - These are controls that inherit from WebControl where you add pre-existing controls to the control within the CreateChildControls method. This provides great flexibility, but lack of designer support without additional coding. They are highly portable though since they can be compiled into a DLL. Custom Rendered Controls - Similar to Custom Composite Controls, these are added to a Web Control Library project. The rendering of the control is completely controlled by the programmer by overriding the Render method. My Thoughts.. OK, so while playing with custom composites, I found the following: You have little/no control over the HTML output making it difficult to "debug". The CreateChildControls (and subsequent methods) can get real busy with Controls.Add(myControl) everywhere. I found rendering tables (be it for layout or content) to be considerably awkward. The Question(s).. So, I admit, I am new to this so I could be way off-base with some of my points noted above.. Do you use Composites? Do you have any neat tricks to control the HTML output? Do you just say "to hell with it" and go ahead and create a custom rendered control? Its something I am keen to get really firm in my mind since I know how much good control development can cut overall development time. I look forward to your answers ^_^
I say go ahead with the custom rendered control. I find that in most cases the composite can be easier done and used in a UserControl, but anything beyond that and you'd need to have a finer degree of control (pun unintended) to merit your own rendering strategy. There maybe controls that are simple enough to merit a composite (e.g., a textbox combined with a javascript/dhtml based datepicker, for example) but beyond that one example, it looks like custom rendered controls are the way to go.
ASP.NET Custom Controls - Composites Summary Hi All, OK, further into my adventures with custom controls... In summary, here is that I have learned of three main "classes" of custom controls. Please feel free to correct me if any of this is wrong! UserControls - Which inherit from UserControl and are contained within an ASCX file. These are pretty limited in what they can do, but are a quick and light way to get some UI commonality with designer support. Custom Composite Controls - These are controls that inherit from WebControl where you add pre-existing controls to the control within the CreateChildControls method. This provides great flexibility, but lack of designer support without additional coding. They are highly portable though since they can be compiled into a DLL. Custom Rendered Controls - Similar to Custom Composite Controls, these are added to a Web Control Library project. The rendering of the control is completely controlled by the programmer by overriding the Render method. My Thoughts.. OK, so while playing with custom composites, I found the following: You have little/no control over the HTML output making it difficult to "debug". The CreateChildControls (and subsequent methods) can get real busy with Controls.Add(myControl) everywhere. I found rendering tables (be it for layout or content) to be considerably awkward. The Question(s).. So, I admit, I am new to this so I could be way off-base with some of my points noted above.. Do you use Composites? Do you have any neat tricks to control the HTML output? Do you just say "to hell with it" and go ahead and create a custom rendered control? Its something I am keen to get really firm in my mind since I know how much good control development can cut overall development time. I look forward to your answers ^_^
TITLE: ASP.NET Custom Controls - Composites QUESTION: Summary Hi All, OK, further into my adventures with custom controls... In summary, here is that I have learned of three main "classes" of custom controls. Please feel free to correct me if any of this is wrong! UserControls - Which inherit from UserControl and are contained within an ASCX file. These are pretty limited in what they can do, but are a quick and light way to get some UI commonality with designer support. Custom Composite Controls - These are controls that inherit from WebControl where you add pre-existing controls to the control within the CreateChildControls method. This provides great flexibility, but lack of designer support without additional coding. They are highly portable though since they can be compiled into a DLL. Custom Rendered Controls - Similar to Custom Composite Controls, these are added to a Web Control Library project. The rendering of the control is completely controlled by the programmer by overriding the Render method. My Thoughts.. OK, so while playing with custom composites, I found the following: You have little/no control over the HTML output making it difficult to "debug". The CreateChildControls (and subsequent methods) can get real busy with Controls.Add(myControl) everywhere. I found rendering tables (be it for layout or content) to be considerably awkward. The Question(s).. So, I admit, I am new to this so I could be way off-base with some of my points noted above.. Do you use Composites? Do you have any neat tricks to control the HTML output? Do you just say "to hell with it" and go ahead and create a custom rendered control? Its something I am keen to get really firm in my mind since I know how much good control development can cut overall development time. I look forward to your answers ^_^ ANSWER: I say go ahead with the custom rendered control. I find that in most cases the composite can be easier done and used in a UserControl, but anything beyond that and you'd need to have a finer degree of control (pun unintended) to merit your own rendering strategy. There maybe controls that are simple enough to merit a composite (e.g., a textbox combined with a javascript/dhtml based datepicker, for example) but beyond that one example, it looks like custom rendered controls are the way to go.
[ "c#", ".net", "asp.net", "user-controls", "controls" ]
19
5
4,239
6
0
2008-08-20T07:49:06.967000
2008-08-20T07:53:32.230000
17,533
90,442
Request Windows Vista UAC elevation if path is protected?
For my C# app, I don't want to always prompt for elevation on application start, but if they choose an output path that is UAC protected then I need to request elevation. So, how do I check if a path is UAC protected and then how do I request elevation mid-execution?
The best way to detect if they are unable to perform an action is to attempt it and catch the UnauthorizedAccessException. However as @ DannySmurf correctly points out you can only elevate a COM object or separate process. There is a demonstration application within the Windows SDK Cross Technology Samples called UAC Demo. This demonstration application shows a method of executing actions with an elevated process. It also demonstrates how to find out if a user is currently an administrator.
Request Windows Vista UAC elevation if path is protected? For my C# app, I don't want to always prompt for elevation on application start, but if they choose an output path that is UAC protected then I need to request elevation. So, how do I check if a path is UAC protected and then how do I request elevation mid-execution?
TITLE: Request Windows Vista UAC elevation if path is protected? QUESTION: For my C# app, I don't want to always prompt for elevation on application start, but if they choose an output path that is UAC protected then I need to request elevation. So, how do I check if a path is UAC protected and then how do I request elevation mid-execution? ANSWER: The best way to detect if they are unable to perform an action is to attempt it and catch the UnauthorizedAccessException. However as @ DannySmurf correctly points out you can only elevate a COM object or separate process. There is a demonstration application within the Windows SDK Cross Technology Samples called UAC Demo. This demonstration application shows a method of executing actions with an elevated process. It also demonstrates how to find out if a user is currently an administrator.
[ "c#", ".net", "windows-vista", "uac", "elevated-privileges" ]
27
25
15,180
6
0
2008-08-20T07:50:29.350000
2008-09-18T06:10:20.783000
17,561
17,616
Recommendations for browser add-on tools to help with development
Can anyone suggest some good browser add-on tools/extensions to help with development? I have firebug installed in Firefox which is great for dealing with CSS, HTML and javascript; any other suggestions? Firebug
Firefox: Inspect This if you use the DOM Inspector at all Measure It for telling you pixel distances (if you need that) IE View or Safari View for ease of testing in other browsers HTML Validator if you care about validation Console 2 to improve your js error console The Javascript Shell bookmarklet is also handy (and look at the others there as well) Edit: This is in addition to the Web Development Toolbar mentioned by others
Recommendations for browser add-on tools to help with development Can anyone suggest some good browser add-on tools/extensions to help with development? I have firebug installed in Firefox which is great for dealing with CSS, HTML and javascript; any other suggestions? Firebug
TITLE: Recommendations for browser add-on tools to help with development QUESTION: Can anyone suggest some good browser add-on tools/extensions to help with development? I have firebug installed in Firefox which is great for dealing with CSS, HTML and javascript; any other suggestions? Firebug ANSWER: Firefox: Inspect This if you use the DOM Inspector at all Measure It for telling you pixel distances (if you need that) IE View or Safari View for ease of testing in other browsers HTML Validator if you care about validation Console 2 to improve your js error console The Javascript Shell bookmarklet is also handy (and look at the others there as well) Edit: This is in addition to the Web Development Toolbar mentioned by others
[ "browser" ]
7
5
838
12
0
2008-08-20T08:09:38.010000
2008-08-20T08:46:13.537000
17,609
17,617
Email queueing in php
What is the most proper way to sending email of minimal 1000 or more in PHP? Any reliable email queuing technique that is capable to handle that? ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­
You could just insert your emails into a Mail Queue database table, and have a separate process check the queue and batch send a certain number at once.
Email queueing in php What is the most proper way to sending email of minimal 1000 or more in PHP? Any reliable email queuing technique that is capable to handle that? ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­
TITLE: Email queueing in php QUESTION: What is the most proper way to sending email of minimal 1000 or more in PHP? Any reliable email queuing technique that is capable to handle that? ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­ ANSWER: You could just insert your emails into a Mail Queue database table, and have a separate process check the queue and batch send a certain number at once.
[ "php", "email", "queue" ]
5
6
7,164
7
0
2008-08-20T08:38:24.803000
2008-08-20T08:46:49.933000
17,612
17,620
How do you place a file in recycle bin instead of delete?
Programmatic solution of course...
http://www.daveamenta.com/2008-05/c-delete-a-file-to-the-recycle-bin/ From above: using Microsoft.VisualBasic; string path = @"c:\myfile.txt"; FileIO.FileSystem.DeleteDirectory(path, FileIO.UIOption.OnlyErrorDialogs, RecycleOption.SendToRecycleBin);
How do you place a file in recycle bin instead of delete? Programmatic solution of course...
TITLE: How do you place a file in recycle bin instead of delete? QUESTION: Programmatic solution of course... ANSWER: http://www.daveamenta.com/2008-05/c-delete-a-file-to-the-recycle-bin/ From above: using Microsoft.VisualBasic; string path = @"c:\myfile.txt"; FileIO.FileSystem.DeleteDirectory(path, FileIO.UIOption.OnlyErrorDialogs, RecycleOption.SendToRecycleBin);
[ "c#", ".net", "c++", "windows", "io" ]
29
38
11,640
3
0
2008-08-20T08:43:00.393000
2008-08-20T08:48:07.073000
17,624
17,627
What is the easiest way using T-SQL / MS-SQL to append a string to existing table cells?
I have a table with a 'filename' column. I recently performed an insert into this column but in my haste forgot to append the file extension to all the filenames entered. Fortunately they are all '.jpg' images. How can I easily update the 'filename' column of these inserted fields (assuming I can select the recent rows based on known id values) to include the '.jpg' extension?
The solution is: UPDATE tablename SET [filename] = RTRIM([filename]) + '.jpg' WHERE id > 50 RTRIM is required because otherwise the [filename] column in its entirety will be selected for the string concatenation i.e. if it is a varchar(20) column and filename is only 10 letters long then it will still select those 10 letters and then 10 spaces. This will in turn result in an error as you try to fit 20 + 3 characters into a 20 character long field.
What is the easiest way using T-SQL / MS-SQL to append a string to existing table cells? I have a table with a 'filename' column. I recently performed an insert into this column but in my haste forgot to append the file extension to all the filenames entered. Fortunately they are all '.jpg' images. How can I easily update the 'filename' column of these inserted fields (assuming I can select the recent rows based on known id values) to include the '.jpg' extension?
TITLE: What is the easiest way using T-SQL / MS-SQL to append a string to existing table cells? QUESTION: I have a table with a 'filename' column. I recently performed an insert into this column but in my haste forgot to append the file extension to all the filenames entered. Fortunately they are all '.jpg' images. How can I easily update the 'filename' column of these inserted fields (assuming I can select the recent rows based on known id values) to include the '.jpg' extension? ANSWER: The solution is: UPDATE tablename SET [filename] = RTRIM([filename]) + '.jpg' WHERE id > 50 RTRIM is required because otherwise the [filename] column in its entirety will be selected for the string concatenation i.e. if it is a varchar(20) column and filename is only 10 letters long then it will still select those 10 letters and then 10 spaces. This will in turn result in an error as you try to fit 20 + 3 characters into a 20 character long field.
[ "sql", "sql-server", "t-sql" ]
11
27
25,754
6
0
2008-08-20T08:52:00.497000
2008-08-20T08:54:43.220000
17,645
17,649
Differences between unix and windows files
Am I correct in assuming that the only difference between "windows files" and "unix files" is the linebreak? We have a system that has been moved from a windows machine to a unix machine and are having troubles with the format. I need to automate the translation between unix/windows before the files get delivered to the system in our "transportsystem". I'll probably need something to determine the current format and something to transform it into the other format. If it's just the newline thats the big difference then I'm considering just reading the files with the java.io. As far as I know, they are able to handle both with readLine. And then just write each line back with while (line = readline) print(line + NewlineInOtherFormat).... Summary: samjudson: This is only a difference in text files, where UNIX uses a single Line Feed (LF) to signify a new line, Windows uses a Carriage Return/Line Feed (CRLF) and Mac uses just a CR. to which Cebjyre elaborates: OS X uses LF, the same as UNIX - MacOS 9 and below did use CR though Mo There could also be a difference in character encoding for national characters. There is no "unix-encoding" but many linux-variants use UTF-8 as the default encoding. Mac OS (which is also a unix) uses its own encoding (macroman). I am not sure, what windows default encoding is. McDowell In addition to the new-line differences, the byte-order mark can cause problems if files are treated as Unicode on Windows. Cheekysoft However, another set of problems that you may come across can be related to single/multi-byte character encodings. If you see strange unexpected chars (not at end-of-line) then this could be the reason. Especially if you see square boxes, question marks, upside-down question marks, extra characters or unexpected accented characters. Sadie On unix, files that start with a. are hidden. On windows, it's a filesystem flag that you probably don't have easy access to. This may result in files that are supposed to be hidden now becoming visible on the client machines. File permissions vary between the two. You will probably find, when you copy files onto a unix system, that the files now belong to the user that did the copying and have limited rights. You'll need to use chown/chmod to make sure the correct users have access to them. There exists tools to help with the problem: pauldoo If you are just interested in the content of text files, then yes the line endings are different. Take a look at something like dos2unix, it may be of help here. Cheekysoft As pauldoo suggests, tools like dos2unix can be very useful. Note that these may be on your linux/unix system as fromdos or tofrodos, or perhaps even as the general purpose toolbox recode. Help for java coding Cheekysoft When writing to files or reading from files (that you are in control of), it is often worth specifying the encoding to use, as most Java methods allow this. However, also ensuring that the system locale matches can save a lot of pain
This is only a difference in text files, where UNIX uses a single Line Feed (LF) to signify a new line, Windows uses a Carriage Return/Line Feed (CRLF) and Mac uses just a CR. Binary files there should be no difference (i.e. a JPEG on a windows machine will be byte for byte the same as the same JPEG on a unix box.)
Differences between unix and windows files Am I correct in assuming that the only difference between "windows files" and "unix files" is the linebreak? We have a system that has been moved from a windows machine to a unix machine and are having troubles with the format. I need to automate the translation between unix/windows before the files get delivered to the system in our "transportsystem". I'll probably need something to determine the current format and something to transform it into the other format. If it's just the newline thats the big difference then I'm considering just reading the files with the java.io. As far as I know, they are able to handle both with readLine. And then just write each line back with while (line = readline) print(line + NewlineInOtherFormat).... Summary: samjudson: This is only a difference in text files, where UNIX uses a single Line Feed (LF) to signify a new line, Windows uses a Carriage Return/Line Feed (CRLF) and Mac uses just a CR. to which Cebjyre elaborates: OS X uses LF, the same as UNIX - MacOS 9 and below did use CR though Mo There could also be a difference in character encoding for national characters. There is no "unix-encoding" but many linux-variants use UTF-8 as the default encoding. Mac OS (which is also a unix) uses its own encoding (macroman). I am not sure, what windows default encoding is. McDowell In addition to the new-line differences, the byte-order mark can cause problems if files are treated as Unicode on Windows. Cheekysoft However, another set of problems that you may come across can be related to single/multi-byte character encodings. If you see strange unexpected chars (not at end-of-line) then this could be the reason. Especially if you see square boxes, question marks, upside-down question marks, extra characters or unexpected accented characters. Sadie On unix, files that start with a. are hidden. On windows, it's a filesystem flag that you probably don't have easy access to. This may result in files that are supposed to be hidden now becoming visible on the client machines. File permissions vary between the two. You will probably find, when you copy files onto a unix system, that the files now belong to the user that did the copying and have limited rights. You'll need to use chown/chmod to make sure the correct users have access to them. There exists tools to help with the problem: pauldoo If you are just interested in the content of text files, then yes the line endings are different. Take a look at something like dos2unix, it may be of help here. Cheekysoft As pauldoo suggests, tools like dos2unix can be very useful. Note that these may be on your linux/unix system as fromdos or tofrodos, or perhaps even as the general purpose toolbox recode. Help for java coding Cheekysoft When writing to files or reading from files (that you are in control of), it is often worth specifying the encoding to use, as most Java methods allow this. However, also ensuring that the system locale matches can save a lot of pain
TITLE: Differences between unix and windows files QUESTION: Am I correct in assuming that the only difference between "windows files" and "unix files" is the linebreak? We have a system that has been moved from a windows machine to a unix machine and are having troubles with the format. I need to automate the translation between unix/windows before the files get delivered to the system in our "transportsystem". I'll probably need something to determine the current format and something to transform it into the other format. If it's just the newline thats the big difference then I'm considering just reading the files with the java.io. As far as I know, they are able to handle both with readLine. And then just write each line back with while (line = readline) print(line + NewlineInOtherFormat).... Summary: samjudson: This is only a difference in text files, where UNIX uses a single Line Feed (LF) to signify a new line, Windows uses a Carriage Return/Line Feed (CRLF) and Mac uses just a CR. to which Cebjyre elaborates: OS X uses LF, the same as UNIX - MacOS 9 and below did use CR though Mo There could also be a difference in character encoding for national characters. There is no "unix-encoding" but many linux-variants use UTF-8 as the default encoding. Mac OS (which is also a unix) uses its own encoding (macroman). I am not sure, what windows default encoding is. McDowell In addition to the new-line differences, the byte-order mark can cause problems if files are treated as Unicode on Windows. Cheekysoft However, another set of problems that you may come across can be related to single/multi-byte character encodings. If you see strange unexpected chars (not at end-of-line) then this could be the reason. Especially if you see square boxes, question marks, upside-down question marks, extra characters or unexpected accented characters. Sadie On unix, files that start with a. are hidden. On windows, it's a filesystem flag that you probably don't have easy access to. This may result in files that are supposed to be hidden now becoming visible on the client machines. File permissions vary between the two. You will probably find, when you copy files onto a unix system, that the files now belong to the user that did the copying and have limited rights. You'll need to use chown/chmod to make sure the correct users have access to them. There exists tools to help with the problem: pauldoo If you are just interested in the content of text files, then yes the line endings are different. Take a look at something like dos2unix, it may be of help here. Cheekysoft As pauldoo suggests, tools like dos2unix can be very useful. Note that these may be on your linux/unix system as fromdos or tofrodos, or perhaps even as the general purpose toolbox recode. Help for java coding Cheekysoft When writing to files or reading from files (that you are in control of), it is often worth specifying the encoding to use, as most Java methods allow this. However, also ensuring that the system locale matches can save a lot of pain ANSWER: This is only a difference in text files, where UNIX uses a single Line Feed (LF) to signify a new line, Windows uses a Carriage Return/Line Feed (CRLF) and Mac uses just a CR. Binary files there should be no difference (i.e. a JPEG on a windows machine will be byte for byte the same as the same JPEG on a unix box.)
[ "java", "windows", "unix", "file" ]
20
13
17,897
6
0
2008-08-20T09:18:44.707000
2008-08-20T09:22:07.477000
17,664
17,698
Retrieving the PC Name of a Client? (Windows Auth)
I have an ASP.net Application that runs on the internal network (well, actually it's running on Sharepoint 2007). I just wonder: Can I somehow retrieve the name of the PC the Client is using? I would have access to Active Directory if that helps. The thing is, people use multiple PCs. So, I cannot use any manual/static mapping. If possible, I do not want to use any client-side (read: JavaScript) code, but if it cannot be done server-side, JavaScript would be OK as well. ActiveX is absolutely out of question.
System.Web.HttpRequest.UserHostname as suggested in this answer just returns the IP:-( But I just found this: System.Net.Dns.GetHostEntry(Page.Request.UserHostAddress).HostName That only works if there is actually a DNS Server to resolve the name, which is the case for my network.
Retrieving the PC Name of a Client? (Windows Auth) I have an ASP.net Application that runs on the internal network (well, actually it's running on Sharepoint 2007). I just wonder: Can I somehow retrieve the name of the PC the Client is using? I would have access to Active Directory if that helps. The thing is, people use multiple PCs. So, I cannot use any manual/static mapping. If possible, I do not want to use any client-side (read: JavaScript) code, but if it cannot be done server-side, JavaScript would be OK as well. ActiveX is absolutely out of question.
TITLE: Retrieving the PC Name of a Client? (Windows Auth) QUESTION: I have an ASP.net Application that runs on the internal network (well, actually it's running on Sharepoint 2007). I just wonder: Can I somehow retrieve the name of the PC the Client is using? I would have access to Active Directory if that helps. The thing is, people use multiple PCs. So, I cannot use any manual/static mapping. If possible, I do not want to use any client-side (read: JavaScript) code, but if it cannot be done server-side, JavaScript would be OK as well. ActiveX is absolutely out of question. ANSWER: System.Web.HttpRequest.UserHostname as suggested in this answer just returns the IP:-( But I just found this: System.Net.Dns.GetHostEntry(Page.Request.UserHostAddress).HostName That only works if there is actually a DNS Server to resolve the name, which is the case for my network.
[ "asp.net", "sharepoint", "authentication" ]
3
4
1,173
2
0
2008-08-20T09:34:54.887000
2008-08-20T10:05:54.830000
17,670
17,683
Suitable alternative to CryptEncrypt
We have a situation in our product where for a long time some data has been stored in the application's database as SQL string (choice of MS SQL server or sybase SQL anywhere) which was encrypted via the Windows API function CryptEncrypt. (direct and de-cryptable) The problem is that CryptEncrypt can produce NULL's in the output, meaning that when it's stored in the database, the string manipulations will at some point truncate the CipherText. Ideally we'd like to use an algo that will produce CipherText that doesn't contain NULLs as that will cause the least amount of change to the existing databases (changing a column from string to binary and code to deal with binary instead of strings) and just decrypt existing data and re-encrypt with the new algorithm at database upgrade time. The algorithm doesn't need to be the most secure, as the database is already in a reasonably secure environment (not an open network / the inter-webs) but does need to be better than ROT13 (which I can almost decrypt in my head now!) edit: btw, any particular reason for changing ciphertext to cyphertext? ciphertext seems more widely used...
Any semi-decent algorithm will end up with a strong chance of generating a NULL value somewhere in the resulting ciphertext. Why not do something like base-64 encode your resulting binary blob before persisting to the DB? ( sample implementation in C++ ).
Suitable alternative to CryptEncrypt We have a situation in our product where for a long time some data has been stored in the application's database as SQL string (choice of MS SQL server or sybase SQL anywhere) which was encrypted via the Windows API function CryptEncrypt. (direct and de-cryptable) The problem is that CryptEncrypt can produce NULL's in the output, meaning that when it's stored in the database, the string manipulations will at some point truncate the CipherText. Ideally we'd like to use an algo that will produce CipherText that doesn't contain NULLs as that will cause the least amount of change to the existing databases (changing a column from string to binary and code to deal with binary instead of strings) and just decrypt existing data and re-encrypt with the new algorithm at database upgrade time. The algorithm doesn't need to be the most secure, as the database is already in a reasonably secure environment (not an open network / the inter-webs) but does need to be better than ROT13 (which I can almost decrypt in my head now!) edit: btw, any particular reason for changing ciphertext to cyphertext? ciphertext seems more widely used...
TITLE: Suitable alternative to CryptEncrypt QUESTION: We have a situation in our product where for a long time some data has been stored in the application's database as SQL string (choice of MS SQL server or sybase SQL anywhere) which was encrypted via the Windows API function CryptEncrypt. (direct and de-cryptable) The problem is that CryptEncrypt can produce NULL's in the output, meaning that when it's stored in the database, the string manipulations will at some point truncate the CipherText. Ideally we'd like to use an algo that will produce CipherText that doesn't contain NULLs as that will cause the least amount of change to the existing databases (changing a column from string to binary and code to deal with binary instead of strings) and just decrypt existing data and re-encrypt with the new algorithm at database upgrade time. The algorithm doesn't need to be the most secure, as the database is already in a reasonably secure environment (not an open network / the inter-webs) but does need to be better than ROT13 (which I can almost decrypt in my head now!) edit: btw, any particular reason for changing ciphertext to cyphertext? ciphertext seems more widely used... ANSWER: Any semi-decent algorithm will end up with a strong chance of generating a NULL value somewhere in the resulting ciphertext. Why not do something like base-64 encode your resulting binary blob before persisting to the DB? ( sample implementation in C++ ).
[ "c++", "encryption", "winapi" ]
2
3
832
4
0
2008-08-20T09:37:02.603000
2008-08-20T09:49:56.333000
17,679
17,859
Why does Guid.ToString() reverse the byte order?
We're storing some Guid's in a MS SQL database. There's some legacy code that does Guid.ToString() and then passes them in to a varchar(64) and there's some newer code that passes them in using a unique identifier parameter. When you look at the results using MS SQL Management studio they look different. The byte order of the first three blocks is reversed but the last one remains the same. Why?
Uniqueidentifier fields in Sql server can be indexed, and so are 'backwards'. Guids can be generated from both machine specific info and 'event-time' information. The default Guid in.Net is random, but you can get sequential Guids from it with an extern call: [DllImport( "rpcrt4.dll", SetLastError = true )] static extern int UuidCreateSequential( out Guid guid ); This will get you Guids based on your MAC address ( MSDN docs ) that are sequential. If you.ToString() these sequential guids then you will see the first part of the string varies, while the rest stays constant. This makes equality checks between Guids quicker (as the differences will be at the start) and improves the variation for truncated ones. For searching columns SqlServer builds indexes in a similar way to a telephone directory or dictionary. It is much quicker to search for words starting with "Over*" than it would be to find ones ending in "*flow". This means that for Sql server any sequential Guids need to be stored with the repeating value first, so it stores them back to front.
Why does Guid.ToString() reverse the byte order? We're storing some Guid's in a MS SQL database. There's some legacy code that does Guid.ToString() and then passes them in to a varchar(64) and there's some newer code that passes them in using a unique identifier parameter. When you look at the results using MS SQL Management studio they look different. The byte order of the first three blocks is reversed but the last one remains the same. Why?
TITLE: Why does Guid.ToString() reverse the byte order? QUESTION: We're storing some Guid's in a MS SQL database. There's some legacy code that does Guid.ToString() and then passes them in to a varchar(64) and there's some newer code that passes them in using a unique identifier parameter. When you look at the results using MS SQL Management studio they look different. The byte order of the first three blocks is reversed but the last one remains the same. Why? ANSWER: Uniqueidentifier fields in Sql server can be indexed, and so are 'backwards'. Guids can be generated from both machine specific info and 'event-time' information. The default Guid in.Net is random, but you can get sequential Guids from it with an extern call: [DllImport( "rpcrt4.dll", SetLastError = true )] static extern int UuidCreateSequential( out Guid guid ); This will get you Guids based on your MAC address ( MSDN docs ) that are sequential. If you.ToString() these sequential guids then you will see the first part of the string varies, while the rest stays constant. This makes equality checks between Guids quicker (as the differences will be at the start) and improves the variation for truncated ones. For searching columns SqlServer builds indexes in a similar way to a telephone directory or dictionary. It is much quicker to search for words starting with "Over*" than it would be to find ones ending in "*flow". This means that for Sql server any sequential Guids need to be stored with the repeating value first, so it stores them back to front.
[ ".net", "sql-server" ]
9
9
2,625
1
0
2008-08-20T09:44:02.947000
2008-08-20T12:55:52.877000
17,704
17,709
Unix subsystem for windows
One of the bullet point features for Windows Vista Enterprize and Ultimate is the Unix subsystem for windows, which allows you to write posix... stuff? Anyway I'm outa my league talking about it... Anyone use this feature? Or explain it... I know next to nothing about Unix programming.
It's probably best not to try to use the Posix subsystem for Windows. It was never really complete and is just a useless marketing tick box. If you're truly interested in programming stuff for Unix, download one of the many Linux distributions (ie. Ubuntu ) and VirtualBox. Install and start playing.
Unix subsystem for windows One of the bullet point features for Windows Vista Enterprize and Ultimate is the Unix subsystem for windows, which allows you to write posix... stuff? Anyway I'm outa my league talking about it... Anyone use this feature? Or explain it... I know next to nothing about Unix programming.
TITLE: Unix subsystem for windows QUESTION: One of the bullet point features for Windows Vista Enterprize and Ultimate is the Unix subsystem for windows, which allows you to write posix... stuff? Anyway I'm outa my league talking about it... Anyone use this feature? Or explain it... I know next to nothing about Unix programming. ANSWER: It's probably best not to try to use the Posix subsystem for Windows. It was never really complete and is just a useless marketing tick box. If you're truly interested in programming stuff for Unix, download one of the many Linux distributions (ie. Ubuntu ) and VirtualBox. Install and start playing.
[ "windows", "posix" ]
2
4
1,666
5
0
2008-08-20T10:18:36.123000
2008-08-20T10:26:27.573000