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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
8,612 | 8,616 | Code crash in MS Visual Studio 2005 in RELEASE configuration | I have a workspace for running an H.263 Video Encoder in a loop for 31 times i.e. the main is executed 31 times to generate 31 different encoded bit streams. This MS Visual Studio 2005 Workspace has all C source files. When i create a "DEBUG" configuration for the workspace and build and execute it, it runs fine, i.e. it generates all the 31 output files as expected. But when I set the configuration of the workspace to "RELEASE" mdoe, and repeat the process, the encoder crashes at some test case run. Now to debug this is verified following: Analyzed the code to see if there was any variable initialization being missed out in every run of the encoder Checked the various Workspace(Solution) options in both the modes (DEBUG and RELEASE). There are some obvious differences, but i turned the optimization related options explicitly same in both modes. But still could not nail the problem and find a fix for that. Any pointers? -Ajit. | It's hard to say what the problem might be without carefully inspecting the code. However... One of the differences between debug and release builds is how the function call stack frame is set up. There are certain classes of bad things you can do (like calling a function with the wrong number of arguments) that are not fatal in a debug build but crash horribly in a release build. Perhaps you could try changing the stack frame related options (I forget what they're called, sorry) in the release build to the same as the debug build and see whether that helps. Another thing might be to enable all the warnings you possibly can, and fix them all. | Code crash in MS Visual Studio 2005 in RELEASE configuration I have a workspace for running an H.263 Video Encoder in a loop for 31 times i.e. the main is executed 31 times to generate 31 different encoded bit streams. This MS Visual Studio 2005 Workspace has all C source files. When i create a "DEBUG" configuration for the workspace and build and execute it, it runs fine, i.e. it generates all the 31 output files as expected. But when I set the configuration of the workspace to "RELEASE" mdoe, and repeat the process, the encoder crashes at some test case run. Now to debug this is verified following: Analyzed the code to see if there was any variable initialization being missed out in every run of the encoder Checked the various Workspace(Solution) options in both the modes (DEBUG and RELEASE). There are some obvious differences, but i turned the optimization related options explicitly same in both modes. But still could not nail the problem and find a fix for that. Any pointers? -Ajit. | TITLE:
Code crash in MS Visual Studio 2005 in RELEASE configuration
QUESTION:
I have a workspace for running an H.263 Video Encoder in a loop for 31 times i.e. the main is executed 31 times to generate 31 different encoded bit streams. This MS Visual Studio 2005 Workspace has all C source files. When i create a "DEBUG" configuration for the workspace and build and execute it, it runs fine, i.e. it generates all the 31 output files as expected. But when I set the configuration of the workspace to "RELEASE" mdoe, and repeat the process, the encoder crashes at some test case run. Now to debug this is verified following: Analyzed the code to see if there was any variable initialization being missed out in every run of the encoder Checked the various Workspace(Solution) options in both the modes (DEBUG and RELEASE). There are some obvious differences, but i turned the optimization related options explicitly same in both modes. But still could not nail the problem and find a fix for that. Any pointers? -Ajit.
ANSWER:
It's hard to say what the problem might be without carefully inspecting the code. However... One of the differences between debug and release builds is how the function call stack frame is set up. There are certain classes of bad things you can do (like calling a function with the wrong number of arguments) that are not fatal in a debug build but crash horribly in a release build. Perhaps you could try changing the stack frame related options (I forget what they're called, sorry) in the release build to the same as the debug build and see whether that helps. Another thing might be to enable all the warnings you possibly can, and fix them all. | [
"visual-studio-2005"
] | 2 | 2 | 1,491 | 8 | 0 | 2008-08-12T08:44:09.600000 | 2008-08-12T08:51:01.053000 |
8,624 | 8,654 | Best format for displaying rendered time on a webpage | I've started to add the time taken to render a page to the footer of our internal web applications. Currently it appears like this Rendered in 0.062 seconds Occasionally I get rendered times like this Rendered in 0.000 seconds Currently it's only meant to be a guide for users to judge whether a page is quick to load or not, allowing them to quickly inform us if a page is taking 17 seconds rather than the usual 0.5. My question is what format should the time be in? At which point should I switch to a statement such as Rendered in less than a second I like seeing the tenths of a second but the second example above is of no use to anyone, in fact it just highlights the limits of the calculation I use to find the render time. I'd rather not let the users see that at all! Any answers welcome, including whether anything should be included on the page. | I'm not sure there's any value in telling users how long it took for the server to render the page. It could well be worth you logging that sort of information, but they don't care. If it takes the server 0.001 of a second to draw the page but it takes 17 seconds for them to load it (due to network, javascript, page size, their rubbish PC, etc) their perception will be the latter. Then again adding the render time might help you fend off the enquiries about any percieved slowness with a "talk to your local network admin" response. Given that you know the accuracy of your measurements you could have the 0.000 text be "Rendered in less than a thousandth of a second" | Best format for displaying rendered time on a webpage I've started to add the time taken to render a page to the footer of our internal web applications. Currently it appears like this Rendered in 0.062 seconds Occasionally I get rendered times like this Rendered in 0.000 seconds Currently it's only meant to be a guide for users to judge whether a page is quick to load or not, allowing them to quickly inform us if a page is taking 17 seconds rather than the usual 0.5. My question is what format should the time be in? At which point should I switch to a statement such as Rendered in less than a second I like seeing the tenths of a second but the second example above is of no use to anyone, in fact it just highlights the limits of the calculation I use to find the render time. I'd rather not let the users see that at all! Any answers welcome, including whether anything should be included on the page. | TITLE:
Best format for displaying rendered time on a webpage
QUESTION:
I've started to add the time taken to render a page to the footer of our internal web applications. Currently it appears like this Rendered in 0.062 seconds Occasionally I get rendered times like this Rendered in 0.000 seconds Currently it's only meant to be a guide for users to judge whether a page is quick to load or not, allowing them to quickly inform us if a page is taking 17 seconds rather than the usual 0.5. My question is what format should the time be in? At which point should I switch to a statement such as Rendered in less than a second I like seeing the tenths of a second but the second example above is of no use to anyone, in fact it just highlights the limits of the calculation I use to find the render time. I'd rather not let the users see that at all! Any answers welcome, including whether anything should be included on the page.
ANSWER:
I'm not sure there's any value in telling users how long it took for the server to render the page. It could well be worth you logging that sort of information, but they don't care. If it takes the server 0.001 of a second to draw the page but it takes 17 seconds for them to load it (due to network, javascript, page size, their rubbish PC, etc) their perception will be the latter. Then again adding the render time might help you fend off the enquiries about any percieved slowness with a "talk to your local network admin" response. Given that you know the accuracy of your measurements you could have the 0.000 text be "Rendered in less than a thousandth of a second" | [
"render"
] | 2 | 1 | 777 | 4 | 0 | 2008-08-12T09:08:05.217000 | 2008-08-12T10:40:26.590000 |
8,625 | 8,633 | Generic type conversion FROM string | I have a class that I want to use to store "properties" for another class. These properties simply have a name and a value. Ideally, what I would like is to be able to add typed properties, so that the "value" returned is always of the type that I want it to be. The type should always be a primitive. This class subclasses an abstract class which basically stores the name and value as string. The idea being that this subclass will add some type-safety to the base class (as well as saving me on some conversion). So, I have created a class which is (roughly) this: public class TypedProperty: Property { public DataType TypedValue { get { // Having problems here! } set { base.Value = value.ToString();} } } So the question is: Is there a "generic" way to convert from string back to a primitive? I can't seem to find any generic interface that links the conversion across the board (something like ITryParsable would have been ideal!). | I am not sure whether I understood your intentions correctly, but let's see if this one helps. public class TypedProperty: Property where T: IConvertible { public T TypedValue { get { return (T)Convert.ChangeType(base.Value, typeof(T)); } set { base.Value = value.ToString();} } } | Generic type conversion FROM string I have a class that I want to use to store "properties" for another class. These properties simply have a name and a value. Ideally, what I would like is to be able to add typed properties, so that the "value" returned is always of the type that I want it to be. The type should always be a primitive. This class subclasses an abstract class which basically stores the name and value as string. The idea being that this subclass will add some type-safety to the base class (as well as saving me on some conversion). So, I have created a class which is (roughly) this: public class TypedProperty: Property { public DataType TypedValue { get { // Having problems here! } set { base.Value = value.ToString();} } } So the question is: Is there a "generic" way to convert from string back to a primitive? I can't seem to find any generic interface that links the conversion across the board (something like ITryParsable would have been ideal!). | TITLE:
Generic type conversion FROM string
QUESTION:
I have a class that I want to use to store "properties" for another class. These properties simply have a name and a value. Ideally, what I would like is to be able to add typed properties, so that the "value" returned is always of the type that I want it to be. The type should always be a primitive. This class subclasses an abstract class which basically stores the name and value as string. The idea being that this subclass will add some type-safety to the base class (as well as saving me on some conversion). So, I have created a class which is (roughly) this: public class TypedProperty: Property { public DataType TypedValue { get { // Having problems here! } set { base.Value = value.ToString();} } } So the question is: Is there a "generic" way to convert from string back to a primitive? I can't seem to find any generic interface that links the conversion across the board (something like ITryParsable would have been ideal!).
ANSWER:
I am not sure whether I understood your intentions correctly, but let's see if this one helps. public class TypedProperty: Property where T: IConvertible { public T TypedValue { get { return (T)Convert.ChangeType(base.Value, typeof(T)); } set { base.Value = value.ToString();} } } | [
"c#",
"generics",
"primitive",
"type-safety"
] | 280 | 448 | 179,212 | 11 | 0 | 2008-08-12T09:13:23.520000 | 2008-08-12T09:24:33.203000 |
8,626 | 4,068,900 | Globus Toolkit virtual machine | Is there anyplace where one can download a virtual machine containing a working install of some Linux distro with Globus Toolkit and some development tools (Java) for testing purposes? A real deployment of a grid is more complicated but I just need something portable, for development. | The link to http://workspace.globus.org/vm/marketplace.html appears to be broken now. I think the new location is http://scienceclouds.org/marketplace/. | Globus Toolkit virtual machine Is there anyplace where one can download a virtual machine containing a working install of some Linux distro with Globus Toolkit and some development tools (Java) for testing purposes? A real deployment of a grid is more complicated but I just need something portable, for development. | TITLE:
Globus Toolkit virtual machine
QUESTION:
Is there anyplace where one can download a virtual machine containing a working install of some Linux distro with Globus Toolkit and some development tools (Java) for testing purposes? A real deployment of a grid is more complicated but I just need something portable, for development.
ANSWER:
The link to http://workspace.globus.org/vm/marketplace.html appears to be broken now. I think the new location is http://scienceclouds.org/marketplace/. | [
"linux",
"virtual-machine",
"globus-toolkit"
] | 2 | 1 | 1,165 | 2 | 0 | 2008-08-12T09:13:40.773000 | 2010-11-01T12:36:12.553000 |
8,651 | 8,687 | Import Namespace System.Query | I am trying to load Linq on my.Net 3.5 enabled web server by adding the following to my.aspx page: <%@ Import Namespace="System.Query" %> However, this fails and tells me it cannot find the namespace. The type or namespace name 'Query' does not exist in the namespace 'System' I have also tried with no luck: System.Data.Linq System.Linq System.Xml.Linq I believe that.Net 3.5 is working because var hello = "Hello World" seems to work. Can anyone help please? PS: I just want to clarify that I don't use Visual Studio, I simply have a Text Editor and write my code directly into.aspx files. | I have version 2 selected in IIS and I Well, surely that's your problem? Select 3.5. Actually, here's the real info: http://www.hanselman.com/blog/HowToSetAnIISApplicationOrAppPoolToUseASPNET35RatherThan20.aspx | Import Namespace System.Query I am trying to load Linq on my.Net 3.5 enabled web server by adding the following to my.aspx page: <%@ Import Namespace="System.Query" %> However, this fails and tells me it cannot find the namespace. The type or namespace name 'Query' does not exist in the namespace 'System' I have also tried with no luck: System.Data.Linq System.Linq System.Xml.Linq I believe that.Net 3.5 is working because var hello = "Hello World" seems to work. Can anyone help please? PS: I just want to clarify that I don't use Visual Studio, I simply have a Text Editor and write my code directly into.aspx files. | TITLE:
Import Namespace System.Query
QUESTION:
I am trying to load Linq on my.Net 3.5 enabled web server by adding the following to my.aspx page: <%@ Import Namespace="System.Query" %> However, this fails and tells me it cannot find the namespace. The type or namespace name 'Query' does not exist in the namespace 'System' I have also tried with no luck: System.Data.Linq System.Linq System.Xml.Linq I believe that.Net 3.5 is working because var hello = "Hello World" seems to work. Can anyone help please? PS: I just want to clarify that I don't use Visual Studio, I simply have a Text Editor and write my code directly into.aspx files.
ANSWER:
I have version 2 selected in IIS and I Well, surely that's your problem? Select 3.5. Actually, here's the real info: http://www.hanselman.com/blog/HowToSetAnIISApplicationOrAppPoolToUseASPNET35RatherThan20.aspx | [
"asp.net",
"linq"
] | 4 | 5 | 6,784 | 6 | 0 | 2008-08-12T10:37:50.107000 | 2008-08-12T11:15:29.797000 |
8,653 | 8,656 | Numerical formatting using String.Format | Are there any codes that allow for numerical formatting of data when using string.format? | Loads, stick string.Format into Google:-) A quite good tutorial is at iduno | Numerical formatting using String.Format Are there any codes that allow for numerical formatting of data when using string.format? | TITLE:
Numerical formatting using String.Format
QUESTION:
Are there any codes that allow for numerical formatting of data when using string.format?
ANSWER:
Loads, stick string.Format into Google:-) A quite good tutorial is at iduno | [
".net",
"formatting",
"numeric"
] | 2 | 6 | 1,446 | 5 | 0 | 2008-08-12T10:40:05.030000 | 2008-08-12T10:42:59.953000 |
8,669 | 9,319 | Is there some way of recycling a Crystal Reports dataset? | I'm trying to write a Crystal Report which has totals grouped in a different way to the main report. The only way I've been able to do this so far is to use a subreport for the totals, but it means having to hit the data source again to retrieve the same data, which seems like nonsense. Here's a simplified example: date name earnings source location ----------------------------------------------------------- 12-AUG-2008 Tom $50.00 washing cars uptown 12-AUG-2008 Dick $100.00 washing cars downtown { main report } 12-AUG-2008 Harry $75.00 mowing lawns around town
total earnings for washing cars: $150.00 { subreport } total earnings for mowing lawns: $75.00
date name earnings source location ----------------------------------------------------------- 13-AUG-2008 John $95.00 dog walking downtown 13-AUG-2008 Jane $105.00 washing cars around town { main report } 13-AUG-2008 Dave $65.00 mowing lawns around town
total earnings for dog walking: $95.00 total earnings for washing cars: $105.00 { subreport } total earnings for mowing lawns: $65.00 In this example, the main report is grouped by 'date', but the totals are grouped additionally by 'source'. I've looked up examples of using running totals, but they don't really do what I need. Isn't there some way of storing the result set and having both the main report and the subreport reference the same data? | Hmm... as nice as it is to call the stored proc from the report and have it all contained in one location, however we found (like you) that you eventually hit a point where you can't get crystal to do what you want even tho the data is right there. We ended up introducing a business layer which sits under the report and rather than "pulling" data from the report we "push" the datasets to it and bind the data to the report. The advantage is that you can manipulate the data in code in datasets or objects before it reaches the report and then simply bind the data to the report. This article has a nice intro on how to setup pushing data to the reports. I understand that your time/business constraints may not allow you to do this, but if it's at all possible, I'd highly recommend it as it's meant we can remove all "coding" out of our reports and into managed code which is always a good thing. | Is there some way of recycling a Crystal Reports dataset? I'm trying to write a Crystal Report which has totals grouped in a different way to the main report. The only way I've been able to do this so far is to use a subreport for the totals, but it means having to hit the data source again to retrieve the same data, which seems like nonsense. Here's a simplified example: date name earnings source location ----------------------------------------------------------- 12-AUG-2008 Tom $50.00 washing cars uptown 12-AUG-2008 Dick $100.00 washing cars downtown { main report } 12-AUG-2008 Harry $75.00 mowing lawns around town
total earnings for washing cars: $150.00 { subreport } total earnings for mowing lawns: $75.00
date name earnings source location ----------------------------------------------------------- 13-AUG-2008 John $95.00 dog walking downtown 13-AUG-2008 Jane $105.00 washing cars around town { main report } 13-AUG-2008 Dave $65.00 mowing lawns around town
total earnings for dog walking: $95.00 total earnings for washing cars: $105.00 { subreport } total earnings for mowing lawns: $65.00 In this example, the main report is grouped by 'date', but the totals are grouped additionally by 'source'. I've looked up examples of using running totals, but they don't really do what I need. Isn't there some way of storing the result set and having both the main report and the subreport reference the same data? | TITLE:
Is there some way of recycling a Crystal Reports dataset?
QUESTION:
I'm trying to write a Crystal Report which has totals grouped in a different way to the main report. The only way I've been able to do this so far is to use a subreport for the totals, but it means having to hit the data source again to retrieve the same data, which seems like nonsense. Here's a simplified example: date name earnings source location ----------------------------------------------------------- 12-AUG-2008 Tom $50.00 washing cars uptown 12-AUG-2008 Dick $100.00 washing cars downtown { main report } 12-AUG-2008 Harry $75.00 mowing lawns around town
total earnings for washing cars: $150.00 { subreport } total earnings for mowing lawns: $75.00
date name earnings source location ----------------------------------------------------------- 13-AUG-2008 John $95.00 dog walking downtown 13-AUG-2008 Jane $105.00 washing cars around town { main report } 13-AUG-2008 Dave $65.00 mowing lawns around town
total earnings for dog walking: $95.00 total earnings for washing cars: $105.00 { subreport } total earnings for mowing lawns: $65.00 In this example, the main report is grouped by 'date', but the totals are grouped additionally by 'source'. I've looked up examples of using running totals, but they don't really do what I need. Isn't there some way of storing the result set and having both the main report and the subreport reference the same data?
ANSWER:
Hmm... as nice as it is to call the stored proc from the report and have it all contained in one location, however we found (like you) that you eventually hit a point where you can't get crystal to do what you want even tho the data is right there. We ended up introducing a business layer which sits under the report and rather than "pulling" data from the report we "push" the datasets to it and bind the data to the report. The advantage is that you can manipulate the data in code in datasets or objects before it reaches the report and then simply bind the data to the report. This article has a nice intro on how to setup pushing data to the reports. I understand that your time/business constraints may not allow you to do this, but if it's at all possible, I'd highly recommend it as it's meant we can remove all "coding" out of our reports and into managed code which is always a good thing. | [
"asp.net",
"crystal-reports",
"dataset"
] | 3 | 2 | 1,000 | 2 | 0 | 2008-08-12T10:54:54.330000 | 2008-08-12T23:29:57.007000 |
8,676 | 110,153 | Entity Framework vs LINQ to SQL | Now that.NET v3.5 SP1 has been released (along with VS2008 SP1), we now have access to the.NET entity framework. My question is this. When trying to decide between using the Entity Framework and LINQ to SQL as an ORM, what's the difference? The way I understand it, the Entity Framework (when used with LINQ to Entities) is a 'big brother' to LINQ to SQL? If this is the case - what advantages does it have? What can it do that LINQ to SQL can't do on its own? | LINQ to SQL only supports 1 to 1 mapping of database tables, views, sprocs and functions available in Microsoft SQL Server. It's a great API to use for quick data access construction to relatively well designed SQL Server databases. LINQ2SQL was first released with C# 3.0 and.Net Framework 3.5. LINQ to Entities (ADO.Net Entity Framework) is an ORM (Object Relational Mapper) API which allows for a broad definition of object domain models and their relationships to many different ADO.Net data providers. As such, you can mix and match a number of different database vendors, application servers or protocols to design an aggregated mash-up of objects which are constructed from a variety of tables, sources, services, etc. ADO.Net Framework was released with the.Net Framework 3.5 SP1. This is a good introductory article on MSDN: Introducing LINQ to Relational Data | Entity Framework vs LINQ to SQL Now that.NET v3.5 SP1 has been released (along with VS2008 SP1), we now have access to the.NET entity framework. My question is this. When trying to decide between using the Entity Framework and LINQ to SQL as an ORM, what's the difference? The way I understand it, the Entity Framework (when used with LINQ to Entities) is a 'big brother' to LINQ to SQL? If this is the case - what advantages does it have? What can it do that LINQ to SQL can't do on its own? | TITLE:
Entity Framework vs LINQ to SQL
QUESTION:
Now that.NET v3.5 SP1 has been released (along with VS2008 SP1), we now have access to the.NET entity framework. My question is this. When trying to decide between using the Entity Framework and LINQ to SQL as an ORM, what's the difference? The way I understand it, the Entity Framework (when used with LINQ to Entities) is a 'big brother' to LINQ to SQL? If this is the case - what advantages does it have? What can it do that LINQ to SQL can't do on its own?
ANSWER:
LINQ to SQL only supports 1 to 1 mapping of database tables, views, sprocs and functions available in Microsoft SQL Server. It's a great API to use for quick data access construction to relatively well designed SQL Server databases. LINQ2SQL was first released with C# 3.0 and.Net Framework 3.5. LINQ to Entities (ADO.Net Entity Framework) is an ORM (Object Relational Mapper) API which allows for a broad definition of object domain models and their relationships to many different ADO.Net data providers. As such, you can mix and match a number of different database vendors, application servers or protocols to design an aggregated mash-up of objects which are constructed from a variety of tables, sources, services, etc. ADO.Net Framework was released with the.Net Framework 3.5 SP1. This is a good introductory article on MSDN: Introducing LINQ to Relational Data | [
".net",
"entity-framework",
"linq-to-sql"
] | 868 | 495 | 292,932 | 17 | 0 | 2008-08-12T11:04:11.677000 | 2008-09-21T03:22:59.403000 |
8,681 | 9,269 | JQuery.Validate failure in Opera | If you're using Opera 9.5x you may notice that our client-side JQuery.Validate code is disabled here at Stack Overflow. function initValidation() { if (navigator.userAgent.indexOf("Opera")!= -1) return; $("#post-text").rules("add", { required: true, minlength: 5 }); } That's because it generates an exception in Opera! Of course it works in every other browser we've tried. I'm starting to seriously, seriously hate Opera. This is kind of a bummer because without proper client-side validation some of our requests will fail. We haven't had time to put in complete server-side messaging when data is incomplete, so you may see the YSOD on Opera much more than other browsers, if you forget to fill out all the fields on the form. Any Opera-ites want to uncomment those lines (they're on core Ask & Answer pages like this one -- just View Source and search for "Opera" ) and give it a go? | turns out the problem was in the { debug: true } option for the JQuery.Validate initializer. With this removed, things work fine in Opera. Thanks to Jörn Zaefferer for helping us figure this out! Oh, and the $50 will be donated to the JQuery project.:) | JQuery.Validate failure in Opera If you're using Opera 9.5x you may notice that our client-side JQuery.Validate code is disabled here at Stack Overflow. function initValidation() { if (navigator.userAgent.indexOf("Opera")!= -1) return; $("#post-text").rules("add", { required: true, minlength: 5 }); } That's because it generates an exception in Opera! Of course it works in every other browser we've tried. I'm starting to seriously, seriously hate Opera. This is kind of a bummer because without proper client-side validation some of our requests will fail. We haven't had time to put in complete server-side messaging when data is incomplete, so you may see the YSOD on Opera much more than other browsers, if you forget to fill out all the fields on the form. Any Opera-ites want to uncomment those lines (they're on core Ask & Answer pages like this one -- just View Source and search for "Opera" ) and give it a go? | TITLE:
JQuery.Validate failure in Opera
QUESTION:
If you're using Opera 9.5x you may notice that our client-side JQuery.Validate code is disabled here at Stack Overflow. function initValidation() { if (navigator.userAgent.indexOf("Opera")!= -1) return; $("#post-text").rules("add", { required: true, minlength: 5 }); } That's because it generates an exception in Opera! Of course it works in every other browser we've tried. I'm starting to seriously, seriously hate Opera. This is kind of a bummer because without proper client-side validation some of our requests will fail. We haven't had time to put in complete server-side messaging when data is incomplete, so you may see the YSOD on Opera much more than other browsers, if you forget to fill out all the fields on the form. Any Opera-ites want to uncomment those lines (they're on core Ask & Answer pages like this one -- just View Source and search for "Opera" ) and give it a go?
ANSWER:
turns out the problem was in the { debug: true } option for the JQuery.Validate initializer. With this removed, things work fine in Opera. Thanks to Jörn Zaefferer for helping us figure this out! Oh, and the $50 will be donated to the JQuery project.:) | [
"jquery",
"validation",
"opera"
] | 13 | 11 | 1,837 | 3 | 0 | 2008-08-12T11:11:29.680000 | 2008-08-12T21:41:17.363000 |
8,685 | 113,115 | Advancing through relative dates using strtotime() | I'm trying to use strtotime() to respond to a button click to advance -1 and +1 days (two buttons) relative to the day advanced to on the previous click. Example: It's the 10th of the month, I click "-1 day" button, and now the date reads as the 9th. I click the "-1 day" button again and now the readout states the 8th day. I click the "+1 day" button and now the readout states it's the 9th. I understand the buttons and the displaying the date and using $_GET and PHP to pass info, but how do I get strtotime() to work on the relative date from the last time the time travel script was called? My work so far has let me show yesterday and today relative to now but not relative to, for example, the day before yesterday, or the day after tomorrow. Or if I use my "last monday" button, the day before or after whatever that day is. | Working from previous calls to the same script isn't really a good idea for this type of thing. What you want to do is always pass two values to your script, the date, and the movement. (the below example is simplified so that you only pass the date, and it will always add one day to it) Example http://www.site.com/addOneDay.php?date=1999-12-31 Please note that you should check to make sure that isset($_GET[date]) before as well If you really want to work from previous calls to the same script, you're going to have to do it with sessions, so please specify if that is the case. | Advancing through relative dates using strtotime() I'm trying to use strtotime() to respond to a button click to advance -1 and +1 days (two buttons) relative to the day advanced to on the previous click. Example: It's the 10th of the month, I click "-1 day" button, and now the date reads as the 9th. I click the "-1 day" button again and now the readout states the 8th day. I click the "+1 day" button and now the readout states it's the 9th. I understand the buttons and the displaying the date and using $_GET and PHP to pass info, but how do I get strtotime() to work on the relative date from the last time the time travel script was called? My work so far has let me show yesterday and today relative to now but not relative to, for example, the day before yesterday, or the day after tomorrow. Or if I use my "last monday" button, the day before or after whatever that day is. | TITLE:
Advancing through relative dates using strtotime()
QUESTION:
I'm trying to use strtotime() to respond to a button click to advance -1 and +1 days (two buttons) relative to the day advanced to on the previous click. Example: It's the 10th of the month, I click "-1 day" button, and now the date reads as the 9th. I click the "-1 day" button again and now the readout states the 8th day. I click the "+1 day" button and now the readout states it's the 9th. I understand the buttons and the displaying the date and using $_GET and PHP to pass info, but how do I get strtotime() to work on the relative date from the last time the time travel script was called? My work so far has let me show yesterday and today relative to now but not relative to, for example, the day before yesterday, or the day after tomorrow. Or if I use my "last monday" button, the day before or after whatever that day is.
ANSWER:
Working from previous calls to the same script isn't really a good idea for this type of thing. What you want to do is always pass two values to your script, the date, and the movement. (the below example is simplified so that you only pass the date, and it will always add one day to it) Example http://www.site.com/addOneDay.php?date=1999-12-31 Please note that you should check to make sure that isset($_GET[date]) before as well If you really want to work from previous calls to the same script, you're going to have to do it with sessions, so please specify if that is the case. | [
"php",
"date",
"strtotime"
] | 7 | 6 | 2,827 | 3 | 0 | 2008-08-12T11:14:27.660000 | 2008-09-22T04:02:03.170000 |
8,688 | 12,447 | Install Visual Studio 2008 Sp1 on "D" Drive | I am trying to install VS2008 sp1 to my work machine - it has a pathetic 10Gb C drive. The SP1 bootstrapper doesn't give the option to install items to D, only C. It needs 3Gb free and the machine only has about 700Mb. VS allowed me to install to D originally why not the SP. The only thing I can think of that it requires system files installed in Windows etc, but I can't believe there are 3Gb worth of system files? | Worth a read: http://blogs.msdn.com/heaths/archive/2008/07/24/why-windows-installer-may-require-so-much-disk-space.aspx | Install Visual Studio 2008 Sp1 on "D" Drive I am trying to install VS2008 sp1 to my work machine - it has a pathetic 10Gb C drive. The SP1 bootstrapper doesn't give the option to install items to D, only C. It needs 3Gb free and the machine only has about 700Mb. VS allowed me to install to D originally why not the SP. The only thing I can think of that it requires system files installed in Windows etc, but I can't believe there are 3Gb worth of system files? | TITLE:
Install Visual Studio 2008 Sp1 on "D" Drive
QUESTION:
I am trying to install VS2008 sp1 to my work machine - it has a pathetic 10Gb C drive. The SP1 bootstrapper doesn't give the option to install items to D, only C. It needs 3Gb free and the machine only has about 700Mb. VS allowed me to install to D originally why not the SP. The only thing I can think of that it requires system files installed in Windows etc, but I can't believe there are 3Gb worth of system files?
ANSWER:
Worth a read: http://blogs.msdn.com/heaths/archive/2008/07/24/why-windows-installer-may-require-so-much-disk-space.aspx | [
"visual-studio",
"visual-studio-2008",
"visual-studio-2008-sp1"
] | 4 | 4 | 11,849 | 9 | 0 | 2008-08-12T11:20:43.887000 | 2008-08-15T16:27:40.600000 |
8,691 | 8,706 | User Control Property Designer Properties | For a C# UserControl on Windows Mobile (though please answer if you know it for full Windows...it might work) how do you change what shows up in the Designer Properties window for one of the Control's public Properties. For example: private Color blah = Color.Black;
public Color Blah { get { return this.blah; } set { this.blah = value; } } This shows up for the control, but it's in the "Misc" category and has no description or default value. I've tried using the settings in System.ComponentModel like "DesignerCategory", such as: [DesignerCategory("Custom")] But says this is only valid for class declarations... could've sworn it was the System.ComponentModel items I used before... Update: @John said: DesignerCatogy is used to say if the class is a form, component etc. Try this: [Category("Custom")] Is there a particular namespace I need to use in order to get those? I've tried those exactly and the compiler doesn't recognize them. In.NETCF all I seem to have available from System.ComponentModel is: DataObject, DataObjectMethod, DefaultValue, DesignerCategory, DesignTimeVisible, EditorBrowsable The only one it doesn't scream at is EditorBrowsable | Is this of use to you? I am not into CF development, but it looks like you need to add some XML metadata to enable it: http://blogs.msdn.com/bluecollar/archive/2007/02/08/adding-compact-framework-design-time-attributes-or-more-fun-with-textboxes.aspx Interesting read.. Looks like a lot of design time support was stripped out of CF because you dont design them on the devices.. Which seems kinda weird to me.. Cant imagine using a handheld as a development rig! Scroll down about half way for the good stuff;) | User Control Property Designer Properties For a C# UserControl on Windows Mobile (though please answer if you know it for full Windows...it might work) how do you change what shows up in the Designer Properties window for one of the Control's public Properties. For example: private Color blah = Color.Black;
public Color Blah { get { return this.blah; } set { this.blah = value; } } This shows up for the control, but it's in the "Misc" category and has no description or default value. I've tried using the settings in System.ComponentModel like "DesignerCategory", such as: [DesignerCategory("Custom")] But says this is only valid for class declarations... could've sworn it was the System.ComponentModel items I used before... Update: @John said: DesignerCatogy is used to say if the class is a form, component etc. Try this: [Category("Custom")] Is there a particular namespace I need to use in order to get those? I've tried those exactly and the compiler doesn't recognize them. In.NETCF all I seem to have available from System.ComponentModel is: DataObject, DataObjectMethod, DefaultValue, DesignerCategory, DesignTimeVisible, EditorBrowsable The only one it doesn't scream at is EditorBrowsable | TITLE:
User Control Property Designer Properties
QUESTION:
For a C# UserControl on Windows Mobile (though please answer if you know it for full Windows...it might work) how do you change what shows up in the Designer Properties window for one of the Control's public Properties. For example: private Color blah = Color.Black;
public Color Blah { get { return this.blah; } set { this.blah = value; } } This shows up for the control, but it's in the "Misc" category and has no description or default value. I've tried using the settings in System.ComponentModel like "DesignerCategory", such as: [DesignerCategory("Custom")] But says this is only valid for class declarations... could've sworn it was the System.ComponentModel items I used before... Update: @John said: DesignerCatogy is used to say if the class is a form, component etc. Try this: [Category("Custom")] Is there a particular namespace I need to use in order to get those? I've tried those exactly and the compiler doesn't recognize them. In.NETCF all I seem to have available from System.ComponentModel is: DataObject, DataObjectMethod, DefaultValue, DesignerCategory, DesignTimeVisible, EditorBrowsable The only one it doesn't scream at is EditorBrowsable
ANSWER:
Is this of use to you? I am not into CF development, but it looks like you need to add some XML metadata to enable it: http://blogs.msdn.com/bluecollar/archive/2007/02/08/adding-compact-framework-design-time-attributes-or-more-fun-with-textboxes.aspx Interesting read.. Looks like a lot of design time support was stripped out of CF because you dont design them on the devices.. Which seems kinda weird to me.. Cant imagine using a handheld as a development rig! Scroll down about half way for the good stuff;) | [
"c#",
"user-controls",
"windows-mobile"
] | 10 | 4 | 15,351 | 3 | 0 | 2008-08-12T11:25:41.227000 | 2008-08-12T11:51:49.753000 |
8,704 | 192,733 | Final managed exception handler in a mixed native/managed executable? | I have an MFC application compiled with /clr and I'm trying to implement a final handler for otherwise un-caught managed exceptions. For native exceptions, overriding CWinApp::ProcessWndProcException works. The two events suggested in Jeff's CodeProject article, Application.ThreadException and AppDomain.CurrentDomain.UnhandledException, are not raised. Can anyone suggest a way to provide a final managed exception handler for a mixed executable? Update: It appears that these exception handlers are only triggered downstream of Application.Run or similar (there's a worker thread flavor, can't remember the name.) If you want to truly globally catch a managed exception you do need to install an SEH filter. You're not going to get a System.Exception and if you want a callstack you're going to have to roll your own walker. In an MSDN forum question on this topic it was suggested to override a sufficiently low-level point of the main MFC thread in a try... catch (Exception^). For instance, CWinApp::Run. This may be a good solution but I haven't looked at any perf or stability implications. You'll get a chance to log with a call stack before you bail and you can avoid the default windows unahndled exception behavior. | Taking a look around the internets, you'll find that you need to install a filter to get the unmanaged exceptions passing the filters on their way to your AppDomain. From CLR and Unhandled Exception Filters: The CLR relies on the SEH unhandled exception filter mechanism to catch unhandled exceptions. | Final managed exception handler in a mixed native/managed executable? I have an MFC application compiled with /clr and I'm trying to implement a final handler for otherwise un-caught managed exceptions. For native exceptions, overriding CWinApp::ProcessWndProcException works. The two events suggested in Jeff's CodeProject article, Application.ThreadException and AppDomain.CurrentDomain.UnhandledException, are not raised. Can anyone suggest a way to provide a final managed exception handler for a mixed executable? Update: It appears that these exception handlers are only triggered downstream of Application.Run or similar (there's a worker thread flavor, can't remember the name.) If you want to truly globally catch a managed exception you do need to install an SEH filter. You're not going to get a System.Exception and if you want a callstack you're going to have to roll your own walker. In an MSDN forum question on this topic it was suggested to override a sufficiently low-level point of the main MFC thread in a try... catch (Exception^). For instance, CWinApp::Run. This may be a good solution but I haven't looked at any perf or stability implications. You'll get a chance to log with a call stack before you bail and you can avoid the default windows unahndled exception behavior. | TITLE:
Final managed exception handler in a mixed native/managed executable?
QUESTION:
I have an MFC application compiled with /clr and I'm trying to implement a final handler for otherwise un-caught managed exceptions. For native exceptions, overriding CWinApp::ProcessWndProcException works. The two events suggested in Jeff's CodeProject article, Application.ThreadException and AppDomain.CurrentDomain.UnhandledException, are not raised. Can anyone suggest a way to provide a final managed exception handler for a mixed executable? Update: It appears that these exception handlers are only triggered downstream of Application.Run or similar (there's a worker thread flavor, can't remember the name.) If you want to truly globally catch a managed exception you do need to install an SEH filter. You're not going to get a System.Exception and if you want a callstack you're going to have to roll your own walker. In an MSDN forum question on this topic it was suggested to override a sufficiently low-level point of the main MFC thread in a try... catch (Exception^). For instance, CWinApp::Run. This may be a good solution but I haven't looked at any perf or stability implications. You'll get a chance to log with a call stack before you bail and you can avoid the default windows unahndled exception behavior.
ANSWER:
Taking a look around the internets, you'll find that you need to install a filter to get the unmanaged exceptions passing the filters on their way to your AppDomain. From CLR and Unhandled Exception Filters: The CLR relies on the SEH unhandled exception filter mechanism to catch unhandled exceptions. | [
"exception",
"executable",
"mixed",
"unhandled"
] | 7 | 2 | 2,007 | 3 | 0 | 2008-08-12T11:48:52.850000 | 2008-10-10T19:25:41.983000 |
8,726 | 8,794 | Checking FTP status codes with a PHP script | I have a script that checks responses from HTTP servers using the PEAR HTTP classes. However, I've recently found that the script fails on FTP servers (and probably anything that's not HTTP or HTTPS). I tried Google, but didn't see any scripts or code that returned the server status code from servers other than HTTP servers. How can I find out the status of a newsgroup or FTP server using PHP? EDIT: I should clarify that I am interested only in the ability to read from an FTP server and the directory that I specify. I need to know if the server is dead/gone, I'm not authorized to read, etc. Please note that, although most of the time I'm language agnostic, the entire website is PHP-driven, so a PHP solution would be the best for easy of maintainability and extensibility in the future. | HTTP works slightly differently than FTP though unfortunately. Although both may look the same in your browser, HTTP works off the basis of URI (i.e. to access resource A, you have an identifier which tells you how to access that). FTP is very old school server driven. Even anonymous FTP is a bit of a hack, since you still supply a username and password, it's just defined as "anonymous" and your email address. Checking if an FTP server is up means checking That you can connect to the FTP server if (!($ftpfd = ftp_connect($hostname))) {... } That you can login to the server: if (!ftp_login($ftpfd, $username, $password)) {... } Then, if there are further underlying resources that you need to access to test whether a particular site is up, then use an appropiate operation on them. e.g. on a file, maybe use ftp_mdtm() to get the last modified time or on a directory, see if ftp_nlist() works. | Checking FTP status codes with a PHP script I have a script that checks responses from HTTP servers using the PEAR HTTP classes. However, I've recently found that the script fails on FTP servers (and probably anything that's not HTTP or HTTPS). I tried Google, but didn't see any scripts or code that returned the server status code from servers other than HTTP servers. How can I find out the status of a newsgroup or FTP server using PHP? EDIT: I should clarify that I am interested only in the ability to read from an FTP server and the directory that I specify. I need to know if the server is dead/gone, I'm not authorized to read, etc. Please note that, although most of the time I'm language agnostic, the entire website is PHP-driven, so a PHP solution would be the best for easy of maintainability and extensibility in the future. | TITLE:
Checking FTP status codes with a PHP script
QUESTION:
I have a script that checks responses from HTTP servers using the PEAR HTTP classes. However, I've recently found that the script fails on FTP servers (and probably anything that's not HTTP or HTTPS). I tried Google, but didn't see any scripts or code that returned the server status code from servers other than HTTP servers. How can I find out the status of a newsgroup or FTP server using PHP? EDIT: I should clarify that I am interested only in the ability to read from an FTP server and the directory that I specify. I need to know if the server is dead/gone, I'm not authorized to read, etc. Please note that, although most of the time I'm language agnostic, the entire website is PHP-driven, so a PHP solution would be the best for easy of maintainability and extensibility in the future.
ANSWER:
HTTP works slightly differently than FTP though unfortunately. Although both may look the same in your browser, HTTP works off the basis of URI (i.e. to access resource A, you have an identifier which tells you how to access that). FTP is very old school server driven. Even anonymous FTP is a bit of a hack, since you still supply a username and password, it's just defined as "anonymous" and your email address. Checking if an FTP server is up means checking That you can connect to the FTP server if (!($ftpfd = ftp_connect($hostname))) {... } That you can login to the server: if (!ftp_login($ftpfd, $username, $password)) {... } Then, if there are further underlying resources that you need to access to test whether a particular site is up, then use an appropiate operation on them. e.g. on a file, maybe use ftp_mdtm() to get the last modified time or on a directory, see if ftp_nlist() works. | [
"php",
"http",
"ftp",
"pear",
"server-response"
] | 7 | 4 | 2,999 | 3 | 0 | 2008-08-12T12:07:15.557000 | 2008-08-12T13:07:00.117000 |
8,728 | 161,214 | Delphi MDI Application and the titlebar of the MDI Children | I've got an MDI application written in Delphi 2006 which runs XP with the default theme. Is there a way of controlling the appearance of the MDI Children to avoid the large XP-style title bar on each window? I've tried setting the BorderStyle of the MDIChildren to bsSizeToolWin but they are still rendered as normal Forms. | All your need - overload procedure CreateWindowHandle, like this: unit CHILDWIN; interface uses Windows, Classes, Graphics, Forms, Controls, StdCtrls;
type TMDIChild = class(TForm) private { Private declarations } public { Public declarations } procedure CreateWindowHandle(const Params: TCreateParams); override; end;
implementation
{$R *.dfm} procedure TMDIChild.CreateWindowHandle(const Params: TCreateParams); begin inherited CreateWindowHandle(Params); SetWindowLong(Handle, GWL_EXSTYLE, WS_EX_TOOLWINDOW); end; end. | Delphi MDI Application and the titlebar of the MDI Children I've got an MDI application written in Delphi 2006 which runs XP with the default theme. Is there a way of controlling the appearance of the MDI Children to avoid the large XP-style title bar on each window? I've tried setting the BorderStyle of the MDIChildren to bsSizeToolWin but they are still rendered as normal Forms. | TITLE:
Delphi MDI Application and the titlebar of the MDI Children
QUESTION:
I've got an MDI application written in Delphi 2006 which runs XP with the default theme. Is there a way of controlling the appearance of the MDI Children to avoid the large XP-style title bar on each window? I've tried setting the BorderStyle of the MDIChildren to bsSizeToolWin but they are still rendered as normal Forms.
ANSWER:
All your need - overload procedure CreateWindowHandle, like this: unit CHILDWIN; interface uses Windows, Classes, Graphics, Forms, Controls, StdCtrls;
type TMDIChild = class(TForm) private { Private declarations } public { Public declarations } procedure CreateWindowHandle(const Params: TCreateParams); override; end;
implementation
{$R *.dfm} procedure TMDIChild.CreateWindowHandle(const Params: TCreateParams); begin inherited CreateWindowHandle(Params); SetWindowLong(Handle, GWL_EXSTYLE, WS_EX_TOOLWINDOW); end; end. | [
"delphi",
"forms",
"mdi"
] | 4 | 6 | 5,718 | 4 | 0 | 2008-08-12T12:10:14.663000 | 2008-10-02T07:33:43.147000 |
8,742 | 8,764 | Getting accurate ticks from a timer in C# | I'm trying to rebuild an old metronome application that was originally written using MFC in C++ to be written in.NET using C#. One of the issues I'm running into is getting the timer to "tick" accurately enough. For example, assuming an easy BPM (beats per minute) of 120, the timer should tick every.5 seconds (or 500 milliseconds). Using this as the basis for the ticks, however, isn't entirely accurate as.NET only guarantees that your timer will not tick before the elapsed time has passed. Currently, to get around this for the same 120 BPM example used above, I am setting the ticks to something like 100 milliseconds and only playing the click sound on every 5th timer tick. This does improve the accuracy quite a bit, but if feels like a bit of a hack. So, what is the best way to get accurate ticks? I know there are more timers available than the windows forms timer that is readily available in Visual Studio, but I'm not really familiar with them. | There are three timer classes called 'Timer' in.NET. It sounds like you're using the Windows Forms one, but actually you might find the System.Threading.Timer class more useful - but be careful because it calls back on a pool thread, so you can't directly interact with your form from the callback. Another approach might be to p/invoke to the Win32 multimedia timers - timeGetTime, timeSetPeriod, etc. A quick google found this, which might be useful http://www.codeproject.com/KB/miscctrl/lescsmultimediatimer.aspx 'Multimedia' (timer) is the buzz-word to search for in this context. | Getting accurate ticks from a timer in C# I'm trying to rebuild an old metronome application that was originally written using MFC in C++ to be written in.NET using C#. One of the issues I'm running into is getting the timer to "tick" accurately enough. For example, assuming an easy BPM (beats per minute) of 120, the timer should tick every.5 seconds (or 500 milliseconds). Using this as the basis for the ticks, however, isn't entirely accurate as.NET only guarantees that your timer will not tick before the elapsed time has passed. Currently, to get around this for the same 120 BPM example used above, I am setting the ticks to something like 100 milliseconds and only playing the click sound on every 5th timer tick. This does improve the accuracy quite a bit, but if feels like a bit of a hack. So, what is the best way to get accurate ticks? I know there are more timers available than the windows forms timer that is readily available in Visual Studio, but I'm not really familiar with them. | TITLE:
Getting accurate ticks from a timer in C#
QUESTION:
I'm trying to rebuild an old metronome application that was originally written using MFC in C++ to be written in.NET using C#. One of the issues I'm running into is getting the timer to "tick" accurately enough. For example, assuming an easy BPM (beats per minute) of 120, the timer should tick every.5 seconds (or 500 milliseconds). Using this as the basis for the ticks, however, isn't entirely accurate as.NET only guarantees that your timer will not tick before the elapsed time has passed. Currently, to get around this for the same 120 BPM example used above, I am setting the ticks to something like 100 milliseconds and only playing the click sound on every 5th timer tick. This does improve the accuracy quite a bit, but if feels like a bit of a hack. So, what is the best way to get accurate ticks? I know there are more timers available than the windows forms timer that is readily available in Visual Studio, but I'm not really familiar with them.
ANSWER:
There are three timer classes called 'Timer' in.NET. It sounds like you're using the Windows Forms one, but actually you might find the System.Threading.Timer class more useful - but be careful because it calls back on a pool thread, so you can't directly interact with your form from the callback. Another approach might be to p/invoke to the Win32 multimedia timers - timeGetTime, timeSetPeriod, etc. A quick google found this, which might be useful http://www.codeproject.com/KB/miscctrl/lescsmultimediatimer.aspx 'Multimedia' (timer) is the buzz-word to search for in this context. | [
".net",
"timer"
] | 16 | 11 | 17,262 | 6 | 0 | 2008-08-12T12:20:29.853000 | 2008-08-12T12:34:43.443000 |
8,747 | 8,767 | Learning Version Control, and learning it well | Where should I start learning about version control systems? I've used SVN, Team Foundation, and Sourcesafe in the past but I don't really feel like I grasp it completely, and my team doesn't seem to grasp it either. Which points are the most important to master? I realise this differs from VCS to VCS, but for the sake of this question we can assume that Subversion is the VCS I'm the most interested in learning about. Also, if you could, please recommend any books on the subject that you find useful. | The wikipedia article on Revision Control is a great place to start Revision control When trying to teach my colleagues, I found getting him to understand the vocabulary at the end was a great way to start to introduce him to source code control techniques. Don't know what a branch is? Go find out and how they work:) There's a free online subversion book at Version Control with Subversion which provides an invaluable reference. | Learning Version Control, and learning it well Where should I start learning about version control systems? I've used SVN, Team Foundation, and Sourcesafe in the past but I don't really feel like I grasp it completely, and my team doesn't seem to grasp it either. Which points are the most important to master? I realise this differs from VCS to VCS, but for the sake of this question we can assume that Subversion is the VCS I'm the most interested in learning about. Also, if you could, please recommend any books on the subject that you find useful. | TITLE:
Learning Version Control, and learning it well
QUESTION:
Where should I start learning about version control systems? I've used SVN, Team Foundation, and Sourcesafe in the past but I don't really feel like I grasp it completely, and my team doesn't seem to grasp it either. Which points are the most important to master? I realise this differs from VCS to VCS, but for the sake of this question we can assume that Subversion is the VCS I'm the most interested in learning about. Also, if you could, please recommend any books on the subject that you find useful.
ANSWER:
The wikipedia article on Revision Control is a great place to start Revision control When trying to teach my colleagues, I found getting him to understand the vocabulary at the end was a great way to start to introduce him to source code control techniques. Don't know what a branch is? Go find out and how they work:) There's a free online subversion book at Version Control with Subversion which provides an invaluable reference. | [
"svn",
"version-control"
] | 19 | 10 | 4,964 | 13 | 0 | 2008-08-12T12:24:11.733000 | 2008-08-12T12:35:51.740000 |
8,756 | 8,776 | iPhone web applications, templates, frameworks? | Does anyone have any good starting points for me when looking at making web pages/sites/applications specifically for viewing on the iPhone? I've looked at templates like the one Joe Hewitt has made, and also seen some templates I can purchase, which I haven't done yet. I figured someone else had already started on this track and decided that I could probably leech on their newfound knowledge:) So, does anyone have any pointers? I'm well aware of the problem that the more such a template/framework makes a web app look like a native iPhone app, the more likely I'm going to get into trouble because it just isn't, but for now I want a framework I can start building on, and then in the process figure out how to make it distinctive enough to be perceived as a web app as well as looking like a native iPhone application. Specifically I'm looking for features like: stylesheets set up, or pointers to how to do them for iPhone page flipping animation, ie. pick an item in a list, list scrolls out of view to the left and information for item scrolls in from the right the animation part would have to work with dynamic pages, ie. not just one big page that has divs set up for each sub-item, which at least one such framework had as a sort of quick fix, I would need to have list item picking load the page for that item, and then when loaded, scroll to it Edit: To avoid people reading only the question and answering, before reading my other reply, I'll add my clarification for GPL licensing and similar issues here. The framework I need to use can not be distributed under a license which would require me to license my own project out under a similar license. The GPL family of licenses allows for exceptions regarding library usage, but this won't apply to this since by necessity, the kind of framework I would need to use would be all source code. The project can easily accomodate commercial libraries. Also, I don't need a library or a framework as such, example files that look good and aren't overly obfuscated would be welcome as well. | I found iphone-universal on Google Code the other day. Haven't had a chance to try it out but it looks promising. | iPhone web applications, templates, frameworks? Does anyone have any good starting points for me when looking at making web pages/sites/applications specifically for viewing on the iPhone? I've looked at templates like the one Joe Hewitt has made, and also seen some templates I can purchase, which I haven't done yet. I figured someone else had already started on this track and decided that I could probably leech on their newfound knowledge:) So, does anyone have any pointers? I'm well aware of the problem that the more such a template/framework makes a web app look like a native iPhone app, the more likely I'm going to get into trouble because it just isn't, but for now I want a framework I can start building on, and then in the process figure out how to make it distinctive enough to be perceived as a web app as well as looking like a native iPhone application. Specifically I'm looking for features like: stylesheets set up, or pointers to how to do them for iPhone page flipping animation, ie. pick an item in a list, list scrolls out of view to the left and information for item scrolls in from the right the animation part would have to work with dynamic pages, ie. not just one big page that has divs set up for each sub-item, which at least one such framework had as a sort of quick fix, I would need to have list item picking load the page for that item, and then when loaded, scroll to it Edit: To avoid people reading only the question and answering, before reading my other reply, I'll add my clarification for GPL licensing and similar issues here. The framework I need to use can not be distributed under a license which would require me to license my own project out under a similar license. The GPL family of licenses allows for exceptions regarding library usage, but this won't apply to this since by necessity, the kind of framework I would need to use would be all source code. The project can easily accomodate commercial libraries. Also, I don't need a library or a framework as such, example files that look good and aren't overly obfuscated would be welcome as well. | TITLE:
iPhone web applications, templates, frameworks?
QUESTION:
Does anyone have any good starting points for me when looking at making web pages/sites/applications specifically for viewing on the iPhone? I've looked at templates like the one Joe Hewitt has made, and also seen some templates I can purchase, which I haven't done yet. I figured someone else had already started on this track and decided that I could probably leech on their newfound knowledge:) So, does anyone have any pointers? I'm well aware of the problem that the more such a template/framework makes a web app look like a native iPhone app, the more likely I'm going to get into trouble because it just isn't, but for now I want a framework I can start building on, and then in the process figure out how to make it distinctive enough to be perceived as a web app as well as looking like a native iPhone application. Specifically I'm looking for features like: stylesheets set up, or pointers to how to do them for iPhone page flipping animation, ie. pick an item in a list, list scrolls out of view to the left and information for item scrolls in from the right the animation part would have to work with dynamic pages, ie. not just one big page that has divs set up for each sub-item, which at least one such framework had as a sort of quick fix, I would need to have list item picking load the page for that item, and then when loaded, scroll to it Edit: To avoid people reading only the question and answering, before reading my other reply, I'll add my clarification for GPL licensing and similar issues here. The framework I need to use can not be distributed under a license which would require me to license my own project out under a similar license. The GPL family of licenses allows for exceptions regarding library usage, but this won't apply to this since by necessity, the kind of framework I would need to use would be all source code. The project can easily accomodate commercial libraries. Also, I don't need a library or a framework as such, example files that look good and aren't overly obfuscated would be welcome as well.
ANSWER:
I found iphone-universal on Google Code the other day. Haven't had a chance to try it out but it looks promising. | [
"iphone",
"web-applications",
"dashcode"
] | 22 | 5 | 20,890 | 9 | 0 | 2008-08-12T12:29:32.017000 | 2008-08-12T12:45:01.550000 |
8,761 | 8,804 | Find out which colours are in use when using the MFC Feature pack in Office 2007 style | I'm updating some of our legacy C++ code to use the "MFC feature pack" that Microsoft released for Visual Studio 2008. We've used the new classes to derive our application from CFrameWndEx, and are applying the Office 2007 styles to give our application a more modern appearance. This gives us gradient filled window titles, status bars etc, and the use of the ribbon toolbars. However, our application contains some owner drawn controls, and I'd like to update these to match the color scheme used by the feature pack. Ideally I'd like to know the light and shaded toolbar colors that are currently in use. I've had a hunt around the documentation and web and have not yet found anything. Does anyone know how to find this information out? [Edit] In particular we need to find out which colors are being used at runtime. You can change the appearance of your application at runtime using the new static function CMFCVisualManager::SetDefaultManager. The following msdn page shows you what kind of styles are available, in particular the Office2007 look: link to msdn | Have you looked in the MFC source code, which you'll find in something like C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\src\mfc | Find out which colours are in use when using the MFC Feature pack in Office 2007 style I'm updating some of our legacy C++ code to use the "MFC feature pack" that Microsoft released for Visual Studio 2008. We've used the new classes to derive our application from CFrameWndEx, and are applying the Office 2007 styles to give our application a more modern appearance. This gives us gradient filled window titles, status bars etc, and the use of the ribbon toolbars. However, our application contains some owner drawn controls, and I'd like to update these to match the color scheme used by the feature pack. Ideally I'd like to know the light and shaded toolbar colors that are currently in use. I've had a hunt around the documentation and web and have not yet found anything. Does anyone know how to find this information out? [Edit] In particular we need to find out which colors are being used at runtime. You can change the appearance of your application at runtime using the new static function CMFCVisualManager::SetDefaultManager. The following msdn page shows you what kind of styles are available, in particular the Office2007 look: link to msdn | TITLE:
Find out which colours are in use when using the MFC Feature pack in Office 2007 style
QUESTION:
I'm updating some of our legacy C++ code to use the "MFC feature pack" that Microsoft released for Visual Studio 2008. We've used the new classes to derive our application from CFrameWndEx, and are applying the Office 2007 styles to give our application a more modern appearance. This gives us gradient filled window titles, status bars etc, and the use of the ribbon toolbars. However, our application contains some owner drawn controls, and I'd like to update these to match the color scheme used by the feature pack. Ideally I'd like to know the light and shaded toolbar colors that are currently in use. I've had a hunt around the documentation and web and have not yet found anything. Does anyone know how to find this information out? [Edit] In particular we need to find out which colors are being used at runtime. You can change the appearance of your application at runtime using the new static function CMFCVisualManager::SetDefaultManager. The following msdn page shows you what kind of styles are available, in particular the Office2007 look: link to msdn
ANSWER:
Have you looked in the MFC source code, which you'll find in something like C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\src\mfc | [
"colors",
"mfc-feature-pack"
] | 4 | 1 | 4,580 | 9 | 0 | 2008-08-12T12:33:10.857000 | 2008-08-12T13:14:00.273000 |
8,763 | 8,777 | Best way to play MIDI sounds using C# | I'm trying to rebuild an old metronome application that was originally written using MFC in C++ to be written in.NET using C#. One of the issues I'm running into is playing the midi files that are used to represent the metronome "clicks". I've found a few articles online about playing MIDI in.NET, but most of them seem to rely on custom libraries that someone has cobbled together and made available. I'm not averse to using these, but I'd rather understand for myself how this is being done, since it seems like it should be a mostly trivial exercise. So, am I missing something? Or is it just difficult to use MIDI inside of a.NET application? | I think you'll need to p/invoke out to the windows api to be able to play midi files from.net. This codeproject article does a good job on explaining how to do this: vb.net article to play midi files To rewrite this is c# you'd need the following import statement for mciSendString: [DllImport("winmm.dll")] static extern Int32 mciSendString(String command, StringBuilder buffer, Int32 bufferSize, IntPtr hwndCallback); Hope this helps - good luck! | Best way to play MIDI sounds using C# I'm trying to rebuild an old metronome application that was originally written using MFC in C++ to be written in.NET using C#. One of the issues I'm running into is playing the midi files that are used to represent the metronome "clicks". I've found a few articles online about playing MIDI in.NET, but most of them seem to rely on custom libraries that someone has cobbled together and made available. I'm not averse to using these, but I'd rather understand for myself how this is being done, since it seems like it should be a mostly trivial exercise. So, am I missing something? Or is it just difficult to use MIDI inside of a.NET application? | TITLE:
Best way to play MIDI sounds using C#
QUESTION:
I'm trying to rebuild an old metronome application that was originally written using MFC in C++ to be written in.NET using C#. One of the issues I'm running into is playing the midi files that are used to represent the metronome "clicks". I've found a few articles online about playing MIDI in.NET, but most of them seem to rely on custom libraries that someone has cobbled together and made available. I'm not averse to using these, but I'd rather understand for myself how this is being done, since it seems like it should be a mostly trivial exercise. So, am I missing something? Or is it just difficult to use MIDI inside of a.NET application?
ANSWER:
I think you'll need to p/invoke out to the windows api to be able to play midi files from.net. This codeproject article does a good job on explaining how to do this: vb.net article to play midi files To rewrite this is c# you'd need the following import statement for mciSendString: [DllImport("winmm.dll")] static extern Int32 mciSendString(String command, StringBuilder buffer, Int32 bufferSize, IntPtr hwndCallback); Hope this helps - good luck! | [
"c#",
".net",
"midi"
] | 20 | 10 | 38,845 | 11 | 0 | 2008-08-12T12:34:07.733000 | 2008-08-12T12:46:31.750000 |
8,790 | 8,805 | Ant build scripts, antcall, dependencies, etc | I have a build script and as part of that script it copies a jar file to a directory, for ease lets call it the utils jar. the utils jar is built by another build script sitting in another directory. What im trying to do have my build script run the utils build script so that I can ensure the utils jar is up to date. So I know I need to import the utils build file. Which doesn't work because the import task, unlike almost every other ant taks, doesn't run from basedir, it runs from the pwd. So to get around that I have this little ditty, which does successfully import the build file So now that ive solved my import problem I need to call the task, well that should be easy right: note that in the above, utils is the project name of../utils/build/build.xml the problem I'm now running into is that ant call doesn't execute in../utils/build so what I need, and cant find, is a runat property or something similar, essentially: The reason I need this is that in my utils build file the step to select which code to copy to the jar is based on relative paths so as to avoid hardcoding paths in my ant file. Any ideas? | I've got something similar set up: I have a main Ant build.xml which calls a separate build.xml that takes care of building my tests. This is how I do it: The trick is to use subant instead of antcall. You don't have to import the other build file. | Ant build scripts, antcall, dependencies, etc I have a build script and as part of that script it copies a jar file to a directory, for ease lets call it the utils jar. the utils jar is built by another build script sitting in another directory. What im trying to do have my build script run the utils build script so that I can ensure the utils jar is up to date. So I know I need to import the utils build file. Which doesn't work because the import task, unlike almost every other ant taks, doesn't run from basedir, it runs from the pwd. So to get around that I have this little ditty, which does successfully import the build file So now that ive solved my import problem I need to call the task, well that should be easy right: note that in the above, utils is the project name of../utils/build/build.xml the problem I'm now running into is that ant call doesn't execute in../utils/build so what I need, and cant find, is a runat property or something similar, essentially: The reason I need this is that in my utils build file the step to select which code to copy to the jar is based on relative paths so as to avoid hardcoding paths in my ant file. Any ideas? | TITLE:
Ant build scripts, antcall, dependencies, etc
QUESTION:
I have a build script and as part of that script it copies a jar file to a directory, for ease lets call it the utils jar. the utils jar is built by another build script sitting in another directory. What im trying to do have my build script run the utils build script so that I can ensure the utils jar is up to date. So I know I need to import the utils build file. Which doesn't work because the import task, unlike almost every other ant taks, doesn't run from basedir, it runs from the pwd. So to get around that I have this little ditty, which does successfully import the build file So now that ive solved my import problem I need to call the task, well that should be easy right: note that in the above, utils is the project name of../utils/build/build.xml the problem I'm now running into is that ant call doesn't execute in../utils/build so what I need, and cant find, is a runat property or something similar, essentially: The reason I need this is that in my utils build file the step to select which code to copy to the jar is based on relative paths so as to avoid hardcoding paths in my ant file. Any ideas?
ANSWER:
I've got something similar set up: I have a main Ant build.xml which calls a separate build.xml that takes care of building my tests. This is how I do it: The trick is to use subant instead of antcall. You don't have to import the other build file. | [
"ant",
"build-process"
] | 27 | 33 | 23,719 | 3 | 0 | 2008-08-12T13:04:28.890000 | 2008-08-12T13:14:50.273000 |
8,795 | 8,859 | Is there any list datatype in MySQL stored procedures, or a way to emulate them? | I would like to create a stored procedure in MySQL that took a list as argument. For example, say that I would like to be able to set multiple tags for an item in one call, then what I want to do is to define a procedure that takes the ID of the item and a list of tags to set. However, I can't seem to find any way to do this, there is no list datatype, as far as I'm aware, but can it be emulated somehow? Could the list of tags be a comma-separated string, which can somehow be split and looped over? How do you usually work with lists in MySQL stored procedures? | This article has some good discussion on the problem of parsing an array to a stored procedure since stored procedures only allow valid table column data-types as parameters. There are some neat things you can do with the csv table type in mysql - that is if you are loading a flat file into the db. You could create a temporary table in the stored procedure, iterate over the csv list and insert it to the temp table, then create a cursor which selects the values from that table. This answer in the above mentioned thread shows a way of doing this. Generally I would split the array before I come to the database and then perform the query individually on each item. | Is there any list datatype in MySQL stored procedures, or a way to emulate them? I would like to create a stored procedure in MySQL that took a list as argument. For example, say that I would like to be able to set multiple tags for an item in one call, then what I want to do is to define a procedure that takes the ID of the item and a list of tags to set. However, I can't seem to find any way to do this, there is no list datatype, as far as I'm aware, but can it be emulated somehow? Could the list of tags be a comma-separated string, which can somehow be split and looped over? How do you usually work with lists in MySQL stored procedures? | TITLE:
Is there any list datatype in MySQL stored procedures, or a way to emulate them?
QUESTION:
I would like to create a stored procedure in MySQL that took a list as argument. For example, say that I would like to be able to set multiple tags for an item in one call, then what I want to do is to define a procedure that takes the ID of the item and a list of tags to set. However, I can't seem to find any way to do this, there is no list datatype, as far as I'm aware, but can it be emulated somehow? Could the list of tags be a comma-separated string, which can somehow be split and looped over? How do you usually work with lists in MySQL stored procedures?
ANSWER:
This article has some good discussion on the problem of parsing an array to a stored procedure since stored procedures only allow valid table column data-types as parameters. There are some neat things you can do with the csv table type in mysql - that is if you are loading a flat file into the db. You could create a temporary table in the stored procedure, iterate over the csv list and insert it to the temp table, then create a cursor which selects the values from that table. This answer in the above mentioned thread shows a way of doing this. Generally I would split the array before I come to the database and then perform the query individually on each item. | [
"mysql",
"stored-procedures"
] | 13 | 9 | 21,752 | 4 | 0 | 2008-08-12T13:09:22.220000 | 2008-08-12T14:02:46.697000 |
8,800 | 8,811 | Best implementation for Key Value Pair Data Structure? | So I've been poking around with C# a bit lately, and all the Generic Collections have me a little confused. Say I wanted to represent a data structure where the head of a tree was a key value pair, and then there is one optional list of key value pairs below that (but no more levels than these). Would this be suitable? public class TokenTree { public TokenTree() { /* I must admit to not fully understanding this, * I got it from msdn. As far as I can tell, IDictionary is an * interface, and Dictionary is the default implementation of * that interface, right? */ SubPairs = new Dictionary (); }
public string Key; public string Value; public IDictionary SubPairs; } It's only really a simple shunt for passing around data. | There is an actual Data Type called KeyValuePair, use like this KeyValuePair myKeyValuePair = new KeyValuePair ("defaultkey", "defaultvalue"); | Best implementation for Key Value Pair Data Structure? So I've been poking around with C# a bit lately, and all the Generic Collections have me a little confused. Say I wanted to represent a data structure where the head of a tree was a key value pair, and then there is one optional list of key value pairs below that (but no more levels than these). Would this be suitable? public class TokenTree { public TokenTree() { /* I must admit to not fully understanding this, * I got it from msdn. As far as I can tell, IDictionary is an * interface, and Dictionary is the default implementation of * that interface, right? */ SubPairs = new Dictionary (); }
public string Key; public string Value; public IDictionary SubPairs; } It's only really a simple shunt for passing around data. | TITLE:
Best implementation for Key Value Pair Data Structure?
QUESTION:
So I've been poking around with C# a bit lately, and all the Generic Collections have me a little confused. Say I wanted to represent a data structure where the head of a tree was a key value pair, and then there is one optional list of key value pairs below that (but no more levels than these). Would this be suitable? public class TokenTree { public TokenTree() { /* I must admit to not fully understanding this, * I got it from msdn. As far as I can tell, IDictionary is an * interface, and Dictionary is the default implementation of * that interface, right? */ SubPairs = new Dictionary (); }
public string Key; public string Value; public IDictionary SubPairs; } It's only really a simple shunt for passing around data.
ANSWER:
There is an actual Data Type called KeyValuePair, use like this KeyValuePair myKeyValuePair = new KeyValuePair ("defaultkey", "defaultvalue"); | [
"c#",
"data-structures",
"collections"
] | 79 | 143 | 207,295 | 9 | 0 | 2008-08-12T13:12:50.887000 | 2008-08-12T13:20:55.127000 |
8,807 | 8,899 | Cannot add WebViewer of ActiveReports to an ASP.NET page | I installed ActiveReports from their site. The version was labeled as.NET 2.0 build 5.2.1013.2 (for Visual Studio 2005 and 2008). I have an ASP.NET project in VS 2008 which has 2.0 as target framework. I added all the tools in the DataDynamics namespace to the toolbox, created a new project, added a new report. When I drag and drop the WebViewer control to a page in the design view, nothing happens. No mark up is added, no report viewer is displayed on the page. Also I noticed that there are no tags related to DataDynamics components in my web.config file. Am I missing some configuration? | I think I found the reason. While trying to get this work, I think I installed another version of the package that removed or deactivated my current version. The control I was dropping on the form belonged to the older version that had no assemblies referenced. I removed all installations of ActiveReports, installed the last version and cleaned up the toolbox. I added the latest version of the WebViewer to toolbox and dropped it on the form. It worked. | Cannot add WebViewer of ActiveReports to an ASP.NET page I installed ActiveReports from their site. The version was labeled as.NET 2.0 build 5.2.1013.2 (for Visual Studio 2005 and 2008). I have an ASP.NET project in VS 2008 which has 2.0 as target framework. I added all the tools in the DataDynamics namespace to the toolbox, created a new project, added a new report. When I drag and drop the WebViewer control to a page in the design view, nothing happens. No mark up is added, no report viewer is displayed on the page. Also I noticed that there are no tags related to DataDynamics components in my web.config file. Am I missing some configuration? | TITLE:
Cannot add WebViewer of ActiveReports to an ASP.NET page
QUESTION:
I installed ActiveReports from their site. The version was labeled as.NET 2.0 build 5.2.1013.2 (for Visual Studio 2005 and 2008). I have an ASP.NET project in VS 2008 which has 2.0 as target framework. I added all the tools in the DataDynamics namespace to the toolbox, created a new project, added a new report. When I drag and drop the WebViewer control to a page in the design view, nothing happens. No mark up is added, no report viewer is displayed on the page. Also I noticed that there are no tags related to DataDynamics components in my web.config file. Am I missing some configuration?
ANSWER:
I think I found the reason. While trying to get this work, I think I installed another version of the package that removed or deactivated my current version. The control I was dropping on the form belonged to the older version that had no assemblies referenced. I removed all installations of ActiveReports, installed the last version and cleaned up the toolbox. I added the latest version of the WebViewer to toolbox and dropped it on the form. It worked. | [
"activereports"
] | 2 | 2 | 1,341 | 1 | 0 | 2008-08-12T13:15:46.543000 | 2008-08-12T14:39:20.040000 |
8,832 | 12,062 | mod_rewrite to alias one file suffix type to another | I hope I can explain this clearly enough, but if not let me know and I'll try to clarify. I'm currently developing a site using ColdFusion and have a mod_rewrite rule in place to make it look like the site is using PHP. Any requests for index.php get processed by index.cfm (the rule maps *.php to *.cfm). This works great - so far, so good. The problem is that I want to return a 404 status code if index.cfm (or any ColdFusion page) is requested directly. If I try to block access to *.cfm files using mod_rewrite it also returns a 404 for requests to *.php. I figure I might have to change my Apache config rather than use.htaccess | You can use the S flag to skip the 404 rule, like this: RewriteEngine on
# Do not separate these two rules so long as the first has S=1 RewriteRule (.*)\.php$ $1.cfm [S=1] RewriteRule \.cfm$ - [R=404] If you are also using the Alias option then you should also add the PT flag. See the mod_rewrite documentation for details. | mod_rewrite to alias one file suffix type to another I hope I can explain this clearly enough, but if not let me know and I'll try to clarify. I'm currently developing a site using ColdFusion and have a mod_rewrite rule in place to make it look like the site is using PHP. Any requests for index.php get processed by index.cfm (the rule maps *.php to *.cfm). This works great - so far, so good. The problem is that I want to return a 404 status code if index.cfm (or any ColdFusion page) is requested directly. If I try to block access to *.cfm files using mod_rewrite it also returns a 404 for requests to *.php. I figure I might have to change my Apache config rather than use.htaccess | TITLE:
mod_rewrite to alias one file suffix type to another
QUESTION:
I hope I can explain this clearly enough, but if not let me know and I'll try to clarify. I'm currently developing a site using ColdFusion and have a mod_rewrite rule in place to make it look like the site is using PHP. Any requests for index.php get processed by index.cfm (the rule maps *.php to *.cfm). This works great - so far, so good. The problem is that I want to return a 404 status code if index.cfm (or any ColdFusion page) is requested directly. If I try to block access to *.cfm files using mod_rewrite it also returns a 404 for requests to *.php. I figure I might have to change my Apache config rather than use.htaccess
ANSWER:
You can use the S flag to skip the 404 rule, like this: RewriteEngine on
# Do not separate these two rules so long as the first has S=1 RewriteRule (.*)\.php$ $1.cfm [S=1] RewriteRule \.cfm$ - [R=404] If you are also using the Alias option then you should also add the PT flag. See the mod_rewrite documentation for details. | [
"apache",
"mod-rewrite",
"seo"
] | 3 | 1 | 1,601 | 3 | 0 | 2008-08-12T13:44:06.580000 | 2008-08-15T08:02:25.513000 |
8,849 | 9,730 | SharePoint - Connection String dialog box during FeatureActivated event | Does anyone know if it is possible to display a prompt to a user/administrator when activating or installing a sharepoint feature? I am writing a custom webpart and it is connecting to a separate database, I would like to allow the administrator to select or type in a connection string when installing the.wsp file or activating the feature. I am looking inside the FeatureActivated event and thinking of using the SPWebConfigModification class to actually write the connection string to the web.config files in the farm. I do not want to hand edit the web.configs or hard code the string into the DLL. If you have other methods for handling connection strings inside sharepoint I would be interested in them as well. | Unfortunately there is no way to swap to a screen where you can get user via the feature activation process. Couple of comments for you: I'm assuming the connection string is going to be different for every installation, so there is no way you can include it directly in the Solution. I'm assuming that you couldn't programmatically construct this during installation. Therefore, you need some way to get user input. Here are a couple of options: It could be a web part property, though this would mean setting it each and every time the web part was added, and you would need to then maitain those settings individually. You could build out your own _layouts settings screen (good post: http://community.zevenseas.com/Blogs/Robin/archive/2008/03/17/lcm-creating-custom-application-page-and-using-the-propertybag-more-detailed.aspx ), and from there users can maintain the property, storing it in either the Web Property bag, or inside the Web.Config. I try to avoid using the Web.Config where I can, but if you do wish to go this route then MAKE SURE you use the SPWebConfigModification class (Read this great blog: http://www.crsw.com/mark/Lists/Posts/Post.aspx?ID=32 ) Finally, a technique I often use is storing configuration information in a SharePoint List. Chris O'Brien has a great framework for that here: http://www.codeplex.com/SPConfigStore Hope that helps, Daniel | SharePoint - Connection String dialog box during FeatureActivated event Does anyone know if it is possible to display a prompt to a user/administrator when activating or installing a sharepoint feature? I am writing a custom webpart and it is connecting to a separate database, I would like to allow the administrator to select or type in a connection string when installing the.wsp file or activating the feature. I am looking inside the FeatureActivated event and thinking of using the SPWebConfigModification class to actually write the connection string to the web.config files in the farm. I do not want to hand edit the web.configs or hard code the string into the DLL. If you have other methods for handling connection strings inside sharepoint I would be interested in them as well. | TITLE:
SharePoint - Connection String dialog box during FeatureActivated event
QUESTION:
Does anyone know if it is possible to display a prompt to a user/administrator when activating or installing a sharepoint feature? I am writing a custom webpart and it is connecting to a separate database, I would like to allow the administrator to select or type in a connection string when installing the.wsp file or activating the feature. I am looking inside the FeatureActivated event and thinking of using the SPWebConfigModification class to actually write the connection string to the web.config files in the farm. I do not want to hand edit the web.configs or hard code the string into the DLL. If you have other methods for handling connection strings inside sharepoint I would be interested in them as well.
ANSWER:
Unfortunately there is no way to swap to a screen where you can get user via the feature activation process. Couple of comments for you: I'm assuming the connection string is going to be different for every installation, so there is no way you can include it directly in the Solution. I'm assuming that you couldn't programmatically construct this during installation. Therefore, you need some way to get user input. Here are a couple of options: It could be a web part property, though this would mean setting it each and every time the web part was added, and you would need to then maitain those settings individually. You could build out your own _layouts settings screen (good post: http://community.zevenseas.com/Blogs/Robin/archive/2008/03/17/lcm-creating-custom-application-page-and-using-the-propertybag-more-detailed.aspx ), and from there users can maintain the property, storing it in either the Web Property bag, or inside the Web.Config. I try to avoid using the Web.Config where I can, but if you do wish to go this route then MAKE SURE you use the SPWebConfigModification class (Read this great blog: http://www.crsw.com/mark/Lists/Posts/Post.aspx?ID=32 ) Finally, a technique I often use is storing configuration information in a SharePoint List. Chris O'Brien has a great framework for that here: http://www.codeplex.com/SPConfigStore Hope that helps, Daniel | [
"sharepoint",
"connection-string"
] | 2 | 1 | 2,273 | 2 | 0 | 2008-08-12T13:57:04.353000 | 2008-08-13T12:50:32.333000 |
8,864 | 8,869 | Difference between NULL and null in PHP | Is there a difference between NULL and null in PHP? Sometimes they seem to be interchangeable and sometimes not. edit: for some reason when I read the documentation linked to in the answer (before posting this question) I read it as "case sensitive" instead of "case insensitive" which was the whole reason I posted this question in the first place... | Null is case insensitive. From the documentation: There is only one value of type null, and that is the case-insensitive keyword NULL. | Difference between NULL and null in PHP Is there a difference between NULL and null in PHP? Sometimes they seem to be interchangeable and sometimes not. edit: for some reason when I read the documentation linked to in the answer (before posting this question) I read it as "case sensitive" instead of "case insensitive" which was the whole reason I posted this question in the first place... | TITLE:
Difference between NULL and null in PHP
QUESTION:
Is there a difference between NULL and null in PHP? Sometimes they seem to be interchangeable and sometimes not. edit: for some reason when I read the documentation linked to in the answer (before posting this question) I read it as "case sensitive" instead of "case insensitive" which was the whole reason I posted this question in the first place...
ANSWER:
Null is case insensitive. From the documentation: There is only one value of type null, and that is the case-insensitive keyword NULL. | [
"php",
"null"
] | 106 | 140 | 39,477 | 4 | 0 | 2008-08-12T14:08:23.363000 | 2008-08-12T14:11:11.393000 |
8,876 | 8,882 | Evidence Based Scheduling Tool | Are there any free tools that implement evidence-based scheduling like Joel talks about? There is FogBugz, of course, but I am looking for a simple and free tool that can apply EBS on some tasks that I give estimates (and actual times which are complete) for. | FogBugz is free for up to 2 users by the way. As far I know this is the only tool that does EBS. See here http://www.workhappy.net/2008/06/get-fogbugz-for.html | Evidence Based Scheduling Tool Are there any free tools that implement evidence-based scheduling like Joel talks about? There is FogBugz, of course, but I am looking for a simple and free tool that can apply EBS on some tasks that I give estimates (and actual times which are complete) for. | TITLE:
Evidence Based Scheduling Tool
QUESTION:
Are there any free tools that implement evidence-based scheduling like Joel talks about? There is FogBugz, of course, but I am looking for a simple and free tool that can apply EBS on some tasks that I give estimates (and actual times which are complete) for.
ANSWER:
FogBugz is free for up to 2 users by the way. As far I know this is the only tool that does EBS. See here http://www.workhappy.net/2008/06/get-fogbugz-for.html | [
"fogbugz"
] | 30 | 14 | 3,170 | 2 | 0 | 2008-08-12T14:16:41.757000 | 2008-08-12T14:28:52.497000 |
8,880 | 8,888 | Get list of domains on the network | Using the Windows API, how can I get a list of domains on my network? | You will need to use some LDAP queries Here is some code I have used in a previous script (it was taken off the net somewhere, and I've left in the copyright notices) ' This VBScript code gets the list of the domains contained in the ' forest that the user running the script is logged into
' --------------------------------------------------------------- ' From the book "Active Directory Cookbook" by Robbie Allen ' Publisher: O'Reilly and Associates ' ISBN: 0-596-00466-4 ' Book web site: http://rallenhome.com/books/adcookbook/code.html ' ---------------------------------------------------------------
set objRootDSE = GetObject("LDAP://RootDSE") strADsPath = ";" strFilter = "(objectcategory=domainDNS);" strAttrs = "name;" strScope = "SubTree"
set objConn = CreateObject("ADODB.Connection") objConn.Provider = "ADsDSOObject" objConn.Open "Active Directory Provider" set objRS = objConn.Execute(strADsPath & strFilter & strAttrs & strScope) objRS.MoveFirst while Not objRS.EOF Wscript.Echo objRS.Fields(0).Value objRS.MoveNext wend Also a C# version | Get list of domains on the network Using the Windows API, how can I get a list of domains on my network? | TITLE:
Get list of domains on the network
QUESTION:
Using the Windows API, how can I get a list of domains on my network?
ANSWER:
You will need to use some LDAP queries Here is some code I have used in a previous script (it was taken off the net somewhere, and I've left in the copyright notices) ' This VBScript code gets the list of the domains contained in the ' forest that the user running the script is logged into
' --------------------------------------------------------------- ' From the book "Active Directory Cookbook" by Robbie Allen ' Publisher: O'Reilly and Associates ' ISBN: 0-596-00466-4 ' Book web site: http://rallenhome.com/books/adcookbook/code.html ' ---------------------------------------------------------------
set objRootDSE = GetObject("LDAP://RootDSE") strADsPath = ";" strFilter = "(objectcategory=domainDNS);" strAttrs = "name;" strScope = "SubTree"
set objConn = CreateObject("ADODB.Connection") objConn.Provider = "ADsDSOObject" objConn.Open "Active Directory Provider" set objRS = objConn.Execute(strADsPath & strFilter & strAttrs & strScope) objRS.MoveFirst while Not objRS.EOF Wscript.Echo objRS.Fields(0).Value objRS.MoveNext wend Also a C# version | [
"winapi"
] | 1 | 1 | 3,261 | 2 | 0 | 2008-08-12T14:20:31.153000 | 2008-08-12T14:33:20.303000 |
8,893 | 8,906 | Anyone know of an on-line free database? | I wrote an application that currently runs against a local instance of MySql. I would like to centralize the DB somewhere on the Net, and share my application. But, I'm cheap, and don't want to pay for it. Does anyone know of a free on-line relational DB service that I could connect to via C#? | What about http://www.freesql.org? Seems like you can't be too picky when you're asking for free, and this seems to offer something. | Anyone know of an on-line free database? I wrote an application that currently runs against a local instance of MySql. I would like to centralize the DB somewhere on the Net, and share my application. But, I'm cheap, and don't want to pay for it. Does anyone know of a free on-line relational DB service that I could connect to via C#? | TITLE:
Anyone know of an on-line free database?
QUESTION:
I wrote an application that currently runs against a local instance of MySql. I would like to centralize the DB somewhere on the Net, and share my application. But, I'm cheap, and don't want to pay for it. Does anyone know of a free on-line relational DB service that I could connect to via C#?
ANSWER:
What about http://www.freesql.org? Seems like you can't be too picky when you're asking for free, and this seems to offer something. | [
"c#",
"database"
] | 11 | 6 | 1,050 | 6 | 0 | 2008-08-12T14:35:39.643000 | 2008-08-12T14:43:31.077000 |
8,894 | 10,140 | Use for the phppgadmin Reports Database? | Phppgadmin comes with instructions for creating a reports database on the system for use with phppgadmin. The instructions describe how to set it up, but do not really give any indication of what its purpose is, and the phppgadmin site was not very helpful either. It seems to allow you to store SQL queries, so is it for storing admin queries accessing tables like pg_class etc? | This is just a standard location to store frequently used SQL scripts. The reports-pgsql.sql script creates a table for storing these queries, the database they are intended to be run on, a title and some descriptive text about what they do. PhpPgAdmin has functionality to browse and execute these reports. It's a pretty simple system just meant to aid in organization. | Use for the phppgadmin Reports Database? Phppgadmin comes with instructions for creating a reports database on the system for use with phppgadmin. The instructions describe how to set it up, but do not really give any indication of what its purpose is, and the phppgadmin site was not very helpful either. It seems to allow you to store SQL queries, so is it for storing admin queries accessing tables like pg_class etc? | TITLE:
Use for the phppgadmin Reports Database?
QUESTION:
Phppgadmin comes with instructions for creating a reports database on the system for use with phppgadmin. The instructions describe how to set it up, but do not really give any indication of what its purpose is, and the phppgadmin site was not very helpful either. It seems to allow you to store SQL queries, so is it for storing admin queries accessing tables like pg_class etc?
ANSWER:
This is just a standard location to store frequently used SQL scripts. The reports-pgsql.sql script creates a table for storing these queries, the database they are intended to be run on, a title and some descriptive text about what they do. PhpPgAdmin has functionality to browse and execute these reports. It's a pretty simple system just meant to aid in organization. | [
"php",
"database",
"postgresql",
"phppgadmin"
] | 7 | 6 | 1,897 | 1 | 0 | 2008-08-12T14:35:46.803000 | 2008-08-13T18:08:47.947000 |
8,896 | 2,356,710 | Can I get Memcached running on a Windows (x64) 64bit environment? | Does anyone know IF, WHEN or HOW I can get Memcached running on a Windows 64bit environment? I'm setting up a new hosting solution and would much prefer to run a 64bit OS, and since it's an ASP.Net MVC solution with SQL Server DB, the OS is either going to be Windows Server 2003 or (hopefully!) 2008. I know that this could spill over into a debate regarding 32bit vs 64bit on servers, but let's just say that my preference is 64bit and that I have some very good reasons. So far, I've tried a number of options and found a bit of help related to getting this up on a 32bit machine (and succeeded I might add), but since the original Windows port is Win32 specific, this is hardly going to help when installing as a service on x64. It also has a dependency on the libevent for which I can only get a Win32 compiled version. I suspect that simply loading all this up in C++ and hitting "compile" (for 64bit) wouldn't work, not least because of the intricate differences in 32 and 64bit architectures, but I'm wondering if anyone is working on getting this off the ground? Unfortunately, my expertise lie in managed code (C#) only, otherwise I would try and take this on myself, but I can't believe I'm the only guy out there trying to get memcached running on a 64 bit Windows server....am I? Update Yes I'm afraid I'm still looking for an answer to this - all my efforts (with my pathetic C++ skills) to make a stable build have failed - I've trashed one server and 3 VM's just trying it out so now I turn to the real experts. Is anyone planning on porting this to 64bit? Or are you really suggesting that I use MS Velocity instead? I shudder at the thought. Update: @Lars - I do use Enyim actually - it's very good, but what you're referring to is a client, rather than the server part. @DannySmurf - I've only been able to install it as a service on a 32 bit OS. 64 bit OS rejects the installation of this Win32 service. Of course yes, lots of Win32 code works seamlessly on x64 architecture, hence you can run 32bit apps (like Office for instance) or games on Vista/XP 64 etc, but this doesn't translate directly when it comes to services. I'm no expert, I suspect that it has to do with the syncs or eventing that services need to subscribe to, and I suspect that 64 and 32 don't play nicely. I'm happy to be corrected on any of this, but to answer your question - yes I have tried. @OJ - thanks very much for the straight-forward response. I thought as much, but wasn't sure if anyone else had suggestions or had already gone down this route. Maybe when StackOverflow is LIVE, then more people will respond and let me know if this is something being looked into, and although I can try and compile it myself - I simply can't "trust" (with my C++ experience level) that it would provide "Enterprise Level" reliability in such a crucial component of large scalable solutions. I think it would need educated intervention rather than my unsanitised experimental approach before I could be confident. One little oversight on my part, could bring the site down. Oh well... till next time. | North Scale labs have released a build of memcached 1.4.4 for Windows x64: http://blog.couchbase.com/memcached-windows-64-bit-pre-release-available http://labs.northscale.com/memcached-packages/ UPDATE: they have recently released Memcached Server - still FREE but enhanced distro with clustering, web-based admin/stats UI etc. (I'm not related to them in any way) Check it out at http://northscale.com/products/memcached.html and download at: http://www.northscale.com/download.php?a=d UPDATE 2: NorthScale Memcached is no longer available as a standalone download. Now they have made it part of their commercial No-SQL DB offering called Membase. It can be configured to run in Memcached-only mode (i.e. without persistence) and there's a 100% free version too. Check it out here: http://www.membase.org/downloads UPDATE 3: MemBase has slept with CouchDB and produced a hybrid product offering, called CouchBase. They still do offer a free "Community" version at http://www.couchbase.com/download | Can I get Memcached running on a Windows (x64) 64bit environment? Does anyone know IF, WHEN or HOW I can get Memcached running on a Windows 64bit environment? I'm setting up a new hosting solution and would much prefer to run a 64bit OS, and since it's an ASP.Net MVC solution with SQL Server DB, the OS is either going to be Windows Server 2003 or (hopefully!) 2008. I know that this could spill over into a debate regarding 32bit vs 64bit on servers, but let's just say that my preference is 64bit and that I have some very good reasons. So far, I've tried a number of options and found a bit of help related to getting this up on a 32bit machine (and succeeded I might add), but since the original Windows port is Win32 specific, this is hardly going to help when installing as a service on x64. It also has a dependency on the libevent for which I can only get a Win32 compiled version. I suspect that simply loading all this up in C++ and hitting "compile" (for 64bit) wouldn't work, not least because of the intricate differences in 32 and 64bit architectures, but I'm wondering if anyone is working on getting this off the ground? Unfortunately, my expertise lie in managed code (C#) only, otherwise I would try and take this on myself, but I can't believe I'm the only guy out there trying to get memcached running on a 64 bit Windows server....am I? Update Yes I'm afraid I'm still looking for an answer to this - all my efforts (with my pathetic C++ skills) to make a stable build have failed - I've trashed one server and 3 VM's just trying it out so now I turn to the real experts. Is anyone planning on porting this to 64bit? Or are you really suggesting that I use MS Velocity instead? I shudder at the thought. Update: @Lars - I do use Enyim actually - it's very good, but what you're referring to is a client, rather than the server part. @DannySmurf - I've only been able to install it as a service on a 32 bit OS. 64 bit OS rejects the installation of this Win32 service. Of course yes, lots of Win32 code works seamlessly on x64 architecture, hence you can run 32bit apps (like Office for instance) or games on Vista/XP 64 etc, but this doesn't translate directly when it comes to services. I'm no expert, I suspect that it has to do with the syncs or eventing that services need to subscribe to, and I suspect that 64 and 32 don't play nicely. I'm happy to be corrected on any of this, but to answer your question - yes I have tried. @OJ - thanks very much for the straight-forward response. I thought as much, but wasn't sure if anyone else had suggestions or had already gone down this route. Maybe when StackOverflow is LIVE, then more people will respond and let me know if this is something being looked into, and although I can try and compile it myself - I simply can't "trust" (with my C++ experience level) that it would provide "Enterprise Level" reliability in such a crucial component of large scalable solutions. I think it would need educated intervention rather than my unsanitised experimental approach before I could be confident. One little oversight on my part, could bring the site down. Oh well... till next time. | TITLE:
Can I get Memcached running on a Windows (x64) 64bit environment?
QUESTION:
Does anyone know IF, WHEN or HOW I can get Memcached running on a Windows 64bit environment? I'm setting up a new hosting solution and would much prefer to run a 64bit OS, and since it's an ASP.Net MVC solution with SQL Server DB, the OS is either going to be Windows Server 2003 or (hopefully!) 2008. I know that this could spill over into a debate regarding 32bit vs 64bit on servers, but let's just say that my preference is 64bit and that I have some very good reasons. So far, I've tried a number of options and found a bit of help related to getting this up on a 32bit machine (and succeeded I might add), but since the original Windows port is Win32 specific, this is hardly going to help when installing as a service on x64. It also has a dependency on the libevent for which I can only get a Win32 compiled version. I suspect that simply loading all this up in C++ and hitting "compile" (for 64bit) wouldn't work, not least because of the intricate differences in 32 and 64bit architectures, but I'm wondering if anyone is working on getting this off the ground? Unfortunately, my expertise lie in managed code (C#) only, otherwise I would try and take this on myself, but I can't believe I'm the only guy out there trying to get memcached running on a 64 bit Windows server....am I? Update Yes I'm afraid I'm still looking for an answer to this - all my efforts (with my pathetic C++ skills) to make a stable build have failed - I've trashed one server and 3 VM's just trying it out so now I turn to the real experts. Is anyone planning on porting this to 64bit? Or are you really suggesting that I use MS Velocity instead? I shudder at the thought. Update: @Lars - I do use Enyim actually - it's very good, but what you're referring to is a client, rather than the server part. @DannySmurf - I've only been able to install it as a service on a 32 bit OS. 64 bit OS rejects the installation of this Win32 service. Of course yes, lots of Win32 code works seamlessly on x64 architecture, hence you can run 32bit apps (like Office for instance) or games on Vista/XP 64 etc, but this doesn't translate directly when it comes to services. I'm no expert, I suspect that it has to do with the syncs or eventing that services need to subscribe to, and I suspect that 64 and 32 don't play nicely. I'm happy to be corrected on any of this, but to answer your question - yes I have tried. @OJ - thanks very much for the straight-forward response. I thought as much, but wasn't sure if anyone else had suggestions or had already gone down this route. Maybe when StackOverflow is LIVE, then more people will respond and let me know if this is something being looked into, and although I can try and compile it myself - I simply can't "trust" (with my C++ experience level) that it would provide "Enterprise Level" reliability in such a crucial component of large scalable solutions. I think it would need educated intervention rather than my unsanitised experimental approach before I could be confident. One little oversight on my part, could bring the site down. Oh well... till next time.
ANSWER:
North Scale labs have released a build of memcached 1.4.4 for Windows x64: http://blog.couchbase.com/memcached-windows-64-bit-pre-release-available http://labs.northscale.com/memcached-packages/ UPDATE: they have recently released Memcached Server - still FREE but enhanced distro with clustering, web-based admin/stats UI etc. (I'm not related to them in any way) Check it out at http://northscale.com/products/memcached.html and download at: http://www.northscale.com/download.php?a=d UPDATE 2: NorthScale Memcached is no longer available as a standalone download. Now they have made it part of their commercial No-SQL DB offering called Membase. It can be configured to run in Memcached-only mode (i.e. without persistence) and there's a 100% free version too. Check it out here: http://www.membase.org/downloads UPDATE 3: MemBase has slept with CouchDB and produced a hybrid product offering, called CouchBase. They still do offer a free "Community" version at http://www.couchbase.com/download | [
"c#",
"c++",
"windows",
"64-bit",
"memcached"
] | 90 | 54 | 61,555 | 11 | 0 | 2008-08-12T14:37:28.703000 | 2010-03-01T15:12:00.593000 |
8,919 | 8,928 | Looking for best practice for doing a "Net Use" in C# | I'd rather not have to resort to calling the command line. I'm looking for code that can map/disconnect a drive, while also having exception handling. Any ideas? | Use P/Invoke and WNetAddConnection2 There should also be some wrappers out there to do some of the grunt work for you. Google is your friend, as always. | Looking for best practice for doing a "Net Use" in C# I'd rather not have to resort to calling the command line. I'm looking for code that can map/disconnect a drive, while also having exception handling. Any ideas? | TITLE:
Looking for best practice for doing a "Net Use" in C#
QUESTION:
I'd rather not have to resort to calling the command line. I'm looking for code that can map/disconnect a drive, while also having exception handling. Any ideas?
ANSWER:
Use P/Invoke and WNetAddConnection2 There should also be some wrappers out there to do some of the grunt work for you. Google is your friend, as always. | [
"c#",
".net-1.1"
] | 9 | 9 | 17,135 | 1 | 0 | 2008-08-12T14:53:58.233000 | 2008-08-12T14:58:40.330000 |
8,939 | 205,936 | ActionScript 3.0 sockets can't reconnect | I'm having trouble connecting (via the Socket and XMLSocket classes) to a TCP listener after a connect timeout. I have a flash applet that needs to maintain a TCP connection to a server. I have implemented timeouts using Timers, a ping-pong system, etc. However, there's a problem. Upon calling Socket.connect(), the flash player (9.0.115 and many other stables before that) sends 3 connection requests by way of SYN packets, with some time in between. If none of those are replied to (e.g. because the server is down), I cannot get the applet to [attempt to] connect to the server. Ever. That is, within the lifetime of the applet. To clarify and/or summarize: For any host/port pair given to Socket.connect() or XMLSocket.connect(), if the call fails, any subsequent connect() calls to any other Socket (or XMLSocket) instances within the lifetime of the Flash applet to the same host/port pair get ignored. (At least as far as I can tell using a packet sniffer.) I have tried calling numerous Socket methods, destroying¹ and recreating the objects, using a pool of Sockets, and various other methods I can't remember right now; all to no avail. My current solution is to notify the parent webpage through a JavaScript call and let it reload my applet. It's not a pretty solution, and I'm not about to implement workarounds for the problems it causes, just because Flash can't handle socket connections properly. I must be missing something very simple. Any ideas? 1: I know you can't really destroy objects; I just remove all references to them and hope for the best. I haven't tried to explicitly invoke the GC in this case. (Though I think I did try putting the Socket inside an Array and using delete.) Yes, it works as expected if the connection is successful (even if the connection drops later on.) The only event to trigger this is the case when the server doesn't respond at all; it's as if Flash marks the host/port combination as "offline" and doesn't bother sending any more packets to it for the lifetime of the applet. I suspect an active refusal of the connection (e.g. host is online but not listening to the port) doesn't cause this. I get no error message or feedback of any other kind from the Socket. Have you ever called connect() more than once to the same host/port pair, when the first one failed? How did you know the first connect() failed? And before subsequent connect() calls, did you do anything to reset the socket? | This could be related to the unresolved bug FP-269 which in turn may have the same root cause as FP-67. This build should be fixed in the current public beta release found on labs.adobe.com Edwin Wong - [09/23/08 04:49 PM ] I'd recommend you give the latest public beta a shot... | ActionScript 3.0 sockets can't reconnect I'm having trouble connecting (via the Socket and XMLSocket classes) to a TCP listener after a connect timeout. I have a flash applet that needs to maintain a TCP connection to a server. I have implemented timeouts using Timers, a ping-pong system, etc. However, there's a problem. Upon calling Socket.connect(), the flash player (9.0.115 and many other stables before that) sends 3 connection requests by way of SYN packets, with some time in between. If none of those are replied to (e.g. because the server is down), I cannot get the applet to [attempt to] connect to the server. Ever. That is, within the lifetime of the applet. To clarify and/or summarize: For any host/port pair given to Socket.connect() or XMLSocket.connect(), if the call fails, any subsequent connect() calls to any other Socket (or XMLSocket) instances within the lifetime of the Flash applet to the same host/port pair get ignored. (At least as far as I can tell using a packet sniffer.) I have tried calling numerous Socket methods, destroying¹ and recreating the objects, using a pool of Sockets, and various other methods I can't remember right now; all to no avail. My current solution is to notify the parent webpage through a JavaScript call and let it reload my applet. It's not a pretty solution, and I'm not about to implement workarounds for the problems it causes, just because Flash can't handle socket connections properly. I must be missing something very simple. Any ideas? 1: I know you can't really destroy objects; I just remove all references to them and hope for the best. I haven't tried to explicitly invoke the GC in this case. (Though I think I did try putting the Socket inside an Array and using delete.) Yes, it works as expected if the connection is successful (even if the connection drops later on.) The only event to trigger this is the case when the server doesn't respond at all; it's as if Flash marks the host/port combination as "offline" and doesn't bother sending any more packets to it for the lifetime of the applet. I suspect an active refusal of the connection (e.g. host is online but not listening to the port) doesn't cause this. I get no error message or feedback of any other kind from the Socket. Have you ever called connect() more than once to the same host/port pair, when the first one failed? How did you know the first connect() failed? And before subsequent connect() calls, did you do anything to reset the socket? | TITLE:
ActionScript 3.0 sockets can't reconnect
QUESTION:
I'm having trouble connecting (via the Socket and XMLSocket classes) to a TCP listener after a connect timeout. I have a flash applet that needs to maintain a TCP connection to a server. I have implemented timeouts using Timers, a ping-pong system, etc. However, there's a problem. Upon calling Socket.connect(), the flash player (9.0.115 and many other stables before that) sends 3 connection requests by way of SYN packets, with some time in between. If none of those are replied to (e.g. because the server is down), I cannot get the applet to [attempt to] connect to the server. Ever. That is, within the lifetime of the applet. To clarify and/or summarize: For any host/port pair given to Socket.connect() or XMLSocket.connect(), if the call fails, any subsequent connect() calls to any other Socket (or XMLSocket) instances within the lifetime of the Flash applet to the same host/port pair get ignored. (At least as far as I can tell using a packet sniffer.) I have tried calling numerous Socket methods, destroying¹ and recreating the objects, using a pool of Sockets, and various other methods I can't remember right now; all to no avail. My current solution is to notify the parent webpage through a JavaScript call and let it reload my applet. It's not a pretty solution, and I'm not about to implement workarounds for the problems it causes, just because Flash can't handle socket connections properly. I must be missing something very simple. Any ideas? 1: I know you can't really destroy objects; I just remove all references to them and hope for the best. I haven't tried to explicitly invoke the GC in this case. (Though I think I did try putting the Socket inside an Array and using delete.) Yes, it works as expected if the connection is successful (even if the connection drops later on.) The only event to trigger this is the case when the server doesn't respond at all; it's as if Flash marks the host/port combination as "offline" and doesn't bother sending any more packets to it for the lifetime of the applet. I suspect an active refusal of the connection (e.g. host is online but not listening to the port) doesn't cause this. I get no error message or feedback of any other kind from the Socket. Have you ever called connect() more than once to the same host/port pair, when the first one failed? How did you know the first connect() failed? And before subsequent connect() calls, did you do anything to reset the socket?
ANSWER:
This could be related to the unresolved bug FP-269 which in turn may have the same root cause as FP-67. This build should be fixed in the current public beta release found on labs.adobe.com Edwin Wong - [09/23/08 04:49 PM ] I'd recommend you give the latest public beta a shot... | [
"flash",
"actionscript-3",
"sockets",
"xmlsocket"
] | 5 | 3 | 2,290 | 1 | 0 | 2008-08-12T15:03:40.833000 | 2008-10-15T18:51:14.127000 |
8,940 | 8,996 | VMWare Server Under Linux Secondary NIC connection | With VMWare Server running under Linux (Debain), I would like to have the following setup: 1st: NIC being used by many of the images running under VMWare, as well as being used by the Linux OS 2nd: NIC being used by only 1 image and to be unused by the Linux OS (as its part of a DMZ) Although the second NIC won't be used by Linux, it is certainly recognised as a NIC (e.g. eth1). Is this possible under VMWare Server, and if so, is it as simple as not binding eth1 under Linux and then bridging it to the image under VMWare Server? | I believe you can set the desired solution up by rerunning the vmware configuration script. And doing a custom network setup, so that both NIC's are mapped to your vmware instance. I would recommend making eth0 the 2nd NIC since it will be easier for Linux to use by default. Then make eth1 the 1st NIC. | VMWare Server Under Linux Secondary NIC connection With VMWare Server running under Linux (Debain), I would like to have the following setup: 1st: NIC being used by many of the images running under VMWare, as well as being used by the Linux OS 2nd: NIC being used by only 1 image and to be unused by the Linux OS (as its part of a DMZ) Although the second NIC won't be used by Linux, it is certainly recognised as a NIC (e.g. eth1). Is this possible under VMWare Server, and if so, is it as simple as not binding eth1 under Linux and then bridging it to the image under VMWare Server? | TITLE:
VMWare Server Under Linux Secondary NIC connection
QUESTION:
With VMWare Server running under Linux (Debain), I would like to have the following setup: 1st: NIC being used by many of the images running under VMWare, as well as being used by the Linux OS 2nd: NIC being used by only 1 image and to be unused by the Linux OS (as its part of a DMZ) Although the second NIC won't be used by Linux, it is certainly recognised as a NIC (e.g. eth1). Is this possible under VMWare Server, and if so, is it as simple as not binding eth1 under Linux and then bridging it to the image under VMWare Server?
ANSWER:
I believe you can set the desired solution up by rerunning the vmware configuration script. And doing a custom network setup, so that both NIC's are mapped to your vmware instance. I would recommend making eth0 the 2nd NIC since it will be easier for Linux to use by default. Then make eth1 the 1st NIC. | [
"linux",
"vmware",
"system-administration",
"nic"
] | 0 | 2 | 1,343 | 1 | 0 | 2008-08-12T15:04:29.397000 | 2008-08-12T15:56:13.660000 |
8,941 | 8,956 | Generic type checking | Is there a way to enforce/limit the types that are passed to primitives? (bool, int, string, etc.) Now, I know you can limit the generic type parameter to a type or interface implementation via the where clause. However, this doesn't fit the bill for primitives (AFAIK) because they do not all have a common ground (apart from object before someone says!:P). So, my current thoughts are to just grit my teeth and do a big switch statement and throw an ArgumentException on failure. EDIT 1: Just to clarify: The code definition should be like this: public class MyClass.... And instantiation: MyClass = new MyClass (); // Legal MyClass = new MyClass (); // Legal MyClass = new MyClass (); // Illegal MyClass = new MyClass (); // Illegal (but looks awesome!) EDIT 2 @Jon Limjap - Good point, and something I was already considering. I'm sure there is a generic method that can be used to determine if the type is of a value or reference type. This could be useful in instantly removing a lot of the objects I don't want to deal with (but then you need to worry about the structs that are used such as Size ). Interesting problem no?:) Here it is: where T: struct Taken from MSDN. I'm curious. Could this be done in.NET 3.x using extension methods? Create an interface, and implement the interface in the extension methods (which would probably be cleaner than a bit fat switch). Plus if you then need to later extend to any lightweight custom types, they can also implement the same interface, with no changes required to the base code. What do you guys think? The sad news is I am working in Framework 2!!:D EDIT 3 This was so simple following on from Jon Limjaps Pointer.. So simple I almost want to cry, but it's great because the code works like a charm! So here is what I did (you'll laugh!): Code added to the generic class bool TypeValid() { // Get the TypeCode from the Primitive Type TypeCode code = Type.GetTypeCode(typeof(PrimitiveDataType));
// All of the TypeCode Enumeration refer Primitive Types // with the exception of Object and Empty (Null). // Since I am willing to allow Null Types (at this time) // all we need to check for is Object! switch (code) { case TypeCode.Object: return false; default: return true; } } Then a little utility method to check the type and throw an exception, private void EnforcePrimitiveType() { if (!TypeValid()) throw new InvalidOperationException( "Unable to Instantiate SimpleMetadata based on the Generic Type of '" + typeof(PrimitiveDataType).Name + "' - this Class is Designed to Work with Primitive Data Types Only."); } All that then needs to be done is to call EnforcePrimitiveType() in the classes constructors. Job done!:-) The only downside, it only throws an exception at runtime (obviously) rather than design time. But that's no big deal and could be picked up with utilities like FxCop (which we don't use at work). Special thanks to Jon Limjap on this one! | Primitives appear to be specified in the TypeCode enumeration: Perhaps there is a way to find out if an object contains the TypeCode enum without having to cast it to an specific object or call GetType() or typeof()? Update It was right under my nose. The code sample there shows this: static void WriteObjectInfo(object testObject) { TypeCode typeCode = Type.GetTypeCode( testObject.GetType() );
switch( typeCode ) { case TypeCode.Boolean: Console.WriteLine("Boolean: {0}", testObject); break;
case TypeCode.Double: Console.WriteLine("Double: {0}", testObject); break;
default: Console.WriteLine("{0}: {1}", typeCode.ToString(), testObject); break; } } } It's still an ugly switch. But it's a good place to start! | Generic type checking Is there a way to enforce/limit the types that are passed to primitives? (bool, int, string, etc.) Now, I know you can limit the generic type parameter to a type or interface implementation via the where clause. However, this doesn't fit the bill for primitives (AFAIK) because they do not all have a common ground (apart from object before someone says!:P). So, my current thoughts are to just grit my teeth and do a big switch statement and throw an ArgumentException on failure. EDIT 1: Just to clarify: The code definition should be like this: public class MyClass.... And instantiation: MyClass = new MyClass (); // Legal MyClass = new MyClass (); // Legal MyClass = new MyClass (); // Illegal MyClass = new MyClass (); // Illegal (but looks awesome!) EDIT 2 @Jon Limjap - Good point, and something I was already considering. I'm sure there is a generic method that can be used to determine if the type is of a value or reference type. This could be useful in instantly removing a lot of the objects I don't want to deal with (but then you need to worry about the structs that are used such as Size ). Interesting problem no?:) Here it is: where T: struct Taken from MSDN. I'm curious. Could this be done in.NET 3.x using extension methods? Create an interface, and implement the interface in the extension methods (which would probably be cleaner than a bit fat switch). Plus if you then need to later extend to any lightweight custom types, they can also implement the same interface, with no changes required to the base code. What do you guys think? The sad news is I am working in Framework 2!!:D EDIT 3 This was so simple following on from Jon Limjaps Pointer.. So simple I almost want to cry, but it's great because the code works like a charm! So here is what I did (you'll laugh!): Code added to the generic class bool TypeValid() { // Get the TypeCode from the Primitive Type TypeCode code = Type.GetTypeCode(typeof(PrimitiveDataType));
// All of the TypeCode Enumeration refer Primitive Types // with the exception of Object and Empty (Null). // Since I am willing to allow Null Types (at this time) // all we need to check for is Object! switch (code) { case TypeCode.Object: return false; default: return true; } } Then a little utility method to check the type and throw an exception, private void EnforcePrimitiveType() { if (!TypeValid()) throw new InvalidOperationException( "Unable to Instantiate SimpleMetadata based on the Generic Type of '" + typeof(PrimitiveDataType).Name + "' - this Class is Designed to Work with Primitive Data Types Only."); } All that then needs to be done is to call EnforcePrimitiveType() in the classes constructors. Job done!:-) The only downside, it only throws an exception at runtime (obviously) rather than design time. But that's no big deal and could be picked up with utilities like FxCop (which we don't use at work). Special thanks to Jon Limjap on this one! | TITLE:
Generic type checking
QUESTION:
Is there a way to enforce/limit the types that are passed to primitives? (bool, int, string, etc.) Now, I know you can limit the generic type parameter to a type or interface implementation via the where clause. However, this doesn't fit the bill for primitives (AFAIK) because they do not all have a common ground (apart from object before someone says!:P). So, my current thoughts are to just grit my teeth and do a big switch statement and throw an ArgumentException on failure. EDIT 1: Just to clarify: The code definition should be like this: public class MyClass.... And instantiation: MyClass = new MyClass (); // Legal MyClass = new MyClass (); // Legal MyClass = new MyClass (); // Illegal MyClass = new MyClass (); // Illegal (but looks awesome!) EDIT 2 @Jon Limjap - Good point, and something I was already considering. I'm sure there is a generic method that can be used to determine if the type is of a value or reference type. This could be useful in instantly removing a lot of the objects I don't want to deal with (but then you need to worry about the structs that are used such as Size ). Interesting problem no?:) Here it is: where T: struct Taken from MSDN. I'm curious. Could this be done in.NET 3.x using extension methods? Create an interface, and implement the interface in the extension methods (which would probably be cleaner than a bit fat switch). Plus if you then need to later extend to any lightweight custom types, they can also implement the same interface, with no changes required to the base code. What do you guys think? The sad news is I am working in Framework 2!!:D EDIT 3 This was so simple following on from Jon Limjaps Pointer.. So simple I almost want to cry, but it's great because the code works like a charm! So here is what I did (you'll laugh!): Code added to the generic class bool TypeValid() { // Get the TypeCode from the Primitive Type TypeCode code = Type.GetTypeCode(typeof(PrimitiveDataType));
// All of the TypeCode Enumeration refer Primitive Types // with the exception of Object and Empty (Null). // Since I am willing to allow Null Types (at this time) // all we need to check for is Object! switch (code) { case TypeCode.Object: return false; default: return true; } } Then a little utility method to check the type and throw an exception, private void EnforcePrimitiveType() { if (!TypeValid()) throw new InvalidOperationException( "Unable to Instantiate SimpleMetadata based on the Generic Type of '" + typeof(PrimitiveDataType).Name + "' - this Class is Designed to Work with Primitive Data Types Only."); } All that then needs to be done is to call EnforcePrimitiveType() in the classes constructors. Job done!:-) The only downside, it only throws an exception at runtime (obviously) rather than design time. But that's no big deal and could be picked up with utilities like FxCop (which we don't use at work). Special thanks to Jon Limjap on this one!
ANSWER:
Primitives appear to be specified in the TypeCode enumeration: Perhaps there is a way to find out if an object contains the TypeCode enum without having to cast it to an specific object or call GetType() or typeof()? Update It was right under my nose. The code sample there shows this: static void WriteObjectInfo(object testObject) { TypeCode typeCode = Type.GetTypeCode( testObject.GetType() );
switch( typeCode ) { case TypeCode.Boolean: Console.WriteLine("Boolean: {0}", testObject); break;
case TypeCode.Double: Console.WriteLine("Double: {0}", testObject); break;
default: Console.WriteLine("{0}: {1}", typeCode.ToString(), testObject); break; } } } It's still an ugly switch. But it's a good place to start! | [
"c#",
"generics",
"primitive",
"type-safety"
] | 72 | 41 | 30,114 | 9 | 0 | 2008-08-12T15:07:40.887000 | 2008-08-12T15:21:44.010000 |
8,952 | 8,960 | Storing a file in a database as opposed to the file system? | Generally, how bad of a performance hit is storing a file in a database (specifically mssql) as opposed to the file system? I can't come up with a reason outside of application portability that I would want to store my files as varbinaries in SQL Server. | Have a look at this answer: Storing Images in DB - Yea or Nay? Essentially, the space and performance hit can be quite big, depending on the number of users. Also, keep in mind that Web servers are cheap and you can easily add more to balance the load, whereas the database is the most expensive and hardest to scale part of a web architecture usually. There are some opposite examples (e.g., Microsoft Sharepoint), but usually, storing files in the database is not a good idea. Unless possibly you write desktop apps and/or know roughly how many users you will ever have, but on something as random and unexpectable like a public web site, you may pay a high price for storing files in the database. | Storing a file in a database as opposed to the file system? Generally, how bad of a performance hit is storing a file in a database (specifically mssql) as opposed to the file system? I can't come up with a reason outside of application portability that I would want to store my files as varbinaries in SQL Server. | TITLE:
Storing a file in a database as opposed to the file system?
QUESTION:
Generally, how bad of a performance hit is storing a file in a database (specifically mssql) as opposed to the file system? I can't come up with a reason outside of application portability that I would want to store my files as varbinaries in SQL Server.
ANSWER:
Have a look at this answer: Storing Images in DB - Yea or Nay? Essentially, the space and performance hit can be quite big, depending on the number of users. Also, keep in mind that Web servers are cheap and you can easily add more to balance the load, whereas the database is the most expensive and hardest to scale part of a web architecture usually. There are some opposite examples (e.g., Microsoft Sharepoint), but usually, storing files in the database is not a good idea. Unless possibly you write desktop apps and/or know roughly how many users you will ever have, but on something as random and unexpectable like a public web site, you may pay a high price for storing files in the database. | [
"sql-server",
"database",
"filesystems",
"storage"
] | 95 | 86 | 151,517 | 11 | 0 | 2008-08-12T15:20:25.637000 | 2008-08-12T15:23:54.460000 |
8,966 | 107,940 | Using C#/WIA version 2.0 on Vista to Scan | I want to implement a paperless filing system and was looking to use WIA with C# for the image acquisition. There are quite a few sample projects on CodeProject, etc. However, after downloading every one of them that I can find, I have run into a problem. In each and every one of them, the reference to WIALib is broken. When I go to add "Microsoft Windows Image Acquisition" as a reference, the only version available on my development workstation (also the machine that will run this) is 2.0. Unfortunately, every one of these sample projects appear to have been coded against 1.x. The reference goes in as "WIA" instead of "WIALib". I took a shot, just changing the namespace import, but clearly the API is drastically different. Is there any information on either implementing v2.0 or on upgrading one of these existing sample projects out there? | To access WIA, you'll need to add a reference to the COM library, "Microsoft Windows Image Acquisition Library v2.0" (wiaaut.dll). add a "using WIA;" const string wiaFormatJPEG = "{B96B3CAE-0728-11D3-9D7B-0000F81EF32E}"; CommonDialogClass wiaDiag = new CommonDialogClass(); WIA.ImageFile wiaImage = null;
wiaImage = wiaDiag.ShowAcquireImage( WiaDeviceType.UnspecifiedDeviceType, WiaImageIntent.GrayscaleIntent, WiaImageBias.MaximizeQuality, wiaFormatJPEG, true, true, false);
WIA.Vector vector = wiaImage.FileData; (System.Drawing) Image i = Image.FromStream(new MemoryStream((byte[])vector.get_BinaryData())); i.Save(filename) Thats a basic way, works with my flatbed/doc feeder. If you need more than one document/page at a time though, there is probably a better way to do it (from what I could see, this only handles one image at a time, although I'm not entirely sure). While it is a WIA v1 doc, Scott Hanselman's Coding4Fun article on WIA does contain some more info on how to do it for multiple pages, I think (I'm yet to go further than that myself) If its for a paperless office system, you might want also check out MODI (Office Document Imaging) to do all the OCR for you. | Using C#/WIA version 2.0 on Vista to Scan I want to implement a paperless filing system and was looking to use WIA with C# for the image acquisition. There are quite a few sample projects on CodeProject, etc. However, after downloading every one of them that I can find, I have run into a problem. In each and every one of them, the reference to WIALib is broken. When I go to add "Microsoft Windows Image Acquisition" as a reference, the only version available on my development workstation (also the machine that will run this) is 2.0. Unfortunately, every one of these sample projects appear to have been coded against 1.x. The reference goes in as "WIA" instead of "WIALib". I took a shot, just changing the namespace import, but clearly the API is drastically different. Is there any information on either implementing v2.0 or on upgrading one of these existing sample projects out there? | TITLE:
Using C#/WIA version 2.0 on Vista to Scan
QUESTION:
I want to implement a paperless filing system and was looking to use WIA with C# for the image acquisition. There are quite a few sample projects on CodeProject, etc. However, after downloading every one of them that I can find, I have run into a problem. In each and every one of them, the reference to WIALib is broken. When I go to add "Microsoft Windows Image Acquisition" as a reference, the only version available on my development workstation (also the machine that will run this) is 2.0. Unfortunately, every one of these sample projects appear to have been coded against 1.x. The reference goes in as "WIA" instead of "WIALib". I took a shot, just changing the namespace import, but clearly the API is drastically different. Is there any information on either implementing v2.0 or on upgrading one of these existing sample projects out there?
ANSWER:
To access WIA, you'll need to add a reference to the COM library, "Microsoft Windows Image Acquisition Library v2.0" (wiaaut.dll). add a "using WIA;" const string wiaFormatJPEG = "{B96B3CAE-0728-11D3-9D7B-0000F81EF32E}"; CommonDialogClass wiaDiag = new CommonDialogClass(); WIA.ImageFile wiaImage = null;
wiaImage = wiaDiag.ShowAcquireImage( WiaDeviceType.UnspecifiedDeviceType, WiaImageIntent.GrayscaleIntent, WiaImageBias.MaximizeQuality, wiaFormatJPEG, true, true, false);
WIA.Vector vector = wiaImage.FileData; (System.Drawing) Image i = Image.FromStream(new MemoryStream((byte[])vector.get_BinaryData())); i.Save(filename) Thats a basic way, works with my flatbed/doc feeder. If you need more than one document/page at a time though, there is probably a better way to do it (from what I could see, this only handles one image at a time, although I'm not entirely sure). While it is a WIA v1 doc, Scott Hanselman's Coding4Fun article on WIA does contain some more info on how to do it for multiple pages, I think (I'm yet to go further than that myself) If its for a paperless office system, you might want also check out MODI (Office Document Imaging) to do all the OCR for you. | [
"c#",
".net",
".net-3.5",
"wia",
"image-scanner"
] | 23 | 22 | 40,799 | 5 | 0 | 2008-08-12T15:28:34.573000 | 2008-09-20T11:28:57.827000 |
8,968 | 9,404 | What OSS project should I look at if I need to do Spring friendly WorkFlow? | We need to add WorkFlow to our Spring managed application. Does anyone have any useful experience in using any of the myriad of OSS Work Flow solutions? Which one is best? Which one integrates with Spring best? Which ones should we avoid? | If you only need some simple process orchestration, Spring's own Web Flow, despite its name can serve as a orchestration task manager. If you need to preserve state for several days then you will need to become an 'early adopter' of one of the open-source projects. You may want to look at Eclipse's BPEL project. My hunch is that once a clearer picture of the BPEL/BPM/Workflow space emerges you will see Spring provide an abstraction layer the same way they have for JDBC, Transactions, ORM frameworks etc... | What OSS project should I look at if I need to do Spring friendly WorkFlow? We need to add WorkFlow to our Spring managed application. Does anyone have any useful experience in using any of the myriad of OSS Work Flow solutions? Which one is best? Which one integrates with Spring best? Which ones should we avoid? | TITLE:
What OSS project should I look at if I need to do Spring friendly WorkFlow?
QUESTION:
We need to add WorkFlow to our Spring managed application. Does anyone have any useful experience in using any of the myriad of OSS Work Flow solutions? Which one is best? Which one integrates with Spring best? Which ones should we avoid?
ANSWER:
If you only need some simple process orchestration, Spring's own Web Flow, despite its name can serve as a orchestration task manager. If you need to preserve state for several days then you will need to become an 'early adopter' of one of the open-source projects. You may want to look at Eclipse's BPEL project. My hunch is that once a clearer picture of the BPEL/BPM/Workflow space emerges you will see Spring provide an abstraction layer the same way they have for JDBC, Transactions, ORM frameworks etc... | [
"java",
"spring",
"workflow"
] | 12 | 3 | 935 | 5 | 0 | 2008-08-12T15:29:18.067000 | 2008-08-13T02:02:38.537000 |
8,987 | 8,993 | Calling Table-Valued SQL Functions From .NET | Scalar-valued functions can be called from.NET as follows: SqlCommand cmd = new SqlCommand("testFunction", sqlConn); //testFunction is scalar cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("retVal", SqlDbType.Int); cmd.Parameters["retVal"].Direction = ParameterDirection.ReturnValue; cmd.ExecuteScalar(); int aFunctionResult = (int)cmd.Parameters["retVal"].Value; I also know that table-valued functions can be called in a similar fashion, for example: String query = "select * from testFunction(param1,...)"; //testFunction is table-valued SqlCommand cmd = new SqlCommand(query, sqlConn); SqlDataAdapter adapter = new SqlDataAdapter(cmd); adapter.Fill(tbl); My question is, can table-valued functions be called as stored procedures, like scalar-valued functions can? (e.g., replicate my first code snippet with a table-valued function being called and getting the returned table through a ReturnValue parameter). | No because you need to select them. However you can create a stored proc wrapper, which may defeat the point of having a table function. | Calling Table-Valued SQL Functions From .NET Scalar-valued functions can be called from.NET as follows: SqlCommand cmd = new SqlCommand("testFunction", sqlConn); //testFunction is scalar cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("retVal", SqlDbType.Int); cmd.Parameters["retVal"].Direction = ParameterDirection.ReturnValue; cmd.ExecuteScalar(); int aFunctionResult = (int)cmd.Parameters["retVal"].Value; I also know that table-valued functions can be called in a similar fashion, for example: String query = "select * from testFunction(param1,...)"; //testFunction is table-valued SqlCommand cmd = new SqlCommand(query, sqlConn); SqlDataAdapter adapter = new SqlDataAdapter(cmd); adapter.Fill(tbl); My question is, can table-valued functions be called as stored procedures, like scalar-valued functions can? (e.g., replicate my first code snippet with a table-valued function being called and getting the returned table through a ReturnValue parameter). | TITLE:
Calling Table-Valued SQL Functions From .NET
QUESTION:
Scalar-valued functions can be called from.NET as follows: SqlCommand cmd = new SqlCommand("testFunction", sqlConn); //testFunction is scalar cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("retVal", SqlDbType.Int); cmd.Parameters["retVal"].Direction = ParameterDirection.ReturnValue; cmd.ExecuteScalar(); int aFunctionResult = (int)cmd.Parameters["retVal"].Value; I also know that table-valued functions can be called in a similar fashion, for example: String query = "select * from testFunction(param1,...)"; //testFunction is table-valued SqlCommand cmd = new SqlCommand(query, sqlConn); SqlDataAdapter adapter = new SqlDataAdapter(cmd); adapter.Fill(tbl); My question is, can table-valued functions be called as stored procedures, like scalar-valued functions can? (e.g., replicate my first code snippet with a table-valued function being called and getting the returned table through a ReturnValue parameter).
ANSWER:
No because you need to select them. However you can create a stored proc wrapper, which may defeat the point of having a table function. | [
"c#",
".net",
"sql"
] | 32 | 19 | 19,258 | 1 | 0 | 2008-08-12T15:50:49.460000 | 2008-08-12T15:53:26.193000 |
9,002 | 9,875 | How do I get dbmail to process items from the queue for SQL Server 2005? | When I use the sp_send_dbmail stored procedure, I get a message saying that my mail was queued. However, it never seems to get delivered. I can see them in the queue if I run this SQL: SELECT * FROM msdb..sysmail_allitems WHERE sent_status = 'unsent' This SQL returns a 1: SELECT is_broker_enabled FROM sys.databases WHERE name = 'msdb' This stored procedure returns STARTED: msdb.dbo.sysmail_help_status_sp The appropriate accounts and profiles have been set up and the mail was functioning at one point. There are no errors in msdb.dbo.sysmail_event_log. | Could be oodles of things. For example, I've seen (yes, actually seen) this happen after: Domain controller reboot Exchange server reboot Router outage Service account changes SQL Server running out of disk space So until it happens again, I wouldn't freak out over it. | How do I get dbmail to process items from the queue for SQL Server 2005? When I use the sp_send_dbmail stored procedure, I get a message saying that my mail was queued. However, it never seems to get delivered. I can see them in the queue if I run this SQL: SELECT * FROM msdb..sysmail_allitems WHERE sent_status = 'unsent' This SQL returns a 1: SELECT is_broker_enabled FROM sys.databases WHERE name = 'msdb' This stored procedure returns STARTED: msdb.dbo.sysmail_help_status_sp The appropriate accounts and profiles have been set up and the mail was functioning at one point. There are no errors in msdb.dbo.sysmail_event_log. | TITLE:
How do I get dbmail to process items from the queue for SQL Server 2005?
QUESTION:
When I use the sp_send_dbmail stored procedure, I get a message saying that my mail was queued. However, it never seems to get delivered. I can see them in the queue if I run this SQL: SELECT * FROM msdb..sysmail_allitems WHERE sent_status = 'unsent' This SQL returns a 1: SELECT is_broker_enabled FROM sys.databases WHERE name = 'msdb' This stored procedure returns STARTED: msdb.dbo.sysmail_help_status_sp The appropriate accounts and profiles have been set up and the mail was functioning at one point. There are no errors in msdb.dbo.sysmail_event_log.
ANSWER:
Could be oodles of things. For example, I've seen (yes, actually seen) this happen after: Domain controller reboot Exchange server reboot Router outage Service account changes SQL Server running out of disk space So until it happens again, I wouldn't freak out over it. | [
"sql-server"
] | 4 | 1 | 4,509 | 3 | 0 | 2008-08-12T15:58:30.723000 | 2008-08-13T14:20:56.643000 |
9,009 | 9,011 | Assignment inside Perl ternary conditional operator problems | This snippet of Perl code in my program is giving the wrong result. $condition? $a = 2: $a = 3; print $a; No matter what the value of $condition is, the output is always 3, how come? | This is explained in the Perl documentation. Because of Perl operator precedence the statement is being parsed as ($condition? $a= 2: $a ) = 3; Because the?: operator produces an assignable result, 3 is assigned to the result of the condition. When $condition is true this means ($a=2)=3 giving $a=3 When $condition is false this means ($a)=3 giving $a=3 The correct way to write this is $a = ( $condition? 2: 3 ); print $a; We got bitten by this at work, so I am posting here hoping others will find it useful. | Assignment inside Perl ternary conditional operator problems This snippet of Perl code in my program is giving the wrong result. $condition? $a = 2: $a = 3; print $a; No matter what the value of $condition is, the output is always 3, how come? | TITLE:
Assignment inside Perl ternary conditional operator problems
QUESTION:
This snippet of Perl code in my program is giving the wrong result. $condition? $a = 2: $a = 3; print $a; No matter what the value of $condition is, the output is always 3, how come?
ANSWER:
This is explained in the Perl documentation. Because of Perl operator precedence the statement is being parsed as ($condition? $a= 2: $a ) = 3; Because the?: operator produces an assignable result, 3 is assigned to the result of the condition. When $condition is true this means ($a=2)=3 giving $a=3 When $condition is false this means ($a)=3 giving $a=3 The correct way to write this is $a = ( $condition? 2: 3 ); print $a; We got bitten by this at work, so I am posting here hoping others will find it useful. | [
"perl",
"conditional-operator",
"operator-precedence"
] | 41 | 80 | 7,748 | 5 | 0 | 2008-08-12T16:03:54.893000 | 2008-08-12T16:05:34.390000 |
9,018 | 9,403 | Windows Mobile Device Emulator - how to save config permanently? | I am working at a client site where there is a proxy server ( HTTP ) in place. If I do a hard reset of the emulator it forgets network connection settings for the emulator and settings in the hosted Windows Mobile OS. If I 'save state and exit' it will lose all of these settings. I need to do hard resets regularly which means that I lose this information and spend a lot of time setting: The emulators associated network card DNS servers for network card in the WM OS. Proxy servers in connection settings of WM OS. How can I make my life easier? Can I save this as defaults in the emulator, or create an installer easily? | There is a way you can programmatically provision your devices. If you're using managed code, you can use Microsoft.WindowsMobile.Configuration.dll to do most of the work for you. If you're using unmanaged code, you have to use DMProcessConfigXML native function. There's more details in this blog post by Andrew Arnott. | Windows Mobile Device Emulator - how to save config permanently? I am working at a client site where there is a proxy server ( HTTP ) in place. If I do a hard reset of the emulator it forgets network connection settings for the emulator and settings in the hosted Windows Mobile OS. If I 'save state and exit' it will lose all of these settings. I need to do hard resets regularly which means that I lose this information and spend a lot of time setting: The emulators associated network card DNS servers for network card in the WM OS. Proxy servers in connection settings of WM OS. How can I make my life easier? Can I save this as defaults in the emulator, or create an installer easily? | TITLE:
Windows Mobile Device Emulator - how to save config permanently?
QUESTION:
I am working at a client site where there is a proxy server ( HTTP ) in place. If I do a hard reset of the emulator it forgets network connection settings for the emulator and settings in the hosted Windows Mobile OS. If I 'save state and exit' it will lose all of these settings. I need to do hard resets regularly which means that I lose this information and spend a lot of time setting: The emulators associated network card DNS servers for network card in the WM OS. Proxy servers in connection settings of WM OS. How can I make my life easier? Can I save this as defaults in the emulator, or create an installer easily?
ANSWER:
There is a way you can programmatically provision your devices. If you're using managed code, you can use Microsoft.WindowsMobile.Configuration.dll to do most of the work for you. If you're using unmanaged code, you have to use DMProcessConfigXML native function. There's more details in this blog post by Andrew Arnott. | [
"visual-studio",
"windows-mobile",
"windows-mobile-emulator"
] | 1 | 0 | 2,377 | 2 | 0 | 2008-08-12T16:20:58.040000 | 2008-08-13T02:02:27.727000 |
9,019 | 941,940 | Best method for varchar date validation in Sybase (T-SQL)? | I have a stored procedure which takes as its parameter a varchar which needs to be cast as a datetime for later use: SET @the_date = CAST(@date_string AS DATETIME) I'm expecting the date string to be supplied in the format "DD-MON-YYYY", but in an effort to code defensively, if for some reason it can't be cast successfully, I want to default to the system date and continue. In PL/SQL I could use exception handling to achieve this and I could do this fairly easily with regular expressions too, but the limited pattern matching supported out of the box by Sybase doesn't let me do this and I can't rely on third party libraries or extensions. Is there a simple way of doing this in T-SQL? NB: using Sybase ASE 12.5.3, there is no ISDATE function | I'm having a similar issue. You might be able to do something like this: SET arithabort arith_overflow off SET @the_date = CAST(@date_string AS DATETIME) IF @the_date is NULL set @the_date = getdate() SET arithabort arith_overflow on However, this doesn't work well in a select. It will work well in a cursor (boo) or in logic before / after a SQL batch. | Best method for varchar date validation in Sybase (T-SQL)? I have a stored procedure which takes as its parameter a varchar which needs to be cast as a datetime for later use: SET @the_date = CAST(@date_string AS DATETIME) I'm expecting the date string to be supplied in the format "DD-MON-YYYY", but in an effort to code defensively, if for some reason it can't be cast successfully, I want to default to the system date and continue. In PL/SQL I could use exception handling to achieve this and I could do this fairly easily with regular expressions too, but the limited pattern matching supported out of the box by Sybase doesn't let me do this and I can't rely on third party libraries or extensions. Is there a simple way of doing this in T-SQL? NB: using Sybase ASE 12.5.3, there is no ISDATE function | TITLE:
Best method for varchar date validation in Sybase (T-SQL)?
QUESTION:
I have a stored procedure which takes as its parameter a varchar which needs to be cast as a datetime for later use: SET @the_date = CAST(@date_string AS DATETIME) I'm expecting the date string to be supplied in the format "DD-MON-YYYY", but in an effort to code defensively, if for some reason it can't be cast successfully, I want to default to the system date and continue. In PL/SQL I could use exception handling to achieve this and I could do this fairly easily with regular expressions too, but the limited pattern matching supported out of the box by Sybase doesn't let me do this and I can't rely on third party libraries or extensions. Is there a simple way of doing this in T-SQL? NB: using Sybase ASE 12.5.3, there is no ISDATE function
ANSWER:
I'm having a similar issue. You might be able to do something like this: SET arithabort arith_overflow off SET @the_date = CAST(@date_string AS DATETIME) IF @the_date is NULL set @the_date = getdate() SET arithabort arith_overflow on However, this doesn't work well in a select. It will work well in a cursor (boo) or in logic before / after a SQL batch. | [
"t-sql",
"validation",
"datetime",
"varchar",
"sap-ase"
] | 2 | 1 | 10,073 | 6 | 0 | 2008-08-12T16:22:14.793000 | 2009-06-02T21:10:00.147000 |
9,022 | 9,356 | How have Html entities inside asp.net page? | Inside an asp.net page, should I use My page's title from México Or My page’s title from México Both examples have the same output. Since asp.net encodes all my pages to utf-8, there is no need to use html entities, is that right? | The ASCII table is set of characters, arguable the first standardized set of characters back in the days when you could only spare 1 byte per character. http://asciitable.com/ But I did some looking around at the extended character set of ASCII and it appears that the character you are referencing is an ASCII character. So there really isn't a problem which ever way you choose to display your title. My revised answer is go for less expensive one according to space (i.e. the first one) | How have Html entities inside asp.net page? Inside an asp.net page, should I use My page's title from México Or My page’s title from México Both examples have the same output. Since asp.net encodes all my pages to utf-8, there is no need to use html entities, is that right? | TITLE:
How have Html entities inside asp.net page?
QUESTION:
Inside an asp.net page, should I use My page's title from México Or My page’s title from México Both examples have the same output. Since asp.net encodes all my pages to utf-8, there is no need to use html entities, is that right?
ANSWER:
The ASCII table is set of characters, arguable the first standardized set of characters back in the days when you could only spare 1 byte per character. http://asciitable.com/ But I did some looking around at the extended character set of ASCII and it appears that the character you are referencing is an ASCII character. So there really isn't a problem which ever way you choose to display your title. My revised answer is go for less expensive one according to space (i.e. the first one) | [
"asp.net",
"html",
"encoding"
] | 7 | 3 | 2,657 | 3 | 0 | 2008-08-12T16:25:18.720000 | 2008-08-13T00:37:12.063000 |
9,024 | 9,031 | HTTPS in IIS 5.1 | I'm using IIS 5.1 in Windows XP on my development computer. I'm going to set up HTTPS on my company's web server, but I want to try doing it locally before doing it on a production system. But when I go into the Directory Security tab of my web site's configuration section, the "Secure communication" groupbox is disabled. Is there something I need to do to make this groupbox enabled? | That is because IIS 5.1 under the limited Windows XP version is limited to only HTTP. You need to have a full version of IIS 6.0 on Windows 2003 to do this. Luckily you can download a VHD image of Windows 2003 from Microsoft and run it under a Virtual PC instance. Plus I would recommend this since you are trying to be careful and use a machine close to your production environment. IIS 5.1 version is never deployed as a production machine so you cannot guarantee anything and the differences between IIS 5.1 and IIS 6.0 are significant enough where the VM is worth your while. | HTTPS in IIS 5.1 I'm using IIS 5.1 in Windows XP on my development computer. I'm going to set up HTTPS on my company's web server, but I want to try doing it locally before doing it on a production system. But when I go into the Directory Security tab of my web site's configuration section, the "Secure communication" groupbox is disabled. Is there something I need to do to make this groupbox enabled? | TITLE:
HTTPS in IIS 5.1
QUESTION:
I'm using IIS 5.1 in Windows XP on my development computer. I'm going to set up HTTPS on my company's web server, but I want to try doing it locally before doing it on a production system. But when I go into the Directory Security tab of my web site's configuration section, the "Secure communication" groupbox is disabled. Is there something I need to do to make this groupbox enabled?
ANSWER:
That is because IIS 5.1 under the limited Windows XP version is limited to only HTTP. You need to have a full version of IIS 6.0 on Windows 2003 to do this. Luckily you can download a VHD image of Windows 2003 from Microsoft and run it under a Virtual PC instance. Plus I would recommend this since you are trying to be careful and use a machine close to your production environment. IIS 5.1 version is never deployed as a production machine so you cannot guarantee anything and the differences between IIS 5.1 and IIS 6.0 are significant enough where the VM is worth your while. | [
"iis",
"ssl"
] | 7 | 3 | 3,283 | 2 | 0 | 2008-08-12T16:27:39.510000 | 2008-08-12T16:31:02.403000 |
9,044 | 275,353 | Can I specify a class wide group on a TestNG test case? | I have a base class that represents a database test in TestNG, and I want to specify that all classes extending from this class are of a group "db-test", however I have found that this doesn't seem possible. I have tried the @Test annotation: @Test(groups = { "db-test" }) public class DBTestBase { } However, this doesn't work because the @Test annotation will try to make a bunch of methods into tests, and warnings/errors pop up in eclipse when the tests are run. So I tried disabling the test, so at least the groups are assigned: @Test(enabled = false, groups = { "db-test" }) public class DBTestBase { } but then any @BeforeTest (and other similar annotations) ALSO get disabled... which is of course not what I want. I would like some way to annotate a class as being of a particular type of group, but it doesn't quite seem possible in TestNG. Does anyone have any other ideas? | The answer is through a custom org.testng.IMethodSelector: Its includeMethod() can exclude any method we want, like a public not-annotated method. However, to register a custom Java MethodSelector, you must add it to the XMLTest instance managed by any TestRunner, which means you need your own custom TestRunner. But, to build a custom TestRunner, you need to register a TestRunnerFactory, through the -testrunfactory option. BUT that -testrunfactory is NEVER taken into account by TestNG class... so you need also to define a custom TestNG class: in order to override the configure(Map) method, so you can actually set the TestRunnerFactory TestRunnerFactory which will build you a custom TestRunner, TestRunner which will set to the XMLTest instance a custom XMLMethodSelector XMLMethodSelector which will build a custom IMethodSelector IMethodSelector which will exclude any TestNG methods of your choosing! Ok... it's a nightmare. But it is also a code-challenge, so it must be a little challenging;) All the code is available at DZone snippets. As usual for a code challenge: one java class (and quite a few inner classes) copy-paste the class in a 'source/test' directory (since the package is 'test') run it (no arguments needed) Update from Mike Stone: I'm going to accept this because it sounds pretty close to what I ended up doing, but I figured I would add what I did as well. Basically, I created a Groups annotation that behaves like the groups property of the Test (and other) annotations. Then, I created a GroupsAnnotationTransformer, which uses IAnnotationTransformer to look at all tests and test classes being defined, then modifies the test to add the groups, which works perfectly with group exclusion and inclusion. Modify the build to use the new annotation transformer, and it all works perfectly! Well... the one caveat is that it doesn't add the groups to non-test methods... because at the time I did this, there was another annotation transformer that lets you transform ANYTHING, but it somehow wasn't included in the TestNG I was using for some reason... so it is a good idea to make your before/after annotated methods to alwaysRun=true... which is sufficient for me. The end result is I can do: @Groups({ "myGroup1", "myGroup2"}) public class MyTestCase { @Test @Groups("aMethodLevelGroup") public void myTest() { } } And I made the transformer work with subclassing and everything. | Can I specify a class wide group on a TestNG test case? I have a base class that represents a database test in TestNG, and I want to specify that all classes extending from this class are of a group "db-test", however I have found that this doesn't seem possible. I have tried the @Test annotation: @Test(groups = { "db-test" }) public class DBTestBase { } However, this doesn't work because the @Test annotation will try to make a bunch of methods into tests, and warnings/errors pop up in eclipse when the tests are run. So I tried disabling the test, so at least the groups are assigned: @Test(enabled = false, groups = { "db-test" }) public class DBTestBase { } but then any @BeforeTest (and other similar annotations) ALSO get disabled... which is of course not what I want. I would like some way to annotate a class as being of a particular type of group, but it doesn't quite seem possible in TestNG. Does anyone have any other ideas? | TITLE:
Can I specify a class wide group on a TestNG test case?
QUESTION:
I have a base class that represents a database test in TestNG, and I want to specify that all classes extending from this class are of a group "db-test", however I have found that this doesn't seem possible. I have tried the @Test annotation: @Test(groups = { "db-test" }) public class DBTestBase { } However, this doesn't work because the @Test annotation will try to make a bunch of methods into tests, and warnings/errors pop up in eclipse when the tests are run. So I tried disabling the test, so at least the groups are assigned: @Test(enabled = false, groups = { "db-test" }) public class DBTestBase { } but then any @BeforeTest (and other similar annotations) ALSO get disabled... which is of course not what I want. I would like some way to annotate a class as being of a particular type of group, but it doesn't quite seem possible in TestNG. Does anyone have any other ideas?
ANSWER:
The answer is through a custom org.testng.IMethodSelector: Its includeMethod() can exclude any method we want, like a public not-annotated method. However, to register a custom Java MethodSelector, you must add it to the XMLTest instance managed by any TestRunner, which means you need your own custom TestRunner. But, to build a custom TestRunner, you need to register a TestRunnerFactory, through the -testrunfactory option. BUT that -testrunfactory is NEVER taken into account by TestNG class... so you need also to define a custom TestNG class: in order to override the configure(Map) method, so you can actually set the TestRunnerFactory TestRunnerFactory which will build you a custom TestRunner, TestRunner which will set to the XMLTest instance a custom XMLMethodSelector XMLMethodSelector which will build a custom IMethodSelector IMethodSelector which will exclude any TestNG methods of your choosing! Ok... it's a nightmare. But it is also a code-challenge, so it must be a little challenging;) All the code is available at DZone snippets. As usual for a code challenge: one java class (and quite a few inner classes) copy-paste the class in a 'source/test' directory (since the package is 'test') run it (no arguments needed) Update from Mike Stone: I'm going to accept this because it sounds pretty close to what I ended up doing, but I figured I would add what I did as well. Basically, I created a Groups annotation that behaves like the groups property of the Test (and other) annotations. Then, I created a GroupsAnnotationTransformer, which uses IAnnotationTransformer to look at all tests and test classes being defined, then modifies the test to add the groups, which works perfectly with group exclusion and inclusion. Modify the build to use the new annotation transformer, and it all works perfectly! Well... the one caveat is that it doesn't add the groups to non-test methods... because at the time I did this, there was another annotation transformer that lets you transform ANYTHING, but it somehow wasn't included in the TestNG I was using for some reason... so it is a good idea to make your before/after annotated methods to alwaysRun=true... which is sufficient for me. The end result is I can do: @Groups({ "myGroup1", "myGroup2"}) public class MyTestCase { @Test @Groups("aMethodLevelGroup") public void myTest() { } } And I made the transformer work with subclassing and everything. | [
"java",
"testng"
] | 16 | 2 | 12,563 | 5 | 0 | 2008-08-12T16:52:08.697000 | 2008-11-08T23:12:31.067000 |
9,052 | 9,054 | Is there a way for MS Access to grab the current Active Directory user? | I'm working on a spec for a piece of software for my company and as part of the auditing system I think it would be neat if there was a way to grab the current Active Directory user. Hopefully something like: Dim strUser as String strUser = ActiveDirectory.User() MsgBox "Welcome back, " & strUser | Try this article - I have some code at work that will erm, work if this doesn't... Relevant quote: Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" _ (ByVal IpBuffer As String, nSize As Long) As Long Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" _ (ByVal lpBuffer As String, nSize As Long) As Long
Function ThisUserName() As String Dim LngBufLen As Long Dim strUser As String
strUser = String$(15, " ") LngBufLen = 15
If GetUserName(strUser, LngBufLen) = 1 Then ThisUserName = Left(strUser, LngBufLen - 1) Else ThisUserName = "Unknown" End If End Function
Function ThisComputerID() As String Dim LngBufLen As Long Dim strUser As String
strUser = String$(15, " ") LngBufLen = 15
If GetComputerName(strUser, LngBufLen) = 1 Then ThisComputerID = Left(strUser, LngBufLen) Else ThisComputerID = 0 End If End Function | Is there a way for MS Access to grab the current Active Directory user? I'm working on a spec for a piece of software for my company and as part of the auditing system I think it would be neat if there was a way to grab the current Active Directory user. Hopefully something like: Dim strUser as String strUser = ActiveDirectory.User() MsgBox "Welcome back, " & strUser | TITLE:
Is there a way for MS Access to grab the current Active Directory user?
QUESTION:
I'm working on a spec for a piece of software for my company and as part of the auditing system I think it would be neat if there was a way to grab the current Active Directory user. Hopefully something like: Dim strUser as String strUser = ActiveDirectory.User() MsgBox "Welcome back, " & strUser
ANSWER:
Try this article - I have some code at work that will erm, work if this doesn't... Relevant quote: Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" _ (ByVal IpBuffer As String, nSize As Long) As Long Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" _ (ByVal lpBuffer As String, nSize As Long) As Long
Function ThisUserName() As String Dim LngBufLen As Long Dim strUser As String
strUser = String$(15, " ") LngBufLen = 15
If GetUserName(strUser, LngBufLen) = 1 Then ThisUserName = Left(strUser, LngBufLen - 1) Else ThisUserName = "Unknown" End If End Function
Function ThisComputerID() As String Dim LngBufLen As Long Dim strUser As String
strUser = String$(15, " ") LngBufLen = 15
If GetComputerName(strUser, LngBufLen) = 1 Then ThisComputerID = Left(strUser, LngBufLen) Else ThisComputerID = 0 End If End Function | [
"ms-access",
"active-directory"
] | 12 | 6 | 28,642 | 4 | 0 | 2008-08-12T17:03:28.220000 | 2008-08-12T17:07:52.563000 |
9,072 | 204,732 | YUI drag&drop proxy drag | Question for YUI experts... I have a table and I've made each cell of the first row draggable by proxy. In IE, when the drag proxy is released, the original table cell actually jumps to wherever the release point was. How can I prevent this from happening? Essentially, I want to know where the proxy was dropped and handle my logic from there but I don't want the original to move. | You have to override the drop-functions, check for DD::dragOverEvent( ) DD:endDragEvent( ) functions on this reference: http://developer.yahoo.com/yui/docs/YAHOO.util.DD.html | YUI drag&drop proxy drag Question for YUI experts... I have a table and I've made each cell of the first row draggable by proxy. In IE, when the drag proxy is released, the original table cell actually jumps to wherever the release point was. How can I prevent this from happening? Essentially, I want to know where the proxy was dropped and handle my logic from there but I don't want the original to move. | TITLE:
YUI drag&drop proxy drag
QUESTION:
Question for YUI experts... I have a table and I've made each cell of the first row draggable by proxy. In IE, when the drag proxy is released, the original table cell actually jumps to wherever the release point was. How can I prevent this from happening? Essentially, I want to know where the proxy was dropped and handle my logic from there but I don't want the original to move.
ANSWER:
You have to override the drop-functions, check for DD::dragOverEvent( ) DD:endDragEvent( ) functions on this reference: http://developer.yahoo.com/yui/docs/YAHOO.util.DD.html | [
"javascript",
"drag-and-drop",
"yui"
] | 6 | 2 | 1,071 | 1 | 0 | 2008-08-12T17:47:26.213000 | 2008-10-15T13:39:36.597000 |
9,081 | 9,083 | grep: show lines surrounding each match | How do I grep and show the preceding and following 5 lines surrounding each matched line? | For BSD or GNU grep you can use -B num to set how many lines before the match and -A num for the number of lines after the match. grep -B 3 -A 2 foo README.txt If you want the same number of lines before and after you can use -C num. grep -C 3 foo README.txt This will show 3 lines before and 3 lines after. | grep: show lines surrounding each match How do I grep and show the preceding and following 5 lines surrounding each matched line? | TITLE:
grep: show lines surrounding each match
QUESTION:
How do I grep and show the preceding and following 5 lines surrounding each matched line?
ANSWER:
For BSD or GNU grep you can use -B num to set how many lines before the match and -A num for the number of lines after the match. grep -B 3 -A 2 foo README.txt If you want the same number of lines before and after you can use -C num. grep -C 3 foo README.txt This will show 3 lines before and 3 lines after. | [
"search",
"logging",
"grep",
"command-line-interface"
] | 4,136 | 5,423 | 1,505,962 | 13 | 0 | 2008-08-12T17:55:32.813000 | 2008-08-12T17:57:43.307000 |
9,104 | 9,105 | Add a bookmark that is only javascript, not a URL | I'm thinking that the reason I can't do this is because it might be a huge security hole, but here goes... I want to have a bookmark on my browser (FF3, preferably) that is only a snippet of javascript code. It would merely construct a URL based on the current date and then do a window.location = on that URL. I know that I could make a page and keep it on my local machine and just refer to it that way, but I was just wondering if you could bypass that step and actually have the "location" of the bookmark really just be javascript. I could have sworn that this was possible years ago, but I can't find anything that tells me either way now. | What you want is a bookmarklet they are easy to create and should work in most major browsers. Edit: Stack overflow seems not to allow creating bookmarklets in the context of the site, basically you can create a new bookmark and type the following in the location field javascript:window.location='http://www.google.com/search?q='+Date() to get a bookmarklet that searches google for the current date. | Add a bookmark that is only javascript, not a URL I'm thinking that the reason I can't do this is because it might be a huge security hole, but here goes... I want to have a bookmark on my browser (FF3, preferably) that is only a snippet of javascript code. It would merely construct a URL based on the current date and then do a window.location = on that URL. I know that I could make a page and keep it on my local machine and just refer to it that way, but I was just wondering if you could bypass that step and actually have the "location" of the bookmark really just be javascript. I could have sworn that this was possible years ago, but I can't find anything that tells me either way now. | TITLE:
Add a bookmark that is only javascript, not a URL
QUESTION:
I'm thinking that the reason I can't do this is because it might be a huge security hole, but here goes... I want to have a bookmark on my browser (FF3, preferably) that is only a snippet of javascript code. It would merely construct a URL based on the current date and then do a window.location = on that URL. I know that I could make a page and keep it on my local machine and just refer to it that way, but I was just wondering if you could bypass that step and actually have the "location" of the bookmark really just be javascript. I could have sworn that this was possible years ago, but I can't find anything that tells me either way now.
ANSWER:
What you want is a bookmarklet they are easy to create and should work in most major browsers. Edit: Stack overflow seems not to allow creating bookmarklets in the context of the site, basically you can create a new bookmark and type the following in the location field javascript:window.location='http://www.google.com/search?q='+Date() to get a bookmarklet that searches google for the current date. | [
"javascript",
"bookmarklet",
"bookmarks"
] | 59 | 73 | 77,167 | 5 | 0 | 2008-08-12T18:27:35.883000 | 2008-08-12T18:29:24.037000 |
9,122 | 1,495,476 | Select all columns except one in MySQL? | I'm trying to use a select statement to get all of the columns from a certain MySQL table except one. Is there a simple way to do this? EDIT: There are 53 columns in this table (NOT MY DESIGN) | Actually there is a way, you need to have permissions of course for doing this... SET @sql = CONCAT('SELECT ', (SELECT REPLACE(GROUP_CONCAT(COLUMN_NAME), ',', '') FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = ' ' AND TABLE_SCHEMA = ' '), ' FROM ');
PREPARE stmt1 FROM @sql; EXECUTE stmt1; Replacing, and | Select all columns except one in MySQL? I'm trying to use a select statement to get all of the columns from a certain MySQL table except one. Is there a simple way to do this? EDIT: There are 53 columns in this table (NOT MY DESIGN) | TITLE:
Select all columns except one in MySQL?
QUESTION:
I'm trying to use a select statement to get all of the columns from a certain MySQL table except one. Is there a simple way to do this? EDIT: There are 53 columns in this table (NOT MY DESIGN)
ANSWER:
Actually there is a way, you need to have permissions of course for doing this... SET @sql = CONCAT('SELECT ', (SELECT REPLACE(GROUP_CONCAT(COLUMN_NAME), ',', '') FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = ' ' AND TABLE_SCHEMA = ' '), ' FROM ');
PREPARE stmt1 FROM @sql; EXECUTE stmt1; Replacing, and | [
"mysql",
"select",
"wildcard"
] | 464 | 253 | 491,111 | 34 | 0 | 2008-08-12T18:45:55.207000 | 2009-09-29T23:35:25.420000 |
9,136 | 9,706 | Enterprise Library CacheFactory.GetCacheManager Throws Null Ref | I'm trying to convert an application using the 1.1 version of the Enterprise Library Caching block over to the 2.0 version. I think where I'm really having a problem is that the configuration for the different EntLib pieces was split out over several files. Apparently, this used to be handled by the ConfigurationManagerSectionHandler, but is now obsolete in favor of the built-in configuration mechanisms in.NET 2.0. I'm having a hard time finding a good example of how to do this configuration file splitting, especially in the context of EntLib. Has anyone else dealt with this? | Looks like it was the configuration. I found a good example of the normal, one-file approach here: http://www.devx.com/dotnet/Article/31158/0/page/2 Using an external config file is actually trivial once you figure out the syntax for it. Ex.: In Web.config: In cachingconfiguration.config: Hopefully this helps somebody! | Enterprise Library CacheFactory.GetCacheManager Throws Null Ref I'm trying to convert an application using the 1.1 version of the Enterprise Library Caching block over to the 2.0 version. I think where I'm really having a problem is that the configuration for the different EntLib pieces was split out over several files. Apparently, this used to be handled by the ConfigurationManagerSectionHandler, but is now obsolete in favor of the built-in configuration mechanisms in.NET 2.0. I'm having a hard time finding a good example of how to do this configuration file splitting, especially in the context of EntLib. Has anyone else dealt with this? | TITLE:
Enterprise Library CacheFactory.GetCacheManager Throws Null Ref
QUESTION:
I'm trying to convert an application using the 1.1 version of the Enterprise Library Caching block over to the 2.0 version. I think where I'm really having a problem is that the configuration for the different EntLib pieces was split out over several files. Apparently, this used to be handled by the ConfigurationManagerSectionHandler, but is now obsolete in favor of the built-in configuration mechanisms in.NET 2.0. I'm having a hard time finding a good example of how to do this configuration file splitting, especially in the context of EntLib. Has anyone else dealt with this?
ANSWER:
Looks like it was the configuration. I found a good example of the normal, one-file approach here: http://www.devx.com/dotnet/Article/31158/0/page/2 Using an external config file is actually trivial once you figure out the syntax for it. Ex.: In Web.config: In cachingconfiguration.config: Hopefully this helps somebody! | [
"c#",
"configuration",
"enterprise-library"
] | 6 | 4 | 9,182 | 1 | 0 | 2008-08-12T19:01:17.140000 | 2008-08-13T12:29:57.647000 |
9,161 | 9,176 | Opening a file in my application from File Explorer | I've created my own application in VB.NET that saves its documents into a file with it's own custom extension (.eds). Assuming that I've properly associated the file extension with my application, how do I actually handle the processing of the selected file within my application when I double click on the file in File Explorer? Do I grab an argsc/argsv variable in my Application.Load() method or is it something else? | Try this article but short answer is My.Application.CommandLineArgs | Opening a file in my application from File Explorer I've created my own application in VB.NET that saves its documents into a file with it's own custom extension (.eds). Assuming that I've properly associated the file extension with my application, how do I actually handle the processing of the selected file within my application when I double click on the file in File Explorer? Do I grab an argsc/argsv variable in my Application.Load() method or is it something else? | TITLE:
Opening a file in my application from File Explorer
QUESTION:
I've created my own application in VB.NET that saves its documents into a file with it's own custom extension (.eds). Assuming that I've properly associated the file extension with my application, how do I actually handle the processing of the selected file within my application when I double click on the file in File Explorer? Do I grab an argsc/argsv variable in my Application.Load() method or is it something else?
ANSWER:
Try this article but short answer is My.Application.CommandLineArgs | [
"vb.net",
"file-extension"
] | 5 | 2 | 1,330 | 1 | 0 | 2008-08-12T19:27:35.153000 | 2008-08-12T19:37:01.907000 |
9,173 | 559,613 | Lingering assembly dependency in C# .NET | My C# project - we'll call it the SuperUI - used to make use of a class from an external assembly. Now it doesn't, but the compiler won't let me build the project without the assembly reference in place. Let me elaborate. This project used to throw and catch a custom exception class - the SuperException - which was derived from the standard System.Exception and lived in a separate, precompiled assembly, SuperAssembly.DLL, which I referenced. Eventually, I decided this was a pointless exercise and replaced all SuperExceptions with a System.SuitableStandardException in each case. I removed the reference to SuperException.DLL, but am now met with the following on trying to compile the project: The type 'SuperException' is defined in an assembly that is not referenced. You must add a reference to assembly 'SuperException, Version=1.1.0.0 (...)' The source file referenced by the error doesn't seem relevant; it's the project namespace that gets highlighted in the IDE. Now, here's the thing: All uses of SuperException have been eliminated from the project's code. Compared to another project that compiles fine without a reference to SuperException.DLL, I only reference one more assembly - and that references nothing that my project doesn't reference itself. While it's possible that any of these dependencies could throw SuperExceptions, I'm only catching the base Exception class and in any case... the other project builds fine! I've done Visual Studio's "Clean Solution" and cleared everything out by hand, many times. It's not the end of the world to include this reference, I just don't see why it's necessary any more. Nrrrgg. Any pointers welcome! | It's likely a transitive reference, where some type method call returns an instance of SuperException boxed ("downcast") as e.g. Exception, but from inspecting the code in the transitively included code, i.e. code from your external method calls, the compiler knows that you need to be able to have information about that type at some point. Resharper would tell you where it's the case that you need to add a reference, and you could use Lütz Roeder's aka RedGate's Reflector to scan compiled IL for a reference to this type in two ways: 1) use the search-facility, 2) open each public type you're using and for that one which requires the "ghost" assembly, it will ask you to specify its location. This most often happends to me when I reference Castle.Windsor but not Castle.MicroKernel.:p | Lingering assembly dependency in C# .NET My C# project - we'll call it the SuperUI - used to make use of a class from an external assembly. Now it doesn't, but the compiler won't let me build the project without the assembly reference in place. Let me elaborate. This project used to throw and catch a custom exception class - the SuperException - which was derived from the standard System.Exception and lived in a separate, precompiled assembly, SuperAssembly.DLL, which I referenced. Eventually, I decided this was a pointless exercise and replaced all SuperExceptions with a System.SuitableStandardException in each case. I removed the reference to SuperException.DLL, but am now met with the following on trying to compile the project: The type 'SuperException' is defined in an assembly that is not referenced. You must add a reference to assembly 'SuperException, Version=1.1.0.0 (...)' The source file referenced by the error doesn't seem relevant; it's the project namespace that gets highlighted in the IDE. Now, here's the thing: All uses of SuperException have been eliminated from the project's code. Compared to another project that compiles fine without a reference to SuperException.DLL, I only reference one more assembly - and that references nothing that my project doesn't reference itself. While it's possible that any of these dependencies could throw SuperExceptions, I'm only catching the base Exception class and in any case... the other project builds fine! I've done Visual Studio's "Clean Solution" and cleared everything out by hand, many times. It's not the end of the world to include this reference, I just don't see why it's necessary any more. Nrrrgg. Any pointers welcome! | TITLE:
Lingering assembly dependency in C# .NET
QUESTION:
My C# project - we'll call it the SuperUI - used to make use of a class from an external assembly. Now it doesn't, but the compiler won't let me build the project without the assembly reference in place. Let me elaborate. This project used to throw and catch a custom exception class - the SuperException - which was derived from the standard System.Exception and lived in a separate, precompiled assembly, SuperAssembly.DLL, which I referenced. Eventually, I decided this was a pointless exercise and replaced all SuperExceptions with a System.SuitableStandardException in each case. I removed the reference to SuperException.DLL, but am now met with the following on trying to compile the project: The type 'SuperException' is defined in an assembly that is not referenced. You must add a reference to assembly 'SuperException, Version=1.1.0.0 (...)' The source file referenced by the error doesn't seem relevant; it's the project namespace that gets highlighted in the IDE. Now, here's the thing: All uses of SuperException have been eliminated from the project's code. Compared to another project that compiles fine without a reference to SuperException.DLL, I only reference one more assembly - and that references nothing that my project doesn't reference itself. While it's possible that any of these dependencies could throw SuperExceptions, I'm only catching the base Exception class and in any case... the other project builds fine! I've done Visual Studio's "Clean Solution" and cleared everything out by hand, many times. It's not the end of the world to include this reference, I just don't see why it's necessary any more. Nrrrgg. Any pointers welcome!
ANSWER:
It's likely a transitive reference, where some type method call returns an instance of SuperException boxed ("downcast") as e.g. Exception, but from inspecting the code in the transitively included code, i.e. code from your external method calls, the compiler knows that you need to be able to have information about that type at some point. Resharper would tell you where it's the case that you need to add a reference, and you could use Lütz Roeder's aka RedGate's Reflector to scan compiled IL for a reference to this type in two ways: 1) use the search-facility, 2) open each public type you're using and for that one which requires the "ghost" assembly, it will ask you to specify its location. This most often happends to me when I reference Castle.Windsor but not Castle.MicroKernel.:p | [
"c#",
".net",
"dependencies"
] | 8 | 3 | 5,414 | 14 | 0 | 2008-08-12T19:35:44.590000 | 2009-02-18T02:23:00.040000 |
9,191 | 9,826 | How to obtain good concurrent read performance from disk | I'd like to ask a question then follow it up with my own answer, but also see what answers other people have. We have two large files which we'd like to read from two separate threads concurrently. One thread will sequentially read fileA while the other thread will sequentially read fileB. There is no locking or communication between the threads, both are sequentially reading as fast as they can, and both are immediately discarding the data they read. Our experience with this setup on Windows is very poor. The combined throughput of the two threads is in the order of 2-3 MiB/sec. The drive seems to be spending most of its time seeking backwards and forwards between the two files, presumably reading very little after each seek. If we disable one of the threads and temporarily look at the performance of a single thread then we get much better bandwidth (~45 MiB/sec for this machine). So clearly the bad two-thread performance is an artefact of the OS disk scheduler. Is there anything we can do to improve the concurrent thread read performance? Perhaps by using different APIs or by tweaking the OS disk scheduler parameters in some way. Some details: The files are in the order of 2 GiB each on a machine with 2GiB of RAM. For the purpose of this question we consider them not to be cached and perfectly defragmented. We have used defrag tools and rebooted to ensure this is the case. We are using no special APIs to read these files. The behaviour is repeatable across various bog-standard APIs such as Win32's CreateFile, C's fopen, C++'s std::ifstream, Java's FileInputStream, etc. Each thread spins in a loop making calls to the read function. We have varied the number of bytes requested from the API each iteration from values between 1KiB up to 128MiB. Varying this has had no effect, so clearly the amount the OS is physically reading after each disk seek is not dictated by this number. This is exactly what should be expected. The dramatic difference between one-thread and two-thread performance is repeatable across Windows 2000, Windows XP (32-bit and 64-bit), Windows Server 2003, and also with and without hardware RAID5. | The problem seems to be in Windows I/O scheduling policy. According to what I found here there are many ways for an O.S. to schedule disk requests. While Linux and others can choose between different policies, before Vista Windows was locked in a single policy: a FIFO queue, where all requests where splitted in 64 KB blocks. I believe that this policy is the cause for the problem you are experiencing: the scheduler will mix requests from the two threads, causing continuous seek between different areas of the disk. Now, the good news is that according to here and here, Vista introduced a smarter disk scheduler, where you can set the priority of your requests and also allocate a minimum badwidth for your process. The bad news is that I found no way to change disk policy or buffers size in previous versions of Windows. Also, even if raising disk I/O priority of your process will boost the performance against the other processes, you still have the problems of your threads competing against each other. What I can suggest is to modify your software by introducing a self-made disk access policy. For example, you could use a policy like this in your thread B (similar for Thread A): if THREAD A is reading from disk then wait for THREAD A to stop reading or wait for X ms Read for X ms (or Y MB) Stop reading and check status of thread A again You could use semaphores for status checking or you could use perfmon counters to get the status of the actual disk queue. The values of X and/or Y could also be auto-tuned by checking the actual trasfer rates and slowly modify them, thus maximizing the throughtput when the application runs on different machines and/or O.S. You could find that cache, memory or RAID levels affect them in a way or the other, but with auto-tuning you will always get the best performance in every scenario. | How to obtain good concurrent read performance from disk I'd like to ask a question then follow it up with my own answer, but also see what answers other people have. We have two large files which we'd like to read from two separate threads concurrently. One thread will sequentially read fileA while the other thread will sequentially read fileB. There is no locking or communication between the threads, both are sequentially reading as fast as they can, and both are immediately discarding the data they read. Our experience with this setup on Windows is very poor. The combined throughput of the two threads is in the order of 2-3 MiB/sec. The drive seems to be spending most of its time seeking backwards and forwards between the two files, presumably reading very little after each seek. If we disable one of the threads and temporarily look at the performance of a single thread then we get much better bandwidth (~45 MiB/sec for this machine). So clearly the bad two-thread performance is an artefact of the OS disk scheduler. Is there anything we can do to improve the concurrent thread read performance? Perhaps by using different APIs or by tweaking the OS disk scheduler parameters in some way. Some details: The files are in the order of 2 GiB each on a machine with 2GiB of RAM. For the purpose of this question we consider them not to be cached and perfectly defragmented. We have used defrag tools and rebooted to ensure this is the case. We are using no special APIs to read these files. The behaviour is repeatable across various bog-standard APIs such as Win32's CreateFile, C's fopen, C++'s std::ifstream, Java's FileInputStream, etc. Each thread spins in a loop making calls to the read function. We have varied the number of bytes requested from the API each iteration from values between 1KiB up to 128MiB. Varying this has had no effect, so clearly the amount the OS is physically reading after each disk seek is not dictated by this number. This is exactly what should be expected. The dramatic difference between one-thread and two-thread performance is repeatable across Windows 2000, Windows XP (32-bit and 64-bit), Windows Server 2003, and also with and without hardware RAID5. | TITLE:
How to obtain good concurrent read performance from disk
QUESTION:
I'd like to ask a question then follow it up with my own answer, but also see what answers other people have. We have two large files which we'd like to read from two separate threads concurrently. One thread will sequentially read fileA while the other thread will sequentially read fileB. There is no locking or communication between the threads, both are sequentially reading as fast as they can, and both are immediately discarding the data they read. Our experience with this setup on Windows is very poor. The combined throughput of the two threads is in the order of 2-3 MiB/sec. The drive seems to be spending most of its time seeking backwards and forwards between the two files, presumably reading very little after each seek. If we disable one of the threads and temporarily look at the performance of a single thread then we get much better bandwidth (~45 MiB/sec for this machine). So clearly the bad two-thread performance is an artefact of the OS disk scheduler. Is there anything we can do to improve the concurrent thread read performance? Perhaps by using different APIs or by tweaking the OS disk scheduler parameters in some way. Some details: The files are in the order of 2 GiB each on a machine with 2GiB of RAM. For the purpose of this question we consider them not to be cached and perfectly defragmented. We have used defrag tools and rebooted to ensure this is the case. We are using no special APIs to read these files. The behaviour is repeatable across various bog-standard APIs such as Win32's CreateFile, C's fopen, C++'s std::ifstream, Java's FileInputStream, etc. Each thread spins in a loop making calls to the read function. We have varied the number of bytes requested from the API each iteration from values between 1KiB up to 128MiB. Varying this has had no effect, so clearly the amount the OS is physically reading after each disk seek is not dictated by this number. This is exactly what should be expected. The dramatic difference between one-thread and two-thread performance is repeatable across Windows 2000, Windows XP (32-bit and 64-bit), Windows Server 2003, and also with and without hardware RAID5.
ANSWER:
The problem seems to be in Windows I/O scheduling policy. According to what I found here there are many ways for an O.S. to schedule disk requests. While Linux and others can choose between different policies, before Vista Windows was locked in a single policy: a FIFO queue, where all requests where splitted in 64 KB blocks. I believe that this policy is the cause for the problem you are experiencing: the scheduler will mix requests from the two threads, causing continuous seek between different areas of the disk. Now, the good news is that according to here and here, Vista introduced a smarter disk scheduler, where you can set the priority of your requests and also allocate a minimum badwidth for your process. The bad news is that I found no way to change disk policy or buffers size in previous versions of Windows. Also, even if raising disk I/O priority of your process will boost the performance against the other processes, you still have the problems of your threads competing against each other. What I can suggest is to modify your software by introducing a self-made disk access policy. For example, you could use a policy like this in your thread B (similar for Thread A): if THREAD A is reading from disk then wait for THREAD A to stop reading or wait for X ms Read for X ms (or Y MB) Stop reading and check status of thread A again You could use semaphores for status checking or you could use perfmon counters to get the status of the actual disk queue. The values of X and/or Y could also be auto-tuned by checking the actual trasfer rates and slowly modify them, thus maximizing the throughtput when the application runs on different machines and/or O.S. You could find that cache, memory or RAID levels affect them in a way or the other, but with auto-tuning you will always get the best performance in every scenario. | [
"windows",
"multithreading",
"file-io"
] | 26 | 12 | 9,358 | 6 | 0 | 2008-08-12T19:50:13.440000 | 2008-08-13T13:47:39.333000 |
9,228 | 9,233 | ADO.NET Connection Pooling & SQLServer | What is it? How do I implement connection pooling with MS SQL? What are the performance ramifications when Executing many queries one-after-the other (i.e. using a loop with 30K+ iterations calling a stored procedure)? Executing a few queries that take a long time (10+ min)? Are there any best practices? | Connection pooling is a mechanism to re-use connections, as establishing a new connection is slow. If you use an MSSQL connection string and System.Data.SqlClient then you're already using it - in.Net this stuff is under the hood most of the time. A loop of 30k iterations might be better as a server side cursor (look up T-SQL cursor statements), depending on what you're doing with each step outside of the sproc. Long queries are fine - but be careful calling them from web pages as Asp.Net isn't really optimised for long waits and some connections will cut out. | ADO.NET Connection Pooling & SQLServer What is it? How do I implement connection pooling with MS SQL? What are the performance ramifications when Executing many queries one-after-the other (i.e. using a loop with 30K+ iterations calling a stored procedure)? Executing a few queries that take a long time (10+ min)? Are there any best practices? | TITLE:
ADO.NET Connection Pooling & SQLServer
QUESTION:
What is it? How do I implement connection pooling with MS SQL? What are the performance ramifications when Executing many queries one-after-the other (i.e. using a loop with 30K+ iterations calling a stored procedure)? Executing a few queries that take a long time (10+ min)? Are there any best practices?
ANSWER:
Connection pooling is a mechanism to re-use connections, as establishing a new connection is slow. If you use an MSSQL connection string and System.Data.SqlClient then you're already using it - in.Net this stuff is under the hood most of the time. A loop of 30k iterations might be better as a server side cursor (look up T-SQL cursor statements), depending on what you're doing with each step outside of the sproc. Long queries are fine - but be careful calling them from web pages as Asp.Net isn't really optimised for long waits and some connections will cut out. | [
"sql-server",
"performance",
"ado.net"
] | 3 | 3 | 2,510 | 4 | 0 | 2008-08-12T20:48:30.513000 | 2008-08-12T20:53:40.690000 |
9,231 | 9,260 | Offsite backups | I was recently tasked with coming up with an offsite backup strategy. We have about 2TB of data that would need to be backed up so our needs are a little out of the norm. I looked into Iron Mountain and they wanted $12,000 a month! Does anyone have any suggestions on how best to handle backing up this much data on a budget (like a tenth of Iron Mountain)? How do other companies afford to do this? Thanks! UPDATE:: UPDATE Ironically enough, I just had the sort of devastating failure we're all talking about. I had my BES server fail and than 2 days later 2 drives in my Exchange server's RAID5 died (2!!!??!). I'm currently in the process of rebuilding my network and the backup integrity is an definitely an issue. At least now my bosses are paying attention:) | You can buy external eSATA RAID boxes in the 8TB capacity range for $2600. I'm not saying that particular product is the right choice, but that's the kind of box that will do 6TB in RAID5 and still be portable enough to buy a couple of them and rotate them through the bank, like Stu says. Obviously if you have to have to keep 7 individual days worth, a 14 day, 30 and 90 day snapshot, etc. then things are going to be much more expensive, but it's certainly doable if what you're after is just disaster recovery. The biggest thing to make sure is part of your plan is actually testing the restoration from the backup. That seems to get overlooked WAY too often and turns out to be the weakest link in nearly all of the strategies. You should plan for scheduled restorations as often as is reasonable where you actually dump the real data and restore from the backup. Without that, you don't know that it will work when you NEED it too. I've lost track of the number of times I've been in a company where there's a big rack full of backup tapes/drives, all dutifully made according to the schedule only to find out that NONE of them have valid data when the server gets wiped out. The more ways you can verify the integrity of the backups the better, but nothing substitutes for doing an actual dump/load from one of your backups to really test the setup. | Offsite backups I was recently tasked with coming up with an offsite backup strategy. We have about 2TB of data that would need to be backed up so our needs are a little out of the norm. I looked into Iron Mountain and they wanted $12,000 a month! Does anyone have any suggestions on how best to handle backing up this much data on a budget (like a tenth of Iron Mountain)? How do other companies afford to do this? Thanks! UPDATE:: UPDATE Ironically enough, I just had the sort of devastating failure we're all talking about. I had my BES server fail and than 2 days later 2 drives in my Exchange server's RAID5 died (2!!!??!). I'm currently in the process of rebuilding my network and the backup integrity is an definitely an issue. At least now my bosses are paying attention:) | TITLE:
Offsite backups
QUESTION:
I was recently tasked with coming up with an offsite backup strategy. We have about 2TB of data that would need to be backed up so our needs are a little out of the norm. I looked into Iron Mountain and they wanted $12,000 a month! Does anyone have any suggestions on how best to handle backing up this much data on a budget (like a tenth of Iron Mountain)? How do other companies afford to do this? Thanks! UPDATE:: UPDATE Ironically enough, I just had the sort of devastating failure we're all talking about. I had my BES server fail and than 2 days later 2 drives in my Exchange server's RAID5 died (2!!!??!). I'm currently in the process of rebuilding my network and the backup integrity is an definitely an issue. At least now my bosses are paying attention:)
ANSWER:
You can buy external eSATA RAID boxes in the 8TB capacity range for $2600. I'm not saying that particular product is the right choice, but that's the kind of box that will do 6TB in RAID5 and still be portable enough to buy a couple of them and rotate them through the bank, like Stu says. Obviously if you have to have to keep 7 individual days worth, a 14 day, 30 and 90 day snapshot, etc. then things are going to be much more expensive, but it's certainly doable if what you're after is just disaster recovery. The biggest thing to make sure is part of your plan is actually testing the restoration from the backup. That seems to get overlooked WAY too often and turns out to be the weakest link in nearly all of the strategies. You should plan for scheduled restorations as often as is reasonable where you actually dump the real data and restore from the backup. Without that, you don't know that it will work when you NEED it too. I've lost track of the number of times I've been in a company where there's a big rack full of backup tapes/drives, all dutifully made according to the schedule only to find out that NONE of them have valid data when the server gets wiped out. The more ways you can verify the integrity of the backups the better, but nothing substitutes for doing an actual dump/load from one of your backups to really test the setup. | [
"backup",
"offsite"
] | 8 | 8 | 1,300 | 9 | 0 | 2008-08-12T20:49:54.003000 | 2008-08-12T21:29:01.243000 |
9,240 | 9,502 | Interfaces on different logic layers | Say you have an application divided into 3-tiers: GUI, business logic, and data access. In your business logic layer you have described your business objects: getters, setters, accessors, and so on... you get the idea. The interface to the business logic layer guarantees safe usage of the business logic, so all the methods and accessors you call will validate input. This great when you first write the UI code, because you have a neatly defined interface that you can trust. But here comes the tricky part, when you start writing the data access layer, the interface to the business logic does not accommodate your needs. You need to have more accessors and getters to set fields which are/used to be hidden. Now you are forced to erode the interface of your business logic; now it is possible set fields from the UI layer, which the UI layer has no business setting. Because of the changes needed for the data access layer, the interface to the business logic has eroded to the point where it is possible to even set the business logic with invalid data. Thus, the interface does not guarantee safe usage anymore. I hope I explained the problem clearly enough. How do you prevent interface eroding, maintain information hiding and encapsulation, and yet still accommodate different interface needs among different layers? | If I understand the question correctly, you've created a domain model and you would like to write an object-relational mapper to map between records in your database and your domain objects. However, you're concerned about polluting your domain model with the 'plumbing' code that would be necessary to read and write to your object's fields. Taking a step back, you essentially have two choices of where to put your data mapping code - within the domain class itself or in an external mapping class. The first option is often called the Active Record pattern and has the advantage that each object knows how to persist itself and has sufficient access to its internal structure to allow it to perform the mapping without needing to expose non-business related fields. E.g public class User { private string name; private AccountStatus status;
private User() { }
public string Name { get { return name; } set { name = value; } }
public AccountStatus Status { get { return status; } }
public void Activate() { status = AccountStatus.Active; }
public void Suspend() { status = AccountStatus.Suspended; }
public static User GetById(int id) { User fetchedUser = new User();
// Lots of database and error-checking code // omitted for clarity //...
fetchedUser.name = (string) reader["Name"]; fetchedUser.status = (int)reader["statusCode"] == 0? AccountStatus.Suspended: AccountStatus.Active;
return fetchedUser; }
public static void Save(User user) { // Code to save User's internal structure to database //... } } In this example, we have an object that represents a User with a Name and an AccountStatus. We don't want to allow the Status to be set directly, perhaps because we want to check that the change is a valid status transition, so we don't have a setter. Fortunately, the mapping code in the GetById and Save static methods have full access to the object's name and status fields. The second option is to have a second class that is responsible for the mapping. This has the advantage of seperating out the different concerns of business logic and persistence which can allow your design to be more testable and flexible. The challenge with this method is how to expose the name and status fields to the external class. Some options are: 1. Use reflection (which has no qualms about digging deep into your object's private parts) 2. Provide specially-named, public setters (e.g. prefix them with the word 'Private') and hope no one uses them accidentally 3. If your language suports it, make the setters internal but grant your data mapper module access. E.g. use the InternalsVisibleToAttribute in.NET 2.0 onwards or friend functions in C++ For more information, I'd recommend Martin Fowler's classic book 'Patterns of Enterprise Architecture' However, as a word of warning, before going down the path of writing your own mappers I'd strongly recommend looking at using a 3rd-party object relational mapper (ORM) tool such as nHibernate or Microsoft's Entity Framework. I've worked on four different projects where, for various reasons, we wrote our own mapper and it is very easy to waste a lot of time maintaining and extending the mapper instead of writing code that provides end user value. I've used nHibernate on one project so far and, although it has quite a steep learning curve initially, the investment you put in early on pays off considerably. | Interfaces on different logic layers Say you have an application divided into 3-tiers: GUI, business logic, and data access. In your business logic layer you have described your business objects: getters, setters, accessors, and so on... you get the idea. The interface to the business logic layer guarantees safe usage of the business logic, so all the methods and accessors you call will validate input. This great when you first write the UI code, because you have a neatly defined interface that you can trust. But here comes the tricky part, when you start writing the data access layer, the interface to the business logic does not accommodate your needs. You need to have more accessors and getters to set fields which are/used to be hidden. Now you are forced to erode the interface of your business logic; now it is possible set fields from the UI layer, which the UI layer has no business setting. Because of the changes needed for the data access layer, the interface to the business logic has eroded to the point where it is possible to even set the business logic with invalid data. Thus, the interface does not guarantee safe usage anymore. I hope I explained the problem clearly enough. How do you prevent interface eroding, maintain information hiding and encapsulation, and yet still accommodate different interface needs among different layers? | TITLE:
Interfaces on different logic layers
QUESTION:
Say you have an application divided into 3-tiers: GUI, business logic, and data access. In your business logic layer you have described your business objects: getters, setters, accessors, and so on... you get the idea. The interface to the business logic layer guarantees safe usage of the business logic, so all the methods and accessors you call will validate input. This great when you first write the UI code, because you have a neatly defined interface that you can trust. But here comes the tricky part, when you start writing the data access layer, the interface to the business logic does not accommodate your needs. You need to have more accessors and getters to set fields which are/used to be hidden. Now you are forced to erode the interface of your business logic; now it is possible set fields from the UI layer, which the UI layer has no business setting. Because of the changes needed for the data access layer, the interface to the business logic has eroded to the point where it is possible to even set the business logic with invalid data. Thus, the interface does not guarantee safe usage anymore. I hope I explained the problem clearly enough. How do you prevent interface eroding, maintain information hiding and encapsulation, and yet still accommodate different interface needs among different layers?
ANSWER:
If I understand the question correctly, you've created a domain model and you would like to write an object-relational mapper to map between records in your database and your domain objects. However, you're concerned about polluting your domain model with the 'plumbing' code that would be necessary to read and write to your object's fields. Taking a step back, you essentially have two choices of where to put your data mapping code - within the domain class itself or in an external mapping class. The first option is often called the Active Record pattern and has the advantage that each object knows how to persist itself and has sufficient access to its internal structure to allow it to perform the mapping without needing to expose non-business related fields. E.g public class User { private string name; private AccountStatus status;
private User() { }
public string Name { get { return name; } set { name = value; } }
public AccountStatus Status { get { return status; } }
public void Activate() { status = AccountStatus.Active; }
public void Suspend() { status = AccountStatus.Suspended; }
public static User GetById(int id) { User fetchedUser = new User();
// Lots of database and error-checking code // omitted for clarity //...
fetchedUser.name = (string) reader["Name"]; fetchedUser.status = (int)reader["statusCode"] == 0? AccountStatus.Suspended: AccountStatus.Active;
return fetchedUser; }
public static void Save(User user) { // Code to save User's internal structure to database //... } } In this example, we have an object that represents a User with a Name and an AccountStatus. We don't want to allow the Status to be set directly, perhaps because we want to check that the change is a valid status transition, so we don't have a setter. Fortunately, the mapping code in the GetById and Save static methods have full access to the object's name and status fields. The second option is to have a second class that is responsible for the mapping. This has the advantage of seperating out the different concerns of business logic and persistence which can allow your design to be more testable and flexible. The challenge with this method is how to expose the name and status fields to the external class. Some options are: 1. Use reflection (which has no qualms about digging deep into your object's private parts) 2. Provide specially-named, public setters (e.g. prefix them with the word 'Private') and hope no one uses them accidentally 3. If your language suports it, make the setters internal but grant your data mapper module access. E.g. use the InternalsVisibleToAttribute in.NET 2.0 onwards or friend functions in C++ For more information, I'd recommend Martin Fowler's classic book 'Patterns of Enterprise Architecture' However, as a word of warning, before going down the path of writing your own mappers I'd strongly recommend looking at using a 3rd-party object relational mapper (ORM) tool such as nHibernate or Microsoft's Entity Framework. I've worked on four different projects where, for various reasons, we wrote our own mapper and it is very easy to waste a lot of time maintaining and extending the mapper instead of writing code that provides end user value. I've used nHibernate on one project so far and, although it has quite a steep learning curve initially, the investment you put in early on pays off considerably. | [
"architecture"
] | 12 | 7 | 5,339 | 9 | 0 | 2008-08-12T21:06:38.650000 | 2008-08-13T06:08:24.597000 |
9,256 | 16,362 | How print Flex components in FireFox3? | Thanks to FireFox's buggy implementation of ActiveX components (it really should take an image of them when printing) Flex components (in our case charts) don't print in FX. They print fine in IE7, even IE6. We need these charts to print, but they also have dynamic content. I don't really want to draw them again as images when the user prints - the Flex component should do it. We've found a potential workaround, but unfortunately it doesn't work in FireFox3 (in FireFox2 it sort-of works, but not well enough). Anyone know a workaround? | Using the ACPrintManager I was able to get firefox 3 to print perfectly! The one thing I had to add to the example was to check if stage was null, and callLater if the stage was null. private function initPrint():void { //if we don't have a stage, wait until the next frame and try again if ( stage == null ) { callLater(initPrint); return; }
PrintManager.init(stage);
var data:BitmapData = new BitmapData(stage.stageWidth, stage.stageHeight); data.draw(myDataGrid);
PrintManager.setPrintableContent(data); } | How print Flex components in FireFox3? Thanks to FireFox's buggy implementation of ActiveX components (it really should take an image of them when printing) Flex components (in our case charts) don't print in FX. They print fine in IE7, even IE6. We need these charts to print, but they also have dynamic content. I don't really want to draw them again as images when the user prints - the Flex component should do it. We've found a potential workaround, but unfortunately it doesn't work in FireFox3 (in FireFox2 it sort-of works, but not well enough). Anyone know a workaround? | TITLE:
How print Flex components in FireFox3?
QUESTION:
Thanks to FireFox's buggy implementation of ActiveX components (it really should take an image of them when printing) Flex components (in our case charts) don't print in FX. They print fine in IE7, even IE6. We need these charts to print, but they also have dynamic content. I don't really want to draw them again as images when the user prints - the Flex component should do it. We've found a potential workaround, but unfortunately it doesn't work in FireFox3 (in FireFox2 it sort-of works, but not well enough). Anyone know a workaround?
ANSWER:
Using the ACPrintManager I was able to get firefox 3 to print perfectly! The one thing I had to add to the example was to check if stage was null, and callLater if the stage was null. private function initPrint():void { //if we don't have a stage, wait until the next frame and try again if ( stage == null ) { callLater(initPrint); return; }
PrintManager.init(stage);
var data:BitmapData = new BitmapData(stage.stageWidth, stage.stageHeight); data.draw(myDataGrid);
PrintManager.setPrintableContent(data); } | [
"apache-flex",
"actionscript-3",
"firefox"
] | 5 | 3 | 1,509 | 2 | 0 | 2008-08-12T21:27:40.200000 | 2008-08-19T15:09:16.437000 |
9,272 | 971,143 | How to find untracked files in a Perforce tree? (analogue of svn status) | Anybody have a script or alias to find untracked (really: unadded) files in a Perforce tree? EDIT: I updated the accepted answer on this one since it looks like P4V added support for this in the January 2009 release. | EDIT: Please use p4 status now. There is no need for jumping through hoops anymore. See @ColonelPanic's answer. In the Jan 2009 version of P4V, you can right-click on any folder in your workspace tree and click "reconcile offline work..." This will do a little processing then bring up a split-tree view of files that are not checked out but have differences from the depot version, or not checked in at all. There may even be a few other categories it brings up. You can right-click on files in this view and check them out, add them, or even revert them. It's a very handy tool that's saved my ass a few times. EDIT: ah the question asked about scripts specifically, but I'll leave this answer here just in case. | How to find untracked files in a Perforce tree? (analogue of svn status) Anybody have a script or alias to find untracked (really: unadded) files in a Perforce tree? EDIT: I updated the accepted answer on this one since it looks like P4V added support for this in the January 2009 release. | TITLE:
How to find untracked files in a Perforce tree? (analogue of svn status)
QUESTION:
Anybody have a script or alias to find untracked (really: unadded) files in a Perforce tree? EDIT: I updated the accepted answer on this one since it looks like P4V added support for this in the January 2009 release.
ANSWER:
EDIT: Please use p4 status now. There is no need for jumping through hoops anymore. See @ColonelPanic's answer. In the Jan 2009 version of P4V, you can right-click on any folder in your workspace tree and click "reconcile offline work..." This will do a little processing then bring up a split-tree view of files that are not checked out but have differences from the depot version, or not checked in at all. There may even be a few other categories it brings up. You can right-click on files in this view and check them out, add them, or even revert them. It's a very handy tool that's saved my ass a few times. EDIT: ah the question asked about scripts specifically, but I'll leave this answer here just in case. | [
"version-control",
"language-agnostic",
"perforce"
] | 93 | 91 | 50,008 | 16 | 0 | 2008-08-12T21:44:32.070000 | 2009-06-09T16:28:42.070000 |
9,275 | 9,325 | Using Parameters in MS Reporting Services (SQL Server 2008) against an ODBC data source | I writing a report in Visual Studio that takes a user input parameter and runs against an ODBC datasource. I would like to write the query manually and have reporting services replace part of the where clause with the parameter value before sending it to the database. What seems to be happening is that the @parmName I am assuming will be replaced is actually being sent as part of the SQL statement. Am I missing a configuration setting somewhere or is this simply not possible? I am not using the filter option in the tool because this appears to bring back the full dataset from the database and do the filtering on the SQL Server. | It sounds like you'll need to treat the SQL Statement as an expression. For example: ="Select col1, col2 from table 1 Where col3 = " & Parameters!Param1.Value If the where clause is a string you would need to do the following: ="Select col1, col2 from table 1 Where col3 = '" & Parameters!Param1.Value & "'" Important: Do not use line breaks in your SQL expression. If you do you will get an error. Holla back if you need any more assistance. | Using Parameters in MS Reporting Services (SQL Server 2008) against an ODBC data source I writing a report in Visual Studio that takes a user input parameter and runs against an ODBC datasource. I would like to write the query manually and have reporting services replace part of the where clause with the parameter value before sending it to the database. What seems to be happening is that the @parmName I am assuming will be replaced is actually being sent as part of the SQL statement. Am I missing a configuration setting somewhere or is this simply not possible? I am not using the filter option in the tool because this appears to bring back the full dataset from the database and do the filtering on the SQL Server. | TITLE:
Using Parameters in MS Reporting Services (SQL Server 2008) against an ODBC data source
QUESTION:
I writing a report in Visual Studio that takes a user input parameter and runs against an ODBC datasource. I would like to write the query manually and have reporting services replace part of the where clause with the parameter value before sending it to the database. What seems to be happening is that the @parmName I am assuming will be replaced is actually being sent as part of the SQL statement. Am I missing a configuration setting somewhere or is this simply not possible? I am not using the filter option in the tool because this appears to bring back the full dataset from the database and do the filtering on the SQL Server.
ANSWER:
It sounds like you'll need to treat the SQL Statement as an expression. For example: ="Select col1, col2 from table 1 Where col3 = " & Parameters!Param1.Value If the where clause is a string you would need to do the following: ="Select col1, col2 from table 1 Where col3 = '" & Parameters!Param1.Value & "'" Important: Do not use line breaks in your SQL expression. If you do you will get an error. Holla back if you need any more assistance. | [
"sql-server",
"visual-studio",
"sql-server-2008",
"reporting-services",
"odbc"
] | 2 | 6 | 10,120 | 4 | 0 | 2008-08-12T21:47:45.277000 | 2008-08-12T23:43:15.183000 |
9,279 | 9,287 | Keep Remote Directory Up-to-date | I absolutely love the Keep Remote Directory Up-to-date feature in Winscp. Unfortunately, I can't find anything as simple to use in OS X or Linux. I know the same thing can theoretically be accomplished using changedfiles or rsync, but I've always found the tutorials for both tools to be lacking and/or contradictory. I basically just need a tool that works in OSX or Linux and keeps a remote directory in sync (mirrored) with a local directory while I make changes to the local directory. Update Looking through the solutions, I see a couple which solve the general problem of keeping a remote directory in sync with a local directory manually. I know that I can set a cron task to run rsync every minute, and this should be fairly close to real time. This is not the exact solution I was looking for as winscp does this and more: it detects file changes in a directory (while I work on them) and then automatically pushes the changes to the remote server. I know this is not the best solution (no code repository), but it allows me to very quickly test code on a server while I develop it. Does anyone know how to combine rsync with any other commands to get this functionality? | How "real-time" do you want the syncing? I would still lean toward rsync since you know it is going to be fully supported on both platforms (Windows, too, with cygwin) and you can run it via a cron job. I have a super-simple bash file that I run on my system (this does not remove old files): #!/bin/sh rsync -avrz --progress --exclude-from.rsync_exclude_remote. remote_login@remote_computer:remote_dir
# options # -a archive # -v verbose # -r recursive # -z compress Your best bet is to set it up and try it out. The -n (--dry-run) option is your friend! Keep in mind that rsync (at least in cygwin) does not support unicode file names (as of 16 Aug 2008). | Keep Remote Directory Up-to-date I absolutely love the Keep Remote Directory Up-to-date feature in Winscp. Unfortunately, I can't find anything as simple to use in OS X or Linux. I know the same thing can theoretically be accomplished using changedfiles or rsync, but I've always found the tutorials for both tools to be lacking and/or contradictory. I basically just need a tool that works in OSX or Linux and keeps a remote directory in sync (mirrored) with a local directory while I make changes to the local directory. Update Looking through the solutions, I see a couple which solve the general problem of keeping a remote directory in sync with a local directory manually. I know that I can set a cron task to run rsync every minute, and this should be fairly close to real time. This is not the exact solution I was looking for as winscp does this and more: it detects file changes in a directory (while I work on them) and then automatically pushes the changes to the remote server. I know this is not the best solution (no code repository), but it allows me to very quickly test code on a server while I develop it. Does anyone know how to combine rsync with any other commands to get this functionality? | TITLE:
Keep Remote Directory Up-to-date
QUESTION:
I absolutely love the Keep Remote Directory Up-to-date feature in Winscp. Unfortunately, I can't find anything as simple to use in OS X or Linux. I know the same thing can theoretically be accomplished using changedfiles or rsync, but I've always found the tutorials for both tools to be lacking and/or contradictory. I basically just need a tool that works in OSX or Linux and keeps a remote directory in sync (mirrored) with a local directory while I make changes to the local directory. Update Looking through the solutions, I see a couple which solve the general problem of keeping a remote directory in sync with a local directory manually. I know that I can set a cron task to run rsync every minute, and this should be fairly close to real time. This is not the exact solution I was looking for as winscp does this and more: it detects file changes in a directory (while I work on them) and then automatically pushes the changes to the remote server. I know this is not the best solution (no code repository), but it allows me to very quickly test code on a server while I develop it. Does anyone know how to combine rsync with any other commands to get this functionality?
ANSWER:
How "real-time" do you want the syncing? I would still lean toward rsync since you know it is going to be fully supported on both platforms (Windows, too, with cygwin) and you can run it via a cron job. I have a super-simple bash file that I run on my system (this does not remove old files): #!/bin/sh rsync -avrz --progress --exclude-from.rsync_exclude_remote. remote_login@remote_computer:remote_dir
# options # -a archive # -v verbose # -r recursive # -z compress Your best bet is to set it up and try it out. The -n (--dry-run) option is your friend! Keep in mind that rsync (at least in cygwin) does not support unicode file names (as of 16 Aug 2008). | [
"linux",
"macos",
"ssh",
"sftp"
] | 45 | 19 | 42,224 | 18 | 0 | 2008-08-12T21:56:10.050000 | 2008-08-12T22:14:46.830000 |
9,289 | 9,297 | Removing elements with Array.map in JavaScript | I would like to filter an array of items by using the map() function. Here is a code snippet: var filteredItems = items.map(function(item) { if(...some condition... ) { return item; } }); The problem is that filtered out items still uses space in the array and I would like to completely wipe them out. My specific code was not intended to run in a browser, so I'm not worried about browser-specific support for either function. Any idea? | You should use the filter method rather than map unless you want to mutate the items in the array, in addition to filtering. eg. var filteredItems = items.filter(function(item) { return...some condition...; }); [Edit: Of course you could always do sourceArray.filter(...).map(...) to both filter and mutate] | Removing elements with Array.map in JavaScript I would like to filter an array of items by using the map() function. Here is a code snippet: var filteredItems = items.map(function(item) { if(...some condition... ) { return item; } }); The problem is that filtered out items still uses space in the array and I would like to completely wipe them out. My specific code was not intended to run in a browser, so I'm not worried about browser-specific support for either function. Any idea? | TITLE:
Removing elements with Array.map in JavaScript
QUESTION:
I would like to filter an array of items by using the map() function. Here is a code snippet: var filteredItems = items.map(function(item) { if(...some condition... ) { return item; } }); The problem is that filtered out items still uses space in the array and I would like to completely wipe them out. My specific code was not intended to run in a browser, so I'm not worried about browser-specific support for either function. Any idea?
ANSWER:
You should use the filter method rather than map unless you want to mutate the items in the array, in addition to filtering. eg. var filteredItems = items.filter(function(item) { return...some condition...; }); [Edit: Of course you could always do sourceArray.filter(...).map(...) to both filter and mutate] | [
"javascript",
"functional-programming",
"data-manipulation",
"client-side"
] | 132 | 137 | 198,387 | 8 | 0 | 2008-08-12T22:21:30.263000 | 2008-08-12T22:38:28.327000 |
9,303 | 9,306 | How do you retrieve selected text using Regex in C#? | How do you retrieve selected text using Regex in C#? I am looking for C# code that is equivalent to this Perl code: $indexVal = 0; if($string =~ /Index: (\d*)/){$indexVal = $1;} | int indexVal = 0; Regex re = new Regex(@"Index: (\d*)") Match m = re.Match(s)
if(m.Success) indexVal = int.TryParse(m.Groups[1].toString()); I might have the group number wrong, but you should be able to figure it out from here. | How do you retrieve selected text using Regex in C#? How do you retrieve selected text using Regex in C#? I am looking for C# code that is equivalent to this Perl code: $indexVal = 0; if($string =~ /Index: (\d*)/){$indexVal = $1;} | TITLE:
How do you retrieve selected text using Regex in C#?
QUESTION:
How do you retrieve selected text using Regex in C#? I am looking for C# code that is equivalent to this Perl code: $indexVal = 0; if($string =~ /Index: (\d*)/){$indexVal = $1;}
ANSWER:
int indexVal = 0; Regex re = new Regex(@"Index: (\d*)") Match m = re.Match(s)
if(m.Success) indexVal = int.TryParse(m.Groups[1].toString()); I might have the group number wrong, but you should be able to figure it out from here. | [
"c#",
"regex",
"perl"
] | 13 | 7 | 2,420 | 5 | 0 | 2008-08-12T23:04:10.770000 | 2008-08-12T23:12:48.927000 |
9,304 | 9,310 | C# 3.0 auto-properties — useful or not? | Note: This was posted when I was starting out C#. With 2014 knowledge, I can truly say that auto-properties are among the best things that ever happened to the C# language. I am used to create my properties in C# using a private and a public field: private string title; public string Title { get { return title; } set { title = value; } } Now, with.NET 3.0, we got auto-properties: public string Title { get; set; } I know this is more a philosophical/subjective questions, but is there any reason to use these auto-properties except from saving five lines of code for each field? My personal gripe is that those properties are hiding stuff from me, and I am not a big fan of black magic. In fact, the hidden private field does not even show up in the debugger, which is OK given the fact that the get/set functions do nothing. But when I want to actually implement some getter/setter logic, I have to use the private/public pair anyway. I see the benefit that I save a lot of code (one vs six lines) without losing the ability to change the getter/setter logic later, but then again I can already do that by simply declaring a public field "Public string Title" without the need of the { get; set; } block, thus even saving more code. So, what am I missing here? Why would anyone actually want to use auto-properties? | We use them all the time in Stack Overflow. You may also be interested in a discussion of Properties vs. Public Variables. IMHO that's really what this is a reaction to, and for that purpose, it's great. | C# 3.0 auto-properties — useful or not? Note: This was posted when I was starting out C#. With 2014 knowledge, I can truly say that auto-properties are among the best things that ever happened to the C# language. I am used to create my properties in C# using a private and a public field: private string title; public string Title { get { return title; } set { title = value; } } Now, with.NET 3.0, we got auto-properties: public string Title { get; set; } I know this is more a philosophical/subjective questions, but is there any reason to use these auto-properties except from saving five lines of code for each field? My personal gripe is that those properties are hiding stuff from me, and I am not a big fan of black magic. In fact, the hidden private field does not even show up in the debugger, which is OK given the fact that the get/set functions do nothing. But when I want to actually implement some getter/setter logic, I have to use the private/public pair anyway. I see the benefit that I save a lot of code (one vs six lines) without losing the ability to change the getter/setter logic later, but then again I can already do that by simply declaring a public field "Public string Title" without the need of the { get; set; } block, thus even saving more code. So, what am I missing here? Why would anyone actually want to use auto-properties? | TITLE:
C# 3.0 auto-properties — useful or not?
QUESTION:
Note: This was posted when I was starting out C#. With 2014 knowledge, I can truly say that auto-properties are among the best things that ever happened to the C# language. I am used to create my properties in C# using a private and a public field: private string title; public string Title { get { return title; } set { title = value; } } Now, with.NET 3.0, we got auto-properties: public string Title { get; set; } I know this is more a philosophical/subjective questions, but is there any reason to use these auto-properties except from saving five lines of code for each field? My personal gripe is that those properties are hiding stuff from me, and I am not a big fan of black magic. In fact, the hidden private field does not even show up in the debugger, which is OK given the fact that the get/set functions do nothing. But when I want to actually implement some getter/setter logic, I have to use the private/public pair anyway. I see the benefit that I save a lot of code (one vs six lines) without losing the ability to change the getter/setter logic later, but then again I can already do that by simply declaring a public field "Public string Title" without the need of the { get; set; } block, thus even saving more code. So, what am I missing here? Why would anyone actually want to use auto-properties?
ANSWER:
We use them all the time in Stack Overflow. You may also be interested in a discussion of Properties vs. Public Variables. IMHO that's really what this is a reaction to, and for that purpose, it's great. | [
"c#",
".net",
"automatic-properties"
] | 158 | 121 | 50,291 | 17 | 0 | 2008-08-12T23:06:58.767000 | 2008-08-12T23:13:41.470000 |
9,314 | 9,387 | "Could not find type" error loading a form in the Windows Forms Designer | I have a.NET 2.0 windows forms app, which makes heavy use of the ListView control. I've subclassed the ListView class into a templated SortableListView class, so it can be a bit smarter about how it displays things, and sort itself. Unfortunately this seems to break the Visual Studio Forms Designer, in both VS2005 and 2008. The program compiles and runs fine, but when I try view the owning form in the designer, I get these Errors: Could not find type 'MyApp.Controls.SortableListView'. Please make sure that the assembly that contains this type is referenced. If this type is a part of your development project, make sure that the project has been successfully built. There is no stack trace or error line information available for this error The variable 'listViewImages' is either undeclared or was never assigned. At MyApp.Main.Designer.cs Line:XYZ Column:1 Call stack: at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.Error(IDesignerSerializationManager manager, String exceptionText, String helpLink) at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeExpression(IDesignerSerializationManager manager, String name, CodeExpression expression) at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeExpression(IDesignerSerializationManager manager, String name, CodeExpression expression) at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeStatement(IDesignerSerializationManager manager, CodeStatement statement) The line of code in question is where it is actually added to the form, and is this.imagesTab.Controls.Add( this.listViewImages ); listViewImages is declared as private MyApp.Controls.SortableListView listViewImages; and is instantiated in the InitializeComponent method as follows: this.listViewImages = new MyApp.Controls.SortableListView (); As mentioned earlier, the program compiles and runs perfectly, and I've tried shifting the SortableListView class out to a seperate assembly so it can be compiled seperately, but this makes no difference. I have no idea where to go from here. Any help would be appreciated! | when you added the listview, did you add it to the toolbox and then add it to the form? No, I just edited Main.Designer.cs and changed it from System.Windows.Forms.ListView to MyApp.Controls.SortableListView Suspecting it might have been due to the generics led me to actually finding a solution. For each class that I need to make a SortableListView for, I defined a 'stub class' like this class ImagesListView: SortableListView { } Then made the Main.Designer.cs file refer to these stub classes instead of the SortableListView. It now works, hooray! Thankfully I am able to do this because all my types are known up front, and I'm only using the SortableListView as a method of reducing duplicate code. | "Could not find type" error loading a form in the Windows Forms Designer I have a.NET 2.0 windows forms app, which makes heavy use of the ListView control. I've subclassed the ListView class into a templated SortableListView class, so it can be a bit smarter about how it displays things, and sort itself. Unfortunately this seems to break the Visual Studio Forms Designer, in both VS2005 and 2008. The program compiles and runs fine, but when I try view the owning form in the designer, I get these Errors: Could not find type 'MyApp.Controls.SortableListView'. Please make sure that the assembly that contains this type is referenced. If this type is a part of your development project, make sure that the project has been successfully built. There is no stack trace or error line information available for this error The variable 'listViewImages' is either undeclared or was never assigned. At MyApp.Main.Designer.cs Line:XYZ Column:1 Call stack: at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.Error(IDesignerSerializationManager manager, String exceptionText, String helpLink) at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeExpression(IDesignerSerializationManager manager, String name, CodeExpression expression) at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeExpression(IDesignerSerializationManager manager, String name, CodeExpression expression) at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeStatement(IDesignerSerializationManager manager, CodeStatement statement) The line of code in question is where it is actually added to the form, and is this.imagesTab.Controls.Add( this.listViewImages ); listViewImages is declared as private MyApp.Controls.SortableListView listViewImages; and is instantiated in the InitializeComponent method as follows: this.listViewImages = new MyApp.Controls.SortableListView (); As mentioned earlier, the program compiles and runs perfectly, and I've tried shifting the SortableListView class out to a seperate assembly so it can be compiled seperately, but this makes no difference. I have no idea where to go from here. Any help would be appreciated! | TITLE:
"Could not find type" error loading a form in the Windows Forms Designer
QUESTION:
I have a.NET 2.0 windows forms app, which makes heavy use of the ListView control. I've subclassed the ListView class into a templated SortableListView class, so it can be a bit smarter about how it displays things, and sort itself. Unfortunately this seems to break the Visual Studio Forms Designer, in both VS2005 and 2008. The program compiles and runs fine, but when I try view the owning form in the designer, I get these Errors: Could not find type 'MyApp.Controls.SortableListView'. Please make sure that the assembly that contains this type is referenced. If this type is a part of your development project, make sure that the project has been successfully built. There is no stack trace or error line information available for this error The variable 'listViewImages' is either undeclared or was never assigned. At MyApp.Main.Designer.cs Line:XYZ Column:1 Call stack: at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.Error(IDesignerSerializationManager manager, String exceptionText, String helpLink) at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeExpression(IDesignerSerializationManager manager, String name, CodeExpression expression) at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeExpression(IDesignerSerializationManager manager, String name, CodeExpression expression) at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeStatement(IDesignerSerializationManager manager, CodeStatement statement) The line of code in question is where it is actually added to the form, and is this.imagesTab.Controls.Add( this.listViewImages ); listViewImages is declared as private MyApp.Controls.SortableListView listViewImages; and is instantiated in the InitializeComponent method as follows: this.listViewImages = new MyApp.Controls.SortableListView (); As mentioned earlier, the program compiles and runs perfectly, and I've tried shifting the SortableListView class out to a seperate assembly so it can be compiled seperately, but this makes no difference. I have no idea where to go from here. Any help would be appreciated!
ANSWER:
when you added the listview, did you add it to the toolbox and then add it to the form? No, I just edited Main.Designer.cs and changed it from System.Windows.Forms.ListView to MyApp.Controls.SortableListView Suspecting it might have been due to the generics led me to actually finding a solution. For each class that I need to make a SortableListView for, I defined a 'stub class' like this class ImagesListView: SortableListView { } Then made the Main.Designer.cs file refer to these stub classes instead of the SortableListView. It now works, hooray! Thankfully I am able to do this because all my types are known up front, and I'm only using the SortableListView as a method of reducing duplicate code. | [
"c#",
".net",
"winforms",
"visual-studio-2008",
"visual-studio-2005"
] | 43 | 9 | 33,901 | 11 | 0 | 2008-08-12T23:17:00.540000 | 2008-08-13T01:23:58.633000 |
9,321 | 9,328 | How do you create a static class? | How do you create a static class in C++? I should be able to do something like: cout << "bit 5 is " << BitParser::getBitAt(buffer, 5) << endl; Assuming I created the BitParser class. What would the BitParser class definition look like? | If you're looking for a way of applying the static keyword to a class, like you can in C# for example, then you won't be able to without using Managed C++. But the looks of your sample, you just need to create a public static method on your BitParser object. Like so: BitParser.h class BitParser { public: static bool getBitAt(int buffer, int bitIndex);
//...
// Disallow creating an instance of this object // (Making all constructors private also works but is not ideal and does not // convey your intent as well) BitParser() = delete; }; BitParser.cpp bool BitParser::getBitAt(int buffer, int bitIndex) { bool isBitSet = false; //.. determine if bit is set return isBitSet; } You can use this code to call the method in the same way as your example code. | How do you create a static class? How do you create a static class in C++? I should be able to do something like: cout << "bit 5 is " << BitParser::getBitAt(buffer, 5) << endl; Assuming I created the BitParser class. What would the BitParser class definition look like? | TITLE:
How do you create a static class?
QUESTION:
How do you create a static class in C++? I should be able to do something like: cout << "bit 5 is " << BitParser::getBitAt(buffer, 5) << endl; Assuming I created the BitParser class. What would the BitParser class definition look like?
ANSWER:
If you're looking for a way of applying the static keyword to a class, like you can in C# for example, then you won't be able to without using Managed C++. But the looks of your sample, you just need to create a public static method on your BitParser object. Like so: BitParser.h class BitParser { public: static bool getBitAt(int buffer, int bitIndex);
//...
// Disallow creating an instance of this object // (Making all constructors private also works but is not ideal and does not // convey your intent as well) BitParser() = delete; }; BitParser.cpp bool BitParser::getBitAt(int buffer, int bitIndex) { bool isBitSet = false; //.. determine if bit is set return isBitSet; } You can use this code to call the method in the same way as your example code. | [
"c++",
"class",
"oop",
"static-classes"
] | 314 | 337 | 582,311 | 15 | 0 | 2008-08-12T23:35:00.613000 | 2008-08-12T23:43:37.773000 |
9,336 | 9,533 | Generate sitemap on the fly | I'm trying to generate a sitemap.xml on the fly for a particular asp.net website. I found a couple solutions: chinookwebs cervoproject newtonking Chinookwebs is working great but seems a bit inactive right now and it's impossible to personalize the "priority" and the "changefreq" tags of each and every page, they all inherit the same value from the config file. What solutions do you guys use? | Usually you'll use an HTTP Handler for this. Given a request for... http://www.yoursite.com/sitemap.axd...your handler will respond with a formatted XML sitemap. Whether that sitemap is generated on the fly, from a database, or some other method is up to the HTTP Handler implementation. Here's roughly what it would look like: void IHttpHandler.ProcessRequest(HttpContext context) { // // Important to return qualified XML (text/xml) for sitemaps // context.Response.ClearHeaders(); context.Response.ClearContent(); context.Response.ContentType = "text/xml"; // // Create an XML writer // XmlTextWriter writer = new XmlTextWriter(context.Response.Output); writer.WriteStartDocument(); writer.WriteStartElement("urlset", "http://www.sitemaps.org/schemas/sitemap/0.9"); // // Now add entries for individual pages.. // writer.WriteStartElement("url"); writer.WriteElementString("loc", "http://www.codingthewheel.com"); // use W3 date format.. writer.WriteElementString("lastmod", postDate.ToString("yyyy-MM-dd")); writer.WriteElementString("changefreq", "daily"); writer.WriteElementString("priority", "1.0"); writer.WriteEndElement(); // // Close everything out and go home. // result.WriteEndElement(); result.WriteEndDocument(); writer.Flush(); } This code can be improved but that's the basic idea. | Generate sitemap on the fly I'm trying to generate a sitemap.xml on the fly for a particular asp.net website. I found a couple solutions: chinookwebs cervoproject newtonking Chinookwebs is working great but seems a bit inactive right now and it's impossible to personalize the "priority" and the "changefreq" tags of each and every page, they all inherit the same value from the config file. What solutions do you guys use? | TITLE:
Generate sitemap on the fly
QUESTION:
I'm trying to generate a sitemap.xml on the fly for a particular asp.net website. I found a couple solutions: chinookwebs cervoproject newtonking Chinookwebs is working great but seems a bit inactive right now and it's impossible to personalize the "priority" and the "changefreq" tags of each and every page, they all inherit the same value from the config file. What solutions do you guys use?
ANSWER:
Usually you'll use an HTTP Handler for this. Given a request for... http://www.yoursite.com/sitemap.axd...your handler will respond with a formatted XML sitemap. Whether that sitemap is generated on the fly, from a database, or some other method is up to the HTTP Handler implementation. Here's roughly what it would look like: void IHttpHandler.ProcessRequest(HttpContext context) { // // Important to return qualified XML (text/xml) for sitemaps // context.Response.ClearHeaders(); context.Response.ClearContent(); context.Response.ContentType = "text/xml"; // // Create an XML writer // XmlTextWriter writer = new XmlTextWriter(context.Response.Output); writer.WriteStartDocument(); writer.WriteStartElement("urlset", "http://www.sitemaps.org/schemas/sitemap/0.9"); // // Now add entries for individual pages.. // writer.WriteStartElement("url"); writer.WriteElementString("loc", "http://www.codingthewheel.com"); // use W3 date format.. writer.WriteElementString("lastmod", postDate.ToString("yyyy-MM-dd")); writer.WriteElementString("changefreq", "daily"); writer.WriteElementString("priority", "1.0"); writer.WriteEndElement(); // // Close everything out and go home. // result.WriteEndElement(); result.WriteEndDocument(); writer.Flush(); } This code can be improved but that's the basic idea. | [
".net",
"asp.net",
"sitemap"
] | 5 | 8 | 3,293 | 3 | 0 | 2008-08-13T00:01:11.780000 | 2008-08-13T07:19:07.713000 |
9,338 | 9,374 | Quality Control / Log Monitoring | One of the articles I really enjoyed reading recently was Quality Control by Last.FM. In the spirit of this article, I was wondering if anyone else had favorite monitoring setups for web type applications. Or maybe if you don't believe in Log Monitoring, why? I'm looking for a mix of opinion slash experience here I guess. | We get a bunch of email/pager alerts from an older host/app/network monitoring environment that get gradually more abusive depending on severity of the problem/time taken to respond. Fortunately we all have thick skins and very broad senses of humour.:) | Quality Control / Log Monitoring One of the articles I really enjoyed reading recently was Quality Control by Last.FM. In the spirit of this article, I was wondering if anyone else had favorite monitoring setups for web type applications. Or maybe if you don't believe in Log Monitoring, why? I'm looking for a mix of opinion slash experience here I guess. | TITLE:
Quality Control / Log Monitoring
QUESTION:
One of the articles I really enjoyed reading recently was Quality Control by Last.FM. In the spirit of this article, I was wondering if anyone else had favorite monitoring setups for web type applications. Or maybe if you don't believe in Log Monitoring, why? I'm looking for a mix of opinion slash experience here I guess.
ANSWER:
We get a bunch of email/pager alerts from an older host/app/network monitoring environment that get gradually more abusive depending on severity of the problem/time taken to respond. Fortunately we all have thick skins and very broad senses of humour.:) | [
"monitoring",
"logging"
] | 2 | 2 | 801 | 2 | 0 | 2008-08-13T00:01:56.800000 | 2008-08-13T01:04:19.013000 |
9,341 | 9,365 | Running Javascript after control's selected value has been set | Simple ASP.NET application. I have two drop-down controls. On the first-drop down I have a JavaScript onChange event. The JavaScript enables the second drop-down and removes a value from it (the value selected in the first drop-down). If they click the blank first value of the drop-down, then the second drop-down will be disabled (and the options reset). I also have code in the OnPreRender method that will enable or disable the second drop-down based on the value of the first drop-down. This is so that the value of the first drop-down can be selected in code (loading user settings). My problem is: The user selects something in the first drop-down. The second drop-down will become enabled through JavaScript. They then change a third drop-down that initiates a post back. After the post back the drop-downs are in the correct state (first value selected, second drop-down enabled). If they then click the back button, the second drop-down will no longer be enabled although it should be since there's something selected in the first drop-down. I've tried adding a startup script (that will set the correct state of the second-drop down) through ClientScript.RegisterStartupScript, however when this gets called the first drop-down has a selectedIndex of 0, not what it actually is. My guess is that the value of the selection gets set after my start script (but still doesn't call the onChange script). Any ideas on what to try? | <%@ Page Language="C#" %> Test Page One Two Three One Two Three Edit: Replaced the whole code. This should work even in your user control. I believe that Register.ClientScriptBlock is not working because the code you write in that block is executed before window.onload is called. And, I assume (I am not sure of this point) that the DOM objects do not have their values set at that time. And, this is why you are getting selectedIndex as always 0. | Running Javascript after control's selected value has been set Simple ASP.NET application. I have two drop-down controls. On the first-drop down I have a JavaScript onChange event. The JavaScript enables the second drop-down and removes a value from it (the value selected in the first drop-down). If they click the blank first value of the drop-down, then the second drop-down will be disabled (and the options reset). I also have code in the OnPreRender method that will enable or disable the second drop-down based on the value of the first drop-down. This is so that the value of the first drop-down can be selected in code (loading user settings). My problem is: The user selects something in the first drop-down. The second drop-down will become enabled through JavaScript. They then change a third drop-down that initiates a post back. After the post back the drop-downs are in the correct state (first value selected, second drop-down enabled). If they then click the back button, the second drop-down will no longer be enabled although it should be since there's something selected in the first drop-down. I've tried adding a startup script (that will set the correct state of the second-drop down) through ClientScript.RegisterStartupScript, however when this gets called the first drop-down has a selectedIndex of 0, not what it actually is. My guess is that the value of the selection gets set after my start script (but still doesn't call the onChange script). Any ideas on what to try? | TITLE:
Running Javascript after control's selected value has been set
QUESTION:
Simple ASP.NET application. I have two drop-down controls. On the first-drop down I have a JavaScript onChange event. The JavaScript enables the second drop-down and removes a value from it (the value selected in the first drop-down). If they click the blank first value of the drop-down, then the second drop-down will be disabled (and the options reset). I also have code in the OnPreRender method that will enable or disable the second drop-down based on the value of the first drop-down. This is so that the value of the first drop-down can be selected in code (loading user settings). My problem is: The user selects something in the first drop-down. The second drop-down will become enabled through JavaScript. They then change a third drop-down that initiates a post back. After the post back the drop-downs are in the correct state (first value selected, second drop-down enabled). If they then click the back button, the second drop-down will no longer be enabled although it should be since there's something selected in the first drop-down. I've tried adding a startup script (that will set the correct state of the second-drop down) through ClientScript.RegisterStartupScript, however when this gets called the first drop-down has a selectedIndex of 0, not what it actually is. My guess is that the value of the selection gets set after my start script (but still doesn't call the onChange script). Any ideas on what to try?
ANSWER:
<%@ Page Language="C#" %> Test Page One Two Three One Two Three Edit: Replaced the whole code. This should work even in your user control. I believe that Register.ClientScriptBlock is not working because the code you write in that block is executed before window.onload is called. And, I assume (I am not sure of this point) that the DOM objects do not have their values set at that time. And, this is why you are getting selectedIndex as always 0. | [
"asp.net",
"javascript"
] | 12 | 2 | 4,035 | 2 | 0 | 2008-08-13T00:11:03.863000 | 2008-08-13T00:53:34.077000 |
9,355 | 3,011,284 | Programmatically select multiple files in windows explorer | I can display and select a single file in windows explorer like this: explorer.exe /select, "c:\path\to\file.txt" However, I can't work out how to select more than one file. None of the permutations of select I've tried work. Note: I looked at these pages for docs, neither helped. https://support.microsoft.com/kb/314853 http://web.archive.org/web/20100716112458/http://www.infocellar.com:80/Win98/explorer-switches.htm | This should be possible with the shell function SHOpenFolderAndSelectItems EDIT Here is some sample code showing how to use the function in C/C++, without error checking: //Directory to open ITEMIDLIST *dir = ILCreateFromPath(_T("C:\\"));
//Items in directory to select ITEMIDLIST *item1 = ILCreateFromPath(_T("C:\\Program Files\\")); ITEMIDLIST *item2 = ILCreateFromPath(_T("C:\\Windows\\")); const ITEMIDLIST* selection[] = {item1,item2}; UINT count = sizeof(selection) / sizeof(ITEMIDLIST);
//Perform selection SHOpenFolderAndSelectItems(dir, count, selection, 0);
//Free resources ILFree(dir); ILFree(item1); ILFree(item2); | Programmatically select multiple files in windows explorer I can display and select a single file in windows explorer like this: explorer.exe /select, "c:\path\to\file.txt" However, I can't work out how to select more than one file. None of the permutations of select I've tried work. Note: I looked at these pages for docs, neither helped. https://support.microsoft.com/kb/314853 http://web.archive.org/web/20100716112458/http://www.infocellar.com:80/Win98/explorer-switches.htm | TITLE:
Programmatically select multiple files in windows explorer
QUESTION:
I can display and select a single file in windows explorer like this: explorer.exe /select, "c:\path\to\file.txt" However, I can't work out how to select more than one file. None of the permutations of select I've tried work. Note: I looked at these pages for docs, neither helped. https://support.microsoft.com/kb/314853 http://web.archive.org/web/20100716112458/http://www.infocellar.com:80/Win98/explorer-switches.htm
ANSWER:
This should be possible with the shell function SHOpenFolderAndSelectItems EDIT Here is some sample code showing how to use the function in C/C++, without error checking: //Directory to open ITEMIDLIST *dir = ILCreateFromPath(_T("C:\\"));
//Items in directory to select ITEMIDLIST *item1 = ILCreateFromPath(_T("C:\\Program Files\\")); ITEMIDLIST *item2 = ILCreateFromPath(_T("C:\\Windows\\")); const ITEMIDLIST* selection[] = {item1,item2}; UINT count = sizeof(selection) / sizeof(ITEMIDLIST);
//Perform selection SHOpenFolderAndSelectItems(dir, count, selection, 0);
//Free resources ILFree(dir); ILFree(item1); ILFree(item2); | [
"windows",
"explorer",
"windows-shell"
] | 24 | 18 | 22,226 | 9 | 0 | 2008-08-13T00:35:50.977000 | 2010-06-10T02:36:47.240000 |
9,361 | 16,650 | ICE Faces fileInput file path and file name properties | I'd like to utilize an ICE Faces fileInput control to fill in the file path & file name for the input to an input field on a web page based on file that the user selects. How can I capture these properties without actually performing any file transfer operations? | I believe that the real answer is that you can't. The file path won't be sent by the browser for security reasons. The file name will be sent, however I don't believe it gets sent without an actual upload. The closest you could come, afaik, would be to forcibly kill the connection just when the upload starts. That would net you the filename with little actual transferred data, but it doesn't sound like it would be useful to you. Alternatively, a signed Java applet might get you closer to a solution that you'd want. | ICE Faces fileInput file path and file name properties I'd like to utilize an ICE Faces fileInput control to fill in the file path & file name for the input to an input field on a web page based on file that the user selects. How can I capture these properties without actually performing any file transfer operations? | TITLE:
ICE Faces fileInput file path and file name properties
QUESTION:
I'd like to utilize an ICE Faces fileInput control to fill in the file path & file name for the input to an input field on a web page based on file that the user selects. How can I capture these properties without actually performing any file transfer operations?
ANSWER:
I believe that the real answer is that you can't. The file path won't be sent by the browser for security reasons. The file name will be sent, however I don't believe it gets sent without an actual upload. The closest you could come, afaik, would be to forcibly kill the connection just when the upload starts. That would net you the filename with little actual transferred data, but it doesn't sound like it would be useful to you. Alternatively, a signed Java applet might get you closer to a solution that you'd want. | [
"java",
"ajax",
"jsf",
"icefaces"
] | 5 | 0 | 1,731 | 1 | 0 | 2008-08-13T00:49:17.360000 | 2008-08-19T18:09:44.513000 |
9,372 | 9,380 | How do I prevent IIS7 from dropping my cookies? | I'm using Windows Vista x64 with SP1, and I'm developing an ASP.NET app with IIS7 as the web server. I've got a problem where my cookies aren't "sticking" to the session, so I had a Google and found that there was a known issue with duplicate response headers overwriting instead of being added to the session. This problem was, however, supposed to have been fixed in Service Pack 1 for Vista. Any ideas as to what my trouble might be? I'm using an Integrated app pool, and the max number of worker processes == 1. What's the significance of the underscore? Does it matter where in the URL it is (e.g. it matters if it's in the host name, but not if it's in the query string)? | Just a thought, have you got an underscore in the url. e.g. http://my_site? And one other thing, you're not running the app pool in web garden mode? i.e. Process Model -> Maximum Worker Processes: > 1 What type of app pool are you using - Integrated or Classic mode? | How do I prevent IIS7 from dropping my cookies? I'm using Windows Vista x64 with SP1, and I'm developing an ASP.NET app with IIS7 as the web server. I've got a problem where my cookies aren't "sticking" to the session, so I had a Google and found that there was a known issue with duplicate response headers overwriting instead of being added to the session. This problem was, however, supposed to have been fixed in Service Pack 1 for Vista. Any ideas as to what my trouble might be? I'm using an Integrated app pool, and the max number of worker processes == 1. What's the significance of the underscore? Does it matter where in the URL it is (e.g. it matters if it's in the host name, but not if it's in the query string)? | TITLE:
How do I prevent IIS7 from dropping my cookies?
QUESTION:
I'm using Windows Vista x64 with SP1, and I'm developing an ASP.NET app with IIS7 as the web server. I've got a problem where my cookies aren't "sticking" to the session, so I had a Google and found that there was a known issue with duplicate response headers overwriting instead of being added to the session. This problem was, however, supposed to have been fixed in Service Pack 1 for Vista. Any ideas as to what my trouble might be? I'm using an Integrated app pool, and the max number of worker processes == 1. What's the significance of the underscore? Does it matter where in the URL it is (e.g. it matters if it's in the host name, but not if it's in the query string)?
ANSWER:
Just a thought, have you got an underscore in the url. e.g. http://my_site? And one other thing, you're not running the app pool in web garden mode? i.e. Process Model -> Maximum Worker Processes: > 1 What type of app pool are you using - Integrated or Classic mode? | [
"http",
"iis",
"iis-7",
"cookies",
"windows-vista"
] | 6 | 4 | 5,158 | 1 | 0 | 2008-08-13T01:02:27.507000 | 2008-08-13T01:09:00.033000 |
9,376 | 34,033 | ILMerge Best Practices | Do you use ILMerge? Do you use ILMerge to merge multiple assemblies to ease deployment of dll's? Have you found problems with deployment/versioning in production after ILMerging assemblies together? I'm looking for some advice in regards to using ILMerge to reduce deployment friction, if that is even possible. | I use ILMerge for almost all of my different applications. I have it integrated right into the release build process so what I end up with is one exe per application with no extra dll's. You can't ILMerge any C++ assemblies that have native code. You also can't ILMerge any assemblies that contain XAML for WPF (at least I haven't had any success with that). It complains at runtime that the resources cannot be located. I did write a wrapper executable for ILMerge where I pass in the startup exe name for the project I want to merge, and an output exe name, and then it reflects the dependent assemblies and calls ILMerge with the appropriate command line parameters. It is much easier now when I add new assemblies to the project, I don't have to remember to update the build script. | ILMerge Best Practices Do you use ILMerge? Do you use ILMerge to merge multiple assemblies to ease deployment of dll's? Have you found problems with deployment/versioning in production after ILMerging assemblies together? I'm looking for some advice in regards to using ILMerge to reduce deployment friction, if that is even possible. | TITLE:
ILMerge Best Practices
QUESTION:
Do you use ILMerge? Do you use ILMerge to merge multiple assemblies to ease deployment of dll's? Have you found problems with deployment/versioning in production after ILMerging assemblies together? I'm looking for some advice in regards to using ILMerge to reduce deployment friction, if that is even possible.
ANSWER:
I use ILMerge for almost all of my different applications. I have it integrated right into the release build process so what I end up with is one exe per application with no extra dll's. You can't ILMerge any C++ assemblies that have native code. You also can't ILMerge any assemblies that contain XAML for WPF (at least I haven't had any success with that). It complains at runtime that the resources cannot be located. I did write a wrapper executable for ILMerge where I pass in the startup exe name for the project I want to merge, and an output exe name, and then it reflects the dependent assemblies and calls ILMerge with the appropriate command line parameters. It is much easier now when I add new assemblies to the project, I don't have to remember to update the build script. | [
"c#",
".net",
"deployment",
"ilmerge"
] | 74 | 46 | 60,317 | 12 | 0 | 2008-08-13T01:05:47.250000 | 2008-08-29T06:00:05.953000 |
9,383 | 9,384 | Access a SQL Server 2005 Express Edition from a network computer | How do you access a SQL Server 2005 Express Edition from a application in a network computer? The access I need is both from application (Linq-to-SQL and ODBC) and from Management Studio | See this KB Article. How to configure SQL Server 2005 to allow remote connections. Oh, and remember that the SQLServer name will probably be MyMachineName\SQLExpress | Access a SQL Server 2005 Express Edition from a network computer How do you access a SQL Server 2005 Express Edition from a application in a network computer? The access I need is both from application (Linq-to-SQL and ODBC) and from Management Studio | TITLE:
Access a SQL Server 2005 Express Edition from a network computer
QUESTION:
How do you access a SQL Server 2005 Express Edition from a application in a network computer? The access I need is both from application (Linq-to-SQL and ODBC) and from Management Studio
ANSWER:
See this KB Article. How to configure SQL Server 2005 to allow remote connections. Oh, and remember that the SQLServer name will probably be MyMachineName\SQLExpress | [
"sql-server",
"sql-server-2005-express"
] | 1 | 5 | 1,256 | 2 | 0 | 2008-08-13T01:14:16.857000 | 2008-08-13T01:16:48.257000 |
9,409 | 9,426 | Datagrid: Calculate Avg or Sum for column in Footer | I have a datagrid getting bound to a dataset, and I want to display the average result in the footer for a column populated with integers. The way I figure, there's 2 ways I can think of: 1."Use the Source, Luke" In the code where I'm calling DataGrid.DataBind(), use the DataTable.Compute() method ( or in my case DataSet.DataTable(0).Compute() ). For example: Dim strAverage = DataTable.Compute("Avg(ColumnName)", "") But once I have this, how can I insert it into the footer? 2." Bound for Glory" Using the DataGrid.ItemDataBound event, and calculating a running total from every ListItemType.Item and ListItemType.AlternatingItem, finally displaying in ListItemType.Footer. For example: Select Case e.Item.ItemType Case ListItemType.Item, ListItemType.AlternatingItem runningTotal += CInt(e.Item.Cells(2).Text) Case ListItemType.Footer e.Item.Cells(2).Text = runningTotal/DataGrid.Items.Count End Select This just feels wrong, plus I would have to make sure the runningTotal is reset on every DataBind. Is there a better way? | I don't know if either are necessarily better, but two alternate ways would be: Manually run through the table once you hit the footer and calculate from the on-screen text Manually retrieve the data and do the calculation separately from the bind Of course, #2 sort of offsets the advantages of data binding (assuming that's what you're doing). | Datagrid: Calculate Avg or Sum for column in Footer I have a datagrid getting bound to a dataset, and I want to display the average result in the footer for a column populated with integers. The way I figure, there's 2 ways I can think of: 1."Use the Source, Luke" In the code where I'm calling DataGrid.DataBind(), use the DataTable.Compute() method ( or in my case DataSet.DataTable(0).Compute() ). For example: Dim strAverage = DataTable.Compute("Avg(ColumnName)", "") But once I have this, how can I insert it into the footer? 2." Bound for Glory" Using the DataGrid.ItemDataBound event, and calculating a running total from every ListItemType.Item and ListItemType.AlternatingItem, finally displaying in ListItemType.Footer. For example: Select Case e.Item.ItemType Case ListItemType.Item, ListItemType.AlternatingItem runningTotal += CInt(e.Item.Cells(2).Text) Case ListItemType.Footer e.Item.Cells(2).Text = runningTotal/DataGrid.Items.Count End Select This just feels wrong, plus I would have to make sure the runningTotal is reset on every DataBind. Is there a better way? | TITLE:
Datagrid: Calculate Avg or Sum for column in Footer
QUESTION:
I have a datagrid getting bound to a dataset, and I want to display the average result in the footer for a column populated with integers. The way I figure, there's 2 ways I can think of: 1."Use the Source, Luke" In the code where I'm calling DataGrid.DataBind(), use the DataTable.Compute() method ( or in my case DataSet.DataTable(0).Compute() ). For example: Dim strAverage = DataTable.Compute("Avg(ColumnName)", "") But once I have this, how can I insert it into the footer? 2." Bound for Glory" Using the DataGrid.ItemDataBound event, and calculating a running total from every ListItemType.Item and ListItemType.AlternatingItem, finally displaying in ListItemType.Footer. For example: Select Case e.Item.ItemType Case ListItemType.Item, ListItemType.AlternatingItem runningTotal += CInt(e.Item.Cells(2).Text) Case ListItemType.Footer e.Item.Cells(2).Text = runningTotal/DataGrid.Items.Count End Select This just feels wrong, plus I would have to make sure the runningTotal is reset on every DataBind. Is there a better way?
ANSWER:
I don't know if either are necessarily better, but two alternate ways would be: Manually run through the table once you hit the footer and calculate from the on-screen text Manually retrieve the data and do the calculation separately from the bind Of course, #2 sort of offsets the advantages of data binding (assuming that's what you're doing). | [
"asp.net",
"vb.net",
"datagrid",
"report"
] | 5 | 1 | 9,754 | 2 | 0 | 2008-08-13T02:15:17.093000 | 2008-08-13T02:59:55.943000 |
9,410 | 9,413 | How do you pass a function as a parameter in C? | I want to create a function that performs a function passed by parameter on a set of data. How do you pass a function as a parameter in C? | Declaration A prototype for a function which takes a function parameter looks like the following: void func ( void (*f)(int) ); This states that the parameter f will be a pointer to a function which has a void return type and which takes a single int parameter. The following function ( print ) is an example of a function which could be passed to func as a parameter because it is the proper type: void print ( int x ) { printf("%d\n", x); } Function Call When calling a function with a function parameter, the value passed must be a pointer to a function. Use the function's name (without parentheses) for this: func(print); would call func, passing the print function to it. Function Body As with any parameter, func can now use the parameter's name in the function body to access the value of the parameter. Let's say that func will apply the function it is passed to the numbers 0-4. Consider, first, what the loop would look like to call print directly: for ( int ctr = 0; ctr < 5; ctr++ ) { print(ctr); } Since func 's parameter declaration says that f is the name for a pointer to the desired function, we recall first that if f is a pointer then *f is the thing that f points to (i.e. the function print in this case). As a result, just replace every occurrence of print in the loop above with *f: void func ( void (*f)(int) ) { for ( int ctr = 0; ctr < 5; ctr++ ) { (*f)(ctr); } } Source | How do you pass a function as a parameter in C? I want to create a function that performs a function passed by parameter on a set of data. How do you pass a function as a parameter in C? | TITLE:
How do you pass a function as a parameter in C?
QUESTION:
I want to create a function that performs a function passed by parameter on a set of data. How do you pass a function as a parameter in C?
ANSWER:
Declaration A prototype for a function which takes a function parameter looks like the following: void func ( void (*f)(int) ); This states that the parameter f will be a pointer to a function which has a void return type and which takes a single int parameter. The following function ( print ) is an example of a function which could be passed to func as a parameter because it is the proper type: void print ( int x ) { printf("%d\n", x); } Function Call When calling a function with a function parameter, the value passed must be a pointer to a function. Use the function's name (without parentheses) for this: func(print); would call func, passing the print function to it. Function Body As with any parameter, func can now use the parameter's name in the function body to access the value of the parameter. Let's say that func will apply the function it is passed to the numbers 0-4. Consider, first, what the loop would look like to call print directly: for ( int ctr = 0; ctr < 5; ctr++ ) { print(ctr); } Since func 's parameter declaration says that f is the name for a pointer to the desired function, we recall first that if f is a pointer then *f is the thing that f points to (i.e. the function print in this case). As a result, just replace every occurrence of print in the loop above with *f: void func ( void (*f)(int) ) { for ( int ctr = 0; ctr < 5; ctr++ ) { (*f)(ctr); } } Source | [
"c",
"function",
"pointers",
"syntax",
"parameters"
] | 815 | 970 | 811,917 | 10 | 0 | 2008-08-13T02:16:32.520000 | 2008-08-13T02:22:24.007000 |
9,433 | 9,453 | Do you name controls on forms using the same convention as a private variable? | For some reason I never see this done. Is there a reason why not? For instance I like _blah for private variables, and at least in Windows Forms controls are by default private member variables, but I can't remember ever seeing them named that way. In the case that I am creating/storing control objects in local variables within a member function, it is especially useful to have some visual distinction. | This might be counter-intuitive for some, but we use the dreaded Hungarian notation for UI elements. The logic is simple: for any given data object you may have two or more controls associated with it. For example, you have a control that indicates a birth date on a text box, you will have: the text box a label indicating that the text box is for birth dates a calendar control that will allow you to select a date For that, I would have lblBirthDate for the label, txtBirthDate for the text box, and calBirthDate for the calendar control. I am interested in hearing how others do this, however.:) | Do you name controls on forms using the same convention as a private variable? For some reason I never see this done. Is there a reason why not? For instance I like _blah for private variables, and at least in Windows Forms controls are by default private member variables, but I can't remember ever seeing them named that way. In the case that I am creating/storing control objects in local variables within a member function, it is especially useful to have some visual distinction. | TITLE:
Do you name controls on forms using the same convention as a private variable?
QUESTION:
For some reason I never see this done. Is there a reason why not? For instance I like _blah for private variables, and at least in Windows Forms controls are by default private member variables, but I can't remember ever seeing them named that way. In the case that I am creating/storing control objects in local variables within a member function, it is especially useful to have some visual distinction.
ANSWER:
This might be counter-intuitive for some, but we use the dreaded Hungarian notation for UI elements. The logic is simple: for any given data object you may have two or more controls associated with it. For example, you have a control that indicates a birth date on a text box, you will have: the text box a label indicating that the text box is for birth dates a calendar control that will allow you to select a date For that, I would have lblBirthDate for the label, txtBirthDate for the text box, and calBirthDate for the calendar control. I am interested in hearing how others do this, however.:) | [
"user-interface",
"oop",
"coding-style"
] | 10 | 13 | 1,345 | 11 | 0 | 2008-08-13T03:17:52.037000 | 2008-08-13T03:45:18.550000 |
9,434 | 688,199 | Add multiple window.onload events | In my ASP.NET User Control I'm adding some JavaScript to the window.onload event: if (!Page.ClientScript.IsStartupScriptRegistered(this.GetType(), onloadScriptName)) Page.ClientScript.RegisterStartupScript(this.GetType(), onloadScriptName, "window.onload = function() {myFunction();};", true); My problem is, if there is already something in the onload event, than this overwrites it. How would I go about allowing two user controls to each execute JavaScript in the onload event? Edit: Thanks for the info on third party libraries. I'll keep them in mind. | Most of the "solutions" suggested are Microsoft-specific, or require bloated libraries. Here's one good way. This works with W3C-compliant browsers and with Microsoft IE. if (window.addEventListener) // W3C standard { window.addEventListener('load', myFunction, false); // NB **not** 'onload' } else if (window.attachEvent) // Microsoft { window.attachEvent('onload', myFunction); } | Add multiple window.onload events In my ASP.NET User Control I'm adding some JavaScript to the window.onload event: if (!Page.ClientScript.IsStartupScriptRegistered(this.GetType(), onloadScriptName)) Page.ClientScript.RegisterStartupScript(this.GetType(), onloadScriptName, "window.onload = function() {myFunction();};", true); My problem is, if there is already something in the onload event, than this overwrites it. How would I go about allowing two user controls to each execute JavaScript in the onload event? Edit: Thanks for the info on third party libraries. I'll keep them in mind. | TITLE:
Add multiple window.onload events
QUESTION:
In my ASP.NET User Control I'm adding some JavaScript to the window.onload event: if (!Page.ClientScript.IsStartupScriptRegistered(this.GetType(), onloadScriptName)) Page.ClientScript.RegisterStartupScript(this.GetType(), onloadScriptName, "window.onload = function() {myFunction();};", true); My problem is, if there is already something in the onload event, than this overwrites it. How would I go about allowing two user controls to each execute JavaScript in the onload event? Edit: Thanks for the info on third party libraries. I'll keep them in mind.
ANSWER:
Most of the "solutions" suggested are Microsoft-specific, or require bloated libraries. Here's one good way. This works with W3C-compliant browsers and with Microsoft IE. if (window.addEventListener) // W3C standard { window.addEventListener('load', myFunction, false); // NB **not** 'onload' } else if (window.attachEvent) // Microsoft { window.attachEvent('onload', myFunction); } | [
"javascript",
"asp.net",
"events",
"listener"
] | 68 | 106 | 66,462 | 8 | 0 | 2008-08-13T03:18:32.893000 | 2009-03-27T01:34:31.973000 |
9,435 | 31,805 | Planning and Building a mobile enabled site for your main site | We are in the initial planning stages of building out a mobile site for one of our clients. This mobile site will be in addition to the main site that we have already built for them. We've determined that the content is going to be a small subsection of the main site and will target the main audience that is expected to use the site. While looking through some sample mobile sites we noticed that a lot of site that have WAP in the url are actually just simplified HTML files. http://wap.mlb.com is not really WAP enabled but simple HTML. My question is WAP a think of the past? With smartphones and the iPhone having the ability to render sites as is do we need to worry about WML and WAP or will a stripped down html version be enough? Also can you recommend a blog or tutorial or answer below how best to check for mobile devices? Do we as the programmer need to know each variation of user agent in order to redirect them to our mobile site? Finally, would you program a mobile site for the iPhone/Touch Safari browser or just leave the site as is? | Newer phones come with WAP2 which uses HTML Mobile Profile (XHTML MP), which is quite similar to normal HTML. Older phones use Wireless Markup Language (WML). Depending on your audience I would consider making a mobile phone friendly version of the site using XHTML MP and drop WML completely. By mobile phone friendly I mean light graphics, little JavaScript and simple navigation. To check capabilities of different hand phones, take look at WURFL. Also, you might want to take a look at Mobile Web Best Practices from w3c. | Planning and Building a mobile enabled site for your main site We are in the initial planning stages of building out a mobile site for one of our clients. This mobile site will be in addition to the main site that we have already built for them. We've determined that the content is going to be a small subsection of the main site and will target the main audience that is expected to use the site. While looking through some sample mobile sites we noticed that a lot of site that have WAP in the url are actually just simplified HTML files. http://wap.mlb.com is not really WAP enabled but simple HTML. My question is WAP a think of the past? With smartphones and the iPhone having the ability to render sites as is do we need to worry about WML and WAP or will a stripped down html version be enough? Also can you recommend a blog or tutorial or answer below how best to check for mobile devices? Do we as the programmer need to know each variation of user agent in order to redirect them to our mobile site? Finally, would you program a mobile site for the iPhone/Touch Safari browser or just leave the site as is? | TITLE:
Planning and Building a mobile enabled site for your main site
QUESTION:
We are in the initial planning stages of building out a mobile site for one of our clients. This mobile site will be in addition to the main site that we have already built for them. We've determined that the content is going to be a small subsection of the main site and will target the main audience that is expected to use the site. While looking through some sample mobile sites we noticed that a lot of site that have WAP in the url are actually just simplified HTML files. http://wap.mlb.com is not really WAP enabled but simple HTML. My question is WAP a think of the past? With smartphones and the iPhone having the ability to render sites as is do we need to worry about WML and WAP or will a stripped down html version be enough? Also can you recommend a blog or tutorial or answer below how best to check for mobile devices? Do we as the programmer need to know each variation of user agent in order to redirect them to our mobile site? Finally, would you program a mobile site for the iPhone/Touch Safari browser or just leave the site as is?
ANSWER:
Newer phones come with WAP2 which uses HTML Mobile Profile (XHTML MP), which is quite similar to normal HTML. Older phones use Wireless Markup Language (WML). Depending on your audience I would consider making a mobile phone friendly version of the site using XHTML MP and drop WML completely. By mobile phone friendly I mean light graphics, little JavaScript and simple navigation. To check capabilities of different hand phones, take look at WURFL. Also, you might want to take a look at Mobile Web Best Practices from w3c. | [
"html",
"mobile",
"responsive-design",
"wap",
"wml"
] | 7 | 4 | 2,780 | 8 | 0 | 2008-08-13T03:23:55.987000 | 2008-08-28T07:39:01.357000 |
9,455 | 113,793 | Running xinc on OpenBSD's Apache Server | Has anyone been able to get xinc to run correctly under OpenBSD's chrooted default Apache? I'd like to keep our development server running fully chrooted just like our Production server so that we make sure our code runs just fine chrooted. | Have you posted the issue on the Xinc bug tracker? Xinc itself should run fine as it runs both as a daemon and as a web app. As you alluded to, the issue may be that the daemon is not running in a chroot'ed environment where as the web interface is, leading to either side not grabbing the files. | Running xinc on OpenBSD's Apache Server Has anyone been able to get xinc to run correctly under OpenBSD's chrooted default Apache? I'd like to keep our development server running fully chrooted just like our Production server so that we make sure our code runs just fine chrooted. | TITLE:
Running xinc on OpenBSD's Apache Server
QUESTION:
Has anyone been able to get xinc to run correctly under OpenBSD's chrooted default Apache? I'd like to keep our development server running fully chrooted just like our Production server so that we make sure our code runs just fine chrooted.
ANSWER:
Have you posted the issue on the Xinc bug tracker? Xinc itself should run fine as it runs both as a daemon and as a web app. As you alluded to, the issue may be that the daemon is not running in a chroot'ed environment where as the web interface is, leading to either side not grabbing the files. | [
"php",
"continuous-integration",
"openbsd",
"xinc"
] | 11 | 4 | 662 | 4 | 0 | 2008-08-13T03:47:52.397000 | 2008-09-22T08:26:34.580000 |
9,467 | 9,474 | Best way to write a RESTful service "client" in .Net? | What techniques do people use to "consume" services in the REST stile on.Net? Plain http client? Related to this: many rest services are now using JSON (its tighter and faster) - so what JSON lib is used? | My approach was Write some libraries and interfaces to serialize your objects into REST-compatible XML. You can't neccessarily just use the built-in serializers, because your service may not accept the same kind of XML that.NET wants to give you. Example: When passing booleans to a Rails REST service, "true" gets unserialized as true, whereas "True" (which.NET gives you) unserializes to false. Write some libraries to do the HTTP, wrapping around the basic.NET WebRequest objects. You might get some mileage out of some third party libraries in this area as it tends to be more standard. I found some issues though, such as this lovely bug in the.NET framework, so I'm glad I stuck with the basics. | Best way to write a RESTful service "client" in .Net? What techniques do people use to "consume" services in the REST stile on.Net? Plain http client? Related to this: many rest services are now using JSON (its tighter and faster) - so what JSON lib is used? | TITLE:
Best way to write a RESTful service "client" in .Net?
QUESTION:
What techniques do people use to "consume" services in the REST stile on.Net? Plain http client? Related to this: many rest services are now using JSON (its tighter and faster) - so what JSON lib is used?
ANSWER:
My approach was Write some libraries and interfaces to serialize your objects into REST-compatible XML. You can't neccessarily just use the built-in serializers, because your service may not accept the same kind of XML that.NET wants to give you. Example: When passing booleans to a Rails REST service, "true" gets unserialized as true, whereas "True" (which.NET gives you) unserializes to false. Write some libraries to do the HTTP, wrapping around the basic.NET WebRequest objects. You might get some mileage out of some third party libraries in this area as it tends to be more standard. I found some issues though, such as this lovely bug in the.NET framework, so I'm glad I stuck with the basics. | [
".net",
"web-services",
"rest"
] | 7 | 5 | 2,679 | 1 | 0 | 2008-08-13T04:04:05.877000 | 2008-08-13T04:30:50.487000 |
9,472 | 9,531 | WCF Backward Compatibility Issue | I have a WCF service that I have to reference from a.net 2.0 project. I have tried to reference it using the " add web reference " method but it messes up the params. For example, I have a method in the service that expects a char[] to be passed in, but when I add the web reference, the method expects an int[]. So then I tried to setup svcutil and it worked... kind of. I could only get the service class to compile by adding a bunch of.net 3.0 references to my.net 2.0 project. This didn't sit well with the architect so I've had to can it (and probably for the best too). So I was wondering if anyone has any pointers or resources on how I can setup a.net 2.0 project to reference a WCF service. | One of those instances that you need to edit the WSDL. For a start a useful tool http://codeplex.com/storm | WCF Backward Compatibility Issue I have a WCF service that I have to reference from a.net 2.0 project. I have tried to reference it using the " add web reference " method but it messes up the params. For example, I have a method in the service that expects a char[] to be passed in, but when I add the web reference, the method expects an int[]. So then I tried to setup svcutil and it worked... kind of. I could only get the service class to compile by adding a bunch of.net 3.0 references to my.net 2.0 project. This didn't sit well with the architect so I've had to can it (and probably for the best too). So I was wondering if anyone has any pointers or resources on how I can setup a.net 2.0 project to reference a WCF service. | TITLE:
WCF Backward Compatibility Issue
QUESTION:
I have a WCF service that I have to reference from a.net 2.0 project. I have tried to reference it using the " add web reference " method but it messes up the params. For example, I have a method in the service that expects a char[] to be passed in, but when I add the web reference, the method expects an int[]. So then I tried to setup svcutil and it worked... kind of. I could only get the service class to compile by adding a bunch of.net 3.0 references to my.net 2.0 project. This didn't sit well with the architect so I've had to can it (and probably for the best too). So I was wondering if anyone has any pointers or resources on how I can setup a.net 2.0 project to reference a WCF service.
ANSWER:
One of those instances that you need to edit the WSDL. For a start a useful tool http://codeplex.com/storm | [
"c#",
".net",
"wcf"
] | 0 | 2 | 1,172 | 4 | 0 | 2008-08-13T04:27:31.773000 | 2008-08-13T07:14:23.353000 |
9,473 | 9,481 | RaisePostBackEvent not firing | I have a custom control that implements IPostBackEventHandler. Some client-side events invoke __doPostBack(controlID, eventArgs). The control is implemented in two different user controls. In one control, RaisePostBackEvent is fired on the server-side when __doPostBack is invoked. In the other control, RaisePostBackEvent is never invoked. I checked the __EVENTTARGET parameter and it does match the ClientID of the control... where else might I look to troubleshoot this? | There's a lot of ways this can fall apart. Are you adding the control to the page dynamically in code behind? If so alot of times your UniqueID can be off - even though the client id's are equal. Do you have a code sample that might demonstrate what you're doing? | RaisePostBackEvent not firing I have a custom control that implements IPostBackEventHandler. Some client-side events invoke __doPostBack(controlID, eventArgs). The control is implemented in two different user controls. In one control, RaisePostBackEvent is fired on the server-side when __doPostBack is invoked. In the other control, RaisePostBackEvent is never invoked. I checked the __EVENTTARGET parameter and it does match the ClientID of the control... where else might I look to troubleshoot this? | TITLE:
RaisePostBackEvent not firing
QUESTION:
I have a custom control that implements IPostBackEventHandler. Some client-side events invoke __doPostBack(controlID, eventArgs). The control is implemented in two different user controls. In one control, RaisePostBackEvent is fired on the server-side when __doPostBack is invoked. In the other control, RaisePostBackEvent is never invoked. I checked the __EVENTTARGET parameter and it does match the ClientID of the control... where else might I look to troubleshoot this?
ANSWER:
There's a lot of ways this can fall apart. Are you adding the control to the page dynamically in code behind? If so alot of times your UniqueID can be off - even though the client id's are equal. Do you have a code sample that might demonstrate what you're doing? | [
"asp.net",
"postback"
] | 5 | 1 | 5,001 | 2 | 0 | 2008-08-13T04:30:30.610000 | 2008-08-13T04:45:06.557000 |
9,486 | 9,491 | How do I make Visual Studio auto generate braces for a function block? | I could swear I've seen people typing function headers and then hitting some key combination to auto-create function braces and insert the cursor between them like so: void foo()_ to void foo() { _ } Is this a built-in feature? | Check out Resharper - it is a Visual Studio add-on with this feature, among many other development helps. Also see C# Completer, another add-on. If you want to roll your own, check out this article. Insane that one should have to do that, though. | How do I make Visual Studio auto generate braces for a function block? I could swear I've seen people typing function headers and then hitting some key combination to auto-create function braces and insert the cursor between them like so: void foo()_ to void foo() { _ } Is this a built-in feature? | TITLE:
How do I make Visual Studio auto generate braces for a function block?
QUESTION:
I could swear I've seen people typing function headers and then hitting some key combination to auto-create function braces and insert the cursor between them like so: void foo()_ to void foo() { _ } Is this a built-in feature?
ANSWER:
Check out Resharper - it is a Visual Studio add-on with this feature, among many other development helps. Also see C# Completer, another add-on. If you want to roll your own, check out this article. Insane that one should have to do that, though. | [
"c#",
"visual-studio"
] | 11 | 5 | 6,977 | 5 | 0 | 2008-08-13T05:09:33.233000 | 2008-08-13T05:20:34.147000 |
9,508 | 9,526 | C# 2.0 code consuming assemblies compiled with C# 3.0 | This should be fine seeing as the CLR hasn't actually changed? The boxes running the C# 2.0 code have had.NET 3.5 rolled out. The background is that we have a windows service (.NET 2.0 exe built with VS2005, deployed to ~150 servers) that dynamically loads assemblies (almost like plug-ins) to complete various work items asked of it. Whenever we roll out a new version of the bus logic, we just drop the assemblies on an FTP server and the windows service knows how to check for, grab and store the latest versions. New assemblies are now built using VS2008 and targetting.NET 2.0, we know that works ok. However we'd like to start taking advantage of C# 3.0 language features such as LINQ and targetting the assemblies against.NET 3.5 without having to build and deploy a new version of the windows service. | C#3 and.Net 3.5 adds new assemblies, but the IL is unchanged. This means that with.Net 2 assemblies you can compile and use C#3, as long as you don't use Linq or anything else that references System.Linq or System.Core yield, var, lambda syntax, anon types and initialisers are all compiler cleverness. The IL they produce is cross-compatible. If you can reference the new assemblies for 3.5 it should all just work. There is no new version of ASP.Net - it should still be 2.0.50727 - but you should still compile for 3.5 | C# 2.0 code consuming assemblies compiled with C# 3.0 This should be fine seeing as the CLR hasn't actually changed? The boxes running the C# 2.0 code have had.NET 3.5 rolled out. The background is that we have a windows service (.NET 2.0 exe built with VS2005, deployed to ~150 servers) that dynamically loads assemblies (almost like plug-ins) to complete various work items asked of it. Whenever we roll out a new version of the bus logic, we just drop the assemblies on an FTP server and the windows service knows how to check for, grab and store the latest versions. New assemblies are now built using VS2008 and targetting.NET 2.0, we know that works ok. However we'd like to start taking advantage of C# 3.0 language features such as LINQ and targetting the assemblies against.NET 3.5 without having to build and deploy a new version of the windows service. | TITLE:
C# 2.0 code consuming assemblies compiled with C# 3.0
QUESTION:
This should be fine seeing as the CLR hasn't actually changed? The boxes running the C# 2.0 code have had.NET 3.5 rolled out. The background is that we have a windows service (.NET 2.0 exe built with VS2005, deployed to ~150 servers) that dynamically loads assemblies (almost like plug-ins) to complete various work items asked of it. Whenever we roll out a new version of the bus logic, we just drop the assemblies on an FTP server and the windows service knows how to check for, grab and store the latest versions. New assemblies are now built using VS2008 and targetting.NET 2.0, we know that works ok. However we'd like to start taking advantage of C# 3.0 language features such as LINQ and targetting the assemblies against.NET 3.5 without having to build and deploy a new version of the windows service.
ANSWER:
C#3 and.Net 3.5 adds new assemblies, but the IL is unchanged. This means that with.Net 2 assemblies you can compile and use C#3, as long as you don't use Linq or anything else that references System.Linq or System.Core yield, var, lambda syntax, anon types and initialisers are all compiler cleverness. The IL they produce is cross-compatible. If you can reference the new assemblies for 3.5 it should all just work. There is no new version of ASP.Net - it should still be 2.0.50727 - but you should still compile for 3.5 | [
"c#",
".net",
".net-3.5"
] | 11 | 6 | 991 | 3 | 0 | 2008-08-13T06:17:00.570000 | 2008-08-13T06:58:35.197000 |
9,543 | 9,643 | How do you deploy your SharePoint solutions? | I am now in the process of planning the deployment of a SharePoint solution into a production environment. I have read about some tools that promise an easy way to automate this process, but nothing that seems to fit my scenario. In the testing phase I have used SharePoint Designer to copy site content between the different development and testing servers, but this process is manual and it seems a bit unnecessary. The site is made up of SharePoint web part pages with custom web parts, and a lot of Reporting Services report definitions. So, is there any good advice out there in this vast land of geeks on how to most efficiently create and deploy a SharePoint site for a multiple deployment scenario? Edit Just to clarify. I need to deploy several "SharePoint Sites" into an existing site collection. Since SharePoint likes to have its sites in the SharePoint content database, just putting the files into IIS is not an option at this time. | I would also suggest checking out the SharePoint Content Deployment Wizard by Chris O'Brien. http://www.codeplex.com/SPDeploymentWizard Should help smooth the process you describe, and it's a nice tool for your kitbag regardless | How do you deploy your SharePoint solutions? I am now in the process of planning the deployment of a SharePoint solution into a production environment. I have read about some tools that promise an easy way to automate this process, but nothing that seems to fit my scenario. In the testing phase I have used SharePoint Designer to copy site content between the different development and testing servers, but this process is manual and it seems a bit unnecessary. The site is made up of SharePoint web part pages with custom web parts, and a lot of Reporting Services report definitions. So, is there any good advice out there in this vast land of geeks on how to most efficiently create and deploy a SharePoint site for a multiple deployment scenario? Edit Just to clarify. I need to deploy several "SharePoint Sites" into an existing site collection. Since SharePoint likes to have its sites in the SharePoint content database, just putting the files into IIS is not an option at this time. | TITLE:
How do you deploy your SharePoint solutions?
QUESTION:
I am now in the process of planning the deployment of a SharePoint solution into a production environment. I have read about some tools that promise an easy way to automate this process, but nothing that seems to fit my scenario. In the testing phase I have used SharePoint Designer to copy site content between the different development and testing servers, but this process is manual and it seems a bit unnecessary. The site is made up of SharePoint web part pages with custom web parts, and a lot of Reporting Services report definitions. So, is there any good advice out there in this vast land of geeks on how to most efficiently create and deploy a SharePoint site for a multiple deployment scenario? Edit Just to clarify. I need to deploy several "SharePoint Sites" into an existing site collection. Since SharePoint likes to have its sites in the SharePoint content database, just putting the files into IIS is not an option at this time.
ANSWER:
I would also suggest checking out the SharePoint Content Deployment Wizard by Chris O'Brien. http://www.codeplex.com/SPDeploymentWizard Should help smooth the process you describe, and it's a nice tool for your kitbag regardless | [
"sharepoint",
"deployment",
"production"
] | 18 | 4 | 15,570 | 3 | 0 | 2008-08-13T07:33:45.810000 | 2008-08-13T10:35:58.363000 |
9,570 | 10,888 | What libraries do I need to link my mixed-mode application to? | I'm integrating.NET support into our C++ application. It's an old-school MFC application, with 1 extra file compiled with the "/clr" option that references a CWinFormsControl. I'm not allowed to remove the linker flag "/NODEFAULTLIB". (We have our own build management system, not Visual Studio's.) This means I have to specify all necessary libraries: VC runtime and MFC. Other compiler options include "/MD" Next to that: I can't use the linker flag "/FORCE:MULTIPLE" and just add everything: I'm looking for a non-overlapping set of libraries. | How I solved it: link with "/FORCE:MULTIPLE /verbose" (that links ok) and set the output aside. link with "/NODEFAULTIB /verbose" and trace all unresolveds in the output of the previous step and add the libraries 1 by 1. This resulted in doubles: "AAA.lib: XXX already defined in BBB.lib" Then I finally got it: Recompiled managed AND unmanaged units with /MD and link to (among others): mscoree.lib msvcmrt.lib mfcm80d.lib Mixing /MT (unmanaged) and /MD (managed) turned out to be the bad idea: different(overlapping) libraries are needed. @ajryan: Dependcy Walker only tells me what dll's are used, not what libraries are linked to when linking. (e.g. msvcmrt.lib?) I think. Thanks for the answers! Jan | What libraries do I need to link my mixed-mode application to? I'm integrating.NET support into our C++ application. It's an old-school MFC application, with 1 extra file compiled with the "/clr" option that references a CWinFormsControl. I'm not allowed to remove the linker flag "/NODEFAULTLIB". (We have our own build management system, not Visual Studio's.) This means I have to specify all necessary libraries: VC runtime and MFC. Other compiler options include "/MD" Next to that: I can't use the linker flag "/FORCE:MULTIPLE" and just add everything: I'm looking for a non-overlapping set of libraries. | TITLE:
What libraries do I need to link my mixed-mode application to?
QUESTION:
I'm integrating.NET support into our C++ application. It's an old-school MFC application, with 1 extra file compiled with the "/clr" option that references a CWinFormsControl. I'm not allowed to remove the linker flag "/NODEFAULTLIB". (We have our own build management system, not Visual Studio's.) This means I have to specify all necessary libraries: VC runtime and MFC. Other compiler options include "/MD" Next to that: I can't use the linker flag "/FORCE:MULTIPLE" and just add everything: I'm looking for a non-overlapping set of libraries.
ANSWER:
How I solved it: link with "/FORCE:MULTIPLE /verbose" (that links ok) and set the output aside. link with "/NODEFAULTIB /verbose" and trace all unresolveds in the output of the previous step and add the libraries 1 by 1. This resulted in doubles: "AAA.lib: XXX already defined in BBB.lib" Then I finally got it: Recompiled managed AND unmanaged units with /MD and link to (among others): mscoree.lib msvcmrt.lib mfcm80d.lib Mixing /MT (unmanaged) and /MD (managed) turned out to be the bad idea: different(overlapping) libraries are needed. @ajryan: Dependcy Walker only tells me what dll's are used, not what libraries are linked to when linking. (e.g. msvcmrt.lib?) I think. Thanks for the answers! Jan | [
"linker",
"c++-cli",
"mixed-mode"
] | 1 | 1 | 1,202 | 3 | 0 | 2008-08-13T08:05:00.337000 | 2008-08-14T11:01:33.623000 |
9,589 | 12,064 | Is there a good tool for Makefile generation? | I'm looking for a tool which can generate a Makefile for a C/C++ project for different compilers ( GCC, Microsoft Visual C++, C++Builder, etc.) and different platforms (Windows, Linux, and Mac). | Other suggestions you may want to consider: Scons is a cross-platform, cross-compiler build library, uses Python scripting for the build systems. Used in a variety of large projects, and performs very well. If you're using Qt, QMake is a nice build system too. CMake is also pretty sweet. Finally, if all else fails... | Is there a good tool for Makefile generation? I'm looking for a tool which can generate a Makefile for a C/C++ project for different compilers ( GCC, Microsoft Visual C++, C++Builder, etc.) and different platforms (Windows, Linux, and Mac). | TITLE:
Is there a good tool for Makefile generation?
QUESTION:
I'm looking for a tool which can generate a Makefile for a C/C++ project for different compilers ( GCC, Microsoft Visual C++, C++Builder, etc.) and different platforms (Windows, Linux, and Mac).
ANSWER:
Other suggestions you may want to consider: Scons is a cross-platform, cross-compiler build library, uses Python scripting for the build systems. Used in a variety of large projects, and performs very well. If you're using Qt, QMake is a nice build system too. CMake is also pretty sweet. Finally, if all else fails... | [
"c++",
"c",
"cross-platform",
"makefile"
] | 51 | 40 | 64,148 | 10 | 0 | 2008-08-13T08:47:36.363000 | 2008-08-15T08:09:26.123000 |
9,591 | 9,919 | What WPF books would you recommend? | Well, i've got a nice WPF book its called Sams Windows Presentation Foundation Unleashed. I really like to read and learn with it. Are there any other WPF books you could recommend? | I've found the following books very useful: Windows Presentation Foundation Unleashed - Adam Nathan You mention you already have this book, however I wanted to give my opinion on it. It is a great book for the newcomer - it is printed in full color which is a great help for visualizing both xaml and concepts for WPF. Essential Windows Presentation Foundation - Chris Anderson This is also another great book for the newcomer. While it is not printed in color, it does give a great insight into how WPF works. Pro WPF in C# 2008 - Matthew Macdonald This is a great reference book - one that sits on my desk and is constantly referred too. However, I didn't feel is was as newbie friendly as the other two books above. This is the most recently released book (at the time of this posting), and has been updated for VS2008. This is useful, as there are some changes with the versions of WPF. I believe there is a VB.NET version available. Programming WPF - Chris Sells & Ian Griffiths Another great book - I wish this was available when I was first learning the framework. Application = Code + Markup - Charles Petzold This was the very first WPF I purchased. It is not very newbie friendly, and I wouldn't recommend it for a first-time-wpf'er. The fact that Xaml is not introduced until page 457 makes learning the technology for the real world very difficult. That said, this book is invaluable if you really want to understand how things work at a very deep level (which is also important to get the most of the framework. The only book I would totally avoid is: Professional WPF Programming - Chris Andrade et al. While the content was Ok in this book, I just found the other books to be much clearer and delve to a much deeper level. Hope this helps! WPF has a steep learning curve, but once you "get it", UI programming can actually become "fun"! | What WPF books would you recommend? Well, i've got a nice WPF book its called Sams Windows Presentation Foundation Unleashed. I really like to read and learn with it. Are there any other WPF books you could recommend? | TITLE:
What WPF books would you recommend?
QUESTION:
Well, i've got a nice WPF book its called Sams Windows Presentation Foundation Unleashed. I really like to read and learn with it. Are there any other WPF books you could recommend?
ANSWER:
I've found the following books very useful: Windows Presentation Foundation Unleashed - Adam Nathan You mention you already have this book, however I wanted to give my opinion on it. It is a great book for the newcomer - it is printed in full color which is a great help for visualizing both xaml and concepts for WPF. Essential Windows Presentation Foundation - Chris Anderson This is also another great book for the newcomer. While it is not printed in color, it does give a great insight into how WPF works. Pro WPF in C# 2008 - Matthew Macdonald This is a great reference book - one that sits on my desk and is constantly referred too. However, I didn't feel is was as newbie friendly as the other two books above. This is the most recently released book (at the time of this posting), and has been updated for VS2008. This is useful, as there are some changes with the versions of WPF. I believe there is a VB.NET version available. Programming WPF - Chris Sells & Ian Griffiths Another great book - I wish this was available when I was first learning the framework. Application = Code + Markup - Charles Petzold This was the very first WPF I purchased. It is not very newbie friendly, and I wouldn't recommend it for a first-time-wpf'er. The fact that Xaml is not introduced until page 457 makes learning the technology for the real world very difficult. That said, this book is invaluable if you really want to understand how things work at a very deep level (which is also important to get the most of the framework. The only book I would totally avoid is: Professional WPF Programming - Chris Andrade et al. While the content was Ok in this book, I just found the other books to be much clearer and delve to a much deeper level. Hope this helps! WPF has a steep learning curve, but once you "get it", UI programming can actually become "fun"! | [
"wpf"
] | 65 | 76 | 87,418 | 9 | 0 | 2008-08-13T08:59:42.783000 | 2008-08-13T14:57:08.973000 |
9,601 | 9,630 | Visual Studio 2008 Window layout annoyance | I'm having a weird issue with Visual Studio 2008. Every time I fire it up, the solution explorer is about an inch wide. It's like it can't remember it's layout settings. Every un-docked window is in the position I place it. But if I dock a window, it's position is saved, but it's size will be reset to very-narrow (around an inch) when I load. I've never come across this before and it's pretty annoying. Any ideas? The things I've tried: Saving, then reloading settings via Import/Export. Resetting all environment settings via Import/Export. Window -> Reset Window layout. Comination of rebooting after changing the above. Installed SP1. No improvement none of which changed the behaviour of docked windows. (Also, definitely no other instances running..) I do run two monitors, but I've had this setup on three different workstations and this is the first time I've come across it. | I had the same problem. It turned out that if the VS window was non-maximized, it was really small. So after making the non-maximized wider, the problem disappeared. | Visual Studio 2008 Window layout annoyance I'm having a weird issue with Visual Studio 2008. Every time I fire it up, the solution explorer is about an inch wide. It's like it can't remember it's layout settings. Every un-docked window is in the position I place it. But if I dock a window, it's position is saved, but it's size will be reset to very-narrow (around an inch) when I load. I've never come across this before and it's pretty annoying. Any ideas? The things I've tried: Saving, then reloading settings via Import/Export. Resetting all environment settings via Import/Export. Window -> Reset Window layout. Comination of rebooting after changing the above. Installed SP1. No improvement none of which changed the behaviour of docked windows. (Also, definitely no other instances running..) I do run two monitors, but I've had this setup on three different workstations and this is the first time I've come across it. | TITLE:
Visual Studio 2008 Window layout annoyance
QUESTION:
I'm having a weird issue with Visual Studio 2008. Every time I fire it up, the solution explorer is about an inch wide. It's like it can't remember it's layout settings. Every un-docked window is in the position I place it. But if I dock a window, it's position is saved, but it's size will be reset to very-narrow (around an inch) when I load. I've never come across this before and it's pretty annoying. Any ideas? The things I've tried: Saving, then reloading settings via Import/Export. Resetting all environment settings via Import/Export. Window -> Reset Window layout. Comination of rebooting after changing the above. Installed SP1. No improvement none of which changed the behaviour of docked windows. (Also, definitely no other instances running..) I do run two monitors, but I've had this setup on three different workstations and this is the first time I've come across it.
ANSWER:
I had the same problem. It turned out that if the VS window was non-maximized, it was really small. So after making the non-maximized wider, the problem disappeared. | [
"visual-studio"
] | 8 | 11 | 6,611 | 3 | 0 | 2008-08-13T09:24:10.020000 | 2008-08-13T10:04:49.143000 |
9,612 | 9,638 | Setting Group Type for new Active Directory Entry in VB.NET | I'm trying to set the group type for a new Active Directory Entry via VB.NET and DirectoryServices to create a distribution list. How do I access the ADS_GROUP_TYPE enumerations? Specifically I'm after ADS_GROUP_TYPE_GLOBAL_GROUP. | You're correct, you can't actually get access to the enumerations. Just a wee nitpick, this constant doesn't need to be an object, you can make it an int32 - Const ADS_GROUP_TYPE_GLOBAL_GROUP As Object = &H2 | Setting Group Type for new Active Directory Entry in VB.NET I'm trying to set the group type for a new Active Directory Entry via VB.NET and DirectoryServices to create a distribution list. How do I access the ADS_GROUP_TYPE enumerations? Specifically I'm after ADS_GROUP_TYPE_GLOBAL_GROUP. | TITLE:
Setting Group Type for new Active Directory Entry in VB.NET
QUESTION:
I'm trying to set the group type for a new Active Directory Entry via VB.NET and DirectoryServices to create a distribution list. How do I access the ADS_GROUP_TYPE enumerations? Specifically I'm after ADS_GROUP_TYPE_GLOBAL_GROUP.
ANSWER:
You're correct, you can't actually get access to the enumerations. Just a wee nitpick, this constant doesn't need to be an object, you can make it an int32 - Const ADS_GROUP_TYPE_GLOBAL_GROUP As Object = &H2 | [
"vb.net",
"active-directory",
"directoryservices",
"distribution-list"
] | 3 | 0 | 4,165 | 3 | 0 | 2008-08-13T09:40:12.890000 | 2008-08-13T10:19:05.120000 |
9,614 | 9,635 | Bidirectional outer join | Suppose we have a table A: itemid mark 1 5 2 3 and table B: itemid mark 1 3 3 5 I want to join A*B on A.itemid=B.itemid both right and left ways. i.e. result: itemid A.mark B.mark 1 5 3 2 3 NULL 3 NULL 5 Is there a way to do it in one query in MySQL? | It's called a full outer join and it's not supported natively in MySQL, judging from its docs. You can work around this limitation using UNION as described in the comments to the page I linked to. [edit] Since others posted snippets, here you go. You can see explanation on the linked page. SELECT * FROM A LEFT JOIN B ON A.id = B.id UNION ALL SELECT * FROM A RIGHT JOIN B ON A.id = B.id WHERE A.id IS NULL | Bidirectional outer join Suppose we have a table A: itemid mark 1 5 2 3 and table B: itemid mark 1 3 3 5 I want to join A*B on A.itemid=B.itemid both right and left ways. i.e. result: itemid A.mark B.mark 1 5 3 2 3 NULL 3 NULL 5 Is there a way to do it in one query in MySQL? | TITLE:
Bidirectional outer join
QUESTION:
Suppose we have a table A: itemid mark 1 5 2 3 and table B: itemid mark 1 3 3 5 I want to join A*B on A.itemid=B.itemid both right and left ways. i.e. result: itemid A.mark B.mark 1 5 3 2 3 NULL 3 NULL 5 Is there a way to do it in one query in MySQL?
ANSWER:
It's called a full outer join and it's not supported natively in MySQL, judging from its docs. You can work around this limitation using UNION as described in the comments to the page I linked to. [edit] Since others posted snippets, here you go. You can see explanation on the linked page. SELECT * FROM A LEFT JOIN B ON A.id = B.id UNION ALL SELECT * FROM A RIGHT JOIN B ON A.id = B.id WHERE A.id IS NULL | [
"sql",
"mysql"
] | 8 | 8 | 2,022 | 3 | 0 | 2008-08-13T09:41:43.917000 | 2008-08-13T10:15:39.293000 |
9,632 | 2,523,372 | WPF: How to style or disable the default ContextMenu of a TextBox | Apparantly when users right-click in our WPF application, and they use the Windows Classic theme, the default ContextMenu of the TextBox (which contains Copy, Cut and Paste) has a black background. I know this works well: But this doesn't work: Does anyone know how to style or disable the default ContextMenu for all TextBoxes in WPF? | Due to a late bug report we discovered that we cannot use the ApplicationComands Cut Paste and Copy directly in a partial trusted application. Therefor, using these commands in any Commmand of your controls will do absolutely nothing when executed. So in essence Brads answer was almost there, it sure looked the right way i.e. no black background, but did not fix the problem. We decided to "remove" the menu based on Brads answer, like so: And use this empty context menu like so: | WPF: How to style or disable the default ContextMenu of a TextBox Apparantly when users right-click in our WPF application, and they use the Windows Classic theme, the default ContextMenu of the TextBox (which contains Copy, Cut and Paste) has a black background. I know this works well: But this doesn't work: Does anyone know how to style or disable the default ContextMenu for all TextBoxes in WPF? | TITLE:
WPF: How to style or disable the default ContextMenu of a TextBox
QUESTION:
Apparantly when users right-click in our WPF application, and they use the Windows Classic theme, the default ContextMenu of the TextBox (which contains Copy, Cut and Paste) has a black background. I know this works well: But this doesn't work: Does anyone know how to style or disable the default ContextMenu for all TextBoxes in WPF?
ANSWER:
Due to a late bug report we discovered that we cannot use the ApplicationComands Cut Paste and Copy directly in a partial trusted application. Therefor, using these commands in any Commmand of your controls will do absolutely nothing when executed. So in essence Brads answer was almost there, it sure looked the right way i.e. no black background, but did not fix the problem. We decided to "remove" the menu based on Brads answer, like so: And use this empty context menu like so: | [
"wpf",
"xaml",
".net-3.5"
] | 31 | 9 | 42,384 | 6 | 0 | 2008-08-13T10:05:41.747000 | 2010-03-26T13:04:21.047000 |
9,666 | 9,788 | Is accessing a variable in C# an atomic operation? | I've been raised to believe that if multiple threads can access a variable, then all reads from and writes to that variable must be protected by synchronization code, such as a "lock" statement, because the processor might switch to another thread halfway through a write. However, I was looking through System.Web.Security.Membership using Reflector and found code like this: public static class Membership { private static bool s_Initialized = false; private static object s_lock = new object(); private static MembershipProvider s_Provider;
public static MembershipProvider Provider { get { Initialize(); return s_Provider; } }
private static void Initialize() { if (s_Initialized) return;
lock(s_lock) { if (s_Initialized) return;
// Perform initialization... s_Initialized = true; } } } Why is the s_Initialized field read outside of the lock? Couldn't another thread be trying to write to it at the same time? Are reads and writes of variables atomic? | For the definitive answer go to the spec.:) Partition I, Section 12.6.6 of the CLI spec states: "A conforming CLI shall guarantee that read and write access to properly aligned memory locations no larger than the native word size is atomic when all the write accesses to a location are the same size." So that confirms that s_Initialized will never be unstable, and that read and writes to primitve types smaller than 32 bits are atomic. In particular, double and long ( Int64 and UInt64 ) are not guaranteed to be atomic on a 32-bit platform. You can use the methods on the Interlocked class to protect these. Additionally, while reads and writes are atomic, there is a race condition with addition, subtraction, and incrementing and decrementing primitive types, since they must be read, operated on, and rewritten. The interlocked class allows you to protect these using the CompareExchange and Increment methods. Interlocking creates a memory barrier to prevent the processor from reordering reads and writes. The lock creates the only required barrier in this example. | Is accessing a variable in C# an atomic operation? I've been raised to believe that if multiple threads can access a variable, then all reads from and writes to that variable must be protected by synchronization code, such as a "lock" statement, because the processor might switch to another thread halfway through a write. However, I was looking through System.Web.Security.Membership using Reflector and found code like this: public static class Membership { private static bool s_Initialized = false; private static object s_lock = new object(); private static MembershipProvider s_Provider;
public static MembershipProvider Provider { get { Initialize(); return s_Provider; } }
private static void Initialize() { if (s_Initialized) return;
lock(s_lock) { if (s_Initialized) return;
// Perform initialization... s_Initialized = true; } } } Why is the s_Initialized field read outside of the lock? Couldn't another thread be trying to write to it at the same time? Are reads and writes of variables atomic? | TITLE:
Is accessing a variable in C# an atomic operation?
QUESTION:
I've been raised to believe that if multiple threads can access a variable, then all reads from and writes to that variable must be protected by synchronization code, such as a "lock" statement, because the processor might switch to another thread halfway through a write. However, I was looking through System.Web.Security.Membership using Reflector and found code like this: public static class Membership { private static bool s_Initialized = false; private static object s_lock = new object(); private static MembershipProvider s_Provider;
public static MembershipProvider Provider { get { Initialize(); return s_Provider; } }
private static void Initialize() { if (s_Initialized) return;
lock(s_lock) { if (s_Initialized) return;
// Perform initialization... s_Initialized = true; } } } Why is the s_Initialized field read outside of the lock? Couldn't another thread be trying to write to it at the same time? Are reads and writes of variables atomic?
ANSWER:
For the definitive answer go to the spec.:) Partition I, Section 12.6.6 of the CLI spec states: "A conforming CLI shall guarantee that read and write access to properly aligned memory locations no larger than the native word size is atomic when all the write accesses to a location are the same size." So that confirms that s_Initialized will never be unstable, and that read and writes to primitve types smaller than 32 bits are atomic. In particular, double and long ( Int64 and UInt64 ) are not guaranteed to be atomic on a 32-bit platform. You can use the methods on the Interlocked class to protect these. Additionally, while reads and writes are atomic, there is a race condition with addition, subtraction, and incrementing and decrementing primitive types, since they must be read, operated on, and rewritten. The interlocked class allows you to protect these using the CompareExchange and Increment methods. Interlocking creates a memory barrier to prevent the processor from reordering reads and writes. The lock creates the only required barrier in this example. | [
"c#",
"multithreading"
] | 66 | 38 | 27,452 | 15 | 0 | 2008-08-13T11:41:29.307000 | 2008-08-13T13:24:41.533000 |
9,667 | 9,670 | Validating a Win32 Window Handle | Given a handle of type HWND is it possible to confirm that the handle represents a real window? | There is a function IsWindow which does exactly what you asked for. BOOL isRealHandle = IsWindow(unknwodnHandle); Look at this link for more information. | Validating a Win32 Window Handle Given a handle of type HWND is it possible to confirm that the handle represents a real window? | TITLE:
Validating a Win32 Window Handle
QUESTION:
Given a handle of type HWND is it possible to confirm that the handle represents a real window?
ANSWER:
There is a function IsWindow which does exactly what you asked for. BOOL isRealHandle = IsWindow(unknwodnHandle); Look at this link for more information. | [
"c++",
"windows",
"winapi"
] | 9 | 16 | 2,356 | 2 | 0 | 2008-08-13T11:42:13.860000 | 2008-08-13T11:46:44.537000 |
9,673 | 9,685 | How do I remove duplicates from a C# array? | I have been working with a string[] array in C# that gets returned from a function call. I could possibly cast to a Generic collection, but I was wondering if there was a better way to do it, possibly by using a temp array. What is the best way to remove duplicates from a C# array? | You could possibly use a LINQ query to do this: int[] s = { 1, 2, 3, 3, 4}; int[] q = s.Distinct().ToArray(); | How do I remove duplicates from a C# array? I have been working with a string[] array in C# that gets returned from a function call. I could possibly cast to a Generic collection, but I was wondering if there was a better way to do it, possibly by using a temp array. What is the best way to remove duplicates from a C# array? | TITLE:
How do I remove duplicates from a C# array?
QUESTION:
I have been working with a string[] array in C# that gets returned from a function call. I could possibly cast to a Generic collection, but I was wondering if there was a better way to do it, possibly by using a temp array. What is the best way to remove duplicates from a C# array?
ANSWER:
You could possibly use a LINQ query to do this: int[] s = { 1, 2, 3, 3, 4}; int[] q = s.Distinct().ToArray(); | [
"c#",
"arrays",
"duplicates"
] | 247 | 496 | 422,895 | 29 | 0 | 2008-08-13T11:48:44.360000 | 2008-08-13T12:03:05.940000 |
9,675 | 9,692 | Document Server: Handling Concurrent Saves | I'm implementing a document server. Currently, if two users open the same document, then modify it and save the changes, the document's state will be undefined (either the first user's changes are saved permanently, or the second's). This is entirely unsatisfactory. I considered two possibilities to solve this problem: The first is to lock the document when it is opened by someone the first time, and unlock it when it is closed. But if the network connection to the server is suddenly interrupted, the document would stay in a forever-locked state. The obvious solution is to send regular pings to the server. If the server doesn't receive K pings in a row (K > 1) from a particular client, documents locked by this client are unlocked. If that client re-appears, documents are locked again, if someone hadn't already locked them. This could also help if the client application (running in web browser) is terminated unexpectedly, making it impossible to send a 'quitting, unlock my documents' signal to the server. The second is to store multiple versions of the same document saved by different users. If changes to the document are made in rapid succession, the system would offer either to merge versions or to select a preferred version. To optimize storage space, only document diffs should be kept (just like source control software). What method should I choose, taking into consideration that the connection to the server might sometimes be slow and unresponsive? How should the parameters (ping interval, rapid succession interval) be determined? P.S. Unfortunately, I can't store the documents in a database. | My suggestion would be something like your first one. When the first user (Bob) opens the document, he acquires a lock so that other users can only read the current document. If the user saves the document while he is using it, he keeps the lock. Only when he exits the document, it is unlocked and other people can edit it. If the second user (Kate) opens the document while Bob has the lock on it, Kate will get a message saying the document is uneditable but she can read it until it the lock has been released. So what happens when Bob acquires the lock, maybe saves the document once or twice but then exits the application leaving the lock hanging? As you said yourself, requiring the client with the lock to send pings at a certain frequency is probably the best option. If you don't get a ping from the client for a set amount of time, this effectively means his client is not responding anymore. If this is a web application you can use javascript for the pings. The document that was last saved releases its lock and Kate can now acquire it. A ping can contain the name of the document that the client has a lock on, and the server can calculate when the last ping for that document was received. | Document Server: Handling Concurrent Saves I'm implementing a document server. Currently, if two users open the same document, then modify it and save the changes, the document's state will be undefined (either the first user's changes are saved permanently, or the second's). This is entirely unsatisfactory. I considered two possibilities to solve this problem: The first is to lock the document when it is opened by someone the first time, and unlock it when it is closed. But if the network connection to the server is suddenly interrupted, the document would stay in a forever-locked state. The obvious solution is to send regular pings to the server. If the server doesn't receive K pings in a row (K > 1) from a particular client, documents locked by this client are unlocked. If that client re-appears, documents are locked again, if someone hadn't already locked them. This could also help if the client application (running in web browser) is terminated unexpectedly, making it impossible to send a 'quitting, unlock my documents' signal to the server. The second is to store multiple versions of the same document saved by different users. If changes to the document are made in rapid succession, the system would offer either to merge versions or to select a preferred version. To optimize storage space, only document diffs should be kept (just like source control software). What method should I choose, taking into consideration that the connection to the server might sometimes be slow and unresponsive? How should the parameters (ping interval, rapid succession interval) be determined? P.S. Unfortunately, I can't store the documents in a database. | TITLE:
Document Server: Handling Concurrent Saves
QUESTION:
I'm implementing a document server. Currently, if two users open the same document, then modify it and save the changes, the document's state will be undefined (either the first user's changes are saved permanently, or the second's). This is entirely unsatisfactory. I considered two possibilities to solve this problem: The first is to lock the document when it is opened by someone the first time, and unlock it when it is closed. But if the network connection to the server is suddenly interrupted, the document would stay in a forever-locked state. The obvious solution is to send regular pings to the server. If the server doesn't receive K pings in a row (K > 1) from a particular client, documents locked by this client are unlocked. If that client re-appears, documents are locked again, if someone hadn't already locked them. This could also help if the client application (running in web browser) is terminated unexpectedly, making it impossible to send a 'quitting, unlock my documents' signal to the server. The second is to store multiple versions of the same document saved by different users. If changes to the document are made in rapid succession, the system would offer either to merge versions or to select a preferred version. To optimize storage space, only document diffs should be kept (just like source control software). What method should I choose, taking into consideration that the connection to the server might sometimes be slow and unresponsive? How should the parameters (ping interval, rapid succession interval) be determined? P.S. Unfortunately, I can't store the documents in a database.
ANSWER:
My suggestion would be something like your first one. When the first user (Bob) opens the document, he acquires a lock so that other users can only read the current document. If the user saves the document while he is using it, he keeps the lock. Only when he exits the document, it is unlocked and other people can edit it. If the second user (Kate) opens the document while Bob has the lock on it, Kate will get a message saying the document is uneditable but she can read it until it the lock has been released. So what happens when Bob acquires the lock, maybe saves the document once or twice but then exits the application leaving the lock hanging? As you said yourself, requiring the client with the lock to send pings at a certain frequency is probably the best option. If you don't get a ping from the client for a set amount of time, this effectively means his client is not responding anymore. If this is a web application you can use javascript for the pings. The document that was last saved releases its lock and Kate can now acquire it. A ping can contain the name of the document that the client has a lock on, and the server can calculate when the last ping for that document was received. | [
"concurrency",
"locking",
"versioning"
] | 2 | 0 | 653 | 3 | 0 | 2008-08-13T11:49:14.250000 | 2008-08-13T12:10:43.240000 |
9,693 | 9,732 | Visual Studio 2005 Macros stop working when Visual Studio 2008 is installed | I have a number of macros written for Visual Studio 2005, but they have since stopped working once I installed Visual Studio 2008 on my computer. No error is returned by the macro when I try and run it, and the environment merely shows the hourglass for a second and then returns to the normal cursor. Currently uninstalling one or the other is not possible, and I am wondering if there is anyway to get the macros to work again? | You may need to install (reinstall) VS 2005 SP1, since a security update from Microsoft (KB928365) on July 10 may have caused the issue. | Visual Studio 2005 Macros stop working when Visual Studio 2008 is installed I have a number of macros written for Visual Studio 2005, but they have since stopped working once I installed Visual Studio 2008 on my computer. No error is returned by the macro when I try and run it, and the environment merely shows the hourglass for a second and then returns to the normal cursor. Currently uninstalling one or the other is not possible, and I am wondering if there is anyway to get the macros to work again? | TITLE:
Visual Studio 2005 Macros stop working when Visual Studio 2008 is installed
QUESTION:
I have a number of macros written for Visual Studio 2005, but they have since stopped working once I installed Visual Studio 2008 on my computer. No error is returned by the macro when I try and run it, and the environment merely shows the hourglass for a second and then returns to the normal cursor. Currently uninstalling one or the other is not possible, and I am wondering if there is anyway to get the macros to work again?
ANSWER:
You may need to install (reinstall) VS 2005 SP1, since a security update from Microsoft (KB928365) on July 10 may have caused the issue. | [
"visual-studio",
"visual-studio-2008",
"ide",
"visual-studio-2005",
"macros"
] | 0 | 3 | 1,155 | 1 | 0 | 2008-08-13T12:11:07.657000 | 2008-08-13T12:51:50.490000 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.