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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
45,600 | 231,357 | A issue with the jquery dialog when using the themeroller css | The demos for the jquery ui dialog all use the "flora" theme. I wanted a customized theme, so I used the themeroller to generate a css file. When I used it, everything seemed to be working fine, but later I found that I can't control any input element contained in the dialog (i.e, can't type into a text field, can't check checkboxes). Further investigation revealed that this happens if I set the dialog attribute "modal" to true. This doesn't happen when I use the flora theme. Here is the js file: topMenu = { init: function(){ $("#my_button").bind("click", function(){ $("#SERVICE03_DLG").dialog("open"); $("#something").focus(); });
$("#SERVICE03_DLG").dialog({ autoOpen: false, modal: true, resizable: false, title: "my title", overlay: { opacity: 0.5, background: "black" }, buttons: { "OK": function() { alert("hi!"); }, "cancel": function() { $(this).dialog("close"); } }, close: function(){ $("#something").val(""); } }); } }
$(document).ready(topMenu.init); Here is the html that uses the flora theme: sample please enter something somthing: Here is the html that uses the downloaded themeroller theme: sample please enter something somthing: As you can see, only the referenced css file and class names are different. Anybody have a clue as to what could be wrong? @David: I tried it, and it doesn't seem to work (neither on FF or IE). I tried inline css: style="z-index:5000" and I've also tried it referencing an external css file: #SERVICE03_DLG{z-index:5000;} But neither of these work. Am I missing something in what you suggested? Edit: Solve by brostbeef! Since I was originally using flora, I had mistakenly assumed that I have to specify a class attribute. Turns out, this is only true when you actually use the flora theme (as in the samples). If you use the customized theme, specifying a class attribute causes that strange behaviour. | I think it is because you have the classes different. (flora) (custom) Even with the flora theme, you would still use the ui-dialog class to define it as a dialog. I've done modals before and I've never even defined a class in the tag. jQueryUI should take care of that for you. Try getting rid of the class attribute or using the "ui-dialog" class. | A issue with the jquery dialog when using the themeroller css The demos for the jquery ui dialog all use the "flora" theme. I wanted a customized theme, so I used the themeroller to generate a css file. When I used it, everything seemed to be working fine, but later I found that I can't control any input element contained in the dialog (i.e, can't type into a text field, can't check checkboxes). Further investigation revealed that this happens if I set the dialog attribute "modal" to true. This doesn't happen when I use the flora theme. Here is the js file: topMenu = { init: function(){ $("#my_button").bind("click", function(){ $("#SERVICE03_DLG").dialog("open"); $("#something").focus(); });
$("#SERVICE03_DLG").dialog({ autoOpen: false, modal: true, resizable: false, title: "my title", overlay: { opacity: 0.5, background: "black" }, buttons: { "OK": function() { alert("hi!"); }, "cancel": function() { $(this).dialog("close"); } }, close: function(){ $("#something").val(""); } }); } }
$(document).ready(topMenu.init); Here is the html that uses the flora theme: sample please enter something somthing: Here is the html that uses the downloaded themeroller theme: sample please enter something somthing: As you can see, only the referenced css file and class names are different. Anybody have a clue as to what could be wrong? @David: I tried it, and it doesn't seem to work (neither on FF or IE). I tried inline css: style="z-index:5000" and I've also tried it referencing an external css file: #SERVICE03_DLG{z-index:5000;} But neither of these work. Am I missing something in what you suggested? Edit: Solve by brostbeef! Since I was originally using flora, I had mistakenly assumed that I have to specify a class attribute. Turns out, this is only true when you actually use the flora theme (as in the samples). If you use the customized theme, specifying a class attribute causes that strange behaviour. | TITLE:
A issue with the jquery dialog when using the themeroller css
QUESTION:
The demos for the jquery ui dialog all use the "flora" theme. I wanted a customized theme, so I used the themeroller to generate a css file. When I used it, everything seemed to be working fine, but later I found that I can't control any input element contained in the dialog (i.e, can't type into a text field, can't check checkboxes). Further investigation revealed that this happens if I set the dialog attribute "modal" to true. This doesn't happen when I use the flora theme. Here is the js file: topMenu = { init: function(){ $("#my_button").bind("click", function(){ $("#SERVICE03_DLG").dialog("open"); $("#something").focus(); });
$("#SERVICE03_DLG").dialog({ autoOpen: false, modal: true, resizable: false, title: "my title", overlay: { opacity: 0.5, background: "black" }, buttons: { "OK": function() { alert("hi!"); }, "cancel": function() { $(this).dialog("close"); } }, close: function(){ $("#something").val(""); } }); } }
$(document).ready(topMenu.init); Here is the html that uses the flora theme: sample please enter something somthing: Here is the html that uses the downloaded themeroller theme: sample please enter something somthing: As you can see, only the referenced css file and class names are different. Anybody have a clue as to what could be wrong? @David: I tried it, and it doesn't seem to work (neither on FF or IE). I tried inline css: style="z-index:5000" and I've also tried it referencing an external css file: #SERVICE03_DLG{z-index:5000;} But neither of these work. Am I missing something in what you suggested? Edit: Solve by brostbeef! Since I was originally using flora, I had mistakenly assumed that I have to specify a class attribute. Turns out, this is only true when you actually use the flora theme (as in the samples). If you use the customized theme, specifying a class attribute causes that strange behaviour.
ANSWER:
I think it is because you have the classes different. (flora) (custom) Even with the flora theme, you would still use the ui-dialog class to define it as a dialog. I've done modals before and I've never even defined a class in the tag. jQueryUI should take care of that for you. Try getting rid of the class attribute or using the "ui-dialog" class. | [
"javascript",
"jquery",
"user-interface",
"dialog"
] | 7 | 3 | 4,478 | 4 | 0 | 2008-09-05T11:55:12.313000 | 2008-10-23T20:27:16.847000 |
45,604 | 45,728 | Why doesn't C# support implied generic types on class constructors? | C# doesn't require you to specify a generic type parameter if the compiler can infer it, for instance: List myInts = new List {0,1,1, 2,3,5,8,13,21,34,55,89,144,233,377, 610,987,1597,2584,4181,6765};
//this statement is clunky List myStrings = myInts. Select ( i => i.ToString() ). ToList ();
//the type is inferred from the lambda expression //the compiler knows that it's taking an int and //returning a string List myStrings = myInts. Select( i => i.ToString() ). ToList(); This is needed for anonymous types where you don't know what the type parameter would be (in intellisense it shows up as 'a ) because it's added by the compiler. Class-level type parameters don't let you do this: //sample generic class public class GenericDemo { public GenericDemo ( T value ) { GenericTypedProperty = value; }
public T GenericTypedProperty {get; set;} }
//why can't I do: int anIntValue = 4181; var item = new GenericDemo( anIntValue ); //type inference fails
//however I can create a wrapper like this: public static GenericDemo Create ( T value ) { return new GenericDemo ( value ); }
//then this works - type inference on the method compiles var item = Create( anIntValue ); Why doesn't C# support this class level generic type inference? | Actually, your question isn't bad. I've been toying with a generic programming language for last few years and although I've never come around to actually develop it (and probably never will), I've thought a lot about generic type inference and one of my top priorities has always been to allow the construction of classes without having to specify the generic type. C# simply lacks the set of rules to make this possible. I think the developers never saw the neccesity to include this. Actually, the following code would be very near to your proposition and solve the problem. All C# needs is an added syntax support. class Foo { public Foo(T x) { … } }
// Notice: non-generic class overload. Possible in C#! class Foo { public static Foo ctor (T x) { return new Foo (x); } }
var x = Foo.ctor(42); Since this code actually works, we've shown that the problem is not one of semantics but simply one of lacking support. I guess I have to take back my previous posting.;-) | Why doesn't C# support implied generic types on class constructors? C# doesn't require you to specify a generic type parameter if the compiler can infer it, for instance: List myInts = new List {0,1,1, 2,3,5,8,13,21,34,55,89,144,233,377, 610,987,1597,2584,4181,6765};
//this statement is clunky List myStrings = myInts. Select ( i => i.ToString() ). ToList ();
//the type is inferred from the lambda expression //the compiler knows that it's taking an int and //returning a string List myStrings = myInts. Select( i => i.ToString() ). ToList(); This is needed for anonymous types where you don't know what the type parameter would be (in intellisense it shows up as 'a ) because it's added by the compiler. Class-level type parameters don't let you do this: //sample generic class public class GenericDemo { public GenericDemo ( T value ) { GenericTypedProperty = value; }
public T GenericTypedProperty {get; set;} }
//why can't I do: int anIntValue = 4181; var item = new GenericDemo( anIntValue ); //type inference fails
//however I can create a wrapper like this: public static GenericDemo Create ( T value ) { return new GenericDemo ( value ); }
//then this works - type inference on the method compiles var item = Create( anIntValue ); Why doesn't C# support this class level generic type inference? | TITLE:
Why doesn't C# support implied generic types on class constructors?
QUESTION:
C# doesn't require you to specify a generic type parameter if the compiler can infer it, for instance: List myInts = new List {0,1,1, 2,3,5,8,13,21,34,55,89,144,233,377, 610,987,1597,2584,4181,6765};
//this statement is clunky List myStrings = myInts. Select ( i => i.ToString() ). ToList ();
//the type is inferred from the lambda expression //the compiler knows that it's taking an int and //returning a string List myStrings = myInts. Select( i => i.ToString() ). ToList(); This is needed for anonymous types where you don't know what the type parameter would be (in intellisense it shows up as 'a ) because it's added by the compiler. Class-level type parameters don't let you do this: //sample generic class public class GenericDemo { public GenericDemo ( T value ) { GenericTypedProperty = value; }
public T GenericTypedProperty {get; set;} }
//why can't I do: int anIntValue = 4181; var item = new GenericDemo( anIntValue ); //type inference fails
//however I can create a wrapper like this: public static GenericDemo Create ( T value ) { return new GenericDemo ( value ); }
//then this works - type inference on the method compiles var item = Create( anIntValue ); Why doesn't C# support this class level generic type inference?
ANSWER:
Actually, your question isn't bad. I've been toying with a generic programming language for last few years and although I've never come around to actually develop it (and probably never will), I've thought a lot about generic type inference and one of my top priorities has always been to allow the construction of classes without having to specify the generic type. C# simply lacks the set of rules to make this possible. I think the developers never saw the neccesity to include this. Actually, the following code would be very near to your proposition and solve the problem. All C# needs is an added syntax support. class Foo { public Foo(T x) { … } }
// Notice: non-generic class overload. Possible in C#! class Foo { public static Foo ctor (T x) { return new Foo (x); } }
var x = Foo.ctor(42); Since this code actually works, we've shown that the problem is not one of semantics but simply one of lacking support. I guess I have to take back my previous posting.;-) | [
"c#",
".net",
"generics"
] | 55 | 34 | 16,714 | 3 | 0 | 2008-09-05T12:01:39.380000 | 2008-09-05T12:58:05.767000 |
45,613 | 45,625 | Javascript collection of DOM objects - why can't I reverse with Array.reverse()? | What could be the problem with reversing the array of DOM objects as in the following code: var imagesArr = new Array(); imagesArr = document.getElementById("myDivHolderId").getElementsByTagName("img"); imagesArr.reverse(); In Firefox 3, when I call the reverse() method the script stops executing and shows the following error in the console of the Web Developer Toolbar: imagesArr.reverse is not a function The imagesArr variable can be iterated through with a for loop and elements like imagesArr[i] can be accessed, so why is it not seen as an array when calling the reverse() method? | Because getElementsByTag name actually returns a NodeList structure. It has similar array like indexing properties for syntactic convenience, but it is not an array. For example, the set of entries is actually constantly being dynamically updated - if you add a new img tag under myDivHolderId, it will automatically appear in imagesArr. See http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-536297177 for more. | Javascript collection of DOM objects - why can't I reverse with Array.reverse()? What could be the problem with reversing the array of DOM objects as in the following code: var imagesArr = new Array(); imagesArr = document.getElementById("myDivHolderId").getElementsByTagName("img"); imagesArr.reverse(); In Firefox 3, when I call the reverse() method the script stops executing and shows the following error in the console of the Web Developer Toolbar: imagesArr.reverse is not a function The imagesArr variable can be iterated through with a for loop and elements like imagesArr[i] can be accessed, so why is it not seen as an array when calling the reverse() method? | TITLE:
Javascript collection of DOM objects - why can't I reverse with Array.reverse()?
QUESTION:
What could be the problem with reversing the array of DOM objects as in the following code: var imagesArr = new Array(); imagesArr = document.getElementById("myDivHolderId").getElementsByTagName("img"); imagesArr.reverse(); In Firefox 3, when I call the reverse() method the script stops executing and shows the following error in the console of the Web Developer Toolbar: imagesArr.reverse is not a function The imagesArr variable can be iterated through with a for loop and elements like imagesArr[i] can be accessed, so why is it not seen as an array when calling the reverse() method?
ANSWER:
Because getElementsByTag name actually returns a NodeList structure. It has similar array like indexing properties for syntactic convenience, but it is not an array. For example, the set of entries is actually constantly being dynamically updated - if you add a new img tag under myDivHolderId, it will automatically appear in imagesArr. See http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-536297177 for more. | [
"javascript",
"arrays"
] | 24 | 18 | 20,799 | 8 | 0 | 2008-09-05T12:05:42.943000 | 2008-09-05T12:17:39.777000 |
45,621 | 45,647 | How do you deal with polymorphism in a database? | Example I have Person, SpecialPerson, and User. Person and SpecialPerson are just people - they don't have a user name or password on a site, but they are stored in a database for record keeping. User has all of the same data as Person and potentially SpecialPerson, along with a user name and password as they are registered with the site. How would you address this problem? Would you have a Person table which stores all data common to a person and use a key to look up their data in SpecialPerson (if they are a special person) and User (if they are a user) and vice-versa? | There are generally three ways of mapping object inheritance to database tables. You can make one big table with all the fields from all the objects with a special field for the type. This is fast but wastes space, although modern databases save space by not storing empty fields. And if you're only looking for all users in the table, with every type of person in it things can get slow. Not all or-mappers support this. You can make different tables for all the different child classes with all of the tables containing the base-class fields. This is ok from a performance perspective. But not from a maintenance perspective. Every time your base-class changes all the tables change. You can also make a table per class like you suggested. This way you need joins to get all the data. So it's less performant. I think it's the cleanest solution. What you want to use depends of course on your situation. None of the solutions is perfect so you have to weigh the pros and cons. | How do you deal with polymorphism in a database? Example I have Person, SpecialPerson, and User. Person and SpecialPerson are just people - they don't have a user name or password on a site, but they are stored in a database for record keeping. User has all of the same data as Person and potentially SpecialPerson, along with a user name and password as they are registered with the site. How would you address this problem? Would you have a Person table which stores all data common to a person and use a key to look up their data in SpecialPerson (if they are a special person) and User (if they are a user) and vice-versa? | TITLE:
How do you deal with polymorphism in a database?
QUESTION:
Example I have Person, SpecialPerson, and User. Person and SpecialPerson are just people - they don't have a user name or password on a site, but they are stored in a database for record keeping. User has all of the same data as Person and potentially SpecialPerson, along with a user name and password as they are registered with the site. How would you address this problem? Would you have a Person table which stores all data common to a person and use a key to look up their data in SpecialPerson (if they are a special person) and User (if they are a user) and vice-versa?
ANSWER:
There are generally three ways of mapping object inheritance to database tables. You can make one big table with all the fields from all the objects with a special field for the type. This is fast but wastes space, although modern databases save space by not storing empty fields. And if you're only looking for all users in the table, with every type of person in it things can get slow. Not all or-mappers support this. You can make different tables for all the different child classes with all of the tables containing the base-class fields. This is ok from a performance perspective. But not from a maintenance perspective. Every time your base-class changes all the tables change. You can also make a table per class like you suggested. This way you need joins to get all the data. So it's less performant. I think it's the cleanest solution. What you want to use depends of course on your situation. None of the solutions is perfect so you have to weigh the pros and cons. | [
"database-design",
"oop"
] | 66 | 50 | 34,449 | 14 | 0 | 2008-09-05T12:16:12.933000 | 2008-09-05T12:26:59.693000 |
45,623 | 45,630 | Sockets and Processes in Java | In Java, what would the best way be to have a constantly listening port open, and still send upon receipt of a packet. I am not particularly savvy with network programming at the moment, so the tutorials I have found on the net aren't particularly helpful. Would it make sense to have the listening socket as a serversocket and run it in a separate thread to the socket I'm using to send data to the server? In a loosely related question. Does anyone know if programming simply for java, in netbeans then exporting it for use on a blackberry (using a plugin) the sockets would still work? | If you can afford the threading, try this (keep in mind I've left out some details like exception handling and playing nice with threads). You may want to look into SocketChannels and/or NIO async sockets / selectors. This should get you started. boolean finished = false; int port = 10000; ServerSocket server = new ServerSocket(port);
while (!finished) { // This will block until a connection is made Socket s = server.accept(); // Spawn off some thread (or use a thread pool) to handle this socket // Server will continue to listen } | Sockets and Processes in Java In Java, what would the best way be to have a constantly listening port open, and still send upon receipt of a packet. I am not particularly savvy with network programming at the moment, so the tutorials I have found on the net aren't particularly helpful. Would it make sense to have the listening socket as a serversocket and run it in a separate thread to the socket I'm using to send data to the server? In a loosely related question. Does anyone know if programming simply for java, in netbeans then exporting it for use on a blackberry (using a plugin) the sockets would still work? | TITLE:
Sockets and Processes in Java
QUESTION:
In Java, what would the best way be to have a constantly listening port open, and still send upon receipt of a packet. I am not particularly savvy with network programming at the moment, so the tutorials I have found on the net aren't particularly helpful. Would it make sense to have the listening socket as a serversocket and run it in a separate thread to the socket I'm using to send data to the server? In a loosely related question. Does anyone know if programming simply for java, in netbeans then exporting it for use on a blackberry (using a plugin) the sockets would still work?
ANSWER:
If you can afford the threading, try this (keep in mind I've left out some details like exception handling and playing nice with threads). You may want to look into SocketChannels and/or NIO async sockets / selectors. This should get you started. boolean finished = false; int port = 10000; ServerSocket server = new ServerSocket(port);
while (!finished) { // This will block until a connection is made Socket s = server.accept(); // Spawn off some thread (or use a thread pool) to handle this socket // Server will continue to listen } | [
"java",
"networking",
"sockets",
"blackberry"
] | 4 | 12 | 1,414 | 4 | 0 | 2008-09-05T12:16:50.140000 | 2008-09-05T12:20:37.213000 |
45,624 | 265,268 | How do I change the default author for accessing a local SVN repository? | I use TortoiseSVN to access file based local repo. In all my commits an author is my Windows login name. Is it possible to use different name? I know how to change author after commit but how to change before? Installing apache/svnserver is not an option. | Yes, it's possible. TortoiseSVN and the svn command line client share the same settings location in your profile folder. So you may simply checkout one version using svn.exe: $ svn co --username different_user_name file:///C:/path/to/your/repo... and Subversion will happily replace the associated username for that repository. New commits from TortoiseSVN will then always use that username, no matter with what program you make the new checkouts. The procedure should work with TortoiseSVN 1.5.5. If it doesn't, try emptying svn's authentication cache ( %APPDATA%\Subversion\auth\svn.username ) first. | How do I change the default author for accessing a local SVN repository? I use TortoiseSVN to access file based local repo. In all my commits an author is my Windows login name. Is it possible to use different name? I know how to change author after commit but how to change before? Installing apache/svnserver is not an option. | TITLE:
How do I change the default author for accessing a local SVN repository?
QUESTION:
I use TortoiseSVN to access file based local repo. In all my commits an author is my Windows login name. Is it possible to use different name? I know how to change author after commit but how to change before? Installing apache/svnserver is not an option.
ANSWER:
Yes, it's possible. TortoiseSVN and the svn command line client share the same settings location in your profile folder. So you may simply checkout one version using svn.exe: $ svn co --username different_user_name file:///C:/path/to/your/repo... and Subversion will happily replace the associated username for that repository. New commits from TortoiseSVN will then always use that username, no matter with what program you make the new checkouts. The procedure should work with TortoiseSVN 1.5.5. If it doesn't, try emptying svn's authentication cache ( %APPDATA%\Subversion\auth\svn.username ) first. | [
"svn",
"tortoisesvn",
"default",
"author"
] | 13 | 17 | 24,012 | 5 | 0 | 2008-09-05T12:17:17.347000 | 2008-11-05T14:27:20.753000 |
45,626 | 49,371 | Using ASP.NET AJAX PageMethods and Validators | I have a basic CRUD form that uses PageMethods to update the user details, however the Validators don't fire off, I think I need to manually initialize the validators and check whether the validation has passed in my javascript save method. Any ideas on how to do this? | Ok so I finally solved this: You need to call Page_ClientValidate() in your Save javascript method and If it returns true continue with the save, the Page_ClientValidate() initiates the client side validators, See code below: function Save() { var clientValidationPassed =Page_ClientValidate(); if(clientValidationPassed) { //Save Data PageMethods.SaveUser(UserName,Role,SaveCustomerRequestComplete, RequestError); $find('editPopupExtender').hide(); } else { //Do Nothing as CLient Validation messages are now displayed } return false; } | Using ASP.NET AJAX PageMethods and Validators I have a basic CRUD form that uses PageMethods to update the user details, however the Validators don't fire off, I think I need to manually initialize the validators and check whether the validation has passed in my javascript save method. Any ideas on how to do this? | TITLE:
Using ASP.NET AJAX PageMethods and Validators
QUESTION:
I have a basic CRUD form that uses PageMethods to update the user details, however the Validators don't fire off, I think I need to manually initialize the validators and check whether the validation has passed in my javascript save method. Any ideas on how to do this?
ANSWER:
Ok so I finally solved this: You need to call Page_ClientValidate() in your Save javascript method and If it returns true continue with the save, the Page_ClientValidate() initiates the client side validators, See code below: function Save() { var clientValidationPassed =Page_ClientValidate(); if(clientValidationPassed) { //Save Data PageMethods.SaveUser(UserName,Role,SaveCustomerRequestComplete, RequestError); $find('editPopupExtender').hide(); } else { //Do Nothing as CLient Validation messages are now displayed } return false; } | [
"asp.net-ajax",
"validation"
] | 3 | 1 | 1,135 | 3 | 0 | 2008-09-05T12:17:42.633000 | 2008-09-08T09:32:20.150000 |
45,634 | 45,648 | How do I write SELECT FROM myTable WHERE id IN (SELECT...) in Linq? | How do you rewrite this in Linq? SELECT Id, Name FROM TableA WHERE TableA.Id IN (SELECT xx from TableB INNER JOIN Table C....) So in plain english, I want to select Id and Name from TableA where TableA's Id is in a result set from a second query. | from a in TableA where (from b in TableB join c in TableC on b.id equals c.id where.. select b.id).Contains(a.Id) select new { a.Id, a.Name } | How do I write SELECT FROM myTable WHERE id IN (SELECT...) in Linq? How do you rewrite this in Linq? SELECT Id, Name FROM TableA WHERE TableA.Id IN (SELECT xx from TableB INNER JOIN Table C....) So in plain english, I want to select Id and Name from TableA where TableA's Id is in a result set from a second query. | TITLE:
How do I write SELECT FROM myTable WHERE id IN (SELECT...) in Linq?
QUESTION:
How do you rewrite this in Linq? SELECT Id, Name FROM TableA WHERE TableA.Id IN (SELECT xx from TableB INNER JOIN Table C....) So in plain english, I want to select Id and Name from TableA where TableA's Id is in a result set from a second query.
ANSWER:
from a in TableA where (from b in TableB join c in TableC on b.id equals c.id where.. select b.id).Contains(a.Id) select new { a.Id, a.Name } | [
"sql",
"linq",
"linq-to-sql"
] | 9 | 10 | 10,563 | 3 | 0 | 2008-09-05T12:22:32.060000 | 2008-09-05T12:27:28.647000 |
45,650 | 45,664 | Common Files in Visual Studio Solution | Many times I have seen Visual Studio solutions which have multiple projects that share source files. These common source files are usually out in a common directory and in the solution explorer their icon shows up with a link arrow in the bottom left. However, any time I try to add a source file to the project that is outside of that project's main directory, it just automatically copies it into the directory so that I no longer have a shared copy. I found that I can get around this by manually opening the project file in a text editor and modifying the path to something like "../../../Common/Source.cs" but this is more of a hack then I would like. Is there a setting or something I can change that will allow me to do this from within the IDE? | Right click on a project, select Add->Existing Item->Add as link (press on small arrow on Add button) | Common Files in Visual Studio Solution Many times I have seen Visual Studio solutions which have multiple projects that share source files. These common source files are usually out in a common directory and in the solution explorer their icon shows up with a link arrow in the bottom left. However, any time I try to add a source file to the project that is outside of that project's main directory, it just automatically copies it into the directory so that I no longer have a shared copy. I found that I can get around this by manually opening the project file in a text editor and modifying the path to something like "../../../Common/Source.cs" but this is more of a hack then I would like. Is there a setting or something I can change that will allow me to do this from within the IDE? | TITLE:
Common Files in Visual Studio Solution
QUESTION:
Many times I have seen Visual Studio solutions which have multiple projects that share source files. These common source files are usually out in a common directory and in the solution explorer their icon shows up with a link arrow in the bottom left. However, any time I try to add a source file to the project that is outside of that project's main directory, it just automatically copies it into the directory so that I no longer have a shared copy. I found that I can get around this by manually opening the project file in a text editor and modifying the path to something like "../../../Common/Source.cs" but this is more of a hack then I would like. Is there a setting or something I can change that will allow me to do this from within the IDE?
ANSWER:
Right click on a project, select Add->Existing Item->Add as link (press on small arrow on Add button) | [
"visual-studio",
"projects-and-solutions"
] | 9 | 22 | 6,134 | 2 | 0 | 2008-09-05T12:27:52.733000 | 2008-09-05T12:31:41.523000 |
45,651 | 45,667 | SQL: How to get the id of values I just INSERTed? | I inserted some values into a table. There is a column whose value is auto-generated. In the next statement of my code, I want to retrieve this value. Can you tell me how to do it the right way? | @@IDENTITY is not scope safe and will get you back the id from another table if you have an insert trigger on the original table, always use SCOPE_IDENTITY() | SQL: How to get the id of values I just INSERTed? I inserted some values into a table. There is a column whose value is auto-generated. In the next statement of my code, I want to retrieve this value. Can you tell me how to do it the right way? | TITLE:
SQL: How to get the id of values I just INSERTed?
QUESTION:
I inserted some values into a table. There is a column whose value is auto-generated. In the next statement of my code, I want to retrieve this value. Can you tell me how to do it the right way?
ANSWER:
@@IDENTITY is not scope safe and will get you back the id from another table if you have an insert trigger on the original table, always use SCOPE_IDENTITY() | [
"sql-server"
] | 84 | 60 | 120,297 | 21 | 0 | 2008-09-05T12:27:58.210000 | 2008-09-05T12:31:48.903000 |
45,653 | 45,735 | Has anyone connected BizTalk with QuickBooks? | We use QuickBooks for financial management, and feed it from a variety of sources. I now need to hook it up to BizTalk, and I'd hate to reinvent the wheel. I've done searches, and as far as I can tell there's no QuickBooks adapter for BizTalk. Does anyone know of anything that'll do the job, preferably something that doesn't suck? Doesn't the QB SDK require that Quickbooks be running on the client machine? Is there any way around it? | Quickbooks talks.NET quite easily. You'll need the QuickBooks SDK 7.0 and a copy of Visual Studio.NET, but after that it's very easy to do anything with Quickbooks. Imports QBFC7Lib
Sub AttachToDB() If isAttachedtoQB Then Exit Sub
Lasterror = "Unknown QuickBooks Error" Try QbSession = New QBSessionManager QbSession.OpenConnection("", "Your Company Name") QbSession.BeginSession("", ENOpenMode.omDontCare) MsgReq = QbSession.CreateMsgSetRequest("UK", 6, 0) MsgReq.Attributes.OnError = ENRqOnError.roeStop
Lasterror = "" isAttachedtoQB = True Catch e As Exception If Not QbSession Is Nothing Then QbSession.CloseConnection() QbSession = Nothing End If isAttachedtoQB = False Lasterror = "QuickBooks Connection Error. - " + e.Message + "." End Try End Sub See http://developer.intuit.com/ for more information. | Has anyone connected BizTalk with QuickBooks? We use QuickBooks for financial management, and feed it from a variety of sources. I now need to hook it up to BizTalk, and I'd hate to reinvent the wheel. I've done searches, and as far as I can tell there's no QuickBooks adapter for BizTalk. Does anyone know of anything that'll do the job, preferably something that doesn't suck? Doesn't the QB SDK require that Quickbooks be running on the client machine? Is there any way around it? | TITLE:
Has anyone connected BizTalk with QuickBooks?
QUESTION:
We use QuickBooks for financial management, and feed it from a variety of sources. I now need to hook it up to BizTalk, and I'd hate to reinvent the wheel. I've done searches, and as far as I can tell there's no QuickBooks adapter for BizTalk. Does anyone know of anything that'll do the job, preferably something that doesn't suck? Doesn't the QB SDK require that Quickbooks be running on the client machine? Is there any way around it?
ANSWER:
Quickbooks talks.NET quite easily. You'll need the QuickBooks SDK 7.0 and a copy of Visual Studio.NET, but after that it's very easy to do anything with Quickbooks. Imports QBFC7Lib
Sub AttachToDB() If isAttachedtoQB Then Exit Sub
Lasterror = "Unknown QuickBooks Error" Try QbSession = New QBSessionManager QbSession.OpenConnection("", "Your Company Name") QbSession.BeginSession("", ENOpenMode.omDontCare) MsgReq = QbSession.CreateMsgSetRequest("UK", 6, 0) MsgReq.Attributes.OnError = ENRqOnError.roeStop
Lasterror = "" isAttachedtoQB = True Catch e As Exception If Not QbSession Is Nothing Then QbSession.CloseConnection() QbSession = Nothing End If isAttachedtoQB = False Lasterror = "QuickBooks Connection Error. - " + e.Message + "." End Try End Sub See http://developer.intuit.com/ for more information. | [
"biztalk",
"quickbooks"
] | 3 | 1 | 635 | 4 | 0 | 2008-09-05T12:29:03.200000 | 2008-09-05T13:02:52.057000 |
45,658 | 63,430 | How do I retrieve IPIEHTMLDocument2 interface on IE Mobile | I wrote an Active X plugin for IE7 which implements IObjectWithSite besides some other necessary interfaces (note no IOleClient). This interface is queried and called by IE7. During the SetSite() call I retrieve a pointer to IE7's site interface which I can use to retrieve the IHTMLDocument2 interface using the following approach: IUnknown *site = pUnkSite; /* retrieved from IE7 during SetSite() call */ IServiceProvider *sp = NULL; IHTMLWindow2 *win = NULL; IHTMLDocument2 *doc = NULL;
if(site) { site->QueryInterface(IID_IServiceProvider, (void **)&sp); if(sp) { sp->QueryService(IID_IHTMLWindow2, IID_IHTMLWindow2, (void **)&win); if(win) { win->get_document(&doc); } } } if(doc) { /* found */ } I tried a similiar approach on PIE as well using the following code, however, even the IPIEHTMLWindow2 interface cannot be acquired, so I'm stuck: IUnknown *site = pUnkSite; /* retrieved from PIE during SetSite() call */ IPIEHTMLWindow2 *win = NULL; IPIEHTMLDocument1 *tmp = NULL; IPIEHTMLDocument2 *doc = NULL;
if(site) { site->QueryInterface(__uuidof(*win), (void **)&win); if(win) { /* never the case */ win->get_document(&tmp); if(tmp) { tmp->QueryInterface(__uuidof(*doc), (void **)&doc); } } } if(doc) { /* found */ } Using the IServiceProvider interface doesn't work either, so I already tested this. Any ideas? | I found the following code in the Google Gears code, here. I copied the functions I think you need to here. The one you need is at the bottom (GetHtmlWindow2), but the other two are needed as well. Hopefully I didn't miss anything, but if I did the stuff you need is probably at the link. #ifdef WINCE // We can't get IWebBrowser2 for WinCE. #else HRESULT ActiveXUtils::GetWebBrowser2(IUnknown *site, IWebBrowser2 **browser2) { CComQIPtr service_provider = site; if (!service_provider) { return E_FAIL; }
return service_provider->QueryService(SID_SWebBrowserApp, IID_IWebBrowser2, reinterpret_cast (browser2)); } #endif
HRESULT ActiveXUtils::GetHtmlDocument2(IUnknown *site, IHTMLDocument2 **document2) { HRESULT hr;
#ifdef WINCE // Follow path Window2 -> Window -> Document -> Document2 CComPtr window2; hr = GetHtmlWindow2(site, &window2); if (FAILED(hr) ||!window2) { return false; } CComQIPtr window = window2; CComPtr document; hr = window->get_document(&document); if (FAILED(hr) ||!document) { return E_FAIL; } return document->QueryInterface(__uuidof(*document2), reinterpret_cast (document2)); #else CComPtr web_browser2; hr = GetWebBrowser2(site, &web_browser2); if (FAILED(hr) ||!web_browser2) { return E_FAIL; }
CComPtr doc_dispatch; hr = web_browser2->get_Document(&doc_dispatch); if (FAILED(hr) ||!doc_dispatch) { return E_FAIL; }
return doc_dispatch->QueryInterface(document2); #endif }
HRESULT ActiveXUtils::GetHtmlWindow2(IUnknown *site, #ifdef WINCE IPIEHTMLWindow2 **window2) { // site is javascript IDispatch pointer. return site->QueryInterface(__uuidof(*window2), reinterpret_cast (window2)); #else IHTMLWindow2 **window2) { CComPtr html_document2; // To hook an event on a page's window object, follow the path // IWebBrowser2->document->parentWindow->IHTMLWindow2
HRESULT hr = GetHtmlDocument2(site, &html_document2); if (FAILED(hr) ||!html_document2) { return E_FAIL; }
return html_document2->get_parentWindow(window2); #endif } | How do I retrieve IPIEHTMLDocument2 interface on IE Mobile I wrote an Active X plugin for IE7 which implements IObjectWithSite besides some other necessary interfaces (note no IOleClient). This interface is queried and called by IE7. During the SetSite() call I retrieve a pointer to IE7's site interface which I can use to retrieve the IHTMLDocument2 interface using the following approach: IUnknown *site = pUnkSite; /* retrieved from IE7 during SetSite() call */ IServiceProvider *sp = NULL; IHTMLWindow2 *win = NULL; IHTMLDocument2 *doc = NULL;
if(site) { site->QueryInterface(IID_IServiceProvider, (void **)&sp); if(sp) { sp->QueryService(IID_IHTMLWindow2, IID_IHTMLWindow2, (void **)&win); if(win) { win->get_document(&doc); } } } if(doc) { /* found */ } I tried a similiar approach on PIE as well using the following code, however, even the IPIEHTMLWindow2 interface cannot be acquired, so I'm stuck: IUnknown *site = pUnkSite; /* retrieved from PIE during SetSite() call */ IPIEHTMLWindow2 *win = NULL; IPIEHTMLDocument1 *tmp = NULL; IPIEHTMLDocument2 *doc = NULL;
if(site) { site->QueryInterface(__uuidof(*win), (void **)&win); if(win) { /* never the case */ win->get_document(&tmp); if(tmp) { tmp->QueryInterface(__uuidof(*doc), (void **)&doc); } } } if(doc) { /* found */ } Using the IServiceProvider interface doesn't work either, so I already tested this. Any ideas? | TITLE:
How do I retrieve IPIEHTMLDocument2 interface on IE Mobile
QUESTION:
I wrote an Active X plugin for IE7 which implements IObjectWithSite besides some other necessary interfaces (note no IOleClient). This interface is queried and called by IE7. During the SetSite() call I retrieve a pointer to IE7's site interface which I can use to retrieve the IHTMLDocument2 interface using the following approach: IUnknown *site = pUnkSite; /* retrieved from IE7 during SetSite() call */ IServiceProvider *sp = NULL; IHTMLWindow2 *win = NULL; IHTMLDocument2 *doc = NULL;
if(site) { site->QueryInterface(IID_IServiceProvider, (void **)&sp); if(sp) { sp->QueryService(IID_IHTMLWindow2, IID_IHTMLWindow2, (void **)&win); if(win) { win->get_document(&doc); } } } if(doc) { /* found */ } I tried a similiar approach on PIE as well using the following code, however, even the IPIEHTMLWindow2 interface cannot be acquired, so I'm stuck: IUnknown *site = pUnkSite; /* retrieved from PIE during SetSite() call */ IPIEHTMLWindow2 *win = NULL; IPIEHTMLDocument1 *tmp = NULL; IPIEHTMLDocument2 *doc = NULL;
if(site) { site->QueryInterface(__uuidof(*win), (void **)&win); if(win) { /* never the case */ win->get_document(&tmp); if(tmp) { tmp->QueryInterface(__uuidof(*doc), (void **)&doc); } } } if(doc) { /* found */ } Using the IServiceProvider interface doesn't work either, so I already tested this. Any ideas?
ANSWER:
I found the following code in the Google Gears code, here. I copied the functions I think you need to here. The one you need is at the bottom (GetHtmlWindow2), but the other two are needed as well. Hopefully I didn't miss anything, but if I did the stuff you need is probably at the link. #ifdef WINCE // We can't get IWebBrowser2 for WinCE. #else HRESULT ActiveXUtils::GetWebBrowser2(IUnknown *site, IWebBrowser2 **browser2) { CComQIPtr service_provider = site; if (!service_provider) { return E_FAIL; }
return service_provider->QueryService(SID_SWebBrowserApp, IID_IWebBrowser2, reinterpret_cast (browser2)); } #endif
HRESULT ActiveXUtils::GetHtmlDocument2(IUnknown *site, IHTMLDocument2 **document2) { HRESULT hr;
#ifdef WINCE // Follow path Window2 -> Window -> Document -> Document2 CComPtr window2; hr = GetHtmlWindow2(site, &window2); if (FAILED(hr) ||!window2) { return false; } CComQIPtr window = window2; CComPtr document; hr = window->get_document(&document); if (FAILED(hr) ||!document) { return E_FAIL; } return document->QueryInterface(__uuidof(*document2), reinterpret_cast (document2)); #else CComPtr web_browser2; hr = GetWebBrowser2(site, &web_browser2); if (FAILED(hr) ||!web_browser2) { return E_FAIL; }
CComPtr doc_dispatch; hr = web_browser2->get_Document(&doc_dispatch); if (FAILED(hr) ||!doc_dispatch) { return E_FAIL; }
return doc_dispatch->QueryInterface(document2); #endif }
HRESULT ActiveXUtils::GetHtmlWindow2(IUnknown *site, #ifdef WINCE IPIEHTMLWindow2 **window2) { // site is javascript IDispatch pointer. return site->QueryInterface(__uuidof(*window2), reinterpret_cast (window2)); #else IHTMLWindow2 **window2) { CComPtr html_document2; // To hook an event on a page's window object, follow the path // IWebBrowser2->document->parentWindow->IHTMLWindow2
HRESULT hr = GetHtmlDocument2(site, &html_document2); if (FAILED(hr) ||!html_document2) { return E_FAIL; }
return html_document2->get_parentWindow(window2); #endif } | [
"c++",
"internet-explorer",
"windows-mobile",
"pocketpc"
] | 2 | 4 | 1,341 | 2 | 0 | 2008-09-05T12:29:34.320000 | 2008-09-15T14:32:04.847000 |
45,695 | 45,712 | Visual Studio Add-in not going away | Ok, so I demo'd Refactor Pro and Resharper, I'm more comfortable with Resharper so that's what I bought. When I uninstalled Refactor Pro I thought everything was breezy. However, now when I open Visual Studio I get The Add-in 'DevExpress Tools' failed to load or caused and exception, woudl you like to remove this Add in? If you choose yes, the file it was loaded from, 'C:\ProgramData\Application Data\Microsoft\MSEnvShared\Addins\DevExpressToolsOrcas.Addin' will be renamed. I hit yes, then get: "Could Not rename Add-in file "C:\ProgramData\Application Data\Microsoft\MSEnvShared\Addins\DevExpressToolsOrcas.Addin" This happens every time, I went to that location and there is not folder by that name. I searched for that file and nothing. Anyone experience a clingy add-in? | I had the same issue with the VS.NET 2005 version and I'm not sure it is related. It was a registry problem and when i contacted the people from devexpress they send me a clean up tool. You can try to see if there is another clean up tool for 2008 or search in the registry for the file name and remove it manually. | Visual Studio Add-in not going away Ok, so I demo'd Refactor Pro and Resharper, I'm more comfortable with Resharper so that's what I bought. When I uninstalled Refactor Pro I thought everything was breezy. However, now when I open Visual Studio I get The Add-in 'DevExpress Tools' failed to load or caused and exception, woudl you like to remove this Add in? If you choose yes, the file it was loaded from, 'C:\ProgramData\Application Data\Microsoft\MSEnvShared\Addins\DevExpressToolsOrcas.Addin' will be renamed. I hit yes, then get: "Could Not rename Add-in file "C:\ProgramData\Application Data\Microsoft\MSEnvShared\Addins\DevExpressToolsOrcas.Addin" This happens every time, I went to that location and there is not folder by that name. I searched for that file and nothing. Anyone experience a clingy add-in? | TITLE:
Visual Studio Add-in not going away
QUESTION:
Ok, so I demo'd Refactor Pro and Resharper, I'm more comfortable with Resharper so that's what I bought. When I uninstalled Refactor Pro I thought everything was breezy. However, now when I open Visual Studio I get The Add-in 'DevExpress Tools' failed to load or caused and exception, woudl you like to remove this Add in? If you choose yes, the file it was loaded from, 'C:\ProgramData\Application Data\Microsoft\MSEnvShared\Addins\DevExpressToolsOrcas.Addin' will be renamed. I hit yes, then get: "Could Not rename Add-in file "C:\ProgramData\Application Data\Microsoft\MSEnvShared\Addins\DevExpressToolsOrcas.Addin" This happens every time, I went to that location and there is not folder by that name. I searched for that file and nothing. Anyone experience a clingy add-in?
ANSWER:
I had the same issue with the VS.NET 2005 version and I'm not sure it is related. It was a registry problem and when i contacted the people from devexpress they send me a clean up tool. You can try to see if there is another clean up tool for 2008 or search in the registry for the file name and remove it manually. | [
"visual-studio"
] | 7 | 5 | 1,439 | 2 | 0 | 2008-09-05T12:44:19.277000 | 2008-09-05T12:50:55.253000 |
45,702 | 45,710 | How to compile a .NET application to native code? | Let's say I want to run a.NET application on a machine where the.NET framework is not available; Is there any way to compile the application to native code? | Microsoft has an article describing how you can Compile MSIL to Native Code You can use Ngen. The Native Image Generator (Ngen.exe) is a tool that improves the performance of managed applications. Ngen.exe creates native images, which are files containing compiled processor-specific machine code, and installs them into the native image cache on the local computer. The runtime can use native images from the cache instead using the just-in-time (JIT) compiler to compile the original assembly. Unfortunately, you still need the libraries from the framework in order to run your program. There's no feature that I know of with the MS.Net framework SDK that allows you to compile all the required files into a single executable | How to compile a .NET application to native code? Let's say I want to run a.NET application on a machine where the.NET framework is not available; Is there any way to compile the application to native code? | TITLE:
How to compile a .NET application to native code?
QUESTION:
Let's say I want to run a.NET application on a machine where the.NET framework is not available; Is there any way to compile the application to native code?
ANSWER:
Microsoft has an article describing how you can Compile MSIL to Native Code You can use Ngen. The Native Image Generator (Ngen.exe) is a tool that improves the performance of managed applications. Ngen.exe creates native images, which are files containing compiled processor-specific machine code, and installs them into the native image cache on the local computer. The runtime can use native images from the cache instead using the just-in-time (JIT) compiler to compile the original assembly. Unfortunately, you still need the libraries from the framework in order to run your program. There's no feature that I know of with the MS.Net framework SDK that allows you to compile all the required files into a single executable | [
".net",
"compilation",
"native-code"
] | 95 | 45 | 75,915 | 16 | 0 | 2008-09-05T12:46:24.890000 | 2008-09-05T12:50:23.537000 |
45,705 | 45,731 | How would you architect a desktop application in C# 3.0 | I've created a simple desktop application in C# 3.0 to learn some C#, wpf and.Net 3.5. My application essentially reads data from a csv file and stores it in a SQL server CE database. I use sqlmetal to generate the ORM code for the database. My first iteration of this app is ugly as hell and I'm in the process of refactoring it. Which brings me to my question. How would you architect a desktop database app in C#? What are the best practices? Do you create a Database Abstraction Layer (DAL) which uses the sqlmetal generated code? Or is the generated code enough of an abstraction? If you use DAL pattern, do you make it a singleton or a static member? Do you use the View-Model-ModelView pattern with the DAL pattern? Apologies if this seems like a long open ended question, but I have been giving this a lot of thought recently. I see a lot of examples on how to architect an enterprise n-tier app in C# but not that many on architecting standalone desktop apps. | I would start with the Composite Application Guidance for WPF ( cough PRISM cough ) from Microsoft's P&P team. With the download comes a great reference application that is the starting point for most of my WPF development today. The DotNetRocks crew just interviewed Glenn Block and Brian Noyes about this if you're interested in hearing more from them. Even better, Prism is not nearly as heavy as the CAB was, if you're familiar at all with that from the WinForms days. | How would you architect a desktop application in C# 3.0 I've created a simple desktop application in C# 3.0 to learn some C#, wpf and.Net 3.5. My application essentially reads data from a csv file and stores it in a SQL server CE database. I use sqlmetal to generate the ORM code for the database. My first iteration of this app is ugly as hell and I'm in the process of refactoring it. Which brings me to my question. How would you architect a desktop database app in C#? What are the best practices? Do you create a Database Abstraction Layer (DAL) which uses the sqlmetal generated code? Or is the generated code enough of an abstraction? If you use DAL pattern, do you make it a singleton or a static member? Do you use the View-Model-ModelView pattern with the DAL pattern? Apologies if this seems like a long open ended question, but I have been giving this a lot of thought recently. I see a lot of examples on how to architect an enterprise n-tier app in C# but not that many on architecting standalone desktop apps. | TITLE:
How would you architect a desktop application in C# 3.0
QUESTION:
I've created a simple desktop application in C# 3.0 to learn some C#, wpf and.Net 3.5. My application essentially reads data from a csv file and stores it in a SQL server CE database. I use sqlmetal to generate the ORM code for the database. My first iteration of this app is ugly as hell and I'm in the process of refactoring it. Which brings me to my question. How would you architect a desktop database app in C#? What are the best practices? Do you create a Database Abstraction Layer (DAL) which uses the sqlmetal generated code? Or is the generated code enough of an abstraction? If you use DAL pattern, do you make it a singleton or a static member? Do you use the View-Model-ModelView pattern with the DAL pattern? Apologies if this seems like a long open ended question, but I have been giving this a lot of thought recently. I see a lot of examples on how to architect an enterprise n-tier app in C# but not that many on architecting standalone desktop apps.
ANSWER:
I would start with the Composite Application Guidance for WPF ( cough PRISM cough ) from Microsoft's P&P team. With the download comes a great reference application that is the starting point for most of my WPF development today. The DotNetRocks crew just interviewed Glenn Block and Brian Noyes about this if you're interested in hearing more from them. Even better, Prism is not nearly as heavy as the CAB was, if you're familiar at all with that from the WinForms days. | [
"c#",
"wpf",
"architecture"
] | 10 | 4 | 3,406 | 5 | 0 | 2008-09-05T12:48:42.433000 | 2008-09-05T12:59:13.703000 |
45,716 | 226,949 | How to do multi-column sorting on a Visual Basic 6 ListView? | I am working in Visual Basic 6 and need to sort by multiple columns in a ListView. For example, sorting a list of music tracks by artist, then album, then track number. As far as I know, VB6 does not support this out of the box. Here are the suggestions I have already heard: Sort the data in a SQL table first and display the data in the resulting order Sort the data in an ADO recordset object in memory Sort by the primary column and then perform a sort algorithm on the items, moving them around into the correct positions manually Does anyone have experience with multiple-column sorting in VB6 who could lend advice? | I would create a hidden column in the listview that concatenates those three columns and sort by that | How to do multi-column sorting on a Visual Basic 6 ListView? I am working in Visual Basic 6 and need to sort by multiple columns in a ListView. For example, sorting a list of music tracks by artist, then album, then track number. As far as I know, VB6 does not support this out of the box. Here are the suggestions I have already heard: Sort the data in a SQL table first and display the data in the resulting order Sort the data in an ADO recordset object in memory Sort by the primary column and then perform a sort algorithm on the items, moving them around into the correct positions manually Does anyone have experience with multiple-column sorting in VB6 who could lend advice? | TITLE:
How to do multi-column sorting on a Visual Basic 6 ListView?
QUESTION:
I am working in Visual Basic 6 and need to sort by multiple columns in a ListView. For example, sorting a list of music tracks by artist, then album, then track number. As far as I know, VB6 does not support this out of the box. Here are the suggestions I have already heard: Sort the data in a SQL table first and display the data in the resulting order Sort the data in an ADO recordset object in memory Sort by the primary column and then perform a sort algorithm on the items, moving them around into the correct positions manually Does anyone have experience with multiple-column sorting in VB6 who could lend advice?
ANSWER:
I would create a hidden column in the listview that concatenates those three columns and sort by that | [
"sql-server",
"vb6",
"sorting"
] | 4 | 4 | 4,535 | 2 | 0 | 2008-09-05T12:53:40.270000 | 2008-10-22T18:15:01.823000 |
45,729 | 45,747 | What path should I pass as an AssemblyPath parameter to the Publish.GacRemove function? | I want to use the Publish.GacRemove function to remove an assembly from GAC. However, I don't understand what path I should pass as an argument. Should it be a path to the original DLL (what if I removed it after installing it in the GAC?) or the path to the assembly in the GAC? UPDATE: I finally used these API wrappers. | I am using the GacInstall to publish my assemblies, however once installed into the gac, I sometimes delete my ‘temporary’ copy of the assemblies. And then, if I ever wanted to uninstall the assemblies from the gac I do not have the files at the original path. This is causing a problem since I cannot seem to get the GacRemove method to uninstall the assemblies unless I keep the original files. Conclusion: Yes, you need to specify the path to the original DLL. (And try to not move/delete it later). If you delete it, try to copy the file from the GAC to your original path and you should be able to uninstall it using GacRemove. | What path should I pass as an AssemblyPath parameter to the Publish.GacRemove function? I want to use the Publish.GacRemove function to remove an assembly from GAC. However, I don't understand what path I should pass as an argument. Should it be a path to the original DLL (what if I removed it after installing it in the GAC?) or the path to the assembly in the GAC? UPDATE: I finally used these API wrappers. | TITLE:
What path should I pass as an AssemblyPath parameter to the Publish.GacRemove function?
QUESTION:
I want to use the Publish.GacRemove function to remove an assembly from GAC. However, I don't understand what path I should pass as an argument. Should it be a path to the original DLL (what if I removed it after installing it in the GAC?) or the path to the assembly in the GAC? UPDATE: I finally used these API wrappers.
ANSWER:
I am using the GacInstall to publish my assemblies, however once installed into the gac, I sometimes delete my ‘temporary’ copy of the assemblies. And then, if I ever wanted to uninstall the assemblies from the gac I do not have the files at the original path. This is causing a problem since I cannot seem to get the GacRemove method to uninstall the assemblies unless I keep the original files. Conclusion: Yes, you need to specify the path to the original DLL. (And try to not move/delete it later). If you delete it, try to copy the file from the GAC to your original path and you should be able to uninstall it using GacRemove. | [
".net",
"gac"
] | 1 | 2 | 2,346 | 2 | 0 | 2008-09-05T12:58:57.167000 | 2008-09-05T13:06:26.587000 |
45,732 | 45,864 | How can I extract a part of a xaml object graph via linq to xml? | I have an object graph serialized to xaml. A rough sample of what it looks like is: I want to use Linq to XML in order to extract the serialized objects within the TheCollection. Note: MyObject may be named differently at runtime; I'm interested in any object that implements the same interface, which has a public collection called TheCollection that contains types of IPolymorphicLol. The only things I know at runtime are the depth at which I will find the collection and that the collection element is named ``*.TheCollection`. Everything else will change. The xml will be retrieved from a database using Linq; if I could combine both queries so instead of getting the entire serialized graph and then extracting the collection objects I would just get back the collection that would be sweet. | Will, It is not possible to find out whether an object implements some interface by looking at XAML. With constraints given you can find xml element that has a child named. You can use following code: It will return all elements having child element which name ends with.TheCollection static IEnumerable FindElement(XElement root) { foreach (var element in root.Elements()) { if (element.Name.LocalName.EndsWith(".TheCollection")) { yield return element.Parent; } foreach (var subElement in FindElement(element)) { yield return subElement; } } } To make sure that object represented by this element implements some interface you need to read metadata from your assemblies. I would recommend you to use Mono.Cecil framework to analyze types in your assemblies without using reflection. | How can I extract a part of a xaml object graph via linq to xml? I have an object graph serialized to xaml. A rough sample of what it looks like is: I want to use Linq to XML in order to extract the serialized objects within the TheCollection. Note: MyObject may be named differently at runtime; I'm interested in any object that implements the same interface, which has a public collection called TheCollection that contains types of IPolymorphicLol. The only things I know at runtime are the depth at which I will find the collection and that the collection element is named ``*.TheCollection`. Everything else will change. The xml will be retrieved from a database using Linq; if I could combine both queries so instead of getting the entire serialized graph and then extracting the collection objects I would just get back the collection that would be sweet. | TITLE:
How can I extract a part of a xaml object graph via linq to xml?
QUESTION:
I have an object graph serialized to xaml. A rough sample of what it looks like is: I want to use Linq to XML in order to extract the serialized objects within the TheCollection. Note: MyObject may be named differently at runtime; I'm interested in any object that implements the same interface, which has a public collection called TheCollection that contains types of IPolymorphicLol. The only things I know at runtime are the depth at which I will find the collection and that the collection element is named ``*.TheCollection`. Everything else will change. The xml will be retrieved from a database using Linq; if I could combine both queries so instead of getting the entire serialized graph and then extracting the collection objects I would just get back the collection that would be sweet.
ANSWER:
Will, It is not possible to find out whether an object implements some interface by looking at XAML. With constraints given you can find xml element that has a child named. You can use following code: It will return all elements having child element which name ends with.TheCollection static IEnumerable FindElement(XElement root) { foreach (var element in root.Elements()) { if (element.Name.LocalName.EndsWith(".TheCollection")) { yield return element.Parent; } foreach (var subElement in FindElement(element)) { yield return subElement; } } } To make sure that object represented by this element implements some interface you need to read metadata from your assemblies. I would recommend you to use Mono.Cecil framework to analyze types in your assemblies without using reflection. | [
"linq",
"xaml",
"linq-to-xml"
] | 1 | 0 | 353 | 2 | 0 | 2008-09-05T13:01:34.133000 | 2008-09-05T13:47:36.037000 |
45,736 | 45,759 | apache mod_proxy error os10060 and returning 503? | Can't get to my site. Apache gives the following error message: [Fri Sep 05 08:47:42 2008] [error] (OS 10060)A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.: proxy: HTTP: attempt to connect to 10.10.10.1:80 (10.10.10.1) failed | Can you connect to the proxied host (10.10.10.1) directly? Is it functioning normally? | apache mod_proxy error os10060 and returning 503? Can't get to my site. Apache gives the following error message: [Fri Sep 05 08:47:42 2008] [error] (OS 10060)A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.: proxy: HTTP: attempt to connect to 10.10.10.1:80 (10.10.10.1) failed | TITLE:
apache mod_proxy error os10060 and returning 503?
QUESTION:
Can't get to my site. Apache gives the following error message: [Fri Sep 05 08:47:42 2008] [error] (OS 10060)A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.: proxy: HTTP: attempt to connect to 10.10.10.1:80 (10.10.10.1) failed
ANSWER:
Can you connect to the proxied host (10.10.10.1) directly? Is it functioning normally? | [
"apache",
"proxy"
] | 1 | 2 | 5,134 | 2 | 0 | 2008-09-05T13:03:03.180000 | 2008-09-05T13:09:34.083000 |
45,741 | 49,293 | Customize the Sharepoint add list column page | I have defined a custom Sharepoint list for special attributes related to a software application inventory and installed it as a feature. I also want to group these attributes in categories. How could I change the Sharepoint page that allows the user to add a column to a list, so that when the user adds a column to my custom list type (column = attribute) he'll have a dropdown to choose the category? | From what I understand you want to add a choice column data type thats already prepopulated so that users can then add it to their own content types? have a look here, this is probably what you want to do: http://www.sharethispoint.com/archive/2006/08/07/23.aspx | Customize the Sharepoint add list column page I have defined a custom Sharepoint list for special attributes related to a software application inventory and installed it as a feature. I also want to group these attributes in categories. How could I change the Sharepoint page that allows the user to add a column to a list, so that when the user adds a column to my custom list type (column = attribute) he'll have a dropdown to choose the category? | TITLE:
Customize the Sharepoint add list column page
QUESTION:
I have defined a custom Sharepoint list for special attributes related to a software application inventory and installed it as a feature. I also want to group these attributes in categories. How could I change the Sharepoint page that allows the user to add a column to a list, so that when the user adds a column to my custom list type (column = attribute) he'll have a dropdown to choose the category?
ANSWER:
From what I understand you want to add a choice column data type thats already prepopulated so that users can then add it to their own content types? have a look here, this is probably what you want to do: http://www.sharethispoint.com/archive/2006/08/07/23.aspx | [
"sharepoint",
"list"
] | 1 | 1 | 1,204 | 1 | 0 | 2008-09-05T13:04:44.377000 | 2008-09-08T08:07:27.547000 |
45,779 | 45,901 | C# Dynamic Event Subscription | How would you dynamically subscribe to a C# event so that given a Object instance and a String name containing the name of the event, you subscribe to that event and do something (write to the console for example) when that event has been fired? It would seem using Reflection this isn't possible and I would like to avoid having to use Reflection.Emit if possible, as this currently (to me) seems like the only way of doing it. /EDIT: I do not know the signature of the delegate needed for the event, this is the core of the problem /EDIT 2: Although delegate contravariance seems like a good plan, I can not make the assumption necessary to use this solution | You can compile expression trees to use void methods without any arguments as event handlers for events of any type. To accommodate other event handler types, you have to map the event handler's parameters to the events somehow. using System; using System.Linq; using System.Linq.Expressions; using System.Reflection;
class ExampleEventArgs: EventArgs { public int IntArg {get; set;} }
class EventRaiser { public event EventHandler SomethingHappened; public event EventHandler SomethingHappenedWithArg;
public void RaiseEvents() { if (SomethingHappened!=null) SomethingHappened(this, EventArgs.Empty);
if (SomethingHappenedWithArg!=null) { SomethingHappenedWithArg(this, new ExampleEventArgs{IntArg = 5}); } } }
class Handler { public void HandleEvent() { Console.WriteLine("Handler.HandleEvent() called.");} public void HandleEventWithArg(int arg) { Console.WriteLine("Arg: {0}",arg); } }
static class EventProxy { //void delegates with no parameters static public Delegate Create(EventInfo evt, Action d) { var handlerType = evt.EventHandlerType; var eventParams = handlerType.GetMethod("Invoke").GetParameters();
//lambda: (object x0, EventArgs x1) => d() var parameters = eventParams.Select(p=>Expression.Parameter(p.ParameterType,"x")); var body = Expression.Call(Expression.Constant(d),d.GetType().GetMethod("Invoke")); var lambda = Expression.Lambda(body,parameters.ToArray()); return Delegate.CreateDelegate(handlerType, lambda.Compile(), "Invoke", false); }
//void delegate with one parameter static public Delegate Create (EventInfo evt, Action d) { var handlerType = evt.EventHandlerType; var eventParams = handlerType.GetMethod("Invoke").GetParameters();
//lambda: (object x0, ExampleEventArgs x1) => d(x1.IntArg) var parameters = eventParams.Select(p=>Expression.Parameter(p.ParameterType,"x")).ToArray(); var arg = getArgExpression(parameters[1], typeof(T)); var body = Expression.Call(Expression.Constant(d),d.GetType().GetMethod("Invoke"), arg); var lambda = Expression.Lambda(body,parameters); return Delegate.CreateDelegate(handlerType, lambda.Compile(), "Invoke", false); }
//returns an expression that represents an argument to be passed to the delegate static Expression getArgExpression(ParameterExpression eventArgs, Type handlerArgType) { if (eventArgs.Type==typeof(ExampleEventArgs) && handlerArgType==typeof(int)) { //"x1.IntArg" var memberInfo = eventArgs.Type.GetMember("IntArg")[0]; return Expression.MakeMemberAccess(eventArgs,memberInfo); }
throw new NotSupportedException(eventArgs+"->"+handlerArgType); } }
static class Test { public static void Main() { var raiser = new EventRaiser(); var handler = new Handler();
//void delegate with no parameters string eventName = "SomethingHappened"; var eventinfo = raiser.GetType().GetEvent(eventName); eventinfo.AddEventHandler(raiser,EventProxy.Create(eventinfo,handler.HandleEvent));
//void delegate with one parameter string eventName2 = "SomethingHappenedWithArg"; var eventInfo2 = raiser.GetType().GetEvent(eventName2); eventInfo2.AddEventHandler(raiser,EventProxy.Create (eventInfo2,handler.HandleEventWithArg));
//or even just: eventinfo.AddEventHandler(raiser,EventProxy.Create(eventinfo,()=>Console.WriteLine("!"))); eventInfo2.AddEventHandler(raiser,EventProxy.Create (eventInfo2,i=>Console.WriteLine(i+"!")));
raiser.RaiseEvents(); } } | C# Dynamic Event Subscription How would you dynamically subscribe to a C# event so that given a Object instance and a String name containing the name of the event, you subscribe to that event and do something (write to the console for example) when that event has been fired? It would seem using Reflection this isn't possible and I would like to avoid having to use Reflection.Emit if possible, as this currently (to me) seems like the only way of doing it. /EDIT: I do not know the signature of the delegate needed for the event, this is the core of the problem /EDIT 2: Although delegate contravariance seems like a good plan, I can not make the assumption necessary to use this solution | TITLE:
C# Dynamic Event Subscription
QUESTION:
How would you dynamically subscribe to a C# event so that given a Object instance and a String name containing the name of the event, you subscribe to that event and do something (write to the console for example) when that event has been fired? It would seem using Reflection this isn't possible and I would like to avoid having to use Reflection.Emit if possible, as this currently (to me) seems like the only way of doing it. /EDIT: I do not know the signature of the delegate needed for the event, this is the core of the problem /EDIT 2: Although delegate contravariance seems like a good plan, I can not make the assumption necessary to use this solution
ANSWER:
You can compile expression trees to use void methods without any arguments as event handlers for events of any type. To accommodate other event handler types, you have to map the event handler's parameters to the events somehow. using System; using System.Linq; using System.Linq.Expressions; using System.Reflection;
class ExampleEventArgs: EventArgs { public int IntArg {get; set;} }
class EventRaiser { public event EventHandler SomethingHappened; public event EventHandler SomethingHappenedWithArg;
public void RaiseEvents() { if (SomethingHappened!=null) SomethingHappened(this, EventArgs.Empty);
if (SomethingHappenedWithArg!=null) { SomethingHappenedWithArg(this, new ExampleEventArgs{IntArg = 5}); } } }
class Handler { public void HandleEvent() { Console.WriteLine("Handler.HandleEvent() called.");} public void HandleEventWithArg(int arg) { Console.WriteLine("Arg: {0}",arg); } }
static class EventProxy { //void delegates with no parameters static public Delegate Create(EventInfo evt, Action d) { var handlerType = evt.EventHandlerType; var eventParams = handlerType.GetMethod("Invoke").GetParameters();
//lambda: (object x0, EventArgs x1) => d() var parameters = eventParams.Select(p=>Expression.Parameter(p.ParameterType,"x")); var body = Expression.Call(Expression.Constant(d),d.GetType().GetMethod("Invoke")); var lambda = Expression.Lambda(body,parameters.ToArray()); return Delegate.CreateDelegate(handlerType, lambda.Compile(), "Invoke", false); }
//void delegate with one parameter static public Delegate Create (EventInfo evt, Action d) { var handlerType = evt.EventHandlerType; var eventParams = handlerType.GetMethod("Invoke").GetParameters();
//lambda: (object x0, ExampleEventArgs x1) => d(x1.IntArg) var parameters = eventParams.Select(p=>Expression.Parameter(p.ParameterType,"x")).ToArray(); var arg = getArgExpression(parameters[1], typeof(T)); var body = Expression.Call(Expression.Constant(d),d.GetType().GetMethod("Invoke"), arg); var lambda = Expression.Lambda(body,parameters); return Delegate.CreateDelegate(handlerType, lambda.Compile(), "Invoke", false); }
//returns an expression that represents an argument to be passed to the delegate static Expression getArgExpression(ParameterExpression eventArgs, Type handlerArgType) { if (eventArgs.Type==typeof(ExampleEventArgs) && handlerArgType==typeof(int)) { //"x1.IntArg" var memberInfo = eventArgs.Type.GetMember("IntArg")[0]; return Expression.MakeMemberAccess(eventArgs,memberInfo); }
throw new NotSupportedException(eventArgs+"->"+handlerArgType); } }
static class Test { public static void Main() { var raiser = new EventRaiser(); var handler = new Handler();
//void delegate with no parameters string eventName = "SomethingHappened"; var eventinfo = raiser.GetType().GetEvent(eventName); eventinfo.AddEventHandler(raiser,EventProxy.Create(eventinfo,handler.HandleEvent));
//void delegate with one parameter string eventName2 = "SomethingHappenedWithArg"; var eventInfo2 = raiser.GetType().GetEvent(eventName2); eventInfo2.AddEventHandler(raiser,EventProxy.Create (eventInfo2,handler.HandleEventWithArg));
//or even just: eventinfo.AddEventHandler(raiser,EventProxy.Create(eventinfo,()=>Console.WriteLine("!"))); eventInfo2.AddEventHandler(raiser,EventProxy.Create (eventInfo2,i=>Console.WriteLine(i+"!")));
raiser.RaiseEvents(); } } | [
"c#",
"events",
"reflection",
"delegates"
] | 34 | 29 | 35,805 | 10 | 0 | 2008-09-05T13:17:38.637000 | 2008-09-05T14:14:37.080000 |
45,783 | 56,109 | Automate Deployment for Web Applications? | My team is currently trying to automate the deployment of our.Net and PHP web applications. We want to streamline deployments, and to avoid the hassle and many of the headaches caused by doing it manually. We require a solution that will enable us to: - Compile the application - Version the application with the SVN version number - Backup the existing site - Deploy to a web farm All our apps are source controlled using SVN and our.Net apps use CruiseControl. We have been trying to use MSBuild and NAnt deployment scripts with limited success. We have also used Capistrano in the past, but wish to avoid using Ruby if possible. Are there any other deployment tools out there that would help us? | Thank you all for your kind suggestions. We checked them all out, but after careful consideration we decided to roll our own with a combination of CruiseControl, NAnt, MSBuild and MSDeploy. This article has some great information: Integrating MSBuild with CruiseControl.NET Here's roughly how our solution works: Developers build the 'debug' version of the app and run unit tests, then check in to SVN. CruiseControl sees the updates and calls our build script... Runs any new migrations on the build database Replaces the config files with the build server config Builds the 'debug' configuration of the app Runs all unit and integration tests Builds the 'deploy' configuration of the app Versions the DLLs with the current major/minor version and SVN revision, e.g. 1.2.0.423 Moves this new build to a 'release' folder on our build server Removes unneeded files Updates IIS on the build server if required Then when we have verified everything is ready to go up to live/staging we run another script to: Run migrations on live/staging server MSDeploy: archive current live/staging site MSDeploy: sync site from build to live/staging It wasn't pretty getting to this stage, but it's mostly working like a charm now:D I'm going to try and keep this answer updated as we make changes to our process, as there seem to be several similar questions on SA now. | Automate Deployment for Web Applications? My team is currently trying to automate the deployment of our.Net and PHP web applications. We want to streamline deployments, and to avoid the hassle and many of the headaches caused by doing it manually. We require a solution that will enable us to: - Compile the application - Version the application with the SVN version number - Backup the existing site - Deploy to a web farm All our apps are source controlled using SVN and our.Net apps use CruiseControl. We have been trying to use MSBuild and NAnt deployment scripts with limited success. We have also used Capistrano in the past, but wish to avoid using Ruby if possible. Are there any other deployment tools out there that would help us? | TITLE:
Automate Deployment for Web Applications?
QUESTION:
My team is currently trying to automate the deployment of our.Net and PHP web applications. We want to streamline deployments, and to avoid the hassle and many of the headaches caused by doing it manually. We require a solution that will enable us to: - Compile the application - Version the application with the SVN version number - Backup the existing site - Deploy to a web farm All our apps are source controlled using SVN and our.Net apps use CruiseControl. We have been trying to use MSBuild and NAnt deployment scripts with limited success. We have also used Capistrano in the past, but wish to avoid using Ruby if possible. Are there any other deployment tools out there that would help us?
ANSWER:
Thank you all for your kind suggestions. We checked them all out, but after careful consideration we decided to roll our own with a combination of CruiseControl, NAnt, MSBuild and MSDeploy. This article has some great information: Integrating MSBuild with CruiseControl.NET Here's roughly how our solution works: Developers build the 'debug' version of the app and run unit tests, then check in to SVN. CruiseControl sees the updates and calls our build script... Runs any new migrations on the build database Replaces the config files with the build server config Builds the 'debug' configuration of the app Runs all unit and integration tests Builds the 'deploy' configuration of the app Versions the DLLs with the current major/minor version and SVN revision, e.g. 1.2.0.423 Moves this new build to a 'release' folder on our build server Removes unneeded files Updates IIS on the build server if required Then when we have verified everything is ready to go up to live/staging we run another script to: Run migrations on live/staging server MSDeploy: archive current live/staging site MSDeploy: sync site from build to live/staging It wasn't pretty getting to this stage, but it's mostly working like a charm now:D I'm going to try and keep this answer updated as we make changes to our process, as there seem to be several similar questions on SA now. | [
".net",
"php",
"deployment",
"web-applications"
] | 41 | 33 | 25,114 | 9 | 0 | 2008-09-05T13:18:23.267000 | 2008-09-11T09:17:22.203000 |
45,792 | 45,836 | How can I fork a background processes from a Perl CGI script on Windows? | I've had some trouble forking of processes from a Perl CGI script when running on Windows. The main issue seems to be that 'fork' is emulated when running on windows, and doesn't actually seem to create a new process (just another thread in the current one). This means that web servers (like IIS) which are waiting for the process to finish continue waiting until the 'background' process finishes. Is there a way of forking off a background process from a CGI script under Windows? Even better, is there a single function I can call which will do this in a cross platform way? (And just to make life extra difficult, I'd really like a good way to redirect the forked processes output to a file at the same time). | If you want to do this in a platform independent way, Proc::Background is probably the best way. | How can I fork a background processes from a Perl CGI script on Windows? I've had some trouble forking of processes from a Perl CGI script when running on Windows. The main issue seems to be that 'fork' is emulated when running on windows, and doesn't actually seem to create a new process (just another thread in the current one). This means that web servers (like IIS) which are waiting for the process to finish continue waiting until the 'background' process finishes. Is there a way of forking off a background process from a CGI script under Windows? Even better, is there a single function I can call which will do this in a cross platform way? (And just to make life extra difficult, I'd really like a good way to redirect the forked processes output to a file at the same time). | TITLE:
How can I fork a background processes from a Perl CGI script on Windows?
QUESTION:
I've had some trouble forking of processes from a Perl CGI script when running on Windows. The main issue seems to be that 'fork' is emulated when running on windows, and doesn't actually seem to create a new process (just another thread in the current one). This means that web servers (like IIS) which are waiting for the process to finish continue waiting until the 'background' process finishes. Is there a way of forking off a background process from a CGI script under Windows? Even better, is there a single function I can call which will do this in a cross platform way? (And just to make life extra difficult, I'd really like a good way to redirect the forked processes output to a file at the same time).
ANSWER:
If you want to do this in a platform independent way, Proc::Background is probably the best way. | [
"windows",
"perl",
"cgi",
"background",
"fork"
] | 8 | 9 | 5,506 | 5 | 0 | 2008-09-05T13:21:09.423000 | 2008-09-05T13:36:59.197000 |
45,796 | 45,926 | Using IIS6, how can I place files in a sub-folder but have them served as if they were in the root? | Our ASP.NET 3.5 website running on IIS 6 has two teams that are adding content: Development team adding code. Business team adding simple web pages. For sanity and organization, we would like for the business team to add their web pages to a sub-folder in the project: Root: for pages of development team Content: for pages of business team But We would like for users to be able to navigate to the business team content without having to append "Content" in their URLs, as described below: Root: Default.aspx ( Available at: www.oursite.com/default.aspx ) Content: Popcorn.aspx ( Available at: www.oursite.com/popcorn.aspx ) Is there a way we can accomplish for making a config entry in an ISAPI rewrite tool for every one of these pages? | I don't have any way to test this right now, but I think you can use the -f flag on RewriteCond to check if a file exists, in either directory. RewriteCond %{REQUEST_FILENAME} -!f RewriteCond Content/%{REQUEST_FILENAME} -f RewriteRule (.*) Content/(.*) Something like that might do what you're after, too. | Using IIS6, how can I place files in a sub-folder but have them served as if they were in the root? Our ASP.NET 3.5 website running on IIS 6 has two teams that are adding content: Development team adding code. Business team adding simple web pages. For sanity and organization, we would like for the business team to add their web pages to a sub-folder in the project: Root: for pages of development team Content: for pages of business team But We would like for users to be able to navigate to the business team content without having to append "Content" in their URLs, as described below: Root: Default.aspx ( Available at: www.oursite.com/default.aspx ) Content: Popcorn.aspx ( Available at: www.oursite.com/popcorn.aspx ) Is there a way we can accomplish for making a config entry in an ISAPI rewrite tool for every one of these pages? | TITLE:
Using IIS6, how can I place files in a sub-folder but have them served as if they were in the root?
QUESTION:
Our ASP.NET 3.5 website running on IIS 6 has two teams that are adding content: Development team adding code. Business team adding simple web pages. For sanity and organization, we would like for the business team to add their web pages to a sub-folder in the project: Root: for pages of development team Content: for pages of business team But We would like for users to be able to navigate to the business team content without having to append "Content" in their URLs, as described below: Root: Default.aspx ( Available at: www.oursite.com/default.aspx ) Content: Popcorn.aspx ( Available at: www.oursite.com/popcorn.aspx ) Is there a way we can accomplish for making a config entry in an ISAPI rewrite tool for every one of these pages?
ANSWER:
I don't have any way to test this right now, but I think you can use the -f flag on RewriteCond to check if a file exists, in either directory. RewriteCond %{REQUEST_FILENAME} -!f RewriteCond Content/%{REQUEST_FILENAME} -f RewriteRule (.*) Content/(.*) Something like that might do what you're after, too. | [
"asp.net",
"iis-6",
"url-rewriting"
] | 2 | 1 | 393 | 2 | 0 | 2008-09-05T13:23:01.027000 | 2008-09-05T14:32:21.903000 |
45,803 | 45,823 | Service to make an audio podcast from a video one? | Video podcast??? Audio only mp3 player I'm looking for somewhere which will extract audio from video, but instead of a single file, for an on going video podcast. I would most like a website which would suck in the RSS and spit out an RSS (I'm thinking of something like Feedburner), though would settle for something on my own machine. If it must be on my machine, it should be quick, transparent, and automatic when I download each episode. What would you use? Edit: I'm on an Ubuntu 8.04 machine; so running ffmpeg is no problem; however, I'm looking for automation and feed awareness. Here's my use case: I want to listen to lectures at Google Video, or Structure and Interpretation of Computer Programs. These videos come out fairly often, so anything that's needed to be done manually will also be done fairly often. Here's one approach I'd thought of: download the RSS parse the RSS for enclosures, download the enclosures, keeping a track what has already been downloaded previously transcode the files, but not the ones done already reconstruct an RSS with the audio files, remembering to change the metadata. schedule to be run periodically point podcatcher at new RSS feed. I also liked the approach of gPodder of using a post-download script. I wish the Lazy Web still worked. | You could automate this using the open source command line tool ffmpeg. Parse the RSS to get the video files, fetch them over the net if needed, then spit each one out to a command line like this: ffmpeg -i episode1.mov -ab 128000 episode1.mp3 The -ab switch sets the output bit rate to 128 kbits/s on the audio file, adjust as needed. Once you have the audio files you can reconstruct the RSS feed to link to the audio files if so desired. | Service to make an audio podcast from a video one? Video podcast??? Audio only mp3 player I'm looking for somewhere which will extract audio from video, but instead of a single file, for an on going video podcast. I would most like a website which would suck in the RSS and spit out an RSS (I'm thinking of something like Feedburner), though would settle for something on my own machine. If it must be on my machine, it should be quick, transparent, and automatic when I download each episode. What would you use? Edit: I'm on an Ubuntu 8.04 machine; so running ffmpeg is no problem; however, I'm looking for automation and feed awareness. Here's my use case: I want to listen to lectures at Google Video, or Structure and Interpretation of Computer Programs. These videos come out fairly often, so anything that's needed to be done manually will also be done fairly often. Here's one approach I'd thought of: download the RSS parse the RSS for enclosures, download the enclosures, keeping a track what has already been downloaded previously transcode the files, but not the ones done already reconstruct an RSS with the audio files, remembering to change the metadata. schedule to be run periodically point podcatcher at new RSS feed. I also liked the approach of gPodder of using a post-download script. I wish the Lazy Web still worked. | TITLE:
Service to make an audio podcast from a video one?
QUESTION:
Video podcast??? Audio only mp3 player I'm looking for somewhere which will extract audio from video, but instead of a single file, for an on going video podcast. I would most like a website which would suck in the RSS and spit out an RSS (I'm thinking of something like Feedburner), though would settle for something on my own machine. If it must be on my machine, it should be quick, transparent, and automatic when I download each episode. What would you use? Edit: I'm on an Ubuntu 8.04 machine; so running ffmpeg is no problem; however, I'm looking for automation and feed awareness. Here's my use case: I want to listen to lectures at Google Video, or Structure and Interpretation of Computer Programs. These videos come out fairly often, so anything that's needed to be done manually will also be done fairly often. Here's one approach I'd thought of: download the RSS parse the RSS for enclosures, download the enclosures, keeping a track what has already been downloaded previously transcode the files, but not the ones done already reconstruct an RSS with the audio files, remembering to change the metadata. schedule to be run periodically point podcatcher at new RSS feed. I also liked the approach of gPodder of using a post-download script. I wish the Lazy Web still worked.
ANSWER:
You could automate this using the open source command line tool ffmpeg. Parse the RSS to get the video files, fetch them over the net if needed, then spit each one out to a command line like this: ffmpeg -i episode1.mov -ab 128000 episode1.mp3 The -ab switch sets the output bit rate to 128 kbits/s on the audio file, adjust as needed. Once you have the audio files you can reconstruct the RSS feed to link to the audio files if so desired. | [
"audio",
"video",
"podcast"
] | 4 | 5 | 733 | 4 | 0 | 2008-09-05T13:24:01.367000 | 2008-09-05T13:31:01.287000 |
45,813 | 182,363 | WPF Get Element(s) under mouse | Is there a way with WPF to get an array of elements under the mouse on a MouseMove event? | From " WPF Unleashed ", page 383: Visual hit testing can inform you about all Visual s that intersect a location, [...] you must use [...] the [VisualTreeHelper.]HitTest method that accepts a HitTestResultCallback delegate. Before this version of HitTest returns, the delegate is invoked once for each relevant Visual, starting from the topmost and ending at the bottommost. The signature of such a callback is HitTestResultBehavior Callback(HitTestResult result) and it has to return HitTestResultBehaviour.Continue to receive further hits, as shown below (from the linked page on MSDN): // Return the result of the hit test to the callback. public HitTestResultBehavior MyHitTestResult(HitTestResult result) { // Add the hit test result to the list that will be processed after the enumeration. hitResultsList.Add(result.VisualHit);
// Set the behavior to return visuals at all z-order levels. return HitTestResultBehavior.Continue; } For further information, please consult the MSDN documentation for VisualTreeHelper.HitTest. | WPF Get Element(s) under mouse Is there a way with WPF to get an array of elements under the mouse on a MouseMove event? | TITLE:
WPF Get Element(s) under mouse
QUESTION:
Is there a way with WPF to get an array of elements under the mouse on a MouseMove event?
ANSWER:
From " WPF Unleashed ", page 383: Visual hit testing can inform you about all Visual s that intersect a location, [...] you must use [...] the [VisualTreeHelper.]HitTest method that accepts a HitTestResultCallback delegate. Before this version of HitTest returns, the delegate is invoked once for each relevant Visual, starting from the topmost and ending at the bottommost. The signature of such a callback is HitTestResultBehavior Callback(HitTestResult result) and it has to return HitTestResultBehaviour.Continue to receive further hits, as shown below (from the linked page on MSDN): // Return the result of the hit test to the callback. public HitTestResultBehavior MyHitTestResult(HitTestResult result) { // Add the hit test result to the list that will be processed after the enumeration. hitResultsList.Add(result.VisualHit);
// Set the behavior to return visuals at all z-order levels. return HitTestResultBehavior.Continue; } For further information, please consult the MSDN documentation for VisualTreeHelper.HitTest. | [
"wpf",
"element",
"visualtreehelper",
"visual-tree"
] | 37 | 41 | 47,278 | 3 | 0 | 2008-09-05T13:28:16.347000 | 2008-10-08T11:59:34.923000 |
45,824 | 45,835 | Counting number of views for a page ignoring search engines? | I notice that StackOverflow has a views count for each question and that these view numbers are fairly low and accurate. I have a similar thing on one of my sites. It basically logs a "hit" whenever the page is loaded in the backend code. Unfortunately it also does this for search engine hits giving bloated and inaccurate numbers. I guess one way to not count a robot would be to do the view counting with an AJAX call once the page has loaded, but I'm sure there's other, better ways to ignore search engines in your hit counters whilst still letting them in to crawl your site. Do you know any? | An AJAX call will do it, but usually search engines will not load images, javascript or CSS files, so it may be easier to include one of those files in the page, and pass the URL of the page you want to log a request against as a parameter in the file request. For example, in the page... http://www.example.com/example.html You might include in the head section And have your server side log the request, then return an empty css file. The same approach would apply to JavaScript or and image file, though in all cases you'll want to look carefully at what caching might take place. Another option would be to eliminate the search engines based on their user agent. There's a big list of possible user agents at http://user-agents.org/ to get you started. Of course, you could go the other way, and only count requests from things you know are web browsers (covering IE, Firefox, Safari, Opera and this newfangled Chrome thing would get you 99% of the way there). Even easier would be to use a log analytics tool like awstats or a service like Google analytics, both of which have already solved this problem. | Counting number of views for a page ignoring search engines? I notice that StackOverflow has a views count for each question and that these view numbers are fairly low and accurate. I have a similar thing on one of my sites. It basically logs a "hit" whenever the page is loaded in the backend code. Unfortunately it also does this for search engine hits giving bloated and inaccurate numbers. I guess one way to not count a robot would be to do the view counting with an AJAX call once the page has loaded, but I'm sure there's other, better ways to ignore search engines in your hit counters whilst still letting them in to crawl your site. Do you know any? | TITLE:
Counting number of views for a page ignoring search engines?
QUESTION:
I notice that StackOverflow has a views count for each question and that these view numbers are fairly low and accurate. I have a similar thing on one of my sites. It basically logs a "hit" whenever the page is loaded in the backend code. Unfortunately it also does this for search engine hits giving bloated and inaccurate numbers. I guess one way to not count a robot would be to do the view counting with an AJAX call once the page has loaded, but I'm sure there's other, better ways to ignore search engines in your hit counters whilst still letting them in to crawl your site. Do you know any?
ANSWER:
An AJAX call will do it, but usually search engines will not load images, javascript or CSS files, so it may be easier to include one of those files in the page, and pass the URL of the page you want to log a request against as a parameter in the file request. For example, in the page... http://www.example.com/example.html You might include in the head section And have your server side log the request, then return an empty css file. The same approach would apply to JavaScript or and image file, though in all cases you'll want to look carefully at what caching might take place. Another option would be to eliminate the search engines based on their user agent. There's a big list of possible user agents at http://user-agents.org/ to get you started. Of course, you could go the other way, and only count requests from things you know are web browsers (covering IE, Firefox, Safari, Opera and this newfangled Chrome thing would get you 99% of the way there). Even easier would be to use a log analytics tool like awstats or a service like Google analytics, both of which have already solved this problem. | [
"search-engine",
"website-metrics"
] | 10 | 5 | 1,704 | 6 | 0 | 2008-09-05T13:31:57.010000 | 2008-09-05T13:36:08.980000 |
45,827 | 45,863 | How do you automatically set the focus to a textbox when a web page loads? | How do you automatically set the focus to a textbox when a web page loads? Is there an HTML tag to do it or does it have to be done via Javascript? | If you're using jquery: $(function() { $("#Box1").focus(); }); or prototype: Event.observe(window, 'load', function() { $("Box1").focus(); }); or plain javascript: window.onload = function() { document.getElementById("Box1").focus(); }; though keep in mind that this will replace other on load handlers, so look up addLoadEvent() in google for a safe way to append onload handlers rather than replacing. | How do you automatically set the focus to a textbox when a web page loads? How do you automatically set the focus to a textbox when a web page loads? Is there an HTML tag to do it or does it have to be done via Javascript? | TITLE:
How do you automatically set the focus to a textbox when a web page loads?
QUESTION:
How do you automatically set the focus to a textbox when a web page loads? Is there an HTML tag to do it or does it have to be done via Javascript?
ANSWER:
If you're using jquery: $(function() { $("#Box1").focus(); }); or prototype: Event.observe(window, 'load', function() { $("Box1").focus(); }); or plain javascript: window.onload = function() { document.getElementById("Box1").focus(); }; though keep in mind that this will replace other on load handlers, so look up addLoadEvent() in google for a safe way to append onload handlers rather than replacing. | [
"javascript",
"html"
] | 175 | 263 | 388,833 | 14 | 0 | 2008-09-05T13:33:44.260000 | 2008-09-05T13:46:38.410000 |
45,838 | 45,853 | How many app.config files are you allowed to have per AppDomain? | I'm hoping there's a way to avoid custom configuration files if an application runs in a single AppDomain. | From Suzanne Cook's.NET CLR Notes: App.Config Files: As default the app config file of the default appdomain is in the process exe’s directory and named the same as the process exe + ".config". Also, note that a web.config file is an app.config - ASP.NET sets that as the config file for your appdomain. To change the config file, set an AppDomainSetup.ConfigurationFile to the new location and pass that AppDomainSetup to your call to AppDomain.CreateDomain(). Then, run all of the code requiring that application config from within that new appdomain. Note, though, that you won’t be able to choose the CLR version by setting the ConfigurationFile – at that point, a CLR will already be running, and there can only be one per process. Application configuration files are per appdomain. So, you can set a ‘dll config’ by using the method above, but that means that it will be used for the entire appdomain, and it only gets one. | How many app.config files are you allowed to have per AppDomain? I'm hoping there's a way to avoid custom configuration files if an application runs in a single AppDomain. | TITLE:
How many app.config files are you allowed to have per AppDomain?
QUESTION:
I'm hoping there's a way to avoid custom configuration files if an application runs in a single AppDomain.
ANSWER:
From Suzanne Cook's.NET CLR Notes: App.Config Files: As default the app config file of the default appdomain is in the process exe’s directory and named the same as the process exe + ".config". Also, note that a web.config file is an app.config - ASP.NET sets that as the config file for your appdomain. To change the config file, set an AppDomainSetup.ConfigurationFile to the new location and pass that AppDomainSetup to your call to AppDomain.CreateDomain(). Then, run all of the code requiring that application config from within that new appdomain. Note, though, that you won’t be able to choose the CLR version by setting the ConfigurationFile – at that point, a CLR will already be running, and there can only be one per process. Application configuration files are per appdomain. So, you can set a ‘dll config’ by using the method above, but that means that it will be used for the entire appdomain, and it only gets one. | [
".net",
"configuration"
] | 2 | 5 | 1,698 | 1 | 0 | 2008-09-05T13:37:33.517000 | 2008-09-05T13:43:12.397000 |
45,846 | 45,858 | Web Design for Google Chrome | What, if any, considerations (HTML, CSS, JavaScript) should you take when designing for Google Chrome? | Chrome uses Webkit, the same engine as is used by Safari, OmniWeb, iCab and more. Just code everything based on the standards and verify in each browser. | Web Design for Google Chrome What, if any, considerations (HTML, CSS, JavaScript) should you take when designing for Google Chrome? | TITLE:
Web Design for Google Chrome
QUESTION:
What, if any, considerations (HTML, CSS, JavaScript) should you take when designing for Google Chrome?
ANSWER:
Chrome uses Webkit, the same engine as is used by Safari, OmniWeb, iCab and more. Just code everything based on the standards and verify in each browser. | [
"google-chrome"
] | 1 | 9 | 1,025 | 5 | 0 | 2008-09-05T13:39:46.897000 | 2008-09-05T13:44:07.947000 |
45,861 | 46,174 | How do I get js2-mode to use spaces instead of tabs in Emacs? | I am using js2-mode to edit Javascript in Emacs, but I can't seem to get it to stop using tabs instead of spaces for indentation. My other modes work fine, just having issues w/ js2. | Do you have (setq-default indent-tabs-mode nil) in your.emacs? It works fine for me in emacs 23.0.60.1 when I do that. js2-mode uses the standard emacs function indent-to, which respects indent-tabs-mode, to do its indenting. | How do I get js2-mode to use spaces instead of tabs in Emacs? I am using js2-mode to edit Javascript in Emacs, but I can't seem to get it to stop using tabs instead of spaces for indentation. My other modes work fine, just having issues w/ js2. | TITLE:
How do I get js2-mode to use spaces instead of tabs in Emacs?
QUESTION:
I am using js2-mode to edit Javascript in Emacs, but I can't seem to get it to stop using tabs instead of spaces for indentation. My other modes work fine, just having issues w/ js2.
ANSWER:
Do you have (setq-default indent-tabs-mode nil) in your.emacs? It works fine for me in emacs 23.0.60.1 when I do that. js2-mode uses the standard emacs function indent-to, which respects indent-tabs-mode, to do its indenting. | [
"javascript",
"emacs",
"ide",
"js2-mode"
] | 23 | 25 | 6,370 | 3 | 0 | 2008-09-05T13:45:21.753000 | 2008-09-05T16:14:19.537000 |
45,865 | 45,870 | Can you disable the back button in a JFace wizard? | I'm writing a wizard for an Eclipse RCP application. After doing some processing on a file and taking some user input, I don't want to let the user go back to make changes. At this point they must either accept or reject the changes they are about to make to the system. What I can't seem to find is a method call that lets me override the buttons that display or the user's ability to hit the back button. I'd prefer that it not be there or at least be disabled. Has anyone found a way to do this using the JFace Wizard and WizardPage? Usability-wise, am I breaking wizard conventions? Should I consider a different approach to the problem? | You can return null from the getPreviousPage() method in your wizard page implementation. | Can you disable the back button in a JFace wizard? I'm writing a wizard for an Eclipse RCP application. After doing some processing on a file and taking some user input, I don't want to let the user go back to make changes. At this point they must either accept or reject the changes they are about to make to the system. What I can't seem to find is a method call that lets me override the buttons that display or the user's ability to hit the back button. I'd prefer that it not be there or at least be disabled. Has anyone found a way to do this using the JFace Wizard and WizardPage? Usability-wise, am I breaking wizard conventions? Should I consider a different approach to the problem? | TITLE:
Can you disable the back button in a JFace wizard?
QUESTION:
I'm writing a wizard for an Eclipse RCP application. After doing some processing on a file and taking some user input, I don't want to let the user go back to make changes. At this point they must either accept or reject the changes they are about to make to the system. What I can't seem to find is a method call that lets me override the buttons that display or the user's ability to hit the back button. I'd prefer that it not be there or at least be disabled. Has anyone found a way to do this using the JFace Wizard and WizardPage? Usability-wise, am I breaking wizard conventions? Should I consider a different approach to the problem?
ANSWER:
You can return null from the getPreviousPage() method in your wizard page implementation. | [
"java",
"eclipse",
"rcp",
"jface",
"wizard"
] | 7 | 12 | 4,546 | 4 | 0 | 2008-09-05T13:48:32.197000 | 2008-09-05T13:51:12.907000 |
45,879 | 45,987 | MySQL Partitioning / Sharding / Splitting - which way to go? | We have an InnoDB database that is about 70 GB and we expect it to grow to several hundred GB in the next 2 to 3 years. About 60 % of the data belong to a single table. Currently the database is working quite well as we have a server with 64 GB of RAM, so almost the whole database fits into memory, but we’re concerned about the future when the amount of data will be considerably larger. Right now we’re considering some way of splitting up the tables (especially the one that accounts for the biggest part of the data) and I’m now wondering, what would be the best way to do it. The options I’m currently aware of are Using MySQL Partitioning that comes with version 5.1 Using some kind of third party library that encapsulates the partitioning of the data (like hibernate shards) Implementing it ourselves inside our application Our application is built on J2EE and EJB 2.1 (hopefully we’re switching to EJB 3 some day). What would you suggest? EDIT (2011-02-11): Just an update: Currently the size of the database is 380 GB, the data size of our "big" table is 220 GB and the size of its index is 36 GB. So while the whole table does not fit in memory any more, the index does. The system is still performing fine (still on the same hardware) and we're still thinking about partitioning the data. EDIT (2014-06-04): One more update: The size of the whole database is 1.5 TB, the size of our "big" table is 1.1 TB. We upgraded our server to a 4 processor machine (Intel Xeon E7450) with 128 GB RAM. The system is still performing fine. What we're planning to do next is putting our big table on a separate database server (we've already done the necessary changes in our software) while simultaneously upgrading to new hardware with 256 GB RAM. This setup is supposed to last for two years. Then we will either have to finally start implementing a sharding solution or just buy servers with 1 TB of RAM which should keep us going for some time. EDIT (2016-01-18): We have since put our big table in it's own database on a separate server. Currently the size ot this database is about 1.9 TB, the size of the other database (with all tables except for the "big" one) is 1.1 TB. Current Hardware setup: HP ProLiant DL 580 4 x Intel(R) Xeon(R) CPU E7- 4830 256 GB RAM Performance is fine with this setup. | If you think you're going to be IO/memory bound, I don't think partitioning is going to be helpful. As usual, benchmarking first will help you figure out the best direction. If you don't have spare servers with 64GB of memory kicking around, you can always ask your vendor for a 'demo unit'. I would lean towards sharding if you don't expect 1 query aggregate reporting. I'm assuming you'd shard the whole database and not just your big table: it's best to keep entire entities together. Well, if your model splits nicely, anyway. | MySQL Partitioning / Sharding / Splitting - which way to go? We have an InnoDB database that is about 70 GB and we expect it to grow to several hundred GB in the next 2 to 3 years. About 60 % of the data belong to a single table. Currently the database is working quite well as we have a server with 64 GB of RAM, so almost the whole database fits into memory, but we’re concerned about the future when the amount of data will be considerably larger. Right now we’re considering some way of splitting up the tables (especially the one that accounts for the biggest part of the data) and I’m now wondering, what would be the best way to do it. The options I’m currently aware of are Using MySQL Partitioning that comes with version 5.1 Using some kind of third party library that encapsulates the partitioning of the data (like hibernate shards) Implementing it ourselves inside our application Our application is built on J2EE and EJB 2.1 (hopefully we’re switching to EJB 3 some day). What would you suggest? EDIT (2011-02-11): Just an update: Currently the size of the database is 380 GB, the data size of our "big" table is 220 GB and the size of its index is 36 GB. So while the whole table does not fit in memory any more, the index does. The system is still performing fine (still on the same hardware) and we're still thinking about partitioning the data. EDIT (2014-06-04): One more update: The size of the whole database is 1.5 TB, the size of our "big" table is 1.1 TB. We upgraded our server to a 4 processor machine (Intel Xeon E7450) with 128 GB RAM. The system is still performing fine. What we're planning to do next is putting our big table on a separate database server (we've already done the necessary changes in our software) while simultaneously upgrading to new hardware with 256 GB RAM. This setup is supposed to last for two years. Then we will either have to finally start implementing a sharding solution or just buy servers with 1 TB of RAM which should keep us going for some time. EDIT (2016-01-18): We have since put our big table in it's own database on a separate server. Currently the size ot this database is about 1.9 TB, the size of the other database (with all tables except for the "big" one) is 1.1 TB. Current Hardware setup: HP ProLiant DL 580 4 x Intel(R) Xeon(R) CPU E7- 4830 256 GB RAM Performance is fine with this setup. | TITLE:
MySQL Partitioning / Sharding / Splitting - which way to go?
QUESTION:
We have an InnoDB database that is about 70 GB and we expect it to grow to several hundred GB in the next 2 to 3 years. About 60 % of the data belong to a single table. Currently the database is working quite well as we have a server with 64 GB of RAM, so almost the whole database fits into memory, but we’re concerned about the future when the amount of data will be considerably larger. Right now we’re considering some way of splitting up the tables (especially the one that accounts for the biggest part of the data) and I’m now wondering, what would be the best way to do it. The options I’m currently aware of are Using MySQL Partitioning that comes with version 5.1 Using some kind of third party library that encapsulates the partitioning of the data (like hibernate shards) Implementing it ourselves inside our application Our application is built on J2EE and EJB 2.1 (hopefully we’re switching to EJB 3 some day). What would you suggest? EDIT (2011-02-11): Just an update: Currently the size of the database is 380 GB, the data size of our "big" table is 220 GB and the size of its index is 36 GB. So while the whole table does not fit in memory any more, the index does. The system is still performing fine (still on the same hardware) and we're still thinking about partitioning the data. EDIT (2014-06-04): One more update: The size of the whole database is 1.5 TB, the size of our "big" table is 1.1 TB. We upgraded our server to a 4 processor machine (Intel Xeon E7450) with 128 GB RAM. The system is still performing fine. What we're planning to do next is putting our big table on a separate database server (we've already done the necessary changes in our software) while simultaneously upgrading to new hardware with 256 GB RAM. This setup is supposed to last for two years. Then we will either have to finally start implementing a sharding solution or just buy servers with 1 TB of RAM which should keep us going for some time. EDIT (2016-01-18): We have since put our big table in it's own database on a separate server. Currently the size ot this database is about 1.9 TB, the size of the other database (with all tables except for the "big" one) is 1.1 TB. Current Hardware setup: HP ProLiant DL 580 4 x Intel(R) Xeon(R) CPU E7- 4830 256 GB RAM Performance is fine with this setup.
ANSWER:
If you think you're going to be IO/memory bound, I don't think partitioning is going to be helpful. As usual, benchmarking first will help you figure out the best direction. If you don't have spare servers with 64GB of memory kicking around, you can always ask your vendor for a 'demo unit'. I would lean towards sharding if you don't expect 1 query aggregate reporting. I'm assuming you'd shard the whole database and not just your big table: it's best to keep entire entities together. Well, if your model splits nicely, anyway. | [
"mysql",
"partitioning",
"database-performance",
"sharding"
] | 50 | 9 | 19,872 | 8 | 0 | 2008-09-05T13:59:07.663000 | 2008-09-05T15:00:05.877000 |
45,882 | 1,568,341 | View TFS checkin history through merges? | In TFS when you merge branch A to branch B and checkin, you get a single changeset on B (typically with a comment like "merged A->B"). This means B doesn't have any of the checkin history from A. So if someone created a new file on branch A, you can't tell who created it from branch B. And if someone updated a file on A, you can't tell who did the update from branch B. Is there any way to see this kind of detailed changeset history across branches? Some kind of power toy, or third party tool, or anything? Update: The TFS Power Toy tfpt history /followbranches tool does not "expand merges," it only "expands branches" and therefore doesn't solve this problem. | TFS 2010 will include support for this. Brian Harry talks about it in this presentation. You will now be able to see where a change originated and who made it after the change has been merged to a different branch. | View TFS checkin history through merges? In TFS when you merge branch A to branch B and checkin, you get a single changeset on B (typically with a comment like "merged A->B"). This means B doesn't have any of the checkin history from A. So if someone created a new file on branch A, you can't tell who created it from branch B. And if someone updated a file on A, you can't tell who did the update from branch B. Is there any way to see this kind of detailed changeset history across branches? Some kind of power toy, or third party tool, or anything? Update: The TFS Power Toy tfpt history /followbranches tool does not "expand merges," it only "expands branches" and therefore doesn't solve this problem. | TITLE:
View TFS checkin history through merges?
QUESTION:
In TFS when you merge branch A to branch B and checkin, you get a single changeset on B (typically with a comment like "merged A->B"). This means B doesn't have any of the checkin history from A. So if someone created a new file on branch A, you can't tell who created it from branch B. And if someone updated a file on A, you can't tell who did the update from branch B. Is there any way to see this kind of detailed changeset history across branches? Some kind of power toy, or third party tool, or anything? Update: The TFS Power Toy tfpt history /followbranches tool does not "expand merges," it only "expands branches" and therefore doesn't solve this problem.
ANSWER:
TFS 2010 will include support for this. Brian Harry talks about it in this presentation. You will now be able to see where a change originated and who made it after the change has been merged to a different branch. | [
"tfs",
"merge",
"branch"
] | 17 | 6 | 14,544 | 7 | 0 | 2008-09-05T14:00:26.053000 | 2009-10-14T19:07:37.613000 |
45,888 | 1,885,355 | What is the most efficient way to sort an Html Select's Options by value, while preserving the currently selected item? | I have jQuery but I'm not sure if it has any built-in sorting helpers. I could make a 2d array of each item's text, value, and selected properties, but I don't think that javascript's built in Array.sort() would work correctly. | Extract options into a temporary array, sort, then rebuild the list: var my_options = $("#my_select option"); var selected = $("#my_select").val();
my_options.sort(function(a,b) { if (a.text > b.text) return 1; if (a.text < b.text) return -1; return 0 })
$("#my_select").empty().append( my_options ); $("#my_select").val(selected); Mozilla's sort documentation (specifically the compareFunction) and Wikipedia's Sorting Algorithm page are relevant. If you want to make the sort case insensitive, replace text with text.toLowerCase() The sort function shown above illustrates how to sort. Sorting non-english languages accurately can be complex (see the unicode collation algorithm ). Using localeCompare in the sort function is a good solution, eg: my_options.sort(function(a,b) { return a.text.localeCompare(b.text); }); | What is the most efficient way to sort an Html Select's Options by value, while preserving the currently selected item? I have jQuery but I'm not sure if it has any built-in sorting helpers. I could make a 2d array of each item's text, value, and selected properties, but I don't think that javascript's built in Array.sort() would work correctly. | TITLE:
What is the most efficient way to sort an Html Select's Options by value, while preserving the currently selected item?
QUESTION:
I have jQuery but I'm not sure if it has any built-in sorting helpers. I could make a 2d array of each item's text, value, and selected properties, but I don't think that javascript's built in Array.sort() would work correctly.
ANSWER:
Extract options into a temporary array, sort, then rebuild the list: var my_options = $("#my_select option"); var selected = $("#my_select").val();
my_options.sort(function(a,b) { if (a.text > b.text) return 1; if (a.text < b.text) return -1; return 0 })
$("#my_select").empty().append( my_options ); $("#my_select").val(selected); Mozilla's sort documentation (specifically the compareFunction) and Wikipedia's Sorting Algorithm page are relevant. If you want to make the sort case insensitive, replace text with text.toLowerCase() The sort function shown above illustrates how to sort. Sorting non-english languages accurately can be complex (see the unicode collation algorithm ). Using localeCompare in the sort function is a good solution, eg: my_options.sort(function(a,b) { return a.text.localeCompare(b.text); }); | [
"javascript",
"jquery",
"arrays",
"sorting",
"html-select"
] | 86 | 138 | 106,970 | 12 | 0 | 2008-09-05T14:05:34.917000 | 2009-12-11T01:51:28.060000 |
45,898 | 46,212 | Opening a non-standard URL in a Cocoa app | In an application that I'm writing I have some code like this: NSWorkspace* ws = [NSWorkspace sharedWorkspace]; NSString* myurl = @"http://www.somewebsite.com/method?a=%d";
NSURL* url = [NSURL URLWithString:myurl];
[ws openURL:url]; The main difference being that myurl comes from somewhere outside my control. Note the %d in the URL which isn't entirely correct and means that URLWithString fails, returning nil. What is the "correct" way of handling this? Do I need to parse the string and properly encode the arguments? Or is there some clever method in Cocoa that does all the hard work for me? | I'm not sure if this is exactly what you're looking for, but there is a method in NSString that will sanitize a URL: stringByAddingPercentEscapesUsingEncoding: | Opening a non-standard URL in a Cocoa app In an application that I'm writing I have some code like this: NSWorkspace* ws = [NSWorkspace sharedWorkspace]; NSString* myurl = @"http://www.somewebsite.com/method?a=%d";
NSURL* url = [NSURL URLWithString:myurl];
[ws openURL:url]; The main difference being that myurl comes from somewhere outside my control. Note the %d in the URL which isn't entirely correct and means that URLWithString fails, returning nil. What is the "correct" way of handling this? Do I need to parse the string and properly encode the arguments? Or is there some clever method in Cocoa that does all the hard work for me? | TITLE:
Opening a non-standard URL in a Cocoa app
QUESTION:
In an application that I'm writing I have some code like this: NSWorkspace* ws = [NSWorkspace sharedWorkspace]; NSString* myurl = @"http://www.somewebsite.com/method?a=%d";
NSURL* url = [NSURL URLWithString:myurl];
[ws openURL:url]; The main difference being that myurl comes from somewhere outside my control. Note the %d in the URL which isn't entirely correct and means that URLWithString fails, returning nil. What is the "correct" way of handling this? Do I need to parse the string and properly encode the arguments? Or is there some clever method in Cocoa that does all the hard work for me?
ANSWER:
I'm not sure if this is exactly what you're looking for, but there is a method in NSString that will sanitize a URL: stringByAddingPercentEscapesUsingEncoding: | [
"objective-c",
"macos",
"cocoa"
] | 6 | 8 | 1,577 | 3 | 0 | 2008-09-05T14:12:18.427000 | 2008-09-05T16:21:18.100000 |
45,904 | 45,955 | How do you add an image? | Situation: I have a simple XML document that contains image information. I need to transform it into HTML. However, I can't see where the open tag is and when I use the XSL code below, it shows the following error message: "Cannot write an attribute node when no element start tag is open." XML content: Dan Testing This is a test of the body text false XSL code: 100 100 CalloutRightPhoto | Just to clarify the problem here - the error is in the following bit of code: The instruction xsl:copy-of takes a node or node-set and makes a copy of it - outputting a node or node-set. However an attribute cannot contain a node, only a textual value, so xsl:value-of would be a possible solution (as this returns the textual value of a node or nodeset). A MUCH shorter solution (and perhaps more elegant) would be the following: The use of the {} in the attribute is called an Attribute Value Template, and can contain any XPATH expression. Note, the same XPath can be used here as you have used in the xsl_copy-of as it knows to take the textual value when used in a Attribute Value Template. | How do you add an image? Situation: I have a simple XML document that contains image information. I need to transform it into HTML. However, I can't see where the open tag is and when I use the XSL code below, it shows the following error message: "Cannot write an attribute node when no element start tag is open." XML content: Dan Testing This is a test of the body text false XSL code: 100 100 CalloutRightPhoto | TITLE:
How do you add an image?
QUESTION:
Situation: I have a simple XML document that contains image information. I need to transform it into HTML. However, I can't see where the open tag is and when I use the XSL code below, it shows the following error message: "Cannot write an attribute node when no element start tag is open." XML content: Dan Testing This is a test of the body text false XSL code: 100 100 CalloutRightPhoto
ANSWER:
Just to clarify the problem here - the error is in the following bit of code: The instruction xsl:copy-of takes a node or node-set and makes a copy of it - outputting a node or node-set. However an attribute cannot contain a node, only a textual value, so xsl:value-of would be a possible solution (as this returns the textual value of a node or nodeset). A MUCH shorter solution (and perhaps more elegant) would be the following: The use of the {} in the attribute is called an Attribute Value Template, and can contain any XPATH expression. Note, the same XPath can be used here as you have used in the xsl_copy-of as it knows to take the textual value when used in a Attribute Value Template. | [
"xml",
"xslt",
"xslt-1.0"
] | 18 | 27 | 127,227 | 5 | 0 | 2008-09-05T14:17:22.737000 | 2008-09-05T14:44:27.460000 |
45,941 | 45,978 | Branch / merge management in Subversion 1.5 | I've used subversion for a while, and used the svnmerge.py script for a while in my old job to manage merges between branches. I believe Subversion 1.5 is now out, and was supposed to have some branch / merge management system integrated with it. So, can someone give me a quick overview of how to track merges in a branch with Subversion 1.5? Are there any pitfalls with using this support? Do I need to ensure all the team upgrades to 1.5 before using this support? | Usage Merge tracking is managed by the client and stored in a property ( svn:mergeinfo ). To use merge tracking you just merge as usual but without the revision range: svn merge trunkURL The client will take care of reading the properties to see what revision(s) need to be merged in and then update the properties with the newly-merged revision(s). Here is a pretty basic overview of the process. Pitfalls, etc. I personally haven't run into any problems with merge tracking, but my usage of the feature has been pretty light. Upgrading There are two upgrades you'll need to do to get merge tracking: Server: Your server must be running 1.5 to get merge tracking support. Client: You can use a 1.x client against a 1.5 server, but you won't get merge tracking. Just upgrade everyone. | Branch / merge management in Subversion 1.5 I've used subversion for a while, and used the svnmerge.py script for a while in my old job to manage merges between branches. I believe Subversion 1.5 is now out, and was supposed to have some branch / merge management system integrated with it. So, can someone give me a quick overview of how to track merges in a branch with Subversion 1.5? Are there any pitfalls with using this support? Do I need to ensure all the team upgrades to 1.5 before using this support? | TITLE:
Branch / merge management in Subversion 1.5
QUESTION:
I've used subversion for a while, and used the svnmerge.py script for a while in my old job to manage merges between branches. I believe Subversion 1.5 is now out, and was supposed to have some branch / merge management system integrated with it. So, can someone give me a quick overview of how to track merges in a branch with Subversion 1.5? Are there any pitfalls with using this support? Do I need to ensure all the team upgrades to 1.5 before using this support?
ANSWER:
Usage Merge tracking is managed by the client and stored in a property ( svn:mergeinfo ). To use merge tracking you just merge as usual but without the revision range: svn merge trunkURL The client will take care of reading the properties to see what revision(s) need to be merged in and then update the properties with the newly-merged revision(s). Here is a pretty basic overview of the process. Pitfalls, etc. I personally haven't run into any problems with merge tracking, but my usage of the feature has been pretty light. Upgrading There are two upgrades you'll need to do to get merge tracking: Server: Your server must be running 1.5 to get merge tracking support. Client: You can use a 1.x client against a 1.5 server, but you won't get merge tracking. Just upgrade everyone. | [
"svn",
"version-control"
] | 5 | 4 | 1,324 | 3 | 0 | 2008-09-05T14:38:05.853000 | 2008-09-05T14:55:53.347000 |
45,953 | 45,966 | php execute a background process | I need to execute a directory copy upon a user action, but the directories are quite large, so I would like to be able to perform such an action without the user being aware of the time it takes for the copy to complete. Any suggestions would be much appreciated. | Assuming this is running on a Linux machine, I've always handled it like this: exec(sprintf("%s > %s 2>&1 & echo $! >> %s", $cmd, $outputfile, $pidfile)); This launches the command $cmd, redirects the command output to $outputfile, and writes the process id to $pidfile. That lets you easily monitor what the process is doing and if it's still running. function isRunning($pid){ try{ $result = shell_exec(sprintf("ps %d", $pid)); if( count(preg_split("/\n/", $result)) > 2){ return true; } }catch(Exception $e){}
return false; } | php execute a background process I need to execute a directory copy upon a user action, but the directories are quite large, so I would like to be able to perform such an action without the user being aware of the time it takes for the copy to complete. Any suggestions would be much appreciated. | TITLE:
php execute a background process
QUESTION:
I need to execute a directory copy upon a user action, but the directories are quite large, so I would like to be able to perform such an action without the user being aware of the time it takes for the copy to complete. Any suggestions would be much appreciated.
ANSWER:
Assuming this is running on a Linux machine, I've always handled it like this: exec(sprintf("%s > %s 2>&1 & echo $! >> %s", $cmd, $outputfile, $pidfile)); This launches the command $cmd, redirects the command output to $outputfile, and writes the process id to $pidfile. That lets you easily monitor what the process is doing and if it's still running. function isRunning($pid){ try{ $result = shell_exec(sprintf("ps %d", $pid)); if( count(preg_split("/\n/", $result)) > 2){ return true; } }catch(Exception $e){}
return false; } | [
"php"
] | 287 | 395 | 281,020 | 23 | 0 | 2008-09-05T14:43:48.053000 | 2008-09-05T14:49:53 |
45,964 | 45,975 | How to multiply 10 to an "Integer" object in Java? | How do I multiply 10 to an Integer object and get back the Integer object? I am looking for the neatest way of doing this. I would probably do it this way: Get int from Integer object, multiply it with the other int and create another Integer object with this int value. Code will be something like... integerObj = new Integer(integerObj.intValue() * 10); But, I saw a code where the author is doing it this way: Get the String from the Integer object, concatenate "0" at the end and then get Integer object back by using Integer.parseInt The code is something like this: String s = integerObj + "0"; integerObj = Integer.parseInt(s); Is there any merit in doing it either way? And what would be the most efficient/neatest way in general and in this case? | With Java 5's autoboxing, you can simply do: Integer a = new Integer(2); // or even just Integer a = 2; a *= 10; System.out.println(a); | How to multiply 10 to an "Integer" object in Java? How do I multiply 10 to an Integer object and get back the Integer object? I am looking for the neatest way of doing this. I would probably do it this way: Get int from Integer object, multiply it with the other int and create another Integer object with this int value. Code will be something like... integerObj = new Integer(integerObj.intValue() * 10); But, I saw a code where the author is doing it this way: Get the String from the Integer object, concatenate "0" at the end and then get Integer object back by using Integer.parseInt The code is something like this: String s = integerObj + "0"; integerObj = Integer.parseInt(s); Is there any merit in doing it either way? And what would be the most efficient/neatest way in general and in this case? | TITLE:
How to multiply 10 to an "Integer" object in Java?
QUESTION:
How do I multiply 10 to an Integer object and get back the Integer object? I am looking for the neatest way of doing this. I would probably do it this way: Get int from Integer object, multiply it with the other int and create another Integer object with this int value. Code will be something like... integerObj = new Integer(integerObj.intValue() * 10); But, I saw a code where the author is doing it this way: Get the String from the Integer object, concatenate "0" at the end and then get Integer object back by using Integer.parseInt The code is something like this: String s = integerObj + "0"; integerObj = Integer.parseInt(s); Is there any merit in doing it either way? And what would be the most efficient/neatest way in general and in this case?
ANSWER:
With Java 5's autoboxing, you can simply do: Integer a = new Integer(2); // or even just Integer a = 2; a *= 10; System.out.println(a); | [
"java",
"types",
"casting"
] | 9 | 27 | 32,040 | 6 | 0 | 2008-09-05T14:49:27.667000 | 2008-09-05T14:52:57.907000 |
45,988 | 625,057 | Choosing a folder with .NET 3.5 | In a C#.NET 3.5 app (a mix of WinForms and WPF) I want to let the user select a folder to import a load of data from. At the moment, it's using System.Windows.Forms.FolderBrowserDialog but that's a bit lame. Mainly because you can't type the path into it (so you need to map a network drive, instead of typing a UNC path). I'd like something more like the System.Windows.Forms.OpenFileDialog, but for folders instead of files. What can I use instead? A WinForms or WPF solution is fine, but I'd prefer not to PInvoke into the Windows API if I can avoid it. | Don't create it yourself! It's been done. You can use FolderBrowserDialogEx - a re-usable derivative of the built-in FolderBrowserDialog. This one allows you to type in a path, even a UNC path. You can also browse for computers or printers with it. Works just like the built-in FBD, but... better. Full Source code. Free. MS-Public license. Code to use it: var dlg1 = new Ionic.Utils.FolderBrowserDialogEx(); dlg1.Description = "Select a folder to extract to:"; dlg1.ShowNewFolderButton = true; dlg1.ShowEditBox = true; //dlg1.NewStyle = false; dlg1.SelectedPath = txtExtractDirectory.Text; dlg1.ShowFullPathInEditBox = true; dlg1.RootFolder = System.Environment.SpecialFolder.MyComputer;
// Show the FolderBrowserDialog. DialogResult result = dlg1.ShowDialog(); if (result == DialogResult.OK) { txtExtractDirectory.Text = dlg1.SelectedPath; } | Choosing a folder with .NET 3.5 In a C#.NET 3.5 app (a mix of WinForms and WPF) I want to let the user select a folder to import a load of data from. At the moment, it's using System.Windows.Forms.FolderBrowserDialog but that's a bit lame. Mainly because you can't type the path into it (so you need to map a network drive, instead of typing a UNC path). I'd like something more like the System.Windows.Forms.OpenFileDialog, but for folders instead of files. What can I use instead? A WinForms or WPF solution is fine, but I'd prefer not to PInvoke into the Windows API if I can avoid it. | TITLE:
Choosing a folder with .NET 3.5
QUESTION:
In a C#.NET 3.5 app (a mix of WinForms and WPF) I want to let the user select a folder to import a load of data from. At the moment, it's using System.Windows.Forms.FolderBrowserDialog but that's a bit lame. Mainly because you can't type the path into it (so you need to map a network drive, instead of typing a UNC path). I'd like something more like the System.Windows.Forms.OpenFileDialog, but for folders instead of files. What can I use instead? A WinForms or WPF solution is fine, but I'd prefer not to PInvoke into the Windows API if I can avoid it.
ANSWER:
Don't create it yourself! It's been done. You can use FolderBrowserDialogEx - a re-usable derivative of the built-in FolderBrowserDialog. This one allows you to type in a path, even a UNC path. You can also browse for computers or printers with it. Works just like the built-in FBD, but... better. Full Source code. Free. MS-Public license. Code to use it: var dlg1 = new Ionic.Utils.FolderBrowserDialogEx(); dlg1.Description = "Select a folder to extract to:"; dlg1.ShowNewFolderButton = true; dlg1.ShowEditBox = true; //dlg1.NewStyle = false; dlg1.SelectedPath = txtExtractDirectory.Text; dlg1.ShowFullPathInEditBox = true; dlg1.RootFolder = System.Environment.SpecialFolder.MyComputer;
// Show the FolderBrowserDialog. DialogResult result = dlg1.ShowDialog(); if (result == DialogResult.OK) { txtExtractDirectory.Text = dlg1.SelectedPath; } | [
"c#",
".net",
"wpf",
"winforms"
] | 27 | 36 | 16,464 | 4 | 0 | 2008-09-05T15:01:28.607000 | 2009-03-09T04:55:47.160000 |
45,991 | 45,998 | What's the easiest way to convert Wiki markup to HTML? | I'm building a website that requires very basic markup capabilities. I can't use any 3rd party plugins, so I just need a simple way to convert markup to HTML. I might have a total of 3 tags that I'll allow. What is the best way to convert ==Heading== to Heading, or --bold-- to bold? Can this be done simply with Regex, or does somebody have a simple function? I'm writing this in C#, but examples from other languages would probably work. | It's not really a simple problem, because if you're going to display things back to the user, you'll need to also sanitise the input to ensure you don't create any cross site scripting vulnerabilities. That said, you could probably do something pretty simple as you describe most easily with a regular expression replacement. For example replace the pattern ==([^=]*)== with \1 | What's the easiest way to convert Wiki markup to HTML? I'm building a website that requires very basic markup capabilities. I can't use any 3rd party plugins, so I just need a simple way to convert markup to HTML. I might have a total of 3 tags that I'll allow. What is the best way to convert ==Heading== to Heading, or --bold-- to bold? Can this be done simply with Regex, or does somebody have a simple function? I'm writing this in C#, but examples from other languages would probably work. | TITLE:
What's the easiest way to convert Wiki markup to HTML?
QUESTION:
I'm building a website that requires very basic markup capabilities. I can't use any 3rd party plugins, so I just need a simple way to convert markup to HTML. I might have a total of 3 tags that I'll allow. What is the best way to convert ==Heading== to Heading, or --bold-- to bold? Can this be done simply with Regex, or does somebody have a simple function? I'm writing this in C#, but examples from other languages would probably work.
ANSWER:
It's not really a simple problem, because if you're going to display things back to the user, you'll need to also sanitise the input to ensure you don't create any cross site scripting vulnerabilities. That said, you could probably do something pretty simple as you describe most easily with a regular expression replacement. For example replace the pattern ==([^=]*)== with \1 | [
"html",
"wiki",
"markup"
] | 12 | 4 | 23,573 | 3 | 0 | 2008-09-05T15:04:16.790000 | 2008-09-05T15:10:07.010000 |
46,003 | 46,016 | How to change "Generate Method Stub" to throw NotImplementedException in VS? | How can I change default Generate Method Stub behavior in Visaul Studio to generate method with body throw new NotImplementedException(); instead of throw new Exception("The method or operation is not implemented."); | Taken from: http://blogs.msdn.com/ansonh/archive/2005/12/08/501763.aspx Visual Studio 2005 supports targeting the 1.0 version of the compact framework. In order to keep the size of the compact framework small, it does not include all of the same types that exist in the desktop framework. One of the types that is not included is NotImplementedException. You can change the generated code by editing the code snippet file: C:\Program Files\Microsoft Visual Studio 8\VC#\Snippets\1033\Refactoring\MethodStub.snippet and changing the Declarations section to the following: signature signature Exception SimpleTypeName(global::System.NotImplementedException) | How to change "Generate Method Stub" to throw NotImplementedException in VS? How can I change default Generate Method Stub behavior in Visaul Studio to generate method with body throw new NotImplementedException(); instead of throw new Exception("The method or operation is not implemented."); | TITLE:
How to change "Generate Method Stub" to throw NotImplementedException in VS?
QUESTION:
How can I change default Generate Method Stub behavior in Visaul Studio to generate method with body throw new NotImplementedException(); instead of throw new Exception("The method or operation is not implemented.");
ANSWER:
Taken from: http://blogs.msdn.com/ansonh/archive/2005/12/08/501763.aspx Visual Studio 2005 supports targeting the 1.0 version of the compact framework. In order to keep the size of the compact framework small, it does not include all of the same types that exist in the desktop framework. One of the types that is not included is NotImplementedException. You can change the generated code by editing the code snippet file: C:\Program Files\Microsoft Visual Studio 8\VC#\Snippets\1033\Refactoring\MethodStub.snippet and changing the Declarations section to the following: signature signature Exception SimpleTypeName(global::System.NotImplementedException) | [
".net",
"visual-studio",
"configuration"
] | 8 | 8 | 1,925 | 2 | 0 | 2008-09-05T15:11:29.500000 | 2008-09-05T15:17:12.593000 |
46,004 | 46,015 | How do you implement resource "edit" forms in a RESTful way? | We are trying to implement a REST API for an application we have now. We want to expose read/write capabilities for various resources using the REST API. How do we implement the "form" part of this? I get how to expose "read" of our data by creating RESTful URLs that essentially function as method calls and return the data: GET /restapi/myobject?param=object-id-maybe...and an XML document representing some data structure is returned. Fine. But, normally, in a web application, an "edit" would involve two requests: one to load the current version of the resources and populate the form with that data, and one to post the modified data back. But I don't get how you would do the same thing with HTTP methods that REST is sort of mapped to. It's a PUT, right? Can someone explain this? (Additional consideration: The UI would be primarily done with AJAX) -- Update: That definitely helps. But, I am still a bit confused about the server side? Obviously, I am not simply dealing with files here. On the server, the code that answers the requests should be filtering the request method to determine what to do with it? Is that the "switch" between reads and writes? | If you're submitting the data via plain HTML, you're restricted to doing a POST based form. The URI that the POST request is sent to should not be the URI for the resource being modified. You should either POST to a collection resource that ADDs a newly created resource each time (with the URI for the new resource in the Location header and a 202 status code) or POST to an updater resource that updates a resource with a supplied URI in the request's content (or custom header). If you're using an XmlHttpRequest object, you can set the method to PUT and submit the data to the resource's URI. This can also work with empty forms if the server supplies a valid URI for the yet-nonexistent resource. The first PUT would create the resource (returning 202 ). Subsequent PUTs will either do nothing if it's the same data or modify the existing resource (in either case a 200 is returned unless an error occurs). | How do you implement resource "edit" forms in a RESTful way? We are trying to implement a REST API for an application we have now. We want to expose read/write capabilities for various resources using the REST API. How do we implement the "form" part of this? I get how to expose "read" of our data by creating RESTful URLs that essentially function as method calls and return the data: GET /restapi/myobject?param=object-id-maybe...and an XML document representing some data structure is returned. Fine. But, normally, in a web application, an "edit" would involve two requests: one to load the current version of the resources and populate the form with that data, and one to post the modified data back. But I don't get how you would do the same thing with HTTP methods that REST is sort of mapped to. It's a PUT, right? Can someone explain this? (Additional consideration: The UI would be primarily done with AJAX) -- Update: That definitely helps. But, I am still a bit confused about the server side? Obviously, I am not simply dealing with files here. On the server, the code that answers the requests should be filtering the request method to determine what to do with it? Is that the "switch" between reads and writes? | TITLE:
How do you implement resource "edit" forms in a RESTful way?
QUESTION:
We are trying to implement a REST API for an application we have now. We want to expose read/write capabilities for various resources using the REST API. How do we implement the "form" part of this? I get how to expose "read" of our data by creating RESTful URLs that essentially function as method calls and return the data: GET /restapi/myobject?param=object-id-maybe...and an XML document representing some data structure is returned. Fine. But, normally, in a web application, an "edit" would involve two requests: one to load the current version of the resources and populate the form with that data, and one to post the modified data back. But I don't get how you would do the same thing with HTTP methods that REST is sort of mapped to. It's a PUT, right? Can someone explain this? (Additional consideration: The UI would be primarily done with AJAX) -- Update: That definitely helps. But, I am still a bit confused about the server side? Obviously, I am not simply dealing with files here. On the server, the code that answers the requests should be filtering the request method to determine what to do with it? Is that the "switch" between reads and writes?
ANSWER:
If you're submitting the data via plain HTML, you're restricted to doing a POST based form. The URI that the POST request is sent to should not be the URI for the resource being modified. You should either POST to a collection resource that ADDs a newly created resource each time (with the URI for the new resource in the Location header and a 202 status code) or POST to an updater resource that updates a resource with a supplied URI in the request's content (or custom header). If you're using an XmlHttpRequest object, you can set the method to PUT and submit the data to the resource's URI. This can also work with empty forms if the server supplies a valid URI for the yet-nonexistent resource. The first PUT would create the resource (returning 202 ). Subsequent PUTs will either do nothing if it's the same data or modify the existing resource (in either case a 200 is returned unless an error occurs). | [
"rest"
] | 12 | 3 | 12,992 | 4 | 0 | 2008-09-05T15:11:44.383000 | 2008-09-05T15:17:08.787000 |
46,013 | 46,024 | Best way for a program to self update | What's the best way to terminate a program and then run additional code from the program that's being terminated? For example, what would be the best way for a program to self update itself? | You have a couple options: You could use another application.exe to do the auto update. This is probably the best method. You can also rename a program's exe while it is running. Hence allowing you to get the file from some update server and replace it. On the program's next startup it will be using the new.exe. You can then delete the renamed file on startup. | Best way for a program to self update What's the best way to terminate a program and then run additional code from the program that's being terminated? For example, what would be the best way for a program to self update itself? | TITLE:
Best way for a program to self update
QUESTION:
What's the best way to terminate a program and then run additional code from the program that's being terminated? For example, what would be the best way for a program to self update itself?
ANSWER:
You have a couple options: You could use another application.exe to do the auto update. This is probably the best method. You can also rename a program's exe while it is running. Hence allowing you to get the file from some update server and replace it. On the program's next startup it will be using the new.exe. You can then delete the renamed file on startup. | [
"updating",
"patch"
] | 8 | 10 | 2,856 | 7 | 0 | 2008-09-05T15:15:49.990000 | 2008-09-05T15:20:23.537000 |
46,029 | 72,421 | Data Validation Design Patterns | If I have a collection of database tables (in an Access file, for example) and need to validate each table in this collection against a rule set that has both common rules across all tables as well as individual rules specific to one or a subset of tables, can someone recommend a good design pattern to look into? Specifically, I would like to avoid code similar to: void Main() { ValidateTable1(); ValidateTable2(); ValidateTable3(); }
private void ValidateTable1() { //Table1 validation code goes here }
private void ValidateTable2() { //Table2 validation code goes here }
private void ValidateTable3() { //Table3 validation code goes here } Also, I've decided to use log4net to log all of the errors and warnings, so that each method can be declared void and doesn't need to return anything. Is this a good idea or would it be better to create some sort of ValidationException that catches all exceptions and stores them in a List before printing them all out at the end? I did find this, which looks like it may work, but I'm hoping to actually find some code samples to work off of. Any suggestions? Has anyone done something similar in the past? For some background, the program will be written in either C# or VB.NET and the tables will more than likely be stored in either Access or SQL Server CE. | Just an update on this: I decided to go with the Decorator pattern. That is, I have one 'generic' table class that implements an IValidateableTable interface (which contains validate() method). Then, I created several validation decorators (that also implement IValidateableTable ) which I can wrap around each table that I'm trying to validate. So, the code ends up looking like this: IValidateableTable table1 = new GenericTable(myDataSet); table1 = new NonNullNonEmptyColumnValidator(table1, "ColumnA"); table1 = new ColumnValueValidator(table1, "ColumnB", "ExpectedValue"); Then, all I need to do is call table1.Validate() which unwinds through the decorators calling all of the needed validations. So far, it seems to work really well, though I am still open to suggestions. | Data Validation Design Patterns If I have a collection of database tables (in an Access file, for example) and need to validate each table in this collection against a rule set that has both common rules across all tables as well as individual rules specific to one or a subset of tables, can someone recommend a good design pattern to look into? Specifically, I would like to avoid code similar to: void Main() { ValidateTable1(); ValidateTable2(); ValidateTable3(); }
private void ValidateTable1() { //Table1 validation code goes here }
private void ValidateTable2() { //Table2 validation code goes here }
private void ValidateTable3() { //Table3 validation code goes here } Also, I've decided to use log4net to log all of the errors and warnings, so that each method can be declared void and doesn't need to return anything. Is this a good idea or would it be better to create some sort of ValidationException that catches all exceptions and stores them in a List before printing them all out at the end? I did find this, which looks like it may work, but I'm hoping to actually find some code samples to work off of. Any suggestions? Has anyone done something similar in the past? For some background, the program will be written in either C# or VB.NET and the tables will more than likely be stored in either Access or SQL Server CE. | TITLE:
Data Validation Design Patterns
QUESTION:
If I have a collection of database tables (in an Access file, for example) and need to validate each table in this collection against a rule set that has both common rules across all tables as well as individual rules specific to one or a subset of tables, can someone recommend a good design pattern to look into? Specifically, I would like to avoid code similar to: void Main() { ValidateTable1(); ValidateTable2(); ValidateTable3(); }
private void ValidateTable1() { //Table1 validation code goes here }
private void ValidateTable2() { //Table2 validation code goes here }
private void ValidateTable3() { //Table3 validation code goes here } Also, I've decided to use log4net to log all of the errors and warnings, so that each method can be declared void and doesn't need to return anything. Is this a good idea or would it be better to create some sort of ValidationException that catches all exceptions and stores them in a List before printing them all out at the end? I did find this, which looks like it may work, but I'm hoping to actually find some code samples to work off of. Any suggestions? Has anyone done something similar in the past? For some background, the program will be written in either C# or VB.NET and the tables will more than likely be stored in either Access or SQL Server CE.
ANSWER:
Just an update on this: I decided to go with the Decorator pattern. That is, I have one 'generic' table class that implements an IValidateableTable interface (which contains validate() method). Then, I created several validation decorators (that also implement IValidateableTable ) which I can wrap around each table that I'm trying to validate. So, the code ends up looking like this: IValidateableTable table1 = new GenericTable(myDataSet); table1 = new NonNullNonEmptyColumnValidator(table1, "ColumnA"); table1 = new ColumnValueValidator(table1, "ColumnB", "ExpectedValue"); Then, all I need to do is call table1.Validate() which unwinds through the decorators calling all of the needed validations. So far, it seems to work really well, though I am still open to suggestions. | [
"design-patterns",
"validation",
"oop"
] | 14 | 19 | 37,161 | 5 | 0 | 2008-09-05T15:24:39.830000 | 2008-09-16T13:50:23.427000 |
46,030 | 46,092 | C# Force Form Focus | So, I did search google and SO prior to asking this question. Basically I have a DLL that has a form compiled into it. The form will be used to display information to the screen. Eventually it will be asynchronous and expose a lot of customization in the dll. For now I just want it to display properly. The problem that I am having is that I use the dll by loading it in a Powershell session. So when I try to display the form and get it to come to the top and have focus, It has no problem with displaying over all the other apps, but I can't for the life of me get it to display over the Powershell window. Here is the code that I am currently using to try and get it to display. I am sure that the majority of it won't be required once I figure it out, this just represents all the things that I found via google. CLass Blah { [DllImport("user32.dll", EntryPoint = "SystemParametersInfo")] public static extern bool SystemParametersInfo(uint uiAction, uint uiParam, uint pvParam, uint fWinIni);
[DllImport("user32.dll", EntryPoint = "SetForegroundWindow")] public static extern bool SetForegroundWindow(IntPtr hWnd);
[DllImport("User32.dll", EntryPoint = "ShowWindowAsync")] private static extern bool ShowWindowAsync(IntPtr hWnd, int cmdShow); private const int WS_SHOWNORMAL = 1;
public void ShowMessage(string msg) { MessageForm msgFrm = new MessageForm(); msgFrm.lblMessage.Text = "FOO"; msgFrm.ShowDialog(); msgFrm.BringToFront(); msgFrm.TopMost = true; msgFrm.Activate();
SystemParametersInfo((uint)0x2001, 0, 0, 0x0002 | 0x0001); ShowWindowAsync(msgFrm.Handle, WS_SHOWNORMAL); SetForegroundWindow(msgFrm.Handle); SystemParametersInfo((uint)0x2001, 200000, 200000, 0x0002 | 0x0001); } } As I say I'm sure that most of that is either not needed or even flat out wrong, I just wanted to show the things that I had tried. Also, as I mentioned, I plan to have this be asynchronously displayed at some point which I suspect will wind up requiring a separate thread. Would splitting the form out into it's own thread make it easier to cause it to get focus over the Powershell session? @Joel, thanks for the info. Here is what I tried based on your suggestion: msgFrm.ShowDialog(); msgFrm.BringToFront(); msgFrm.Focus(); Application.DoEvents(); The form still comes up under the Powershell session. I'll proceed with working out the threading. I've spawned threads before but never where the parent thread needed to talk to the child thread, so we'll see how it goes. Thnks for all the ideas so far folks. Ok, threading it took care of the problem. @Quarrelsome, I did try both of those. Neither (nor both together) worked. I am curious as to what is evil about using threading? I am not using Application.Run and I have yet to have a problem. I am using a mediator class that both the parent thread and the child thread have access to. In that object I am using a ReaderWriterLock to lock one property that represents the message that I want displayed on the form that the child thread creates. The parent locks the property then writes what should be displayed. The child thread locks the property and reads what it should change the label on the form to. The child has to do this on a polling interval (I default it to 500ms) which I'm not real happy about, but I could not find an event driven way to let the child thread know that the proerty had changed, so I'm stuck with polling. | I also had trouble activating and bringing a window to the foreground. Here is the code that eventually worked for me. I'm not sure if it will solve your problem. Basically, call ShowWindow() then SetForegroundWindow(). using System.Diagnostics; using System.Runtime.InteropServices;
// Sets the window to be foreground [DllImport("User32")] private static extern int SetForegroundWindow(IntPtr hwnd);
// Activate or minimize a window [DllImportAttribute("User32.DLL")] private static extern bool ShowWindow(IntPtr hWnd, int nCmdShow); private const int SW_SHOW = 5; private const int SW_MINIMIZE = 6; private const int SW_RESTORE = 9;
private void ActivateApplication(string briefAppName) { Process[] procList = Process.GetProcessesByName(briefAppName);
if (procList.Length > 0) { ShowWindow(procList[0].MainWindowHandle, SW_RESTORE); SetForegroundWindow(procList[0].MainWindowHandle); } } | C# Force Form Focus So, I did search google and SO prior to asking this question. Basically I have a DLL that has a form compiled into it. The form will be used to display information to the screen. Eventually it will be asynchronous and expose a lot of customization in the dll. For now I just want it to display properly. The problem that I am having is that I use the dll by loading it in a Powershell session. So when I try to display the form and get it to come to the top and have focus, It has no problem with displaying over all the other apps, but I can't for the life of me get it to display over the Powershell window. Here is the code that I am currently using to try and get it to display. I am sure that the majority of it won't be required once I figure it out, this just represents all the things that I found via google. CLass Blah { [DllImport("user32.dll", EntryPoint = "SystemParametersInfo")] public static extern bool SystemParametersInfo(uint uiAction, uint uiParam, uint pvParam, uint fWinIni);
[DllImport("user32.dll", EntryPoint = "SetForegroundWindow")] public static extern bool SetForegroundWindow(IntPtr hWnd);
[DllImport("User32.dll", EntryPoint = "ShowWindowAsync")] private static extern bool ShowWindowAsync(IntPtr hWnd, int cmdShow); private const int WS_SHOWNORMAL = 1;
public void ShowMessage(string msg) { MessageForm msgFrm = new MessageForm(); msgFrm.lblMessage.Text = "FOO"; msgFrm.ShowDialog(); msgFrm.BringToFront(); msgFrm.TopMost = true; msgFrm.Activate();
SystemParametersInfo((uint)0x2001, 0, 0, 0x0002 | 0x0001); ShowWindowAsync(msgFrm.Handle, WS_SHOWNORMAL); SetForegroundWindow(msgFrm.Handle); SystemParametersInfo((uint)0x2001, 200000, 200000, 0x0002 | 0x0001); } } As I say I'm sure that most of that is either not needed or even flat out wrong, I just wanted to show the things that I had tried. Also, as I mentioned, I plan to have this be asynchronously displayed at some point which I suspect will wind up requiring a separate thread. Would splitting the form out into it's own thread make it easier to cause it to get focus over the Powershell session? @Joel, thanks for the info. Here is what I tried based on your suggestion: msgFrm.ShowDialog(); msgFrm.BringToFront(); msgFrm.Focus(); Application.DoEvents(); The form still comes up under the Powershell session. I'll proceed with working out the threading. I've spawned threads before but never where the parent thread needed to talk to the child thread, so we'll see how it goes. Thnks for all the ideas so far folks. Ok, threading it took care of the problem. @Quarrelsome, I did try both of those. Neither (nor both together) worked. I am curious as to what is evil about using threading? I am not using Application.Run and I have yet to have a problem. I am using a mediator class that both the parent thread and the child thread have access to. In that object I am using a ReaderWriterLock to lock one property that represents the message that I want displayed on the form that the child thread creates. The parent locks the property then writes what should be displayed. The child thread locks the property and reads what it should change the label on the form to. The child has to do this on a polling interval (I default it to 500ms) which I'm not real happy about, but I could not find an event driven way to let the child thread know that the proerty had changed, so I'm stuck with polling. | TITLE:
C# Force Form Focus
QUESTION:
So, I did search google and SO prior to asking this question. Basically I have a DLL that has a form compiled into it. The form will be used to display information to the screen. Eventually it will be asynchronous and expose a lot of customization in the dll. For now I just want it to display properly. The problem that I am having is that I use the dll by loading it in a Powershell session. So when I try to display the form and get it to come to the top and have focus, It has no problem with displaying over all the other apps, but I can't for the life of me get it to display over the Powershell window. Here is the code that I am currently using to try and get it to display. I am sure that the majority of it won't be required once I figure it out, this just represents all the things that I found via google. CLass Blah { [DllImport("user32.dll", EntryPoint = "SystemParametersInfo")] public static extern bool SystemParametersInfo(uint uiAction, uint uiParam, uint pvParam, uint fWinIni);
[DllImport("user32.dll", EntryPoint = "SetForegroundWindow")] public static extern bool SetForegroundWindow(IntPtr hWnd);
[DllImport("User32.dll", EntryPoint = "ShowWindowAsync")] private static extern bool ShowWindowAsync(IntPtr hWnd, int cmdShow); private const int WS_SHOWNORMAL = 1;
public void ShowMessage(string msg) { MessageForm msgFrm = new MessageForm(); msgFrm.lblMessage.Text = "FOO"; msgFrm.ShowDialog(); msgFrm.BringToFront(); msgFrm.TopMost = true; msgFrm.Activate();
SystemParametersInfo((uint)0x2001, 0, 0, 0x0002 | 0x0001); ShowWindowAsync(msgFrm.Handle, WS_SHOWNORMAL); SetForegroundWindow(msgFrm.Handle); SystemParametersInfo((uint)0x2001, 200000, 200000, 0x0002 | 0x0001); } } As I say I'm sure that most of that is either not needed or even flat out wrong, I just wanted to show the things that I had tried. Also, as I mentioned, I plan to have this be asynchronously displayed at some point which I suspect will wind up requiring a separate thread. Would splitting the form out into it's own thread make it easier to cause it to get focus over the Powershell session? @Joel, thanks for the info. Here is what I tried based on your suggestion: msgFrm.ShowDialog(); msgFrm.BringToFront(); msgFrm.Focus(); Application.DoEvents(); The form still comes up under the Powershell session. I'll proceed with working out the threading. I've spawned threads before but never where the parent thread needed to talk to the child thread, so we'll see how it goes. Thnks for all the ideas so far folks. Ok, threading it took care of the problem. @Quarrelsome, I did try both of those. Neither (nor both together) worked. I am curious as to what is evil about using threading? I am not using Application.Run and I have yet to have a problem. I am using a mediator class that both the parent thread and the child thread have access to. In that object I am using a ReaderWriterLock to lock one property that represents the message that I want displayed on the form that the child thread creates. The parent locks the property then writes what should be displayed. The child thread locks the property and reads what it should change the label on the form to. The child has to do this on a polling interval (I default it to 500ms) which I'm not real happy about, but I could not find an event driven way to let the child thread know that the proerty had changed, so I'm stuck with polling.
ANSWER:
I also had trouble activating and bringing a window to the foreground. Here is the code that eventually worked for me. I'm not sure if it will solve your problem. Basically, call ShowWindow() then SetForegroundWindow(). using System.Diagnostics; using System.Runtime.InteropServices;
// Sets the window to be foreground [DllImport("User32")] private static extern int SetForegroundWindow(IntPtr hwnd);
// Activate or minimize a window [DllImportAttribute("User32.DLL")] private static extern bool ShowWindow(IntPtr hWnd, int nCmdShow); private const int SW_SHOW = 5; private const int SW_MINIMIZE = 6; private const int SW_RESTORE = 9;
private void ActivateApplication(string briefAppName) { Process[] procList = Process.GetProcessesByName(briefAppName);
if (procList.Length > 0) { ShowWindow(procList[0].MainWindowHandle, SW_RESTORE); SetForegroundWindow(procList[0].MainWindowHandle); } } | [
"c#",
"winforms"
] | 25 | 18 | 56,233 | 8 | 0 | 2008-09-05T15:25:11.030000 | 2008-09-05T15:49:22.937000 |
46,074 | 46,143 | Redirect from domain name to a dotted quad hosted box | I have a php server that is running my domain name. For testing purposes I am running an asp.net on a dotted quad IP. I am hoping to link them together via either PHP or some kind of DNS/.htaccess voodoo. So if I go to www.mydomain.com/test it redirects (but keeps the url of ( www.mydomain.com/test ) in the browser's address bar and the pages are served by the dotted quad IP asp.net box. | Instead of pointing www.yourdomain.com/test at your test server, why not use test.yourdomain.com? Assuming you have access to the DNS records for yourdomain.com, you should just need to create an A record mapping test.yourdomain.com to your test server's IP address. | Redirect from domain name to a dotted quad hosted box I have a php server that is running my domain name. For testing purposes I am running an asp.net on a dotted quad IP. I am hoping to link them together via either PHP or some kind of DNS/.htaccess voodoo. So if I go to www.mydomain.com/test it redirects (but keeps the url of ( www.mydomain.com/test ) in the browser's address bar and the pages are served by the dotted quad IP asp.net box. | TITLE:
Redirect from domain name to a dotted quad hosted box
QUESTION:
I have a php server that is running my domain name. For testing purposes I am running an asp.net on a dotted quad IP. I am hoping to link them together via either PHP or some kind of DNS/.htaccess voodoo. So if I go to www.mydomain.com/test it redirects (but keeps the url of ( www.mydomain.com/test ) in the browser's address bar and the pages are served by the dotted quad IP asp.net box.
ANSWER:
Instead of pointing www.yourdomain.com/test at your test server, why not use test.yourdomain.com? Assuming you have access to the DNS records for yourdomain.com, you should just need to create an A record mapping test.yourdomain.com to your test server's IP address. | [
"php",
"hosting",
"dns"
] | 6 | 6 | 367 | 5 | 0 | 2008-09-05T15:43:15.010000 | 2008-09-05T16:07:40.693000 |
46,079 | 46,138 | What is the best approach for (client-side) disabling of a submit button? | Details: Only disable after user clicks the submit button, but before the posting back to the server ASP.NET Webforms (.NET 1.1) Prefer jQuery (if any library at all) Must be enabled if form reloads (i.e. credit card failed) This isn't a necessity that I do this, but if there is a simple way to do it without having to change too much, I'll do it. (i.e. if there isn't a simple solution, I probably won't do it, so don't worry about digging too deep) | For all submit buttons, via JQuery, it'd be: $('input[type=submit]').click(function() { this.disabled = true; }); Or it might be more useful to do so on form submission: $('form').submit(function() { $('input[type=submit]', this).attr("disabled","disabled"); }); But I think we could give a better answer to your question if we knew a bit more about the context. If this is an ajax request, then you'll need to make sure you enable submit buttons again on either success or failure. If this is a standard HTTP form submission (aside from disabling the button with javascript) and you're doing this to safe guard from multiple submissions of the same form, then you ought to have some sort of control in the code that deals with the submitted data, because disabling a button with javascript might not prevent multiple submissions. | What is the best approach for (client-side) disabling of a submit button? Details: Only disable after user clicks the submit button, but before the posting back to the server ASP.NET Webforms (.NET 1.1) Prefer jQuery (if any library at all) Must be enabled if form reloads (i.e. credit card failed) This isn't a necessity that I do this, but if there is a simple way to do it without having to change too much, I'll do it. (i.e. if there isn't a simple solution, I probably won't do it, so don't worry about digging too deep) | TITLE:
What is the best approach for (client-side) disabling of a submit button?
QUESTION:
Details: Only disable after user clicks the submit button, but before the posting back to the server ASP.NET Webforms (.NET 1.1) Prefer jQuery (if any library at all) Must be enabled if form reloads (i.e. credit card failed) This isn't a necessity that I do this, but if there is a simple way to do it without having to change too much, I'll do it. (i.e. if there isn't a simple solution, I probably won't do it, so don't worry about digging too deep)
ANSWER:
For all submit buttons, via JQuery, it'd be: $('input[type=submit]').click(function() { this.disabled = true; }); Or it might be more useful to do so on form submission: $('form').submit(function() { $('input[type=submit]', this).attr("disabled","disabled"); }); But I think we could give a better answer to your question if we knew a bit more about the context. If this is an ajax request, then you'll need to make sure you enable submit buttons again on either success or failure. If this is a standard HTTP form submission (aside from disabling the button with javascript) and you're doing this to safe guard from multiple submissions of the same form, then you ought to have some sort of control in the code that deals with the submitted data, because disabling a button with javascript might not prevent multiple submissions. | [
"asp.net",
"javascript",
"jquery",
"webforms",
".net-1.1"
] | 11 | 12 | 4,566 | 7 | 0 | 2008-09-05T15:45:22.713000 | 2008-09-05T16:05:04.677000 |
46,080 | 46,083 | How do you move a file? | I'm using TortoiseSVN against the SourceForge SVN repository. I'd like to move a file from one folder to another in order to maintain its revision history. Is this possible? If so, how do you do it? (My current strategy has been to copy the file into the new folder and check it in and then delete the file from the current folder.) | Subversion has native support for moving files. svn move SOURCE DESTINATION See the online help (svn help move) for more information. | How do you move a file? I'm using TortoiseSVN against the SourceForge SVN repository. I'd like to move a file from one folder to another in order to maintain its revision history. Is this possible? If so, how do you do it? (My current strategy has been to copy the file into the new folder and check it in and then delete the file from the current folder.) | TITLE:
How do you move a file?
QUESTION:
I'm using TortoiseSVN against the SourceForge SVN repository. I'd like to move a file from one folder to another in order to maintain its revision history. Is this possible? If so, how do you do it? (My current strategy has been to copy the file into the new folder and check it in and then delete the file from the current folder.)
ANSWER:
Subversion has native support for moving files. svn move SOURCE DESTINATION See the online help (svn help move) for more information. | [
"svn",
"tortoisesvn"
] | 223 | 97 | 137,045 | 13 | 0 | 2008-09-05T15:45:53.380000 | 2008-09-05T15:46:55.907000 |
46,096 | 46,104 | What are the names given to these 2 LINQ expressions | I'm trying to find the correct names for these 2 "types" of coding expressions in LINQ so that I can refer to them correctly. I want to say that the first is called "Fluent Style"? var selectVar = arrayVar.Select( (a,i) => new { Line = a });
var selectVar = from s in arrayVar select new { Line = s }; | First - calling an extension method. This style of coding is called " fluent interface " as you mentioned. Second method is called language integrated query | What are the names given to these 2 LINQ expressions I'm trying to find the correct names for these 2 "types" of coding expressions in LINQ so that I can refer to them correctly. I want to say that the first is called "Fluent Style"? var selectVar = arrayVar.Select( (a,i) => new { Line = a });
var selectVar = from s in arrayVar select new { Line = s }; | TITLE:
What are the names given to these 2 LINQ expressions
QUESTION:
I'm trying to find the correct names for these 2 "types" of coding expressions in LINQ so that I can refer to them correctly. I want to say that the first is called "Fluent Style"? var selectVar = arrayVar.Select( (a,i) => new { Line = a });
var selectVar = from s in arrayVar select new { Line = s };
ANSWER:
First - calling an extension method. This style of coding is called " fluent interface " as you mentioned. Second method is called language integrated query | [
"linq"
] | 0 | 4 | 155 | 3 | 0 | 2008-09-05T15:50:20.453000 | 2008-09-05T15:52:44.037000 |
46,124 | 46,126 | Is there a list of browser conditionals for use including stylesheets? | I've seen people doing things like this in their HTML: Does this work across all modern browsers and is there a list of browser types that will work with that kind of if statement? Edit Thanks Ross. Interesting to find out about gt, lt, gte, & lte. | This works across all browsers because anything except IE sees. Only IE reads the comment if it contains a conditional clause. Have a look at this article You can also specify which version of IE. For example: | Is there a list of browser conditionals for use including stylesheets? I've seen people doing things like this in their HTML: Does this work across all modern browsers and is there a list of browser types that will work with that kind of if statement? Edit Thanks Ross. Interesting to find out about gt, lt, gte, & lte. | TITLE:
Is there a list of browser conditionals for use including stylesheets?
QUESTION:
I've seen people doing things like this in their HTML: Does this work across all modern browsers and is there a list of browser types that will work with that kind of if statement? Edit Thanks Ross. Interesting to find out about gt, lt, gte, & lte.
ANSWER:
This works across all browsers because anything except IE sees. Only IE reads the comment if it contains a conditional clause. Have a look at this article You can also specify which version of IE. For example: | [
"css",
"browser",
"conditional-statements"
] | 8 | 11 | 726 | 4 | 0 | 2008-09-05T15:58:13.913000 | 2008-09-05T15:59:02.397000 |
46,125 | 46,141 | Can XPath match on parts of an element's name? | I want to do this: //*fu which returns all nodes whose name ends in fu, such as and, but not | Do something like: //*[ends-with(name(), 'fu')] For a good XPath reference, check out W3Schools. | Can XPath match on parts of an element's name? I want to do this: //*fu which returns all nodes whose name ends in fu, such as and, but not | TITLE:
Can XPath match on parts of an element's name?
QUESTION:
I want to do this: //*fu which returns all nodes whose name ends in fu, such as and, but not
ANSWER:
Do something like: //*[ends-with(name(), 'fu')] For a good XPath reference, check out W3Schools. | [
"xml",
"xpath"
] | 39 | 41 | 26,454 | 3 | 0 | 2008-09-05T15:58:16.550000 | 2008-09-05T16:06:18.917000 |
46,130 | 47,308 | How do I group in memory lists? | I have a list of Foo. Foo has properties Bar and Lum. Some Foo s have identical values for Bar. How can I use lambda/linq to group my Foo s by Bar so I can iterate over each grouping's Lum s? | Deeno, Enjoy: var foos = new List { new Foo{Bar = 1,Lum = 1}, new Foo{Bar = 1,Lum = 2}, new Foo{Bar = 2,Lum = 3}, };
// Using language integrated queries:
var q = from foo in foos group foo by foo.Bar into groupedFoos let lums = from fooGroup in groupedFoos select fooGroup.Lum select new { Bar = groupedFoos.Key, Lums = lums };
// Using lambdas
var q = foos.GroupBy(x => x.Bar). Select(y => new {Bar = y.Key, Lums = y.Select(z => z.Lum)});
foreach (var group in q) { Console.WriteLine("Lums for Bar#" + group.Bar); foreach (var lum in group.Lums) { Console.WriteLine(lum); } } To learn more about LINQ read 101 LINQ Samples | How do I group in memory lists? I have a list of Foo. Foo has properties Bar and Lum. Some Foo s have identical values for Bar. How can I use lambda/linq to group my Foo s by Bar so I can iterate over each grouping's Lum s? | TITLE:
How do I group in memory lists?
QUESTION:
I have a list of Foo. Foo has properties Bar and Lum. Some Foo s have identical values for Bar. How can I use lambda/linq to group my Foo s by Bar so I can iterate over each grouping's Lum s?
ANSWER:
Deeno, Enjoy: var foos = new List { new Foo{Bar = 1,Lum = 1}, new Foo{Bar = 1,Lum = 2}, new Foo{Bar = 2,Lum = 3}, };
// Using language integrated queries:
var q = from foo in foos group foo by foo.Bar into groupedFoos let lums = from fooGroup in groupedFoos select fooGroup.Lum select new { Bar = groupedFoos.Key, Lums = lums };
// Using lambdas
var q = foos.GroupBy(x => x.Bar). Select(y => new {Bar = y.Key, Lums = y.Select(z => z.Lum)});
foreach (var group in q) { Console.WriteLine("Lums for Bar#" + group.Bar); foreach (var lum in group.Lums) { Console.WriteLine(lum); } } To learn more about LINQ read 101 LINQ Samples | [
"c#",
".net",
"linq",
"lambda"
] | 5 | 3 | 386 | 2 | 0 | 2008-09-05T16:01:35.887000 | 2008-09-06T07:34:15.007000 |
46,136 | 46,184 | What is the best approach to moving a preexisting project from Flash 7/AS2 to Flex/AS3? | I have a large codebase that targetted Flash 7, with a lot of AS2 classes. I'm hoping that I'll be able to use Flex for any new projects, but a lot of new stuff in our roadmap is additions to the old code. The syntax for AS2 and AS3 is generally the same, so I'm starting to wonder how hard it would be to port the current codebase to Flex/AS3. I know all the UI-related stuff would be iffy (currently the UI is generated at runtime with a lot of createEmptyMovieClip() and attachMovie() stuff), but the UI and controller/model stuff is mostly separated. Has anyone tried porting a large codebase of AS2 code to AS3? How difficult is it? What kinds of pitfalls did you run into? Any recommendations for approaches to doing this kind of project? | Some notable problems I saw when attempting to convert a large number of AS2 classes to AS3: Package naming class your.package.YourClass { } becomes package your.package { class YourClass { } } Imports are required You must explicitly import any outside classes used -- referring to them by their fully qualified name is no longer enough. Interface methods can't be labelled 'public' This makes total sense, but AS2 will let you do it so if you have any they'll need to be removed. Explicit 'override' keyword Any functions that override a parent class function must be declared with the override keyword, much like C#. Along the same lines, if you have interfaces that extend other interfaces and redeclare functions, those overrides must be removed (again, as with public, this notation didn't make sense anyway but AS2 let you do it). All the Flash builtin stuff changed You alluded to this above, but it's now flash.display.MovieClip instead of just MovieClip, for example. There are a lot of specifics in this category, and I didn't get far enough to find them all, but there's going to be a lot of annoyance here. Conclusion I didn't get to work on this conversion to the point of success, but I was able in a matter of hours to write a quick C# tool that handled every aspect of this except the override keyword. Automating the imports can be tricky -- in my case the packages we use all start with a few root-level packages so they're easy to detect. | What is the best approach to moving a preexisting project from Flash 7/AS2 to Flex/AS3? I have a large codebase that targetted Flash 7, with a lot of AS2 classes. I'm hoping that I'll be able to use Flex for any new projects, but a lot of new stuff in our roadmap is additions to the old code. The syntax for AS2 and AS3 is generally the same, so I'm starting to wonder how hard it would be to port the current codebase to Flex/AS3. I know all the UI-related stuff would be iffy (currently the UI is generated at runtime with a lot of createEmptyMovieClip() and attachMovie() stuff), but the UI and controller/model stuff is mostly separated. Has anyone tried porting a large codebase of AS2 code to AS3? How difficult is it? What kinds of pitfalls did you run into? Any recommendations for approaches to doing this kind of project? | TITLE:
What is the best approach to moving a preexisting project from Flash 7/AS2 to Flex/AS3?
QUESTION:
I have a large codebase that targetted Flash 7, with a lot of AS2 classes. I'm hoping that I'll be able to use Flex for any new projects, but a lot of new stuff in our roadmap is additions to the old code. The syntax for AS2 and AS3 is generally the same, so I'm starting to wonder how hard it would be to port the current codebase to Flex/AS3. I know all the UI-related stuff would be iffy (currently the UI is generated at runtime with a lot of createEmptyMovieClip() and attachMovie() stuff), but the UI and controller/model stuff is mostly separated. Has anyone tried porting a large codebase of AS2 code to AS3? How difficult is it? What kinds of pitfalls did you run into? Any recommendations for approaches to doing this kind of project?
ANSWER:
Some notable problems I saw when attempting to convert a large number of AS2 classes to AS3: Package naming class your.package.YourClass { } becomes package your.package { class YourClass { } } Imports are required You must explicitly import any outside classes used -- referring to them by their fully qualified name is no longer enough. Interface methods can't be labelled 'public' This makes total sense, but AS2 will let you do it so if you have any they'll need to be removed. Explicit 'override' keyword Any functions that override a parent class function must be declared with the override keyword, much like C#. Along the same lines, if you have interfaces that extend other interfaces and redeclare functions, those overrides must be removed (again, as with public, this notation didn't make sense anyway but AS2 let you do it). All the Flash builtin stuff changed You alluded to this above, but it's now flash.display.MovieClip instead of just MovieClip, for example. There are a lot of specifics in this category, and I didn't get far enough to find them all, but there's going to be a lot of annoyance here. Conclusion I didn't get to work on this conversion to the point of success, but I was able in a matter of hours to write a quick C# tool that handled every aspect of this except the override keyword. Automating the imports can be tricky -- in my case the packages we use all start with a few root-level packages so they're easy to detect. | [
"apache-flex",
"flash",
"actionscript-3",
"porting"
] | 6 | 6 | 1,047 | 5 | 0 | 2008-09-05T16:04:36.580000 | 2008-09-05T16:15:47.523000 |
46,147 | 46,196 | Why are all links are red, in Chrome and Safari? | Have just started using Google Chrome, and noticed in parts of our site, e.g. all the links on the page, are bright red. They should be black with a dotted underline. Is there some gotcha in WebKit rendering that turns all links red regardless of the style? | Are all of the resources that you're linking to in the present at the locations where your page is seeking them (verify this by actually checking it). I've also had an issue when checking an app in Safari where I was attempting to pull a file that wasn't there and I had very similar output to yours (red links). EDIT: Adding Developingchris's find to the answer, since it explains it so well: k, found it. If any of your stylesheets is missing or pathed incorrectly, it throws a 404. If your 404 page has inline styles, they get respected via the "alternate sheets" rule in webkit. Thus, the red links on the "yellow screen of death" are causing my problem in overlap. | Why are all links are red, in Chrome and Safari? Have just started using Google Chrome, and noticed in parts of our site, e.g. all the links on the page, are bright red. They should be black with a dotted underline. Is there some gotcha in WebKit rendering that turns all links red regardless of the style? | TITLE:
Why are all links are red, in Chrome and Safari?
QUESTION:
Have just started using Google Chrome, and noticed in parts of our site, e.g. all the links on the page, are bright red. They should be black with a dotted underline. Is there some gotcha in WebKit rendering that turns all links red regardless of the style?
ANSWER:
Are all of the resources that you're linking to in the present at the locations where your page is seeking them (verify this by actually checking it). I've also had an issue when checking an app in Safari where I was attempting to pull a file that wasn't there and I had very similar output to yours (red links). EDIT: Adding Developingchris's find to the answer, since it explains it so well: k, found it. If any of your stylesheets is missing or pathed incorrectly, it throws a 404. If your 404 page has inline styles, they get respected via the "alternate sheets" rule in webkit. Thus, the red links on the "yellow screen of death" are causing my problem in overlap. | [
"css",
"safari",
"google-chrome",
"webkit"
] | 5 | 4 | 3,117 | 7 | 0 | 2008-09-05T16:08:19.007000 | 2008-09-05T16:17:54.553000 |
46,155 | 46,181 | How can I validate an email address in JavaScript? | I'd like to check if the user input is an email address in JavaScript, before sending it to a server or attempting to send an email to it, to prevent the most basic mistyping. How could I achieve this? | Using regular expressions is probably the best way of validating an email address in JavaScript. View a bunch of tests on JSFiddle taken from Chromium. const validateEmail = (email) => { return String(email).toLowerCase().match( /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|.(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/ ); }; The following is an example of a regular expression that accepts unicode. const re = /^(([^<>()[\]\.,;:\s@\"]+(\.[^<>()[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i; Keep in mind that one should not rely on JavaScript validation alone, as JavaScript can be easily disabled by the client. Furthermore, it is important to validate on the server side. The following snippet of code is an example of JavaScript validating an email address on the client side. const validateEmail = (email) => { return email.match( /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/ ); };
const validate = () => { const $result = $('#result'); const email = $('#email').val(); $result.text('');
if(validateEmail(email)){ $result.text(email + ' is valid.'); $result.css('color', 'green'); } else{ $result.text(email + ' is invalid.'); $result.css('color', 'red'); } return false; }
$('#email').on('input', validate); Enter email address | How can I validate an email address in JavaScript? I'd like to check if the user input is an email address in JavaScript, before sending it to a server or attempting to send an email to it, to prevent the most basic mistyping. How could I achieve this? | TITLE:
How can I validate an email address in JavaScript?
QUESTION:
I'd like to check if the user input is an email address in JavaScript, before sending it to a server or attempting to send an email to it, to prevent the most basic mistyping. How could I achieve this?
ANSWER:
Using regular expressions is probably the best way of validating an email address in JavaScript. View a bunch of tests on JSFiddle taken from Chromium. const validateEmail = (email) => { return String(email).toLowerCase().match( /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|.(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/ ); }; The following is an example of a regular expression that accepts unicode. const re = /^(([^<>()[\]\.,;:\s@\"]+(\.[^<>()[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i; Keep in mind that one should not rely on JavaScript validation alone, as JavaScript can be easily disabled by the client. Furthermore, it is important to validate on the server side. The following snippet of code is an example of JavaScript validating an email address on the client side. const validateEmail = (email) => { return email.match( /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/ ); };
const validate = () => { const $result = $('#result'); const email = $('#email').val(); $result.text('');
if(validateEmail(email)){ $result.text(email + ' is valid.'); $result.css('color', 'green'); } else{ $result.text(email + ' is invalid.'); $result.css('color', 'red'); } return false; }
$('#email').on('input', validate); Enter email address | [
"javascript",
"html",
"regex",
"email-validation"
] | 5,474 | 6,575 | 4,692,898 | 79 | 0 | 2008-09-05T16:10:11.093000 | 2008-09-05T16:15:34.747000 |
46,156 | 46,207 | What could cause Run-time error 1012 Error accessing application data directories | Friend of mine has a problem:). There is an application written in Visual Basic 6.0 (not by him). One of users reported that when it run on Windows 2000 and tried to scan folders on disk it raised box with message: Run-time error 1012 Error accessing application data directories We couldn't google anything about it and didn't find anything about runtime error 1012 in VB6 help files. My guess was that VB calls some old API function which returns folder to which app has no access (private, ciphered, belongs to other user and app is run by user without needed privileges). But we could not reproduce this (on Windows XP professional). Anyone meets with bug like this in the past? | Error 1012 is rather generically ERROR_CANT_READ. See this Microsoft list, but it also implies it refers to the registry. You could try running SysInternals Process Monitor to look for failing file/registry operations by the process. | What could cause Run-time error 1012 Error accessing application data directories Friend of mine has a problem:). There is an application written in Visual Basic 6.0 (not by him). One of users reported that when it run on Windows 2000 and tried to scan folders on disk it raised box with message: Run-time error 1012 Error accessing application data directories We couldn't google anything about it and didn't find anything about runtime error 1012 in VB6 help files. My guess was that VB calls some old API function which returns folder to which app has no access (private, ciphered, belongs to other user and app is run by user without needed privileges). But we could not reproduce this (on Windows XP professional). Anyone meets with bug like this in the past? | TITLE:
What could cause Run-time error 1012 Error accessing application data directories
QUESTION:
Friend of mine has a problem:). There is an application written in Visual Basic 6.0 (not by him). One of users reported that when it run on Windows 2000 and tried to scan folders on disk it raised box with message: Run-time error 1012 Error accessing application data directories We couldn't google anything about it and didn't find anything about runtime error 1012 in VB6 help files. My guess was that VB calls some old API function which returns folder to which app has no access (private, ciphered, belongs to other user and app is run by user without needed privileges). But we could not reproduce this (on Windows XP professional). Anyone meets with bug like this in the past?
ANSWER:
Error 1012 is rather generically ERROR_CANT_READ. See this Microsoft list, but it also implies it refers to the registry. You could try running SysInternals Process Monitor to look for failing file/registry operations by the process. | [
"windows",
"vb6",
"runtime-error"
] | 0 | 2 | 1,013 | 1 | 0 | 2008-09-05T16:10:14.087000 | 2008-09-05T16:20:23.097000 |
46,189 | 46,206 | Mapping collections with LINQ | I have a collection of objects to which I'd like to just add a new property. How do I do that with LINQ? | var a = from i in ObjectCollection select new {i.prop1, i.prop2, i.prop3,..., newprop = newProperty} | Mapping collections with LINQ I have a collection of objects to which I'd like to just add a new property. How do I do that with LINQ? | TITLE:
Mapping collections with LINQ
QUESTION:
I have a collection of objects to which I'd like to just add a new property. How do I do that with LINQ?
ANSWER:
var a = from i in ObjectCollection select new {i.prop1, i.prop2, i.prop3,..., newprop = newProperty} | [
"linq",
"functional-programming"
] | 7 | 3 | 224 | 3 | 0 | 2008-09-05T16:17:16.753000 | 2008-09-05T16:19:35.860000 |
46,214 | 46,253 | Good ways to improve jQuery selector performance? | I'm looking for any way that I can improve the selector performance of a jQuery call. Specifically things like this: Is $("div.myclass") faster than $(".myclass") I would think it might be, but I don't know if jQuery is smart enough to limit the search by tag name first, etc. Anyone have any ideas for how to formulate a jQuery selector string for best performance? | There is no doubt that filtering by tag name first is much faster than filtering by classname. This will be the case until all browsers implement getElementsByClassName natively, as is the case with getElementsByTagName. | Good ways to improve jQuery selector performance? I'm looking for any way that I can improve the selector performance of a jQuery call. Specifically things like this: Is $("div.myclass") faster than $(".myclass") I would think it might be, but I don't know if jQuery is smart enough to limit the search by tag name first, etc. Anyone have any ideas for how to formulate a jQuery selector string for best performance? | TITLE:
Good ways to improve jQuery selector performance?
QUESTION:
I'm looking for any way that I can improve the selector performance of a jQuery call. Specifically things like this: Is $("div.myclass") faster than $(".myclass") I would think it might be, but I don't know if jQuery is smart enough to limit the search by tag name first, etc. Anyone have any ideas for how to formulate a jQuery selector string for best performance?
ANSWER:
There is no doubt that filtering by tag name first is much faster than filtering by classname. This will be the case until all browsers implement getElementsByClassName natively, as is the case with getElementsByTagName. | [
"javascript",
"jquery",
"performance",
"css-selectors"
] | 74 | 35 | 30,282 | 12 | 0 | 2008-09-05T16:22:26.837000 | 2008-09-05T16:39:39.383000 |
46,219 | 46,242 | How to determine if user selected a file for file upload? | If I have a tag, and a submit button, how do I determine, in IE6 (and above) if a file has been selected by the user. In FF, I just do: var selected = document.getElementById("uploadBox").files.length > 0; But that doesn't work in IE. | This works in IE (and FF, I believe): if(document.getElementById("uploadBox").value!= "") { // you have a file } | How to determine if user selected a file for file upload? If I have a tag, and a submit button, how do I determine, in IE6 (and above) if a file has been selected by the user. In FF, I just do: var selected = document.getElementById("uploadBox").files.length > 0; But that doesn't work in IE. | TITLE:
How to determine if user selected a file for file upload?
QUESTION:
If I have a tag, and a submit button, how do I determine, in IE6 (and above) if a file has been selected by the user. In FF, I just do: var selected = document.getElementById("uploadBox").files.length > 0; But that doesn't work in IE.
ANSWER:
This works in IE (and FF, I believe): if(document.getElementById("uploadBox").value!= "") { // you have a file } | [
"javascript",
"html",
"upload"
] | 71 | 132 | 118,489 | 5 | 0 | 2008-09-05T16:23:48.580000 | 2008-09-05T16:33:12.597000 |
46,220 | 46,357 | iPhone app crashing with NSUnknownKeyException setValue:forUndefinedKey: | I'm writing my first iPhone app, so I haven't gotten around to figuring out much in the way of debugging. Essentially my app displays an image and when touched plays a short sound. When compiling and building the project in XCode, everything builds successfully, but when the app is run in the iPhone simulator, it crashes. I get the following error: Application Specific Information: iPhone Simulator 1.0 (70), iPhone OS 2.0 (5A331) *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key kramerImage.' kramerImage here is the image I'm using for the background. I'm not sure what NSUnknownKeyException means or why the class is not key value coding-compliant for the key. | (This isn't really iPhone specific - the same thing will happen in regular Cocoa). NSUnknownKeyException is a common error when using Key-Value Coding to access a key that the object doesn't have. The properties of most Cocoa objects can be accessing directly: [@"hello world" length] // Objective-C 1.0 @"hello world".length // Objective-C 2.0 Or via Key-Value Coding: [@"hello world" valueForKey:@"length"] I would get an NSUnknownKeyException if I used the following line: [@"hello world" valueForKey:@"purpleMonkeyDishwasher"] because NSString does not have a property (key) called 'purpleMonkeyDishwasher'. Something in your code is trying to set a value for the key 'kramerImage' on an UIView, which (apparently) doesn't support that key. If you're using Interface Builder, it might be something in your nib. Find where 'kramerImage' is being used, and try to track it down from there. | iPhone app crashing with NSUnknownKeyException setValue:forUndefinedKey: I'm writing my first iPhone app, so I haven't gotten around to figuring out much in the way of debugging. Essentially my app displays an image and when touched plays a short sound. When compiling and building the project in XCode, everything builds successfully, but when the app is run in the iPhone simulator, it crashes. I get the following error: Application Specific Information: iPhone Simulator 1.0 (70), iPhone OS 2.0 (5A331) *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key kramerImage.' kramerImage here is the image I'm using for the background. I'm not sure what NSUnknownKeyException means or why the class is not key value coding-compliant for the key. | TITLE:
iPhone app crashing with NSUnknownKeyException setValue:forUndefinedKey:
QUESTION:
I'm writing my first iPhone app, so I haven't gotten around to figuring out much in the way of debugging. Essentially my app displays an image and when touched plays a short sound. When compiling and building the project in XCode, everything builds successfully, but when the app is run in the iPhone simulator, it crashes. I get the following error: Application Specific Information: iPhone Simulator 1.0 (70), iPhone OS 2.0 (5A331) *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key kramerImage.' kramerImage here is the image I'm using for the background. I'm not sure what NSUnknownKeyException means or why the class is not key value coding-compliant for the key.
ANSWER:
(This isn't really iPhone specific - the same thing will happen in regular Cocoa). NSUnknownKeyException is a common error when using Key-Value Coding to access a key that the object doesn't have. The properties of most Cocoa objects can be accessing directly: [@"hello world" length] // Objective-C 1.0 @"hello world".length // Objective-C 2.0 Or via Key-Value Coding: [@"hello world" valueForKey:@"length"] I would get an NSUnknownKeyException if I used the following line: [@"hello world" valueForKey:@"purpleMonkeyDishwasher"] because NSString does not have a property (key) called 'purpleMonkeyDishwasher'. Something in your code is trying to set a value for the key 'kramerImage' on an UIView, which (apparently) doesn't support that key. If you're using Interface Builder, it might be something in your nib. Find where 'kramerImage' is being used, and try to track it down from there. | [
"iphone",
"xib",
"key-value-coding"
] | 19 | 22 | 28,846 | 8 | 0 | 2008-09-05T16:23:57.330000 | 2008-09-05T17:28:35.070000 |
46,231 | 46,486 | How to generate a verification code/number? | I'm working on an application where users have to make a call and type a verification number with the keypad of their phone. I would like to be able to detect if the number they type is correct or not. The phone system does not have access to a list of valid numbers, but instead, it will validate the number against an algorithm (like a credit card number). Here are some of the requirements: It must be difficult to type a valid random code It must be difficult to have a valid code if I make a typo (transposition of digits, wrong digit) I must have a reasonable number of possible combinations (let's say 1M) The code must be as short as possible, to avoid errors from the user Given these requirements, how would you generate such a number? EDIT: @Haaked: The code has to be numerical because the user types it with its phone. @matt b: On the first step, the code is displayed on a Web page, the second step is to call and type in the code. I don't know the user's phone number. Followup: I've found several algorithms to check the validity of numbers (See this interesting Google Code project: checkDigits ). | After some research, I think I'll go with the ISO 7064 Mod 97,10 formula. It seems pretty solid as it is used to validate IBAN (International Bank Account Number). The formula is very simple: Take a number: 123456 Apply the following formula to obtain the 2 digits checksum: mod(98 - mod(number * 100, 97), 97) => 76 Concat number and checksum to obtain the code => 12345676 To validate a code, verify that mod(code, 97) == 1 Test: mod(12345676, 97) = 1 => GOOD mod(21345676, 97) = 50 => BAD! mod(12345678, 97) = 10 => BAD! Apparently, this algorithm catches most of the errors. Another interesting option was the Verhoeff algorithm. It has only one verification digit and is more difficult to implement (compared to the simple formula above). | How to generate a verification code/number? I'm working on an application where users have to make a call and type a verification number with the keypad of their phone. I would like to be able to detect if the number they type is correct or not. The phone system does not have access to a list of valid numbers, but instead, it will validate the number against an algorithm (like a credit card number). Here are some of the requirements: It must be difficult to type a valid random code It must be difficult to have a valid code if I make a typo (transposition of digits, wrong digit) I must have a reasonable number of possible combinations (let's say 1M) The code must be as short as possible, to avoid errors from the user Given these requirements, how would you generate such a number? EDIT: @Haaked: The code has to be numerical because the user types it with its phone. @matt b: On the first step, the code is displayed on a Web page, the second step is to call and type in the code. I don't know the user's phone number. Followup: I've found several algorithms to check the validity of numbers (See this interesting Google Code project: checkDigits ). | TITLE:
How to generate a verification code/number?
QUESTION:
I'm working on an application where users have to make a call and type a verification number with the keypad of their phone. I would like to be able to detect if the number they type is correct or not. The phone system does not have access to a list of valid numbers, but instead, it will validate the number against an algorithm (like a credit card number). Here are some of the requirements: It must be difficult to type a valid random code It must be difficult to have a valid code if I make a typo (transposition of digits, wrong digit) I must have a reasonable number of possible combinations (let's say 1M) The code must be as short as possible, to avoid errors from the user Given these requirements, how would you generate such a number? EDIT: @Haaked: The code has to be numerical because the user types it with its phone. @matt b: On the first step, the code is displayed on a Web page, the second step is to call and type in the code. I don't know the user's phone number. Followup: I've found several algorithms to check the validity of numbers (See this interesting Google Code project: checkDigits ).
ANSWER:
After some research, I think I'll go with the ISO 7064 Mod 97,10 formula. It seems pretty solid as it is used to validate IBAN (International Bank Account Number). The formula is very simple: Take a number: 123456 Apply the following formula to obtain the 2 digits checksum: mod(98 - mod(number * 100, 97), 97) => 76 Concat number and checksum to obtain the code => 12345676 To validate a code, verify that mod(code, 97) == 1 Test: mod(12345676, 97) = 1 => GOOD mod(21345676, 97) = 50 => BAD! mod(12345678, 97) = 10 => BAD! Apparently, this algorithm catches most of the errors. Another interesting option was the Verhoeff algorithm. It has only one verification digit and is more difficult to implement (compared to the simple formula above). | [
"algorithm",
"checksum",
"error-checking",
"data-consistency"
] | 28 | 32 | 50,892 | 9 | 0 | 2008-09-05T16:28:34.840000 | 2008-09-05T18:30:26.107000 |
46,252 | 46,257 | Is there a way I can have a VM gain access to my computer? | I would like to have a VM to look at how applications appear and to develop OS-specific applications, however, I want to keep all my code on my Windows machine so if I decide to nuke a VM or anything like that, it's all still there. If it matters, I'm using VirtualBox. | This is usually handled with network shares. Share your code folder from your host machine and access it from the VMs. | Is there a way I can have a VM gain access to my computer? I would like to have a VM to look at how applications appear and to develop OS-specific applications, however, I want to keep all my code on my Windows machine so if I decide to nuke a VM or anything like that, it's all still there. If it matters, I'm using VirtualBox. | TITLE:
Is there a way I can have a VM gain access to my computer?
QUESTION:
I would like to have a VM to look at how applications appear and to develop OS-specific applications, however, I want to keep all my code on my Windows machine so if I decide to nuke a VM or anything like that, it's all still there. If it matters, I'm using VirtualBox.
ANSWER:
This is usually handled with network shares. Share your code folder from your host machine and access it from the VMs. | [
"virtual-machine",
"virtualbox"
] | 0 | 5 | 1,336 | 4 | 0 | 2008-09-05T16:38:39.260000 | 2008-09-05T16:40:26.887000 |
46,276 | 46,294 | Test Driven Development in PHP | I am a web-developer working in PHP. I have some limited experience with using Test Driven Development in C# desktop applications. In that case we used nUnit for the unit testing framework. I would like to start using TDD in new projects but I'm really not sure where to begin. What recommendations do you have for a PHP-based unit testing framework and what are some good resources for someone who is pretty new to the TDD concept? | I've used both PHPUnit & SimpleTest and I found SimpleTest to be easier to use. As far as TDD goes, I haven't had much luck with it in the purest sense. I think that's mainly a time/discipline issue on my part though. Adding tests after the fact has been somewhat useful but my favorite things to do is use write SimpleTest tests that test for specific bugs that I have to fix. That makes it very easy to verify that things are actually fixed and stay fixed. | Test Driven Development in PHP I am a web-developer working in PHP. I have some limited experience with using Test Driven Development in C# desktop applications. In that case we used nUnit for the unit testing framework. I would like to start using TDD in new projects but I'm really not sure where to begin. What recommendations do you have for a PHP-based unit testing framework and what are some good resources for someone who is pretty new to the TDD concept? | TITLE:
Test Driven Development in PHP
QUESTION:
I am a web-developer working in PHP. I have some limited experience with using Test Driven Development in C# desktop applications. In that case we used nUnit for the unit testing framework. I would like to start using TDD in new projects but I'm really not sure where to begin. What recommendations do you have for a PHP-based unit testing framework and what are some good resources for someone who is pretty new to the TDD concept?
ANSWER:
I've used both PHPUnit & SimpleTest and I found SimpleTest to be easier to use. As far as TDD goes, I haven't had much luck with it in the purest sense. I think that's mainly a time/discipline issue on my part though. Adding tests after the fact has been somewhat useful but my favorite things to do is use write SimpleTest tests that test for specific bugs that I have to fix. That makes it very easy to verify that things are actually fixed and stay fixed. | [
"php",
"unit-testing",
"tdd"
] | 44 | 41 | 16,913 | 8 | 0 | 2008-09-05T16:48:44.260000 | 2008-09-05T16:54:04.623000 |
46,277 | 47,808 | Passing large files to WCF service | We have an encryption service that we've exposed over net. tcp. Most of the time, the service is used to encrypt/decrypt strings. However, every now and then, we the need to encrypt large documents (pdf, JPG, bmp, etc.). What are the best endpoint settings for a scenario like this? Should I accept/return a stream? I've read a lot about this, but no one gives guidance on what to do when the large file doesn't occur frequently. | MSDN describes how to enable streaming over WCF rather well. Note, if the link between client and server needs to be encrypted, then you'll need to "roll your own" encryption mechanism. The default net.tcp encryption requires X.509 certificates, which won't work with streams as this kind of encryption needs to work on an entire message in one go rather than a stream of bytes. This, in turn, means that you won't be able to authenticate the client using the default WCF security mechanisms as authentication requires encryption. The only work-around for this that I know of is to implement your own custom behaviour extensions on client and server to handle authentication. A really good reference on how to add custom behaviour extensions is here: this documents how to provide custom configuration, too (something that I don't think is discussed anywhere in the MSDN documents at this time). | Passing large files to WCF service We have an encryption service that we've exposed over net. tcp. Most of the time, the service is used to encrypt/decrypt strings. However, every now and then, we the need to encrypt large documents (pdf, JPG, bmp, etc.). What are the best endpoint settings for a scenario like this? Should I accept/return a stream? I've read a lot about this, but no one gives guidance on what to do when the large file doesn't occur frequently. | TITLE:
Passing large files to WCF service
QUESTION:
We have an encryption service that we've exposed over net. tcp. Most of the time, the service is used to encrypt/decrypt strings. However, every now and then, we the need to encrypt large documents (pdf, JPG, bmp, etc.). What are the best endpoint settings for a scenario like this? Should I accept/return a stream? I've read a lot about this, but no one gives guidance on what to do when the large file doesn't occur frequently.
ANSWER:
MSDN describes how to enable streaming over WCF rather well. Note, if the link between client and server needs to be encrypted, then you'll need to "roll your own" encryption mechanism. The default net.tcp encryption requires X.509 certificates, which won't work with streams as this kind of encryption needs to work on an entire message in one go rather than a stream of bytes. This, in turn, means that you won't be able to authenticate the client using the default WCF security mechanisms as authentication requires encryption. The only work-around for this that I know of is to implement your own custom behaviour extensions on client and server to handle authentication. A really good reference on how to add custom behaviour extensions is here: this documents how to provide custom configuration, too (something that I don't think is discussed anywhere in the MSDN documents at this time). | [
"wcf",
"web-services"
] | 6 | 4 | 3,431 | 2 | 0 | 2008-09-05T16:49:07.800000 | 2008-09-06T20:23:16.653000 |
46,281 | 71,406 | How do DVCSs (DRCSs) work? | I have been hearing a lot of good things about DVCS systems, in particular about bazaar. Apart from the concept of distributed repository, I see two main advantages being touted: the merge is better automated, and the rename is handled right. Could someone please point me at some text explaining how exactly the improvements work? How does bazaar know that I renamed a file? What if I rename two files as part of the same commit? What happens when I refactor by putting half of the file's contents into a new file, re-indenting everything and losing some whitespace in nearly every line? In other words, I'd like to hear from people using bazaar (or another DVCS) in real life, or from people who know how it (they) works. Is the merge really that much better? And how is it achieved? Related question, with a useful answer: Why is branching and merging easier in Mercurial than in Subversion? | Merge is not intrinsically better in DVCS, it is just that they would be practically very difficult to use if the branch/merge did not work correctly (svn arguably does not implement branching/merging correctly), because instead of making a checkout, you are making a new branch everytime you start working on a project from an existing code. I think some proprietary, centralized SCS do handle merge/branch correctly. The way it works for all of them is to record every commit in a Directly Acyclic Graph (DAG), and from this, you have different merge strategies available. Here you can find more information: http://revctrl.org/CategoryMergeAlgorithm At least hg, bzr and git can use external merge utilities. | How do DVCSs (DRCSs) work? I have been hearing a lot of good things about DVCS systems, in particular about bazaar. Apart from the concept of distributed repository, I see two main advantages being touted: the merge is better automated, and the rename is handled right. Could someone please point me at some text explaining how exactly the improvements work? How does bazaar know that I renamed a file? What if I rename two files as part of the same commit? What happens when I refactor by putting half of the file's contents into a new file, re-indenting everything and losing some whitespace in nearly every line? In other words, I'd like to hear from people using bazaar (or another DVCS) in real life, or from people who know how it (they) works. Is the merge really that much better? And how is it achieved? Related question, with a useful answer: Why is branching and merging easier in Mercurial than in Subversion? | TITLE:
How do DVCSs (DRCSs) work?
QUESTION:
I have been hearing a lot of good things about DVCS systems, in particular about bazaar. Apart from the concept of distributed repository, I see two main advantages being touted: the merge is better automated, and the rename is handled right. Could someone please point me at some text explaining how exactly the improvements work? How does bazaar know that I renamed a file? What if I rename two files as part of the same commit? What happens when I refactor by putting half of the file's contents into a new file, re-indenting everything and losing some whitespace in nearly every line? In other words, I'd like to hear from people using bazaar (or another DVCS) in real life, or from people who know how it (they) works. Is the merge really that much better? And how is it achieved? Related question, with a useful answer: Why is branching and merging easier in Mercurial than in Subversion?
ANSWER:
Merge is not intrinsically better in DVCS, it is just that they would be practically very difficult to use if the branch/merge did not work correctly (svn arguably does not implement branching/merging correctly), because instead of making a checkout, you are making a new branch everytime you start working on a project from an existing code. I think some proprietary, centralized SCS do handle merge/branch correctly. The way it works for all of them is to record every commit in a Directly Acyclic Graph (DAG), and from this, you have different merge strategies available. Here you can find more information: http://revctrl.org/CategoryMergeAlgorithm At least hg, bzr and git can use external merge utilities. | [
"git",
"version-control",
"dvcs",
"bazaar"
] | 0 | 2 | 605 | 5 | 0 | 2008-09-05T16:50:23.740000 | 2008-09-16T11:33:12.850000 |
46,282 | 46,378 | How do I create an XmlNode from a call to XmlSerializer.Serialize? | I am using a class library which represents some of its configuration in.xml. The configuration is read in using the XmlSerializer. Fortunately, the classes which represent the.xml use the XmlAnyElement attribute at which allows me to extend the configuration data for my own purposes without modifying the original class library. This is some data This is my data This works well for deserialization. I am able to allow the class library to deserialize the.xml as normal and the I can use my own XmlSerializer instances with a XmlNodeReader against the internal XmlNode. public class Config { [XmlElement] public string data;
[XmlAnyElement] public XmlNode element; }
public class MyConfig { [XmlElement] public string data; }
class Program { static void Main(string[] args) { using (Stream fs = new FileStream(@"c:\temp\xmltest.xml", FileMode.Open)) { XmlSerializer xser1 = new XmlSerializer(typeof(Config)); Config config = (Config)xser1.Deserialize(fs);
if (config.element!= null) { XmlSerializer xser2 = new XmlSerializer(typeof(MyConfig)); MyConfig myConfig = (MyConfig)xser2.Deserialize(new XmlNodeReader(config.element)); } } } I need to create a utility which will allow the user to generate a new configuration file that includes both the class library configuration as well my own configuration, so new objects will be created which were not read from the.xml file. The question is how can I serialize the data back into.xml? I realize that I have to initially call XmlSerializer.Serialize on my data before calling the same method on the class library configuration. However, this requires that my data is represented by an XmlNode after calling Serialize. What is the best way to serialize an object into an XmlNode using the XmlSerializer? Thanks, -kevin btw-- It looks like an XmlNodeWriter class written by Chris Lovett was available at one time from Microsoft, but the links are now broken. Does anyone know of an alternative location to get this class? | So you need to have your class contain custom configuration information, then serialize that class to XML, then make that serialized XML into an XML node: is that right? Could you just take the string created by the XMLSerializer and wrap that in it's own XML tags? XmlSerializer xs = new XmlSerializer(typeof(MyConfig)); StringWriter xout = new StringWriter(); xs.Serialize(xout, myConfig); XmlDocument x = new XmlDocument(); x.LoadXml(" " + xout.ToString() + " "); Now x is an XmlDocument containing one element, " ", which has your serialized custom configuration in it. Is that at all what you're looking for? | How do I create an XmlNode from a call to XmlSerializer.Serialize? I am using a class library which represents some of its configuration in.xml. The configuration is read in using the XmlSerializer. Fortunately, the classes which represent the.xml use the XmlAnyElement attribute at which allows me to extend the configuration data for my own purposes without modifying the original class library. This is some data This is my data This works well for deserialization. I am able to allow the class library to deserialize the.xml as normal and the I can use my own XmlSerializer instances with a XmlNodeReader against the internal XmlNode. public class Config { [XmlElement] public string data;
[XmlAnyElement] public XmlNode element; }
public class MyConfig { [XmlElement] public string data; }
class Program { static void Main(string[] args) { using (Stream fs = new FileStream(@"c:\temp\xmltest.xml", FileMode.Open)) { XmlSerializer xser1 = new XmlSerializer(typeof(Config)); Config config = (Config)xser1.Deserialize(fs);
if (config.element!= null) { XmlSerializer xser2 = new XmlSerializer(typeof(MyConfig)); MyConfig myConfig = (MyConfig)xser2.Deserialize(new XmlNodeReader(config.element)); } } } I need to create a utility which will allow the user to generate a new configuration file that includes both the class library configuration as well my own configuration, so new objects will be created which were not read from the.xml file. The question is how can I serialize the data back into.xml? I realize that I have to initially call XmlSerializer.Serialize on my data before calling the same method on the class library configuration. However, this requires that my data is represented by an XmlNode after calling Serialize. What is the best way to serialize an object into an XmlNode using the XmlSerializer? Thanks, -kevin btw-- It looks like an XmlNodeWriter class written by Chris Lovett was available at one time from Microsoft, but the links are now broken. Does anyone know of an alternative location to get this class? | TITLE:
How do I create an XmlNode from a call to XmlSerializer.Serialize?
QUESTION:
I am using a class library which represents some of its configuration in.xml. The configuration is read in using the XmlSerializer. Fortunately, the classes which represent the.xml use the XmlAnyElement attribute at which allows me to extend the configuration data for my own purposes without modifying the original class library. This is some data This is my data This works well for deserialization. I am able to allow the class library to deserialize the.xml as normal and the I can use my own XmlSerializer instances with a XmlNodeReader against the internal XmlNode. public class Config { [XmlElement] public string data;
[XmlAnyElement] public XmlNode element; }
public class MyConfig { [XmlElement] public string data; }
class Program { static void Main(string[] args) { using (Stream fs = new FileStream(@"c:\temp\xmltest.xml", FileMode.Open)) { XmlSerializer xser1 = new XmlSerializer(typeof(Config)); Config config = (Config)xser1.Deserialize(fs);
if (config.element!= null) { XmlSerializer xser2 = new XmlSerializer(typeof(MyConfig)); MyConfig myConfig = (MyConfig)xser2.Deserialize(new XmlNodeReader(config.element)); } } } I need to create a utility which will allow the user to generate a new configuration file that includes both the class library configuration as well my own configuration, so new objects will be created which were not read from the.xml file. The question is how can I serialize the data back into.xml? I realize that I have to initially call XmlSerializer.Serialize on my data before calling the same method on the class library configuration. However, this requires that my data is represented by an XmlNode after calling Serialize. What is the best way to serialize an object into an XmlNode using the XmlSerializer? Thanks, -kevin btw-- It looks like an XmlNodeWriter class written by Chris Lovett was available at one time from Microsoft, but the links are now broken. Does anyone know of an alternative location to get this class?
ANSWER:
So you need to have your class contain custom configuration information, then serialize that class to XML, then make that serialized XML into an XML node: is that right? Could you just take the string created by the XMLSerializer and wrap that in it's own XML tags? XmlSerializer xs = new XmlSerializer(typeof(MyConfig)); StringWriter xout = new StringWriter(); xs.Serialize(xout, myConfig); XmlDocument x = new XmlDocument(); x.LoadXml(" " + xout.ToString() + " "); Now x is an XmlDocument containing one element, " ", which has your serialized custom configuration in it. Is that at all what you're looking for? | [
"c#",
"xml"
] | 15 | 13 | 21,280 | 4 | 0 | 2008-09-05T16:50:35.973000 | 2008-09-05T17:43:28.387000 |
46,283 | 46,314 | Can a service have multiple endpoints? | We have a service that has some settings that are supported only over net.tcp. What's the best way to add another endpoint? Do I need to create an entire new host? | A service may have multiple endpoints within a single host, but every endpoint must have a unique combination of address, binding and contract. For an IIS-hosted service (that is, an.SVC file), just set the address of the endpoint to a relative URI and make sure that your Visual Studio or wsdl.exe generated client specifies the endpoint's name in its constructor. See also the MSDN article Multiple Endpoints. | Can a service have multiple endpoints? We have a service that has some settings that are supported only over net.tcp. What's the best way to add another endpoint? Do I need to create an entire new host? | TITLE:
Can a service have multiple endpoints?
QUESTION:
We have a service that has some settings that are supported only over net.tcp. What's the best way to add another endpoint? Do I need to create an entire new host?
ANSWER:
A service may have multiple endpoints within a single host, but every endpoint must have a unique combination of address, binding and contract. For an IIS-hosted service (that is, an.SVC file), just set the address of the endpoint to a relative URI and make sure that your Visual Studio or wsdl.exe generated client specifies the endpoint's name in its constructor. See also the MSDN article Multiple Endpoints. | [
".net",
"wcf",
"web-services"
] | 8 | 6 | 23,430 | 4 | 0 | 2008-09-05T16:50:44.847000 | 2008-09-05T17:03:12.633000 |
46,292 | 46,308 | Plug In Design for .NET App | I’m looking at rewriting a portion of our application in C# (currently legacy VB6 code). The module I am starting with is responsible for importing data from a variety of systems into our database. About 5-6 times a year, a new client asks us to write a new import for the system that they use. Presently, this requires us to release a new version of our software for each new import option we add to the application. One of the goals of the rewrite is to make the application support plug-ins. Every new import can become a separate assembly which the host application will recognize and allow the end user to interact with. This will hopefully simplify life to some degree as we can simply drop a new assembly into the directory and have it be recognized and used by the main (host) application. One of the items I am struggling with relates to the differences between the import options we currently support. In some cases we actually let the user point to a directory and read all of the files within the directory into our system. In other cases we allow them to point to a single file and import its contents. Additionally, some imports have a date range restriction that the user applies while others do not. My question is, how can I design the application in a manner that allows for some flexibility among the imports we build and support while at the same time implementing a common interface that will allow the host application to easily recognize the plug-ins and the options that each one exposes to the user? | I would recommend you take a look at the Managed Add-In Framework that shipped with.NET 3.5. The Add-In team has posted some samples and tools at CodePlex site as well.. | Plug In Design for .NET App I’m looking at rewriting a portion of our application in C# (currently legacy VB6 code). The module I am starting with is responsible for importing data from a variety of systems into our database. About 5-6 times a year, a new client asks us to write a new import for the system that they use. Presently, this requires us to release a new version of our software for each new import option we add to the application. One of the goals of the rewrite is to make the application support plug-ins. Every new import can become a separate assembly which the host application will recognize and allow the end user to interact with. This will hopefully simplify life to some degree as we can simply drop a new assembly into the directory and have it be recognized and used by the main (host) application. One of the items I am struggling with relates to the differences between the import options we currently support. In some cases we actually let the user point to a directory and read all of the files within the directory into our system. In other cases we allow them to point to a single file and import its contents. Additionally, some imports have a date range restriction that the user applies while others do not. My question is, how can I design the application in a manner that allows for some flexibility among the imports we build and support while at the same time implementing a common interface that will allow the host application to easily recognize the plug-ins and the options that each one exposes to the user? | TITLE:
Plug In Design for .NET App
QUESTION:
I’m looking at rewriting a portion of our application in C# (currently legacy VB6 code). The module I am starting with is responsible for importing data from a variety of systems into our database. About 5-6 times a year, a new client asks us to write a new import for the system that they use. Presently, this requires us to release a new version of our software for each new import option we add to the application. One of the goals of the rewrite is to make the application support plug-ins. Every new import can become a separate assembly which the host application will recognize and allow the end user to interact with. This will hopefully simplify life to some degree as we can simply drop a new assembly into the directory and have it be recognized and used by the main (host) application. One of the items I am struggling with relates to the differences between the import options we currently support. In some cases we actually let the user point to a directory and read all of the files within the directory into our system. In other cases we allow them to point to a single file and import its contents. Additionally, some imports have a date range restriction that the user applies while others do not. My question is, how can I design the application in a manner that allows for some flexibility among the imports we build and support while at the same time implementing a common interface that will allow the host application to easily recognize the plug-ins and the options that each one exposes to the user?
ANSWER:
I would recommend you take a look at the Managed Add-In Framework that shipped with.NET 3.5. The Add-In team has posted some samples and tools at CodePlex site as well.. | [
".net",
"plugins",
"interface-design"
] | 5 | 3 | 673 | 3 | 0 | 2008-09-05T16:53:13.860000 | 2008-09-05T16:59:46.497000 |
46,305 | 46,313 | Setting Nameservers - how? | I understand how I can change the dns settings for my domains by editing my bind configs, when I run my own name-servers. I know that I can define the name-servers with my registrar via their online control panels. But I have no idea how that part works... How does my registrar store the data about the name-servers? Is it something clever, like them having the authority to store NS records in the root name-servers? I'm confused by this part, can anyone explain? | The registrar is responsible for setting the Root DNS entry that says, "When someone asks for stackoverflow.com, tell them that the authoritative DNS is xxx.xxx.xxx.xxx". They have an interface that allows them to make changes to the records they own. Then the requester must go to the authoritative DNS (Which is the one you specified to your registrar was your DNS) to find the IP for stackoverflow.com, any subdomain of it, email server, and other DNS records pertaining to that domain. -Adam | Setting Nameservers - how? I understand how I can change the dns settings for my domains by editing my bind configs, when I run my own name-servers. I know that I can define the name-servers with my registrar via their online control panels. But I have no idea how that part works... How does my registrar store the data about the name-servers? Is it something clever, like them having the authority to store NS records in the root name-servers? I'm confused by this part, can anyone explain? | TITLE:
Setting Nameservers - how?
QUESTION:
I understand how I can change the dns settings for my domains by editing my bind configs, when I run my own name-servers. I know that I can define the name-servers with my registrar via their online control panels. But I have no idea how that part works... How does my registrar store the data about the name-servers? Is it something clever, like them having the authority to store NS records in the root name-servers? I'm confused by this part, can anyone explain?
ANSWER:
The registrar is responsible for setting the Root DNS entry that says, "When someone asks for stackoverflow.com, tell them that the authoritative DNS is xxx.xxx.xxx.xxx". They have an interface that allows them to make changes to the records they own. Then the requester must go to the authoritative DNS (Which is the one you specified to your registrar was your DNS) to find the IP for stackoverflow.com, any subdomain of it, email server, and other DNS records pertaining to that domain. -Adam | [
"dns",
"config"
] | 3 | 2 | 1,356 | 5 | 0 | 2008-09-05T16:58:59.790000 | 2008-09-05T17:02:17.520000 |
46,324 | 46,448 | Possible to perform cross-database queries with PostgreSQL? | I'm going to guess that the answer is "no" based on the below error message (and this Google result ), but is there anyway to perform a cross-database query using PostgreSQL? databaseA=# select * from databaseB.public.someTableName; ERROR: cross-database references are not implemented: "databaseB.public.someTableName" I'm working with some data that is partitioned across two databases although data is really shared between the two (userid columns in one database come from the users table in the other database). I have no idea why these are two separate databases instead of schema, but c'est la vie... | Note: As the original asker implied, if you are setting up two databases on the same machine you probably want to make two schemas instead - in that case you don't need anything special to query across them. postgres_fdw Use postgres_fdw (foreign data wrapper) to connect to tables in any Postgres database - local or remote. Note that there are foreign data wrappers for other popular data sources. At this time, only postgres_fdw and file_fdw are part of the official Postgres distribution. For Postgres versions before 9.3 Versions this old are no longer supported, but if you need to do this in a pre-2013 Postgres installation, there is a function called dblink. I've never used it, but it is maintained and distributed with the rest of PostgreSQL. If you're using the version of PostgreSQL that came with your Linux distro, you might need to install a package called postgresql-contrib. | Possible to perform cross-database queries with PostgreSQL? I'm going to guess that the answer is "no" based on the below error message (and this Google result ), but is there anyway to perform a cross-database query using PostgreSQL? databaseA=# select * from databaseB.public.someTableName; ERROR: cross-database references are not implemented: "databaseB.public.someTableName" I'm working with some data that is partitioned across two databases although data is really shared between the two (userid columns in one database come from the users table in the other database). I have no idea why these are two separate databases instead of schema, but c'est la vie... | TITLE:
Possible to perform cross-database queries with PostgreSQL?
QUESTION:
I'm going to guess that the answer is "no" based on the below error message (and this Google result ), but is there anyway to perform a cross-database query using PostgreSQL? databaseA=# select * from databaseB.public.someTableName; ERROR: cross-database references are not implemented: "databaseB.public.someTableName" I'm working with some data that is partitioned across two databases although data is really shared between the two (userid columns in one database come from the users table in the other database). I have no idea why these are two separate databases instead of schema, but c'est la vie...
ANSWER:
Note: As the original asker implied, if you are setting up two databases on the same machine you probably want to make two schemas instead - in that case you don't need anything special to query across them. postgres_fdw Use postgres_fdw (foreign data wrapper) to connect to tables in any Postgres database - local or remote. Note that there are foreign data wrappers for other popular data sources. At this time, only postgres_fdw and file_fdw are part of the official Postgres distribution. For Postgres versions before 9.3 Versions this old are no longer supported, but if you need to do this in a pre-2013 Postgres installation, there is a function called dblink. I've never used it, but it is maintained and distributed with the rest of PostgreSQL. If you're using the version of PostgreSQL that came with your Linux distro, you might need to install a package called postgresql-contrib. | [
"sql",
"postgresql"
] | 216 | 165 | 354,408 | 10 | 0 | 2008-09-05T17:09:13.853000 | 2008-09-05T18:10:20.070000 |
46,332 | 46,583 | How to organize a complex Flash project | Let's compile a list of tips. (Understandably there will be some subjectivity involved, but some pointers would be useful to someone overwhelmed by tackling a large project within the Flash framework.) | These are just scattered thoughts on organization for projects being worked on mostly with the Flash IDE. First, I highly recommend using source control, like Subversion, CVS, or Git. Organization of filesystem folder structure is subjective, but I generally have a "src" folder for all my source FLAs and AS class files, and a "deploy" or "bin" folder for compiled files. The src folder would contain class package files, with class packages organized in reverse domain style (e.g. - com.codehinting.projectname.context ). Modify the publish path of your FLA to publish to the deploy folder by tracing back up using the "../" path segment, for as many levels as needed to trace back from the nesting in the src folder. Also, I typically place third-party libraries (that are pretty well "baked") in a separate location and then modify the global classpath in the Flash IDE to point to this location. Two extremely handy plugins for the Flash IDE are Create Basic Layers and Library Generator, which quickly create your skeleton layer and library folder structure - saves time versus manually creating layers and folders. | How to organize a complex Flash project Let's compile a list of tips. (Understandably there will be some subjectivity involved, but some pointers would be useful to someone overwhelmed by tackling a large project within the Flash framework.) | TITLE:
How to organize a complex Flash project
QUESTION:
Let's compile a list of tips. (Understandably there will be some subjectivity involved, but some pointers would be useful to someone overwhelmed by tackling a large project within the Flash framework.)
ANSWER:
These are just scattered thoughts on organization for projects being worked on mostly with the Flash IDE. First, I highly recommend using source control, like Subversion, CVS, or Git. Organization of filesystem folder structure is subjective, but I generally have a "src" folder for all my source FLAs and AS class files, and a "deploy" or "bin" folder for compiled files. The src folder would contain class package files, with class packages organized in reverse domain style (e.g. - com.codehinting.projectname.context ). Modify the publish path of your FLA to publish to the deploy folder by tracing back up using the "../" path segment, for as many levels as needed to trace back from the nesting in the src folder. Also, I typically place third-party libraries (that are pretty well "baked") in a separate location and then modify the global classpath in the Flash IDE to point to this location. Two extremely handy plugins for the Flash IDE are Create Basic Layers and Library Generator, which quickly create your skeleton layer and library folder structure - saves time versus manually creating layers and folders. | [
"actionscript-3",
"flash"
] | 5 | 2 | 4,192 | 3 | 0 | 2008-09-05T17:15:51.997000 | 2008-09-05T19:04:26.197000 |
46,338 | 46,356 | Can you access a model from inside another model in CodeIgniter? | I am writing a webapp using CodeIgniter that requires authentication. I created a model which handles all my authentication. However, I can't find a way to access this authentication model from inside another model. Is there a way to access a model from inside another mode, or a better way to handle authentication inside CodeIgniter? | In general, you don't want to create objects inside an object. That's a bad habit, instead, write a clear API and inject a model into your model. setWhatever($model1);?> | Can you access a model from inside another model in CodeIgniter? I am writing a webapp using CodeIgniter that requires authentication. I created a model which handles all my authentication. However, I can't find a way to access this authentication model from inside another model. Is there a way to access a model from inside another mode, or a better way to handle authentication inside CodeIgniter? | TITLE:
Can you access a model from inside another model in CodeIgniter?
QUESTION:
I am writing a webapp using CodeIgniter that requires authentication. I created a model which handles all my authentication. However, I can't find a way to access this authentication model from inside another model. Is there a way to access a model from inside another mode, or a better way to handle authentication inside CodeIgniter?
ANSWER:
In general, you don't want to create objects inside an object. That's a bad habit, instead, write a clear API and inject a model into your model. setWhatever($model1);?> | [
"php",
"codeigniter",
"authentication",
"model"
] | 20 | 14 | 21,568 | 4 | 0 | 2008-09-05T17:18:55.983000 | 2008-09-05T17:26:45.090000 |
46,346 | 46,396 | .NET Console Application Tab Completion | Any ideas on how to implement tab completion for a.NET (C#) Console Application? And I mean within an application that is run and then loops for user input (like if you run ftp.exe without any arguments), like this: string line = string.Empty; while (line!= "exit") { //do something here Console.ReadLine(); } I know I probably couldn't actually use readline, but I would like to be able to do tab completion at that same point where you retrieve input from the user. | Take a look at this code from the Mono project http://tirania.org/blog/archive/2008/Aug-26.html I played with it some the other day. It does a lot of command line editingy, but I don't think it does line completion. | .NET Console Application Tab Completion Any ideas on how to implement tab completion for a.NET (C#) Console Application? And I mean within an application that is run and then loops for user input (like if you run ftp.exe without any arguments), like this: string line = string.Empty; while (line!= "exit") { //do something here Console.ReadLine(); } I know I probably couldn't actually use readline, but I would like to be able to do tab completion at that same point where you retrieve input from the user. | TITLE:
.NET Console Application Tab Completion
QUESTION:
Any ideas on how to implement tab completion for a.NET (C#) Console Application? And I mean within an application that is run and then loops for user input (like if you run ftp.exe without any arguments), like this: string line = string.Empty; while (line!= "exit") { //do something here Console.ReadLine(); } I know I probably couldn't actually use readline, but I would like to be able to do tab completion at that same point where you retrieve input from the user.
ANSWER:
Take a look at this code from the Mono project http://tirania.org/blog/archive/2008/Aug-26.html I played with it some the other day. It does a lot of command line editingy, but I don't think it does line completion. | [
".net",
"console"
] | 17 | 6 | 7,016 | 5 | 0 | 2008-09-05T17:22:53.850000 | 2008-09-05T17:49:20.963000 |
46,350 | 46,391 | Center a block of content when you don't know its width in advance | After lots of attempts and search I have never found a satisfactory way to do it with CSS2. A simple way to accomplish it is to wrap it into a handy as shown in the sample below. Do you know how to do it avoiding table layouts and also avoiding quirky tricks? table { margin: 0 auto; } test test What I want to know is how to do it without a fixed width and also being a block. | @Jason, yep, works. Good times. I'll propose the following, though: body {
text-align: center;
}.my-centered-content {
margin: 0 auto; /* Centering */
display: inline;
} test test EDIT @Santi, a block-level element will fill the width of the parent container, so it will effectively be width:100% and the text will flow on the left, leaving you with useless markup and an uncentered element. You might want to try display: inline-block;. Firefox might complain, but it's right. Also, try adding a border: solid red 1px; to the CSS of the.my-centered-content DIV to see what's happening as you try these things out. | Center a block of content when you don't know its width in advance After lots of attempts and search I have never found a satisfactory way to do it with CSS2. A simple way to accomplish it is to wrap it into a handy as shown in the sample below. Do you know how to do it avoiding table layouts and also avoiding quirky tricks? table { margin: 0 auto; } test test What I want to know is how to do it without a fixed width and also being a block. | TITLE:
Center a block of content when you don't know its width in advance
QUESTION:
After lots of attempts and search I have never found a satisfactory way to do it with CSS2. A simple way to accomplish it is to wrap it into a handy as shown in the sample below. Do you know how to do it avoiding table layouts and also avoiding quirky tricks? table { margin: 0 auto; } test test What I want to know is how to do it without a fixed width and also being a block.
ANSWER:
@Jason, yep, works. Good times. I'll propose the following, though: body {
text-align: center;
}.my-centered-content {
margin: 0 auto; /* Centering */
display: inline;
} test test EDIT @Santi, a block-level element will fill the width of the parent container, so it will effectively be width:100% and the text will flow on the left, leaving you with useless markup and an uncentered element. You might want to try display: inline-block;. Firefox might complain, but it's right. Also, try adding a border: solid red 1px; to the CSS of the.my-centered-content DIV to see what's happening as you try these things out. | [
"html",
"css"
] | 8 | 9 | 4,356 | 6 | 0 | 2008-09-05T17:24:42.457000 | 2008-09-05T17:48:53.913000 |
46,354 | 46,382 | "Invalid column name" error on SQL statement from OpenQuery results | I'm trying to perform a SQL query through a linked SSAS server. The initial query works fine: SELECT "Ugly OLAP name" as "Value" FROM OpenQuery( OLAP, 'OLAP Query') But if I try to add: WHERE "Value" > 0 I get an error Invalid column name 'Value' Any ideas what I might be doing wrong? So the problem was that the order in which elements of the query are processed are different that the order they are written. According to this source: http://blogs.x2line.com/al/archive/2007/06/30/3187.aspx The order of evaluation in MSSQL is: FROM ON JOIN WHERE GROUP BY HAVING SELECT ORDER BY So the alias wasn't processed until after the WHERE and HAVING clauses. | This should work: SELECT A.Value FROM ( SELECT "Ugly OLAP name" as "Value" FROM OpenQuery( OLAP, 'OLAP Query') ) AS a WHERE a.Value > 0 It's not that Value is a reserved word, the problem is that it's a column alias, not the column name. By making it an inline view, "Value" becomes the column name and can then be used in a where clause. | "Invalid column name" error on SQL statement from OpenQuery results I'm trying to perform a SQL query through a linked SSAS server. The initial query works fine: SELECT "Ugly OLAP name" as "Value" FROM OpenQuery( OLAP, 'OLAP Query') But if I try to add: WHERE "Value" > 0 I get an error Invalid column name 'Value' Any ideas what I might be doing wrong? So the problem was that the order in which elements of the query are processed are different that the order they are written. According to this source: http://blogs.x2line.com/al/archive/2007/06/30/3187.aspx The order of evaluation in MSSQL is: FROM ON JOIN WHERE GROUP BY HAVING SELECT ORDER BY So the alias wasn't processed until after the WHERE and HAVING clauses. | TITLE:
"Invalid column name" error on SQL statement from OpenQuery results
QUESTION:
I'm trying to perform a SQL query through a linked SSAS server. The initial query works fine: SELECT "Ugly OLAP name" as "Value" FROM OpenQuery( OLAP, 'OLAP Query') But if I try to add: WHERE "Value" > 0 I get an error Invalid column name 'Value' Any ideas what I might be doing wrong? So the problem was that the order in which elements of the query are processed are different that the order they are written. According to this source: http://blogs.x2line.com/al/archive/2007/06/30/3187.aspx The order of evaluation in MSSQL is: FROM ON JOIN WHERE GROUP BY HAVING SELECT ORDER BY So the alias wasn't processed until after the WHERE and HAVING clauses.
ANSWER:
This should work: SELECT A.Value FROM ( SELECT "Ugly OLAP name" as "Value" FROM OpenQuery( OLAP, 'OLAP Query') ) AS a WHERE a.Value > 0 It's not that Value is a reserved word, the problem is that it's a column alias, not the column name. By making it an inline view, "Value" becomes the column name and can then be used in a where clause. | [
"sql",
"sql-server"
] | 21 | 17 | 85,197 | 4 | 0 | 2008-09-05T17:26:38.367000 | 2008-09-05T17:45:43.983000 |
46,377 | 46,384 | How do I specify multiple constraints on a generic type in C#? | What is the syntax for placing constraints on multiple types? The basic example: class Animal where SpeciesType: Species I would like to place constraints on both types in the following definition such that SpeciesType must inherit from Species and OrderType must inherit from Order: class Animal | public class Animal where SpeciesType: Species where OrderType: Order { } | How do I specify multiple constraints on a generic type in C#? What is the syntax for placing constraints on multiple types? The basic example: class Animal where SpeciesType: Species I would like to place constraints on both types in the following definition such that SpeciesType must inherit from Species and OrderType must inherit from Order: class Animal | TITLE:
How do I specify multiple constraints on a generic type in C#?
QUESTION:
What is the syntax for placing constraints on multiple types? The basic example: class Animal where SpeciesType: Species I would like to place constraints on both types in the following definition such that SpeciesType must inherit from Species and OrderType must inherit from Order: class Animal
ANSWER:
public class Animal where SpeciesType: Species where OrderType: Order { } | [
"c#",
".net",
"oop",
"generics",
"type-constraints"
] | 33 | 60 | 9,774 | 2 | 0 | 2008-09-05T17:43:03.473000 | 2008-09-05T17:46:13.810000 |
46,380 | 46,400 | Why doesn't Oracle tell you WHICH table or view does not exist? | If you've used Oracle, you've probably gotten the helpful message "ORA-00942: Table or view does not exist". Is there a legitimate technical reason the message doesn't include the name of the missing object? Arguments about this being due to security sound like they were crafted by the TSA. If I'm an attacker, I'd know what table I just attempted to exploit, and be able to interpret this unhelpful message easily. If I'm a developer working with a complex join through several layers of application code, it's often very difficult to tell. My guess is that when this error was originally implemented, someone neglected to add the object name, and now, people are afraid it will break compatibility to fix it. (Code doing silly things like parsing the error message will be confused if it changes.) Is there a developer-friendly (as opposed to recruiting your DBA) way to determine the name of the missing table? Although I've accepted an answer which is relevant to the topic, it doesn't really answer my question: Why isn't the name part of the error message? If anyone can come up with the real answer, I'll be happy to change my vote. | You can set an EVENT in your parameter file (plain text or spfile) to force Oracle to dump a detailed trace file in the user_dump_dest, the object name might be in there, if not the SQL should be. EVENT="942 trace name errorstack level 12" If you are using a plain text file you need to keep all your EVENT settings on consecutive lines. Not sure how that applied to spfile. | Why doesn't Oracle tell you WHICH table or view does not exist? If you've used Oracle, you've probably gotten the helpful message "ORA-00942: Table or view does not exist". Is there a legitimate technical reason the message doesn't include the name of the missing object? Arguments about this being due to security sound like they were crafted by the TSA. If I'm an attacker, I'd know what table I just attempted to exploit, and be able to interpret this unhelpful message easily. If I'm a developer working with a complex join through several layers of application code, it's often very difficult to tell. My guess is that when this error was originally implemented, someone neglected to add the object name, and now, people are afraid it will break compatibility to fix it. (Code doing silly things like parsing the error message will be confused if it changes.) Is there a developer-friendly (as opposed to recruiting your DBA) way to determine the name of the missing table? Although I've accepted an answer which is relevant to the topic, it doesn't really answer my question: Why isn't the name part of the error message? If anyone can come up with the real answer, I'll be happy to change my vote. | TITLE:
Why doesn't Oracle tell you WHICH table or view does not exist?
QUESTION:
If you've used Oracle, you've probably gotten the helpful message "ORA-00942: Table or view does not exist". Is there a legitimate technical reason the message doesn't include the name of the missing object? Arguments about this being due to security sound like they were crafted by the TSA. If I'm an attacker, I'd know what table I just attempted to exploit, and be able to interpret this unhelpful message easily. If I'm a developer working with a complex join through several layers of application code, it's often very difficult to tell. My guess is that when this error was originally implemented, someone neglected to add the object name, and now, people are afraid it will break compatibility to fix it. (Code doing silly things like parsing the error message will be confused if it changes.) Is there a developer-friendly (as opposed to recruiting your DBA) way to determine the name of the missing table? Although I've accepted an answer which is relevant to the topic, it doesn't really answer my question: Why isn't the name part of the error message? If anyone can come up with the real answer, I'll be happy to change my vote.
ANSWER:
You can set an EVENT in your parameter file (plain text or spfile) to force Oracle to dump a detailed trace file in the user_dump_dest, the object name might be in there, if not the SQL should be. EVENT="942 trace name errorstack level 12" If you are using a plain text file you need to keep all your EVENT settings on consecutive lines. Not sure how that applied to spfile. | [
"sql",
"database",
"oracle",
"ora-00942"
] | 66 | 14 | 24,245 | 8 | 0 | 2008-09-05T17:45:02.223000 | 2008-09-05T17:51:57.167000 |
46,385 | 46,386 | Delete all but top n from database table in SQL | What's the best way to delete all rows from a table in sql but to keep n number of rows on the top? | DELETE FROM Table WHERE ID NOT IN (SELECT TOP 10 ID FROM Table) Edit: Chris brings up a good performance hit since the TOP 10 query would be run for each row. If this is a one time thing, then it may not be as big of a deal, but if it is a common thing, then I did look closer at it. | Delete all but top n from database table in SQL What's the best way to delete all rows from a table in sql but to keep n number of rows on the top? | TITLE:
Delete all but top n from database table in SQL
QUESTION:
What's the best way to delete all rows from a table in sql but to keep n number of rows on the top?
ANSWER:
DELETE FROM Table WHERE ID NOT IN (SELECT TOP 10 ID FROM Table) Edit: Chris brings up a good performance hit since the TOP 10 query would be run for each row. If this is a one time thing, then it may not be as big of a deal, but if it is a common thing, then I did look closer at it. | [
"sql"
] | 98 | 94 | 108,163 | 11 | 0 | 2008-09-05T17:46:33.607000 | 2008-09-05T17:47:34.073000 |
46,387 | 46,405 | How to get the correct Content-Length for a POST request | I am using a perl script to POST to Google Appengine application. I post a text file containing some XML using the -F option. http://www.cpan.org/authors/id/E/EL/ELIJAH/bget-1.1 There is a version 1.2, already tested and get the same issue. The post looks something like this. Host: foo.appspot.com User-Agent: lwp-request/1.38 Content-Type: text/plain Content-Length: 202 Hello World I have modified the example so the 202 isn't right, don't worry about that. On to the problem. The Content-Length matches the number of bytes on the file, however unless I manually increase the Content-Length it does not send all of the file, a few bytes get truncated. The number of bytes truncated is not the same for files of different sizes. I used the -r option on the script and I can see what it is sending and it is sending all of the file, but Google Appengine self.request.body shows that not everything is received. I think the solution is to get the right number for Content-Length and apparently it isn't as simple as number of bytes on the file or the perl script is mangling it somehow. Update: Thanks to Erickson for the right answer. I used printf to append characters to the end of the file and it always truncated exactly the number of lines in the file. I suppose I could figure out what is being added by iterating through every character on the server side but not worth it. This wasn't even answered over on the google groups set up for app engine! | Is the number of extra bytes you need equal to the number of lines in the file? I ask because perhaps its possible that somehow carriage-returns are being introduced but not counted. | How to get the correct Content-Length for a POST request I am using a perl script to POST to Google Appengine application. I post a text file containing some XML using the -F option. http://www.cpan.org/authors/id/E/EL/ELIJAH/bget-1.1 There is a version 1.2, already tested and get the same issue. The post looks something like this. Host: foo.appspot.com User-Agent: lwp-request/1.38 Content-Type: text/plain Content-Length: 202 Hello World I have modified the example so the 202 isn't right, don't worry about that. On to the problem. The Content-Length matches the number of bytes on the file, however unless I manually increase the Content-Length it does not send all of the file, a few bytes get truncated. The number of bytes truncated is not the same for files of different sizes. I used the -r option on the script and I can see what it is sending and it is sending all of the file, but Google Appengine self.request.body shows that not everything is received. I think the solution is to get the right number for Content-Length and apparently it isn't as simple as number of bytes on the file or the perl script is mangling it somehow. Update: Thanks to Erickson for the right answer. I used printf to append characters to the end of the file and it always truncated exactly the number of lines in the file. I suppose I could figure out what is being added by iterating through every character on the server side but not worth it. This wasn't even answered over on the google groups set up for app engine! | TITLE:
How to get the correct Content-Length for a POST request
QUESTION:
I am using a perl script to POST to Google Appengine application. I post a text file containing some XML using the -F option. http://www.cpan.org/authors/id/E/EL/ELIJAH/bget-1.1 There is a version 1.2, already tested and get the same issue. The post looks something like this. Host: foo.appspot.com User-Agent: lwp-request/1.38 Content-Type: text/plain Content-Length: 202 Hello World I have modified the example so the 202 isn't right, don't worry about that. On to the problem. The Content-Length matches the number of bytes on the file, however unless I manually increase the Content-Length it does not send all of the file, a few bytes get truncated. The number of bytes truncated is not the same for files of different sizes. I used the -r option on the script and I can see what it is sending and it is sending all of the file, but Google Appengine self.request.body shows that not everything is received. I think the solution is to get the right number for Content-Length and apparently it isn't as simple as number of bytes on the file or the perl script is mangling it somehow. Update: Thanks to Erickson for the right answer. I used printf to append characters to the end of the file and it always truncated exactly the number of lines in the file. I suppose I could figure out what is being added by iterating through every character on the server side but not worth it. This wasn't even answered over on the google groups set up for app engine!
ANSWER:
Is the number of extra bytes you need equal to the number of lines in the file? I ask because perhaps its possible that somehow carriage-returns are being introduced but not counted. | [
"perl",
"google-app-engine",
"https"
] | 3 | 3 | 7,233 | 3 | 0 | 2008-09-05T17:48:00.467000 | 2008-09-05T17:53:02.873000 |
46,389 | 46,966 | How to export findbugs results from Eclipse findbugs plugin? | I have findbugs plugin for eclipse which when run on my project will show results in Bugs explorer clubbed by the type of bug. I need to be able to do two things: Export all these to excel sheet Find out the bugs reported in a set of files (and be able to do it recursively w/o running for whole project and exporting and finding out the classes to be modified. Any suggestions? FYI, I am using MyEclipse v 6.0.1 and FindBugs 1.3.4 | Findbugs dumps its results into an XML file in your workspace's.metadata folder. Look for the subfolder that's named something like findbugs. You can also download a standalone version of Findbugs that will save the results wherever you like. Once you have the results file, you might be able to import from XML to Excel and filter there. Alternatively, you can use XSLT to transform to several CSV files and open them in Excel. | How to export findbugs results from Eclipse findbugs plugin? I have findbugs plugin for eclipse which when run on my project will show results in Bugs explorer clubbed by the type of bug. I need to be able to do two things: Export all these to excel sheet Find out the bugs reported in a set of files (and be able to do it recursively w/o running for whole project and exporting and finding out the classes to be modified. Any suggestions? FYI, I am using MyEclipse v 6.0.1 and FindBugs 1.3.4 | TITLE:
How to export findbugs results from Eclipse findbugs plugin?
QUESTION:
I have findbugs plugin for eclipse which when run on my project will show results in Bugs explorer clubbed by the type of bug. I need to be able to do two things: Export all these to excel sheet Find out the bugs reported in a set of files (and be able to do it recursively w/o running for whole project and exporting and finding out the classes to be modified. Any suggestions? FYI, I am using MyEclipse v 6.0.1 and FindBugs 1.3.4
ANSWER:
Findbugs dumps its results into an XML file in your workspace's.metadata folder. Look for the subfolder that's named something like findbugs. You can also download a standalone version of Findbugs that will save the results wherever you like. Once you have the results file, you might be able to import from XML to Excel and filter there. Alternatively, you can use XSLT to transform to several CSV files and open them in Excel. | [
"java",
"eclipse-plugin",
"findbugs"
] | 7 | 7 | 14,312 | 2 | 0 | 2008-09-05T17:48:28.470000 | 2008-09-05T21:49:12.383000 |
46,394 | 46,410 | Automatic Timeout Web Client Use | One of the problems I have come across having complex tasks on the browser is with automatic timeouts. Currently our site has a sliding expiration of 30 minutes. Normally, this isn't a problem because we use asp.net and most of the time the users update one or two fields and then submit the form. This obviously keeps the session active. I have struggled with how to handle this with significantly more complex forms/user interaction where there are few if no round trips to the server. Now users can view reports, type emails etc. on our site, and I am struggling with how to keep their session active while they're actually using browser but they are not actively posting information back. I would dispense with the sliding expiration, but it's a requirement, so I am stuck with it. Most of our users are outside of the organization, so I can't use any form of SSO. Does anyone have an elegant solution (I'll even go for an ugly one if it works), or am I out of luck? | We recently went through this in my organization. Although it is not the best solution, and hitting the right session across multiple browser windows is rough, we put a countdown timer on our page, included a button that just went back and hit the server to restart the session, and also provided the user with a JavaScript popup (the user's favorite part of the solution) with a message saying that the session was, say, five minutes from timing out and to hit the "OK" button to restart. Then the button would hit the server to restart the session, restart the timer on the base page, close the popup and the base page didn't need to be refreshed at all. | Automatic Timeout Web Client Use One of the problems I have come across having complex tasks on the browser is with automatic timeouts. Currently our site has a sliding expiration of 30 minutes. Normally, this isn't a problem because we use asp.net and most of the time the users update one or two fields and then submit the form. This obviously keeps the session active. I have struggled with how to handle this with significantly more complex forms/user interaction where there are few if no round trips to the server. Now users can view reports, type emails etc. on our site, and I am struggling with how to keep their session active while they're actually using browser but they are not actively posting information back. I would dispense with the sliding expiration, but it's a requirement, so I am stuck with it. Most of our users are outside of the organization, so I can't use any form of SSO. Does anyone have an elegant solution (I'll even go for an ugly one if it works), or am I out of luck? | TITLE:
Automatic Timeout Web Client Use
QUESTION:
One of the problems I have come across having complex tasks on the browser is with automatic timeouts. Currently our site has a sliding expiration of 30 minutes. Normally, this isn't a problem because we use asp.net and most of the time the users update one or two fields and then submit the form. This obviously keeps the session active. I have struggled with how to handle this with significantly more complex forms/user interaction where there are few if no round trips to the server. Now users can view reports, type emails etc. on our site, and I am struggling with how to keep their session active while they're actually using browser but they are not actively posting information back. I would dispense with the sliding expiration, but it's a requirement, so I am stuck with it. Most of our users are outside of the organization, so I can't use any form of SSO. Does anyone have an elegant solution (I'll even go for an ugly one if it works), or am I out of luck?
ANSWER:
We recently went through this in my organization. Although it is not the best solution, and hitting the right session across multiple browser windows is rough, we put a countdown timer on our page, included a button that just went back and hit the server to restart the session, and also provided the user with a JavaScript popup (the user's favorite part of the solution) with a message saying that the session was, say, five minutes from timing out and to hit the "OK" button to restart. Then the button would hit the server to restart the session, restart the timer on the base page, close the popup and the base page didn't need to be refreshed at all. | [
"c#",
"asp.net"
] | 0 | 2 | 613 | 4 | 0 | 2008-09-05T17:49:11.713000 | 2008-09-05T17:54:38.657000 |
46,415 | 46,461 | Passing untampered data from Flash app to server? | I'm looking for secure ways to pass data between a client running Flash and a server. The data in question will be generated BY the Flash app, which in this case is your score after finishing a game. I want to verify the data is untampered on the server. What are some good methods of getting this done? One simple way is to perform some operations on the data such as a hash, and pass the hash back to the server along with the data. This is easily broken by someone with access to the client source code, however. Edit: I realize that nothing will be unhackable, but I want to make it as difficult as possible. @jcnnghm's solution of encryping data with a public key and optionally doing sanity-checks and/or recalculation with the game logs is the best option I think. SSL encryption is also a good idea as this makes it more difficult to decipher what's actually being sent back to the server. | Encrypt the data with a public key stored in the binary. This will raise the barrier of entry for an attack. In addition to that, sanity check the data as it arrives on the server. This could be as simple as calculating the maximum number of points that could realistically be earned per time unit of play, or transmitting game logs back to the server to make sure the scoring is correct. Nothing is going to be totally hack proof, no matter what you do, but this will stop all but the most determined. Update: @mark: Flash supports SSL natively. | Passing untampered data from Flash app to server? I'm looking for secure ways to pass data between a client running Flash and a server. The data in question will be generated BY the Flash app, which in this case is your score after finishing a game. I want to verify the data is untampered on the server. What are some good methods of getting this done? One simple way is to perform some operations on the data such as a hash, and pass the hash back to the server along with the data. This is easily broken by someone with access to the client source code, however. Edit: I realize that nothing will be unhackable, but I want to make it as difficult as possible. @jcnnghm's solution of encryping data with a public key and optionally doing sanity-checks and/or recalculation with the game logs is the best option I think. SSL encryption is also a good idea as this makes it more difficult to decipher what's actually being sent back to the server. | TITLE:
Passing untampered data from Flash app to server?
QUESTION:
I'm looking for secure ways to pass data between a client running Flash and a server. The data in question will be generated BY the Flash app, which in this case is your score after finishing a game. I want to verify the data is untampered on the server. What are some good methods of getting this done? One simple way is to perform some operations on the data such as a hash, and pass the hash back to the server along with the data. This is easily broken by someone with access to the client source code, however. Edit: I realize that nothing will be unhackable, but I want to make it as difficult as possible. @jcnnghm's solution of encryping data with a public key and optionally doing sanity-checks and/or recalculation with the game logs is the best option I think. SSL encryption is also a good idea as this makes it more difficult to decipher what's actually being sent back to the server.
ANSWER:
Encrypt the data with a public key stored in the binary. This will raise the barrier of entry for an attack. In addition to that, sanity check the data as it arrives on the server. This could be as simple as calculating the maximum number of points that could realistically be earned per time unit of play, or transmitting game logs back to the server to make sure the scoring is correct. Nothing is going to be totally hack proof, no matter what you do, but this will stop all but the most determined. Update: @mark: Flash supports SSL natively. | [
"flash",
"security",
"encryption"
] | 2 | 3 | 3,385 | 5 | 0 | 2008-09-05T17:56:00.730000 | 2008-09-05T18:16:27.857000 |
46,425 | 46,437 | Lisp list iteration | I have a function that gets x(a value) and xs(a list) and removes all values that are bigger than x from the list. Well it doesn't work, can you tell me why? (defun biggerElems(x xs) (let ((xst)) (dolist (elem xs) (if (> x elem) (setf xst (remove elem xs)))) xst)) | I think it's this line that's not right: (setf xst (remove elem xs)))) The first argument to setf is the place, followed by the value. It looks like you have it backwards (and xst is either nil or uninitialized). You might find it easier to do this: (defun biggerElems (x xs) (remove-if (lambda (item) (> item x)) xs)) | Lisp list iteration I have a function that gets x(a value) and xs(a list) and removes all values that are bigger than x from the list. Well it doesn't work, can you tell me why? (defun biggerElems(x xs) (let ((xst)) (dolist (elem xs) (if (> x elem) (setf xst (remove elem xs)))) xst)) | TITLE:
Lisp list iteration
QUESTION:
I have a function that gets x(a value) and xs(a list) and removes all values that are bigger than x from the list. Well it doesn't work, can you tell me why? (defun biggerElems(x xs) (let ((xst)) (dolist (elem xs) (if (> x elem) (setf xst (remove elem xs)))) xst))
ANSWER:
I think it's this line that's not right: (setf xst (remove elem xs)))) The first argument to setf is the place, followed by the value. It looks like you have it backwards (and xst is either nil or uninitialized). You might find it easier to do this: (defun biggerElems (x xs) (remove-if (lambda (item) (> item x)) xs)) | [
"lisp",
"list",
"iteration"
] | 4 | 5 | 3,374 | 6 | 0 | 2008-09-05T17:59:01.237000 | 2008-09-05T18:06:23.810000 |
46,454 | 50,264 | WebBrowserControl Scroll to Bottom | I am working on a simple chat application using a System.Windows.Forms.WebBrowser Control to display the messages between the user and the recipient. How do I get the control to automatically scroll to the bottom every time I update the DocumentText of the control? | Thanks guys -- I voted you both up but neither would work out for my situation. What I ended up doing was webCtrl.Document.Window.ScrollTo(0, int.MaxValue); | WebBrowserControl Scroll to Bottom I am working on a simple chat application using a System.Windows.Forms.WebBrowser Control to display the messages between the user and the recipient. How do I get the control to automatically scroll to the bottom every time I update the DocumentText of the control? | TITLE:
WebBrowserControl Scroll to Bottom
QUESTION:
I am working on a simple chat application using a System.Windows.Forms.WebBrowser Control to display the messages between the user and the recipient. How do I get the control to automatically scroll to the bottom every time I update the DocumentText of the control?
ANSWER:
Thanks guys -- I voted you both up but neither would work out for my situation. What I ended up doing was webCtrl.Document.Window.ScrollTo(0, int.MaxValue); | [
".net",
"user-controls",
"wysiwyg"
] | 2 | 5 | 9,163 | 5 | 0 | 2008-09-05T18:12:31.390000 | 2008-09-08T17:41:40.660000 |
46,482 | 46,526 | Read Access File into a DataSet | Is there an easy way to read an entire Access file (.mdb) into a DataSet in.NET (specifically C# or VB)? Or at least to get a list of tables from an access file so that I can loop through it and add them one at a time into a DataSet? | Thanks for the suggestions. I was able to use those samples to put together this code, which seems to achieve what I'm looking for. Using cn = New OleDbConnection(connectionstring) cn.Open() Dim ds As DataSet = new DataSet()
Dim Schema As DataTable = cn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, New Object() {Nothing, Nothing, Nothing, "TABLE"}) For i As Integer = 0 To Schema.Rows.Count - 1 Dim dt As DataTable = New DataTable(Schema.Rows(i)!TABLE_NAME.ToString())
Using adapter = New OleDbDataAdapter("SELECT * FROM " + Schema.Rows(i)!TABLE_NAME.ToString(), cn) adapter.Fill(dt) End Using
ds.Tables.Add(dt) Next i End Using | Read Access File into a DataSet Is there an easy way to read an entire Access file (.mdb) into a DataSet in.NET (specifically C# or VB)? Or at least to get a list of tables from an access file so that I can loop through it and add them one at a time into a DataSet? | TITLE:
Read Access File into a DataSet
QUESTION:
Is there an easy way to read an entire Access file (.mdb) into a DataSet in.NET (specifically C# or VB)? Or at least to get a list of tables from an access file so that I can loop through it and add them one at a time into a DataSet?
ANSWER:
Thanks for the suggestions. I was able to use those samples to put together this code, which seems to achieve what I'm looking for. Using cn = New OleDbConnection(connectionstring) cn.Open() Dim ds As DataSet = new DataSet()
Dim Schema As DataTable = cn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, New Object() {Nothing, Nothing, Nothing, "TABLE"}) For i As Integer = 0 To Schema.Rows.Count - 1 Dim dt As DataTable = New DataTable(Schema.Rows(i)!TABLE_NAME.ToString())
Using adapter = New OleDbDataAdapter("SELECT * FROM " + Schema.Rows(i)!TABLE_NAME.ToString(), cn) adapter.Fill(dt) End Using
ds.Tables.Add(dt) Next i End Using | [
".net",
"ms-access",
"dataset"
] | 2 | 5 | 7,191 | 5 | 0 | 2008-09-05T18:29:04.863000 | 2008-09-05T18:40:24.960000 |
46,483 | 46,491 | htmlentities() vs. htmlspecialchars() | What are the differences between htmlspecialchars() and htmlentities(). When should I use one or the other? | From the PHP documentation for htmlentities: This function is identical to htmlspecialchars() in all ways, except with htmlentities(), all characters which have HTML character entity equivalents are translated into these entities. From the PHP documentation for htmlspecialchars: Certain characters have special significance in HTML, and should be represented by HTML entities if they are to preserve their meanings. This function returns a string with some of these conversions made; the translations made are those most useful for everyday web programming. If you require all HTML character entities to be translated, use htmlentities() instead. The difference is what gets encoded. The choices are everything (entities) or "special" characters, like ampersand, double and single quotes, less than, and greater than (specialchars). I prefer to use htmlspecialchars whenever possible. For example: echo htmlentities('.'); // Output: <Il était une fois un être>. // ^^^^^^^^ ^^^^^^^
echo htmlspecialchars('.'); // Output: <Il était une fois un être>. // ^ ^ | htmlentities() vs. htmlspecialchars() What are the differences between htmlspecialchars() and htmlentities(). When should I use one or the other? | TITLE:
htmlentities() vs. htmlspecialchars()
QUESTION:
What are the differences between htmlspecialchars() and htmlentities(). When should I use one or the other?
ANSWER:
From the PHP documentation for htmlentities: This function is identical to htmlspecialchars() in all ways, except with htmlentities(), all characters which have HTML character entity equivalents are translated into these entities. From the PHP documentation for htmlspecialchars: Certain characters have special significance in HTML, and should be represented by HTML entities if they are to preserve their meanings. This function returns a string with some of these conversions made; the translations made are those most useful for everyday web programming. If you require all HTML character entities to be translated, use htmlentities() instead. The difference is what gets encoded. The choices are everything (entities) or "special" characters, like ampersand, double and single quotes, less than, and greater than (specialchars). I prefer to use htmlspecialchars whenever possible. For example: echo htmlentities('.'); // Output: <Il était une fois un être>. // ^^^^^^^^ ^^^^^^^
echo htmlspecialchars('.'); // Output: <Il était une fois un être>. // ^ ^ | [
"php"
] | 602 | 393 | 364,902 | 11 | 0 | 2008-09-05T18:29:12.880000 | 2008-09-05T18:31:52.920000 |
46,484 | 46,507 | How to encrypt email addresses using JQuery | Is there a way to use JQuery to cloak or encrypt email addresses on an HTML page without changing the syntax in the href? | Using JQuery may not be the route you want to take since this would be on the client side... Is there a reason you're not encrypting on server side? | How to encrypt email addresses using JQuery Is there a way to use JQuery to cloak or encrypt email addresses on an HTML page without changing the syntax in the href? | TITLE:
How to encrypt email addresses using JQuery
QUESTION:
Is there a way to use JQuery to cloak or encrypt email addresses on an HTML page without changing the syntax in the href?
ANSWER:
Using JQuery may not be the route you want to take since this would be on the client side... Is there a reason you're not encrypting on server side? | [
"jquery",
"email"
] | 8 | 6 | 6,447 | 5 | 0 | 2008-09-05T18:29:25.533000 | 2008-09-05T18:35:51.133000 |
46,489 | 47,242 | Referencing Embedded resources from other resources in c# | In my web application I include all of my JavaScripts as js files that are embedded resources in the assembly, and add them to the page using ClientScriptManager.GetWebResourceUrl(). However, in some of my js files, I have references to other static assets like image urls. I would like to make those assembly resources as well. Is there a way to tokenize the reference to the resource? e.g. this.drophint = document.createElement('img'); this.drophint.src = '/_layouts/images/dragdrophint.gif'; Could become something like: this.drophint = document.createElement('img'); this.drophint.src = '{resource:assembly.location.dragdrophint.gif}'; | I'd suggest that you emit the web resources as a dynamic javascript associative array. Server side code: StringBuilder script = new StringBuilder(); script.Append("var imgResources = {};"); script.AppendFormat("imgResources['{0}'] = '{1}';", "drophint", Page.ClientScript.GetWebResourceUrl(Page.GetType(), "assembly.location.dragdrophint.gif")); script.AppendFormat("imgResources['{0}'] = '{1}';", "anotherimg", Page.ClientScript.GetWebResourceUrl(Page.GetType(), "assembly.location.anotherimg.gif"));
Page.ClientScript.RegisterClientScriptBlock( Page.GetType(), "imgResources", script.ToString(), true); Then your client side code looks like this: this.drophint = document.createElement('img'); this.drophint.src = imgResources['drophint']; this.anotherimg = document.createElement('img'); this.anotherimg.src = imgResources['anotherimg']; Hope this helps. | Referencing Embedded resources from other resources in c# In my web application I include all of my JavaScripts as js files that are embedded resources in the assembly, and add them to the page using ClientScriptManager.GetWebResourceUrl(). However, in some of my js files, I have references to other static assets like image urls. I would like to make those assembly resources as well. Is there a way to tokenize the reference to the resource? e.g. this.drophint = document.createElement('img'); this.drophint.src = '/_layouts/images/dragdrophint.gif'; Could become something like: this.drophint = document.createElement('img'); this.drophint.src = '{resource:assembly.location.dragdrophint.gif}'; | TITLE:
Referencing Embedded resources from other resources in c#
QUESTION:
In my web application I include all of my JavaScripts as js files that are embedded resources in the assembly, and add them to the page using ClientScriptManager.GetWebResourceUrl(). However, in some of my js files, I have references to other static assets like image urls. I would like to make those assembly resources as well. Is there a way to tokenize the reference to the resource? e.g. this.drophint = document.createElement('img'); this.drophint.src = '/_layouts/images/dragdrophint.gif'; Could become something like: this.drophint = document.createElement('img'); this.drophint.src = '{resource:assembly.location.dragdrophint.gif}';
ANSWER:
I'd suggest that you emit the web resources as a dynamic javascript associative array. Server side code: StringBuilder script = new StringBuilder(); script.Append("var imgResources = {};"); script.AppendFormat("imgResources['{0}'] = '{1}';", "drophint", Page.ClientScript.GetWebResourceUrl(Page.GetType(), "assembly.location.dragdrophint.gif")); script.AppendFormat("imgResources['{0}'] = '{1}';", "anotherimg", Page.ClientScript.GetWebResourceUrl(Page.GetType(), "assembly.location.anotherimg.gif"));
Page.ClientScript.RegisterClientScriptBlock( Page.GetType(), "imgResources", script.ToString(), true); Then your client side code looks like this: this.drophint = document.createElement('img'); this.drophint.src = imgResources['drophint']; this.anotherimg = document.createElement('img'); this.anotherimg.src = imgResources['anotherimg']; Hope this helps. | [
"c#",
"asp.net",
"javascript"
] | 3 | 3 | 2,499 | 3 | 0 | 2008-09-05T18:31:39.193000 | 2008-09-06T03:57:02.530000 |
46,495 | 147,571 | SQL Server 2005 error | Why can't you do this and is there are work around? You get this error. Msg 2714, Level 16, State 1, Line 13 There is already an object named '#temptable' in the database. declare @x int
set @x = 1
if (@x = 0) begin select 1 as Value into #temptable end else begin select 2 as Value into #temptable end
select * from #temptable
drop table #temptable | This is a two-part question and while Kev Fairchild provides a good answer to the second question he totally ignores the first - why is the error produced? The answer lies in the way the preprocessor works. This SELECT field-list INTO #symbol... is resolved into a parse-tree that is directly equivalent to DECLARE #symbol_sessionid TABLE(field-list) INSERT INTO #symbol_sessionid SELECT field-list... and this puts #symbol into the local scope's name table. The business with _sessionid is to provide each user session with a private namespace; if you specify two hashes (##symbol) this behaviour is suppressed. Munging and unmunging of the sessionid extension is (ovbiously) transparent. The upshot of all this is that multiple INTO #symbol clauses produce multiple declarations in the same scope, leading to Msg 2714. | SQL Server 2005 error Why can't you do this and is there are work around? You get this error. Msg 2714, Level 16, State 1, Line 13 There is already an object named '#temptable' in the database. declare @x int
set @x = 1
if (@x = 0) begin select 1 as Value into #temptable end else begin select 2 as Value into #temptable end
select * from #temptable
drop table #temptable | TITLE:
SQL Server 2005 error
QUESTION:
Why can't you do this and is there are work around? You get this error. Msg 2714, Level 16, State 1, Line 13 There is already an object named '#temptable' in the database. declare @x int
set @x = 1
if (@x = 0) begin select 1 as Value into #temptable end else begin select 2 as Value into #temptable end
select * from #temptable
drop table #temptable
ANSWER:
This is a two-part question and while Kev Fairchild provides a good answer to the second question he totally ignores the first - why is the error produced? The answer lies in the way the preprocessor works. This SELECT field-list INTO #symbol... is resolved into a parse-tree that is directly equivalent to DECLARE #symbol_sessionid TABLE(field-list) INSERT INTO #symbol_sessionid SELECT field-list... and this puts #symbol into the local scope's name table. The business with _sessionid is to provide each user session with a private namespace; if you specify two hashes (##symbol) this behaviour is suppressed. Munging and unmunging of the sessionid extension is (ovbiously) transparent. The upshot of all this is that multiple INTO #symbol clauses produce multiple declarations in the same scope, leading to Msg 2714. | [
"sql-server",
"temp-tables"
] | 0 | 1 | 242 | 6 | 0 | 2008-09-05T18:32:21.220000 | 2008-09-29T04:58:08.787000 |
46,496 | 46,579 | Should I avoid using Java Label Statements? | Today I had a coworker suggest I refactor my code to use a label statement to control flow through 2 nested for loops I had created. I've never used them before because personally I think they decrease the readability of a program. I am willing to change my mind about using them if the argument is solid enough however. What are people's opinions on label statements? | Many algorithms are expressed more easily if you can jump across two loops (or a loop containing a switch statement). Don't feel bad about it. On the other hand, it may indicate an overly complex solution. So stand back and look at the problem. Some people prefer a "single entry, single exit" approach to all loops. That is to say avoiding break (and continue) and early return for loops altogether. This may result in some duplicate code. What I would strongly avoid doing is introducing auxilary variables. Hiding control-flow within state adds to confusion. Splitting labeled loops into two methods may well be difficult. Exceptions are probably too heavyweight. Try a single entry, single exit approach. | Should I avoid using Java Label Statements? Today I had a coworker suggest I refactor my code to use a label statement to control flow through 2 nested for loops I had created. I've never used them before because personally I think they decrease the readability of a program. I am willing to change my mind about using them if the argument is solid enough however. What are people's opinions on label statements? | TITLE:
Should I avoid using Java Label Statements?
QUESTION:
Today I had a coworker suggest I refactor my code to use a label statement to control flow through 2 nested for loops I had created. I've never used them before because personally I think they decrease the readability of a program. I am willing to change my mind about using them if the argument is solid enough however. What are people's opinions on label statements?
ANSWER:
Many algorithms are expressed more easily if you can jump across two loops (or a loop containing a switch statement). Don't feel bad about it. On the other hand, it may indicate an overly complex solution. So stand back and look at the problem. Some people prefer a "single entry, single exit" approach to all loops. That is to say avoiding break (and continue) and early return for loops altogether. This may result in some duplicate code. What I would strongly avoid doing is introducing auxilary variables. Hiding control-flow within state adds to confusion. Splitting labeled loops into two methods may well be difficult. Exceptions are probably too heavyweight. Try a single entry, single exit approach. | [
"java",
"loops"
] | 69 | 49 | 34,995 | 12 | 0 | 2008-09-05T18:32:25.900000 | 2008-09-05T19:03:10.567000 |
46,512 | 46,535 | Can Visual Studio put timestamps in the build log? | In the build log I'd like to the start and end time of each project's compilation. Is there any way to get VS to do this? | For VC++ builds you can enable build timing. Go to Tools->Options->Projects and Solutions->VC++ Project settings and choose the option for 'Build Timing' | Can Visual Studio put timestamps in the build log? In the build log I'd like to the start and end time of each project's compilation. Is there any way to get VS to do this? | TITLE:
Can Visual Studio put timestamps in the build log?
QUESTION:
In the build log I'd like to the start and end time of each project's compilation. Is there any way to get VS to do this?
ANSWER:
For VC++ builds you can enable build timing. Go to Tools->Options->Projects and Solutions->VC++ Project settings and choose the option for 'Build Timing' | [
"visual-studio",
"build"
] | 31 | 14 | 13,210 | 5 | 0 | 2008-09-05T18:37:09.430000 | 2008-09-05T18:43:51.020000 |
46,532 | 47,396 | Do namespaces propagate to children in XElement objects? | If I have an XElement that has child elements, and if I remove a child element from the parent, removing all references between the two, will the child XElement have the same namespaces as the parent? In other words, if I have the following XML: and I remove the child element, will the child element's xml look like or like | The answer is yes, namespaces do propagate to children. You do NOT have to specify the namespace within child elements. The scoping of a namespace includes all elements until the closing tag of the element it was defined in. See section #6.1 here http://www.w3.org/TR/REC-xml-names/#scoping hope that helps | Do namespaces propagate to children in XElement objects? If I have an XElement that has child elements, and if I remove a child element from the parent, removing all references between the two, will the child XElement have the same namespaces as the parent? In other words, if I have the following XML: and I remove the child element, will the child element's xml look like or like | TITLE:
Do namespaces propagate to children in XElement objects?
QUESTION:
If I have an XElement that has child elements, and if I remove a child element from the parent, removing all references between the two, will the child XElement have the same namespaces as the parent? In other words, if I have the following XML: and I remove the child element, will the child element's xml look like or like
ANSWER:
The answer is yes, namespaces do propagate to children. You do NOT have to specify the namespace within child elements. The scoping of a namespace includes all elements until the closing tag of the element it was defined in. See section #6.1 here http://www.w3.org/TR/REC-xml-names/#scoping hope that helps | [
".net",
"namespaces",
"linq-to-xml"
] | 2 | 1 | 1,824 | 2 | 0 | 2008-09-05T18:43:25.203000 | 2008-09-06T11:43:30.273000 |
46,541 | 151,332 | When should you use the singleton pattern instead of a static class? | Name the design considerations in deciding between use of a singleton versus a static class. In doing this, you're kind of forced to contrast the two, so whatever contrasts you can come up with are also useful in showing your thought process! Also, every interviewer likes to see illustrative examples.:) | Singletons can implement interfaces and inherit from other classes. Singletons can be lazy loaded. Only when it is actually needed. That's very handy if the initialisation includes expensive resource loading or database connections. Singletons offer an actual object. Singletons can be extended into a factory. The object management behind the scenes is abstract so it's better maintainable and results in better code. | When should you use the singleton pattern instead of a static class? Name the design considerations in deciding between use of a singleton versus a static class. In doing this, you're kind of forced to contrast the two, so whatever contrasts you can come up with are also useful in showing your thought process! Also, every interviewer likes to see illustrative examples.:) | TITLE:
When should you use the singleton pattern instead of a static class?
QUESTION:
Name the design considerations in deciding between use of a singleton versus a static class. In doing this, you're kind of forced to contrast the two, so whatever contrasts you can come up with are also useful in showing your thought process! Also, every interviewer likes to see illustrative examples.:)
ANSWER:
Singletons can implement interfaces and inherit from other classes. Singletons can be lazy loaded. Only when it is actually needed. That's very handy if the initialisation includes expensive resource loading or database connections. Singletons offer an actual object. Singletons can be extended into a factory. The object management behind the scenes is abstract so it's better maintainable and results in better code. | [
"design-patterns"
] | 87 | 82 | 53,337 | 22 | 0 | 2008-09-05T18:48:03.693000 | 2008-09-30T00:43:21.857000 |
46,568 | 46,695 | Can you programmatically restart a j2ee application? | Does anyone know if it is possible to restart a J2EE application (from the application)? If so, how? I would like to be able to do it in an app-server-agnostic way, if it is possible. The application will be run on many different app servers-- basically whatever the client prefers. If it isn't possible to do this in an app-server-agnostic manner, then it probably isn't really worth doing for my purposes. I can always just display a message informing the user that they will need to restart the app manually. | I would suggest that you're unlikely to find an appserver agnostic way. And while I don't pretend to know your requirements, I might question a design that requires the application to restart itself, other than an installer that is deploying a new version. Finally, I would suggest that for any nontrivial purpose "any" appserver will not work. You should have a list of supported app servers and versions, documented in your release notes, so you can test on all of those and dont have to worry about supporting clients on a non-conforming server/version. From experience, there are always subtle differences between, for example, Apache Tomcat and BEA WebLogic, and these differences are often undocument and hard to determine until you run into them. | Can you programmatically restart a j2ee application? Does anyone know if it is possible to restart a J2EE application (from the application)? If so, how? I would like to be able to do it in an app-server-agnostic way, if it is possible. The application will be run on many different app servers-- basically whatever the client prefers. If it isn't possible to do this in an app-server-agnostic manner, then it probably isn't really worth doing for my purposes. I can always just display a message informing the user that they will need to restart the app manually. | TITLE:
Can you programmatically restart a j2ee application?
QUESTION:
Does anyone know if it is possible to restart a J2EE application (from the application)? If so, how? I would like to be able to do it in an app-server-agnostic way, if it is possible. The application will be run on many different app servers-- basically whatever the client prefers. If it isn't possible to do this in an app-server-agnostic manner, then it probably isn't really worth doing for my purposes. I can always just display a message informing the user that they will need to restart the app manually.
ANSWER:
I would suggest that you're unlikely to find an appserver agnostic way. And while I don't pretend to know your requirements, I might question a design that requires the application to restart itself, other than an installer that is deploying a new version. Finally, I would suggest that for any nontrivial purpose "any" appserver will not work. You should have a list of supported app servers and versions, documented in your release notes, so you can test on all of those and dont have to worry about supporting clients on a non-conforming server/version. From experience, there are always subtle differences between, for example, Apache Tomcat and BEA WebLogic, and these differences are often undocument and hard to determine until you run into them. | [
"java",
"jakarta-ee"
] | 5 | 6 | 1,170 | 3 | 0 | 2008-09-05T19:00:08.797000 | 2008-09-05T19:31:45.490000 |
46,571 | 47,197 | cfqueryparam with like operator in ColdFusion | I have been tasked with going through a number of ColdFusion sites that have recently been the subject of a rather nasty SQL Injection attack. Basically my work involves adding > tags to all of the inline sql. For the most part I've got it down, but can anybody tell me how to use cfqueryparam with the LIKE operator? If my query looks like this: select * from Foo where name like '%Bob%' what should my > tag look like? | @Joel, I have to disagree. select a,b,c from Foo where name like Never suggest to someone that they should "select star." Bad form! Even for an example! (Even copied from the question!) The query is pre-compiled and you should include the wild card character(s) as part of the parameter being passed to the query. This format is more readable and will run more efficiently. When doing string concatenation, use the ampersand operator (&), not the plus sign. Technically, in most cases, plus will work just fine... until you throw a NumberFormat() in the middle of the string and start wondering why you're being told that you're not passing a valid number when you've checked and you are. | cfqueryparam with like operator in ColdFusion I have been tasked with going through a number of ColdFusion sites that have recently been the subject of a rather nasty SQL Injection attack. Basically my work involves adding > tags to all of the inline sql. For the most part I've got it down, but can anybody tell me how to use cfqueryparam with the LIKE operator? If my query looks like this: select * from Foo where name like '%Bob%' what should my > tag look like? | TITLE:
cfqueryparam with like operator in ColdFusion
QUESTION:
I have been tasked with going through a number of ColdFusion sites that have recently been the subject of a rather nasty SQL Injection attack. Basically my work involves adding > tags to all of the inline sql. For the most part I've got it down, but can anybody tell me how to use cfqueryparam with the LIKE operator? If my query looks like this: select * from Foo where name like '%Bob%' what should my > tag look like?
ANSWER:
@Joel, I have to disagree. select a,b,c from Foo where name like Never suggest to someone that they should "select star." Bad form! Even for an example! (Even copied from the question!) The query is pre-compiled and you should include the wild card character(s) as part of the parameter being passed to the query. This format is more readable and will run more efficiently. When doing string concatenation, use the ampersand operator (&), not the plus sign. Technically, in most cases, plus will work just fine... until you throw a NumberFormat() in the middle of the string and start wondering why you're being told that you're not passing a valid number when you've checked and you are. | [
"coldfusion",
"railo",
"cfml",
"openbd"
] | 28 | 50 | 10,822 | 2 | 0 | 2008-09-05T19:00:58.793000 | 2008-09-06T02:21:48.750000 |
46,572 | 46,577 | What is the ASP.NET process for IIS 7.0? | Looking at what's running and nothing jumps out. Thanks! | It should be w3wp.exe EDIT: In line with Darren's comment, you should also check the "Show processes from all users" in Task Manager if that is where you are looking for the process. | What is the ASP.NET process for IIS 7.0? Looking at what's running and nothing jumps out. Thanks! | TITLE:
What is the ASP.NET process for IIS 7.0?
QUESTION:
Looking at what's running and nothing jumps out. Thanks!
ANSWER:
It should be w3wp.exe EDIT: In line with Darren's comment, you should also check the "Show processes from all users" in Task Manager if that is where you are looking for the process. | [
"asp.net",
"iis-7"
] | 7 | 8 | 1,398 | 5 | 0 | 2008-09-05T19:01:03.600000 | 2008-09-05T19:02:45.407000 |
46,582 | 47,735 | Response.Redirect with POST instead of Get? | We have the requirement to take a form submission and save some data, then redirect the user to a page offsite, but in redirecting, we need to "submit" a form with POST, not GET. I was hoping there was an easy way to accomplish this, but I'm starting to think there isn't. I think I must now create a simple other page, with just the form that I want, redirect to it, populate the form variables, then do a body.onload call to a script that merely calls document.forms[0].submit(); Can anyone tell me if there is an alternative? We might need to tweak this later in the project, and it might get sort of complicated, so if there was an easy we could do this all non-other page dependent that would be fantastic. Anyway, thanks for any and all responses. | Doing this requires understanding how HTTP redirects work. When you use Response.Redirect(), you send a response (to the browser that made the request) with HTTP Status Code 302, which tells the browser where to go next. By definition, the browser will make that via a GET request, even if the original request was a POST. Another option is to use HTTP Status Code 307, which specifies that the browser should make the redirect request in the same way as the original request, but to prompt the user with a security warning. To do that, you would write something like this: public void PageLoad(object sender, EventArgs e) { // Process the post on your side
Response.Status = "307 Temporary Redirect"; Response.AddHeader("Location", "http://example.com/page/to/post.to"); } Unfortunately, this won't always work. Different browsers implement this differently, since it is not a common status code. Alas, unlike the Opera and FireFox developers, the IE developers have never read the spec, and even the latest, most secure IE7 will redirect the POST request from domain A to domain B without any warnings or confirmation dialogs! Safari also acts in an interesting manner, while it does not raise a confirmation dialog and performs the redirect, it throws away the POST data, effectively changing 307 redirect into the more common 302. So, as far as I know, the only way to implement something like this would be to use Javascript. There are two options I can think of off the top of my head: Create the form and have its action attribute point to the third-party server. Then, add a click event to the submit button that first executes an AJAX request to your server with the data, and then allows the form to be submitted to the third-party server. Create the form to post to your server. When the form is submitted, show the user a page that has a form in it with all of the data you want to pass on, all in hidden inputs. Just show a message like "Redirecting...". Then, add a javascript event to the page that submits the form to the third-party server. Of the two, I would choose the second, for two reasons. First, it is more reliable than the first because Javascript is not required for it to work; for those who don't have it enabled, you can always make the submit button for the hidden form visible, and instruct them to press it if it takes more than 5 seconds. Second, you can decide what data gets transmitted to the third-party server; if you use just process the form as it goes by, you will be passing along all of the post data, which is not always what you want. Same for the 307 solution, assuming it worked for all of your users. | Response.Redirect with POST instead of Get? We have the requirement to take a form submission and save some data, then redirect the user to a page offsite, but in redirecting, we need to "submit" a form with POST, not GET. I was hoping there was an easy way to accomplish this, but I'm starting to think there isn't. I think I must now create a simple other page, with just the form that I want, redirect to it, populate the form variables, then do a body.onload call to a script that merely calls document.forms[0].submit(); Can anyone tell me if there is an alternative? We might need to tweak this later in the project, and it might get sort of complicated, so if there was an easy we could do this all non-other page dependent that would be fantastic. Anyway, thanks for any and all responses. | TITLE:
Response.Redirect with POST instead of Get?
QUESTION:
We have the requirement to take a form submission and save some data, then redirect the user to a page offsite, but in redirecting, we need to "submit" a form with POST, not GET. I was hoping there was an easy way to accomplish this, but I'm starting to think there isn't. I think I must now create a simple other page, with just the form that I want, redirect to it, populate the form variables, then do a body.onload call to a script that merely calls document.forms[0].submit(); Can anyone tell me if there is an alternative? We might need to tweak this later in the project, and it might get sort of complicated, so if there was an easy we could do this all non-other page dependent that would be fantastic. Anyway, thanks for any and all responses.
ANSWER:
Doing this requires understanding how HTTP redirects work. When you use Response.Redirect(), you send a response (to the browser that made the request) with HTTP Status Code 302, which tells the browser where to go next. By definition, the browser will make that via a GET request, even if the original request was a POST. Another option is to use HTTP Status Code 307, which specifies that the browser should make the redirect request in the same way as the original request, but to prompt the user with a security warning. To do that, you would write something like this: public void PageLoad(object sender, EventArgs e) { // Process the post on your side
Response.Status = "307 Temporary Redirect"; Response.AddHeader("Location", "http://example.com/page/to/post.to"); } Unfortunately, this won't always work. Different browsers implement this differently, since it is not a common status code. Alas, unlike the Opera and FireFox developers, the IE developers have never read the spec, and even the latest, most secure IE7 will redirect the POST request from domain A to domain B without any warnings or confirmation dialogs! Safari also acts in an interesting manner, while it does not raise a confirmation dialog and performs the redirect, it throws away the POST data, effectively changing 307 redirect into the more common 302. So, as far as I know, the only way to implement something like this would be to use Javascript. There are two options I can think of off the top of my head: Create the form and have its action attribute point to the third-party server. Then, add a click event to the submit button that first executes an AJAX request to your server with the data, and then allows the form to be submitted to the third-party server. Create the form to post to your server. When the form is submitted, show the user a page that has a form in it with all of the data you want to pass on, all in hidden inputs. Just show a message like "Redirecting...". Then, add a javascript event to the page that submits the form to the third-party server. Of the two, I would choose the second, for two reasons. First, it is more reliable than the first because Javascript is not required for it to work; for those who don't have it enabled, you can always make the submit button for the hidden form visible, and instruct them to press it if it takes more than 5 seconds. Second, you can decide what data gets transmitted to the third-party server; if you use just process the form as it goes by, you will be passing along all of the post data, which is not always what you want. Same for the 307 solution, assuming it worked for all of your users. | [
"asp.net",
"https",
"response.redirect"
] | 281 | 246 | 298,176 | 14 | 0 | 2008-09-05T19:03:46.183000 | 2008-09-06T18:54:00.723000 |
46,584 | 46,618 | When should one use a project reference opposed to a binary reference? | My company has a common code library which consists of many class libary projects along with supporting test projects. Each class library project outputs a single binary, e.g. Company.Common.Serialization.dll. Since we own the compiled, tested binaries as well as the source code, there's debate as to whether our consuming applications should use binary or project references. Some arguments in favor of project references: Project references would allow users to debug and view all solution code without the overhead of loading additional projects/solutions. Project references would assist in keeping up with common component changes committed to the source control system as changes would be easily identifiable without the active solution. Some arguments in favor of binary references: Binary references would simplify solutions and make for faster solution loading times. Binary references would allow developers to focus on new code rather than potentially being distracted by code which is already baked and proven stable. Binary references would force us to appropriately dogfood our stuff as we would be using the common library just as those outside of our organization would be required to do. Since a binary reference can't be debugged (stepped into), one would be forced to replicate and fix issues by extending the existing test projects rather than testing and fixing within the context of the consuming application alone. Binary references will ensure that concurrent development on the class library project will have no impact on the consuming application as a stable version of the binary will be referenced rather than an influx version. It would be the decision of the project lead whether or not to incorporate a newer release of the component if necessary. What is your policy/preference when it comes to using project or binary references? | It sounds to me as though you've covered all the major points. We've had a similar discussion at work recently and we're not quite decided yet. However, one thing we've looked into is to reference the binary files, to gain all the advantages you note, but have the binaries built by a common build system where the source code is in a common location, accessible from all developer machines (at least if they're sitting on the network at work), so that any debugging can in fact dive into library code, if necessary. However, on the same note, we've also tagged a lot of the base classes with appropriate attributes in order to make the debugger skip them completely, because any debugging you do in your own classes (at the level you're developing) would only be vastly outsized by code from the base libraries. This way when you hit the Step Into debugging shortcut key on a library class, you resurface into the next piece of code at your current level, instead of having to wade through tons of library code. Basically, I definitely vote up (in SO terms) your comments about keeping proven library code out of sight for the normal developer. Also, if I load the global solution file, that contains all the projects and basically, just everything, ReSharper 4 seems to have some kind of coronary problem, as Visual Studio practically comes to a stand-still. | When should one use a project reference opposed to a binary reference? My company has a common code library which consists of many class libary projects along with supporting test projects. Each class library project outputs a single binary, e.g. Company.Common.Serialization.dll. Since we own the compiled, tested binaries as well as the source code, there's debate as to whether our consuming applications should use binary or project references. Some arguments in favor of project references: Project references would allow users to debug and view all solution code without the overhead of loading additional projects/solutions. Project references would assist in keeping up with common component changes committed to the source control system as changes would be easily identifiable without the active solution. Some arguments in favor of binary references: Binary references would simplify solutions and make for faster solution loading times. Binary references would allow developers to focus on new code rather than potentially being distracted by code which is already baked and proven stable. Binary references would force us to appropriately dogfood our stuff as we would be using the common library just as those outside of our organization would be required to do. Since a binary reference can't be debugged (stepped into), one would be forced to replicate and fix issues by extending the existing test projects rather than testing and fixing within the context of the consuming application alone. Binary references will ensure that concurrent development on the class library project will have no impact on the consuming application as a stable version of the binary will be referenced rather than an influx version. It would be the decision of the project lead whether or not to incorporate a newer release of the component if necessary. What is your policy/preference when it comes to using project or binary references? | TITLE:
When should one use a project reference opposed to a binary reference?
QUESTION:
My company has a common code library which consists of many class libary projects along with supporting test projects. Each class library project outputs a single binary, e.g. Company.Common.Serialization.dll. Since we own the compiled, tested binaries as well as the source code, there's debate as to whether our consuming applications should use binary or project references. Some arguments in favor of project references: Project references would allow users to debug and view all solution code without the overhead of loading additional projects/solutions. Project references would assist in keeping up with common component changes committed to the source control system as changes would be easily identifiable without the active solution. Some arguments in favor of binary references: Binary references would simplify solutions and make for faster solution loading times. Binary references would allow developers to focus on new code rather than potentially being distracted by code which is already baked and proven stable. Binary references would force us to appropriately dogfood our stuff as we would be using the common library just as those outside of our organization would be required to do. Since a binary reference can't be debugged (stepped into), one would be forced to replicate and fix issues by extending the existing test projects rather than testing and fixing within the context of the consuming application alone. Binary references will ensure that concurrent development on the class library project will have no impact on the consuming application as a stable version of the binary will be referenced rather than an influx version. It would be the decision of the project lead whether or not to incorporate a newer release of the component if necessary. What is your policy/preference when it comes to using project or binary references?
ANSWER:
It sounds to me as though you've covered all the major points. We've had a similar discussion at work recently and we're not quite decided yet. However, one thing we've looked into is to reference the binary files, to gain all the advantages you note, but have the binaries built by a common build system where the source code is in a common location, accessible from all developer machines (at least if they're sitting on the network at work), so that any debugging can in fact dive into library code, if necessary. However, on the same note, we've also tagged a lot of the base classes with appropriate attributes in order to make the debugger skip them completely, because any debugging you do in your own classes (at the level you're developing) would only be vastly outsized by code from the base libraries. This way when you hit the Step Into debugging shortcut key on a library class, you resurface into the next piece of code at your current level, instead of having to wade through tons of library code. Basically, I definitely vote up (in SO terms) your comments about keeping proven library code out of sight for the normal developer. Also, if I load the global solution file, that contains all the projects and basically, just everything, ReSharper 4 seems to have some kind of coronary problem, as Visual Studio practically comes to a stand-still. | [
"standards",
"coding-style"
] | 16 | 6 | 2,118 | 6 | 0 | 2008-09-05T19:04:26.727000 | 2008-09-05T19:13:03.727000 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.