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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
26,843 | 26,862 | New Project : MySQL or SQL 2005 Express | I am starting a new client/server project at work and I want to start using some of the newer technologies I've been reading about, LINQ and Generics being the main ones. Up until now I have been developing these types of applications with MySQL as clients were unwilling to pay the large licence costs for MSSQL. I have played around a small amount with the express versions but have never actually developed anything with them. The new application will not have more than 5 concurrent connections but will be needed for daily reporting. Can MSSQL 2005 express still be downloaded? I cant seem to find it on the microsoft site. I would be hesitant to use MSSQL 2008 on a project so soon after its release. Are the express version adequate for my needs, I'm sure loads of people reading this have used them. Did you encounter any problems? | The answer to the question on any project in regards to what platform/technologies to use is: What does everyone know best? Yes express can still be downloaded. Will it fit your requirements? That depends on your requirements, of course. I have deployed MSSQL2005 Express on several enterprise level projects which I knew had a fixed database size that would never be exceeded (Express has a limit of each database of 4Gb). Also keep in mind there are other hardware constraints such as a 1 cpu limit. Another thing to consider is if you need the Enterprise level tools that come with a paid edition of SQL Server. If you are moving a lot of flat data around you are stuck writing your own Bulk Copy Procs, which rule the house, but its an extra step, no doubt. | New Project : MySQL or SQL 2005 Express I am starting a new client/server project at work and I want to start using some of the newer technologies I've been reading about, LINQ and Generics being the main ones. Up until now I have been developing these types of applications with MySQL as clients were unwilling to pay the large licence costs for MSSQL. I have played around a small amount with the express versions but have never actually developed anything with them. The new application will not have more than 5 concurrent connections but will be needed for daily reporting. Can MSSQL 2005 express still be downloaded? I cant seem to find it on the microsoft site. I would be hesitant to use MSSQL 2008 on a project so soon after its release. Are the express version adequate for my needs, I'm sure loads of people reading this have used them. Did you encounter any problems? | TITLE:
New Project : MySQL or SQL 2005 Express
QUESTION:
I am starting a new client/server project at work and I want to start using some of the newer technologies I've been reading about, LINQ and Generics being the main ones. Up until now I have been developing these types of applications with MySQL as clients were unwilling to pay the large licence costs for MSSQL. I have played around a small amount with the express versions but have never actually developed anything with them. The new application will not have more than 5 concurrent connections but will be needed for daily reporting. Can MSSQL 2005 express still be downloaded? I cant seem to find it on the microsoft site. I would be hesitant to use MSSQL 2008 on a project so soon after its release. Are the express version adequate for my needs, I'm sure loads of people reading this have used them. Did you encounter any problems?
ANSWER:
The answer to the question on any project in regards to what platform/technologies to use is: What does everyone know best? Yes express can still be downloaded. Will it fit your requirements? That depends on your requirements, of course. I have deployed MSSQL2005 Express on several enterprise level projects which I knew had a fixed database size that would never be exceeded (Express has a limit of each database of 4Gb). Also keep in mind there are other hardware constraints such as a 1 cpu limit. Another thing to consider is if you need the Enterprise level tools that come with a paid edition of SQL Server. If you are moving a lot of flat data around you are stuck writing your own Bulk Copy Procs, which rule the house, but its an extra step, no doubt. | [
"mysql",
"sql-server"
] | 3 | 6 | 636 | 6 | 0 | 2008-08-25T20:45:47.603000 | 2008-08-25T20:52:14.530000 |
26,845 | 27,033 | Do you use distributed version control? | I'd like to hear from people who are using distributed version control (aka distributed revision control, decentralized version control) and how they are finding it. What are you using, Mercurial, Darcs, Git, Bazaar? Are you still using it? If you've used client/server rcs in the past, are you finding it better, worse or just different? What could you tell me that would get me to jump on the bandwagon? Or jump off for that matter, I'd be interested to hear from people with negative experiences as well. I'm currently looking at replacing our current source control system (Subversion) which is the impetus for this question. I'd be especially interested in anyone who's used it with co-workers in other countries, where your machines may not be on at the same time, and your connection is very slow. If you're not sure what distributed version control is, here are a couple articles: Intro to Distributed Version Control Wikipedia Entry | I've been using Mercurial both at work and in my own personal projects, and I am really happy with it. The advantages I see are: Local version control. Sometimes I'm working on something, and I want to keep a version history on it, but I'm not ready to push it to the central repositories. With distributed VCS, I can just commit to my local repo until it's ready, without branching. That way, if other people make changes that I need, I can still get them and integrate them into my code. When I'm ready, I push it out to the servers. Fewer merge conflicts. They still happen, but they seem to be less frequent, and are less of a risk, because all the code is checked in to my local repo, so even if I botch the merge, I can always back up and do it again. Separate repos as branches. If I have a couple development vectors running at the same time, I can just make several clones of my repo and develop each feature independently. That way, if something gets scrapped or slipped, I don't have to pull pieces out. When they're ready to go, I just merge them together. Speed. Mercurial is much faster to work with, mostly because most of your common operations are local. Of course, like any new system, there was some pain during the transition. You have to think about version control differently than you did when you were using SVN, but overall I think it's very much worth it. | Do you use distributed version control? I'd like to hear from people who are using distributed version control (aka distributed revision control, decentralized version control) and how they are finding it. What are you using, Mercurial, Darcs, Git, Bazaar? Are you still using it? If you've used client/server rcs in the past, are you finding it better, worse or just different? What could you tell me that would get me to jump on the bandwagon? Or jump off for that matter, I'd be interested to hear from people with negative experiences as well. I'm currently looking at replacing our current source control system (Subversion) which is the impetus for this question. I'd be especially interested in anyone who's used it with co-workers in other countries, where your machines may not be on at the same time, and your connection is very slow. If you're not sure what distributed version control is, here are a couple articles: Intro to Distributed Version Control Wikipedia Entry | TITLE:
Do you use distributed version control?
QUESTION:
I'd like to hear from people who are using distributed version control (aka distributed revision control, decentralized version control) and how they are finding it. What are you using, Mercurial, Darcs, Git, Bazaar? Are you still using it? If you've used client/server rcs in the past, are you finding it better, worse or just different? What could you tell me that would get me to jump on the bandwagon? Or jump off for that matter, I'd be interested to hear from people with negative experiences as well. I'm currently looking at replacing our current source control system (Subversion) which is the impetus for this question. I'd be especially interested in anyone who's used it with co-workers in other countries, where your machines may not be on at the same time, and your connection is very slow. If you're not sure what distributed version control is, here are a couple articles: Intro to Distributed Version Control Wikipedia Entry
ANSWER:
I've been using Mercurial both at work and in my own personal projects, and I am really happy with it. The advantages I see are: Local version control. Sometimes I'm working on something, and I want to keep a version history on it, but I'm not ready to push it to the central repositories. With distributed VCS, I can just commit to my local repo until it's ready, without branching. That way, if other people make changes that I need, I can still get them and integrate them into my code. When I'm ready, I push it out to the servers. Fewer merge conflicts. They still happen, but they seem to be less frequent, and are less of a risk, because all the code is checked in to my local repo, so even if I botch the merge, I can always back up and do it again. Separate repos as branches. If I have a couple development vectors running at the same time, I can just make several clones of my repo and develop each feature independently. That way, if something gets scrapped or slipped, I don't have to pull pieces out. When they're ready to go, I just merge them together. Speed. Mercurial is much faster to work with, mostly because most of your common operations are local. Of course, like any new system, there was some pain during the transition. You have to think about version control differently than you did when you were using SVN, but overall I think it's very much worth it. | [
"version-control",
"dvcs",
"revision"
] | 37 | 30 | 2,988 | 18 | 0 | 2008-08-25T20:46:10.427000 | 2008-08-25T22:16:04.377000 |
26,854 | 129,235 | guid REST URL for ado.net dataservice call? | Trying to use a guid as a resource id in a rest url but cant find any resource on how to. My best right now (not working though) is: http://localhost:49157/PhotogalleryDS.svc/gallery ('1d03beb3-6d63-498b-aad7-fab0b1480996') (I've tried duouble/single quotes. And also {guid....} with braces. Still no luck. i only get:
Syntax error '"' at position 0. Question is: How would I (with regard to specification) write the url for a resource where the id is a guid? | I figured it out! http://localhost:49157/PhotogalleryDS.svc/photo(guid '01231cc7-1e26-4f33-9fdf-fdf7015267dd') This is the way | guid REST URL for ado.net dataservice call? Trying to use a guid as a resource id in a rest url but cant find any resource on how to. My best right now (not working though) is: http://localhost:49157/PhotogalleryDS.svc/gallery ('1d03beb3-6d63-498b-aad7-fab0b1480996') (I've tried duouble/single quotes. And also {guid....} with braces. Still no luck. i only get:
Syntax error '"' at position 0. Question is: How would I (with regard to specification) write the url for a resource where the id is a guid? | TITLE:
guid REST URL for ado.net dataservice call?
QUESTION:
Trying to use a guid as a resource id in a rest url but cant find any resource on how to. My best right now (not working though) is: http://localhost:49157/PhotogalleryDS.svc/gallery ('1d03beb3-6d63-498b-aad7-fab0b1480996') (I've tried duouble/single quotes. And also {guid....} with braces. Still no luck. i only get:
Syntax error '"' at position 0. Question is: How would I (with regard to specification) write the url for a resource where the id is a guid?
ANSWER:
I figured it out! http://localhost:49157/PhotogalleryDS.svc/photo(guid '01231cc7-1e26-4f33-9fdf-fdf7015267dd') This is the way | [
"rest",
"wcf-data-services"
] | 0 | 1 | 999 | 2 | 0 | 2008-08-25T20:48:17.240000 | 2008-09-24T19:14:15.677000 |
26,855 | 26,960 | What's the fastest way to determine a full URL from a relative URL (given a base URL) | I'm currently using the module URI::URL to generate a full URL from a relative URL; however, it isn't running as fast as I'd like it to be. Does anyone know another way to do this that may be faster? | The following code should work. $uri = URI->new_abs( $str, $base_uri ) You should also take a look at the URI page on search.cpan.org. | What's the fastest way to determine a full URL from a relative URL (given a base URL) I'm currently using the module URI::URL to generate a full URL from a relative URL; however, it isn't running as fast as I'd like it to be. Does anyone know another way to do this that may be faster? | TITLE:
What's the fastest way to determine a full URL from a relative URL (given a base URL)
QUESTION:
I'm currently using the module URI::URL to generate a full URL from a relative URL; however, it isn't running as fast as I'd like it to be. Does anyone know another way to do this that may be faster?
ANSWER:
The following code should work. $uri = URI->new_abs( $str, $base_uri ) You should also take a look at the URI page on search.cpan.org. | [
"regex",
"performance",
"perl",
"uri",
"perl-module"
] | 4 | 3 | 465 | 5 | 0 | 2008-08-25T20:49:17.673000 | 2008-08-25T21:33:37.240000 |
26,857 | 26,881 | How do you programmatically fill in a form and 'POST' a web page? | Using C# and ASP.NET I want to programmatically fill in some values (4 text boxes) on a web page (form) and then 'POST' those values. How do I do this? Edit: Clarification: There is a service (www.stopforumspam.com) where you can submit ip, username and email address on their 'add' page. I want to be able to create a link/button on my site's page that will fill in those values and submit the info without having to copy/paste them across and click the submit button. Further clarification: How do automated spam bots fill out forms and click the submit button if they were written in C#? | The code will look something like this: WebRequest req = WebRequest.Create("http://mysite/myform.aspx"); string postData = "item1=11111&item2=22222&Item3=33333";
byte[] send = Encoding.Default.GetBytes(postData); req.Method = "POST"; req.ContentType = "application/x-www-form-urlencoded"; req.ContentLength = send.Length;
Stream sout = req.GetRequestStream(); sout.Write(send, 0, send.Length); sout.Flush(); sout.Close();
WebResponse res = req.GetResponse(); StreamReader sr = new StreamReader(res.GetResponseStream()); string returnvalue = sr.ReadToEnd(); | How do you programmatically fill in a form and 'POST' a web page? Using C# and ASP.NET I want to programmatically fill in some values (4 text boxes) on a web page (form) and then 'POST' those values. How do I do this? Edit: Clarification: There is a service (www.stopforumspam.com) where you can submit ip, username and email address on their 'add' page. I want to be able to create a link/button on my site's page that will fill in those values and submit the info without having to copy/paste them across and click the submit button. Further clarification: How do automated spam bots fill out forms and click the submit button if they were written in C#? | TITLE:
How do you programmatically fill in a form and 'POST' a web page?
QUESTION:
Using C# and ASP.NET I want to programmatically fill in some values (4 text boxes) on a web page (form) and then 'POST' those values. How do I do this? Edit: Clarification: There is a service (www.stopforumspam.com) where you can submit ip, username and email address on their 'add' page. I want to be able to create a link/button on my site's page that will fill in those values and submit the info without having to copy/paste them across and click the submit button. Further clarification: How do automated spam bots fill out forms and click the submit button if they were written in C#?
ANSWER:
The code will look something like this: WebRequest req = WebRequest.Create("http://mysite/myform.aspx"); string postData = "item1=11111&item2=22222&Item3=33333";
byte[] send = Encoding.Default.GetBytes(postData); req.Method = "POST"; req.ContentType = "application/x-www-form-urlencoded"; req.ContentLength = send.Length;
Stream sout = req.GetRequestStream(); sout.Write(send, 0, send.Length); sout.Flush(); sout.Close();
WebResponse res = req.GetResponse(); StreamReader sr = new StreamReader(res.GetResponseStream()); string returnvalue = sr.ReadToEnd(); | [
"c#",
"asp.net"
] | 37 | 49 | 105,351 | 6 | 0 | 2008-08-25T20:49:47.453000 | 2008-08-25T21:01:37.037000 |
26,863 | 26,868 | How do I REALLY reset the Visual Studio window layout? | I had a plugin installed in Visual Studio 2008, and it created some extra dockable windows. I have uninstalled it, and I can't get rid of the windows it created - I close them, but they always come back. They're just empty windows now, since the plugin is no longer present, but nothing I've tried gets rid of them. I've tried: Window -> Reset Window Layout Deleting the.suo files in my project directories Deleting the Visual Studio 9.0 folder in my Application Settings directory Any ideas? | Have you tried this? In Visual Studio go to Tools > Import and Export Settings > Reset all settings Be sure you back up your settings before you do this. I made the mistake of trying this to fix an issue and didn't realize it would undo all my appearance settings and toolbars as well. Took a lot of time to get back to the way I like things. | How do I REALLY reset the Visual Studio window layout? I had a plugin installed in Visual Studio 2008, and it created some extra dockable windows. I have uninstalled it, and I can't get rid of the windows it created - I close them, but they always come back. They're just empty windows now, since the plugin is no longer present, but nothing I've tried gets rid of them. I've tried: Window -> Reset Window Layout Deleting the.suo files in my project directories Deleting the Visual Studio 9.0 folder in my Application Settings directory Any ideas? | TITLE:
How do I REALLY reset the Visual Studio window layout?
QUESTION:
I had a plugin installed in Visual Studio 2008, and it created some extra dockable windows. I have uninstalled it, and I can't get rid of the windows it created - I close them, but they always come back. They're just empty windows now, since the plugin is no longer present, but nothing I've tried gets rid of them. I've tried: Window -> Reset Window Layout Deleting the.suo files in my project directories Deleting the Visual Studio 9.0 folder in my Application Settings directory Any ideas?
ANSWER:
Have you tried this? In Visual Studio go to Tools > Import and Export Settings > Reset all settings Be sure you back up your settings before you do this. I made the mistake of trying this to fix an issue and didn't realize it would undo all my appearance settings and toolbars as well. Took a lot of time to get back to the way I like things. | [
"visual-studio"
] | 134 | 165 | 149,618 | 12 | 0 | 2008-08-25T20:53:21.067000 | 2008-08-25T20:55:13.510000 |
26,875 | 26,921 | Setting up a large Xcode project | I have a large exiting C++ project involving: 4 applications 50+ libraries 20+ third party libraries It all builds fine on Windows using VS8, Linux using QMake (project uses Qt a lot). I also build it on OS X using QMake but I was wanting to setup an Xcode project to handle it in an IDE. I'm struggling to setup proper configuration to easily define dependencies, both to internal libraries and to the third party. I can do property sheets and.pri files in my (disturbed) sleep, but would appreciate some advice on building such large projects in Xcode. I've been experiencing with Xcode configuration files and #including one from another but it does not seem to work as I would expect, especially when defining standard locations for header files etc. Is there some good book describing the process of setting up Xcode (remember it's C++, I'm not wanting to learn ObjC at this time)? Or maybe a good open source project I could learn from? Thanks! | Step in to Xcode may be the book you're looking for. It's got a whole section devoted to using AppleScript to automate configuration includes. I've been going through the book myself on O'Reilly Safari as I've found myself in a situation similar to yourself! | Setting up a large Xcode project I have a large exiting C++ project involving: 4 applications 50+ libraries 20+ third party libraries It all builds fine on Windows using VS8, Linux using QMake (project uses Qt a lot). I also build it on OS X using QMake but I was wanting to setup an Xcode project to handle it in an IDE. I'm struggling to setup proper configuration to easily define dependencies, both to internal libraries and to the third party. I can do property sheets and.pri files in my (disturbed) sleep, but would appreciate some advice on building such large projects in Xcode. I've been experiencing with Xcode configuration files and #including one from another but it does not seem to work as I would expect, especially when defining standard locations for header files etc. Is there some good book describing the process of setting up Xcode (remember it's C++, I'm not wanting to learn ObjC at this time)? Or maybe a good open source project I could learn from? Thanks! | TITLE:
Setting up a large Xcode project
QUESTION:
I have a large exiting C++ project involving: 4 applications 50+ libraries 20+ third party libraries It all builds fine on Windows using VS8, Linux using QMake (project uses Qt a lot). I also build it on OS X using QMake but I was wanting to setup an Xcode project to handle it in an IDE. I'm struggling to setup proper configuration to easily define dependencies, both to internal libraries and to the third party. I can do property sheets and.pri files in my (disturbed) sleep, but would appreciate some advice on building such large projects in Xcode. I've been experiencing with Xcode configuration files and #including one from another but it does not seem to work as I would expect, especially when defining standard locations for header files etc. Is there some good book describing the process of setting up Xcode (remember it's C++, I'm not wanting to learn ObjC at this time)? Or maybe a good open source project I could learn from? Thanks!
ANSWER:
Step in to Xcode may be the book you're looking for. It's got a whole section devoted to using AppleScript to automate configuration includes. I've been going through the book myself on O'Reilly Safari as I've found myself in a situation similar to yourself! | [
"xcode"
] | 2 | 3 | 1,304 | 1 | 0 | 2008-08-25T20:58:03.130000 | 2008-08-25T21:16:36.533000 |
26,877 | 26,884 | Difference between wiring events with and without "new" | In C#, what is the difference (if any) between these two lines of code? tmrMain.Elapsed += new ElapsedEventHandler(tmrMain_Tick); and tmrMain.Elapsed += tmrMain_Tick; Both appear to work exactly the same. Does C# just assume you mean the former when you type the latter? | I did this static void Hook1() { someEvent += new EventHandler( Program_someEvent ); }
static void Hook2() { someEvent += Program_someEvent; } And then ran ildasm over the code. The generated MSIL was exactly the same. So to answer your question, yes they are the same thing. The compiler is just inferring that you want someEvent += new EventHandler( Program_someEvent ); -- You can see it creating the new EventHandler object in both cases in the MSIL | Difference between wiring events with and without "new" In C#, what is the difference (if any) between these two lines of code? tmrMain.Elapsed += new ElapsedEventHandler(tmrMain_Tick); and tmrMain.Elapsed += tmrMain_Tick; Both appear to work exactly the same. Does C# just assume you mean the former when you type the latter? | TITLE:
Difference between wiring events with and without "new"
QUESTION:
In C#, what is the difference (if any) between these two lines of code? tmrMain.Elapsed += new ElapsedEventHandler(tmrMain_Tick); and tmrMain.Elapsed += tmrMain_Tick; Both appear to work exactly the same. Does C# just assume you mean the former when you type the latter?
ANSWER:
I did this static void Hook1() { someEvent += new EventHandler( Program_someEvent ); }
static void Hook2() { someEvent += Program_someEvent; } And then ran ildasm over the code. The generated MSIL was exactly the same. So to answer your question, yes they are the same thing. The compiler is just inferring that you want someEvent += new EventHandler( Program_someEvent ); -- You can see it creating the new EventHandler object in both cases in the MSIL | [
"c#",
"events",
"syntax",
"delegates"
] | 14 | 26 | 3,554 | 6 | 0 | 2008-08-25T20:59:54.247000 | 2008-08-25T21:02:27.847000 |
26,879 | 26,924 | Browser scrollbar | I have a website that is perfectely centered aligned. The CSS code works fine. The problem doesn't really have to do with CSS. I have headers for each page that perfectely match eachother. However, when the content gets larger, Opera and FireFox show a scrollbar at the left so you can scroll to the content not on the screen. This makes my site jump a few pixels to the left. Thus the headers are not perfectely aligned anymore. IE always has a scrollbar, so the site never jumps around in IE. Does anyone know a JavaScript/CSS/HTML solution for this problem? | I use html { overflow-y: scroll; } To standardize the scrollbar behavior in IE and FF | Browser scrollbar I have a website that is perfectely centered aligned. The CSS code works fine. The problem doesn't really have to do with CSS. I have headers for each page that perfectely match eachother. However, when the content gets larger, Opera and FireFox show a scrollbar at the left so you can scroll to the content not on the screen. This makes my site jump a few pixels to the left. Thus the headers are not perfectely aligned anymore. IE always has a scrollbar, so the site never jumps around in IE. Does anyone know a JavaScript/CSS/HTML solution for this problem? | TITLE:
Browser scrollbar
QUESTION:
I have a website that is perfectely centered aligned. The CSS code works fine. The problem doesn't really have to do with CSS. I have headers for each page that perfectely match eachother. However, when the content gets larger, Opera and FireFox show a scrollbar at the left so you can scroll to the content not on the screen. This makes my site jump a few pixels to the left. Thus the headers are not perfectely aligned anymore. IE always has a scrollbar, so the site never jumps around in IE. Does anyone know a JavaScript/CSS/HTML solution for this problem?
ANSWER:
I use html { overflow-y: scroll; } To standardize the scrollbar behavior in IE and FF | [
"browser"
] | 0 | 9 | 1,080 | 6 | 0 | 2008-08-25T21:01:14.713000 | 2008-08-25T21:17:25.110000 |
26,897 | 27,006 | Recommendations for Javascript Editor on Windows? | Are there any good recommendations anyone can provide for a good Javascript editor on Windows? I currently use combinations of FireBug and TextPad but would hate to miss out on the party if there are better options out there. Thanks. | In case you're a.Net programmer: VS 2008 has pretty great JS support including intellisense on dynamically added methods/properties and comfortable debugging. | Recommendations for Javascript Editor on Windows? Are there any good recommendations anyone can provide for a good Javascript editor on Windows? I currently use combinations of FireBug and TextPad but would hate to miss out on the party if there are better options out there. Thanks. | TITLE:
Recommendations for Javascript Editor on Windows?
QUESTION:
Are there any good recommendations anyone can provide for a good Javascript editor on Windows? I currently use combinations of FireBug and TextPad but would hate to miss out on the party if there are better options out there. Thanks.
ANSWER:
In case you're a.Net programmer: VS 2008 has pretty great JS support including intellisense on dynamically added methods/properties and comfortable debugging. | [
"javascript",
"editor"
] | 37 | 5 | 26,794 | 13 | 0 | 2008-08-25T21:06:49.053000 | 2008-08-25T22:02:23.927000 |
26,903 | 27,454 | How can you require a constructor with no parameters for types implementing an interface? | Is there a way? I need all types that implement a specific interface to have a parameterless constructor, can it be done? I am developing the base code for other developers in my company to use in a specific project. There's a proccess which will create instances of types (in different threads) that perform certain tasks, and I need those types to follow a specific contract (ergo, the interface). The interface will be internal to the assembly If you have a suggestion for this scenario without interfaces, I'll gladly take it into consideration... | Juan Manuel said: that's one of the reasons I don't understand why it cannot be a part of the contract in the interface It's an indirect mechanism. The generic allows you to "cheat" and send type information along with the interface. The critical thing to remember here is that the constraint isn't on the interface that you are working with directly. It's not a constraint on the interface itself, but on some other type that will "ride along" on the interface. This is the best explanation I can offer, I'm afraid. By way of illustration of this fact, I'll point out a hole that I have noticed in aku's code. It's possible to write a class that would compile fine but fail at runtime when you try to instantiate it: public class Something: ITest { private Something() { } } Something derives from ITest, but implements no parameterless constructor. It will compile fine, because String does implement a parameterless constructor. Again, the constraint is on T, and therefore String, rather than ITest or Something. Since the constraint on T is satisfied, this will compile. But it will fail at runtime. To prevent some instances of this problem, you need to add another constraint to T, as below: public interface ITest where T: ITest, new() { } Note the new constraint: T: ITest. This constraint specifies that what you pass into the argument parameter of ITest must also derive from ITest. Even so this will not prevent all cases of the hole. The code below will compile fine, because A has a parameterless constructor. But since B's parameterless constructor is private, instantiating B with your process will fail at runtime. public class A: ITest { }
public class B: ITest { private B() { } } | How can you require a constructor with no parameters for types implementing an interface? Is there a way? I need all types that implement a specific interface to have a parameterless constructor, can it be done? I am developing the base code for other developers in my company to use in a specific project. There's a proccess which will create instances of types (in different threads) that perform certain tasks, and I need those types to follow a specific contract (ergo, the interface). The interface will be internal to the assembly If you have a suggestion for this scenario without interfaces, I'll gladly take it into consideration... | TITLE:
How can you require a constructor with no parameters for types implementing an interface?
QUESTION:
Is there a way? I need all types that implement a specific interface to have a parameterless constructor, can it be done? I am developing the base code for other developers in my company to use in a specific project. There's a proccess which will create instances of types (in different threads) that perform certain tasks, and I need those types to follow a specific contract (ergo, the interface). The interface will be internal to the assembly If you have a suggestion for this scenario without interfaces, I'll gladly take it into consideration...
ANSWER:
Juan Manuel said: that's one of the reasons I don't understand why it cannot be a part of the contract in the interface It's an indirect mechanism. The generic allows you to "cheat" and send type information along with the interface. The critical thing to remember here is that the constraint isn't on the interface that you are working with directly. It's not a constraint on the interface itself, but on some other type that will "ride along" on the interface. This is the best explanation I can offer, I'm afraid. By way of illustration of this fact, I'll point out a hole that I have noticed in aku's code. It's possible to write a class that would compile fine but fail at runtime when you try to instantiate it: public class Something: ITest { private Something() { } } Something derives from ITest, but implements no parameterless constructor. It will compile fine, because String does implement a parameterless constructor. Again, the constraint is on T, and therefore String, rather than ITest or Something. Since the constraint on T is satisfied, this will compile. But it will fail at runtime. To prevent some instances of this problem, you need to add another constraint to T, as below: public interface ITest where T: ITest, new() { } Note the new constraint: T: ITest. This constraint specifies that what you pass into the argument parameter of ITest must also derive from ITest. Even so this will not prevent all cases of the hole. The code below will compile fine, because A has a parameterless constructor. But since B's parameterless constructor is private, instantiating B with your process will fail at runtime. public class A: ITest { }
public class B: ITest { private B() { } } | [
"c#",
".net",
"constructor",
"interface",
"oop"
] | 10 | 5 | 5,036 | 10 | 0 | 2008-08-25T21:08:45.147000 | 2008-08-26T05:35:16.880000 |
26,904 | 27,828 | Getting QMake to generate a proper .app | I have a large exiting C++ project involving: 4 applications 50+ libraries 20+ third party libraries The project uses QMake (part of Trolltech's Qt) to build the production version on Linux, but I've been playing around at building it on MacOS. I can build in on MacOS using QMake just fine but I'm having trouble producing the final.app. It needs collecting all the third party frameworks and dynamic libraries, all the project's dynamic libraries and making sure the application finds them. I've read online about using install_name_tool but was wondering if there's a process to automate it. (Maybe the answer is to use XCode, see related question, but it would have issues with building uic and moc) Thanks | I'm sure this could be of some great help for you: deployqt Hope this helps! | Getting QMake to generate a proper .app I have a large exiting C++ project involving: 4 applications 50+ libraries 20+ third party libraries The project uses QMake (part of Trolltech's Qt) to build the production version on Linux, but I've been playing around at building it on MacOS. I can build in on MacOS using QMake just fine but I'm having trouble producing the final.app. It needs collecting all the third party frameworks and dynamic libraries, all the project's dynamic libraries and making sure the application finds them. I've read online about using install_name_tool but was wondering if there's a process to automate it. (Maybe the answer is to use XCode, see related question, but it would have issues with building uic and moc) Thanks | TITLE:
Getting QMake to generate a proper .app
QUESTION:
I have a large exiting C++ project involving: 4 applications 50+ libraries 20+ third party libraries The project uses QMake (part of Trolltech's Qt) to build the production version on Linux, but I've been playing around at building it on MacOS. I can build in on MacOS using QMake just fine but I'm having trouble producing the final.app. It needs collecting all the third party frameworks and dynamic libraries, all the project's dynamic libraries and making sure the application finds them. I've read online about using install_name_tool but was wondering if there's a process to automate it. (Maybe the answer is to use XCode, see related question, but it would have issues with building uic and moc) Thanks
ANSWER:
I'm sure this could be of some great help for you: deployqt Hope this helps! | [
"xcode",
"qt",
"qmake"
] | 3 | 3 | 2,184 | 3 | 0 | 2008-08-25T21:08:45.553000 | 2008-08-26T12:00:19.607000 |
26,971 | 26,991 | NHibernate vs LINQ to SQL | As someone who hasn't used either technology on real-world projects I wonder if anyone knows how these two complement each other and how much their functionalities overlap? | LINQ to SQL forces you to use the table-per-class pattern. The benefits of using this pattern are that it's quick and easy to implement and it takes very little effort to get your domain running based on an existing database structure. For simple applications, this is perfectly acceptable (and oftentimes even preferable), but for more complex applications devs will often suggest using a domain driven design pattern instead (which is what NHibernate facilitates). The problem with the table-per-class pattern is that your database structure has a direct influence over your domain design. For instance, let's say you have a Customers table with the following columns to hold a customer's primary address information: StreetAddress City State Zip Now, let's say you want to add columns for the customer's mailing address as well so you add in the following columns to the Customers table: MailingStreetAddress MailingCity MailingState MailingZip Using LINQ to SQL, the Customer object in your domain would now have properties for each of these eight columns. But if you were following a domain driven design pattern, you would probably have created an Address class and had your Customer class hold two Address properties, one for the mailing address and one for their current address. That's a simple example, but it demonstrates how the table-per-class pattern can lead to a somewhat smelly domain. In the end, it's up to you. Again, for simple apps that just need basic CRUD (create, read, update, delete) functionality, LINQ to SQL is ideal because of simplicity. But personally I like using NHibernate because it facilitates a cleaner domain. Edit: @lomaxx - Yes, the example I used was simplistic and could have been optimized to work well with LINQ to SQL. I wanted to keep it as basic as possible to drive home the point. The point remains though that there are several scenarios where having your database structure determine your domain structure would be a bad idea, or at least lead to suboptimal OO design. | NHibernate vs LINQ to SQL As someone who hasn't used either technology on real-world projects I wonder if anyone knows how these two complement each other and how much their functionalities overlap? | TITLE:
NHibernate vs LINQ to SQL
QUESTION:
As someone who hasn't used either technology on real-world projects I wonder if anyone knows how these two complement each other and how much their functionalities overlap?
ANSWER:
LINQ to SQL forces you to use the table-per-class pattern. The benefits of using this pattern are that it's quick and easy to implement and it takes very little effort to get your domain running based on an existing database structure. For simple applications, this is perfectly acceptable (and oftentimes even preferable), but for more complex applications devs will often suggest using a domain driven design pattern instead (which is what NHibernate facilitates). The problem with the table-per-class pattern is that your database structure has a direct influence over your domain design. For instance, let's say you have a Customers table with the following columns to hold a customer's primary address information: StreetAddress City State Zip Now, let's say you want to add columns for the customer's mailing address as well so you add in the following columns to the Customers table: MailingStreetAddress MailingCity MailingState MailingZip Using LINQ to SQL, the Customer object in your domain would now have properties for each of these eight columns. But if you were following a domain driven design pattern, you would probably have created an Address class and had your Customer class hold two Address properties, one for the mailing address and one for their current address. That's a simple example, but it demonstrates how the table-per-class pattern can lead to a somewhat smelly domain. In the end, it's up to you. Again, for simple apps that just need basic CRUD (create, read, update, delete) functionality, LINQ to SQL is ideal because of simplicity. But personally I like using NHibernate because it facilitates a cleaner domain. Edit: @lomaxx - Yes, the example I used was simplistic and could have been optimized to work well with LINQ to SQL. I wanted to keep it as basic as possible to drive home the point. The point remains though that there are several scenarios where having your database structure determine your domain structure would be a bad idea, or at least lead to suboptimal OO design. | [
"linq",
"nhibernate",
"linq-to-sql",
"orm"
] | 117 | 113 | 34,774 | 9 | 0 | 2008-08-25T21:39:35.837000 | 2008-08-25T21:51:07.790000 |
26,984 | 27,064 | What is the general rule of thumbs for creating an Exception in Java? | I have been in both situations: Creating too many custom Exceptions Using too many general Exception class In both cases the project started OK but soon became an overhead to maintain (and refactor). So what is the best practice regarding the creation of your own Exception classes? | The Java Specialists wrote a post about Exceptions in Java, and in it they list a few "best practices" for creating Exceptions, summarized below: Don't Write Own Exceptions (there are lots of useful Exceptions that are already part of the Java API) Write Useful Exceptions (if you have to write your own Exceptions, make sure they provide useful information about the problem that occurred) | What is the general rule of thumbs for creating an Exception in Java? I have been in both situations: Creating too many custom Exceptions Using too many general Exception class In both cases the project started OK but soon became an overhead to maintain (and refactor). So what is the best practice regarding the creation of your own Exception classes? | TITLE:
What is the general rule of thumbs for creating an Exception in Java?
QUESTION:
I have been in both situations: Creating too many custom Exceptions Using too many general Exception class In both cases the project started OK but soon became an overhead to maintain (and refactor). So what is the best practice regarding the creation of your own Exception classes?
ANSWER:
The Java Specialists wrote a post about Exceptions in Java, and in it they list a few "best practices" for creating Exceptions, summarized below: Don't Write Own Exceptions (there are lots of useful Exceptions that are already part of the Java API) Write Useful Exceptions (if you have to write your own Exceptions, make sure they provide useful information about the problem that occurred) | [
"java",
"exception"
] | 23 | 22 | 14,928 | 8 | 0 | 2008-08-25T21:46:43.153000 | 2008-08-25T22:50:32.080000 |
27,009 | 29,545 | How does one implement FxCop / static analysis on an existing code base | What are some of the strategies that are used when implementing FxCop / static analysis on existing code bases with existing violations? How can one most effectively reduce the static analysis violations? | Make liberal use of [SuppressMessage] attribute to begin with. At least at the beginning. Once you get the count to 0 via the attribute, you then put in a rule that new checkins may not introduce FxCop violations. Visual Studio 2008 has a nice code analysis feature that allows you to ensure that code analysis runs on every build and you can treat warnings as errors. That might slow things down a bit so I recommend setting up a continuous integration server (like CruiseControl.NET) and having it run code analysis on every checkin. Once you get it under control and aren't introducing new violations with every checkin, start to tackle whole classes of FxCop violations at a time with the goal of removing the SuppressMessageAttributes that you used. The way to keep track of which ones you really want to keep is to always add a Justification value to the ones you really want to suppress. | How does one implement FxCop / static analysis on an existing code base What are some of the strategies that are used when implementing FxCop / static analysis on existing code bases with existing violations? How can one most effectively reduce the static analysis violations? | TITLE:
How does one implement FxCop / static analysis on an existing code base
QUESTION:
What are some of the strategies that are used when implementing FxCop / static analysis on existing code bases with existing violations? How can one most effectively reduce the static analysis violations?
ANSWER:
Make liberal use of [SuppressMessage] attribute to begin with. At least at the beginning. Once you get the count to 0 via the attribute, you then put in a rule that new checkins may not introduce FxCop violations. Visual Studio 2008 has a nice code analysis feature that allows you to ensure that code analysis runs on every build and you can treat warnings as errors. That might slow things down a bit so I recommend setting up a continuous integration server (like CruiseControl.NET) and having it run code analysis on every checkin. Once you get it under control and aren't introducing new violations with every checkin, start to tackle whole classes of FxCop violations at a time with the goal of removing the SuppressMessageAttributes that you used. The way to keep track of which ones you really want to keep is to always add a Justification value to the ones you really want to suppress. | [
"static-analysis",
"fxcop",
"metrics"
] | 5 | 13 | 1,765 | 4 | 0 | 2008-08-25T22:04:40.490000 | 2008-08-27T04:53:45.520000 |
27,018 | 27,269 | Single responsiblity principle: granularity of the reason to change | When applying the Single Responsibility Principle and looking at a class's reason to change, how do you determine whether that reason too change is too granular, or not granular enough? | I don't know that there's a good answer to this one other than "apply your judgement, based on your experience." Failing that, get help, which I guess is what you're doing here;) Seriously, though, if you find that you're creating a gazillion classes to do what seems like a simple job, then you're probably being too granular. If your classes all seem collossal, then you're probably being too coarse. Please pardon me if that's a statement of the obvious. I think this is one of those fuzzy, no-hard-and-fast-rules cases that show us why we need human programmers. Just try something, seeking balance, and refactor if you find you're going too far in one direction or the other. And remember: if it's worth doing, it's worth doing badly. | Single responsiblity principle: granularity of the reason to change When applying the Single Responsibility Principle and looking at a class's reason to change, how do you determine whether that reason too change is too granular, or not granular enough? | TITLE:
Single responsiblity principle: granularity of the reason to change
QUESTION:
When applying the Single Responsibility Principle and looking at a class's reason to change, how do you determine whether that reason too change is too granular, or not granular enough?
ANSWER:
I don't know that there's a good answer to this one other than "apply your judgement, based on your experience." Failing that, get help, which I guess is what you're doing here;) Seriously, though, if you find that you're creating a gazillion classes to do what seems like a simple job, then you're probably being too granular. If your classes all seem collossal, then you're probably being too coarse. Please pardon me if that's a statement of the obvious. I think this is one of those fuzzy, no-hard-and-fast-rules cases that show us why we need human programmers. Just try something, seeking balance, and refactor if you find you're going too far in one direction or the other. And remember: if it's worth doing, it's worth doing badly. | [
"oop"
] | 4 | 1 | 481 | 2 | 0 | 2008-08-25T22:09:23.253000 | 2008-08-26T02:13:39.487000 |
27,020 | 27,139 | Alternating coloring groups of rows in Excel | I have an Excel Spreadsheet like this id | data for id | more data for id id | data for id id | data for id | more data for id | even more data for id id | data for id | more data for id id | data for id id | data for id | more data for id Now I want to group the data of one id by alternating the background color of the rows var color = white for each row if the first cell is not empty and color is white set color to green if the first cell is not empty and color is green set color to white set background of row to color Can anyone help me with a macro or some VBA code Thanks | I think this does what you are looking for. Flips color when the cell in column A changes value. Runs until there is no value in column B. Public Sub HighLightRows() Dim i As Integer i = 1 Dim c As Integer c = 3 'red
Do While (Cells(i, 2) <> "") If (Cells(i, 1) <> "") Then 'check for new ID If c = 3 Then c = 4 'green Else c = 3 'red End If End If
Rows(Trim(Str(i)) + ":" + Trim(Str(i))).Interior.ColorIndex = c i = i + 1 Loop End Sub | Alternating coloring groups of rows in Excel I have an Excel Spreadsheet like this id | data for id | more data for id id | data for id id | data for id | more data for id | even more data for id id | data for id | more data for id id | data for id id | data for id | more data for id Now I want to group the data of one id by alternating the background color of the rows var color = white for each row if the first cell is not empty and color is white set color to green if the first cell is not empty and color is green set color to white set background of row to color Can anyone help me with a macro or some VBA code Thanks | TITLE:
Alternating coloring groups of rows in Excel
QUESTION:
I have an Excel Spreadsheet like this id | data for id | more data for id id | data for id id | data for id | more data for id | even more data for id id | data for id | more data for id id | data for id id | data for id | more data for id Now I want to group the data of one id by alternating the background color of the rows var color = white for each row if the first cell is not empty and color is white set color to green if the first cell is not empty and color is green set color to white set background of row to color Can anyone help me with a macro or some VBA code Thanks
ANSWER:
I think this does what you are looking for. Flips color when the cell in column A changes value. Runs until there is no value in column B. Public Sub HighLightRows() Dim i As Integer i = 1 Dim c As Integer c = 3 'red
Do While (Cells(i, 2) <> "") If (Cells(i, 1) <> "") Then 'check for new ID If c = 3 Then c = 4 'green Else c = 3 'red End If End If
Rows(Trim(Str(i)) + ":" + Trim(Str(i))).Interior.ColorIndex = c i = i + 1 Loop End Sub | [
"excel",
"vba",
"colors"
] | 11 | 4 | 42,441 | 8 | 0 | 2008-08-25T22:11:30.770000 | 2008-08-26T00:03:06.243000 |
27,027 | 32,441 | Best approaches to versioning Mac "bundle" files | So you know a lot of Mac apps use "bundles": It looks like a single file to your application, but it's actually a folder with many files inside. For a version control system to handle this, it needs to: check out all the files in a directory, so the app can modify them as necessary at checkin, commit files which have been modified add new files which the application has created mark as deleted files which are no longer there (since the app deleted them) manage this as one atomic change Any ideas on the best way to handle this with existing version control systems? Are any of the versioning systems more adept in this area? | For distributed SCM systems like git and mercurial shouldn't be a problem as Matthew mentioned. If you need to use a centralized SCM like Subversion or CVS, then you can zip up (archive) your bundles before checking them into source control. This can be painful and takes an extra step. There is a good blog post about this at Tapestry Central: Mac OS X bundles vs. Subversion This article demonstrates a ruby script that manages the archiving for you. | Best approaches to versioning Mac "bundle" files So you know a lot of Mac apps use "bundles": It looks like a single file to your application, but it's actually a folder with many files inside. For a version control system to handle this, it needs to: check out all the files in a directory, so the app can modify them as necessary at checkin, commit files which have been modified add new files which the application has created mark as deleted files which are no longer there (since the app deleted them) manage this as one atomic change Any ideas on the best way to handle this with existing version control systems? Are any of the versioning systems more adept in this area? | TITLE:
Best approaches to versioning Mac "bundle" files
QUESTION:
So you know a lot of Mac apps use "bundles": It looks like a single file to your application, but it's actually a folder with many files inside. For a version control system to handle this, it needs to: check out all the files in a directory, so the app can modify them as necessary at checkin, commit files which have been modified add new files which the application has created mark as deleted files which are no longer there (since the app deleted them) manage this as one atomic change Any ideas on the best way to handle this with existing version control systems? Are any of the versioning systems more adept in this area?
ANSWER:
For distributed SCM systems like git and mercurial shouldn't be a problem as Matthew mentioned. If you need to use a centralized SCM like Subversion or CVS, then you can zip up (archive) your bundles before checking them into source control. This can be painful and takes an extra step. There is a good blog post about this at Tapestry Central: Mac OS X bundles vs. Subversion This article demonstrates a ruby script that manages the archiving for you. | [
"macos",
"version-control",
"bundle"
] | 6 | 1 | 1,977 | 4 | 0 | 2008-08-25T22:13:58.953000 | 2008-08-28T14:39:37.337000 |
27,030 | 27,212 | Comparing Arrays of Objects in JavaScript | I want to compare 2 arrays of objects in JavaScript code. The objects have 8 total properties, but each object will not have a value for each, and the arrays are never going to be any larger than 8 items each, so maybe the brute force method of traversing each and then looking at the values of the 8 properties is the easiest way to do what I want to do, but before implementing, I wanted to see if anyone had a more elegant solution. Any thoughts? | EDIT: You cannot overload operators in current, common browser-based implementations of JavaScript interpreters. To answer the original question, one way you could do this, and mind you, this is a bit of a hack, simply serialize the two arrays to JSON and then compare the two JSON strings. That would simply tell you if the arrays are different, obviously you could do this to each of the objects within the arrays as well to see which ones were different. Another option is to use a library which has some nice facilities for comparing objects - I use and recommend MochiKit. EDIT: The answer kamens gave deserves consideration as well, since a single function to compare two given objects would be much smaller than any library to do what I suggest (although my suggestion would certainly work well enough). Here is a naïve implemenation that may do just enough for you - be aware that there are potential problems with this implementation: function objectsAreSame(x, y) { var objectsAreSame = true; for(var propertyName in x) { if(x[propertyName]!== y[propertyName]) { objectsAreSame = false; break; } } return objectsAreSame; } The assumption is that both objects have the same exact list of properties. Oh, and it is probably obvious that, for better or worse, I belong to the only-one-return-point camp.:) | Comparing Arrays of Objects in JavaScript I want to compare 2 arrays of objects in JavaScript code. The objects have 8 total properties, but each object will not have a value for each, and the arrays are never going to be any larger than 8 items each, so maybe the brute force method of traversing each and then looking at the values of the 8 properties is the easiest way to do what I want to do, but before implementing, I wanted to see if anyone had a more elegant solution. Any thoughts? | TITLE:
Comparing Arrays of Objects in JavaScript
QUESTION:
I want to compare 2 arrays of objects in JavaScript code. The objects have 8 total properties, but each object will not have a value for each, and the arrays are never going to be any larger than 8 items each, so maybe the brute force method of traversing each and then looking at the values of the 8 properties is the easiest way to do what I want to do, but before implementing, I wanted to see if anyone had a more elegant solution. Any thoughts?
ANSWER:
EDIT: You cannot overload operators in current, common browser-based implementations of JavaScript interpreters. To answer the original question, one way you could do this, and mind you, this is a bit of a hack, simply serialize the two arrays to JSON and then compare the two JSON strings. That would simply tell you if the arrays are different, obviously you could do this to each of the objects within the arrays as well to see which ones were different. Another option is to use a library which has some nice facilities for comparing objects - I use and recommend MochiKit. EDIT: The answer kamens gave deserves consideration as well, since a single function to compare two given objects would be much smaller than any library to do what I suggest (although my suggestion would certainly work well enough). Here is a naïve implemenation that may do just enough for you - be aware that there are potential problems with this implementation: function objectsAreSame(x, y) { var objectsAreSame = true; for(var propertyName in x) { if(x[propertyName]!== y[propertyName]) { objectsAreSame = false; break; } } return objectsAreSame; } The assumption is that both objects have the same exact list of properties. Oh, and it is probably obvious that, for better or worse, I belong to the only-one-return-point camp.:) | [
"javascript",
"arrays",
"comparison",
"array-of-dict"
] | 116 | 71 | 409,287 | 18 | 0 | 2008-08-25T22:15:21.617000 | 2008-08-26T01:39:34.340000 |
27,034 | 27,098 | Javascript: declaring a variable before the conditional result? | My JavaScript is pretty nominal, so when I saw this construction, I was kind of baffled: var shareProxiesPref = document.getElementById("network.proxy.share_proxy_settings"); shareProxiesPref.disabled = proxyTypePref.value!= 1; Isn't it better to do an if on proxyTypePref.value, and then declare the var inside the result, only if you need it? (Incidentally, I also found this form very hard to read in comparison to the normal usage. There were a set of two or three of these conditionals, instead of doing a single if with a block of statements in the result.) UPDATE: The responses were very helpful and asked for more context. The code fragment is from Firefox 3, so you can see the code here: http://mxr.mozilla.org/firefox/source/browser/components/preferences/connection.js Basically, when you look at the Connect preferences window in Firefox, clicking the proxy modes (radio buttons), causes various form elements to enable|disable. | It depends on the context of this code. If it's running on page load, then it would be better to put this code in an if block. But, if this is part of a validation function, and the field switches between enabled and disabled throughout the life of the page, then this code sort of makes sense. It's important to remember that setting disabled to false also alters page state. | Javascript: declaring a variable before the conditional result? My JavaScript is pretty nominal, so when I saw this construction, I was kind of baffled: var shareProxiesPref = document.getElementById("network.proxy.share_proxy_settings"); shareProxiesPref.disabled = proxyTypePref.value!= 1; Isn't it better to do an if on proxyTypePref.value, and then declare the var inside the result, only if you need it? (Incidentally, I also found this form very hard to read in comparison to the normal usage. There were a set of two or three of these conditionals, instead of doing a single if with a block of statements in the result.) UPDATE: The responses were very helpful and asked for more context. The code fragment is from Firefox 3, so you can see the code here: http://mxr.mozilla.org/firefox/source/browser/components/preferences/connection.js Basically, when you look at the Connect preferences window in Firefox, clicking the proxy modes (radio buttons), causes various form elements to enable|disable. | TITLE:
Javascript: declaring a variable before the conditional result?
QUESTION:
My JavaScript is pretty nominal, so when I saw this construction, I was kind of baffled: var shareProxiesPref = document.getElementById("network.proxy.share_proxy_settings"); shareProxiesPref.disabled = proxyTypePref.value!= 1; Isn't it better to do an if on proxyTypePref.value, and then declare the var inside the result, only if you need it? (Incidentally, I also found this form very hard to read in comparison to the normal usage. There were a set of two or three of these conditionals, instead of doing a single if with a block of statements in the result.) UPDATE: The responses were very helpful and asked for more context. The code fragment is from Firefox 3, so you can see the code here: http://mxr.mozilla.org/firefox/source/browser/components/preferences/connection.js Basically, when you look at the Connect preferences window in Firefox, clicking the proxy modes (radio buttons), causes various form elements to enable|disable.
ANSWER:
It depends on the context of this code. If it's running on page load, then it would be better to put this code in an if block. But, if this is part of a validation function, and the field switches between enabled and disabled throughout the life of the page, then this code sort of makes sense. It's important to remember that setting disabled to false also alters page state. | [
"javascript"
] | 2 | 2 | 688 | 3 | 0 | 2008-08-25T22:16:10.227000 | 2008-08-25T23:14:03.753000 |
27,044 | 27,051 | How can I set LANG to ascii? | I'm accessing an Ubuntu machine using PuTTY, and using gcc. The default LANG environment variable on this machine is set to en_NZ.UTF-8, which causes GCC to think PuTTY is capable of displaying UTF-8 text, which it doesn't seem to be. Maybe it's my font, I don't know - it does this: foo.c:1: error: expected â=â, â,â, â;â, âasmâ or â__attribute__â at end of input If I set it with export LANG=en_NZ, then this causes GCC to behave correctly, I get: foo.c:1: error: expected '=', ',', ';', 'asm' or '__attribute__' at end of input but this then causes everything else to go wrong. For example man foo man: can't set the locale; make sure $LC_* and $LANG are correct I've trawled Google and I can't for the life of me find out what I have to put in there for it to just use ASCII. en_NZ.ASCII doesn't work, nor do any of the other things I can find. Thanks | LANG=en_NZ is correct. However, you must make locale files for en_NZ. For Ubuntu, edit /var/lib/locales/supported.d/local and add en_NZ ISO-8859-1 to the file. If your system is another distribution (including Debian), the location will be different. Look at /usr/sbin/locale-gen and see where it stores this info. Afterwards, run locale-gen to create the en_NZ locale file. Hope this helps! | How can I set LANG to ascii? I'm accessing an Ubuntu machine using PuTTY, and using gcc. The default LANG environment variable on this machine is set to en_NZ.UTF-8, which causes GCC to think PuTTY is capable of displaying UTF-8 text, which it doesn't seem to be. Maybe it's my font, I don't know - it does this: foo.c:1: error: expected â=â, â,â, â;â, âasmâ or â__attribute__â at end of input If I set it with export LANG=en_NZ, then this causes GCC to behave correctly, I get: foo.c:1: error: expected '=', ',', ';', 'asm' or '__attribute__' at end of input but this then causes everything else to go wrong. For example man foo man: can't set the locale; make sure $LC_* and $LANG are correct I've trawled Google and I can't for the life of me find out what I have to put in there for it to just use ASCII. en_NZ.ASCII doesn't work, nor do any of the other things I can find. Thanks | TITLE:
How can I set LANG to ascii?
QUESTION:
I'm accessing an Ubuntu machine using PuTTY, and using gcc. The default LANG environment variable on this machine is set to en_NZ.UTF-8, which causes GCC to think PuTTY is capable of displaying UTF-8 text, which it doesn't seem to be. Maybe it's my font, I don't know - it does this: foo.c:1: error: expected â=â, â,â, â;â, âasmâ or â__attribute__â at end of input If I set it with export LANG=en_NZ, then this causes GCC to behave correctly, I get: foo.c:1: error: expected '=', ',', ';', 'asm' or '__attribute__' at end of input but this then causes everything else to go wrong. For example man foo man: can't set the locale; make sure $LC_* and $LANG are correct I've trawled Google and I can't for the life of me find out what I have to put in there for it to just use ASCII. en_NZ.ASCII doesn't work, nor do any of the other things I can find. Thanks
ANSWER:
LANG=en_NZ is correct. However, you must make locale files for en_NZ. For Ubuntu, edit /var/lib/locales/supported.d/local and add en_NZ ISO-8859-1 to the file. If your system is another distribution (including Debian), the location will be different. Look at /usr/sbin/locale-gen and see where it stores this info. Afterwards, run locale-gen to create the en_NZ locale file. Hope this helps! | [
"linux",
"bash",
"utf-8"
] | 2 | 4 | 7,497 | 3 | 0 | 2008-08-25T22:28:08.717000 | 2008-08-25T22:34:52.397000 |
27,065 | 27,505 | Tool to read and display Java .class versions | Do any of you know of a tool that will search for.class files and then display their compiled versions? I know you can look at them individually in a hex editor but I have a lot of class files to look over (something in my giant application is compiling to Java6 for some reason). | Use the javap tool that comes with the JDK. The -verbose option will print the version number of the class file. > javap -verbose MyClass Compiled from "MyClass.java" public class MyClass SourceFile: "MyClass.java" minor version: 0 major version: 46... To only show the version: WINDOWS> javap -verbose MyClass | find "version" LINUX > javap -verbose MyClass | grep version | Tool to read and display Java .class versions Do any of you know of a tool that will search for.class files and then display their compiled versions? I know you can look at them individually in a hex editor but I have a lot of class files to look over (something in my giant application is compiling to Java6 for some reason). | TITLE:
Tool to read and display Java .class versions
QUESTION:
Do any of you know of a tool that will search for.class files and then display their compiled versions? I know you can look at them individually in a hex editor but I have a lot of class files to look over (something in my giant application is compiling to Java6 for some reason).
ANSWER:
Use the javap tool that comes with the JDK. The -verbose option will print the version number of the class file. > javap -verbose MyClass Compiled from "MyClass.java" public class MyClass SourceFile: "MyClass.java" minor version: 0 major version: 46... To only show the version: WINDOWS> javap -verbose MyClass | find "version" LINUX > javap -verbose MyClass | grep version | [
"jvm-bytecode"
] | 128 | 153 | 67,273 | 12 | 0 | 2008-08-25T22:52:02.667000 | 2008-08-26T07:16:23.953000 |
27,071 | 27,326 | Pointer to Pointer Managed C++ | I have an old C library with a function that takes a void**: oldFunction(void** pStuff); I'm trying to call this function from managed C++ (m_pStuff is a member of the parent ref class of type void*): oldFunction( static_cast ( &m_pStuff ) ); This gives me the following error from Visual Studio: error C2440: 'static_cast': cannot convert from 'cli::interior_ptr' to 'void **' I'm guessing the compiler is converting the void* member pointer to a cli::interior_ptr behind my back. Any advice on how to do this? | EDIT: Fixed answer, see below. Really you need to know what oldFunction is going to be doing with pStuff. If pStuff is a pointer to some unmanaged data you can try wrapping the definition of m_pStuff with: #pragma unmanaged
void* m_pStuff
#pragma managed This will make the pointer unmanaged which can then be passed into unmanaged functions. Of course you will not be able to assign any managed objects to this pointer directly. Fundamentally unmanaged and managed pointers are not the same and can't be converted without some sort of glue code that copies the underlying data. Basically managed pointers point to the managed heap and since this is garbage collected the actual memory address they point to can change over time. Unmanaged pointers do not change the memory address without you explicitly doing so. Scratch that, you can't define unmanaged / managed inside a class definition. But this test code seems to work just fine: // TestSol.cpp: main project file.
#include "stdafx.h"
using namespace System;
#pragma unmanaged
void oldFunction(void** pStuff) { return; }
#pragma managed
ref class Test { public: void* m_test;
};
int main(array ^args) { Console::WriteLine(L"Hello World");
Test^ test = gcnew Test(); void* pStuff = test->m_test; oldFunction(&pStuff); test->m_test = pStuff;
return 0; } Here I copy the pointer out of the managed object first and then pass that in by to the oldFunction. Then I copy the result (probably updated by oldFunction) back into the managed object. Since the managed object is on the managed heap, the compiler won't let you pass a reference to the pointer contained in that object as it may move when the garbage collector runs. | Pointer to Pointer Managed C++ I have an old C library with a function that takes a void**: oldFunction(void** pStuff); I'm trying to call this function from managed C++ (m_pStuff is a member of the parent ref class of type void*): oldFunction( static_cast ( &m_pStuff ) ); This gives me the following error from Visual Studio: error C2440: 'static_cast': cannot convert from 'cli::interior_ptr' to 'void **' I'm guessing the compiler is converting the void* member pointer to a cli::interior_ptr behind my back. Any advice on how to do this? | TITLE:
Pointer to Pointer Managed C++
QUESTION:
I have an old C library with a function that takes a void**: oldFunction(void** pStuff); I'm trying to call this function from managed C++ (m_pStuff is a member of the parent ref class of type void*): oldFunction( static_cast ( &m_pStuff ) ); This gives me the following error from Visual Studio: error C2440: 'static_cast': cannot convert from 'cli::interior_ptr' to 'void **' I'm guessing the compiler is converting the void* member pointer to a cli::interior_ptr behind my back. Any advice on how to do this?
ANSWER:
EDIT: Fixed answer, see below. Really you need to know what oldFunction is going to be doing with pStuff. If pStuff is a pointer to some unmanaged data you can try wrapping the definition of m_pStuff with: #pragma unmanaged
void* m_pStuff
#pragma managed This will make the pointer unmanaged which can then be passed into unmanaged functions. Of course you will not be able to assign any managed objects to this pointer directly. Fundamentally unmanaged and managed pointers are not the same and can't be converted without some sort of glue code that copies the underlying data. Basically managed pointers point to the managed heap and since this is garbage collected the actual memory address they point to can change over time. Unmanaged pointers do not change the memory address without you explicitly doing so. Scratch that, you can't define unmanaged / managed inside a class definition. But this test code seems to work just fine: // TestSol.cpp: main project file.
#include "stdafx.h"
using namespace System;
#pragma unmanaged
void oldFunction(void** pStuff) { return; }
#pragma managed
ref class Test { public: void* m_test;
};
int main(array ^args) { Console::WriteLine(L"Hello World");
Test^ test = gcnew Test(); void* pStuff = test->m_test; oldFunction(&pStuff); test->m_test = pStuff;
return 0; } Here I copy the pointer out of the managed object first and then pass that in by to the oldFunction. Then I copy the result (probably updated by oldFunction) back into the managed object. Since the managed object is on the managed heap, the compiler won't let you pass a reference to the pointer contained in that object as it may move when the garbage collector runs. | [
"pointers",
"managed-c++"
] | 1 | 1 | 6,324 | 2 | 0 | 2008-08-25T22:55:48.213000 | 2008-08-26T03:06:46.177000 |
27,077 | 28,262 | Is there any way to prevent find from digging down recursively into subdirectories? | When I do: $ find / It searches the entire system. How do I prevent that? (This question comes from an " answer " to another question.) | G'day, Just wanted to expand on the suggestion from Jon to use -prune. It isn't the easiest of find options to use, for example to just search in the current directory the find command looks like: find. \( -type d! -name. -prune \) -o \( \) this will stop find from descending into sub-directories within this directory. Basically, it says, "prune anything that is a directory, whose name isn't ".", i.e. current dir." The find command evals left to right for each item found in the current directory so after completion of the first element, i.e. the prune segment, it will then continue on with the matched item in your second -o (OR'd) expression. HTH. cheers, Rob | Is there any way to prevent find from digging down recursively into subdirectories? When I do: $ find / It searches the entire system. How do I prevent that? (This question comes from an " answer " to another question.) | TITLE:
Is there any way to prevent find from digging down recursively into subdirectories?
QUESTION:
When I do: $ find / It searches the entire system. How do I prevent that? (This question comes from an " answer " to another question.)
ANSWER:
G'day, Just wanted to expand on the suggestion from Jon to use -prune. It isn't the easiest of find options to use, for example to just search in the current directory the find command looks like: find. \( -type d! -name. -prune \) -o \( \) this will stop find from descending into sub-directories within this directory. Basically, it says, "prune anything that is a directory, whose name isn't ".", i.e. current dir." The find command evals left to right for each item found in the current directory so after completion of the first element, i.e. the prune segment, it will then continue on with the matched item in your second -o (OR'd) expression. HTH. cheers, Rob | [
"bash",
"unix",
"shell",
"ksh"
] | 4 | 4 | 4,262 | 5 | 0 | 2008-08-25T22:58:43.683000 | 2008-08-26T14:55:46.377000 |
27,095 | 27,552 | The Google Calculator Glitch, could float vs. double be a possible reason? | With Google's newfound inability to do math correctly (check it! according to Google 500,000,000,000,002 - 500,000,000,000,001 = 0 ), I figured I'd try the following in C to run a little theory. int main() { char* a = "399999999999999"; char* b = "399999999999998";
float da = atof(a); float db = atof(b);
printf("%s - %s = %f\n", a, b, da-db);
a = "500000000000002"; b = "500000000000001"; da = atof(a); db = atof(b); printf("%s - %s = %f\n", a, b, da-db); } When you run this program, you get the following 399999999999999 - 399999999999998 = 0.000000 500000000000002 - 500000000000001 = 0.000000 It would seem like Google is using simple 32 bit floating precision (the error here), if you switch float for double in the above code, you fix the issue! Could this be it? | In C#, try (double.maxvalue == (double.maxvalue - 100)), you'll get true but that's what it is supposed to be. Thinking about it, you have 64 bit representing a number greater than 2^64 ( double.maxvalue ), so inaccuracy is expected. | The Google Calculator Glitch, could float vs. double be a possible reason? With Google's newfound inability to do math correctly (check it! according to Google 500,000,000,000,002 - 500,000,000,000,001 = 0 ), I figured I'd try the following in C to run a little theory. int main() { char* a = "399999999999999"; char* b = "399999999999998";
float da = atof(a); float db = atof(b);
printf("%s - %s = %f\n", a, b, da-db);
a = "500000000000002"; b = "500000000000001"; da = atof(a); db = atof(b); printf("%s - %s = %f\n", a, b, da-db); } When you run this program, you get the following 399999999999999 - 399999999999998 = 0.000000 500000000000002 - 500000000000001 = 0.000000 It would seem like Google is using simple 32 bit floating precision (the error here), if you switch float for double in the above code, you fix the issue! Could this be it? | TITLE:
The Google Calculator Glitch, could float vs. double be a possible reason?
QUESTION:
With Google's newfound inability to do math correctly (check it! according to Google 500,000,000,000,002 - 500,000,000,000,001 = 0 ), I figured I'd try the following in C to run a little theory. int main() { char* a = "399999999999999"; char* b = "399999999999998";
float da = atof(a); float db = atof(b);
printf("%s - %s = %f\n", a, b, da-db);
a = "500000000000002"; b = "500000000000001"; da = atof(a); db = atof(b); printf("%s - %s = %f\n", a, b, da-db); } When you run this program, you get the following 399999999999999 - 399999999999998 = 0.000000 500000000000002 - 500000000000001 = 0.000000 It would seem like Google is using simple 32 bit floating precision (the error here), if you switch float for double in the above code, you fix the issue! Could this be it?
ANSWER:
In C#, try (double.maxvalue == (double.maxvalue - 100)), you'll get true but that's what it is supposed to be. Thinking about it, you have 64 bit representing a number greater than 2^64 ( double.maxvalue ), so inaccuracy is expected. | [
"c",
"math",
"google-search"
] | 6 | 2 | 2,623 | 7 | 0 | 2008-08-25T23:09:30.363000 | 2008-08-26T08:19:56.813000 |
27,108 | 27,130 | Perfmon File Analysis Tools | I have a bunch of perfmon files that have captured information over a period of time. Whats the best tool to crunch this information? Idealy I'd like to be able to see avg stats per hour for the object counters that have been monitored. | Perhaps look into using LogParser. It depends on how the info was logged (Perfmon doesn't lack flexibility) If they're CSV you can even use the ODBC Text drivers and run queries against them! (performance would be 'intriguing') And here's the obligatory link to a CodingHorror article on the topic;-) | Perfmon File Analysis Tools I have a bunch of perfmon files that have captured information over a period of time. Whats the best tool to crunch this information? Idealy I'd like to be able to see avg stats per hour for the object counters that have been monitored. | TITLE:
Perfmon File Analysis Tools
QUESTION:
I have a bunch of perfmon files that have captured information over a period of time. Whats the best tool to crunch this information? Idealy I'd like to be able to see avg stats per hour for the object counters that have been monitored.
ANSWER:
Perhaps look into using LogParser. It depends on how the info was logged (Perfmon doesn't lack flexibility) If they're CSV you can even use the ODBC Text drivers and run queries against them! (performance would be 'intriguing') And here's the obligatory link to a CodingHorror article on the topic;-) | [
"performance",
"logfile-analysis"
] | 7 | 4 | 18,159 | 4 | 0 | 2008-08-25T23:21:43.597000 | 2008-08-25T23:51:18.470000 |
27,129 | 27,168 | Charting library for Java and .Net | Can anyone recommend a library for chart generation (bar charts, pie charts etc.) which runs on both Java and.Net? | ChartDirector is fantastic and supports more than just Java and.NET. | Charting library for Java and .Net Can anyone recommend a library for chart generation (bar charts, pie charts etc.) which runs on both Java and.Net? | TITLE:
Charting library for Java and .Net
QUESTION:
Can anyone recommend a library for chart generation (bar charts, pie charts etc.) which runs on both Java and.Net?
ANSWER:
ChartDirector is fantastic and supports more than just Java and.NET. | [
"java",
".net",
"charts"
] | 1 | 7 | 1,554 | 7 | 0 | 2008-08-25T23:51:06.630000 | 2008-08-26T00:48:26.727000 |
27,138 | 2,151,866 | iPhone app that access the Core Location framework over web | I was wondering if I could access the iPhones Core Location framework over a website? My goal is to build a webapp/website that the iPhone would browse to, then upload its current GPS location. This would be a simple site primary for friends/family so we could locate each other. I can have them manually enter lng/lat but its not the easiest thing to find. If the iPhone could display or upload this automatically it would be great. I don't own a Mac yet (waiting for the new Mac Book Pro) but would like something a little more automatic right now. Once I have the mac I could download the SDK and build a better version later. For now a webapp version would be great if possible. Thanks. | Why not simply use W3C GeoLocation API available in mobile Safari? This will work on ipod touch as well (suburb precision). It's literally 10 lines of code and the javascript will work without change on Firefox 3.5. Far easier than scrape some third party website. | iPhone app that access the Core Location framework over web I was wondering if I could access the iPhones Core Location framework over a website? My goal is to build a webapp/website that the iPhone would browse to, then upload its current GPS location. This would be a simple site primary for friends/family so we could locate each other. I can have them manually enter lng/lat but its not the easiest thing to find. If the iPhone could display or upload this automatically it would be great. I don't own a Mac yet (waiting for the new Mac Book Pro) but would like something a little more automatic right now. Once I have the mac I could download the SDK and build a better version later. For now a webapp version would be great if possible. Thanks. | TITLE:
iPhone app that access the Core Location framework over web
QUESTION:
I was wondering if I could access the iPhones Core Location framework over a website? My goal is to build a webapp/website that the iPhone would browse to, then upload its current GPS location. This would be a simple site primary for friends/family so we could locate each other. I can have them manually enter lng/lat but its not the easiest thing to find. If the iPhone could display or upload this automatically it would be great. I don't own a Mac yet (waiting for the new Mac Book Pro) but would like something a little more automatic right now. Once I have the mac I could download the SDK and build a better version later. For now a webapp version would be great if possible. Thanks.
ANSWER:
Why not simply use W3C GeoLocation API available in mobile Safari? This will work on ipod touch as well (suburb precision). It's literally 10 lines of code and the javascript will work without change on Firefox 3.5. Far easier than scrape some third party website. | [
"iphone",
"gps",
"web-applications"
] | 3 | 4 | 3,747 | 4 | 0 | 2008-08-26T00:01:55.607000 | 2010-01-28T02:19:17.140000 |
27,148 | 27,156 | merge rss feeds | I want to merge multiple rss feeds into a single feed, removing any duplicates. Specifically, I'm interested in merging the feeds for the tags I'm interested in. [A quick search turned up some promising links, which I don't have time to visit at the moment] Broadly speaking, the ideal would be a reader that would list all the available tags on the site and toggle them on and off, allowing me to explore what's available, keep track of questions I've visited, new answers on interesting feeds, etc, etc... though I don't suppose such a things exists right now. As I randomly explore the site and see questions I think are interesting, I inevitably find "oh yes, that one looked interesting a couple days ago when I read it the first time, and hasn't been updated since". It would be much nicer if my machine would keep track of such deails for me:) Update: You can now use "and", "or", and "not" to combine multiple tags into a single feed: Tags AND Tags OR Tags Update: You can now use Filters to watch tags across one or multiple sites: Improved Tag Stes | Have you heard of Yahoo's Pipes. Its an interactive feed aggregator and manipulator. List of 'hot pipes' to subscribe to, and ability to create your own (yahoo account required). I played with it during beta back in the day, however I had a blast. Its really fun and easy to aggregate different feeds and you can add logic or filters to the "pipes". You can even do more then just RSS like import images from flickr. | merge rss feeds I want to merge multiple rss feeds into a single feed, removing any duplicates. Specifically, I'm interested in merging the feeds for the tags I'm interested in. [A quick search turned up some promising links, which I don't have time to visit at the moment] Broadly speaking, the ideal would be a reader that would list all the available tags on the site and toggle them on and off, allowing me to explore what's available, keep track of questions I've visited, new answers on interesting feeds, etc, etc... though I don't suppose such a things exists right now. As I randomly explore the site and see questions I think are interesting, I inevitably find "oh yes, that one looked interesting a couple days ago when I read it the first time, and hasn't been updated since". It would be much nicer if my machine would keep track of such deails for me:) Update: You can now use "and", "or", and "not" to combine multiple tags into a single feed: Tags AND Tags OR Tags Update: You can now use Filters to watch tags across one or multiple sites: Improved Tag Stes | TITLE:
merge rss feeds
QUESTION:
I want to merge multiple rss feeds into a single feed, removing any duplicates. Specifically, I'm interested in merging the feeds for the tags I'm interested in. [A quick search turned up some promising links, which I don't have time to visit at the moment] Broadly speaking, the ideal would be a reader that would list all the available tags on the site and toggle them on and off, allowing me to explore what's available, keep track of questions I've visited, new answers on interesting feeds, etc, etc... though I don't suppose such a things exists right now. As I randomly explore the site and see questions I think are interesting, I inevitably find "oh yes, that one looked interesting a couple days ago when I read it the first time, and hasn't been updated since". It would be much nicer if my machine would keep track of such deails for me:) Update: You can now use "and", "or", and "not" to combine multiple tags into a single feed: Tags AND Tags OR Tags Update: You can now use Filters to watch tags across one or multiple sites: Improved Tag Stes
ANSWER:
Have you heard of Yahoo's Pipes. Its an interactive feed aggregator and manipulator. List of 'hot pipes' to subscribe to, and ability to create your own (yahoo account required). I played with it during beta back in the day, however I had a blast. Its really fun and easy to aggregate different feeds and you can add logic or filters to the "pipes". You can even do more then just RSS like import images from flickr. | [
"rss",
"feed"
] | 6 | 17 | 3,659 | 6 | 0 | 2008-08-26T00:17:27.393000 | 2008-08-26T00:22:20.127000 |
27,153 | 140,191 | Development resources for Mono on PS3 | I have been considering taking the plunge and installing Linux on my Playstation 3. As C# is my current language of choice, the next logical step would be to install Mono. I have done a little research and found that http://psubuntu.com/wiki/InstallationInstructions has instruction on installing Ubuntu and links to download an ISO containing a PS3 specific version of Ubuntu. There is also this cool project at http://code.google.com/p/celldotnet/ that has developed some code to utilize the 6 additional SPU cores of the CPU, not just the general-purpose one that you have access to by default. The problem is that the project documentation seems a little thin. Has anyone set up a PS3 to develop.NET code? If so, what problems did you encounter? Does anyone have any code samples of how to even partially load up one of these monster processors? Update: I do realize that basic.NET/Mono programming will come into play here. The part I am fuzzy on is what sort of data structures do you pass to a specialty core? If I am reading this right, the 6 SPU cores have 128 registers at 128 bits each. I haven't seen any discussion on how to go about coding effectively for this. Update 2: IBM has announced that further development on the Cell processor has been cancelled. While this pretty much kills any desire I might have to develop on the platform, hopefully someone else might add some useful info. | Just found this posting from Miguel de Icaza's blog. Promising that as recently as Feb 2008 he was looking into this. As he is a member of the SO community now, I hope he can shed some further light on the topic. | Development resources for Mono on PS3 I have been considering taking the plunge and installing Linux on my Playstation 3. As C# is my current language of choice, the next logical step would be to install Mono. I have done a little research and found that http://psubuntu.com/wiki/InstallationInstructions has instruction on installing Ubuntu and links to download an ISO containing a PS3 specific version of Ubuntu. There is also this cool project at http://code.google.com/p/celldotnet/ that has developed some code to utilize the 6 additional SPU cores of the CPU, not just the general-purpose one that you have access to by default. The problem is that the project documentation seems a little thin. Has anyone set up a PS3 to develop.NET code? If so, what problems did you encounter? Does anyone have any code samples of how to even partially load up one of these monster processors? Update: I do realize that basic.NET/Mono programming will come into play here. The part I am fuzzy on is what sort of data structures do you pass to a specialty core? If I am reading this right, the 6 SPU cores have 128 registers at 128 bits each. I haven't seen any discussion on how to go about coding effectively for this. Update 2: IBM has announced that further development on the Cell processor has been cancelled. While this pretty much kills any desire I might have to develop on the platform, hopefully someone else might add some useful info. | TITLE:
Development resources for Mono on PS3
QUESTION:
I have been considering taking the plunge and installing Linux on my Playstation 3. As C# is my current language of choice, the next logical step would be to install Mono. I have done a little research and found that http://psubuntu.com/wiki/InstallationInstructions has instruction on installing Ubuntu and links to download an ISO containing a PS3 specific version of Ubuntu. There is also this cool project at http://code.google.com/p/celldotnet/ that has developed some code to utilize the 6 additional SPU cores of the CPU, not just the general-purpose one that you have access to by default. The problem is that the project documentation seems a little thin. Has anyone set up a PS3 to develop.NET code? If so, what problems did you encounter? Does anyone have any code samples of how to even partially load up one of these monster processors? Update: I do realize that basic.NET/Mono programming will come into play here. The part I am fuzzy on is what sort of data structures do you pass to a specialty core? If I am reading this right, the 6 SPU cores have 128 registers at 128 bits each. I haven't seen any discussion on how to go about coding effectively for this. Update 2: IBM has announced that further development on the Cell processor has been cancelled. While this pretty much kills any desire I might have to develop on the platform, hopefully someone else might add some useful info.
ANSWER:
Just found this posting from Miguel de Icaza's blog. Promising that as recently as Feb 2008 he was looking into this. As he is a member of the SO community now, I hope he can shed some further light on the topic. | [
"c#",
"mono",
"playstation"
] | 4 | 3 | 4,327 | 2 | 0 | 2008-08-26T00:19:00.947000 | 2008-09-26T15:23:35.283000 |
27,195 | 27,196 | Can fogbugz track case dependencies? | Can fogbugz track case dependencies? | Yes and no. Cases can be linked to each other, but if you're looking for a tree of cases (prerequisites and such), you need FogBugz 7 or later. If you're using FogBugz 7.3 or greater, you can now use the Case Dependency Plugin, which was released in April 2011. | Can fogbugz track case dependencies? Can fogbugz track case dependencies? | TITLE:
Can fogbugz track case dependencies?
QUESTION:
Can fogbugz track case dependencies?
ANSWER:
Yes and no. Cases can be linked to each other, but if you're looking for a tree of cases (prerequisites and such), you need FogBugz 7 or later. If you're using FogBugz 7.3 or greater, you can now use the Case Dependency Plugin, which was released in April 2011. | [
"fogbugz"
] | 9 | 9 | 2,061 | 4 | 0 | 2008-08-26T01:17:25.673000 | 2008-08-26T01:19:50.147000 |
27,206 | 27,344 | What are the benefits of using partitions with the Enterprise edition of SQL 2005 | I'm comparing between two techniques to create partitioned tables in SQL 2005. Use partitioned views with a standard version of SQL 2005 (described here ) Use the built in partition in the Enterprise edition of SQL 2005 (described here ) Given that the enterprise edition is much more expensive, I would like to know what are the main benefits of the newer enterprise built-in implementation. Is it just an time saver for the implementation itself. Or will I gain real performance on large DBs? I know i can adjust the constraints in the first option to keep a sliding window into the partitions. Can I do it with the built in version? | searchdotnet rulz! check this out: http://www.eggheadcafe.com/forumarchives/SQLServerdatawarehouse/Dec2005/post25052042.asp Updated: that link is dead. So here's a better one http://msdn.microsoft.com/en-us/library/ms345146(SQL.90).aspx#sql2k5parti_topic6 From above: Some of the performance and manageability benefits (of partioned tables) are Simplify the design and implementation of large tables that need to be partitioned for performance or manageability purposes. Load data into a new partition of an existing partitioned table with minimal disruption in data access in the remaining partitions. Load data into a new partition of an existing partitioned table with performance equal to loading the same data into a new, empty table. Archive and/or remove a portion of a partitioned table while minimally impacting access to the remainder of the table. Allow partitions to be maintained by switching partitions in and out of the partitioned table. Allow better scaling and parallelism for extremely large operations over multiple related tables. Improve performance over all partitions. Improve query optimization time because each partition does not need to be optimized separately. | What are the benefits of using partitions with the Enterprise edition of SQL 2005 I'm comparing between two techniques to create partitioned tables in SQL 2005. Use partitioned views with a standard version of SQL 2005 (described here ) Use the built in partition in the Enterprise edition of SQL 2005 (described here ) Given that the enterprise edition is much more expensive, I would like to know what are the main benefits of the newer enterprise built-in implementation. Is it just an time saver for the implementation itself. Or will I gain real performance on large DBs? I know i can adjust the constraints in the first option to keep a sliding window into the partitions. Can I do it with the built in version? | TITLE:
What are the benefits of using partitions with the Enterprise edition of SQL 2005
QUESTION:
I'm comparing between two techniques to create partitioned tables in SQL 2005. Use partitioned views with a standard version of SQL 2005 (described here ) Use the built in partition in the Enterprise edition of SQL 2005 (described here ) Given that the enterprise edition is much more expensive, I would like to know what are the main benefits of the newer enterprise built-in implementation. Is it just an time saver for the implementation itself. Or will I gain real performance on large DBs? I know i can adjust the constraints in the first option to keep a sliding window into the partitions. Can I do it with the built in version?
ANSWER:
searchdotnet rulz! check this out: http://www.eggheadcafe.com/forumarchives/SQLServerdatawarehouse/Dec2005/post25052042.asp Updated: that link is dead. So here's a better one http://msdn.microsoft.com/en-us/library/ms345146(SQL.90).aspx#sql2k5parti_topic6 From above: Some of the performance and manageability benefits (of partioned tables) are Simplify the design and implementation of large tables that need to be partitioned for performance or manageability purposes. Load data into a new partition of an existing partitioned table with minimal disruption in data access in the remaining partitions. Load data into a new partition of an existing partitioned table with performance equal to loading the same data into a new, empty table. Archive and/or remove a portion of a partitioned table while minimally impacting access to the remainder of the table. Allow partitions to be maintained by switching partitions in and out of the partitioned table. Allow better scaling and parallelism for extremely large operations over multiple related tables. Improve performance over all partitions. Improve query optimization time because each partition does not need to be optimized separately. | [
"sql",
"sql-server-2005",
"partitioning"
] | 2 | 0 | 611 | 2 | 0 | 2008-08-26T01:29:27.423000 | 2008-08-26T03:23:23.843000 |
27,219 | 27,259 | Keeping key value pairs together in HTML <select/> with jQuery? | Given a select with multiple option's in jQuery. $select = $(" "); $select.append(" Jason ") //Key = 1.append(" John ") //Key = 32.append(" Paul ") //Key = 423 How should the key be stored and retrieved? The ID may be an OK place but would not be guaranteed unique if I had multiple select's sharing values (and other scenarios). Thanks and in the spirit of TMTOWTDI. $option = $(" "); $select = $(" "); $select.addOption = function(value,text){ $(this).append($(" ").val(value).text(text)); };
$select.append($option.val(1).text("Jason").clone()).append(" John ").append($(" ").val(423).text("Paul")).addOption("321","Lenny"); | Like lucas said the value attribute is what you need. Using your code it would look something like this ( I added an id attribute to the select to make it fit ): $select = $(' '); $select.append(' Jason ') //Key = 1.append(' John ') //Key = 32.append(' Paul ') //Key = 423 jQuery lets you get the value using the val() method. Using it on the select tag you get the current selected option's value. $( '#mySelect' ).val(); //Gets the value for the current selected option
$( '#mySelect > option' ).each( function( index, option ) { option.val(); //The value for each individual option } ); Just in case, the.each method loops throught every element the query matched. | Keeping key value pairs together in HTML <select/> with jQuery? Given a select with multiple option's in jQuery. $select = $(" "); $select.append(" Jason ") //Key = 1.append(" John ") //Key = 32.append(" Paul ") //Key = 423 How should the key be stored and retrieved? The ID may be an OK place but would not be guaranteed unique if I had multiple select's sharing values (and other scenarios). Thanks and in the spirit of TMTOWTDI. $option = $(" "); $select = $(" "); $select.addOption = function(value,text){ $(this).append($(" ").val(value).text(text)); };
$select.append($option.val(1).text("Jason").clone()).append(" John ").append($(" ").val(423).text("Paul")).addOption("321","Lenny"); | TITLE:
Keeping key value pairs together in HTML <select/> with jQuery?
QUESTION:
Given a select with multiple option's in jQuery. $select = $(" "); $select.append(" Jason ") //Key = 1.append(" John ") //Key = 32.append(" Paul ") //Key = 423 How should the key be stored and retrieved? The ID may be an OK place but would not be guaranteed unique if I had multiple select's sharing values (and other scenarios). Thanks and in the spirit of TMTOWTDI. $option = $(" "); $select = $(" "); $select.addOption = function(value,text){ $(this).append($(" ").val(value).text(text)); };
$select.append($option.val(1).text("Jason").clone()).append(" John ").append($(" ").val(423).text("Paul")).addOption("321","Lenny");
ANSWER:
Like lucas said the value attribute is what you need. Using your code it would look something like this ( I added an id attribute to the select to make it fit ): $select = $(' '); $select.append(' Jason ') //Key = 1.append(' John ') //Key = 32.append(' Paul ') //Key = 423 jQuery lets you get the value using the val() method. Using it on the select tag you get the current selected option's value. $( '#mySelect' ).val(); //Gets the value for the current selected option
$( '#mySelect > option' ).each( function( index, option ) { option.val(); //The value for each individual option } ); Just in case, the.each method loops throught every element the query matched. | [
"javascript",
"jquery",
"html"
] | 8 | 17 | 15,572 | 3 | 0 | 2008-08-26T01:46:27.273000 | 2008-08-26T02:07:27.940000 |
27,222 | 27,236 | DOM manipulation in PHP | I am looking for good methods of manipulating HTML in PHP. For example, the problem I currently have is dealing with malformed HTML. I am getting input that looks something like this: This is some text As you noticed, the HTML is missing closing tags. I could use regex or an XML Parser to solve this problem. However, it is likely that I will have to do other DOM manipulation in the future. I wonder if there are any good PHP libraries that handle DOM manipulation similar to how Javascript deals with DOM manipulation. | PHP has a PECL extension that gives you access to the features of HTML Tidy. Tidy is a pretty powerful library that should be able to take code like that and close tags in an intelligent manner. I use it to clean up malformed XML and HTML sent to me by a classified ad system prior to import. | DOM manipulation in PHP I am looking for good methods of manipulating HTML in PHP. For example, the problem I currently have is dealing with malformed HTML. I am getting input that looks something like this: This is some text As you noticed, the HTML is missing closing tags. I could use regex or an XML Parser to solve this problem. However, it is likely that I will have to do other DOM manipulation in the future. I wonder if there are any good PHP libraries that handle DOM manipulation similar to how Javascript deals with DOM manipulation. | TITLE:
DOM manipulation in PHP
QUESTION:
I am looking for good methods of manipulating HTML in PHP. For example, the problem I currently have is dealing with malformed HTML. I am getting input that looks something like this: This is some text As you noticed, the HTML is missing closing tags. I could use regex or an XML Parser to solve this problem. However, it is likely that I will have to do other DOM manipulation in the future. I wonder if there are any good PHP libraries that handle DOM manipulation similar to how Javascript deals with DOM manipulation.
ANSWER:
PHP has a PECL extension that gives you access to the features of HTML Tidy. Tidy is a pretty powerful library that should be able to take code like that and close tags in an intelligent manner. I use it to clean up malformed XML and HTML sent to me by a classified ad system prior to import. | [
"php",
"html",
"dom"
] | 10 | 11 | 8,857 | 4 | 0 | 2008-08-26T01:47:29.813000 | 2008-08-26T01:55:30.730000 |
27,240 | 27,389 | Why aren't Enumerations Iterable? | In Java 5 and above you have the foreach loop, which works magically on anything that implements Iterable: for (Object o: list) { doStuff(o); } However, Enumerable still does not implement Iterable, meaning that to iterate over an Enumeration you must do the following: for(; e.hasMoreElements();) { doStuff(e.nextElement()); } Does anyone know if there is a reason why Enumeration still does not implement Iterable? Edit: As a clarification, I'm not talking about the language concept of an enum, I'm talking a Java-specific class in the Java API called ' Enumeration '. | Enumeration hasn't been modified to support Iterable because it's an interface not a concrete class (like Vector, which was modifed to support the Collections interface). If Enumeration was changed to support Iterable it would break a bunch of people's code. | Why aren't Enumerations Iterable? In Java 5 and above you have the foreach loop, which works magically on anything that implements Iterable: for (Object o: list) { doStuff(o); } However, Enumerable still does not implement Iterable, meaning that to iterate over an Enumeration you must do the following: for(; e.hasMoreElements();) { doStuff(e.nextElement()); } Does anyone know if there is a reason why Enumeration still does not implement Iterable? Edit: As a clarification, I'm not talking about the language concept of an enum, I'm talking a Java-specific class in the Java API called ' Enumeration '. | TITLE:
Why aren't Enumerations Iterable?
QUESTION:
In Java 5 and above you have the foreach loop, which works magically on anything that implements Iterable: for (Object o: list) { doStuff(o); } However, Enumerable still does not implement Iterable, meaning that to iterate over an Enumeration you must do the following: for(; e.hasMoreElements();) { doStuff(e.nextElement()); } Does anyone know if there is a reason why Enumeration still does not implement Iterable? Edit: As a clarification, I'm not talking about the language concept of an enum, I'm talking a Java-specific class in the Java API called ' Enumeration '.
ANSWER:
Enumeration hasn't been modified to support Iterable because it's an interface not a concrete class (like Vector, which was modifed to support the Collections interface). If Enumeration was changed to support Iterable it would break a bunch of people's code. | [
"java",
"enumeration",
"iterable"
] | 69 | 41 | 21,475 | 6 | 0 | 2008-08-26T01:57:51.427000 | 2008-08-26T03:55:26.963000 |
27,242 | 27,254 | Where can I learn jQuery? Is it worth it? | I've had a lot of good experiences learning about web development on w3schools.com. It's hit or miss, I know, but the PHP and CSS sections specifically have proven very useful for reference. Anyway, I was wondering if there was a similar site for jQuery. I'm interested in learning, but I need it to be online/searchable, so I can refer back to it easily when I need the information in the future. Also, as a brief aside, is jQuery worth learning? Or should I look at different JavaScript libraries? I know Jeff uses jQuery on Stack Overflow and it seems to be working well. Thanks! Edit: jQuery's website has a pretty big list of tutorials, and a seemingly comprehensive documentation page. I haven't had time to go through it all yet, has anyone else had experience with it? Edit 2: It seems Google is now hosting the jQuery libraries. That should give jQuery a pretty big advantage in terms of publicity. Also, if everyone uses a single unified aQuery library hosted at the same place, it should get cached for most Internet users early on and therefore not impact the download footprint of your site should you decide to use it. 2 Months Later... Edit 3: I started using jQuery on a project at work recently and it is great to work with! Just wanted to let everyone know that I have concluded it is ABSOLUTELY worth it to learn and use jQuery. Also, I learned almost entirely from the Official jQuery documentation and tutorials. It's very straightforward. 10 Months Later... jQuery is a part of just about every web app I've made since I initially wrote this post. It makes progressive enhancement a breeze, and helps make the code maintainable. Also, all the jQuery plug-ins are an invaluable resource! 3 Years Later... Still using jQuery just about every day. I now author jQuery plug-ins and consult full time. I'm primarily a Djangonaut but I've done several javascript only contracts with jQuery. It's a life saver. From one jQuery user to another... You should look at templating with jQuery (or underscore -- see below). Other things I've found valuable in addition to jQuery (with estimated portion of projects I use it on): jQuery Form Plugin (95%) jQuery Form Example Plugin (75%) jQuery UI (70%) Underscore.js (80%) CoffeeScript (30%) Backbone.js (10%) | Rick Strahl and Matt Berseth's blogs both tipped me into jQuery and man am I glad they did. jQuery completely changes a) your client programming perspective, b) the grief it causes it you, and c) how much fun it can be! http://www.west-wind.com/weblog/ http://mattberseth.com/ I used the book jQuery in Action http://www.amazon.com/jQuery-Action-Bear-Bibeault/dp/1933988355/ref=sr_1_1?ie=UTF8&s=books&qid=1219716122&sr=1-1 (I bought it used at Amazon for about $22). It has been a big help into bootstrapping me into jQuery. The documentation at jquery.com are also very helpful. A place where jQuery falls a little flat is with its UI components. Those don't seem to be quite ready for primetime just yet. It could be that Prototype or MooTools or ExtJS are as good as jQuery. But for me, jQuery seems to have a little more momentum behind it right now and that counts for something for me. Check jQuery out. It is very cool! | Where can I learn jQuery? Is it worth it? I've had a lot of good experiences learning about web development on w3schools.com. It's hit or miss, I know, but the PHP and CSS sections specifically have proven very useful for reference. Anyway, I was wondering if there was a similar site for jQuery. I'm interested in learning, but I need it to be online/searchable, so I can refer back to it easily when I need the information in the future. Also, as a brief aside, is jQuery worth learning? Or should I look at different JavaScript libraries? I know Jeff uses jQuery on Stack Overflow and it seems to be working well. Thanks! Edit: jQuery's website has a pretty big list of tutorials, and a seemingly comprehensive documentation page. I haven't had time to go through it all yet, has anyone else had experience with it? Edit 2: It seems Google is now hosting the jQuery libraries. That should give jQuery a pretty big advantage in terms of publicity. Also, if everyone uses a single unified aQuery library hosted at the same place, it should get cached for most Internet users early on and therefore not impact the download footprint of your site should you decide to use it. 2 Months Later... Edit 3: I started using jQuery on a project at work recently and it is great to work with! Just wanted to let everyone know that I have concluded it is ABSOLUTELY worth it to learn and use jQuery. Also, I learned almost entirely from the Official jQuery documentation and tutorials. It's very straightforward. 10 Months Later... jQuery is a part of just about every web app I've made since I initially wrote this post. It makes progressive enhancement a breeze, and helps make the code maintainable. Also, all the jQuery plug-ins are an invaluable resource! 3 Years Later... Still using jQuery just about every day. I now author jQuery plug-ins and consult full time. I'm primarily a Djangonaut but I've done several javascript only contracts with jQuery. It's a life saver. From one jQuery user to another... You should look at templating with jQuery (or underscore -- see below). Other things I've found valuable in addition to jQuery (with estimated portion of projects I use it on): jQuery Form Plugin (95%) jQuery Form Example Plugin (75%) jQuery UI (70%) Underscore.js (80%) CoffeeScript (30%) Backbone.js (10%) | TITLE:
Where can I learn jQuery? Is it worth it?
QUESTION:
I've had a lot of good experiences learning about web development on w3schools.com. It's hit or miss, I know, but the PHP and CSS sections specifically have proven very useful for reference. Anyway, I was wondering if there was a similar site for jQuery. I'm interested in learning, but I need it to be online/searchable, so I can refer back to it easily when I need the information in the future. Also, as a brief aside, is jQuery worth learning? Or should I look at different JavaScript libraries? I know Jeff uses jQuery on Stack Overflow and it seems to be working well. Thanks! Edit: jQuery's website has a pretty big list of tutorials, and a seemingly comprehensive documentation page. I haven't had time to go through it all yet, has anyone else had experience with it? Edit 2: It seems Google is now hosting the jQuery libraries. That should give jQuery a pretty big advantage in terms of publicity. Also, if everyone uses a single unified aQuery library hosted at the same place, it should get cached for most Internet users early on and therefore not impact the download footprint of your site should you decide to use it. 2 Months Later... Edit 3: I started using jQuery on a project at work recently and it is great to work with! Just wanted to let everyone know that I have concluded it is ABSOLUTELY worth it to learn and use jQuery. Also, I learned almost entirely from the Official jQuery documentation and tutorials. It's very straightforward. 10 Months Later... jQuery is a part of just about every web app I've made since I initially wrote this post. It makes progressive enhancement a breeze, and helps make the code maintainable. Also, all the jQuery plug-ins are an invaluable resource! 3 Years Later... Still using jQuery just about every day. I now author jQuery plug-ins and consult full time. I'm primarily a Djangonaut but I've done several javascript only contracts with jQuery. It's a life saver. From one jQuery user to another... You should look at templating with jQuery (or underscore -- see below). Other things I've found valuable in addition to jQuery (with estimated portion of projects I use it on): jQuery Form Plugin (95%) jQuery Form Example Plugin (75%) jQuery UI (70%) Underscore.js (80%) CoffeeScript (30%) Backbone.js (10%)
ANSWER:
Rick Strahl and Matt Berseth's blogs both tipped me into jQuery and man am I glad they did. jQuery completely changes a) your client programming perspective, b) the grief it causes it you, and c) how much fun it can be! http://www.west-wind.com/weblog/ http://mattberseth.com/ I used the book jQuery in Action http://www.amazon.com/jQuery-Action-Bear-Bibeault/dp/1933988355/ref=sr_1_1?ie=UTF8&s=books&qid=1219716122&sr=1-1 (I bought it used at Amazon for about $22). It has been a big help into bootstrapping me into jQuery. The documentation at jquery.com are also very helpful. A place where jQuery falls a little flat is with its UI components. Those don't seem to be quite ready for primetime just yet. It could be that Prototype or MooTools or ExtJS are as good as jQuery. But for me, jQuery seems to have a little more momentum behind it right now and that counts for something for me. Check jQuery out. It is very cool! | [
"javascript",
"jquery",
"review"
] | 126 | 44 | 28,858 | 14 | 0 | 2008-08-26T01:58:23.093000 | 2008-08-26T02:05:41.173000 |
27,243 | 27,323 | NHibernate 1.2 to 2.0 migration | What kinds of considerations are there for migrating an application from NHibernate 1.2 to 2.0? What are breaking changes vs. recommended changes? Are there mapping issues? | Breaking changes in NHibernate 2.0 If you have good test coverage it's busywork. Edit: We upgraded this morning. There is nothing major. You have to Flush() the session after you delete. The Expression namespace got renamed to Criterion. All these are covered in the link above. Mappings need no change. It's quite transparent. Oh, and transactions everywhere, but you were probably doing that already. By the way, here's an interesting look at the changes: http://codebetter.com/blogs/patricksmacchia/archive/2008/08/26/nhibernate-2-0-changes-overview.aspx | NHibernate 1.2 to 2.0 migration What kinds of considerations are there for migrating an application from NHibernate 1.2 to 2.0? What are breaking changes vs. recommended changes? Are there mapping issues? | TITLE:
NHibernate 1.2 to 2.0 migration
QUESTION:
What kinds of considerations are there for migrating an application from NHibernate 1.2 to 2.0? What are breaking changes vs. recommended changes? Are there mapping issues?
ANSWER:
Breaking changes in NHibernate 2.0 If you have good test coverage it's busywork. Edit: We upgraded this morning. There is nothing major. You have to Flush() the session after you delete. The Expression namespace got renamed to Criterion. All these are covered in the link above. Mappings need no change. It's quite transparent. Oh, and transactions everywhere, but you were probably doing that already. By the way, here's an interesting look at the changes: http://codebetter.com/blogs/patricksmacchia/archive/2008/08/26/nhibernate-2-0-changes-overview.aspx | [
"nhibernate"
] | 6 | 8 | 3,202 | 2 | 0 | 2008-08-26T01:59:00.457000 | 2008-08-26T03:04:08.333000 |
27,247 | 27,276 | Could you recommend some guides about Epoll on Linux | I need to know about Epoll On linux System. Could you recommend manual or guides about epoll library? need more detailed guides. it's better to have some examples. help me. and Thank you for reading. | Here's an introduction to Epoll, a pretty basic tutorial: http://blog.kovyrin.net/2006/04/13/epoll-asynchronous-network-programming/ A more complete example can be found here: https://banu.com/blog/2/how-to-use-epoll-a-complete-example-in-c/ Also, the man pages | Could you recommend some guides about Epoll on Linux I need to know about Epoll On linux System. Could you recommend manual or guides about epoll library? need more detailed guides. it's better to have some examples. help me. and Thank you for reading. | TITLE:
Could you recommend some guides about Epoll on Linux
QUESTION:
I need to know about Epoll On linux System. Could you recommend manual or guides about epoll library? need more detailed guides. it's better to have some examples. help me. and Thank you for reading.
ANSWER:
Here's an introduction to Epoll, a pretty basic tutorial: http://blog.kovyrin.net/2006/04/13/epoll-asynchronous-network-programming/ A more complete example can be found here: https://banu.com/blog/2/how-to-use-epoll-a-complete-example-in-c/ Also, the man pages | [
"c++",
"linux",
"epoll"
] | 29 | 19 | 36,451 | 2 | 0 | 2008-08-26T02:00:15.820000 | 2008-08-26T02:19:03.140000 |
27,253 | 418,595 | Is there a tool for reformatting C# code? | I am looking for a (preferably) command-line tool that can reformat the C# source code on a directory tree. Ideally, I should be able to customize the formatting. Bonus points if the tool can be run on Mono (or Linux). | You could also try NArrange to reformat your code. The formatting options it supports are still pretty limited, but it can process an entire directory and is a command-line tool. Also, NArrange runs under Mono. | Is there a tool for reformatting C# code? I am looking for a (preferably) command-line tool that can reformat the C# source code on a directory tree. Ideally, I should be able to customize the formatting. Bonus points if the tool can be run on Mono (or Linux). | TITLE:
Is there a tool for reformatting C# code?
QUESTION:
I am looking for a (preferably) command-line tool that can reformat the C# source code on a directory tree. Ideally, I should be able to customize the formatting. Bonus points if the tool can be run on Mono (or Linux).
ANSWER:
You could also try NArrange to reformat your code. The formatting options it supports are still pretty limited, but it can process an entire directory and is a command-line tool. Also, NArrange runs under Mono. | [
"c#",
"code-formatting"
] | 11 | 5 | 4,039 | 10 | 0 | 2008-08-26T02:04:30.817000 | 2009-01-06T23:21:57.443000 |
27,258 | 27,270 | ASP.NET JavaScript Callbacks Without Full PostBacks? | I'm about to start a fairly Ajax heavy feature in my company's application. What I need to do is make an Ajax callback every few minutes a user has been on the page. I don't need to do any DOM updates before, after, or during the callbacks. I don't need any information from the page, just from a site cookie which should always be sent with requests anyway, and an ID value. What I'm curious to find out, is if there is any clean and simple way to make a JavaScript Ajax callback to an ASP.NET page without posting back the rest of the information on the page. I'd like to not have to do this if it is possible. I really just want to be able to call a single method on the page, nothing else. Also, I'm restricted to ASP.NET 2.0 so I can't use any of the new 3.5 framework ASP AJAX features, although I can use the ASP AJAX extensions for the 2.0 framework. UPDATE I've decided to accept DanP 's answer as it seems to be exactly what I'm looking for. Our site already uses jQuery for some things so I'll probably use jQuery for making requests since in my experience it seems to perform much better than ASP's AJAX framework does. What do you think would be the best method of transferring data to the IHttpHandler? Should I add variables to the query string or POST the data I need to send? The only thing I think I have to send is a single ID, but I can't decide what the best method is to send the ID and have the IHttpHandler handle it. I'd like to come up with a solution that would prevent a person with basic computer skills from accidentally or intentionally accessing the page directly or repeating requests. Is this possible? | If you don't want to create a blank page, you could call a IHttpHandler (ashx) file: public class RSSHandler: IHttpHandler { public void ProcessRequest (HttpContext context) { context.Response.ContentType = "text/xml";
string sXml = BuildXMLString(); //not showing this function, //but it creates the XML string context.Response.Write( sXml ); }
public bool IsReusable { get { return true; } }
} | ASP.NET JavaScript Callbacks Without Full PostBacks? I'm about to start a fairly Ajax heavy feature in my company's application. What I need to do is make an Ajax callback every few minutes a user has been on the page. I don't need to do any DOM updates before, after, or during the callbacks. I don't need any information from the page, just from a site cookie which should always be sent with requests anyway, and an ID value. What I'm curious to find out, is if there is any clean and simple way to make a JavaScript Ajax callback to an ASP.NET page without posting back the rest of the information on the page. I'd like to not have to do this if it is possible. I really just want to be able to call a single method on the page, nothing else. Also, I'm restricted to ASP.NET 2.0 so I can't use any of the new 3.5 framework ASP AJAX features, although I can use the ASP AJAX extensions for the 2.0 framework. UPDATE I've decided to accept DanP 's answer as it seems to be exactly what I'm looking for. Our site already uses jQuery for some things so I'll probably use jQuery for making requests since in my experience it seems to perform much better than ASP's AJAX framework does. What do you think would be the best method of transferring data to the IHttpHandler? Should I add variables to the query string or POST the data I need to send? The only thing I think I have to send is a single ID, but I can't decide what the best method is to send the ID and have the IHttpHandler handle it. I'd like to come up with a solution that would prevent a person with basic computer skills from accidentally or intentionally accessing the page directly or repeating requests. Is this possible? | TITLE:
ASP.NET JavaScript Callbacks Without Full PostBacks?
QUESTION:
I'm about to start a fairly Ajax heavy feature in my company's application. What I need to do is make an Ajax callback every few minutes a user has been on the page. I don't need to do any DOM updates before, after, or during the callbacks. I don't need any information from the page, just from a site cookie which should always be sent with requests anyway, and an ID value. What I'm curious to find out, is if there is any clean and simple way to make a JavaScript Ajax callback to an ASP.NET page without posting back the rest of the information on the page. I'd like to not have to do this if it is possible. I really just want to be able to call a single method on the page, nothing else. Also, I'm restricted to ASP.NET 2.0 so I can't use any of the new 3.5 framework ASP AJAX features, although I can use the ASP AJAX extensions for the 2.0 framework. UPDATE I've decided to accept DanP 's answer as it seems to be exactly what I'm looking for. Our site already uses jQuery for some things so I'll probably use jQuery for making requests since in my experience it seems to perform much better than ASP's AJAX framework does. What do you think would be the best method of transferring data to the IHttpHandler? Should I add variables to the query string or POST the data I need to send? The only thing I think I have to send is a single ID, but I can't decide what the best method is to send the ID and have the IHttpHandler handle it. I'd like to come up with a solution that would prevent a person with basic computer skills from accidentally or intentionally accessing the page directly or repeating requests. Is this possible?
ANSWER:
If you don't want to create a blank page, you could call a IHttpHandler (ashx) file: public class RSSHandler: IHttpHandler { public void ProcessRequest (HttpContext context) { context.Response.ContentType = "text/xml";
string sXml = BuildXMLString(); //not showing this function, //but it creates the XML string context.Response.Write( sXml ); }
public bool IsReusable { get { return true; } }
} | [
"asp.net",
"javascript",
"ajax"
] | 6 | 6 | 4,710 | 9 | 0 | 2008-08-26T02:07:25.630000 | 2008-08-26T02:14:36.237000 |
27,266 | 27,280 | Avoid traffic shaping by using ssh on port 443 | I heard that if you use port 443 (the port usually used for https) for ssh, the encrypted packets look the same to your isp. Could this be a way to avoid traffic shaping/throttling? | I'm not sure it's true that any given ssh packet "looks" the same as any given https packet. However, over their lifetime they don't behave the same way. The session set up and tear down don't look alike (SSH offer a plain text banner during initial connect, for one thing). Also, typically wouldn't an https session be short lived? Connect, get your data, disconnect, whereas ssh would connect and persist for long periods of time? I think perhaps using 443 instead of 22 might get past naive filters, but I don't think it would fool someone specifically looking for active attempts to bypass their filters. Is throttling ssh a common occurrence? I've experienced people blocking it, but I don't think I've experienced throttling. Heck, I usually use ssh tunnels to bypass other blocks since people don't usually care about it. | Avoid traffic shaping by using ssh on port 443 I heard that if you use port 443 (the port usually used for https) for ssh, the encrypted packets look the same to your isp. Could this be a way to avoid traffic shaping/throttling? | TITLE:
Avoid traffic shaping by using ssh on port 443
QUESTION:
I heard that if you use port 443 (the port usually used for https) for ssh, the encrypted packets look the same to your isp. Could this be a way to avoid traffic shaping/throttling?
ANSWER:
I'm not sure it's true that any given ssh packet "looks" the same as any given https packet. However, over their lifetime they don't behave the same way. The session set up and tear down don't look alike (SSH offer a plain text banner during initial connect, for one thing). Also, typically wouldn't an https session be short lived? Connect, get your data, disconnect, whereas ssh would connect and persist for long periods of time? I think perhaps using 443 instead of 22 might get past naive filters, but I don't think it would fool someone specifically looking for active attempts to bypass their filters. Is throttling ssh a common occurrence? I've experienced people blocking it, but I don't think I've experienced throttling. Heck, I usually use ssh tunnels to bypass other blocks since people don't usually care about it. | [
"linux",
"ssh",
"https",
"trafficshaping"
] | 6 | 5 | 6,361 | 3 | 0 | 2008-08-26T02:11:52.750000 | 2008-08-26T02:21:48.187000 |
27,292 | 27,298 | What is the best solution for maintaining backup and revision control on live websites? | What is the best solution for maintaining backup and revision control on live websites? As part of my job I work with several live websites. We need an efficient means of maintaining backups of the live folders over time. Additionally, updating these sites can be a pain, especially if a change happens to break in the live environment for whatever reason. What would be ideal would be hassle-free source control. I implemented SVN for a while which was great as a semi-solution for backup as well as revision control (easy reversion of temporary or breaking changes) etc. Unfortunately SVN places.SVN hidden directories everywhere which cause problems, especially when other developers make folder structure changes or copy/move website directories. I've heard the argument that this is a matter of education etc. but the approach taken by SVN is simply not a practical solution for us. I am thinking that maybe an incremental backup solution may be better. Other possibilities include: SVK, which is command-line only which becomes a problem. Besides, I am unsure on how appropriate this would be. Mercurial, perhaps with some triggers to hide the distributed component which is not required in this case and would be unnecessarily complicated for other developers. I experimented briefly with Mercurial but couldn't find a nice way to have the repository seperate and kept constantly in-sync with the live folder working copy. Maybe as a source control solution (making repository and live folder the same place) combined with another backup solution this could be the way to go. One downside of Mercurial is that it doesn't place empty folders under source control which is problematic for websites which often have empty folders as placeholder locations for file uploads etc. Rsync, which I haven't really investigated. I'd really appreciate your advice on the best way to maintain backups of live websites, ideally with an easy means of retrieving past versions quickly. Answer replies: @Kibbee: It's not so much about education as no familiarity with anything but VSS and a lack of time/effort to learn anything else. The xcopy/7-zip approach sounds reasonable I guess but it would quickly take up a lot of room right? As far as source control, I think I'd like the source control to just say that "this is the state of the folder now, I'll deal with that and if I can't match stuff up that's your fault, I'll just start new histories" rather than fail hard. @Steve M: Yeah that's a nicer way of doing it but would require a significant cultural change. Having said that I very much like this approach. @mk: Nice, I didn't think about using Rsync to deploy. Does this only upload the differences? Overwriting the entire live directory everytime we make a change would be problematic due to site downtime. I am still curious to see if there are any more traditional options | You can still use SVN, but instead of doing a checkout on your live environment, do an export, that way no.svn directories will be created. The downside, of course, is that no code changes on your live environment can take place. This is a good thing. As a general rule, code changes on production systems should never be allowed. The change should be made and tested in a development/test/UAT environment, then once confirmed as OK, you can tag that code in SVN with something like RELEASE-x-x-x. Then, on the live system, export the code with that tag. | What is the best solution for maintaining backup and revision control on live websites? What is the best solution for maintaining backup and revision control on live websites? As part of my job I work with several live websites. We need an efficient means of maintaining backups of the live folders over time. Additionally, updating these sites can be a pain, especially if a change happens to break in the live environment for whatever reason. What would be ideal would be hassle-free source control. I implemented SVN for a while which was great as a semi-solution for backup as well as revision control (easy reversion of temporary or breaking changes) etc. Unfortunately SVN places.SVN hidden directories everywhere which cause problems, especially when other developers make folder structure changes or copy/move website directories. I've heard the argument that this is a matter of education etc. but the approach taken by SVN is simply not a practical solution for us. I am thinking that maybe an incremental backup solution may be better. Other possibilities include: SVK, which is command-line only which becomes a problem. Besides, I am unsure on how appropriate this would be. Mercurial, perhaps with some triggers to hide the distributed component which is not required in this case and would be unnecessarily complicated for other developers. I experimented briefly with Mercurial but couldn't find a nice way to have the repository seperate and kept constantly in-sync with the live folder working copy. Maybe as a source control solution (making repository and live folder the same place) combined with another backup solution this could be the way to go. One downside of Mercurial is that it doesn't place empty folders under source control which is problematic for websites which often have empty folders as placeholder locations for file uploads etc. Rsync, which I haven't really investigated. I'd really appreciate your advice on the best way to maintain backups of live websites, ideally with an easy means of retrieving past versions quickly. Answer replies: @Kibbee: It's not so much about education as no familiarity with anything but VSS and a lack of time/effort to learn anything else. The xcopy/7-zip approach sounds reasonable I guess but it would quickly take up a lot of room right? As far as source control, I think I'd like the source control to just say that "this is the state of the folder now, I'll deal with that and if I can't match stuff up that's your fault, I'll just start new histories" rather than fail hard. @Steve M: Yeah that's a nicer way of doing it but would require a significant cultural change. Having said that I very much like this approach. @mk: Nice, I didn't think about using Rsync to deploy. Does this only upload the differences? Overwriting the entire live directory everytime we make a change would be problematic due to site downtime. I am still curious to see if there are any more traditional options | TITLE:
What is the best solution for maintaining backup and revision control on live websites?
QUESTION:
What is the best solution for maintaining backup and revision control on live websites? As part of my job I work with several live websites. We need an efficient means of maintaining backups of the live folders over time. Additionally, updating these sites can be a pain, especially if a change happens to break in the live environment for whatever reason. What would be ideal would be hassle-free source control. I implemented SVN for a while which was great as a semi-solution for backup as well as revision control (easy reversion of temporary or breaking changes) etc. Unfortunately SVN places.SVN hidden directories everywhere which cause problems, especially when other developers make folder structure changes or copy/move website directories. I've heard the argument that this is a matter of education etc. but the approach taken by SVN is simply not a practical solution for us. I am thinking that maybe an incremental backup solution may be better. Other possibilities include: SVK, which is command-line only which becomes a problem. Besides, I am unsure on how appropriate this would be. Mercurial, perhaps with some triggers to hide the distributed component which is not required in this case and would be unnecessarily complicated for other developers. I experimented briefly with Mercurial but couldn't find a nice way to have the repository seperate and kept constantly in-sync with the live folder working copy. Maybe as a source control solution (making repository and live folder the same place) combined with another backup solution this could be the way to go. One downside of Mercurial is that it doesn't place empty folders under source control which is problematic for websites which often have empty folders as placeholder locations for file uploads etc. Rsync, which I haven't really investigated. I'd really appreciate your advice on the best way to maintain backups of live websites, ideally with an easy means of retrieving past versions quickly. Answer replies: @Kibbee: It's not so much about education as no familiarity with anything but VSS and a lack of time/effort to learn anything else. The xcopy/7-zip approach sounds reasonable I guess but it would quickly take up a lot of room right? As far as source control, I think I'd like the source control to just say that "this is the state of the folder now, I'll deal with that and if I can't match stuff up that's your fault, I'll just start new histories" rather than fail hard. @Steve M: Yeah that's a nicer way of doing it but would require a significant cultural change. Having said that I very much like this approach. @mk: Nice, I didn't think about using Rsync to deploy. Does this only upload the differences? Overwriting the entire live directory everytime we make a change would be problematic due to site downtime. I am still curious to see if there are any more traditional options
ANSWER:
You can still use SVN, but instead of doing a checkout on your live environment, do an export, that way no.svn directories will be created. The downside, of course, is that no code changes on your live environment can take place. This is a good thing. As a general rule, code changes on production systems should never be allowed. The change should be made and tested in a development/test/UAT environment, then once confirmed as OK, you can tag that code in SVN with something like RELEASE-x-x-x. Then, on the live system, export the code with that tag. | [
"version-control",
"backup",
"hosting"
] | 3 | 4 | 1,114 | 4 | 0 | 2008-08-26T02:32:39.783000 | 2008-08-26T02:37:51.423000 |
27,294 | 27,310 | Abstract Factory Design Pattern | I'm working on an internal project for my company, and part of the project is to be able to parse various "Tasks" from an XML file into a collection of tasks to be ran later. Because each type of Task has a multitude of different associated fields, I decided it would be best to represent each type of Task with a seperate class. To do this, I constructed an abstract base class: public abstract class Task { public enum TaskType { // Types of Tasks }
public abstract TaskType Type { get; }
public abstract LoadFromXml(XmlElement task); public abstract XmlElement CreateXml(XmlDocument currentDoc); } Each task inherited from this base class, and included the code necessary to create itself from the passed in XmlElement, as well as serialize itself back out to an XmlElement. A basic example: public class MergeTask: Task {
public override TaskType Type { get { return TaskType.Merge; } }
// Lots of Properties / Methods for this Task
public MergeTask (XmlElement elem) { this.LoadFromXml(elem); }
public override LoadFromXml(XmlElement task) { // Populates this Task from the Xml. }
public override XmlElement CreateXml(XmlDocument currentDoc) { // Serializes this class back to xml. } } The parser would then use code similar to this to create a task collection: XmlNode taskNode = parent.SelectNode("tasks");
TaskFactory tf = new TaskFactory();
foreach (XmlNode task in taskNode.ChildNodes) { // Since XmlComments etc will show up if (task is XmlElement) { tasks.Add(tf.CreateTask(task as XmlElement)); } } All of this works wonderfully, and allows me to pass tasks around using the base class, while retaining the structure of having individual classes for each task. However, I am not happy with my code for TaskFactory.CreateTask. This method accepts an XmlElement, and then returns an instance of the appropriate Task class: public Task CreateTask(XmlElement elem) { if (elem!= null) { switch(elem.Name) { case "merge": return new MergeTask(elem); default: throw new ArgumentException("Invalid Task"); } } } Because I have to parse the XMLElement, I'm using a huge (10-15 cases in the real code) switch to pick which child class to instantiate. I'm hoping there is some sort of polymorphic trick I can do here to clean up this method. Any advice? | I use reflection to do this. You can make a factory that basically expands without you having to add any extra code. make sure you have "using System.Reflection", place the following code in your instantiation method. public Task CreateTask(XmlElement elem) { if (elem!= null) { try { Assembly a = typeof(Task).Assembly string type = string.Format("{0}.{1}Task",typeof(Task).Namespace,elem.Name);
//this is only here, so that if that type doesn't exist, this method //throws an exception Type t = a.GetType(type, true, true);
return a.CreateInstance(type, true) as Task; } catch(System.Exception) { throw new ArgumentException("Invalid Task"); } } } Another observation, is that you can make this method, a static and hang it off of the Task class, so that you don't have to new up the TaskFactory, and also you get to save yourself a moving piece to maintain. | Abstract Factory Design Pattern I'm working on an internal project for my company, and part of the project is to be able to parse various "Tasks" from an XML file into a collection of tasks to be ran later. Because each type of Task has a multitude of different associated fields, I decided it would be best to represent each type of Task with a seperate class. To do this, I constructed an abstract base class: public abstract class Task { public enum TaskType { // Types of Tasks }
public abstract TaskType Type { get; }
public abstract LoadFromXml(XmlElement task); public abstract XmlElement CreateXml(XmlDocument currentDoc); } Each task inherited from this base class, and included the code necessary to create itself from the passed in XmlElement, as well as serialize itself back out to an XmlElement. A basic example: public class MergeTask: Task {
public override TaskType Type { get { return TaskType.Merge; } }
// Lots of Properties / Methods for this Task
public MergeTask (XmlElement elem) { this.LoadFromXml(elem); }
public override LoadFromXml(XmlElement task) { // Populates this Task from the Xml. }
public override XmlElement CreateXml(XmlDocument currentDoc) { // Serializes this class back to xml. } } The parser would then use code similar to this to create a task collection: XmlNode taskNode = parent.SelectNode("tasks");
TaskFactory tf = new TaskFactory();
foreach (XmlNode task in taskNode.ChildNodes) { // Since XmlComments etc will show up if (task is XmlElement) { tasks.Add(tf.CreateTask(task as XmlElement)); } } All of this works wonderfully, and allows me to pass tasks around using the base class, while retaining the structure of having individual classes for each task. However, I am not happy with my code for TaskFactory.CreateTask. This method accepts an XmlElement, and then returns an instance of the appropriate Task class: public Task CreateTask(XmlElement elem) { if (elem!= null) { switch(elem.Name) { case "merge": return new MergeTask(elem); default: throw new ArgumentException("Invalid Task"); } } } Because I have to parse the XMLElement, I'm using a huge (10-15 cases in the real code) switch to pick which child class to instantiate. I'm hoping there is some sort of polymorphic trick I can do here to clean up this method. Any advice? | TITLE:
Abstract Factory Design Pattern
QUESTION:
I'm working on an internal project for my company, and part of the project is to be able to parse various "Tasks" from an XML file into a collection of tasks to be ran later. Because each type of Task has a multitude of different associated fields, I decided it would be best to represent each type of Task with a seperate class. To do this, I constructed an abstract base class: public abstract class Task { public enum TaskType { // Types of Tasks }
public abstract TaskType Type { get; }
public abstract LoadFromXml(XmlElement task); public abstract XmlElement CreateXml(XmlDocument currentDoc); } Each task inherited from this base class, and included the code necessary to create itself from the passed in XmlElement, as well as serialize itself back out to an XmlElement. A basic example: public class MergeTask: Task {
public override TaskType Type { get { return TaskType.Merge; } }
// Lots of Properties / Methods for this Task
public MergeTask (XmlElement elem) { this.LoadFromXml(elem); }
public override LoadFromXml(XmlElement task) { // Populates this Task from the Xml. }
public override XmlElement CreateXml(XmlDocument currentDoc) { // Serializes this class back to xml. } } The parser would then use code similar to this to create a task collection: XmlNode taskNode = parent.SelectNode("tasks");
TaskFactory tf = new TaskFactory();
foreach (XmlNode task in taskNode.ChildNodes) { // Since XmlComments etc will show up if (task is XmlElement) { tasks.Add(tf.CreateTask(task as XmlElement)); } } All of this works wonderfully, and allows me to pass tasks around using the base class, while retaining the structure of having individual classes for each task. However, I am not happy with my code for TaskFactory.CreateTask. This method accepts an XmlElement, and then returns an instance of the appropriate Task class: public Task CreateTask(XmlElement elem) { if (elem!= null) { switch(elem.Name) { case "merge": return new MergeTask(elem); default: throw new ArgumentException("Invalid Task"); } } } Because I have to parse the XMLElement, I'm using a huge (10-15 cases in the real code) switch to pick which child class to instantiate. I'm hoping there is some sort of polymorphic trick I can do here to clean up this method. Any advice?
ANSWER:
I use reflection to do this. You can make a factory that basically expands without you having to add any extra code. make sure you have "using System.Reflection", place the following code in your instantiation method. public Task CreateTask(XmlElement elem) { if (elem!= null) { try { Assembly a = typeof(Task).Assembly string type = string.Format("{0}.{1}Task",typeof(Task).Namespace,elem.Name);
//this is only here, so that if that type doesn't exist, this method //throws an exception Type t = a.GetType(type, true, true);
return a.CreateInstance(type, true) as Task; } catch(System.Exception) { throw new ArgumentException("Invalid Task"); } } } Another observation, is that you can make this method, a static and hang it off of the Task class, so that you don't have to new up the TaskFactory, and also you get to save yourself a moving piece to maintain. | [
"c#",
"design-patterns",
"factory"
] | 21 | 12 | 5,051 | 10 | 0 | 2008-08-26T02:35:30.993000 | 2008-08-26T02:45:00.907000 |
27,303 | 27,478 | Databind RenderTransform Scaling in Silverlight 2 Beta 2 | Anyone know if it's possible to databind the ScaleX and ScaleY of a render transform in Silverlight 2 Beta 2? Binding transforms is possible in WPF - But I'm getting an error when setting up my binding in Silverlight through XAML. Perhaps it's possible to do it through code? I want to bind the ScaleX and ScaleY of the ScaleTransform element. I'm getting a runtime error when I try to bind against a double property on my data context: Message="AG_E_PARSER_BAD_PROPERTY_VALUE [Line: 1570 Position: 108]" My binding looks like this: I have triple verified that the binding path is correct - I'm binding a slidebar against the same value and that works just fine... Visibility is of type double and is a number between 0.0 and 30.0. I have a value converter that scales that number down to 0.5 and 1 - I want to scale the size of the fish depending on the clarity of the water. So I don't think it's a problem with the type I'm binding against... | ScaleTransform doesn't have a data context so most likely the binding is looking for SelectedDive.Visibility off it's self and not finding it. There is much in Silverlight xaml and databinding that is different from WPF... Anyway to solve this you will want to set up the binding in code**, or manually listen for the PropertyChanged event of your data object and set the Scale in code behind. I would choose the latter if you wanted to do an animation/storyboard for the scale change. ** i need to check but you may not be able to bind to it. as i recall if the RenderTransform is not part of an animation it gets turned into a matrix transform and all bets are off. | Databind RenderTransform Scaling in Silverlight 2 Beta 2 Anyone know if it's possible to databind the ScaleX and ScaleY of a render transform in Silverlight 2 Beta 2? Binding transforms is possible in WPF - But I'm getting an error when setting up my binding in Silverlight through XAML. Perhaps it's possible to do it through code? I want to bind the ScaleX and ScaleY of the ScaleTransform element. I'm getting a runtime error when I try to bind against a double property on my data context: Message="AG_E_PARSER_BAD_PROPERTY_VALUE [Line: 1570 Position: 108]" My binding looks like this: I have triple verified that the binding path is correct - I'm binding a slidebar against the same value and that works just fine... Visibility is of type double and is a number between 0.0 and 30.0. I have a value converter that scales that number down to 0.5 and 1 - I want to scale the size of the fish depending on the clarity of the water. So I don't think it's a problem with the type I'm binding against... | TITLE:
Databind RenderTransform Scaling in Silverlight 2 Beta 2
QUESTION:
Anyone know if it's possible to databind the ScaleX and ScaleY of a render transform in Silverlight 2 Beta 2? Binding transforms is possible in WPF - But I'm getting an error when setting up my binding in Silverlight through XAML. Perhaps it's possible to do it through code? I want to bind the ScaleX and ScaleY of the ScaleTransform element. I'm getting a runtime error when I try to bind against a double property on my data context: Message="AG_E_PARSER_BAD_PROPERTY_VALUE [Line: 1570 Position: 108]" My binding looks like this: I have triple verified that the binding path is correct - I'm binding a slidebar against the same value and that works just fine... Visibility is of type double and is a number between 0.0 and 30.0. I have a value converter that scales that number down to 0.5 and 1 - I want to scale the size of the fish depending on the clarity of the water. So I don't think it's a problem with the type I'm binding against...
ANSWER:
ScaleTransform doesn't have a data context so most likely the binding is looking for SelectedDive.Visibility off it's self and not finding it. There is much in Silverlight xaml and databinding that is different from WPF... Anyway to solve this you will want to set up the binding in code**, or manually listen for the PropertyChanged event of your data object and set the Scale in code behind. I would choose the latter if you wanted to do an animation/storyboard for the scale change. ** i need to check but you may not be able to bind to it. as i recall if the RenderTransform is not part of an animation it gets turned into a matrix transform and all bets are off. | [
"silverlight",
"data-binding"
] | 1 | 1 | 3,222 | 7 | 0 | 2008-08-26T02:40:08.017000 | 2008-08-26T06:15:17.267000 |
27,345 | 27,352 | How do I install the php_gd2 extension in MAMP on a Mac? | I'm running MAMP 1.7.2 on a Mac and I'd like to install the extension php_gd2. How do I do this? I know that on Windows using WAMP I'd simply select the php_gd2 entry in the extensions menu to activate it. How is it done when using MAMP? I know that I can do it using MacPorts but I'd prefer not to make any changes to my default OS X PHP installation. | You shouldn't need to install the extension. I have 1.7.2 installed and running right now and it has GD bundled (2.0.34 compatible). From the MAMP start page, click on phpinfo and you should see a GD section. | How do I install the php_gd2 extension in MAMP on a Mac? I'm running MAMP 1.7.2 on a Mac and I'd like to install the extension php_gd2. How do I do this? I know that on Windows using WAMP I'd simply select the php_gd2 entry in the extensions menu to activate it. How is it done when using MAMP? I know that I can do it using MacPorts but I'd prefer not to make any changes to my default OS X PHP installation. | TITLE:
How do I install the php_gd2 extension in MAMP on a Mac?
QUESTION:
I'm running MAMP 1.7.2 on a Mac and I'd like to install the extension php_gd2. How do I do this? I know that on Windows using WAMP I'd simply select the php_gd2 entry in the extensions menu to activate it. How is it done when using MAMP? I know that I can do it using MacPorts but I'd prefer not to make any changes to my default OS X PHP installation.
ANSWER:
You shouldn't need to install the extension. I have 1.7.2 installed and running right now and it has GD bundled (2.0.34 compatible). From the MAMP start page, click on phpinfo and you should see a GD section. | [
"php",
"mamp"
] | 6 | 12 | 14,033 | 2 | 0 | 2008-08-26T03:23:34.170000 | 2008-08-26T03:33:39.340000 |
27,359 | 27,371 | RSync only if filesystem is mounted | I want to setup a cron job to rsync a remote system to a backup partition, something like: bash -c 'rsync -avz --delete --exclude=proc --exclude=sys root@remote1:/ /mnt/remote1/' I would like to be able to "set it and forget it" but what if /mnt/remote1 becomes unmounted? (After a reboot or something) I'd like to error out if /mnt/remote1 isn't mounted, rather than filling up the local filesystem. Edit: Here is what I came up with for a script, cleanup improvements appreciated (especially for the empty then... else, I couldn't leave them empty or bash errors) #!/bin/bash
DATA=data ERROR="0"
if cut -d' ' -f2 /proc/mounts | grep -q "^/mnt/$1\$"; then ERROR=0 else if mount /dev/vg/$1 /mnt/$1; then ERROR=0 else ERROR=$? echo "Can't backup $1, /mnt/$1 could not be mounted: $ERROR" fi fi
if [ "$ERROR" = "0" ]; then if cut -d' ' -f2 /proc/mounts | grep -q "^/mnt/$1/$DATA\$"; then ERROR=0 else if mount /dev/vg/$1$DATA /mnt/$1/data; then ERROR=0 else ERROR=$? echo "Can't backup $1, /mnt/$1/data could not be mounted." fi fi fi
if [ "$ERROR" = "0" ]; then rsync -aqz --delete --numeric-ids --exclude=proc --exclude=sys \ root@$1.domain:/ /mnt/$1/ RETVAL=$? echo "Backup of $1 completed, return value of rsync: $RETVAL" fi | if cut -d' ' -f2 /proc/mounts | grep '^/mnt/remote1$' >/dev/null; then rsync -avz... fi Get the list of mounted partitions from /proc/mounts, only match /mnt/remote1 (and if it is mounted, send grep's output to /dev/null ), then run your rsync job. Recent grep s have a -q option that you can use instead of sending the output to /dev/null. | RSync only if filesystem is mounted I want to setup a cron job to rsync a remote system to a backup partition, something like: bash -c 'rsync -avz --delete --exclude=proc --exclude=sys root@remote1:/ /mnt/remote1/' I would like to be able to "set it and forget it" but what if /mnt/remote1 becomes unmounted? (After a reboot or something) I'd like to error out if /mnt/remote1 isn't mounted, rather than filling up the local filesystem. Edit: Here is what I came up with for a script, cleanup improvements appreciated (especially for the empty then... else, I couldn't leave them empty or bash errors) #!/bin/bash
DATA=data ERROR="0"
if cut -d' ' -f2 /proc/mounts | grep -q "^/mnt/$1\$"; then ERROR=0 else if mount /dev/vg/$1 /mnt/$1; then ERROR=0 else ERROR=$? echo "Can't backup $1, /mnt/$1 could not be mounted: $ERROR" fi fi
if [ "$ERROR" = "0" ]; then if cut -d' ' -f2 /proc/mounts | grep -q "^/mnt/$1/$DATA\$"; then ERROR=0 else if mount /dev/vg/$1$DATA /mnt/$1/data; then ERROR=0 else ERROR=$? echo "Can't backup $1, /mnt/$1/data could not be mounted." fi fi fi
if [ "$ERROR" = "0" ]; then rsync -aqz --delete --numeric-ids --exclude=proc --exclude=sys \ root@$1.domain:/ /mnt/$1/ RETVAL=$? echo "Backup of $1 completed, return value of rsync: $RETVAL" fi | TITLE:
RSync only if filesystem is mounted
QUESTION:
I want to setup a cron job to rsync a remote system to a backup partition, something like: bash -c 'rsync -avz --delete --exclude=proc --exclude=sys root@remote1:/ /mnt/remote1/' I would like to be able to "set it and forget it" but what if /mnt/remote1 becomes unmounted? (After a reboot or something) I'd like to error out if /mnt/remote1 isn't mounted, rather than filling up the local filesystem. Edit: Here is what I came up with for a script, cleanup improvements appreciated (especially for the empty then... else, I couldn't leave them empty or bash errors) #!/bin/bash
DATA=data ERROR="0"
if cut -d' ' -f2 /proc/mounts | grep -q "^/mnt/$1\$"; then ERROR=0 else if mount /dev/vg/$1 /mnt/$1; then ERROR=0 else ERROR=$? echo "Can't backup $1, /mnt/$1 could not be mounted: $ERROR" fi fi
if [ "$ERROR" = "0" ]; then if cut -d' ' -f2 /proc/mounts | grep -q "^/mnt/$1/$DATA\$"; then ERROR=0 else if mount /dev/vg/$1$DATA /mnt/$1/data; then ERROR=0 else ERROR=$? echo "Can't backup $1, /mnt/$1/data could not be mounted." fi fi fi
if [ "$ERROR" = "0" ]; then rsync -aqz --delete --numeric-ids --exclude=proc --exclude=sys \ root@$1.domain:/ /mnt/$1/ RETVAL=$? echo "Backup of $1 completed, return value of rsync: $RETVAL" fi
ANSWER:
if cut -d' ' -f2 /proc/mounts | grep '^/mnt/remote1$' >/dev/null; then rsync -avz... fi Get the list of mounted partitions from /proc/mounts, only match /mnt/remote1 (and if it is mounted, send grep's output to /dev/null ), then run your rsync job. Recent grep s have a -q option that you can use instead of sending the output to /dev/null. | [
"bash",
"backup",
"system-administration",
"rsync"
] | 9 | 5 | 9,231 | 6 | 0 | 2008-08-26T03:37:53.463000 | 2008-08-26T03:43:59.753000 |
27,381 | 27,391 | Should websites expand on window resize? | I'm asking this question purely from a usability standpoint! Should a website expand/stretch to fill the viewing area when you resize a browser window? I know for sure there are the obvious cons: Wide columns of text are hard to read. Writing html/css using percents can be a pain. It makes you vulnerable to having your design stretched past it's limits if an image is too wide, or a block of text is added that is too long. (see it's a pain to code the html/css ). The only Pro I can think of is that users who use the font-resizing that is built into their browser won't have to deal with columns that are only a few words long, with a body of white-space on either side. However, I think that may be a browser problem more than anything else (Firefox 3 allows you to zoom everything instead of just the text, which comes in handy all the time) edit: I noticed stack overflow is fixed width, but coding horror resizes. It seems Jeff doesn't have a strong preference either way. | Raw HTML does just that. Are you changing your data so that it doesn't render so good in random sized windows? In the olden days, everyone had VGA screens. Now, that resolution is most uncommon. Who knows what resolutions are going to be common in the future? And why expect a certain minimum width or height? From a usability viewpoint, demanding a certain resolution from your users is just going to create a degraded experience for anyone not using that resolution. Another thing that comes from this is what is fixed width? I've seen plenty of fixed size windows (popups) that just don't render right because my fonts are different from the designer's. | Should websites expand on window resize? I'm asking this question purely from a usability standpoint! Should a website expand/stretch to fill the viewing area when you resize a browser window? I know for sure there are the obvious cons: Wide columns of text are hard to read. Writing html/css using percents can be a pain. It makes you vulnerable to having your design stretched past it's limits if an image is too wide, or a block of text is added that is too long. (see it's a pain to code the html/css ). The only Pro I can think of is that users who use the font-resizing that is built into their browser won't have to deal with columns that are only a few words long, with a body of white-space on either side. However, I think that may be a browser problem more than anything else (Firefox 3 allows you to zoom everything instead of just the text, which comes in handy all the time) edit: I noticed stack overflow is fixed width, but coding horror resizes. It seems Jeff doesn't have a strong preference either way. | TITLE:
Should websites expand on window resize?
QUESTION:
I'm asking this question purely from a usability standpoint! Should a website expand/stretch to fill the viewing area when you resize a browser window? I know for sure there are the obvious cons: Wide columns of text are hard to read. Writing html/css using percents can be a pain. It makes you vulnerable to having your design stretched past it's limits if an image is too wide, or a block of text is added that is too long. (see it's a pain to code the html/css ). The only Pro I can think of is that users who use the font-resizing that is built into their browser won't have to deal with columns that are only a few words long, with a body of white-space on either side. However, I think that may be a browser problem more than anything else (Firefox 3 allows you to zoom everything instead of just the text, which comes in handy all the time) edit: I noticed stack overflow is fixed width, but coding horror resizes. It seems Jeff doesn't have a strong preference either way.
ANSWER:
Raw HTML does just that. Are you changing your data so that it doesn't render so good in random sized windows? In the olden days, everyone had VGA screens. Now, that resolution is most uncommon. Who knows what resolutions are going to be common in the future? And why expect a certain minimum width or height? From a usability viewpoint, demanding a certain resolution from your users is just going to create a degraded experience for anyone not using that resolution. Another thing that comes from this is what is fixed width? I've seen plenty of fixed size windows (popups) that just don't render right because my fonts are different from the designer's. | [
"html",
"css",
"browser",
"usability"
] | 7 | 11 | 2,084 | 15 | 0 | 2008-08-26T03:52:06.723000 | 2008-08-26T03:57:04.010000 |
27,435 | 27,440 | MySQL vs PostgreSQL for Web Applications | I am working on a web application using Python (Django) and would like to know whether MySQL or PostgreSQL would be more suitable when deploying for production. In one podcast Joel said that he had some problems with MySQL and the data wasn't consistent. I would like to know whether someone had any such problems. Also when it comes to performance which can be easily tweaked? | A note to future readers: The text below was last edited in August 2008. That's nearly 11 years ago as of this edit. Software can change rapidly from version to version, so before you go choosing a DBMS based on the advice below, do some research to see if it's still accurate. Check for newer answers below. Better? MySQL is much more commonly provided by web hosts. PostgreSQL is a much more mature product. There's this discussion addressing your "better" question Apparently, according to this web page, MySQL is fast when concurrent access levels are low, and when there are many more reads than writes. On the other hand, it exhibits low scalability with increasing loads and write/read ratios. PostgreSQL is relatively slow at low concurrency levels, but scales well with increasing load levels, while providing enough isolation between concurrent accesses to avoid slowdowns at high write/read ratios. It goes on to link to a number of performance comparisons, because these things are very... sensitive to conditions. So if your decision factor is, " which is faster? " Then the answer is "it depends. If it really matters, test your application against both. " And if you really, really care, you get in two DBAs (one who specializes in each database) and get them to tune the crap out of the databases, and then choose. It's astonishing how expensive good DBAs are; and they are worth every cent. When it matters. Which it probably doesn't, so just pick whichever database you like the sound of and go with it; better performance can be bought with more RAM and CPU, and more appropriate database design, and clever stored procedure tricks and so on - and all of that is cheaper and easier for random-website-X than agonizing over which to pick, MySQL or PostgreSQL, and specialist tuning from expensive DBAs. Joel also said in that podcast that comment would come back to bite him because people would be saying that MySQL was a piece of crap - Joel couldn't get a count of rows back. The plural of anecdote is not data. He said: MySQL is the only database I've ever programmed against in my career that has had data integrity problems, where you do queries and you get nonsense answers back, that are incorrect. and he also said: It's just an anecdote. And that's one of the things that frustrates me, actually, about blogging or just the Internet in general. [...] There's just a weird tendency to make anecdotes into truths and I actually as a blogger I'm starting to feel a little bit guilty about this | MySQL vs PostgreSQL for Web Applications I am working on a web application using Python (Django) and would like to know whether MySQL or PostgreSQL would be more suitable when deploying for production. In one podcast Joel said that he had some problems with MySQL and the data wasn't consistent. I would like to know whether someone had any such problems. Also when it comes to performance which can be easily tweaked? | TITLE:
MySQL vs PostgreSQL for Web Applications
QUESTION:
I am working on a web application using Python (Django) and would like to know whether MySQL or PostgreSQL would be more suitable when deploying for production. In one podcast Joel said that he had some problems with MySQL and the data wasn't consistent. I would like to know whether someone had any such problems. Also when it comes to performance which can be easily tweaked?
ANSWER:
A note to future readers: The text below was last edited in August 2008. That's nearly 11 years ago as of this edit. Software can change rapidly from version to version, so before you go choosing a DBMS based on the advice below, do some research to see if it's still accurate. Check for newer answers below. Better? MySQL is much more commonly provided by web hosts. PostgreSQL is a much more mature product. There's this discussion addressing your "better" question Apparently, according to this web page, MySQL is fast when concurrent access levels are low, and when there are many more reads than writes. On the other hand, it exhibits low scalability with increasing loads and write/read ratios. PostgreSQL is relatively slow at low concurrency levels, but scales well with increasing load levels, while providing enough isolation between concurrent accesses to avoid slowdowns at high write/read ratios. It goes on to link to a number of performance comparisons, because these things are very... sensitive to conditions. So if your decision factor is, " which is faster? " Then the answer is "it depends. If it really matters, test your application against both. " And if you really, really care, you get in two DBAs (one who specializes in each database) and get them to tune the crap out of the databases, and then choose. It's astonishing how expensive good DBAs are; and they are worth every cent. When it matters. Which it probably doesn't, so just pick whichever database you like the sound of and go with it; better performance can be bought with more RAM and CPU, and more appropriate database design, and clever stored procedure tricks and so on - and all of that is cheaper and easier for random-website-X than agonizing over which to pick, MySQL or PostgreSQL, and specialist tuning from expensive DBAs. Joel also said in that podcast that comment would come back to bite him because people would be saying that MySQL was a piece of crap - Joel couldn't get a count of rows back. The plural of anecdote is not data. He said: MySQL is the only database I've ever programmed against in my career that has had data integrity problems, where you do queries and you get nonsense answers back, that are incorrect. and he also said: It's just an anecdote. And that's one of the things that frustrates me, actually, about blogging or just the Internet in general. [...] There's just a weird tendency to make anecdotes into truths and I actually as a blogger I'm starting to feel a little bit guilty about this | [
"mysql",
"postgresql"
] | 135 | 129 | 74,206 | 10 | 0 | 2008-08-26T05:05:35.610000 | 2008-08-26T05:14:50.690000 |
27,442 | 27,448 | Is there a rake task for backing up the data in your database? | Is there a rake task for backing up the data in your database? I already have my schema backed up, but I want to make a backup of the data. It's a small MySQL database. | The below script is a simplified version taken from eycap, specifically from this file. set:dbuser "user" set:dbhost "host" set:database "db"
namespace:db do desc "Get the database password from user" task:get_password do set(:dbpass) do Capistrano::CLI.ui.ask "Enter mysql password: " end end
task:backup_name,:only => {:primary => true } do now = Time.now run "mkdir -p #{shared_path}/db_backups" backup_time = [now.year,now.month,now.day,now.hour,now.min,now.sec].join('-') set:backup_file, "#{shared_path}/db_backups/#{database}-snapshot-#{backup_time}.sql" end
desc "Dump database to backup file" task:dump,:roles =>:db,:only => {:primary => true} do backup_name run "mysqldump --add-drop-table -u #{dbuser} -h #{dbhost} -p#{dbpass} #{database} | bzip2 -c > #{backup_file}.bz2" end end Edit: Yeah, I guess I missed the point that you were looking for a rake task and not a capistrano task, but I don't have a rake one on hand, sorry. | Is there a rake task for backing up the data in your database? Is there a rake task for backing up the data in your database? I already have my schema backed up, but I want to make a backup of the data. It's a small MySQL database. | TITLE:
Is there a rake task for backing up the data in your database?
QUESTION:
Is there a rake task for backing up the data in your database? I already have my schema backed up, but I want to make a backup of the data. It's a small MySQL database.
ANSWER:
The below script is a simplified version taken from eycap, specifically from this file. set:dbuser "user" set:dbhost "host" set:database "db"
namespace:db do desc "Get the database password from user" task:get_password do set(:dbpass) do Capistrano::CLI.ui.ask "Enter mysql password: " end end
task:backup_name,:only => {:primary => true } do now = Time.now run "mkdir -p #{shared_path}/db_backups" backup_time = [now.year,now.month,now.day,now.hour,now.min,now.sec].join('-') set:backup_file, "#{shared_path}/db_backups/#{database}-snapshot-#{backup_time}.sql" end
desc "Dump database to backup file" task:dump,:roles =>:db,:only => {:primary => true} do backup_name run "mysqldump --add-drop-table -u #{dbuser} -h #{dbhost} -p#{dbpass} #{database} | bzip2 -c > #{backup_file}.bz2" end end Edit: Yeah, I guess I missed the point that you were looking for a rake task and not a capistrano task, but I don't have a rake one on hand, sorry. | [
"mysql",
"ruby-on-rails",
"ruby",
"database",
"rake"
] | 5 | 5 | 2,094 | 7 | 0 | 2008-08-26T05:20:41.393000 | 2008-08-26T05:28:39.190000 |
27,455 | 27,459 | Does Mono support System.Drawing and System.Drawing.Printing? | I'm attempting to use Mono to load a bitmap and print it on Linux but I'm getting an exception. Does Mono support printing on Linux? The code/exception are below: EDIT: No longer getting the exception, but I'm still curious what kind of support there is. Leaving the code for posterity or something. private void btnPrintTest_Click(object sender, EventArgs e) { _printDocTest.DefaultPageSettings.Landscape = true; _printDocTest.DefaultPageSettings.Margins = new Margins(50,50,50,50); _printDocTest.Print(); }
void _printDocTest_PrintPage(object sender, PrintPageEventArgs e) { var bmp = new Bitmap("test.bmp");
// Determine center of graph var xCenter = e.MarginBounds.X + (e.MarginBounds.Width - bmp.Width) / 2; var yCenter = e.MarginBounds.Y + (e.MarginBounds.Height - bmp.Height) / 2;
e.Graphics.DrawImage(bmp, xCenter, yCenter);
e.HasMorePages = false; } | From the Mono docs, I think yes: Managed.Windows.Forms (aka System.Windows.Forms): A complete and cross platform, System.Drawing based Winforms implementation. It also useful if you run the Mono Migration Analyzer first. | Does Mono support System.Drawing and System.Drawing.Printing? I'm attempting to use Mono to load a bitmap and print it on Linux but I'm getting an exception. Does Mono support printing on Linux? The code/exception are below: EDIT: No longer getting the exception, but I'm still curious what kind of support there is. Leaving the code for posterity or something. private void btnPrintTest_Click(object sender, EventArgs e) { _printDocTest.DefaultPageSettings.Landscape = true; _printDocTest.DefaultPageSettings.Margins = new Margins(50,50,50,50); _printDocTest.Print(); }
void _printDocTest_PrintPage(object sender, PrintPageEventArgs e) { var bmp = new Bitmap("test.bmp");
// Determine center of graph var xCenter = e.MarginBounds.X + (e.MarginBounds.Width - bmp.Width) / 2; var yCenter = e.MarginBounds.Y + (e.MarginBounds.Height - bmp.Height) / 2;
e.Graphics.DrawImage(bmp, xCenter, yCenter);
e.HasMorePages = false; } | TITLE:
Does Mono support System.Drawing and System.Drawing.Printing?
QUESTION:
I'm attempting to use Mono to load a bitmap and print it on Linux but I'm getting an exception. Does Mono support printing on Linux? The code/exception are below: EDIT: No longer getting the exception, but I'm still curious what kind of support there is. Leaving the code for posterity or something. private void btnPrintTest_Click(object sender, EventArgs e) { _printDocTest.DefaultPageSettings.Landscape = true; _printDocTest.DefaultPageSettings.Margins = new Margins(50,50,50,50); _printDocTest.Print(); }
void _printDocTest_PrintPage(object sender, PrintPageEventArgs e) { var bmp = new Bitmap("test.bmp");
// Determine center of graph var xCenter = e.MarginBounds.X + (e.MarginBounds.Width - bmp.Width) / 2; var yCenter = e.MarginBounds.Y + (e.MarginBounds.Height - bmp.Height) / 2;
e.Graphics.DrawImage(bmp, xCenter, yCenter);
e.HasMorePages = false; }
ANSWER:
From the Mono docs, I think yes: Managed.Windows.Forms (aka System.Windows.Forms): A complete and cross platform, System.Drawing based Winforms implementation. It also useful if you run the Mono Migration Analyzer first. | [
"c#",
".net",
"linux",
"printing",
"mono"
] | 10 | 7 | 9,909 | 2 | 0 | 2008-08-26T05:36:17.407000 | 2008-08-26T05:44:57.543000 |
27,472 | 27,473 | Timeout not being honoured in connection string | I have a long running SQL statement that I want to run, and no matter what I put in the "timeout=" clause of my connection string, it always seems to end after 30 seconds. I'm just using SqlHelper.ExecuteNonQuery() to execute it, and letting it take care of opening connections, etc. Is there something else that could be overriding my timeout, or causing sql server to ignore it? I have run profiler over the query, and the trace doesn't look any different when I run it in management studio, versus in my code. Management studio completes the query in roughly a minute, but even with a timeout set to 300, or 30000, my code still times out after 30 seconds. | What are you using to set the timeout in your connection string? From memory that's "ConnectionTimeout" and only affects the time it takes to actually connect to the server. Each individual command has a separate "CommandTimeout" which would be what you're looking for. Not sure how SqlHelper implements that though. | Timeout not being honoured in connection string I have a long running SQL statement that I want to run, and no matter what I put in the "timeout=" clause of my connection string, it always seems to end after 30 seconds. I'm just using SqlHelper.ExecuteNonQuery() to execute it, and letting it take care of opening connections, etc. Is there something else that could be overriding my timeout, or causing sql server to ignore it? I have run profiler over the query, and the trace doesn't look any different when I run it in management studio, versus in my code. Management studio completes the query in roughly a minute, but even with a timeout set to 300, or 30000, my code still times out after 30 seconds. | TITLE:
Timeout not being honoured in connection string
QUESTION:
I have a long running SQL statement that I want to run, and no matter what I put in the "timeout=" clause of my connection string, it always seems to end after 30 seconds. I'm just using SqlHelper.ExecuteNonQuery() to execute it, and letting it take care of opening connections, etc. Is there something else that could be overriding my timeout, or causing sql server to ignore it? I have run profiler over the query, and the trace doesn't look any different when I run it in management studio, versus in my code. Management studio completes the query in roughly a minute, but even with a timeout set to 300, or 30000, my code still times out after 30 seconds.
ANSWER:
What are you using to set the timeout in your connection string? From memory that's "ConnectionTimeout" and only affects the time it takes to actually connect to the server. Each individual command has a separate "CommandTimeout" which would be what you're looking for. Not sure how SqlHelper implements that though. | [
"sql-server",
"database",
"timeout"
] | 29 | 44 | 40,230 | 2 | 0 | 2008-08-26T06:06:06.557000 | 2008-08-26T06:08:57.877000 |
27,474 | 27,491 | Email SMTP validator | I need to send hundreds of newsletters, but would like to check first if email exists on server. It's called SMTP validation, at least I think so, based on my research on Internet. There's several libraries that can do that, and also a page with open-source code in ASP Classic ( http://www.coveryourasp.com/ValidateEmail.asp#Result3 ), but I have hard time reading ASP Classic, and it seems that it uses some third-party library... Is there some code for SMTP validation in C#, and/or general explanation of how it works? | Be aware that most MTAs (Mail Transfer Agent) will have the VRFY command turned off for spam protection reasons, they'll probably even block you if you try several RCPT TO in a row (see http://www.spamresource.com/2007/01/whatever-happened-to-vrfy.html ). So even if you find a library to do that verification, it won't be worth a lot. Ishmaeel is right, the only way to really find out, is sending an email and see if it bounces or not. @Hrvoje: Yes, I'm suggesting you monitor rejected emails. BUT: not all the bounced mails should automatically end up on your "does not exist"-list, you also have to differentiate between temporary (e.g. mailbox full) and permanent errors. | Email SMTP validator I need to send hundreds of newsletters, but would like to check first if email exists on server. It's called SMTP validation, at least I think so, based on my research on Internet. There's several libraries that can do that, and also a page with open-source code in ASP Classic ( http://www.coveryourasp.com/ValidateEmail.asp#Result3 ), but I have hard time reading ASP Classic, and it seems that it uses some third-party library... Is there some code for SMTP validation in C#, and/or general explanation of how it works? | TITLE:
Email SMTP validator
QUESTION:
I need to send hundreds of newsletters, but would like to check first if email exists on server. It's called SMTP validation, at least I think so, based on my research on Internet. There's several libraries that can do that, and also a page with open-source code in ASP Classic ( http://www.coveryourasp.com/ValidateEmail.asp#Result3 ), but I have hard time reading ASP Classic, and it seems that it uses some third-party library... Is there some code for SMTP validation in C#, and/or general explanation of how it works?
ANSWER:
Be aware that most MTAs (Mail Transfer Agent) will have the VRFY command turned off for spam protection reasons, they'll probably even block you if you try several RCPT TO in a row (see http://www.spamresource.com/2007/01/whatever-happened-to-vrfy.html ). So even if you find a library to do that verification, it won't be worth a lot. Ishmaeel is right, the only way to really find out, is sending an email and see if it bounces or not. @Hrvoje: Yes, I'm suggesting you monitor rejected emails. BUT: not all the bounced mails should automatically end up on your "does not exist"-list, you also have to differentiate between temporary (e.g. mailbox full) and permanent errors. | [
"validation",
"email"
] | 18 | 21 | 51,166 | 7 | 0 | 2008-08-26T06:10:01.367000 | 2008-08-26T06:47:39.843000 |
27,482 | 27,548 | Commenting on LaTeX PDF documents with PDF reader | Im currently writing my bachelor thesis with latex and using TexnicCenter. I want to be able to send my generated pdf file to people and they should be able to write comments. It seems like commenting is not allowed by default, how do I change this? I am using straight to PDF with pdflatex and acrobat reader 9 to read and comment on the files | I think your problem is that acrobat reader doesn't allow commenting on documents not produced by abode approved products, which I don't think pdflatex would be. You should look at the free PDF-XChange Viewer which allows you to comment and annotate the text. Its a portable windows app ( download ), so doesn't need to be installed on your (or the reviewers) machines. | Commenting on LaTeX PDF documents with PDF reader Im currently writing my bachelor thesis with latex and using TexnicCenter. I want to be able to send my generated pdf file to people and they should be able to write comments. It seems like commenting is not allowed by default, how do I change this? I am using straight to PDF with pdflatex and acrobat reader 9 to read and comment on the files | TITLE:
Commenting on LaTeX PDF documents with PDF reader
QUESTION:
Im currently writing my bachelor thesis with latex and using TexnicCenter. I want to be able to send my generated pdf file to people and they should be able to write comments. It seems like commenting is not allowed by default, how do I change this? I am using straight to PDF with pdflatex and acrobat reader 9 to read and comment on the files
ANSWER:
I think your problem is that acrobat reader doesn't allow commenting on documents not produced by abode approved products, which I don't think pdflatex would be. You should look at the free PDF-XChange Viewer which allows you to comment and annotate the text. Its a portable windows app ( download ), so doesn't need to be installed on your (or the reviewers) machines. | [
"pdf",
"latex",
"comments",
"rights-management",
"texnic-center"
] | 17 | 10 | 9,691 | 5 | 0 | 2008-08-26T06:24:16.763000 | 2008-08-26T08:11:51.200000 |
27,492 | 27,501 | C++ Memory management | I've learned in College that you always have to free your unused Objects but not how you actually do it. For example structuring your code right and so on. Are there any general rules on how to handle pointers in C++? I'm currently not allowed to use boost. I have to stick to pure c++ because the framework I'm using forbids any use of generics. | I have worked with the embedded Symbian OS, which had an excellent system in place for this, based entirely on developer conventions. Only one object will ever own a pointer. By default this is the creator. Ownership can be passed on. To indicate passing of ownership, the object is passed as a pointer in the method signature (e.g. void Foo(Bar *zonk);). The owner will decide when to delete the object. To pass an object to a method just for use, the object is passed as a reference in the method signature (e.g. void Foo(Bat &zonk);). Non-owner classes may store references (never pointers) to objects they are given only when they can be certain that the owner will not destroy it during use. Basically, if a class simply uses something, it uses a reference. If a class owns something, it uses a pointer. This worked beautifully and was a pleasure to use. Memory issues were very rare. | C++ Memory management I've learned in College that you always have to free your unused Objects but not how you actually do it. For example structuring your code right and so on. Are there any general rules on how to handle pointers in C++? I'm currently not allowed to use boost. I have to stick to pure c++ because the framework I'm using forbids any use of generics. | TITLE:
C++ Memory management
QUESTION:
I've learned in College that you always have to free your unused Objects but not how you actually do it. For example structuring your code right and so on. Are there any general rules on how to handle pointers in C++? I'm currently not allowed to use boost. I have to stick to pure c++ because the framework I'm using forbids any use of generics.
ANSWER:
I have worked with the embedded Symbian OS, which had an excellent system in place for this, based entirely on developer conventions. Only one object will ever own a pointer. By default this is the creator. Ownership can be passed on. To indicate passing of ownership, the object is passed as a pointer in the method signature (e.g. void Foo(Bar *zonk);). The owner will decide when to delete the object. To pass an object to a method just for use, the object is passed as a reference in the method signature (e.g. void Foo(Bat &zonk);). Non-owner classes may store references (never pointers) to objects they are given only when they can be certain that the owner will not destroy it during use. Basically, if a class simply uses something, it uses a reference. If a class owns something, it uses a pointer. This worked beautifully and was a pleasure to use. Memory issues were very rare. | [
"c++",
"memory",
"pointers"
] | 8 | 14 | 6,989 | 8 | 0 | 2008-08-26T06:50:32.550000 | 2008-08-26T07:08:26.610000 |
27,499 | 27,541 | What is Multiversion Concurrency Control (MVCC) and who supports it? | Recently Jeff has posted regarding his trouble with database deadlocks related to reading. Multiversion Concurrency Control (MVCC) claims to solve this problem. What is it, and what databases support it? updated: these support it (which others?) oracle postgresql | Oracle has had an excellent multi version control system in place since very long(at least since oracle 8.0) Following should help. User A starts a transaction and is updating 1000 rows with some value At Time T1 User B reads the same 1000 rows at time T2. User A updates row 543 with value Y (original value X) User B reaches row 543 and finds that a transaction is in operation since Time T1. The database returns the unmodified record from the Logs. The returned value is the value that was committed at the time less than or equal to T2. If the record could not be retreived from the redo logs it means the database is not setup appropriately. There needs to be more space allocated to the logs. This way the read consitency is achieved. The returned results are always the same with respect to the start time of transaction. So within a transaction the read consistency is achieved. I have tried to explain in the simplest terms possible...there is a lot to multiversioning in databases. | What is Multiversion Concurrency Control (MVCC) and who supports it? Recently Jeff has posted regarding his trouble with database deadlocks related to reading. Multiversion Concurrency Control (MVCC) claims to solve this problem. What is it, and what databases support it? updated: these support it (which others?) oracle postgresql | TITLE:
What is Multiversion Concurrency Control (MVCC) and who supports it?
QUESTION:
Recently Jeff has posted regarding his trouble with database deadlocks related to reading. Multiversion Concurrency Control (MVCC) claims to solve this problem. What is it, and what databases support it? updated: these support it (which others?) oracle postgresql
ANSWER:
Oracle has had an excellent multi version control system in place since very long(at least since oracle 8.0) Following should help. User A starts a transaction and is updating 1000 rows with some value At Time T1 User B reads the same 1000 rows at time T2. User A updates row 543 with value Y (original value X) User B reaches row 543 and finds that a transaction is in operation since Time T1. The database returns the unmodified record from the Logs. The returned value is the value that was committed at the time less than or equal to T2. If the record could not be retreived from the redo logs it means the database is not setup appropriately. There needs to be more space allocated to the logs. This way the read consitency is achieved. The returned results are always the same with respect to the start time of transaction. So within a transaction the read consistency is achieved. I have tried to explain in the simplest terms possible...there is a lot to multiversioning in databases. | [
"database",
"deadlock",
"terminology"
] | 49 | 42 | 37,471 | 15 | 0 | 2008-08-26T07:04:21.657000 | 2008-08-26T08:04:44.073000 |
27,509 | 416,327 | Detecting an undefined object property | How do I check if an object property in JavaScript is undefined? | The usual way to check if the value of a property is the special value undefined, is: if(o.myProperty === undefined) { alert("myProperty value is the special value `undefined`"); } To check if an object does not actually have such a property, and will therefore return undefined by default when you try to access it: if(!o.hasOwnProperty('myProperty')) { alert("myProperty does not exist"); } To check if the value associated with an identifier is the special value undefined, or if that identifier has not been declared: if(typeof myVariable === 'undefined') { alert('myVariable is either the special value `undefined`, or it has not been declared'); } Note: this last method is the only way to refer to an undeclared identifier without an early error, which is different from having a value of undefined. In versions of JavaScript prior to ECMAScript 5, the property named "undefined" on the global object was writeable, and therefore a simple check foo === undefined might behave unexpectedly if it had accidentally been redefined. In modern JavaScript, the property is read-only. However, in modern JavaScript, "undefined" is not a keyword, and so variables inside functions can be named "undefined" and shadow the global property. If you are worried about this (unlikely) edge case, you can use the void operator to get at the special undefined value itself: if(myVariable === void 0) { alert("myVariable is the special value `undefined`"); } | Detecting an undefined object property How do I check if an object property in JavaScript is undefined? | TITLE:
Detecting an undefined object property
QUESTION:
How do I check if an object property in JavaScript is undefined?
ANSWER:
The usual way to check if the value of a property is the special value undefined, is: if(o.myProperty === undefined) { alert("myProperty value is the special value `undefined`"); } To check if an object does not actually have such a property, and will therefore return undefined by default when you try to access it: if(!o.hasOwnProperty('myProperty')) { alert("myProperty does not exist"); } To check if the value associated with an identifier is the special value undefined, or if that identifier has not been declared: if(typeof myVariable === 'undefined') { alert('myVariable is either the special value `undefined`, or it has not been declared'); } Note: this last method is the only way to refer to an undeclared identifier without an early error, which is different from having a value of undefined. In versions of JavaScript prior to ECMAScript 5, the property named "undefined" on the global object was writeable, and therefore a simple check foo === undefined might behave unexpectedly if it had accidentally been redefined. In modern JavaScript, the property is read-only. However, in modern JavaScript, "undefined" is not a keyword, and so variables inside functions can be named "undefined" and shadow the global property. If you are worried about this (unlikely) edge case, you can use the void operator to get at the special undefined value itself: if(myVariable === void 0) { alert("myVariable is the special value `undefined`"); } | [
"javascript",
"object",
"undefined",
"object-property"
] | 3,218 | 2,940 | 1,496,816 | 49 | 0 | 2008-08-26T07:25:08.083000 | 2009-01-06T12:27:41.587000 |
27,532 | 27,536 | Generating gradients programmatically? | Given 2 rgb colors and a rectangular area, I'd like to generate a basic linear gradient between the colors. I've done a quick search and the only thing I've been able to find is this blog entry, but the example code seems to be missing, or at least it was as of this posting. Anything helps, algorithms, code examples, whatever. This will be written in Java, but the display layer is already taken care of, I just need to figure out how to figure out what to display. | you want an interpolation between the first and the second colour. Interpolating colours is easy by calculating the same interpolation for each of its components (R, G, B). There are many ways to interpolate. The easiest is to use linear interpolation: just take percentage p of the first colour and percentage 1 - p of the second: R = firstCol.R * p + secondCol.R * (1 - p) There's another question related to this. There are other methods of interpolation that sometimes work better. For example, using a bell-shaped (sigmoidal) interpolation function makes the transition smoother. /EDIT: Oops, you mean using a predefined function. OK, even easier. The blog post you linked now has an example code in Python. In Java, you could use the GradientPaint. | Generating gradients programmatically? Given 2 rgb colors and a rectangular area, I'd like to generate a basic linear gradient between the colors. I've done a quick search and the only thing I've been able to find is this blog entry, but the example code seems to be missing, or at least it was as of this posting. Anything helps, algorithms, code examples, whatever. This will be written in Java, but the display layer is already taken care of, I just need to figure out how to figure out what to display. | TITLE:
Generating gradients programmatically?
QUESTION:
Given 2 rgb colors and a rectangular area, I'd like to generate a basic linear gradient between the colors. I've done a quick search and the only thing I've been able to find is this blog entry, but the example code seems to be missing, or at least it was as of this posting. Anything helps, algorithms, code examples, whatever. This will be written in Java, but the display layer is already taken care of, I just need to figure out how to figure out what to display.
ANSWER:
you want an interpolation between the first and the second colour. Interpolating colours is easy by calculating the same interpolation for each of its components (R, G, B). There are many ways to interpolate. The easiest is to use linear interpolation: just take percentage p of the first colour and percentage 1 - p of the second: R = firstCol.R * p + secondCol.R * (1 - p) There's another question related to this. There are other methods of interpolation that sometimes work better. For example, using a bell-shaped (sigmoidal) interpolation function makes the transition smoother. /EDIT: Oops, you mean using a predefined function. OK, even easier. The blog post you linked now has an example code in Python. In Java, you could use the GradientPaint. | [
"java",
"colors",
"rgb",
"gradient"
] | 33 | 44 | 50,969 | 5 | 0 | 2008-08-26T07:57:06.773000 | 2008-08-26T08:00:29.183000 |
27,535 | 33,940 | ASP.NET AJAX and PageRequestManagerParserErrorException | Has anyone run into this error message before when using a timer on an ASP.NET page to update a DataGrid every x seconds? Searching google yielded this blog entry and many more but nothing that seems to apply to me yet. The full text of the error message below: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled. | The RoleProvider sets a cookie to cache role information in a cookie. When the cookie resets during an asynch post back from AJAX, you will get this error. The solution is to either set the cookieTimeout in the roleManager section of your web.config to a very large number of minutes, or set the cacheRolesInCookie=false. This was a known bug in AJAX 1.0 Extensions. I'm not sure if it was fixed in future releases, and I should have mentioned that I was using AJAX 1.0 extensions in VS2008 targeting the 2.0 framework. Happy programming! | ASP.NET AJAX and PageRequestManagerParserErrorException Has anyone run into this error message before when using a timer on an ASP.NET page to update a DataGrid every x seconds? Searching google yielded this blog entry and many more but nothing that seems to apply to me yet. The full text of the error message below: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled. | TITLE:
ASP.NET AJAX and PageRequestManagerParserErrorException
QUESTION:
Has anyone run into this error message before when using a timer on an ASP.NET page to update a DataGrid every x seconds? Searching google yielded this blog entry and many more but nothing that seems to apply to me yet. The full text of the error message below: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled.
ANSWER:
The RoleProvider sets a cookie to cache role information in a cookie. When the cookie resets during an asynch post back from AJAX, you will get this error. The solution is to either set the cookieTimeout in the roleManager section of your web.config to a very large number of minutes, or set the cacheRolesInCookie=false. This was a known bug in AJAX 1.0 Extensions. I'm not sure if it was fixed in future releases, and I should have mentioned that I was using AJAX 1.0 extensions in VS2008 targeting the 2.0 framework. Happy programming! | [
"asp.net"
] | 1 | 2 | 567 | 3 | 0 | 2008-08-26T07:59:57.827000 | 2008-08-29T04:03:30.443000 |
27,562 | 27,693 | Oracle write to file | I am running oracle and have a query which pulls some results from the database. I would like to write the results as a text file. How would I go about doing this? My prefered way would be by using UTL_FILE. Would some one have an example of how to do this? | If you are using PL/SQL then you can use the UTL_FILE package, the difference from using sql+ spool is that the files are written to the server file system. UTL_FILE has a number of limitations so an alternative on the server side would be to use Java stored procedures. | Oracle write to file I am running oracle and have a query which pulls some results from the database. I would like to write the results as a text file. How would I go about doing this? My prefered way would be by using UTL_FILE. Would some one have an example of how to do this? | TITLE:
Oracle write to file
QUESTION:
I am running oracle and have a query which pulls some results from the database. I would like to write the results as a text file. How would I go about doing this? My prefered way would be by using UTL_FILE. Would some one have an example of how to do this?
ANSWER:
If you are using PL/SQL then you can use the UTL_FILE package, the difference from using sql+ spool is that the files are written to the server file system. UTL_FILE has a number of limitations so an alternative on the server side would be to use Java stored procedures. | [
"oracle"
] | 5 | 4 | 62,329 | 5 | 0 | 2008-08-26T08:32:51.103000 | 2008-08-26T10:17:37.340000 |
27,567 | 42,689 | Where can I learn more about PyPy's translation function? | I've been having a hard time trying to understand PyPy's translation. It looks like something absolutely revolutionary from simply reading the description, however I'm hard-pressed to find good documentation on actually translating a real world piece of code to something such as LLVM. Does such a thing exist? The official PyPy documentation on it just skims over the functionality, rather than providing anything I can try out myself. | This document seems to go into quite a bit of detail (and I think a complete description is out of scope for a stackoverflow answer): http://codespeak.net/pypy/dist/pypy/doc/translation.html The general idea of translating from one language to another isn't particularly revolutionary, but it has only recently been gaining popularity / applicability in "real-world" applications. GWT does this with Java (generating Javascript) and there is a library for translating Haskell into various other languages as well (called YHC ) | Where can I learn more about PyPy's translation function? I've been having a hard time trying to understand PyPy's translation. It looks like something absolutely revolutionary from simply reading the description, however I'm hard-pressed to find good documentation on actually translating a real world piece of code to something such as LLVM. Does such a thing exist? The official PyPy documentation on it just skims over the functionality, rather than providing anything I can try out myself. | TITLE:
Where can I learn more about PyPy's translation function?
QUESTION:
I've been having a hard time trying to understand PyPy's translation. It looks like something absolutely revolutionary from simply reading the description, however I'm hard-pressed to find good documentation on actually translating a real world piece of code to something such as LLVM. Does such a thing exist? The official PyPy documentation on it just skims over the functionality, rather than providing anything I can try out myself.
ANSWER:
This document seems to go into quite a bit of detail (and I think a complete description is out of scope for a stackoverflow answer): http://codespeak.net/pypy/dist/pypy/doc/translation.html The general idea of translating from one language to another isn't particularly revolutionary, but it has only recently been gaining popularity / applicability in "real-world" applications. GWT does this with Java (generating Javascript) and there is a library for translating Haskell into various other languages as well (called YHC ) | [
"python",
"translation",
"pypy"
] | 11 | 6 | 1,303 | 5 | 0 | 2008-08-26T08:40:28.853000 | 2008-09-03T21:52:46.640000 |
27,568 | 36,972 | Assembler IDE/Simulator for beginner | I'd like to learn how to program in Assembler. I've done a bit of assembly before (during my A-Level Computing course) but that was very definitely a simplified 'pseudo-assembler'. I've borrowed my Dad's old Z80 Assembler reference manual, and that seems quite interesting so if possible I'd like to have a go with Z80 assembler. However, I don't have a Z80 processor to hand, and would like to do it on my PC (I have windows or linux so either is good). I've found various assemblers around on the internet, but I'm not particularly interested in assembling down to a hex file, I want to just be able to assemble it to something that some kind of simulator on the PC can run. Preferably this simulator would show me the contents of all the registers, memory locations etc, and let me step through instructions. I've found a few bits of software that suggest they might do this - but they either refuse to compile, or don't seem to work properly. Has anyone got any suggestions? If there are good simulator/IDE things available for another type of assembler then I could try that instead (assuming there is a good online reference manual available). | I've found a few bits of software that suggest they might do this - but they either refuse to compile, or don't seem to work properly. Has anyone got any suggestions? Write one. You're best off picking a nice, simple instruction set (Z80 should be perfect). I remember doing this as a first-year undergraduate exercise - I think we wrote the simulator in C++ and simulated 6800 assembly, but really any language/instruction set will do. The idea of "learning assembly language" these days is to get the idea of how computers work at the lowest level, only a select few (compiler writers, etc.) have any real reason to actually be writing assembly code these days. Modern processors are stuffed full of features designed to be used by compilers to help optimise code for speed/concurrent execution/power consumption/etc., and trying to write assembly by hand for a modern processor would be a nightmare. Don't fret about getting your application production-ready unless you want to - in all likelihood the bits of software you've found so far were written by people exactly like you who wanted to figure out how assembly works and wrote their own simulator, then realised how much work would be involved in getting it "production ready" so the general public could use it. | Assembler IDE/Simulator for beginner I'd like to learn how to program in Assembler. I've done a bit of assembly before (during my A-Level Computing course) but that was very definitely a simplified 'pseudo-assembler'. I've borrowed my Dad's old Z80 Assembler reference manual, and that seems quite interesting so if possible I'd like to have a go with Z80 assembler. However, I don't have a Z80 processor to hand, and would like to do it on my PC (I have windows or linux so either is good). I've found various assemblers around on the internet, but I'm not particularly interested in assembling down to a hex file, I want to just be able to assemble it to something that some kind of simulator on the PC can run. Preferably this simulator would show me the contents of all the registers, memory locations etc, and let me step through instructions. I've found a few bits of software that suggest they might do this - but they either refuse to compile, or don't seem to work properly. Has anyone got any suggestions? If there are good simulator/IDE things available for another type of assembler then I could try that instead (assuming there is a good online reference manual available). | TITLE:
Assembler IDE/Simulator for beginner
QUESTION:
I'd like to learn how to program in Assembler. I've done a bit of assembly before (during my A-Level Computing course) but that was very definitely a simplified 'pseudo-assembler'. I've borrowed my Dad's old Z80 Assembler reference manual, and that seems quite interesting so if possible I'd like to have a go with Z80 assembler. However, I don't have a Z80 processor to hand, and would like to do it on my PC (I have windows or linux so either is good). I've found various assemblers around on the internet, but I'm not particularly interested in assembling down to a hex file, I want to just be able to assemble it to something that some kind of simulator on the PC can run. Preferably this simulator would show me the contents of all the registers, memory locations etc, and let me step through instructions. I've found a few bits of software that suggest they might do this - but they either refuse to compile, or don't seem to work properly. Has anyone got any suggestions? If there are good simulator/IDE things available for another type of assembler then I could try that instead (assuming there is a good online reference manual available).
ANSWER:
I've found a few bits of software that suggest they might do this - but they either refuse to compile, or don't seem to work properly. Has anyone got any suggestions? Write one. You're best off picking a nice, simple instruction set (Z80 should be perfect). I remember doing this as a first-year undergraduate exercise - I think we wrote the simulator in C++ and simulated 6800 assembly, but really any language/instruction set will do. The idea of "learning assembly language" these days is to get the idea of how computers work at the lowest level, only a select few (compiler writers, etc.) have any real reason to actually be writing assembly code these days. Modern processors are stuffed full of features designed to be used by compilers to help optimise code for speed/concurrent execution/power consumption/etc., and trying to write assembly by hand for a modern processor would be a nightmare. Don't fret about getting your application production-ready unless you want to - in all likelihood the bits of software you've found so far were written by people exactly like you who wanted to figure out how assembly works and wrote their own simulator, then realised how much work would be involved in getting it "production ready" so the general public could use it. | [
"simulator",
"assembly"
] | 20 | 12 | 45,396 | 16 | 0 | 2008-08-26T08:40:39.803000 | 2008-08-31T17:11:41.253000 |
27,570 | 27,584 | Find number of files with a specific extension, in all subdirectories | Is there a way to find the number of files of a specific type without having to loop through all results inn a Directory.GetFiles() or similar method? I am looking for something like this: int ComponentCount = MagicFindFileCount(@"c:\windows\system32", "*.dll"); I know that I can make a recursive function to call Directory.GetFiles, but it would be much cleaner if I could do this without all the iterating. EDIT: If it is not possible to do this without recursing and iterating yourself, what would be the best way to do it? | You should use the Directory.GetFiles(path, searchPattern, SearchOption) overload of Directory.GetFiles(). Path specifies the path, searchPattern specifies your wildcards (e.g., *, *.format) and SearchOption provides the option to include subdirectories. The Length property of the return array of this search will provide the proper file count for your particular search pattern and option: string[] files = directory.GetFiles(@"c:\windows\system32", "*.dll", SearchOption.AllDirectories);
return files.Length; EDIT: Alternatively you can use Directory.EnumerateFiles method return Directory.EnumerateFiles(@"c:\windows\system32", "*.dll", SearchOption.AllDirectories).Count(); | Find number of files with a specific extension, in all subdirectories Is there a way to find the number of files of a specific type without having to loop through all results inn a Directory.GetFiles() or similar method? I am looking for something like this: int ComponentCount = MagicFindFileCount(@"c:\windows\system32", "*.dll"); I know that I can make a recursive function to call Directory.GetFiles, but it would be much cleaner if I could do this without all the iterating. EDIT: If it is not possible to do this without recursing and iterating yourself, what would be the best way to do it? | TITLE:
Find number of files with a specific extension, in all subdirectories
QUESTION:
Is there a way to find the number of files of a specific type without having to loop through all results inn a Directory.GetFiles() or similar method? I am looking for something like this: int ComponentCount = MagicFindFileCount(@"c:\windows\system32", "*.dll"); I know that I can make a recursive function to call Directory.GetFiles, but it would be much cleaner if I could do this without all the iterating. EDIT: If it is not possible to do this without recursing and iterating yourself, what would be the best way to do it?
ANSWER:
You should use the Directory.GetFiles(path, searchPattern, SearchOption) overload of Directory.GetFiles(). Path specifies the path, searchPattern specifies your wildcards (e.g., *, *.format) and SearchOption provides the option to include subdirectories. The Length property of the return array of this search will provide the proper file count for your particular search pattern and option: string[] files = directory.GetFiles(@"c:\windows\system32", "*.dll", SearchOption.AllDirectories);
return files.Length; EDIT: Alternatively you can use Directory.EnumerateFiles method return Directory.EnumerateFiles(@"c:\windows\system32", "*.dll", SearchOption.AllDirectories).Count(); | [
"c#",
"file",
"recursion"
] | 20 | 37 | 43,385 | 7 | 0 | 2008-08-26T08:42:25.463000 | 2008-08-26T08:53:42.380000 |
27,572 | 764,188 | JavaServiceWrapper on 64bit linux, any problems? | We've been using the 32bit linux version of the JavaServiceWrapper for quite a while now and it's working perfectly. We are now considering also using it on 64bit linux systems. There are downloads for 64bit binaries on the website, but looking into Makefile for the 64bit version I found the following comment, though: # This makefile is in progess. It builds, but the resulting libwrapper.so does not yet work. # If you know how to fix it then please help out. Can anyone confirm, that this comment is just outdated and the resulting wrapper will work without flaws? | I've had it running in production on 64-bit red hat without any trouble for the last year or so. | JavaServiceWrapper on 64bit linux, any problems? We've been using the 32bit linux version of the JavaServiceWrapper for quite a while now and it's working perfectly. We are now considering also using it on 64bit linux systems. There are downloads for 64bit binaries on the website, but looking into Makefile for the 64bit version I found the following comment, though: # This makefile is in progess. It builds, but the resulting libwrapper.so does not yet work. # If you know how to fix it then please help out. Can anyone confirm, that this comment is just outdated and the resulting wrapper will work without flaws? | TITLE:
JavaServiceWrapper on 64bit linux, any problems?
QUESTION:
We've been using the 32bit linux version of the JavaServiceWrapper for quite a while now and it's working perfectly. We are now considering also using it on 64bit linux systems. There are downloads for 64bit binaries on the website, but looking into Makefile for the 64bit version I found the following comment, though: # This makefile is in progess. It builds, but the resulting libwrapper.so does not yet work. # If you know how to fix it then please help out. Can anyone confirm, that this comment is just outdated and the resulting wrapper will work without flaws?
ANSWER:
I've had it running in production on 64-bit red hat without any trouble for the last year or so. | [
"java",
"daemon"
] | 2 | 1 | 417 | 3 | 0 | 2008-08-26T08:43:37.457000 | 2009-04-18T20:58:06.200000 |
27,581 | 27,609 | What issues should be considered when overriding equals and hashCode in Java? | What issues / pitfalls must be considered when overriding equals and hashCode? | The theory (for the language lawyers and the mathematically inclined): equals() ( javadoc ) must define an equivalence relation (it must be reflexive, symmetric, and transitive ). In addition, it must be consistent (if the objects are not modified, then it must keep returning the same value). Furthermore, o.equals(null) must always return false. hashCode() ( javadoc ) must also be consistent (if the object is not modified in terms of equals(), it must keep returning the same value). The relation between the two methods is: Whenever a.equals(b), then a.hashCode() must be same as b.hashCode(). In practice: If you override one, then you should override the other. Use the same set of fields that you use to compute equals() to compute hashCode(). Use the excellent helper classes EqualsBuilder and HashCodeBuilder from the Apache Commons Lang library. An example: public class Person { private String name; private int age; //...
@Override public int hashCode() { return new HashCodeBuilder(17, 31). // two randomly chosen prime numbers // if deriving: appendSuper(super.hashCode()). append(name). append(age). toHashCode(); }
@Override public boolean equals(Object obj) { if (!(obj instanceof Person)) return false; if (obj == this) return true;
Person rhs = (Person) obj; return new EqualsBuilder(). // if deriving: appendSuper(super.equals(obj)). append(name, rhs.name). append(age, rhs.age). isEquals(); } } Also remember: When using a hash-based Collection or Map such as HashSet, LinkedHashSet, HashMap, Hashtable, or WeakHashMap, make sure that the hashCode() of the key objects that you put into the collection never changes while the object is in the collection. The bulletproof way to ensure this is to make your keys immutable, which has also other benefits. | What issues should be considered when overriding equals and hashCode in Java? What issues / pitfalls must be considered when overriding equals and hashCode? | TITLE:
What issues should be considered when overriding equals and hashCode in Java?
QUESTION:
What issues / pitfalls must be considered when overriding equals and hashCode?
ANSWER:
The theory (for the language lawyers and the mathematically inclined): equals() ( javadoc ) must define an equivalence relation (it must be reflexive, symmetric, and transitive ). In addition, it must be consistent (if the objects are not modified, then it must keep returning the same value). Furthermore, o.equals(null) must always return false. hashCode() ( javadoc ) must also be consistent (if the object is not modified in terms of equals(), it must keep returning the same value). The relation between the two methods is: Whenever a.equals(b), then a.hashCode() must be same as b.hashCode(). In practice: If you override one, then you should override the other. Use the same set of fields that you use to compute equals() to compute hashCode(). Use the excellent helper classes EqualsBuilder and HashCodeBuilder from the Apache Commons Lang library. An example: public class Person { private String name; private int age; //...
@Override public int hashCode() { return new HashCodeBuilder(17, 31). // two randomly chosen prime numbers // if deriving: appendSuper(super.hashCode()). append(name). append(age). toHashCode(); }
@Override public boolean equals(Object obj) { if (!(obj instanceof Person)) return false; if (obj == this) return true;
Person rhs = (Person) obj; return new EqualsBuilder(). // if deriving: appendSuper(super.equals(obj)). append(name, rhs.name). append(age, rhs.age). isEquals(); } } Also remember: When using a hash-based Collection or Map such as HashSet, LinkedHashSet, HashMap, Hashtable, or WeakHashMap, make sure that the hashCode() of the key objects that you put into the collection never changes while the object is in the collection. The bulletproof way to ensure this is to make your keys immutable, which has also other benefits. | [
"java",
"overriding",
"equals",
"hashcode"
] | 616 | 1,478 | 608,425 | 11 | 0 | 2008-08-26T08:50:26.223000 | 2008-08-26T09:12:42.910000 |
27,598 | 170,414 | How can I make "jconsole" work with Websphere 6.1? | I've deployed some Managed Beans on WebSphere 6.1 and I've managed to invoke them through a standalone client, but when I try to use the application "jconsole" distributed with the standard JDK can can't make it works. Has anyone achieved to connect the jconsole with WAS 6.1? IBM WebSphere 6.1 it's supossed to support JSR 160 JavaTM Management Extensions (JMX) Remote API. Furthermore, it uses the MX4J implementation ( http://mx4j.sourceforge.net ). But I can't make it works with neither "jconsole" nor "MC4J". I have the Classpath and the JAVA_HOME correctly setted, so the issue it's not there. | WebSphere's support for JMX is crap. Particularly, if you need to connect to any secured JMX beans. Here's an interesting tidbit, their own implementation of jConsole will not connect to their own JVM. I have had a PMR open with IBM for over a year to fix this issue, and have gotten nothing but the runaround. They clearly don't want to fix this issue. The only way I have been able to invoke remote secured JMX beans hosted on WebSphere has been to implement a client using the "WebSphere application client". This is basically a stripped down app server used for stuff like this. Open a PMR with IBM. Perhaps if more people report this issue, they will actually fix it. Update: You can run your application as a WebSphere Application Client in RAD. Open the run menu, then choose "Run...". In the dialog that opens, towards the bottom on the left hand side, you will see "WebSphere v6.1 Application Client". I'm not sure how to start and Application Client outside of RAD. | How can I make "jconsole" work with Websphere 6.1? I've deployed some Managed Beans on WebSphere 6.1 and I've managed to invoke them through a standalone client, but when I try to use the application "jconsole" distributed with the standard JDK can can't make it works. Has anyone achieved to connect the jconsole with WAS 6.1? IBM WebSphere 6.1 it's supossed to support JSR 160 JavaTM Management Extensions (JMX) Remote API. Furthermore, it uses the MX4J implementation ( http://mx4j.sourceforge.net ). But I can't make it works with neither "jconsole" nor "MC4J". I have the Classpath and the JAVA_HOME correctly setted, so the issue it's not there. | TITLE:
How can I make "jconsole" work with Websphere 6.1?
QUESTION:
I've deployed some Managed Beans on WebSphere 6.1 and I've managed to invoke them through a standalone client, but when I try to use the application "jconsole" distributed with the standard JDK can can't make it works. Has anyone achieved to connect the jconsole with WAS 6.1? IBM WebSphere 6.1 it's supossed to support JSR 160 JavaTM Management Extensions (JMX) Remote API. Furthermore, it uses the MX4J implementation ( http://mx4j.sourceforge.net ). But I can't make it works with neither "jconsole" nor "MC4J". I have the Classpath and the JAVA_HOME correctly setted, so the issue it's not there.
ANSWER:
WebSphere's support for JMX is crap. Particularly, if you need to connect to any secured JMX beans. Here's an interesting tidbit, their own implementation of jConsole will not connect to their own JVM. I have had a PMR open with IBM for over a year to fix this issue, and have gotten nothing but the runaround. They clearly don't want to fix this issue. The only way I have been able to invoke remote secured JMX beans hosted on WebSphere has been to implement a client using the "WebSphere application client". This is basically a stripped down app server used for stuff like this. Open a PMR with IBM. Perhaps if more people report this issue, they will actually fix it. Update: You can run your application as a WebSphere Application Client in RAD. Open the run menu, then choose "Run...". In the dialog that opens, towards the bottom on the left hand side, you will see "WebSphere v6.1 Application Client". I'm not sure how to start and Application Client outside of RAD. | [
"java",
"websphere",
"jmx",
"mbeans"
] | 3 | 5 | 15,208 | 7 | 0 | 2008-08-26T09:03:21.077000 | 2008-10-04T14:23:15.823000 |
27,599 | 68,096 | 'Reliable' SMS Unicode & GSM Encoding in PHP | ( Updated a little ) I'm not very experienced with internationalization using PHP, it must be said, and a deal of searching didn't really provide the answers I was looking for. I'm in need of working out a reliable way to convert only 'relevant' text to Unicode to send in an SMS message, using PHP (just temporarily, whilst service is rewritten using C#) - obviously, messages sent at the moment are sent as plain text. I could conceivably convert everything to the Unicode charset (as opposed to using the standard GSM charset), but that would mean that all messages would be limited to 70 characters (instead of 160). So, I guess my real question is: what is the most reliable way to detect the requirement for a message to be Unicode-encoded, so I only have to do it when it's absolutely necessary (e.g. for non-Latin-language characters)? Added Info: Okay, so I've spent the morning working on this, and I'm still no further on than when I started (certainly due to my complete lack of competency when it comes to charset conversion). So here's the revised scenario: I have text SMS messages coming from an external source, this external source provides the responses to me in plain text + Unicode slash-escaped characters. E.g. the 'displayed' text: Let's test öäü éàè אין תמיכה בעברית Returns: Let's test \u00f6\u00e4\u00fc \u00e9\u00e0\u00e8 \u05d0\u05d9\u05df \u05ea\u05de\u05d9\u05db\u05d4 \u05d1\u05e2\u05d1\u05e8\u05d9\u05ea Now, I can send on to my SMS provider in plaintext, GSM 03.38 or Unicode. Obviously, sending the above as plaintext results in a lot of missing characters (they're replaced by spaces by my provider) - I need to adopt relating to what content there is. What I want to do with this is the following: If all text is within the GSM 03.38 codepage, send it as-is. (All but the Hebrew characters above fit into this category, but need to be converted.) Otherwise, convert it to Unicode, and send it over multiple messages (as the Unicode limit is 70 chars not 160 for an SMS). As I said above, I'm stumped on doing this in PHP (C# wasn't much of an issue due to some simple conversion functions built-in), but it's quite probable I'm just missing the obvious, here. I couldn't find any pre-made conversion classes for 7-bit encoding in PHP, either - and my attempts to convert the string myself and send it on seemed futile. Any help would be greatly appreciated. | To deal with it conceptually before getting into mechanisms, and apologies if any of this is obvious, a string can be defined as a sequence of Unicode characters, Unicode being a database that gives an id number known as a code point to every character you might need to work with. GSM-338 contains a subset of the Unicode characters, so what you're doing is extracting a set of codepoints from your string, and checking to see if that set is contained in GSM-338. // second column of http://unicode.org/Public/MAPPINGS/ETSI/GSM0338.TXT $gsm338_codepoints = array(0x0040, 0x0000,..., 0x00fc, 0x00e0) $can_use_gsm338 = true; foreach(codepoints($mystring) as $codepoint){ if(!in_array($codepoint, $gsm338_codepoints)){ $can_use_gsm338 = false; break; } } That leaves the definition of the function codepoints($string), which isn't built in to PHP. PHP understands a string to be a sequence of bytes rather than a sequence of Unicode characters. The best way of bridging the gap is to get your strings into UTF8 as quickly as you can and keep them in UTF8 as long as you can - you'll have to use other encodings when dealing with external systems, but isolate the conversion to the interface to that system and deal only with utf8 internally. The functions you need to convert between php strings in utf8 and sequences of codepoints can be found at http://hsivonen.iki.fi/php-utf8/, so that's your codepoints() function. If you're taking data from an external source that gives you Unicode slash-escaped characters ("Let's test \u00f6\u00e4\u00fc..."), that string escape format should be converted to utf8. I don't know offhand of a function to do this, if one can't be found, it's a matter of string/regex processing + the use of the hsivonen.iki.fi functions, for example when you hit \u00f6, replace it with the utf8 representation of the codepoint 0xf6. | 'Reliable' SMS Unicode & GSM Encoding in PHP ( Updated a little ) I'm not very experienced with internationalization using PHP, it must be said, and a deal of searching didn't really provide the answers I was looking for. I'm in need of working out a reliable way to convert only 'relevant' text to Unicode to send in an SMS message, using PHP (just temporarily, whilst service is rewritten using C#) - obviously, messages sent at the moment are sent as plain text. I could conceivably convert everything to the Unicode charset (as opposed to using the standard GSM charset), but that would mean that all messages would be limited to 70 characters (instead of 160). So, I guess my real question is: what is the most reliable way to detect the requirement for a message to be Unicode-encoded, so I only have to do it when it's absolutely necessary (e.g. for non-Latin-language characters)? Added Info: Okay, so I've spent the morning working on this, and I'm still no further on than when I started (certainly due to my complete lack of competency when it comes to charset conversion). So here's the revised scenario: I have text SMS messages coming from an external source, this external source provides the responses to me in plain text + Unicode slash-escaped characters. E.g. the 'displayed' text: Let's test öäü éàè אין תמיכה בעברית Returns: Let's test \u00f6\u00e4\u00fc \u00e9\u00e0\u00e8 \u05d0\u05d9\u05df \u05ea\u05de\u05d9\u05db\u05d4 \u05d1\u05e2\u05d1\u05e8\u05d9\u05ea Now, I can send on to my SMS provider in plaintext, GSM 03.38 or Unicode. Obviously, sending the above as plaintext results in a lot of missing characters (they're replaced by spaces by my provider) - I need to adopt relating to what content there is. What I want to do with this is the following: If all text is within the GSM 03.38 codepage, send it as-is. (All but the Hebrew characters above fit into this category, but need to be converted.) Otherwise, convert it to Unicode, and send it over multiple messages (as the Unicode limit is 70 chars not 160 for an SMS). As I said above, I'm stumped on doing this in PHP (C# wasn't much of an issue due to some simple conversion functions built-in), but it's quite probable I'm just missing the obvious, here. I couldn't find any pre-made conversion classes for 7-bit encoding in PHP, either - and my attempts to convert the string myself and send it on seemed futile. Any help would be greatly appreciated. | TITLE:
'Reliable' SMS Unicode & GSM Encoding in PHP
QUESTION:
( Updated a little ) I'm not very experienced with internationalization using PHP, it must be said, and a deal of searching didn't really provide the answers I was looking for. I'm in need of working out a reliable way to convert only 'relevant' text to Unicode to send in an SMS message, using PHP (just temporarily, whilst service is rewritten using C#) - obviously, messages sent at the moment are sent as plain text. I could conceivably convert everything to the Unicode charset (as opposed to using the standard GSM charset), but that would mean that all messages would be limited to 70 characters (instead of 160). So, I guess my real question is: what is the most reliable way to detect the requirement for a message to be Unicode-encoded, so I only have to do it when it's absolutely necessary (e.g. for non-Latin-language characters)? Added Info: Okay, so I've spent the morning working on this, and I'm still no further on than when I started (certainly due to my complete lack of competency when it comes to charset conversion). So here's the revised scenario: I have text SMS messages coming from an external source, this external source provides the responses to me in plain text + Unicode slash-escaped characters. E.g. the 'displayed' text: Let's test öäü éàè אין תמיכה בעברית Returns: Let's test \u00f6\u00e4\u00fc \u00e9\u00e0\u00e8 \u05d0\u05d9\u05df \u05ea\u05de\u05d9\u05db\u05d4 \u05d1\u05e2\u05d1\u05e8\u05d9\u05ea Now, I can send on to my SMS provider in plaintext, GSM 03.38 or Unicode. Obviously, sending the above as plaintext results in a lot of missing characters (they're replaced by spaces by my provider) - I need to adopt relating to what content there is. What I want to do with this is the following: If all text is within the GSM 03.38 codepage, send it as-is. (All but the Hebrew characters above fit into this category, but need to be converted.) Otherwise, convert it to Unicode, and send it over multiple messages (as the Unicode limit is 70 chars not 160 for an SMS). As I said above, I'm stumped on doing this in PHP (C# wasn't much of an issue due to some simple conversion functions built-in), but it's quite probable I'm just missing the obvious, here. I couldn't find any pre-made conversion classes for 7-bit encoding in PHP, either - and my attempts to convert the string myself and send it on seemed futile. Any help would be greatly appreciated.
ANSWER:
To deal with it conceptually before getting into mechanisms, and apologies if any of this is obvious, a string can be defined as a sequence of Unicode characters, Unicode being a database that gives an id number known as a code point to every character you might need to work with. GSM-338 contains a subset of the Unicode characters, so what you're doing is extracting a set of codepoints from your string, and checking to see if that set is contained in GSM-338. // second column of http://unicode.org/Public/MAPPINGS/ETSI/GSM0338.TXT $gsm338_codepoints = array(0x0040, 0x0000,..., 0x00fc, 0x00e0) $can_use_gsm338 = true; foreach(codepoints($mystring) as $codepoint){ if(!in_array($codepoint, $gsm338_codepoints)){ $can_use_gsm338 = false; break; } } That leaves the definition of the function codepoints($string), which isn't built in to PHP. PHP understands a string to be a sequence of bytes rather than a sequence of Unicode characters. The best way of bridging the gap is to get your strings into UTF8 as quickly as you can and keep them in UTF8 as long as you can - you'll have to use other encodings when dealing with external systems, but isolate the conversion to the interface to that system and deal only with utf8 internally. The functions you need to convert between php strings in utf8 and sequences of codepoints can be found at http://hsivonen.iki.fi/php-utf8/, so that's your codepoints() function. If you're taking data from an external source that gives you Unicode slash-escaped characters ("Let's test \u00f6\u00e4\u00fc..."), that string escape format should be converted to utf8. I don't know offhand of a function to do this, if one can't be found, it's a matter of string/regex processing + the use of the hsivonen.iki.fi functions, for example when you hit \u00f6, replace it with the utf8 representation of the codepoint 0xf6. | [
"php",
"unicode",
"sms",
"gsm"
] | 18 | 9 | 22,634 | 6 | 0 | 2008-08-26T09:04:19.357000 | 2008-09-16T00:03:36.953000 |
27,621 | 27,625 | Unix shell file copy flattening folder structure | On the UNIX bash shell (specifically Mac OS X Leopard) what would be the simplest way to copy every file having a specific extension from a folder hierarchy (including subdirectories) to the same destination folder (without subfolders)? Obviously there is the problem of having duplicates in the source hierarchy. I wouldn't mind if they are overwritten. Example: I need to copy every.txt file in the following hierarchy /foo/a.txt /foo/x.jpg /foo/bar/a.txt /foo/bar/c.jpg /foo/bar/b.txt To a folder named 'dest' and get: /dest/a.txt /dest/b.txt | In bash: find /foo -iname '*.txt' -exec cp \{\} /dest/ \; find will find all the files under the path /foo matching the wildcard *.txt, case insensitively (That's what -iname means). For each file, find will execute cp {} /dest/, with the found file in place of {}. | Unix shell file copy flattening folder structure On the UNIX bash shell (specifically Mac OS X Leopard) what would be the simplest way to copy every file having a specific extension from a folder hierarchy (including subdirectories) to the same destination folder (without subfolders)? Obviously there is the problem of having duplicates in the source hierarchy. I wouldn't mind if they are overwritten. Example: I need to copy every.txt file in the following hierarchy /foo/a.txt /foo/x.jpg /foo/bar/a.txt /foo/bar/c.jpg /foo/bar/b.txt To a folder named 'dest' and get: /dest/a.txt /dest/b.txt | TITLE:
Unix shell file copy flattening folder structure
QUESTION:
On the UNIX bash shell (specifically Mac OS X Leopard) what would be the simplest way to copy every file having a specific extension from a folder hierarchy (including subdirectories) to the same destination folder (without subfolders)? Obviously there is the problem of having duplicates in the source hierarchy. I wouldn't mind if they are overwritten. Example: I need to copy every.txt file in the following hierarchy /foo/a.txt /foo/x.jpg /foo/bar/a.txt /foo/bar/c.jpg /foo/bar/b.txt To a folder named 'dest' and get: /dest/a.txt /dest/b.txt
ANSWER:
In bash: find /foo -iname '*.txt' -exec cp \{\} /dest/ \; find will find all the files under the path /foo matching the wildcard *.txt, case insensitively (That's what -iname means). For each file, find will execute cp {} /dest/, with the found file in place of {}. | [
"unix",
"shell"
] | 44 | 63 | 24,784 | 5 | 0 | 2008-08-26T09:22:34.510000 | 2008-08-26T09:26:18.137000 |
27,622 | 41,046 | How to enable the TRACE macro in Release mode? | The TRACE macro can be used to output diagnostic messages to the debugger when the code is compiled in Debug mode. I need the same messages while in Release mode. Is there a way to achieve this? (Please do not waste your time discussing why I should not be using TRACE in Release mode:-) | Actually, the TRACE macro is a lot more flexible than OutputDebugString. It takes a printf() style format string and parameter list whereas OutputDebugString just takes a single string. In order to implement the full TRACE functionality in release mode you need to do something like this: void trace(const char* format,...) { char buffer[1000];
va_list argptr; va_start(argptr, format); wvsprintf(buffer, format, argptr); va_end(argptr);
OutputDebugString(buffer); } | How to enable the TRACE macro in Release mode? The TRACE macro can be used to output diagnostic messages to the debugger when the code is compiled in Debug mode. I need the same messages while in Release mode. Is there a way to achieve this? (Please do not waste your time discussing why I should not be using TRACE in Release mode:-) | TITLE:
How to enable the TRACE macro in Release mode?
QUESTION:
The TRACE macro can be used to output diagnostic messages to the debugger when the code is compiled in Debug mode. I need the same messages while in Release mode. Is there a way to achieve this? (Please do not waste your time discussing why I should not be using TRACE in Release mode:-)
ANSWER:
Actually, the TRACE macro is a lot more flexible than OutputDebugString. It takes a printf() style format string and parameter list whereas OutputDebugString just takes a single string. In order to implement the full TRACE functionality in release mode you need to do something like this: void trace(const char* format,...) { char buffer[1000];
va_list argptr; va_start(argptr, format); wvsprintf(buffer, format, argptr); va_end(argptr);
OutputDebugString(buffer); } | [
"mfc",
"macros",
"trace"
] | 15 | 8 | 16,114 | 5 | 0 | 2008-08-26T09:22:40.047000 | 2008-09-03T02:11:11.033000 |
27,640 | 27,811 | Integrating Qt into legacy MFC applications | We currently maintain a suit of MFC applications that are fairly well designed, however the user interface is beginning to look tired and a lot of the code is in need quite a bit of refactoring to tidy up some duplication and/or performance problems. We make use of quite a few custom controls that handle all their own drawing (all written using MFC). Recently I've been doing more research into Qt and the benefits it provides (cross-platform and supports what you might call a more "professional" looking framework for UI development). My question is - what would be the best approach to perhaps moving to the Qt framework? Does Qt play nice with MFC? Would it be better to start porting some of our custom controls to Qt and gradually integrate more and more into our existing MFC apps? (is this possible?). Any advice or previous experience is appreciated. | In my company, we are currently using Qt and are very happy with it. I personnally never had to move a MFC-app into using the Qt framework, but here is something which might be of some interest for you: Qt/MFC Migration Framework Qt/MFC Migration Framework It's part of Qt-Solutions, so this means you'll have to buy a Qt license along with a Qt-Solutions license. (edit: not any more ) I hope this helps! | Integrating Qt into legacy MFC applications We currently maintain a suit of MFC applications that are fairly well designed, however the user interface is beginning to look tired and a lot of the code is in need quite a bit of refactoring to tidy up some duplication and/or performance problems. We make use of quite a few custom controls that handle all their own drawing (all written using MFC). Recently I've been doing more research into Qt and the benefits it provides (cross-platform and supports what you might call a more "professional" looking framework for UI development). My question is - what would be the best approach to perhaps moving to the Qt framework? Does Qt play nice with MFC? Would it be better to start porting some of our custom controls to Qt and gradually integrate more and more into our existing MFC apps? (is this possible?). Any advice or previous experience is appreciated. | TITLE:
Integrating Qt into legacy MFC applications
QUESTION:
We currently maintain a suit of MFC applications that are fairly well designed, however the user interface is beginning to look tired and a lot of the code is in need quite a bit of refactoring to tidy up some duplication and/or performance problems. We make use of quite a few custom controls that handle all their own drawing (all written using MFC). Recently I've been doing more research into Qt and the benefits it provides (cross-platform and supports what you might call a more "professional" looking framework for UI development). My question is - what would be the best approach to perhaps moving to the Qt framework? Does Qt play nice with MFC? Would it be better to start porting some of our custom controls to Qt and gradually integrate more and more into our existing MFC apps? (is this possible?). Any advice or previous experience is appreciated.
ANSWER:
In my company, we are currently using Qt and are very happy with it. I personnally never had to move a MFC-app into using the Qt framework, but here is something which might be of some interest for you: Qt/MFC Migration Framework Qt/MFC Migration Framework It's part of Qt-Solutions, so this means you'll have to buy a Qt license along with a Qt-Solutions license. (edit: not any more ) I hope this helps! | [
"c++",
"qt",
"mfc"
] | 9 | 8 | 6,929 | 4 | 0 | 2008-08-26T09:37:52.320000 | 2008-08-26T11:50:35.247000 |
27,655 | 27,661 | Cannot delete, a file with that name may already exist | This is starting to vex me. I recently decided to clear out my FTP, and stumbled across an old Wordpress install I forgot I had (oh yes, very security conscious me). Anyway, for some reason deleting the directory failed so I investigated to see what was causing the blockage and I've narrowed it down to a file in wp-content. Now when I try to delete this file I can get two errors. I've tried in Windowx Explorer ( FTP ) and the Web Control Panel's File Manager. Here's some error shots: As you can see my File manager thinks the file is a Symbolic Link. While it scares me that my web server is host to an obviously religoious artifact I'm also heavily confused by the situation. I've tried renaming the file. I've refreshed the FTP view. I've tried moving the file to another dir (which worked, no success on deletion though). I've tried editing the file and then deletion. And I'm at a loss. Is there a special way to delete SymLinks? I've never heard of them, until now. edit Oho Windows you really are a magician of sorts. I decided to take a look at my FTP via command prompt and guess what? The file doesn't exist. Whether ftp ignores symlinks I don't know but I'm about to give up:P | First of all, try emailing your webhost either for SSH-access or to remove the symlink for you. If you get SSH-access, use: unlink index.php Or if neither works: Create a PHP file there (for instance remove.php) that contains: Then open that file in your browser, afterwards remove the remove.php file. | Cannot delete, a file with that name may already exist This is starting to vex me. I recently decided to clear out my FTP, and stumbled across an old Wordpress install I forgot I had (oh yes, very security conscious me). Anyway, for some reason deleting the directory failed so I investigated to see what was causing the blockage and I've narrowed it down to a file in wp-content. Now when I try to delete this file I can get two errors. I've tried in Windowx Explorer ( FTP ) and the Web Control Panel's File Manager. Here's some error shots: As you can see my File manager thinks the file is a Symbolic Link. While it scares me that my web server is host to an obviously religoious artifact I'm also heavily confused by the situation. I've tried renaming the file. I've refreshed the FTP view. I've tried moving the file to another dir (which worked, no success on deletion though). I've tried editing the file and then deletion. And I'm at a loss. Is there a special way to delete SymLinks? I've never heard of them, until now. edit Oho Windows you really are a magician of sorts. I decided to take a look at my FTP via command prompt and guess what? The file doesn't exist. Whether ftp ignores symlinks I don't know but I'm about to give up:P | TITLE:
Cannot delete, a file with that name may already exist
QUESTION:
This is starting to vex me. I recently decided to clear out my FTP, and stumbled across an old Wordpress install I forgot I had (oh yes, very security conscious me). Anyway, for some reason deleting the directory failed so I investigated to see what was causing the blockage and I've narrowed it down to a file in wp-content. Now when I try to delete this file I can get two errors. I've tried in Windowx Explorer ( FTP ) and the Web Control Panel's File Manager. Here's some error shots: As you can see my File manager thinks the file is a Symbolic Link. While it scares me that my web server is host to an obviously religoious artifact I'm also heavily confused by the situation. I've tried renaming the file. I've refreshed the FTP view. I've tried moving the file to another dir (which worked, no success on deletion though). I've tried editing the file and then deletion. And I'm at a loss. Is there a special way to delete SymLinks? I've never heard of them, until now. edit Oho Windows you really are a magician of sorts. I decided to take a look at my FTP via command prompt and guess what? The file doesn't exist. Whether ftp ignores symlinks I don't know but I'm about to give up:P
ANSWER:
First of all, try emailing your webhost either for SSH-access or to remove the symlink for you. If you get SSH-access, use: unlink index.php Or if neither works: Create a PHP file there (for instance remove.php) that contains: Then open that file in your browser, afterwards remove the remove.php file. | [
"file",
"ftp",
"symlink"
] | 1 | 2 | 677 | 1 | 0 | 2008-08-26T09:50:51.070000 | 2008-08-26T09:55:10.967000 |
27,674 | 619,685 | Dynamic top down list of controls in WindowsForms and C#? | In our project, SharpWired, we're trying to create a download component similar to the download windows in Firefox or Safari. That is, one single top down list of downloads which are custom controls containing progress bars, buttons and what not. The requirements are that there should be one single list, with one element on each row. Each element must be a custom control. The whole list should be dynamically re-sizable, so that when you make it longer / shorter the list adds a scroll bar when needed and when you make it thinner / wider the custom controls should resize to the width of the list. We've tried using a FlowLayoutPanel but haven't gotten resizing to work the way we want to. Preferably we should only have to set anchoring of the custom controls to Left & Right. We've also thought about using a TableLayoutPanel but found adding rows dynamically to be a too big overhead so far. This must be quite a common use case, and it seems a bit weird to me that the FlowLayoutPanel has no intuitive way of doing this. Has anyone done something similar or have tips or tricks to get us under way? Cheers! /Adam | If you don't want to use databinding (via the DataRepeater control, as mentioned above), you could use a regular Panel control and set its AutoScroll property to true (to enable scrollbars). Then, you could manually add your custom controls, and set the Dock property of each one to Top. | Dynamic top down list of controls in WindowsForms and C#? In our project, SharpWired, we're trying to create a download component similar to the download windows in Firefox or Safari. That is, one single top down list of downloads which are custom controls containing progress bars, buttons and what not. The requirements are that there should be one single list, with one element on each row. Each element must be a custom control. The whole list should be dynamically re-sizable, so that when you make it longer / shorter the list adds a scroll bar when needed and when you make it thinner / wider the custom controls should resize to the width of the list. We've tried using a FlowLayoutPanel but haven't gotten resizing to work the way we want to. Preferably we should only have to set anchoring of the custom controls to Left & Right. We've also thought about using a TableLayoutPanel but found adding rows dynamically to be a too big overhead so far. This must be quite a common use case, and it seems a bit weird to me that the FlowLayoutPanel has no intuitive way of doing this. Has anyone done something similar or have tips or tricks to get us under way? Cheers! /Adam | TITLE:
Dynamic top down list of controls in WindowsForms and C#?
QUESTION:
In our project, SharpWired, we're trying to create a download component similar to the download windows in Firefox or Safari. That is, one single top down list of downloads which are custom controls containing progress bars, buttons and what not. The requirements are that there should be one single list, with one element on each row. Each element must be a custom control. The whole list should be dynamically re-sizable, so that when you make it longer / shorter the list adds a scroll bar when needed and when you make it thinner / wider the custom controls should resize to the width of the list. We've tried using a FlowLayoutPanel but haven't gotten resizing to work the way we want to. Preferably we should only have to set anchoring of the custom controls to Left & Right. We've also thought about using a TableLayoutPanel but found adding rows dynamically to be a too big overhead so far. This must be quite a common use case, and it seems a bit weird to me that the FlowLayoutPanel has no intuitive way of doing this. Has anyone done something similar or have tips or tricks to get us under way? Cheers! /Adam
ANSWER:
If you don't want to use databinding (via the DataRepeater control, as mentioned above), you could use a regular Panel control and set its AutoScroll property to true (to enable scrollbars). Then, you could manually add your custom controls, and set the Dock property of each one to Top. | [
"c#",
".net",
"winforms",
"user-interface",
"user-controls"
] | 4 | 2 | 2,629 | 2 | 0 | 2008-08-26T10:03:24.787000 | 2009-03-06T17:25:35.450000 |
27,695 | 1,066,304 | How to "unversion" a file in either svn and/or git | It happens to me all the time. I accidentally version a file, I do not want to be versioned (i.e. developer/machine specific config-files). If I commit this file, I will mess up the paths on all the other developer machines - they will be unhappy. If I do delete the file from versioning, it will be deleted from the other developers machines - they will be unhappy. If I choose to never commit the file, I always have a "dirty" checkout - I am unhappy. Is a clean way to "unversion" a file from revision-control, that will result in no-one being unhappy? edit: trying to clarify a bit: I have already commited the file to the repository and I want to only remove it from versioning - I specifically do not want it to be physically deleted from everyone doing a checkout. I initially wanted it to be ignored. Answer: If I could accept a second answer, it would be this. It answers my question with respect to git - the accepted answer is about svn. | SVN version 1.5 supports removing/deleting a file from a repository with out losing the local file taken from http://subversion.tigris.org/svn_1.5_releasenotes.html New --keep-local option retains path after delete.. Delete (remove) now takes a --keep-local option to retain its targets locally, so paths will not be removed even if unmodified. | How to "unversion" a file in either svn and/or git It happens to me all the time. I accidentally version a file, I do not want to be versioned (i.e. developer/machine specific config-files). If I commit this file, I will mess up the paths on all the other developer machines - they will be unhappy. If I do delete the file from versioning, it will be deleted from the other developers machines - they will be unhappy. If I choose to never commit the file, I always have a "dirty" checkout - I am unhappy. Is a clean way to "unversion" a file from revision-control, that will result in no-one being unhappy? edit: trying to clarify a bit: I have already commited the file to the repository and I want to only remove it from versioning - I specifically do not want it to be physically deleted from everyone doing a checkout. I initially wanted it to be ignored. Answer: If I could accept a second answer, it would be this. It answers my question with respect to git - the accepted answer is about svn. | TITLE:
How to "unversion" a file in either svn and/or git
QUESTION:
It happens to me all the time. I accidentally version a file, I do not want to be versioned (i.e. developer/machine specific config-files). If I commit this file, I will mess up the paths on all the other developer machines - they will be unhappy. If I do delete the file from versioning, it will be deleted from the other developers machines - they will be unhappy. If I choose to never commit the file, I always have a "dirty" checkout - I am unhappy. Is a clean way to "unversion" a file from revision-control, that will result in no-one being unhappy? edit: trying to clarify a bit: I have already commited the file to the repository and I want to only remove it from versioning - I specifically do not want it to be physically deleted from everyone doing a checkout. I initially wanted it to be ignored. Answer: If I could accept a second answer, it would be this. It answers my question with respect to git - the accepted answer is about svn.
ANSWER:
SVN version 1.5 supports removing/deleting a file from a repository with out losing the local file taken from http://subversion.tigris.org/svn_1.5_releasenotes.html New --keep-local option retains path after delete.. Delete (remove) now takes a --keep-local option to retain its targets locally, so paths will not be removed even if unmodified. | [
"svn",
"git",
"version-control",
"versioning"
] | 80 | 35 | 57,898 | 15 | 0 | 2008-08-26T10:20:41.407000 | 2009-06-30T21:59:45.613000 |
27,700 | 27,749 | C++ : Opening a file in non exclusive mode | I have to develop an application which parses a log file and sends specific data to a server. It has to run on both Linux and Windows. The problem appears when I want to test the log rolling system (which appends.1 to the name of the creates a new one with the same name). On Windows (haven't tested yet on Linux) I can't rename a file that I have opened with std::ifstream() (exclusive access?) even if I open it in "input mode" (ios::in). Is there a cross-platform way to open file in a non-exclusive way? | Is there a way to open file in a non-exclusive way, Yes, using Win32, passing the various FILE_SHARE_Xxxx flags to CreateFile. is it cross platform? No, it requires platform-specific code. Due to annoying backwards compatibility concerns (DOS applications, being single-tasking, assume that nothing can delete a file out from under them, i.e. that they can fclose() and then fopen() without anything going amiss; Win16 preserved this assumption to make porting DOS applications easier, Win32 preserved this assumption to make porting Win16 applications easier, and it's awful), Windows defaults to opening files exclusively. The underlying OS infrastructure supports deleting/renaming open files (although I believe it does have the restriction that memory-mapped files cannot be deleted, which I think isn't a restriction found on *nix), but the default opening semantics do not. C++ has no notion of any of this; the C++ operating environment is much the same as the DOS operating environment--no other applications running concurrently, so no need to control file sharing. | C++ : Opening a file in non exclusive mode I have to develop an application which parses a log file and sends specific data to a server. It has to run on both Linux and Windows. The problem appears when I want to test the log rolling system (which appends.1 to the name of the creates a new one with the same name). On Windows (haven't tested yet on Linux) I can't rename a file that I have opened with std::ifstream() (exclusive access?) even if I open it in "input mode" (ios::in). Is there a cross-platform way to open file in a non-exclusive way? | TITLE:
C++ : Opening a file in non exclusive mode
QUESTION:
I have to develop an application which parses a log file and sends specific data to a server. It has to run on both Linux and Windows. The problem appears when I want to test the log rolling system (which appends.1 to the name of the creates a new one with the same name). On Windows (haven't tested yet on Linux) I can't rename a file that I have opened with std::ifstream() (exclusive access?) even if I open it in "input mode" (ios::in). Is there a cross-platform way to open file in a non-exclusive way?
ANSWER:
Is there a way to open file in a non-exclusive way, Yes, using Win32, passing the various FILE_SHARE_Xxxx flags to CreateFile. is it cross platform? No, it requires platform-specific code. Due to annoying backwards compatibility concerns (DOS applications, being single-tasking, assume that nothing can delete a file out from under them, i.e. that they can fclose() and then fopen() without anything going amiss; Win16 preserved this assumption to make porting DOS applications easier, Win32 preserved this assumption to make porting Win16 applications easier, and it's awful), Windows defaults to opening files exclusively. The underlying OS infrastructure supports deleting/renaming open files (although I believe it does have the restriction that memory-mapped files cannot be deleted, which I think isn't a restriction found on *nix), but the default opening semantics do not. C++ has no notion of any of this; the C++ operating environment is much the same as the DOS operating environment--no other applications running concurrently, so no need to control file sharing. | [
"c++",
"windows",
"linux",
"filesystems"
] | 6 | 3 | 7,652 | 5 | 0 | 2008-08-26T10:24:10.680000 | 2008-08-26T11:02:41.227000 |
27,726 | 27,751 | What are some instances in which expression trees are useful? | I completely understand the concept of expression trees, but I am having a hard time trying to find situations in which they are useful. Is there a specific instance in which expression trees can be applied? Or is it only useful as a transport mechanism for code? I feel like I am missing something here. Thanks! | Or is it only useful as a transport mechanism for code? It's useful as an execution mechanism for code. Using the interpreter pattern, expression trees can directly be interpreted. This is useful because it's very easy and fast to implement. Such interpreters are ubiquitous and used even in cases that don't seem to “interpret” anything, e.g. for printing nested structures. | What are some instances in which expression trees are useful? I completely understand the concept of expression trees, but I am having a hard time trying to find situations in which they are useful. Is there a specific instance in which expression trees can be applied? Or is it only useful as a transport mechanism for code? I feel like I am missing something here. Thanks! | TITLE:
What are some instances in which expression trees are useful?
QUESTION:
I completely understand the concept of expression trees, but I am having a hard time trying to find situations in which they are useful. Is there a specific instance in which expression trees can be applied? Or is it only useful as a transport mechanism for code? I feel like I am missing something here. Thanks!
ANSWER:
Or is it only useful as a transport mechanism for code? It's useful as an execution mechanism for code. Using the interpreter pattern, expression trees can directly be interpreted. This is useful because it's very easy and fast to implement. Such interpreters are ubiquitous and used even in cases that don't seem to “interpret” anything, e.g. for printing nested structures. | [
"c#",
"expression"
] | 11 | 6 | 1,534 | 3 | 0 | 2008-08-26T10:45:59.927000 | 2008-08-26T11:03:34.687000 |
27,729 | 28,512 | Flex tools for Mac | I'm starting developing with Flex on my Mac but i don't find good tools to ease the development (apart from Flex Builder). What is your favourite choice for Flex development on Mac? | TextMate + the Flex and ActionScript 3 bundles is a great combo. Throw in ProjectPlus and you have an almost full featured development environment. What's missing is visual design tools (which I'm sceptical of anyway), debugger (the command line version isn't very easy to work with) and a profiler. I've long used TextMate and the additions mentioned above for all my Flex development, but lately the lack of debugger and profiler has made me use FlexBuilder too, just to get those tools. | Flex tools for Mac I'm starting developing with Flex on my Mac but i don't find good tools to ease the development (apart from Flex Builder). What is your favourite choice for Flex development on Mac? | TITLE:
Flex tools for Mac
QUESTION:
I'm starting developing with Flex on my Mac but i don't find good tools to ease the development (apart from Flex Builder). What is your favourite choice for Flex development on Mac?
ANSWER:
TextMate + the Flex and ActionScript 3 bundles is a great combo. Throw in ProjectPlus and you have an almost full featured development environment. What's missing is visual design tools (which I'm sceptical of anyway), debugger (the command line version isn't very easy to work with) and a profiler. I've long used TextMate and the additions mentioned above for all my Flex development, but lately the lack of debugger and profiler has made me use FlexBuilder too, just to get those tools. | [
"apache-flex",
"macos"
] | 6 | 6 | 3,801 | 3 | 0 | 2008-08-26T10:48:04.710000 | 2008-08-26T16:15:41.053000 |
27,733 | 27,854 | So what am I missing with this here WPF? | Background: I have a little video playing app with a UI inspired by the venerable Sasami2k, just updated to use VMR9 (i.e. Direct3D9 with DirectShow) and be less unstable. Currently, it's a C++ app using raw Win32, through necessity: none of the various toolkits are worth a damn. WPF, in particular, was not possible, due to its airspace restrictions. OK, so, now that D3DImage exists it might be viable to mix and match D3D/VMR9/DirectShow and WPF. Given past frustrations with Win32's inextensibility, this seems like a good thing. But y'know, I'm falling at the first hurdle here. With Win32 I have created (very easily) a borderless window that's resizable, resizes proportionately, snaps to the screen edges, and takes up the whole screen (including taskbar area) when maximized. It's a video app, so these are all pretty desirable properties. OK, so, how to do the same with WPF? In Win32, I use: WM_GETMINMAXINFO to control the maximize behaviour WM_NCHITTEST to control the resize borders WM_MOVING to control the snap-to-screen-edges WM_SIZING to control the resize aspect ratio However, looking at WPF it seems that the various events arrive too late, unless I'm misunderstanding the documentation? For example, I don't know when I'm mid-move, as LocationChanged says it fires only once the window has moved (which is too late). Similarly, it appears that StateChanged only fires once the window has been restored/maximized (when I need the information prior to the maximize, to tell the system the correct maximize size). And I seem to be completely overlooking where the system tells me about resizes. Likewise the hit testing. So, uh, am I missing something here, or do I have no choice but to drop back to hooking the wndproc of this thing anyway? Can I do what I want without hooking the WndProc? If I have to use the WndProc I might as well stick with my existing codebase; I want to have simpler, cleaner UI code, and moving away from the WndProc is fundamental to this. If I do have to hook the WndProc, I have to wonder-- why? Win32 has got the sizing/sized, moving/moved, poschanging/poschanged window messages, and they're all useful. Why wouldn't WPF replicate the same set of events? It seems like an unnecessary gap in functionality. Plus, it means that WPF is tied to a specific USER32-dependent implementation. This means that MS can't (in Windows 7 or 8, say) invert the display layer to make WPF "native" and emulate HWNDs and WndProcs for legacy apps--even though this is precisely what MS should be doing. | And I seem to be completely overlooking where the system tells me about resizes. Likewise the hit testing. For the resizing you're indeed missing the SizeChanged event. AFAIK there is sadly no OnSizeChanging, OnLocationChanging and OnStateChanging event on a Window in.NET I saw that one, but as far as I can tell it only fires after the size has changed, whereas I need the event to fire during the resize. Unless I'm misreading the docs and it actually fires continuously? It does not fire continuously but you can probably use the ResizeBegin and ResizeEnd events and be able to do that. Aren't they WinForms events? Hmm, you're right. | So what am I missing with this here WPF? Background: I have a little video playing app with a UI inspired by the venerable Sasami2k, just updated to use VMR9 (i.e. Direct3D9 with DirectShow) and be less unstable. Currently, it's a C++ app using raw Win32, through necessity: none of the various toolkits are worth a damn. WPF, in particular, was not possible, due to its airspace restrictions. OK, so, now that D3DImage exists it might be viable to mix and match D3D/VMR9/DirectShow and WPF. Given past frustrations with Win32's inextensibility, this seems like a good thing. But y'know, I'm falling at the first hurdle here. With Win32 I have created (very easily) a borderless window that's resizable, resizes proportionately, snaps to the screen edges, and takes up the whole screen (including taskbar area) when maximized. It's a video app, so these are all pretty desirable properties. OK, so, how to do the same with WPF? In Win32, I use: WM_GETMINMAXINFO to control the maximize behaviour WM_NCHITTEST to control the resize borders WM_MOVING to control the snap-to-screen-edges WM_SIZING to control the resize aspect ratio However, looking at WPF it seems that the various events arrive too late, unless I'm misunderstanding the documentation? For example, I don't know when I'm mid-move, as LocationChanged says it fires only once the window has moved (which is too late). Similarly, it appears that StateChanged only fires once the window has been restored/maximized (when I need the information prior to the maximize, to tell the system the correct maximize size). And I seem to be completely overlooking where the system tells me about resizes. Likewise the hit testing. So, uh, am I missing something here, or do I have no choice but to drop back to hooking the wndproc of this thing anyway? Can I do what I want without hooking the WndProc? If I have to use the WndProc I might as well stick with my existing codebase; I want to have simpler, cleaner UI code, and moving away from the WndProc is fundamental to this. If I do have to hook the WndProc, I have to wonder-- why? Win32 has got the sizing/sized, moving/moved, poschanging/poschanged window messages, and they're all useful. Why wouldn't WPF replicate the same set of events? It seems like an unnecessary gap in functionality. Plus, it means that WPF is tied to a specific USER32-dependent implementation. This means that MS can't (in Windows 7 or 8, say) invert the display layer to make WPF "native" and emulate HWNDs and WndProcs for legacy apps--even though this is precisely what MS should be doing. | TITLE:
So what am I missing with this here WPF?
QUESTION:
Background: I have a little video playing app with a UI inspired by the venerable Sasami2k, just updated to use VMR9 (i.e. Direct3D9 with DirectShow) and be less unstable. Currently, it's a C++ app using raw Win32, through necessity: none of the various toolkits are worth a damn. WPF, in particular, was not possible, due to its airspace restrictions. OK, so, now that D3DImage exists it might be viable to mix and match D3D/VMR9/DirectShow and WPF. Given past frustrations with Win32's inextensibility, this seems like a good thing. But y'know, I'm falling at the first hurdle here. With Win32 I have created (very easily) a borderless window that's resizable, resizes proportionately, snaps to the screen edges, and takes up the whole screen (including taskbar area) when maximized. It's a video app, so these are all pretty desirable properties. OK, so, how to do the same with WPF? In Win32, I use: WM_GETMINMAXINFO to control the maximize behaviour WM_NCHITTEST to control the resize borders WM_MOVING to control the snap-to-screen-edges WM_SIZING to control the resize aspect ratio However, looking at WPF it seems that the various events arrive too late, unless I'm misunderstanding the documentation? For example, I don't know when I'm mid-move, as LocationChanged says it fires only once the window has moved (which is too late). Similarly, it appears that StateChanged only fires once the window has been restored/maximized (when I need the information prior to the maximize, to tell the system the correct maximize size). And I seem to be completely overlooking where the system tells me about resizes. Likewise the hit testing. So, uh, am I missing something here, or do I have no choice but to drop back to hooking the wndproc of this thing anyway? Can I do what I want without hooking the WndProc? If I have to use the WndProc I might as well stick with my existing codebase; I want to have simpler, cleaner UI code, and moving away from the WndProc is fundamental to this. If I do have to hook the WndProc, I have to wonder-- why? Win32 has got the sizing/sized, moving/moved, poschanging/poschanged window messages, and they're all useful. Why wouldn't WPF replicate the same set of events? It seems like an unnecessary gap in functionality. Plus, it means that WPF is tied to a specific USER32-dependent implementation. This means that MS can't (in Windows 7 or 8, say) invert the display layer to make WPF "native" and emulate HWNDs and WndProcs for legacy apps--even though this is precisely what MS should be doing.
ANSWER:
And I seem to be completely overlooking where the system tells me about resizes. Likewise the hit testing. For the resizing you're indeed missing the SizeChanged event. AFAIK there is sadly no OnSizeChanging, OnLocationChanging and OnStateChanging event on a Window in.NET I saw that one, but as far as I can tell it only fires after the size has changed, whereas I need the event to fire during the resize. Unless I'm misreading the docs and it actually fires continuously? It does not fire continuously but you can probably use the ResizeBegin and ResizeEnd events and be able to do that. Aren't they WinForms events? Hmm, you're right. | [
"wpf",
"winapi"
] | 1 | 1 | 1,938 | 4 | 0 | 2008-08-26T10:51:34.390000 | 2008-08-26T12:12:58.407000 |
27,742 | 27,750 | Finding the crash dump files for a C# app | An app I'm writing always crashes on a clients computer, but I don't get an exception description, or a stack trace. The only thing I get is a crash report that windows wants to send to Microsoft. I would like to get that dump file and investigate it myself, but I cannot find it. When I "View the contents of the error report" I can see the different memory dumps, but I cannot copy it or save it. | You can use the Windows debugging tools to view the crash dump. To get the most use out of it, you'll need an exact copy of the symbols for that application (i.e. same version). Have a look at Tess's blog for tutorials on how to use the Windows debugging tools. I refer to her blog constantly whenever I'm in need of analysing crash dumps. | Finding the crash dump files for a C# app An app I'm writing always crashes on a clients computer, but I don't get an exception description, or a stack trace. The only thing I get is a crash report that windows wants to send to Microsoft. I would like to get that dump file and investigate it myself, but I cannot find it. When I "View the contents of the error report" I can see the different memory dumps, but I cannot copy it or save it. | TITLE:
Finding the crash dump files for a C# app
QUESTION:
An app I'm writing always crashes on a clients computer, but I don't get an exception description, or a stack trace. The only thing I get is a crash report that windows wants to send to Microsoft. I would like to get that dump file and investigate it myself, but I cannot find it. When I "View the contents of the error report" I can see the different memory dumps, but I cannot copy it or save it.
ANSWER:
You can use the Windows debugging tools to view the crash dump. To get the most use out of it, you'll need an exact copy of the symbols for that application (i.e. same version). Have a look at Tess's blog for tutorials on how to use the Windows debugging tools. I refer to her blog constantly whenever I'm in need of analysing crash dumps. | [
"c#",
"crash",
"memory-dump"
] | 12 | 8 | 8,426 | 2 | 0 | 2008-08-26T10:56:37.717000 | 2008-08-26T11:03:32.957000 |
27,743 | 31,556 | How do I gracefully shut down a Mongrel web server | My RubyOnRails app is set up with the usual pack of mongrels behind Apache configuration. We've noticed that our Mongrel web server memory usage can grow quite large on certain operations and we'd really like to be able to dynamically do a graceful restart of selected Mongrel processes at any time. However, for reasons I won't go into here it can sometimes be very important that we don't interrupt a Mongrel while it is servicing a request, so I assume a simple process kill isn't the answer. Ideally, I want to send the Mongrel a signal that says "finish whatever you're doing and then quit before accepting any more connections". Is there a standard technique or best practice for this? | I've done a little more investigation into the Mongrel source and it turns out that Mongrel installs a signal handler to catch an standard process kill (TERM) and do a graceful shutdown, so I don't need a special procedure after all. You can see this working from the log output you get when killing a Mongrel while it's processing a request. For example: ** TERM signal received. Thu Aug 28 00:52:35 +0000 2008: Reaping 2 threads for slow workers because of 'shutdown' Waiting for 2 requests to finish, could take 60 seconds.Thu Aug 28 00:52:41 +0000 2008: Reaping 2 threads for slow workers because of 'shutdown' Waiting for 2 requests to finish, could take 60 seconds.Thu Aug 28 00:52:43 +0000 2008 (13051) Rendering layoutfalsecontent_typetext/htmlactionindex within layouts/application | How do I gracefully shut down a Mongrel web server My RubyOnRails app is set up with the usual pack of mongrels behind Apache configuration. We've noticed that our Mongrel web server memory usage can grow quite large on certain operations and we'd really like to be able to dynamically do a graceful restart of selected Mongrel processes at any time. However, for reasons I won't go into here it can sometimes be very important that we don't interrupt a Mongrel while it is servicing a request, so I assume a simple process kill isn't the answer. Ideally, I want to send the Mongrel a signal that says "finish whatever you're doing and then quit before accepting any more connections". Is there a standard technique or best practice for this? | TITLE:
How do I gracefully shut down a Mongrel web server
QUESTION:
My RubyOnRails app is set up with the usual pack of mongrels behind Apache configuration. We've noticed that our Mongrel web server memory usage can grow quite large on certain operations and we'd really like to be able to dynamically do a graceful restart of selected Mongrel processes at any time. However, for reasons I won't go into here it can sometimes be very important that we don't interrupt a Mongrel while it is servicing a request, so I assume a simple process kill isn't the answer. Ideally, I want to send the Mongrel a signal that says "finish whatever you're doing and then quit before accepting any more connections". Is there a standard technique or best practice for this?
ANSWER:
I've done a little more investigation into the Mongrel source and it turns out that Mongrel installs a signal handler to catch an standard process kill (TERM) and do a graceful shutdown, so I don't need a special procedure after all. You can see this working from the log output you get when killing a Mongrel while it's processing a request. For example: ** TERM signal received. Thu Aug 28 00:52:35 +0000 2008: Reaping 2 threads for slow workers because of 'shutdown' Waiting for 2 requests to finish, could take 60 seconds.Thu Aug 28 00:52:41 +0000 2008: Reaping 2 threads for slow workers because of 'shutdown' Waiting for 2 requests to finish, could take 60 seconds.Thu Aug 28 00:52:43 +0000 2008 (13051) Rendering layoutfalsecontent_typetext/htmlactionindex within layouts/application | [
"ruby-on-rails",
"ruby",
"mongrel"
] | 4 | 12 | 3,610 | 6 | 0 | 2008-08-26T10:59:50.517000 | 2008-08-28T02:38:06.320000 |
27,745 | 27,755 | Getting parts of a URL (Regex) | Given the URL (single line): http://test.example.com/dir/subdir/file.html How can I extract the following parts using regular expressions: The Subdomain (test) The Domain (example.com) The path without the file (/dir/subdir/) The file (file.html) The path with the file (/dir/subdir/file.html) The URL without the path ( http://test.example.com ) (add any other that you think would be useful) The regex should work correctly even if I enter the following URL: http://test.example.com/example/example/example.html | A single regex to parse and breakup a full URL including query parameters and anchors e.g. https://www.google.com/dir/1/2/search.html?arg=0-a&arg1=1-b&arg3-c#hash ^((http[s]?|ftp):\/)?\/?([^:\/\s]+)((\/\w+)*\/)([\w\-\.]+[^#?\s]+)(.*)?(#[\w\-]+)?$ RexEx positions: url: RegExp['$&'], protocol:RegExp.$2, host:RegExp.$3, path:RegExp.$4, file:RegExp.$6, query:RegExp.$7, hash:RegExp.$8 you could then further parse the host ('.' delimited) quite easily. What I would do is use something like this: /* ^(.*:)//([A-Za-z0-9\-\.]+)(:[0-9]+)?(.*)$ */ proto $1 host $2 port $3 the-rest $4 the further parse 'the rest' to be as specific as possible. Doing it in one regex is, well, a bit crazy. | Getting parts of a URL (Regex) Given the URL (single line): http://test.example.com/dir/subdir/file.html How can I extract the following parts using regular expressions: The Subdomain (test) The Domain (example.com) The path without the file (/dir/subdir/) The file (file.html) The path with the file (/dir/subdir/file.html) The URL without the path ( http://test.example.com ) (add any other that you think would be useful) The regex should work correctly even if I enter the following URL: http://test.example.com/example/example/example.html | TITLE:
Getting parts of a URL (Regex)
QUESTION:
Given the URL (single line): http://test.example.com/dir/subdir/file.html How can I extract the following parts using regular expressions: The Subdomain (test) The Domain (example.com) The path without the file (/dir/subdir/) The file (file.html) The path with the file (/dir/subdir/file.html) The URL without the path ( http://test.example.com ) (add any other that you think would be useful) The regex should work correctly even if I enter the following URL: http://test.example.com/example/example/example.html
ANSWER:
A single regex to parse and breakup a full URL including query parameters and anchors e.g. https://www.google.com/dir/1/2/search.html?arg=0-a&arg1=1-b&arg3-c#hash ^((http[s]?|ftp):\/)?\/?([^:\/\s]+)((\/\w+)*\/)([\w\-\.]+[^#?\s]+)(.*)?(#[\w\-]+)?$ RexEx positions: url: RegExp['$&'], protocol:RegExp.$2, host:RegExp.$3, path:RegExp.$4, file:RegExp.$6, query:RegExp.$7, hash:RegExp.$8 you could then further parse the host ('.' delimited) quite easily. What I would do is use something like this: /* ^(.*:)//([A-Za-z0-9\-\.]+)(:[0-9]+)?(.*)$ */ proto $1 host $2 port $3 the-rest $4 the further parse 'the rest' to be as specific as possible. Doing it in one regex is, well, a bit crazy. | [
"regex",
"language-agnostic",
"url"
] | 164 | 171 | 332,581 | 30 | 0 | 2008-08-26T11:01:37.267000 | 2008-08-26T11:06:09.173000 |
27,757 | 27,773 | How can I discover the "path" of an embedded resource? | I am storing a PNG as an embedded resource in an assembly. From within the same assembly I have some code like this: Bitmap image = new Bitmap(typeof(MyClass), "Resources.file.png"); The file, named "file.png" is stored in the "Resources" folder (within Visual Studio), and is marked as an embedded resource. The code fails with an exception saying: Resource MyNamespace.Resources.file.png cannot be found in class MyNamespace.MyClass I have identical code (in a different assembly, loading a different resource) which works. So I know the technique is sound. My problem is I end up spending a lot of time trying to figure out what the correct path is. If I could simply query (eg. in the debugger) the assembly to find the correct path, that would save me a load of headaches. | This will get you a string array of all the resources: System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceNames(); | How can I discover the "path" of an embedded resource? I am storing a PNG as an embedded resource in an assembly. From within the same assembly I have some code like this: Bitmap image = new Bitmap(typeof(MyClass), "Resources.file.png"); The file, named "file.png" is stored in the "Resources" folder (within Visual Studio), and is marked as an embedded resource. The code fails with an exception saying: Resource MyNamespace.Resources.file.png cannot be found in class MyNamespace.MyClass I have identical code (in a different assembly, loading a different resource) which works. So I know the technique is sound. My problem is I end up spending a lot of time trying to figure out what the correct path is. If I could simply query (eg. in the debugger) the assembly to find the correct path, that would save me a load of headaches. | TITLE:
How can I discover the "path" of an embedded resource?
QUESTION:
I am storing a PNG as an embedded resource in an assembly. From within the same assembly I have some code like this: Bitmap image = new Bitmap(typeof(MyClass), "Resources.file.png"); The file, named "file.png" is stored in the "Resources" folder (within Visual Studio), and is marked as an embedded resource. The code fails with an exception saying: Resource MyNamespace.Resources.file.png cannot be found in class MyNamespace.MyClass I have identical code (in a different assembly, loading a different resource) which works. So I know the technique is sound. My problem is I end up spending a lot of time trying to figure out what the correct path is. If I could simply query (eg. in the debugger) the assembly to find the correct path, that would save me a load of headaches.
ANSWER:
This will get you a string array of all the resources: System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceNames(); | [
"c#",
".net",
"resources"
] | 121 | 218 | 159,442 | 5 | 0 | 2008-08-26T11:08:48.933000 | 2008-08-26T11:21:34.333000 |
27,758 | 27,825 | Notify Developer of a "DO NOT USE" Method | OK, I know what you're thinking, "why write a method you do not want people to use?" Right? Well, in short, I have a class that needs to be serialized to XML. In order for the XmlSerializer to do its magic, the class must have a default, empty constructor: public class MyClass { public MyClass() { // required for xml serialization } } So, I need to have it, but I don't want people to use it, so is there any attribute that can be use to mark the method as "DO NOT USE"? I was thinking of using the Obsolete attribute (since this can stop the build), but that just seems kinda "wrong", is there any other way of doing this, or do I need to go ahead and bite the bullet?:) Update OK, I have accepted Keith's answer, since I guess in my heart of hearts, I totally agree. This is why I asked the question in the first place, I don't like the notion of having the Obsolete attribute. However... There is still a problem, while we are being notified in intellisense, ideally, we would like to break the build, so is there any way to do this? Perhaps create a custom attribute? More focused question has been created here. | If a class is [Serialisable] (i.e. it can be copied around the place as needed) the param-less constructor is needed to deserialise. I'm guessing that you want to force your code's access to pass defaults for your properties to a parameterised constructor. Basically you're saying that it's OK for the XmlSerializer to make a copy and then set properties, but you don't want your own code to. To some extent I think this is over-designing. Just add XML comments that detail what properties need initialising (and what to). Don't use [Obsolete], because it isn't. Reserve that for genuinely deprecated methods. | Notify Developer of a "DO NOT USE" Method OK, I know what you're thinking, "why write a method you do not want people to use?" Right? Well, in short, I have a class that needs to be serialized to XML. In order for the XmlSerializer to do its magic, the class must have a default, empty constructor: public class MyClass { public MyClass() { // required for xml serialization } } So, I need to have it, but I don't want people to use it, so is there any attribute that can be use to mark the method as "DO NOT USE"? I was thinking of using the Obsolete attribute (since this can stop the build), but that just seems kinda "wrong", is there any other way of doing this, or do I need to go ahead and bite the bullet?:) Update OK, I have accepted Keith's answer, since I guess in my heart of hearts, I totally agree. This is why I asked the question in the first place, I don't like the notion of having the Obsolete attribute. However... There is still a problem, while we are being notified in intellisense, ideally, we would like to break the build, so is there any way to do this? Perhaps create a custom attribute? More focused question has been created here. | TITLE:
Notify Developer of a "DO NOT USE" Method
QUESTION:
OK, I know what you're thinking, "why write a method you do not want people to use?" Right? Well, in short, I have a class that needs to be serialized to XML. In order for the XmlSerializer to do its magic, the class must have a default, empty constructor: public class MyClass { public MyClass() { // required for xml serialization } } So, I need to have it, but I don't want people to use it, so is there any attribute that can be use to mark the method as "DO NOT USE"? I was thinking of using the Obsolete attribute (since this can stop the build), but that just seems kinda "wrong", is there any other way of doing this, or do I need to go ahead and bite the bullet?:) Update OK, I have accepted Keith's answer, since I guess in my heart of hearts, I totally agree. This is why I asked the question in the first place, I don't like the notion of having the Obsolete attribute. However... There is still a problem, while we are being notified in intellisense, ideally, we would like to break the build, so is there any way to do this? Perhaps create a custom attribute? More focused question has been created here.
ANSWER:
If a class is [Serialisable] (i.e. it can be copied around the place as needed) the param-less constructor is needed to deserialise. I'm guessing that you want to force your code's access to pass defaults for your properties to a parameterised constructor. Basically you're saying that it's OK for the XmlSerializer to make a copy and then set properties, but you don't want your own code to. To some extent I think this is over-designing. Just add XML comments that detail what properties need initialising (and what to). Don't use [Obsolete], because it isn't. Reserve that for genuinely deprecated methods. | [
".net",
"attributes"
] | 34 | 17 | 11,973 | 14 | 0 | 2008-08-26T11:09:30.820000 | 2008-08-26T11:58:55.040000 |
27,774 | 29,690 | Using VLOOKUP in an array formula on Google Spreadsheets | Effectively I want to give numeric scores to alphabetic grades and sum them. In Excel, putting the LOOKUP function into an array formula works: {=SUM(LOOKUP(grades, scoringarray))} With the VLOOKUP function this does not work (only gets the score for the first grade). Google Spreadsheets does not appear to have the LOOKUP function and VLOOKUP fails in the same way using: =SUM(ARRAYFORMULA(VLOOKUP(grades, scoresarray, 2, 0))) or =ARRAYFORMULA(SUM(VLOOKUP(grades, scoresarray, 2, 0))) Is it possible to do this (but I have the syntax wrong)? Can you suggest a method that allows having the calculation in one simple cell like this rather than hiding the lookups somewhere else and summing them afterwards? | I still can't see the formulae in your example (just values), but that is exactly what I'm trying to do in terms of the result; obviously I can already do it "by the side" and sum separately - the key for me is doing it in one cell. I have looked at it again this morning - using the MATCH function for the lookup works in an array formula. But then the INDEX function does not. I have also tried using it with OFFSET and INDIRECT without success. Finally, the CHOOSE function does not seem to accept a cell range as its list to choose from - the range degrades to a single value (the first cell in the range). It should also be noted that the CHOOSE function only accepts 30 values to choose from (according to the documentation). All very annoying. However, I do now have a working solution in one cell: using the CHOOSE function and explicitly listing the result cells one by one in the arguments like this: =ARRAYFORMULA(SUM(CHOOSE(MATCH(D1:D8,Lookups!$A$1:$A$3,0), Lookups!$B$1,Lookups!$B$2,Lookups!$B$3))) Obviously this doesn't extend very well but hopefully the lookup tables are by nature quite fixed. For larger lookup tables it's a pain to type all the cells individually and some people may exceed the limit of 30 cells. I would certainly welcome a more elegant solution! | Using VLOOKUP in an array formula on Google Spreadsheets Effectively I want to give numeric scores to alphabetic grades and sum them. In Excel, putting the LOOKUP function into an array formula works: {=SUM(LOOKUP(grades, scoringarray))} With the VLOOKUP function this does not work (only gets the score for the first grade). Google Spreadsheets does not appear to have the LOOKUP function and VLOOKUP fails in the same way using: =SUM(ARRAYFORMULA(VLOOKUP(grades, scoresarray, 2, 0))) or =ARRAYFORMULA(SUM(VLOOKUP(grades, scoresarray, 2, 0))) Is it possible to do this (but I have the syntax wrong)? Can you suggest a method that allows having the calculation in one simple cell like this rather than hiding the lookups somewhere else and summing them afterwards? | TITLE:
Using VLOOKUP in an array formula on Google Spreadsheets
QUESTION:
Effectively I want to give numeric scores to alphabetic grades and sum them. In Excel, putting the LOOKUP function into an array formula works: {=SUM(LOOKUP(grades, scoringarray))} With the VLOOKUP function this does not work (only gets the score for the first grade). Google Spreadsheets does not appear to have the LOOKUP function and VLOOKUP fails in the same way using: =SUM(ARRAYFORMULA(VLOOKUP(grades, scoresarray, 2, 0))) or =ARRAYFORMULA(SUM(VLOOKUP(grades, scoresarray, 2, 0))) Is it possible to do this (but I have the syntax wrong)? Can you suggest a method that allows having the calculation in one simple cell like this rather than hiding the lookups somewhere else and summing them afterwards?
ANSWER:
I still can't see the formulae in your example (just values), but that is exactly what I'm trying to do in terms of the result; obviously I can already do it "by the side" and sum separately - the key for me is doing it in one cell. I have looked at it again this morning - using the MATCH function for the lookup works in an array formula. But then the INDEX function does not. I have also tried using it with OFFSET and INDIRECT without success. Finally, the CHOOSE function does not seem to accept a cell range as its list to choose from - the range degrades to a single value (the first cell in the range). It should also be noted that the CHOOSE function only accepts 30 values to choose from (according to the documentation). All very annoying. However, I do now have a working solution in one cell: using the CHOOSE function and explicitly listing the result cells one by one in the arguments like this: =ARRAYFORMULA(SUM(CHOOSE(MATCH(D1:D8,Lookups!$A$1:$A$3,0), Lookups!$B$1,Lookups!$B$2,Lookups!$B$3))) Obviously this doesn't extend very well but hopefully the lookup tables are by nature quite fixed. For larger lookup tables it's a pain to type all the cells individually and some people may exceed the limit of 30 cells. I would certainly welcome a more elegant solution! | [
"google-sheets",
"gs-vlookup"
] | 2 | 0 | 18,028 | 5 | 0 | 2008-08-26T11:21:52.553000 | 2008-08-27T07:55:09.423000 |
27,779 | 29,443 | MFC resources / links | I am about to reenter the MFC world after years away for a new job. What resources to people recommend for refreshing the memory? I have been doing mainly C# recently. Also any MFC centric websites or blogs that people recommend? | For blogs: Your best bet would be the Visual C++ Team Blog. For books: Programming Windows with MFC is one of the best book on the subject. For tutorials: Simply search google for various tutorials on MFC. | MFC resources / links I am about to reenter the MFC world after years away for a new job. What resources to people recommend for refreshing the memory? I have been doing mainly C# recently. Also any MFC centric websites or blogs that people recommend? | TITLE:
MFC resources / links
QUESTION:
I am about to reenter the MFC world after years away for a new job. What resources to people recommend for refreshing the memory? I have been doing mainly C# recently. Also any MFC centric websites or blogs that people recommend?
ANSWER:
For blogs: Your best bet would be the Visual C++ Team Blog. For books: Programming Windows with MFC is one of the best book on the subject. For tutorials: Simply search google for various tutorials on MFC. | [
"c++",
"c",
"mfc"
] | 13 | 5 | 2,934 | 7 | 0 | 2008-08-26T11:28:43.113000 | 2008-08-27T03:15:43.947000 |
27,784 | 35,967 | Web server statics repository -or- ZFS vs. NTFS | My goal is to maintain a web file server separately from my main ASP.NET application server for better scalability. The web file server will store a lot of files downloaded by users. So the question is: Is it worth to adopt FreeBSD + Apache + ZFS, or will good old IIS be сonvenient enough? | It all depends on your skill level and how much load you are getting on your servers. If you have spare (physical) resources and have the technical skills and experience to maintain production machines running different operating systems, I'd recommend going running lighttpd on either Linux or FreeBSD. A light OS install with a static file optimized server will perform faster than Apache or IIS on a heavy OS. However, unless you are extremely comfortable with these solutions, just stick to IIS on Windows. Move the static files to their own machine if you have sufficient load. If you aren't currently thinking about multiple ASP.Net frontends, there's probably no need to spin off the static files yet unless we're talking multiple gigabytes of files. | Web server statics repository -or- ZFS vs. NTFS My goal is to maintain a web file server separately from my main ASP.NET application server for better scalability. The web file server will store a lot of files downloaded by users. So the question is: Is it worth to adopt FreeBSD + Apache + ZFS, or will good old IIS be сonvenient enough? | TITLE:
Web server statics repository -or- ZFS vs. NTFS
QUESTION:
My goal is to maintain a web file server separately from my main ASP.NET application server for better scalability. The web file server will store a lot of files downloaded by users. So the question is: Is it worth to adopt FreeBSD + Apache + ZFS, or will good old IIS be сonvenient enough?
ANSWER:
It all depends on your skill level and how much load you are getting on your servers. If you have spare (physical) resources and have the technical skills and experience to maintain production machines running different operating systems, I'd recommend going running lighttpd on either Linux or FreeBSD. A light OS install with a static file optimized server will perform faster than Apache or IIS on a heavy OS. However, unless you are extremely comfortable with these solutions, just stick to IIS on Windows. Move the static files to their own machine if you have sufficient load. If you aren't currently thinking about multiple ASP.Net frontends, there's probably no need to spin off the static files yet unless we're talking multiple gigabytes of files. | [
"windows",
"bsd"
] | 0 | 1 | 583 | 3 | 0 | 2008-08-26T11:32:57.613000 | 2008-08-30T13:57:37.530000 |
27,818 | 478,654 | How can I manage OSGi build dependencies? | We've embedded an OSGi runtime (Equinox) into out custom client-server application to facilitate plugin development and so far things are going great. We've been using Eclipse to build plugins due to the built-in manifest editor, dependency management, and export wizard. Using Eclipse to manager builds isn't very conducive to continuous integration via Hudson. We have OSGi bundles which depend on other OSGi bundles. I'd really hate to hardcode build order in a custom ANT build. We've done this is the past and it's pretty horrible. Is there any build tool that can EASILY manage OSGi dependencies, if not automatically resolve them? Are there any DECENT examples of how to this? CLARIFICATION: The generated build scripts are only usable via Eclipse. They require manually running pieces of Eclipse. We've also got some standard targets which the Eclipse build won't have, and I don't want to modify the generated file since I may regenerate (I know I can do includes, but I want to avoid the Eclipse gen file all together) Here is my project layout: / -PluginA -PluginB -PluginC... In using the Eclipse PDE, each plugin has a Manifest, but no build.xml as the PDE does that for me. Hard to automate a gui driven process w/ Hudson. I'd like to setup my own build.xml to build each, BUT there are dependencies and build order issues. These issues are driven by the Manifest files (which describe OSGi imports). For example, PluginC depends on PluginB which depends on PluginA. They must be built in the correct order. I realize that I can manually control the build order, I'm looking for a tool to help automate the build order dependency management. | Closing out some old questions... Our setup was not conducive to maven due to lack of network connectivity and timing. I know there are offline maven setups, but it was all too much given the time. Hopefully we'll get to use a proper setup when we've got time to reorganize the build process. The solution involved Ant, BND, and some custom ant tasks. The various bundle dependencies are manually managed. We were already using Ant; BND and custom tasks tied it all together. The custom tasks just made sure our bnd/eclipse projects were in sync. | How can I manage OSGi build dependencies? We've embedded an OSGi runtime (Equinox) into out custom client-server application to facilitate plugin development and so far things are going great. We've been using Eclipse to build plugins due to the built-in manifest editor, dependency management, and export wizard. Using Eclipse to manager builds isn't very conducive to continuous integration via Hudson. We have OSGi bundles which depend on other OSGi bundles. I'd really hate to hardcode build order in a custom ANT build. We've done this is the past and it's pretty horrible. Is there any build tool that can EASILY manage OSGi dependencies, if not automatically resolve them? Are there any DECENT examples of how to this? CLARIFICATION: The generated build scripts are only usable via Eclipse. They require manually running pieces of Eclipse. We've also got some standard targets which the Eclipse build won't have, and I don't want to modify the generated file since I may regenerate (I know I can do includes, but I want to avoid the Eclipse gen file all together) Here is my project layout: / -PluginA -PluginB -PluginC... In using the Eclipse PDE, each plugin has a Manifest, but no build.xml as the PDE does that for me. Hard to automate a gui driven process w/ Hudson. I'd like to setup my own build.xml to build each, BUT there are dependencies and build order issues. These issues are driven by the Manifest files (which describe OSGi imports). For example, PluginC depends on PluginB which depends on PluginA. They must be built in the correct order. I realize that I can manually control the build order, I'm looking for a tool to help automate the build order dependency management. | TITLE:
How can I manage OSGi build dependencies?
QUESTION:
We've embedded an OSGi runtime (Equinox) into out custom client-server application to facilitate plugin development and so far things are going great. We've been using Eclipse to build plugins due to the built-in manifest editor, dependency management, and export wizard. Using Eclipse to manager builds isn't very conducive to continuous integration via Hudson. We have OSGi bundles which depend on other OSGi bundles. I'd really hate to hardcode build order in a custom ANT build. We've done this is the past and it's pretty horrible. Is there any build tool that can EASILY manage OSGi dependencies, if not automatically resolve them? Are there any DECENT examples of how to this? CLARIFICATION: The generated build scripts are only usable via Eclipse. They require manually running pieces of Eclipse. We've also got some standard targets which the Eclipse build won't have, and I don't want to modify the generated file since I may regenerate (I know I can do includes, but I want to avoid the Eclipse gen file all together) Here is my project layout: / -PluginA -PluginB -PluginC... In using the Eclipse PDE, each plugin has a Manifest, but no build.xml as the PDE does that for me. Hard to automate a gui driven process w/ Hudson. I'd like to setup my own build.xml to build each, BUT there are dependencies and build order issues. These issues are driven by the Manifest files (which describe OSGi imports). For example, PluginC depends on PluginB which depends on PluginA. They must be built in the correct order. I realize that I can manually control the build order, I'm looking for a tool to help automate the build order dependency management.
ANSWER:
Closing out some old questions... Our setup was not conducive to maven due to lack of network connectivity and timing. I know there are offline maven setups, but it was all too much given the time. Hopefully we'll get to use a proper setup when we've got time to reorganize the build process. The solution involved Ant, BND, and some custom ant tasks. The various bundle dependencies are manually managed. We were already using Ant; BND and custom tasks tied it all together. The custom tasks just made sure our bnd/eclipse projects were in sync. | [
"dependencies",
"osgi",
"build"
] | 11 | 1 | 8,944 | 8 | 0 | 2008-08-26T11:54:35.283000 | 2009-01-26T01:44:39.053000 |
27,832 | 27,858 | How can I reverse engineer a DirectShow graph? | I have a DirectShow graph to render MPEG2/4 movies from a network stream. When I assemble the graph by connecting the pins manually it doesn't render. But when I call Render on the GraphBuilder it renders fine. Obviously there is some setup step that I'm not performing on some filter in the graph that GraphBuilder is performing. Is there any way to see debug output from GraphBuilder when it assembles a graph? Is there a way to dump a working graph to see how it was put together? Any other ideas for unraveling the mystery that lives in the DirectShow box? Thanks! -Z | You can watch the graph you created using GraphEdit, a tool from the DirectShow SDK. In GraphEdit, select File->Connect to remote Graph... In order to find your graph in the list, you have to register it in the running object table: void AddToRot( IUnknown *pUnkGraph, DWORD *pdwRegister ) { IMoniker* pMoniker; IRunningObjectTable* pROT; GetRunningObjectTable( 0, &pROT );
WCHAR wsz[256]; swprintf_s( wsz, L"FilterGraph %08p pid %08x", (DWORD_PTR)pUnkGraph, GetCurrentProcessId() ); CreateItemMoniker( L"!", wsz, &pMoniker );
pROT->Register( 0, pUnkGraph, pMoniker, pdwRegister );
// Clean up any COM stuff here... } After destroying your graph, you should remove it from the ROT by calling IRunningObjectTable::Revoke | How can I reverse engineer a DirectShow graph? I have a DirectShow graph to render MPEG2/4 movies from a network stream. When I assemble the graph by connecting the pins manually it doesn't render. But when I call Render on the GraphBuilder it renders fine. Obviously there is some setup step that I'm not performing on some filter in the graph that GraphBuilder is performing. Is there any way to see debug output from GraphBuilder when it assembles a graph? Is there a way to dump a working graph to see how it was put together? Any other ideas for unraveling the mystery that lives in the DirectShow box? Thanks! -Z | TITLE:
How can I reverse engineer a DirectShow graph?
QUESTION:
I have a DirectShow graph to render MPEG2/4 movies from a network stream. When I assemble the graph by connecting the pins manually it doesn't render. But when I call Render on the GraphBuilder it renders fine. Obviously there is some setup step that I'm not performing on some filter in the graph that GraphBuilder is performing. Is there any way to see debug output from GraphBuilder when it assembles a graph? Is there a way to dump a working graph to see how it was put together? Any other ideas for unraveling the mystery that lives in the DirectShow box? Thanks! -Z
ANSWER:
You can watch the graph you created using GraphEdit, a tool from the DirectShow SDK. In GraphEdit, select File->Connect to remote Graph... In order to find your graph in the list, you have to register it in the running object table: void AddToRot( IUnknown *pUnkGraph, DWORD *pdwRegister ) { IMoniker* pMoniker; IRunningObjectTable* pROT; GetRunningObjectTable( 0, &pROT );
WCHAR wsz[256]; swprintf_s( wsz, L"FilterGraph %08p pid %08x", (DWORD_PTR)pUnkGraph, GetCurrentProcessId() ); CreateItemMoniker( L"!", wsz, &pMoniker );
pROT->Register( 0, pUnkGraph, pMoniker, pdwRegister );
// Clean up any COM stuff here... } After destroying your graph, you should remove it from the ROT by calling IRunningObjectTable::Revoke | [
"video",
"directx",
"directshow",
"mpeg"
] | 15 | 14 | 6,268 | 7 | 0 | 2008-08-26T12:02:08.400000 | 2008-08-26T12:15:13.160000 |
27,835 | 27,895 | Does MS-SQL support in-memory tables? | Recently, I started changing some of our applications to support MS SQL Server as an alternative back end. One of the compatibility issues I ran into is the use of MySQL's CREATE TEMPORARY TABLE to create in-memory tables that hold data for very fast access during a session with no need for permanent storage. What is the equivalent in MS SQL? A requirement is that I need to be able to use the temporary table just like any other, especially JOIN it with the permanent ones. | @Keith This is a common misconception: Table variables are NOT necessarily stored in memory. In fact SQL Server decides whether to keep the variable in memory or to spill it to TempDB. There is no reliable way (at least in SQL Server 2005) to ensure that table data is kept in memory. For more detailed info look here | Does MS-SQL support in-memory tables? Recently, I started changing some of our applications to support MS SQL Server as an alternative back end. One of the compatibility issues I ran into is the use of MySQL's CREATE TEMPORARY TABLE to create in-memory tables that hold data for very fast access during a session with no need for permanent storage. What is the equivalent in MS SQL? A requirement is that I need to be able to use the temporary table just like any other, especially JOIN it with the permanent ones. | TITLE:
Does MS-SQL support in-memory tables?
QUESTION:
Recently, I started changing some of our applications to support MS SQL Server as an alternative back end. One of the compatibility issues I ran into is the use of MySQL's CREATE TEMPORARY TABLE to create in-memory tables that hold data for very fast access during a session with no need for permanent storage. What is the equivalent in MS SQL? A requirement is that I need to be able to use the temporary table just like any other, especially JOIN it with the permanent ones.
ANSWER:
@Keith This is a common misconception: Table variables are NOT necessarily stored in memory. In fact SQL Server decides whether to keep the variable in memory or to spill it to TempDB. There is no reliable way (at least in SQL Server 2005) to ensure that table data is kept in memory. For more detailed info look here | [
"mysql",
"sql-server",
"rdbms",
"portability"
] | 17 | 13 | 32,056 | 8 | 0 | 2008-08-26T12:03:44.013000 | 2008-08-26T12:29:08.850000 |
27,836 | 29,585 | Is there a Box Plot graph available for Reporting Services 2005? | Is there a Box Plot graph, or box and whisker graph available for Reporting Services 2005? From the looks of the documentation there doesn't seem to be one out of the box; so I am wondering if there is a third party that has the graph, or a way to build my own? | There definitely isn't a Box Plot built into SSRS 2005, though it's possible that 2008 has one. SSRS 2005 does have a robust extension model. If you can implement a chart in System.Drawing/GDI+, you can make it into a custom report item for SSRS. There are a few third-party vendors with fairly feature-rich products, but the only one I've ever evaluated was Dundas Chart, which isn't cheap, but gives you about 100x more charting capability than SSRS 2005 built in (for SSRS 2008, Microsoft incorporated a great deal of Dundas's charting technology). I can't say from experience that I know Dundas Chart supports the Box Plot, but this support forum post says so. | Is there a Box Plot graph available for Reporting Services 2005? Is there a Box Plot graph, or box and whisker graph available for Reporting Services 2005? From the looks of the documentation there doesn't seem to be one out of the box; so I am wondering if there is a third party that has the graph, or a way to build my own? | TITLE:
Is there a Box Plot graph available for Reporting Services 2005?
QUESTION:
Is there a Box Plot graph, or box and whisker graph available for Reporting Services 2005? From the looks of the documentation there doesn't seem to be one out of the box; so I am wondering if there is a third party that has the graph, or a way to build my own?
ANSWER:
There definitely isn't a Box Plot built into SSRS 2005, though it's possible that 2008 has one. SSRS 2005 does have a robust extension model. If you can implement a chart in System.Drawing/GDI+, you can make it into a custom report item for SSRS. There are a few third-party vendors with fairly feature-rich products, but the only one I've ever evaluated was Dundas Chart, which isn't cheap, but gives you about 100x more charting capability than SSRS 2005 built in (for SSRS 2008, Microsoft incorporated a great deal of Dundas's charting technology). I can't say from experience that I know Dundas Chart supports the Box Plot, but this support forum post says so. | [
"sql",
"reporting-services",
"graph"
] | 1 | 2 | 1,703 | 4 | 0 | 2008-08-26T12:04:15.633000 | 2008-08-27T05:23:45.760000 |
27,850 | 28,217 | What are models for storing tree structures and what are their characteristics? | So far I have encountered adjacency list, nested sets and nested intervals as models for storing tree structures in a database. I know these well enough and have migrated trees from one to another. What are other popular models? What are their characteristics? What are good resources (books, web, etc) on this topic? I'm not only looking for db storage but would like to expand my knowledge on trees in general. For example, I understand that nested sets/intervals are especially favorable for relational database storage and have asked myself, are they actually a bad choice in other contexts? | The seminal resource for this are chapters 28-30 of SQL for Smarties. (I've recommended this book so much I figure Celko owes me royalties by now!) | What are models for storing tree structures and what are their characteristics? So far I have encountered adjacency list, nested sets and nested intervals as models for storing tree structures in a database. I know these well enough and have migrated trees from one to another. What are other popular models? What are their characteristics? What are good resources (books, web, etc) on this topic? I'm not only looking for db storage but would like to expand my knowledge on trees in general. For example, I understand that nested sets/intervals are especially favorable for relational database storage and have asked myself, are they actually a bad choice in other contexts? | TITLE:
What are models for storing tree structures and what are their characteristics?
QUESTION:
So far I have encountered adjacency list, nested sets and nested intervals as models for storing tree structures in a database. I know these well enough and have migrated trees from one to another. What are other popular models? What are their characteristics? What are good resources (books, web, etc) on this topic? I'm not only looking for db storage but would like to expand my knowledge on trees in general. For example, I understand that nested sets/intervals are especially favorable for relational database storage and have asked myself, are they actually a bad choice in other contexts?
ANSWER:
The seminal resource for this are chapters 28-30 of SQL for Smarties. (I've recommended this book so much I figure Celko owes me royalties by now!) | [
"data-structures",
"modeling"
] | 5 | 1 | 271 | 2 | 0 | 2008-08-26T12:11:05.010000 | 2008-08-26T14:35:13.760000 |
27,853 | 245,175 | ModalPopupExtender adding scrollbars in SharePoint | Whenever I show a ModalPopupExtender on my Sharepoint site, the popup shown creates both horizontal and vertical scrollbars. If you scroll all the way to the end of the page, the scrollbar refreshes, and there is more page to scroll through. Basically, I think the popup is setting its bounds beyond the end of the page. Has anyone run into this? Searching Google, it seems this may be a known problem, but I haven't found a good solution that doesn't include recompiling AJAX, which my boss will not allow. | I assume the TargetControl is of sufficient size to hold everything you put in it? If so, try: Set CSS overflow:hidden; If the target control is a Panel, set scrollbars="none". Otherwise, put it in a panel and try it. | ModalPopupExtender adding scrollbars in SharePoint Whenever I show a ModalPopupExtender on my Sharepoint site, the popup shown creates both horizontal and vertical scrollbars. If you scroll all the way to the end of the page, the scrollbar refreshes, and there is more page to scroll through. Basically, I think the popup is setting its bounds beyond the end of the page. Has anyone run into this? Searching Google, it seems this may be a known problem, but I haven't found a good solution that doesn't include recompiling AJAX, which my boss will not allow. | TITLE:
ModalPopupExtender adding scrollbars in SharePoint
QUESTION:
Whenever I show a ModalPopupExtender on my Sharepoint site, the popup shown creates both horizontal and vertical scrollbars. If you scroll all the way to the end of the page, the scrollbar refreshes, and there is more page to scroll through. Basically, I think the popup is setting its bounds beyond the end of the page. Has anyone run into this? Searching Google, it seems this may be a known problem, but I haven't found a good solution that doesn't include recompiling AJAX, which my boss will not allow.
ANSWER:
I assume the TargetControl is of sufficient size to hold everything you put in it? If so, try: Set CSS overflow:hidden; If the target control is a Panel, set scrollbars="none". Otherwise, put it in a panel and try it. | [
"sharepoint",
"modalpopupextender"
] | 0 | 1 | 2,074 | 2 | 0 | 2008-08-26T12:12:23.603000 | 2008-10-28T22:54:00.910000 |
27,889 | 28,346 | How to get SpecUnit to run within a TeamCity CI build | I am trying to get SpecUnit to run in a continuous integration build using Nant. At the moment the files are in the correct place but no output is generated from SpecUnit.Report.exe. Here is the relevant task from the nant build script: Please note: ${specunit.exe} is the full path to where “SpecUnit.Report.exe” is located. ${output.dir} is the teamcity output directory for the current build agent. ${acceptance.tests.assembly} is "AcceptanceTests.dll" Anyone tried this before? | You need to specify the full path to the assembly argument I think... | How to get SpecUnit to run within a TeamCity CI build I am trying to get SpecUnit to run in a continuous integration build using Nant. At the moment the files are in the correct place but no output is generated from SpecUnit.Report.exe. Here is the relevant task from the nant build script: Please note: ${specunit.exe} is the full path to where “SpecUnit.Report.exe” is located. ${output.dir} is the teamcity output directory for the current build agent. ${acceptance.tests.assembly} is "AcceptanceTests.dll" Anyone tried this before? | TITLE:
How to get SpecUnit to run within a TeamCity CI build
QUESTION:
I am trying to get SpecUnit to run in a continuous integration build using Nant. At the moment the files are in the correct place but no output is generated from SpecUnit.Report.exe. Here is the relevant task from the nant build script: Please note: ${specunit.exe} is the full path to where “SpecUnit.Report.exe” is located. ${output.dir} is the teamcity output directory for the current build agent. ${acceptance.tests.assembly} is "AcceptanceTests.dll" Anyone tried this before?
ANSWER:
You need to specify the full path to the assembly argument I think... | [
"c#",
"nant",
"teamcity"
] | 0 | 0 | 383 | 1 | 0 | 2008-08-26T12:26:10.620000 | 2008-08-26T15:21:19.577000 |
27,894 | 64,891 | What's the difference between a temp table and table variable in SQL Server? | In SQL Server 2005, we can create similar tables in two different ways. We can use a table variable: declare @tmp table (Col1 int, Col2 int); Or we can use a temporary table: create table #tmp (Col1 int, Col2 int); What are the differences between these two? I have read conflicting opinions on whether @tmp still uses tempdb, or if everything happens in memory. In which scenarios does one outperform the other? | There are a few differences between Temporary Tables (#tmp) and Table Variables (@tmp), although using tempdb isn't one of them, as spelt out in the MSDN link below. As a rule of thumb, for small to medium volumes of data and simple usage scenarios you should use table variables. (This is an overly broad guideline with of course lots of exceptions - see below and following articles.) Some points to consider when choosing between them: Temporary Tables are real tables so you can do things like CREATE INDEXes, etc. If you have large amounts of data for which accessing by index will be faster then temporary tables are a good option. Table variables can have indexes by using PRIMARY KEY or UNIQUE constraints. (If you want a non-unique index just include the primary key column as the last column in the unique constraint. If you don't have a unique column, you can use an identity column.) SQL 2014 has non-unique indexes too. Table variables don't participate in transactions and SELECT s are implicitly with NOLOCK. The transaction behaviour can be very helpful, for instance if you want to ROLLBACK midway through a procedure then table variables populated during that transaction will still be populated! Temp tables might result in stored procedures being recompiled, perhaps often. Table variables will not. You can create a temp table using SELECT INTO, which can be quicker to write (good for ad-hoc querying) and may allow you to deal with changing datatypes over time, since you don't need to define your temp table structure upfront. You can pass table variables back from functions, enabling you to encapsulate and reuse logic much easier (eg make a function to split a string into a table of values on some arbitrary delimiter). Using Table Variables within user-defined functions enables those functions to be used more widely (see CREATE FUNCTION documentation for details). If you're writing a function you should use table variables over temp tables unless there's a compelling need otherwise. Both table variables and temp tables are stored in tempdb. But table variables (since 2005) default to the collation of the current database versus temp tables which take the default collation of tempdb ( ref ). This means you should be aware of collation issues if using temp tables and your db collation is different to tempdb's, causing problems if you want to compare data in the temp table with data in your database. Global Temp Tables (##tmp) are another type of temp table available to all sessions and users. Some further reading: Martin Smith's great answer on dba.stackexchange.com MSDN FAQ on difference between the two: https://support.microsoft.com/en-gb/kb/305977 MDSN blog article: https://learn.microsoft.com/archive/blogs/sqlserverstorageengine/tempdb-table-variable-vs-local-temporary-table Article: https://searchsqlserver.techtarget.com/tip/Temporary-tables-in-SQL-Server-vs-table-variables Unexpected behaviors and performance implications of temp tables and temp variables: Paul White on SQLblog.com | What's the difference between a temp table and table variable in SQL Server? In SQL Server 2005, we can create similar tables in two different ways. We can use a table variable: declare @tmp table (Col1 int, Col2 int); Or we can use a temporary table: create table #tmp (Col1 int, Col2 int); What are the differences between these two? I have read conflicting opinions on whether @tmp still uses tempdb, or if everything happens in memory. In which scenarios does one outperform the other? | TITLE:
What's the difference between a temp table and table variable in SQL Server?
QUESTION:
In SQL Server 2005, we can create similar tables in two different ways. We can use a table variable: declare @tmp table (Col1 int, Col2 int); Or we can use a temporary table: create table #tmp (Col1 int, Col2 int); What are the differences between these two? I have read conflicting opinions on whether @tmp still uses tempdb, or if everything happens in memory. In which scenarios does one outperform the other?
ANSWER:
There are a few differences between Temporary Tables (#tmp) and Table Variables (@tmp), although using tempdb isn't one of them, as spelt out in the MSDN link below. As a rule of thumb, for small to medium volumes of data and simple usage scenarios you should use table variables. (This is an overly broad guideline with of course lots of exceptions - see below and following articles.) Some points to consider when choosing between them: Temporary Tables are real tables so you can do things like CREATE INDEXes, etc. If you have large amounts of data for which accessing by index will be faster then temporary tables are a good option. Table variables can have indexes by using PRIMARY KEY or UNIQUE constraints. (If you want a non-unique index just include the primary key column as the last column in the unique constraint. If you don't have a unique column, you can use an identity column.) SQL 2014 has non-unique indexes too. Table variables don't participate in transactions and SELECT s are implicitly with NOLOCK. The transaction behaviour can be very helpful, for instance if you want to ROLLBACK midway through a procedure then table variables populated during that transaction will still be populated! Temp tables might result in stored procedures being recompiled, perhaps often. Table variables will not. You can create a temp table using SELECT INTO, which can be quicker to write (good for ad-hoc querying) and may allow you to deal with changing datatypes over time, since you don't need to define your temp table structure upfront. You can pass table variables back from functions, enabling you to encapsulate and reuse logic much easier (eg make a function to split a string into a table of values on some arbitrary delimiter). Using Table Variables within user-defined functions enables those functions to be used more widely (see CREATE FUNCTION documentation for details). If you're writing a function you should use table variables over temp tables unless there's a compelling need otherwise. Both table variables and temp tables are stored in tempdb. But table variables (since 2005) default to the collation of the current database versus temp tables which take the default collation of tempdb ( ref ). This means you should be aware of collation issues if using temp tables and your db collation is different to tempdb's, causing problems if you want to compare data in the temp table with data in your database. Global Temp Tables (##tmp) are another type of temp table available to all sessions and users. Some further reading: Martin Smith's great answer on dba.stackexchange.com MSDN FAQ on difference between the two: https://support.microsoft.com/en-gb/kb/305977 MDSN blog article: https://learn.microsoft.com/archive/blogs/sqlserverstorageengine/tempdb-table-variable-vs-local-temporary-table Article: https://searchsqlserver.techtarget.com/tip/Temporary-tables-in-SQL-Server-vs-table-variables Unexpected behaviors and performance implications of temp tables and temp variables: Paul White on SQLblog.com | [
"sql-server",
"temp-tables",
"table-variable"
] | 427 | 422 | 422,492 | 13 | 0 | 2008-08-26T12:27:30.337000 | 2008-09-15T17:24:40.610000 |
27,899 | 5,040,105 | Is there a way to have index.html functionality with content hosted on S3? | Is there a way to make S3 default to an index.html page? E.g.: My bucket object listing: /index.html /favicon.ico /images/logo.gif A call to www.example.com/ index.html works great! But if one were to call www.example.com/ we'd either get a 403 or a REST object listing XML document depending on how bucket-level ACL was configured. So, the question: Is there a way to have index.html functionality with content hosted on S3? | Amazon S3 now supports Index Documents The index document for a bucket can be set to something like index.html. When accessing the root of the site or a sub-directory containing a document of that name that document is returned. It is extremely easy to do using the aws cli: aws s3 website $MY_BUCKET_NAME --index-document index.html You can set the index document from the AWS Management Console: | Is there a way to have index.html functionality with content hosted on S3? Is there a way to make S3 default to an index.html page? E.g.: My bucket object listing: /index.html /favicon.ico /images/logo.gif A call to www.example.com/ index.html works great! But if one were to call www.example.com/ we'd either get a 403 or a REST object listing XML document depending on how bucket-level ACL was configured. So, the question: Is there a way to have index.html functionality with content hosted on S3? | TITLE:
Is there a way to have index.html functionality with content hosted on S3?
QUESTION:
Is there a way to make S3 default to an index.html page? E.g.: My bucket object listing: /index.html /favicon.ico /images/logo.gif A call to www.example.com/ index.html works great! But if one were to call www.example.com/ we'd either get a 403 or a REST object listing XML document depending on how bucket-level ACL was configured. So, the question: Is there a way to have index.html functionality with content hosted on S3?
ANSWER:
Amazon S3 now supports Index Documents The index document for a bucket can be set to something like index.html. When accessing the root of the site or a sub-directory containing a document of that name that document is returned. It is extremely easy to do using the aws cli: aws s3 website $MY_BUCKET_NAME --index-document index.html You can set the index document from the AWS Management Console: | [
"amazon-s3",
"amazon-web-services"
] | 39 | 37 | 31,349 | 7 | 0 | 2008-08-26T12:30:19.253000 | 2011-02-18T10:22:32.553000 |
27,916 | 28,519 | SQL Server - testing the database | What tools are people using for testing SQL Server databases? By this I mean all parts of the database: configuration tables column type stored procedures constraints Most likely, there is not one tool to do it all. | How do you mean "Test the database"? If you are testing foreign keys, a simply script to insert invalid data is all you should need. Testing a database could imply a great number of issues. Does it have all the tables? Are the tables correct? Are the indexes in place? Did the latest updates get applied? Has the data been migrated? Is the even valid? Are the foreign keys correct? There is a lot to test in a database so you are unlikely to find a simple way to test it. I find that a combination of test stored procedures and some Nunit unit tests do most of the vetting of my databases. | SQL Server - testing the database What tools are people using for testing SQL Server databases? By this I mean all parts of the database: configuration tables column type stored procedures constraints Most likely, there is not one tool to do it all. | TITLE:
SQL Server - testing the database
QUESTION:
What tools are people using for testing SQL Server databases? By this I mean all parts of the database: configuration tables column type stored procedures constraints Most likely, there is not one tool to do it all.
ANSWER:
How do you mean "Test the database"? If you are testing foreign keys, a simply script to insert invalid data is all you should need. Testing a database could imply a great number of issues. Does it have all the tables? Are the tables correct? Are the indexes in place? Did the latest updates get applied? Has the data been migrated? Is the even valid? Are the foreign keys correct? There is a lot to test in a database so you are unlikely to find a simple way to test it. I find that a combination of test stored procedures and some Nunit unit tests do most of the vetting of my databases. | [
"sql-server",
"unit-testing"
] | 3 | 1 | 592 | 2 | 0 | 2008-08-26T12:42:12.203000 | 2008-08-26T16:17:42.843000 |
27,921 | 27,938 | What is the "best" way to create a thumbnail using ASP.NET? | Story: The user uploads an image that will be added to a photo gallery. As part of the upload process, we need to A) store the image on the web server's hard drive and B) store a thumbnail of the image on the web server's hard drive. "Best" here is defined as Relatively easy to implement, understand, and maintain Results in a thumbnail of reasonable quality Performance and high-quality thumbnails are secondary. | I suppose your best solution would be using the GetThumbnailImage from the.NET Image class. // Example in C#, should be quite alike in ASP.NET // Assuming filename as the uploaded file using ( Image bigImage = new Bitmap( filename ) ) { // Algorithm simplified for purpose of example. int height = bigImage.Height / 10; int width = bigImage.Width / 10;
// Now create a thumbnail using ( Image smallImage = image.GetThumbnailImage( width, height, new Image.GetThumbnailImageAbort(Abort), IntPtr.Zero) ) { smallImage.Save("thumbnail.jpg", ImageFormat.Jpeg); } } | What is the "best" way to create a thumbnail using ASP.NET? Story: The user uploads an image that will be added to a photo gallery. As part of the upload process, we need to A) store the image on the web server's hard drive and B) store a thumbnail of the image on the web server's hard drive. "Best" here is defined as Relatively easy to implement, understand, and maintain Results in a thumbnail of reasonable quality Performance and high-quality thumbnails are secondary. | TITLE:
What is the "best" way to create a thumbnail using ASP.NET?
QUESTION:
Story: The user uploads an image that will be added to a photo gallery. As part of the upload process, we need to A) store the image on the web server's hard drive and B) store a thumbnail of the image on the web server's hard drive. "Best" here is defined as Relatively easy to implement, understand, and maintain Results in a thumbnail of reasonable quality Performance and high-quality thumbnails are secondary.
ANSWER:
I suppose your best solution would be using the GetThumbnailImage from the.NET Image class. // Example in C#, should be quite alike in ASP.NET // Assuming filename as the uploaded file using ( Image bigImage = new Bitmap( filename ) ) { // Algorithm simplified for purpose of example. int height = bigImage.Height / 10; int width = bigImage.Width / 10;
// Now create a thumbnail using ( Image smallImage = image.GetThumbnailImage( width, height, new Image.GetThumbnailImageAbort(Abort), IntPtr.Zero) ) { smallImage.Save("thumbnail.jpg", ImageFormat.Jpeg); } } | [
"asp.net",
"image",
"thumbnails"
] | 23 | 15 | 28,148 | 6 | 0 | 2008-08-26T12:47:35.123000 | 2008-08-26T12:53:53.800000 |
27,928 | 27,943 | Calculate distance between two latitude-longitude points? (Haversine formula) | How do I calculate the distance between two points specified by latitude and longitude? For clarification, I'd like the distance in kilometers; the points use the WGS84 system and I'd like to understand the relative accuracies of the approaches available. | This link might be helpful to you, as it details the use of the Haversine formula to calculate the distance. Excerpt: This script [in Javascript] calculates great-circle distances between the two points – that is, the shortest distance over the earth’s surface – using the ‘Haversine’ formula. function getDistanceFromLatLonInKm(lat1,lon1,lat2,lon2) { var R = 6371; // Radius of the earth in km var dLat = deg2rad(lat2-lat1); // deg2rad below var dLon = deg2rad(lon2-lon1); var a = Math.sin(dLat/2) * Math.sin(dLat/2) + Math.cos(deg2rad(lat1)) * Math.cos(deg2rad(lat2)) * Math.sin(dLon/2) * Math.sin(dLon/2); var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a)); var d = R * c; // Distance in km return d; }
function deg2rad(deg) { return deg * (Math.PI/180) } | Calculate distance between two latitude-longitude points? (Haversine formula) How do I calculate the distance between two points specified by latitude and longitude? For clarification, I'd like the distance in kilometers; the points use the WGS84 system and I'd like to understand the relative accuracies of the approaches available. | TITLE:
Calculate distance between two latitude-longitude points? (Haversine formula)
QUESTION:
How do I calculate the distance between two points specified by latitude and longitude? For clarification, I'd like the distance in kilometers; the points use the WGS84 system and I'd like to understand the relative accuracies of the approaches available.
ANSWER:
This link might be helpful to you, as it details the use of the Haversine formula to calculate the distance. Excerpt: This script [in Javascript] calculates great-circle distances between the two points – that is, the shortest distance over the earth’s surface – using the ‘Haversine’ formula. function getDistanceFromLatLonInKm(lat1,lon1,lat2,lon2) { var R = 6371; // Radius of the earth in km var dLat = deg2rad(lat2-lat1); // deg2rad below var dLon = deg2rad(lon2-lon1); var a = Math.sin(dLat/2) * Math.sin(dLat/2) + Math.cos(deg2rad(lat1)) * Math.cos(deg2rad(lat2)) * Math.sin(dLon/2) * Math.sin(dLon/2); var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a)); var d = R * c; // Distance in km return d; }
function deg2rad(deg) { return deg * (Math.PI/180) } | [
"algorithm",
"math",
"maps",
"latitude-longitude",
"haversine"
] | 1,160 | 1,381 | 1,186,651 | 49 | 0 | 2008-08-26T12:50:45.647000 | 2008-08-26T12:55:53.030000 |
27,931 | 27,988 | Dynamic Element Names | I want to transform an XML document. The source XML looks like this: 2007 2006 2005 I want to turn that into: The following line of code isn't working: The output is a series of elements that look like this: < NewTag >. (Without the spaces...) "//Element/Year", "./Element/Year", and "//svc:Element/Year" don't work either. One complication is that the "Element" tag is in the "svc" namespace while the "Year" tag is in the default namespace. So anyway, am I facing a namespace issue or am I mis-using the "concat()" function? | Probably namespace issues and maybe one with current context. For source (with added namespace declaration to make it well-formed xml) 2007 2006 2005 the stylesheet will give you the output you need. Note that svc:Element needs to be selected using namespace prefixed and that the context when generating the new tags is svc:Element, not svc:ElementList. | Dynamic Element Names I want to transform an XML document. The source XML looks like this: 2007 2006 2005 I want to turn that into: The following line of code isn't working: The output is a series of elements that look like this: < NewTag >. (Without the spaces...) "//Element/Year", "./Element/Year", and "//svc:Element/Year" don't work either. One complication is that the "Element" tag is in the "svc" namespace while the "Year" tag is in the default namespace. So anyway, am I facing a namespace issue or am I mis-using the "concat()" function? | TITLE:
Dynamic Element Names
QUESTION:
I want to transform an XML document. The source XML looks like this: 2007 2006 2005 I want to turn that into: The following line of code isn't working: The output is a series of elements that look like this: < NewTag >. (Without the spaces...) "//Element/Year", "./Element/Year", and "//svc:Element/Year" don't work either. One complication is that the "Element" tag is in the "svc" namespace while the "Year" tag is in the default namespace. So anyway, am I facing a namespace issue or am I mis-using the "concat()" function?
ANSWER:
Probably namespace issues and maybe one with current context. For source (with added namespace declaration to make it well-formed xml) 2007 2006 2005 the stylesheet will give you the output you need. Note that svc:Element needs to be selected using namespace prefixed and that the context when generating the new tags is svc:Element, not svc:ElementList. | [
"xml",
"xslt",
"namespaces"
] | 14 | 13 | 24,757 | 1 | 0 | 2008-08-26T12:51:55.583000 | 2008-08-26T13:12:30.917000 |
27,942 | 27,963 | Is it worth it to learn a dialect of assembly? | My goals are focused on software application development, and maybe web application development, but most likely desktop applications. I'm embarking on a path to becoming more familiar with C/C++, but should I go much lower than that, into assembly? Or would I not have a benefit for my long-term goals? | It's probably not going to have a whole lot of benefit unless you have a direct application for it. If you're going for general knowledge, C/C++ is a fine place to start. That said, the challenges that assembly poses are very interesting and it requires a pretty different mindset to get things done. I spent a little time learning Z80 assembly by programming the TI-86 calculator. The Z80 instruction set is pretty small and the novelty of programming a calculator in assembly is very amusing. ticalc.org has a lot of good resources on TI assembly programming. | Is it worth it to learn a dialect of assembly? My goals are focused on software application development, and maybe web application development, but most likely desktop applications. I'm embarking on a path to becoming more familiar with C/C++, but should I go much lower than that, into assembly? Or would I not have a benefit for my long-term goals? | TITLE:
Is it worth it to learn a dialect of assembly?
QUESTION:
My goals are focused on software application development, and maybe web application development, but most likely desktop applications. I'm embarking on a path to becoming more familiar with C/C++, but should I go much lower than that, into assembly? Or would I not have a benefit for my long-term goals?
ANSWER:
It's probably not going to have a whole lot of benefit unless you have a direct application for it. If you're going for general knowledge, C/C++ is a fine place to start. That said, the challenges that assembly poses are very interesting and it requires a pretty different mindset to get things done. I spent a little time learning Z80 assembly by programming the TI-86 calculator. The Z80 instruction set is pretty small and the novelty of programming a calculator in assembly is very amusing. ticalc.org has a lot of good resources on TI assembly programming. | [
"assembly"
] | 4 | 1 | 1,454 | 11 | 0 | 2008-08-26T12:54:57.103000 | 2008-08-26T13:02:39.643000 |
27,948 | 28,068 | Which resolution to target for a Mobile App? | When desinging UI for mobile apps in general which resolution could be considered safe as a general rule of thumb. My interest lies specifically in web based apps. The iPhone has a pretty high resolution for a hand held, and the Nokia E Series seem to oriented differently. Is 240×320 still considered safe? | Not enough information... You say you're targeting a "Mobile App" but the reality is that mobile could mean anything from a cell phone with 128x128 resolution to a MID with 800x600 resolution. There is no "safe" resolution for such a wide range, and if you're truly targeting all of them you need to design a custom interface for each major resolution. Add some scaling factors in and you might be able to cut it down to 5-8 different interface designs. Further, the UI means "User Interface" and includes a lot more than just the resolution - you can't count on a touchscreen, full keyboard, or even software keys. You need to either better define your target, or explain your target here so we can better help you. Keep in mind that there are millions of phone users that don't have PDA resolutions, and you can really only count on 128x128 or better to cover the majority of technically inclined cell phone users (those that know there's a web browser in their phone, nevermind those that use it). But if you're prepared to accept these losses, go ahead and hit for 320x240 and 240x320. That will give you most current PDA phones and up (older blackberries and palm devices had smaller square orientations). Plan on spending time later supporting lower resolution devices and above all... Do not tie your app to a particular resolution. Make sure your app is flexible enough that you can deploy new UI's without changing internal application logic - in other words separate the presentation from the core logic. You will find this very useful later - the mobile world changes daily. Once you gauge how your app is being used you can, for instance, easily deploy an iPhone specific version that is pixel perfect (and prettier than an upscaled 320x240) in order to engage more users. Being able to do this in a few hours (because you don't have to change the internals) is going to put you miles ahead of the competition if someone else makes a swipe at your market. -Adam | Which resolution to target for a Mobile App? When desinging UI for mobile apps in general which resolution could be considered safe as a general rule of thumb. My interest lies specifically in web based apps. The iPhone has a pretty high resolution for a hand held, and the Nokia E Series seem to oriented differently. Is 240×320 still considered safe? | TITLE:
Which resolution to target for a Mobile App?
QUESTION:
When desinging UI for mobile apps in general which resolution could be considered safe as a general rule of thumb. My interest lies specifically in web based apps. The iPhone has a pretty high resolution for a hand held, and the Nokia E Series seem to oriented differently. Is 240×320 still considered safe?
ANSWER:
Not enough information... You say you're targeting a "Mobile App" but the reality is that mobile could mean anything from a cell phone with 128x128 resolution to a MID with 800x600 resolution. There is no "safe" resolution for such a wide range, and if you're truly targeting all of them you need to design a custom interface for each major resolution. Add some scaling factors in and you might be able to cut it down to 5-8 different interface designs. Further, the UI means "User Interface" and includes a lot more than just the resolution - you can't count on a touchscreen, full keyboard, or even software keys. You need to either better define your target, or explain your target here so we can better help you. Keep in mind that there are millions of phone users that don't have PDA resolutions, and you can really only count on 128x128 or better to cover the majority of technically inclined cell phone users (those that know there's a web browser in their phone, nevermind those that use it). But if you're prepared to accept these losses, go ahead and hit for 320x240 and 240x320. That will give you most current PDA phones and up (older blackberries and palm devices had smaller square orientations). Plan on spending time later supporting lower resolution devices and above all... Do not tie your app to a particular resolution. Make sure your app is flexible enough that you can deploy new UI's without changing internal application logic - in other words separate the presentation from the core logic. You will find this very useful later - the mobile world changes daily. Once you gauge how your app is being used you can, for instance, easily deploy an iPhone specific version that is pixel perfect (and prettier than an upscaled 320x240) in order to engage more users. Being able to do this in a few hours (because you don't have to change the internals) is going to put you miles ahead of the competition if someone else makes a swipe at your market. -Adam | [
"mobile",
"web-applications"
] | 1 | 3 | 2,739 | 3 | 0 | 2008-08-26T12:57:42.167000 | 2008-08-26T13:45:07.420000 |
27,952 | 28,230 | How do I change the locations of source files in a symbols file (pdb) | Basically what I want to do it this: a pdb file contains a location of source files (e.g. C:\dev\proj1\helloworld.cs ). Is it possible to modify that pdb file so that it contains a different location (e.g. \more\differenter\location\proj1\helloworld.cs )? | You can use the source indexing feature of the Debugging Tools for Windows, which will save references to the appropriate revisions of the files in your source repository as an alternate stream in the PDB file. | How do I change the locations of source files in a symbols file (pdb) Basically what I want to do it this: a pdb file contains a location of source files (e.g. C:\dev\proj1\helloworld.cs ). Is it possible to modify that pdb file so that it contains a different location (e.g. \more\differenter\location\proj1\helloworld.cs )? | TITLE:
How do I change the locations of source files in a symbols file (pdb)
QUESTION:
Basically what I want to do it this: a pdb file contains a location of source files (e.g. C:\dev\proj1\helloworld.cs ). Is it possible to modify that pdb file so that it contains a different location (e.g. \more\differenter\location\proj1\helloworld.cs )?
ANSWER:
You can use the source indexing feature of the Debugging Tools for Windows, which will save references to the appropriate revisions of the files in your source repository as an alternate stream in the PDB file. | [
"debugging",
"symbols",
"pdb-files"
] | 26 | 12 | 12,747 | 4 | 0 | 2008-08-26T12:58:31.073000 | 2008-08-26T14:41:07.130000 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.