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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
29,107 | 165,333 | Generic IBindingListView Implementations | Can anyone suggest a good implementation of a generic collection class that implements the IBindingListView & IBindingList interfaces and provides Filtering and Searching capabilities? I see my current options as: Using a class that someone else has written and tested Inheriting from BindingList, and implementing the IBindingListView interfaces Write a custom collection from scratch, implementing IBindingListView and IBindingList. Obviously, the first option is my preferred choice. | I used and built upon an implementation I found on and old MSDN forum post from a few years ago, but recently I searched around again and found a sourceforge project called BindingListView. It looks pretty nice, I just haven't pulled it in to replace my hacked version yet. nuget package: Equin.ApplicationFramework.BindingListView Example code: var lst = new List { new DemoClass { Prop1 = "a", Prop2 = "b", Prop3 = "c" }, new DemoClass { Prop1 = "a", Prop2 = "e", Prop3 = "f" }, new DemoClass { Prop1 = "b", Prop2 = "h", Prop3 = "i" }, new DemoClass { Prop1 = "b", Prop2 = "k", Prop3 = "l" } }; dataGridView1.DataSource = new BindingListView (lst); // you can now sort by clicking the column headings // // to filter the view... var view = (BindingListView )dataGridView1.DataSource; view.ApplyFilter(dc => dc.Prop1 == "a"); | Generic IBindingListView Implementations Can anyone suggest a good implementation of a generic collection class that implements the IBindingListView & IBindingList interfaces and provides Filtering and Searching capabilities? I see my current options as: Using a class that someone else has written and tested Inheriting from BindingList, and implementing the IBindingListView interfaces Write a custom collection from scratch, implementing IBindingListView and IBindingList. Obviously, the first option is my preferred choice. | TITLE:
Generic IBindingListView Implementations
QUESTION:
Can anyone suggest a good implementation of a generic collection class that implements the IBindingListView & IBindingList interfaces and provides Filtering and Searching capabilities? I see my current options as: Using a class that someone else has written and tested Inheriting from BindingList, and implementing the IBindingListView interfaces Write a custom collection from scratch, implementing IBindingListView and IBindingList. Obviously, the first option is my preferred choice.
ANSWER:
I used and built upon an implementation I found on and old MSDN forum post from a few years ago, but recently I searched around again and found a sourceforge project called BindingListView. It looks pretty nice, I just haven't pulled it in to replace my hacked version yet. nuget package: Equin.ApplicationFramework.BindingListView Example code: var lst = new List { new DemoClass { Prop1 = "a", Prop2 = "b", Prop3 = "c" }, new DemoClass { Prop1 = "a", Prop2 = "e", Prop3 = "f" }, new DemoClass { Prop1 = "b", Prop2 = "h", Prop3 = "i" }, new DemoClass { Prop1 = "b", Prop2 = "k", Prop3 = "l" } }; dataGridView1.DataSource = new BindingListView (lst); // you can now sort by clicking the column headings // // to filter the view... var view = (BindingListView )dataGridView1.DataSource; view.ApplyFilter(dc => dc.Prop1 == "a"); | [
".net",
"data-binding"
] | 27 | 27 | 19,502 | 3 | 0 | 2008-08-26T22:32:51.660000 | 2008-10-03T01:23:31.500000 |
29,141 | 29,232 | Using Interop with C#, Excel Save changing original. How to negate this? | The problem: Loading an excel spreadsheet template. Using the Save command with a different filename and then quitting the interop object. This ends up saving the original template file. Not the result that is liked. public void saveAndExit(string filename) { excelApplication.Save(filename); excelApplication.Quit(); } Original file opened is c:\testing\template.xls The file name that is passed in is c:\testing\7777 (date).xls Does anyone have an answer? (The answer I chose was the most correct and thorough though the wbk.Close() requires parameters passed to it. Thanks.) | Excel interop is pretty painful. I dug up an old project I had, did a little fiddling, and I think this is what you're looking for. The other commenters are right, but, at least in my experience, there's a lot more to calling SaveAs() than you'd expect if you've used the same objects (without the interop wrapper) in VBA. Microsoft.Office.Interop.Excel.Workbook wbk = excelApplication.Workbooks[0]; //or some other way of obtaining this workbook reference, as Jason Z mentioned wbk.SaveAs(filename, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, XlSaveAsAccessMode.xlNoChange, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing); wbk.Close(); excelApplication.Quit(); Gotta love all those Type.Missings. But I think they're necessary. | Using Interop with C#, Excel Save changing original. How to negate this? The problem: Loading an excel spreadsheet template. Using the Save command with a different filename and then quitting the interop object. This ends up saving the original template file. Not the result that is liked. public void saveAndExit(string filename) { excelApplication.Save(filename); excelApplication.Quit(); } Original file opened is c:\testing\template.xls The file name that is passed in is c:\testing\7777 (date).xls Does anyone have an answer? (The answer I chose was the most correct and thorough though the wbk.Close() requires parameters passed to it. Thanks.) | TITLE:
Using Interop with C#, Excel Save changing original. How to negate this?
QUESTION:
The problem: Loading an excel spreadsheet template. Using the Save command with a different filename and then quitting the interop object. This ends up saving the original template file. Not the result that is liked. public void saveAndExit(string filename) { excelApplication.Save(filename); excelApplication.Quit(); } Original file opened is c:\testing\template.xls The file name that is passed in is c:\testing\7777 (date).xls Does anyone have an answer? (The answer I chose was the most correct and thorough though the wbk.Close() requires parameters passed to it. Thanks.)
ANSWER:
Excel interop is pretty painful. I dug up an old project I had, did a little fiddling, and I think this is what you're looking for. The other commenters are right, but, at least in my experience, there's a lot more to calling SaveAs() than you'd expect if you've used the same objects (without the interop wrapper) in VBA. Microsoft.Office.Interop.Excel.Workbook wbk = excelApplication.Workbooks[0]; //or some other way of obtaining this workbook reference, as Jason Z mentioned wbk.SaveAs(filename, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, XlSaveAsAccessMode.xlNoChange, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing); wbk.Close(); excelApplication.Quit(); Gotta love all those Type.Missings. But I think they're necessary. | [
"c#",
"excel"
] | 11 | 8 | 19,777 | 4 | 0 | 2008-08-26T22:55:37.473000 | 2008-08-27T00:02:59.557000 |
29,142 | 29,172 | Getting ssh to execute a command in the background on target machine | This is a follow-on question to the How do you use ssh in a shell script? question. If I want to execute a command on the remote machine that runs in the background on that machine, how do I get the ssh command to return? When I try to just include the ampersand (&) at the end of the command it just hangs. The exact form of the command looks like this: ssh user@target "cd /some/directory; program-to-execute &" Any ideas? One thing to note is that logins to the target machine always produce a text banner and I have SSH keys set up so no password is required. | This should solve your problem: nohup myprogram > foo.log 2> foo.err < /dev/null & The syntax and unusual use of < /dev/null are explained especially well in this answer, quoted here for your convenience. < /dev/null is used to instantly send EOF to the program, so that it doesn't wait for input ( /dev/null, the null device, is a special file that discards all data written to it, but reports that the write operation succeeded, and provides no data to any process that reads from it, yielding EOF immediately). So the command: nohup myscript.sh >myscript.log 2>&1 will move to background the command, outputting both stdout and stderr to myscript.log without waiting for any input. See also the wikipedia artcle on nohup, also quoted here for your convenience. Nohuping backgrounded jobs is for example useful when logged in via SSH, since backgrounded jobs can cause the shell to hang on logout due to a race condition. This problem can also be overcome by redirecting all three I/O streams. | Getting ssh to execute a command in the background on target machine This is a follow-on question to the How do you use ssh in a shell script? question. If I want to execute a command on the remote machine that runs in the background on that machine, how do I get the ssh command to return? When I try to just include the ampersand (&) at the end of the command it just hangs. The exact form of the command looks like this: ssh user@target "cd /some/directory; program-to-execute &" Any ideas? One thing to note is that logins to the target machine always produce a text banner and I have SSH keys set up so no password is required. | TITLE:
Getting ssh to execute a command in the background on target machine
QUESTION:
This is a follow-on question to the How do you use ssh in a shell script? question. If I want to execute a command on the remote machine that runs in the background on that machine, how do I get the ssh command to return? When I try to just include the ampersand (&) at the end of the command it just hangs. The exact form of the command looks like this: ssh user@target "cd /some/directory; program-to-execute &" Any ideas? One thing to note is that logins to the target machine always produce a text banner and I have SSH keys set up so no password is required.
ANSWER:
This should solve your problem: nohup myprogram > foo.log 2> foo.err < /dev/null & The syntax and unusual use of < /dev/null are explained especially well in this answer, quoted here for your convenience. < /dev/null is used to instantly send EOF to the program, so that it doesn't wait for input ( /dev/null, the null device, is a special file that discards all data written to it, but reports that the write operation succeeded, and provides no data to any process that reads from it, yielding EOF immediately). So the command: nohup myscript.sh >myscript.log 2>&1 will move to background the command, outputting both stdout and stderr to myscript.log without waiting for any input. See also the wikipedia artcle on nohup, also quoted here for your convenience. Nohuping backgrounded jobs is for example useful when logged in via SSH, since backgrounded jobs can cause the shell to hang on logout due to a race condition. This problem can also be overcome by redirecting all three I/O streams. | [
"bash",
"ssh",
"csh"
] | 365 | 387 | 389,090 | 19 | 0 | 2008-08-26T22:55:58.970000 | 2008-08-26T23:18:41.147000 |
29,144 | 31,042 | What is the more efficient version control methodology: checkout or merge? | I've always used Subversion or CVS for version control, which use a 'merge' methodology. One of my friends raves about Perforce and how great it is with its change lists and check-out methodology. While I'm sure a lot of it comes down to experience & personal preference, I was wondering if any research had been done into which method of version control is more efficient to work in? EDIT: To clarify, I know both Perforce & SVN allow locking & merging, but SVN 'encourages' a liberal edit & merge method, whereas as I understand it, Perforce encourages a checkout-checkin method. | Honestly I think it depends on the discipline of the developers. I use Subversion for my personal work and I've used it at a few jobs. What I like about Subversion is I don't have to hunt someone down and ask them why they're working on something and if it would be OK for me to do some work. The problem comes when someone decides to start working on something and doesn't check it in for a while; this can make merging difficult as several changes get made between their check-out and check-in. I use Perforce right now and for some reason I like SVN better. Perforce definitely gives me a better indication that there's going to be merge conflicts, and even has built-in tools to help me resolve the merges. It has the same problem where if someone makes tons of changes over a long time, the merge will be more difficult. Basically both models require you to check in changes often. If you make numerous check-ins, then you reduce the likelihood that you'll require a merge. I'm guilty of keeping stuff checked out for too long way too often. Personally I feel like SVN's price tag makes up for anything it lacks compared to Perforce; I haven't found a difference between them yet. | What is the more efficient version control methodology: checkout or merge? I've always used Subversion or CVS for version control, which use a 'merge' methodology. One of my friends raves about Perforce and how great it is with its change lists and check-out methodology. While I'm sure a lot of it comes down to experience & personal preference, I was wondering if any research had been done into which method of version control is more efficient to work in? EDIT: To clarify, I know both Perforce & SVN allow locking & merging, but SVN 'encourages' a liberal edit & merge method, whereas as I understand it, Perforce encourages a checkout-checkin method. | TITLE:
What is the more efficient version control methodology: checkout or merge?
QUESTION:
I've always used Subversion or CVS for version control, which use a 'merge' methodology. One of my friends raves about Perforce and how great it is with its change lists and check-out methodology. While I'm sure a lot of it comes down to experience & personal preference, I was wondering if any research had been done into which method of version control is more efficient to work in? EDIT: To clarify, I know both Perforce & SVN allow locking & merging, but SVN 'encourages' a liberal edit & merge method, whereas as I understand it, Perforce encourages a checkout-checkin method.
ANSWER:
Honestly I think it depends on the discipline of the developers. I use Subversion for my personal work and I've used it at a few jobs. What I like about Subversion is I don't have to hunt someone down and ask them why they're working on something and if it would be OK for me to do some work. The problem comes when someone decides to start working on something and doesn't check it in for a while; this can make merging difficult as several changes get made between their check-out and check-in. I use Perforce right now and for some reason I like SVN better. Perforce definitely gives me a better indication that there's going to be merge conflicts, and even has built-in tools to help me resolve the merges. It has the same problem where if someone makes tons of changes over a long time, the merge will be more difficult. Basically both models require you to check in changes often. If you make numerous check-ins, then you reduce the likelihood that you'll require a merge. I'm guilty of keeping stuff checked out for too long way too often. Personally I feel like SVN's price tag makes up for anything it lacks compared to Perforce; I haven't found a difference between them yet. | [
"svn",
"version-control",
"perforce"
] | 1 | 4 | 1,539 | 10 | 0 | 2008-08-26T22:58:43.720000 | 2008-08-27T19:48:57.443000 |
29,155 | 29,170 | What are the differences between delegates and events? | What are the differences between delegates and an events? Don't both hold references to functions that can be executed? | An Event declaration adds a layer of abstraction and protection on the delegate instance. This protection prevents clients of the delegate from resetting the delegate and its invocation list and only allows adding or removing targets from the invocation list. | What are the differences between delegates and events? What are the differences between delegates and an events? Don't both hold references to functions that can be executed? | TITLE:
What are the differences between delegates and events?
QUESTION:
What are the differences between delegates and an events? Don't both hold references to functions that can be executed?
ANSWER:
An Event declaration adds a layer of abstraction and protection on the delegate instance. This protection prevents clients of the delegate from resetting the delegate and its invocation list and only allows adding or removing targets from the invocation list. | [
"c#",
"events",
"delegates",
"glossary"
] | 376 | 336 | 155,962 | 11 | 0 | 2008-08-26T23:06:31.860000 | 2008-08-26T23:16:18.640000 |
29,168 | 2,047,574 | Deploying a Git subdirectory in Capistrano | My master branch layout is like this: / <-- top level /client <-- desktop client source files /server <-- Rails app What I'd like to do is only pull down the /server directory in my deploy.rb, but I can't seem to find any way to do that. The /client directory is huge, so setting up a hook to copy /server to / won't work very well, it needs to only pull down the Rails app. | Without any dirty forking action but even dirtier! In my config/deploy.rb: set:deploy_subdir, "project/subdir" Then I added this new strategy to my Capfile: require 'capistrano/recipes/deploy/strategy/remote_cache'
class RemoteCacheSubdir < Capistrano::Deploy::Strategy::RemoteCache
private
def repository_cache_subdir if configuration[:deploy_subdir] then File.join(repository_cache, configuration[:deploy_subdir]) else repository_cache end end
def copy_repository_cache logger.trace "copying the cached version to #{configuration[:release_path]}" if copy_exclude.empty? run "cp -RPp #{repository_cache_subdir} #{configuration[:release_path]} && #{mark}" else exclusions = copy_exclude.map { |e| "--exclude=\"#{e}\"" }.join(' ') run "rsync -lrpt #{exclusions} #{repository_cache_subdir}/* #{configuration[:release_path]} && #{mark}" end end
end
set:strategy, RemoteCacheSubdir.new(self) | Deploying a Git subdirectory in Capistrano My master branch layout is like this: / <-- top level /client <-- desktop client source files /server <-- Rails app What I'd like to do is only pull down the /server directory in my deploy.rb, but I can't seem to find any way to do that. The /client directory is huge, so setting up a hook to copy /server to / won't work very well, it needs to only pull down the Rails app. | TITLE:
Deploying a Git subdirectory in Capistrano
QUESTION:
My master branch layout is like this: / <-- top level /client <-- desktop client source files /server <-- Rails app What I'd like to do is only pull down the /server directory in my deploy.rb, but I can't seem to find any way to do that. The /client directory is huge, so setting up a hook to copy /server to / won't work very well, it needs to only pull down the Rails app.
ANSWER:
Without any dirty forking action but even dirtier! In my config/deploy.rb: set:deploy_subdir, "project/subdir" Then I added this new strategy to my Capfile: require 'capistrano/recipes/deploy/strategy/remote_cache'
class RemoteCacheSubdir < Capistrano::Deploy::Strategy::RemoteCache
private
def repository_cache_subdir if configuration[:deploy_subdir] then File.join(repository_cache, configuration[:deploy_subdir]) else repository_cache end end
def copy_repository_cache logger.trace "copying the cached version to #{configuration[:release_path]}" if copy_exclude.empty? run "cp -RPp #{repository_cache_subdir} #{configuration[:release_path]} && #{mark}" else exclusions = copy_exclude.map { |e| "--exclude=\"#{e}\"" }.join(' ') run "rsync -lrpt #{exclusions} #{repository_cache_subdir}/* #{configuration[:release_path]} && #{mark}" end end
end
set:strategy, RemoteCacheSubdir.new(self) | [
"ruby-on-rails",
"git",
"deployment",
"capistrano"
] | 67 | 79 | 15,616 | 12 | 0 | 2008-08-26T23:15:41.697000 | 2010-01-12T08:18:01.160000 |
29,174 | 31,338 | SimpleModal breaks ASP.Net Postbacks | I'm using jQuery and SimpleModal in an ASP.Net project to make some nice dialogs for a web app. Unfortunately, any buttons in a modal dialog can no longer execute their postbacks, which is not really acceptable. There is one source I've found with a workaround, but for the life of me I can't get it to work, mostly because I am not fully understanding all of the necessary steps. I also have a workaround, which is to replace the postbacks, but it's ugly and probably not the most reliable. I would really like to make the postbacks work again. Any ideas? UPDATE: I should clarify, the postbacks are not working because the Javascript used to execute the post backs has broken in some way, so nothing happens at all when the button is clicked. | Both of you were on the right track. What I realized is that SimpleModal appends the dialog to the body, which is outside ASP.Net's, which breaks the functionality, since it can't find the elements. To fix it, I just modified the SimpleModal source to append eveything to 'form' instead of 'body'. When I create the dialog, I also use the persist: true option, to make sure the buttons stay through opening and closing. Thanks everyone for the suggestions! UPDATE: Version 1.3 adds an appendTo option in the configuration for specifying which element the modal dialog should be appended to. Here are the docs. | SimpleModal breaks ASP.Net Postbacks I'm using jQuery and SimpleModal in an ASP.Net project to make some nice dialogs for a web app. Unfortunately, any buttons in a modal dialog can no longer execute their postbacks, which is not really acceptable. There is one source I've found with a workaround, but for the life of me I can't get it to work, mostly because I am not fully understanding all of the necessary steps. I also have a workaround, which is to replace the postbacks, but it's ugly and probably not the most reliable. I would really like to make the postbacks work again. Any ideas? UPDATE: I should clarify, the postbacks are not working because the Javascript used to execute the post backs has broken in some way, so nothing happens at all when the button is clicked. | TITLE:
SimpleModal breaks ASP.Net Postbacks
QUESTION:
I'm using jQuery and SimpleModal in an ASP.Net project to make some nice dialogs for a web app. Unfortunately, any buttons in a modal dialog can no longer execute their postbacks, which is not really acceptable. There is one source I've found with a workaround, but for the life of me I can't get it to work, mostly because I am not fully understanding all of the necessary steps. I also have a workaround, which is to replace the postbacks, but it's ugly and probably not the most reliable. I would really like to make the postbacks work again. Any ideas? UPDATE: I should clarify, the postbacks are not working because the Javascript used to execute the post backs has broken in some way, so nothing happens at all when the button is clicked.
ANSWER:
Both of you were on the right track. What I realized is that SimpleModal appends the dialog to the body, which is outside ASP.Net's, which breaks the functionality, since it can't find the elements. To fix it, I just modified the SimpleModal source to append eveything to 'form' instead of 'body'. When I create the dialog, I also use the persist: true option, to make sure the buttons stay through opening and closing. Thanks everyone for the suggestions! UPDATE: Version 1.3 adds an appendTo option in the configuration for specifying which element the modal dialog should be appended to. Here are the docs. | [
"asp.net",
"javascript",
"jquery",
"postback",
"simplemodal"
] | 25 | 33 | 10,553 | 10 | 0 | 2008-08-26T23:19:47.960000 | 2008-08-27T23:44:06.100000 |
29,175 | 29,204 | (IIS/Win2000Pro) Granting Registry read rights to IIS user? | Okay, so I'm running a small test webserver on my private network. I've got a machine running Windows 2000 Pro, and I'm trying to run an ASP.NET app through IIS. I wrote it so that the webpage would use the registry to store certain settings (connection strings, potentially volatile locations of other web services, paths in the local filesystem where certain information is stored etc...) Of course, it worked fine when testing with VStudio.NET 2005, because the user running the app has elevated privileges. However, running it on IIS I get a "Access to the registry key 'HKEY_LOCAL_MACHINE\Software' is denied.", which suggests the IIS user doesn't have read access to that part of the registry (I only do reads through the website itself, never writes). I was like "okay, simple enough, I'll just go give that user rights to that part of the registry through regedit." The problem is, I don't see an option anywhere in regedit to change security settings... at all. Which got me thinking... I don't think I've ever actually had to change security settings for registry hives/keys before, and I don't think I know how to do it. Half an hour of searching the web later, I haven't found any usable information on this subject. What I'm wondering is... how DO you change security rights to portions of the registry? I'm stumped, and it seems my ability to find the answer on Google is failing me utterly... and since I just signed up here, I figured I'd see if anyone here knew. =) | If your having touble with RegEdit in Windows 2000 you can try the following: Copy the Windows XP RegEdt32.exe to the Windows 2000 Machine Using a Windows XP Machine, connect to the Windows 2000 registry remotely: File > Connect Network Registry | (IIS/Win2000Pro) Granting Registry read rights to IIS user? Okay, so I'm running a small test webserver on my private network. I've got a machine running Windows 2000 Pro, and I'm trying to run an ASP.NET app through IIS. I wrote it so that the webpage would use the registry to store certain settings (connection strings, potentially volatile locations of other web services, paths in the local filesystem where certain information is stored etc...) Of course, it worked fine when testing with VStudio.NET 2005, because the user running the app has elevated privileges. However, running it on IIS I get a "Access to the registry key 'HKEY_LOCAL_MACHINE\Software' is denied.", which suggests the IIS user doesn't have read access to that part of the registry (I only do reads through the website itself, never writes). I was like "okay, simple enough, I'll just go give that user rights to that part of the registry through regedit." The problem is, I don't see an option anywhere in regedit to change security settings... at all. Which got me thinking... I don't think I've ever actually had to change security settings for registry hives/keys before, and I don't think I know how to do it. Half an hour of searching the web later, I haven't found any usable information on this subject. What I'm wondering is... how DO you change security rights to portions of the registry? I'm stumped, and it seems my ability to find the answer on Google is failing me utterly... and since I just signed up here, I figured I'd see if anyone here knew. =) | TITLE:
(IIS/Win2000Pro) Granting Registry read rights to IIS user?
QUESTION:
Okay, so I'm running a small test webserver on my private network. I've got a machine running Windows 2000 Pro, and I'm trying to run an ASP.NET app through IIS. I wrote it so that the webpage would use the registry to store certain settings (connection strings, potentially volatile locations of other web services, paths in the local filesystem where certain information is stored etc...) Of course, it worked fine when testing with VStudio.NET 2005, because the user running the app has elevated privileges. However, running it on IIS I get a "Access to the registry key 'HKEY_LOCAL_MACHINE\Software' is denied.", which suggests the IIS user doesn't have read access to that part of the registry (I only do reads through the website itself, never writes). I was like "okay, simple enough, I'll just go give that user rights to that part of the registry through regedit." The problem is, I don't see an option anywhere in regedit to change security settings... at all. Which got me thinking... I don't think I've ever actually had to change security settings for registry hives/keys before, and I don't think I know how to do it. Half an hour of searching the web later, I haven't found any usable information on this subject. What I'm wondering is... how DO you change security rights to portions of the registry? I'm stumped, and it seems my ability to find the answer on Google is failing me utterly... and since I just signed up here, I figured I'd see if anyone here knew. =)
ANSWER:
If your having touble with RegEdit in Windows 2000 you can try the following: Copy the Windows XP RegEdt32.exe to the Windows 2000 Machine Using a Windows XP Machine, connect to the Windows 2000 registry remotely: File > Connect Network Registry | [
"security",
"iis",
"registry",
"windows-server-2000"
] | 1 | 1 | 3,231 | 6 | 0 | 2008-08-26T23:21:31.280000 | 2008-08-26T23:38:37.073000 |
29,177 | 30,187 | DoDragDrop and MouseUp | Is there an easy way to ensure that after a drag-and-drop fails to complete, the MouseUp event isn't eaten up and ignored by the framework? I have found a blog post describing one mechanism, but it involves a good deal of manual bookkeeping, including status flags, MouseMove events, manual "mouse leave" checking, etc. all of which I would rather not have to implement if it can be avoided. | I was recently wanting to put Drag and Drop functionality in my project and I hadn't come across this issue, but I was intrigued and really wanted to see if I could come up with a better method than the one described in the page you linked to. I hope I clearly understood everything you wanted to do and overall I think I succeeded in solving the problem in a much more elegant and simple fashion. On a quick side note, for problems like this it would be great if you provide some code so we can see exactly what it is you are trying to do. I say this only because I assumed a few things about your code in my solution...so hopefully it's pretty close. Here's the code, which I will explain below: this.LabelDrag.QueryContinueDrag += new System.Windows.Forms.QueryContinueDragEventHandler(this.LabelDrag_QueryContinueDrag); this.LabelDrag.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LabelDrag_MouseDown); this.LabelDrag.MouseUp += new System.Windows.Forms.MouseEventHandler(this.LabelDrag_MouseUp);
this.LabelDrop.DragDrop += new System.Windows.Forms.DragEventHandler(this.LabelDrop_DragDrop); this.LabelDrop.DragEnter += new System.Windows.Forms.DragEventHandler(this.LabelMain_DragEnter);
public partial class Form1: Form { public Form1() { InitializeComponent(); }
private void LabelDrop_DragDrop(object sender, DragEventArgs e) { LabelDrop.Text = e.Data.GetData(DataFormats.Text).ToString(); }
private void LabelMain_DragEnter(object sender, DragEventArgs e) { if (e.Data.GetDataPresent(DataFormats.Text)) e.Effect = DragDropEffects.Copy; else e.Effect = DragDropEffects.None;
}
private void LabelDrag_MouseDown(object sender, MouseEventArgs e) { //EXTREMELY IMPORTANT - MUST CALL LabelDrag's DoDragDrop method!! //Calling the Form's DoDragDrop WILL NOT allow QueryContinueDrag to fire! ((Label)sender).DoDragDrop(TextMain.Text, DragDropEffects.Copy); }
private void LabelDrag_MouseUp(object sender, MouseEventArgs e) { LabelDrop.Text = "LabelDrag_MouseUp"; }
private void LabelDrag_QueryContinueDrag(object sender, QueryContinueDragEventArgs e) { //Get rect of LabelDrop Rectangle rect = new Rectangle(LabelDrop.Location, new Size(LabelDrop.Width, LabelDrop.Height));
//If the left mouse button is up and the mouse is not currently over LabelDrop if (Control.MouseButtons!= MouseButtons.Left &&!rect.Contains(PointToClient(Control.MousePosition))) { //Cancel the DragDrop Action e.Action = DragAction.Cancel; //Manually fire the MouseUp event LabelDrag_MouseUp(sender, new MouseEventArgs(Control.MouseButtons, 0, Control.MousePosition.X, Control.MousePosition.Y, 0)); } }
} I have left out most of the designer code, but included the Event Handler link up code so you can be sure what is linked to what. In my example, the drag/drop is occuring between the labels LabelDrag and LabelDrop. The main piece of my solution is using the QueryContinueDrag event. This event fires when the keyboard or mouse state changes after DoDragDrop has been called on that control. You may already be doing this, but it is very important that you call the DoDragDrop method of the control that is your source and not the method associated with the form. Otherwise QueryContinueDrag will NOT fire! One thing to note is that QueryContinueDrag will actually fire when you release the mouse on the drop control so we need to make sure we allow for that. This is handled by checking that the Mouse position (retrieved with the global Control.MousePosition property) is inside of the LabelDrop control rectangle. You must also be sure to convert MousePosition to a point relative to the Client Window with PointToClient as Control.MousePosition returns a screen relative position. So by checking that the mouse is not over the drop control and that the mouse button is now up we have effectively captured a MouseUp event for the LabelDrag control!:) Now, you could just do whatever processing you want to do here, but if you already have code you are using in the MouseUp event handler, this is not efficient. So just call your MouseUp event from here, passing it the necessary parameters and the MouseUp handler won't ever know the difference. Just a note though, as I call DoDragDrop from within the MouseDown event handler in my example, this code should never actually get a direct MouseUp event to fire. I just put that code in there to show that it is possible to do it. Hope that helps! | DoDragDrop and MouseUp Is there an easy way to ensure that after a drag-and-drop fails to complete, the MouseUp event isn't eaten up and ignored by the framework? I have found a blog post describing one mechanism, but it involves a good deal of manual bookkeeping, including status flags, MouseMove events, manual "mouse leave" checking, etc. all of which I would rather not have to implement if it can be avoided. | TITLE:
DoDragDrop and MouseUp
QUESTION:
Is there an easy way to ensure that after a drag-and-drop fails to complete, the MouseUp event isn't eaten up and ignored by the framework? I have found a blog post describing one mechanism, but it involves a good deal of manual bookkeeping, including status flags, MouseMove events, manual "mouse leave" checking, etc. all of which I would rather not have to implement if it can be avoided.
ANSWER:
I was recently wanting to put Drag and Drop functionality in my project and I hadn't come across this issue, but I was intrigued and really wanted to see if I could come up with a better method than the one described in the page you linked to. I hope I clearly understood everything you wanted to do and overall I think I succeeded in solving the problem in a much more elegant and simple fashion. On a quick side note, for problems like this it would be great if you provide some code so we can see exactly what it is you are trying to do. I say this only because I assumed a few things about your code in my solution...so hopefully it's pretty close. Here's the code, which I will explain below: this.LabelDrag.QueryContinueDrag += new System.Windows.Forms.QueryContinueDragEventHandler(this.LabelDrag_QueryContinueDrag); this.LabelDrag.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LabelDrag_MouseDown); this.LabelDrag.MouseUp += new System.Windows.Forms.MouseEventHandler(this.LabelDrag_MouseUp);
this.LabelDrop.DragDrop += new System.Windows.Forms.DragEventHandler(this.LabelDrop_DragDrop); this.LabelDrop.DragEnter += new System.Windows.Forms.DragEventHandler(this.LabelMain_DragEnter);
public partial class Form1: Form { public Form1() { InitializeComponent(); }
private void LabelDrop_DragDrop(object sender, DragEventArgs e) { LabelDrop.Text = e.Data.GetData(DataFormats.Text).ToString(); }
private void LabelMain_DragEnter(object sender, DragEventArgs e) { if (e.Data.GetDataPresent(DataFormats.Text)) e.Effect = DragDropEffects.Copy; else e.Effect = DragDropEffects.None;
}
private void LabelDrag_MouseDown(object sender, MouseEventArgs e) { //EXTREMELY IMPORTANT - MUST CALL LabelDrag's DoDragDrop method!! //Calling the Form's DoDragDrop WILL NOT allow QueryContinueDrag to fire! ((Label)sender).DoDragDrop(TextMain.Text, DragDropEffects.Copy); }
private void LabelDrag_MouseUp(object sender, MouseEventArgs e) { LabelDrop.Text = "LabelDrag_MouseUp"; }
private void LabelDrag_QueryContinueDrag(object sender, QueryContinueDragEventArgs e) { //Get rect of LabelDrop Rectangle rect = new Rectangle(LabelDrop.Location, new Size(LabelDrop.Width, LabelDrop.Height));
//If the left mouse button is up and the mouse is not currently over LabelDrop if (Control.MouseButtons!= MouseButtons.Left &&!rect.Contains(PointToClient(Control.MousePosition))) { //Cancel the DragDrop Action e.Action = DragAction.Cancel; //Manually fire the MouseUp event LabelDrag_MouseUp(sender, new MouseEventArgs(Control.MouseButtons, 0, Control.MousePosition.X, Control.MousePosition.Y, 0)); } }
} I have left out most of the designer code, but included the Event Handler link up code so you can be sure what is linked to what. In my example, the drag/drop is occuring between the labels LabelDrag and LabelDrop. The main piece of my solution is using the QueryContinueDrag event. This event fires when the keyboard or mouse state changes after DoDragDrop has been called on that control. You may already be doing this, but it is very important that you call the DoDragDrop method of the control that is your source and not the method associated with the form. Otherwise QueryContinueDrag will NOT fire! One thing to note is that QueryContinueDrag will actually fire when you release the mouse on the drop control so we need to make sure we allow for that. This is handled by checking that the Mouse position (retrieved with the global Control.MousePosition property) is inside of the LabelDrop control rectangle. You must also be sure to convert MousePosition to a point relative to the Client Window with PointToClient as Control.MousePosition returns a screen relative position. So by checking that the mouse is not over the drop control and that the mouse button is now up we have effectively captured a MouseUp event for the LabelDrag control!:) Now, you could just do whatever processing you want to do here, but if you already have code you are using in the MouseUp event handler, this is not efficient. So just call your MouseUp event from here, passing it the necessary parameters and the MouseUp handler won't ever know the difference. Just a note though, as I call DoDragDrop from within the MouseDown event handler in my example, this code should never actually get a direct MouseUp event to fire. I just put that code in there to show that it is possible to do it. Hope that helps! | [
".net",
"winforms",
"events",
"drag-and-drop"
] | 20 | 25 | 19,015 | 1 | 0 | 2008-08-26T23:23:05.033000 | 2008-08-27T14:00:12.353000 |
29,242 | 29,395 | Off-the-Shelf C++ Hex Dump Code | I work a lot with network and serial communications software, so it is often necessary for me to have code to display or log hex dumps of data packets. Every time I do this, I write yet another hex-dump routine from scratch. I'm about to do so again, but figured I'd ask here: Is there any good free hex dump code for C++ out there somewhere? Features I'd like: N bytes per line (where N is somehow configurable) optional ASCII/UTF8 dump alongside the hex configurable indentation, per-line prefixes, per-line suffixes, etc. minimal dependencies (ideally, I'd like the code to all be in a header file, or be a snippet I can just paste in) Edit: Clarification: I am looking for code that I can easily drop in to my own programs to write to stderr, stdout, log files, or other such output streams. I'm not looking for a command-line hex dump utility. | The unix tool xxd is distributed as part of vim, and according to http://www.vmunix.com/vim/util.html#xxd, the source for xxd is ftp://ftp.uni-erlangen.de:21/pub/utilities/etc/xxd-1.10.tar.gz. It was written in C and is about 721 lines. The only licensing information given for it is this: * Distribute freely and credit me, * make money and share with me, * lose money and don't ask me. The unix tool hexdump is available from http://gd.tuwien.ac.at/softeng/Aegis/hexdump.html. It was written in C and can be compiled from source. It's quite a bit bigger than xxd, and is distributed under the GPL. | Off-the-Shelf C++ Hex Dump Code I work a lot with network and serial communications software, so it is often necessary for me to have code to display or log hex dumps of data packets. Every time I do this, I write yet another hex-dump routine from scratch. I'm about to do so again, but figured I'd ask here: Is there any good free hex dump code for C++ out there somewhere? Features I'd like: N bytes per line (where N is somehow configurable) optional ASCII/UTF8 dump alongside the hex configurable indentation, per-line prefixes, per-line suffixes, etc. minimal dependencies (ideally, I'd like the code to all be in a header file, or be a snippet I can just paste in) Edit: Clarification: I am looking for code that I can easily drop in to my own programs to write to stderr, stdout, log files, or other such output streams. I'm not looking for a command-line hex dump utility. | TITLE:
Off-the-Shelf C++ Hex Dump Code
QUESTION:
I work a lot with network and serial communications software, so it is often necessary for me to have code to display or log hex dumps of data packets. Every time I do this, I write yet another hex-dump routine from scratch. I'm about to do so again, but figured I'd ask here: Is there any good free hex dump code for C++ out there somewhere? Features I'd like: N bytes per line (where N is somehow configurable) optional ASCII/UTF8 dump alongside the hex configurable indentation, per-line prefixes, per-line suffixes, etc. minimal dependencies (ideally, I'd like the code to all be in a header file, or be a snippet I can just paste in) Edit: Clarification: I am looking for code that I can easily drop in to my own programs to write to stderr, stdout, log files, or other such output streams. I'm not looking for a command-line hex dump utility.
ANSWER:
The unix tool xxd is distributed as part of vim, and according to http://www.vmunix.com/vim/util.html#xxd, the source for xxd is ftp://ftp.uni-erlangen.de:21/pub/utilities/etc/xxd-1.10.tar.gz. It was written in C and is about 721 lines. The only licensing information given for it is this: * Distribute freely and credit me, * make money and share with me, * lose money and don't ask me. The unix tool hexdump is available from http://gd.tuwien.ac.at/softeng/Aegis/hexdump.html. It was written in C and can be compiled from source. It's quite a bit bigger than xxd, and is distributed under the GPL. | [
"c++",
"logging",
"hex",
"hexdump"
] | 16 | 5 | 26,301 | 7 | 0 | 2008-08-27T00:18:19.113000 | 2008-08-27T02:42:07.507000 |
29,243 | 29,255 | How do I create an xml document in python | Here is my sample code: from xml.dom.minidom import * def make_xml(): doc = Document() node = doc.createElement('foo') node.innerText = 'bar' doc.appendChild(node) return doc if __name__ == '__main__': make_xml().writexml(sys.stdout) when I run the above code I get this: I would like to get: bar I just guessed that there was an innerText property, it gives no compiler error, but does not seem to work... how do I go about creating a text node? | Setting an attribute on an object won't give a compile-time or a run-time error, it will just do nothing useful if the object doesn't access it (i.e. " node.noSuchAttr = 'bar' " would also not give an error). Unless you need a specific feature of minidom, I would look at ElementTree: import sys from xml.etree.cElementTree import Element, ElementTree
def make_xml(): node = Element('foo') node.text = 'bar' doc = ElementTree(node) return doc
if __name__ == '__main__': make_xml().write(sys.stdout) | How do I create an xml document in python Here is my sample code: from xml.dom.minidom import * def make_xml(): doc = Document() node = doc.createElement('foo') node.innerText = 'bar' doc.appendChild(node) return doc if __name__ == '__main__': make_xml().writexml(sys.stdout) when I run the above code I get this: I would like to get: bar I just guessed that there was an innerText property, it gives no compiler error, but does not seem to work... how do I go about creating a text node? | TITLE:
How do I create an xml document in python
QUESTION:
Here is my sample code: from xml.dom.minidom import * def make_xml(): doc = Document() node = doc.createElement('foo') node.innerText = 'bar' doc.appendChild(node) return doc if __name__ == '__main__': make_xml().writexml(sys.stdout) when I run the above code I get this: I would like to get: bar I just guessed that there was an innerText property, it gives no compiler error, but does not seem to work... how do I go about creating a text node?
ANSWER:
Setting an attribute on an object won't give a compile-time or a run-time error, it will just do nothing useful if the object doesn't access it (i.e. " node.noSuchAttr = 'bar' " would also not give an error). Unless you need a specific feature of minidom, I would look at ElementTree: import sys from xml.etree.cElementTree import Element, ElementTree
def make_xml(): node = Element('foo') node.text = 'bar' doc = ElementTree(node) return doc
if __name__ == '__main__': make_xml().write(sys.stdout) | [
"python",
"xml"
] | 20 | 9 | 27,897 | 2 | 0 | 2008-08-27T00:21:35.643000 | 2008-08-27T00:35:29.807000 |
29,244 | 29,439 | HTML Select Tag with black background - dropdown triangle is invisible in Firefox 3 | I have the following HTML (note the CSS making the background black and text white) first second Safari is smart enough to make the small triangle that appears to the right of the text the same color as the foreground text. Other browsers basically ignore the CSS, so they're fine too. Firefox 3 however applies the background color but leaves the triangle black, so you can't see it, like this I can't find out how to fix this - can anyone help? Is there a -moz-select-triangle-color or something obscure like that? | Must be a Vista problem. I have XP SP 2 and it looks normal. | HTML Select Tag with black background - dropdown triangle is invisible in Firefox 3 I have the following HTML (note the CSS making the background black and text white) first second Safari is smart enough to make the small triangle that appears to the right of the text the same color as the foreground text. Other browsers basically ignore the CSS, so they're fine too. Firefox 3 however applies the background color but leaves the triangle black, so you can't see it, like this I can't find out how to fix this - can anyone help? Is there a -moz-select-triangle-color or something obscure like that? | TITLE:
HTML Select Tag with black background - dropdown triangle is invisible in Firefox 3
QUESTION:
I have the following HTML (note the CSS making the background black and text white) first second Safari is smart enough to make the small triangle that appears to the right of the text the same color as the foreground text. Other browsers basically ignore the CSS, so they're fine too. Firefox 3 however applies the background color but leaves the triangle black, so you can't see it, like this I can't find out how to fix this - can anyone help? Is there a -moz-select-triangle-color or something obscure like that?
ANSWER:
Must be a Vista problem. I have XP SP 2 and it looks normal. | [
"html",
"css",
"firefox",
"drop-down-menu",
"html-select"
] | 8 | 4 | 23,372 | 6 | 0 | 2008-08-27T00:23:02.783000 | 2008-08-27T03:13:46.680000 |
29,247 | 29,252 | What versions of Visual Studio can be installed concurrently? | Are there any conflicts with having any combination of Visual Studio 2003, 2005 and/or 2008 installed? I noticed a related question here but wanted a more general answer. | 6, 2000/2001 (I can't remember which is.net 1.0), 2003, 2005, 2008... of course within.NET you may have issues with getting the right solution with the right version. I haven't really seen any conflicts in particular. | What versions of Visual Studio can be installed concurrently? Are there any conflicts with having any combination of Visual Studio 2003, 2005 and/or 2008 installed? I noticed a related question here but wanted a more general answer. | TITLE:
What versions of Visual Studio can be installed concurrently?
QUESTION:
Are there any conflicts with having any combination of Visual Studio 2003, 2005 and/or 2008 installed? I noticed a related question here but wanted a more general answer.
ANSWER:
6, 2000/2001 (I can't remember which is.net 1.0), 2003, 2005, 2008... of course within.NET you may have issues with getting the right solution with the right version. I haven't really seen any conflicts in particular. | [
"visual-studio"
] | 7 | 8 | 409 | 7 | 0 | 2008-08-27T00:29:30.180000 | 2008-08-27T00:32:32.327000 |
29,284 | 29,789 | Windows Vista: Unable to load DLL 'x.dll': Invalid access to memory location. (DllNotFoundException) | I was testing on a customer's box this afternoon which has Windows Vista (He had home, but I am testing on a Business Edition with same results). We make use of a.DLL that gets the Hardware ID of the computer. It's usage is very simple and the sample program I have created works. The Dll is This from AzSdk. In fact, this works perfectly under Windows XP. However, for some strange reason, inside our project (way bigger), we get this exception: Exception Type: System.DllNotFoundException Exception Message: Unable to load DLL 'HardwareID.dll': Invalid access to memory location. (Exception from HRESULT: 0x800703E6) Exception Target Site: GetHardwareID I don't know what can be causing the problem, since I have full control over the folder. The project is a c#.net Windows Forms application and everything works fine, except the call for the external library. I am declaring it like this: (note: it's not a COM library and it doesn't need to be registered). [DllImport("HardwareID.dll")] public static extern String GetHardwareID(bool HDD, bool NIC, bool CPU, bool BIOS, string sRegistrationCode); And then the calling code is quite simple: private void button1_Click(object sender, EventArgs e) { textBox1.Text = GetHardwareID(cb_HDD.Checked, cb_NIC.Checked, cb_CPU.Checked, cb_BIOS.Checked, "*Registration Code*"); } When you create a sample application, it works, but inside my projectit doesn't. Under XP works fine. Any ideas about what should I do in Vista to make this work? As I've said, the folder and its sub-folders have Full Control for "Everybody". UPDATE: I do not have Vista SP 1 installed. UPDATE 2: I have installed Vista SP1 and now, with UAC disabled, not even the simple sample works!!!:( Damn Vista. | @ Martín The reason you were not getting the UAC prompt is because UAC can only change how a process is started, once the process is running it must stay at the same elevation level. The UAC will prompt will happen if: Vista thinks it's an installer ( lots of rules here, the simplest one is if it's called "setup.exe"), If it's flagged as "Run as Administrator" (you can edit this by changing the properties of the shortcut or the exe), or If the exe contains a manifest requesting admin privileges. The first two options are workarounds for 'legacy' applications that were around before UAC, the correct way to do it for new applications is to embed a manifest resource asking for the privileges that you need. Some program, such as Process Explorer appear to elevate a running process (when you choose "Show details for all process" in the file menu in this case) but what they really do is start a new instance, and it's that new instance that gets elevated - not the one that was originally running. This is the recommend way of doing it if only some parts of your application need elevation (e.g. a special 'admin options' dialog). | Windows Vista: Unable to load DLL 'x.dll': Invalid access to memory location. (DllNotFoundException) I was testing on a customer's box this afternoon which has Windows Vista (He had home, but I am testing on a Business Edition with same results). We make use of a.DLL that gets the Hardware ID of the computer. It's usage is very simple and the sample program I have created works. The Dll is This from AzSdk. In fact, this works perfectly under Windows XP. However, for some strange reason, inside our project (way bigger), we get this exception: Exception Type: System.DllNotFoundException Exception Message: Unable to load DLL 'HardwareID.dll': Invalid access to memory location. (Exception from HRESULT: 0x800703E6) Exception Target Site: GetHardwareID I don't know what can be causing the problem, since I have full control over the folder. The project is a c#.net Windows Forms application and everything works fine, except the call for the external library. I am declaring it like this: (note: it's not a COM library and it doesn't need to be registered). [DllImport("HardwareID.dll")] public static extern String GetHardwareID(bool HDD, bool NIC, bool CPU, bool BIOS, string sRegistrationCode); And then the calling code is quite simple: private void button1_Click(object sender, EventArgs e) { textBox1.Text = GetHardwareID(cb_HDD.Checked, cb_NIC.Checked, cb_CPU.Checked, cb_BIOS.Checked, "*Registration Code*"); } When you create a sample application, it works, but inside my projectit doesn't. Under XP works fine. Any ideas about what should I do in Vista to make this work? As I've said, the folder and its sub-folders have Full Control for "Everybody". UPDATE: I do not have Vista SP 1 installed. UPDATE 2: I have installed Vista SP1 and now, with UAC disabled, not even the simple sample works!!!:( Damn Vista. | TITLE:
Windows Vista: Unable to load DLL 'x.dll': Invalid access to memory location. (DllNotFoundException)
QUESTION:
I was testing on a customer's box this afternoon which has Windows Vista (He had home, but I am testing on a Business Edition with same results). We make use of a.DLL that gets the Hardware ID of the computer. It's usage is very simple and the sample program I have created works. The Dll is This from AzSdk. In fact, this works perfectly under Windows XP. However, for some strange reason, inside our project (way bigger), we get this exception: Exception Type: System.DllNotFoundException Exception Message: Unable to load DLL 'HardwareID.dll': Invalid access to memory location. (Exception from HRESULT: 0x800703E6) Exception Target Site: GetHardwareID I don't know what can be causing the problem, since I have full control over the folder. The project is a c#.net Windows Forms application and everything works fine, except the call for the external library. I am declaring it like this: (note: it's not a COM library and it doesn't need to be registered). [DllImport("HardwareID.dll")] public static extern String GetHardwareID(bool HDD, bool NIC, bool CPU, bool BIOS, string sRegistrationCode); And then the calling code is quite simple: private void button1_Click(object sender, EventArgs e) { textBox1.Text = GetHardwareID(cb_HDD.Checked, cb_NIC.Checked, cb_CPU.Checked, cb_BIOS.Checked, "*Registration Code*"); } When you create a sample application, it works, but inside my projectit doesn't. Under XP works fine. Any ideas about what should I do in Vista to make this work? As I've said, the folder and its sub-folders have Full Control for "Everybody". UPDATE: I do not have Vista SP 1 installed. UPDATE 2: I have installed Vista SP1 and now, with UAC disabled, not even the simple sample works!!!:( Damn Vista.
ANSWER:
@ Martín The reason you were not getting the UAC prompt is because UAC can only change how a process is started, once the process is running it must stay at the same elevation level. The UAC will prompt will happen if: Vista thinks it's an installer ( lots of rules here, the simplest one is if it's called "setup.exe"), If it's flagged as "Run as Administrator" (you can edit this by changing the properties of the shortcut or the exe), or If the exe contains a manifest requesting admin privileges. The first two options are workarounds for 'legacy' applications that were around before UAC, the correct way to do it for new applications is to embed a manifest resource asking for the privileges that you need. Some program, such as Process Explorer appear to elevate a running process (when you choose "Show details for all process" in the file menu in this case) but what they really do is start a new instance, and it's that new instance that gets elevated - not the one that was originally running. This is the recommend way of doing it if only some parts of your application need elevation (e.g. a special 'admin options' dialog). | [
"c#",
".net",
"windows-vista",
"dllnotfoundexception"
] | 4 | 2 | 12,250 | 6 | 0 | 2008-08-27T01:03:22.827000 | 2008-08-27T09:30:32.920000 |
29,292 | 29,330 | Version Control for Graphics | Say a development team includes (or makes use of) graphic artists who create all the images that go into a product. Such things include icons, bitmaps, window backgrounds, button images, animations, etc. Obviously, everything needed to build a piece of software should be under some form of version control. But most version control systems for developers are designed primarily for text-based information. Should the graphics people use the same version-control system and repository that the coders do? If not, what should they use, and what is the best way to keep everything synchronized? | Yes, having art assets in version control is very useful. You get the ability to track history, roll back changes, and you have a single source to do backups with. Keep in mind that art assets are MUCH larger so your server needs to have lots of disk space & network bandwidth. I've had success with using perforce on very large projects (+100 GB), however we had to wrap access to the version control server with something a little more artist friendly. I've heard some good things about Alienbrain as well, it does seem to have a very slick UI. | Version Control for Graphics Say a development team includes (or makes use of) graphic artists who create all the images that go into a product. Such things include icons, bitmaps, window backgrounds, button images, animations, etc. Obviously, everything needed to build a piece of software should be under some form of version control. But most version control systems for developers are designed primarily for text-based information. Should the graphics people use the same version-control system and repository that the coders do? If not, what should they use, and what is the best way to keep everything synchronized? | TITLE:
Version Control for Graphics
QUESTION:
Say a development team includes (or makes use of) graphic artists who create all the images that go into a product. Such things include icons, bitmaps, window backgrounds, button images, animations, etc. Obviously, everything needed to build a piece of software should be under some form of version control. But most version control systems for developers are designed primarily for text-based information. Should the graphics people use the same version-control system and repository that the coders do? If not, what should they use, and what is the best way to keep everything synchronized?
ANSWER:
Yes, having art assets in version control is very useful. You get the ability to track history, roll back changes, and you have a single source to do backups with. Keep in mind that art assets are MUCH larger so your server needs to have lots of disk space & network bandwidth. I've had success with using perforce on very large projects (+100 GB), however we had to wrap access to the version control server with something a little more artist friendly. I've heard some good things about Alienbrain as well, it does seem to have a very slick UI. | [
"version-control",
"graphics",
"versioning"
] | 53 | 18 | 38,666 | 15 | 0 | 2008-08-27T01:11:16.460000 | 2008-08-27T01:35:58.367000 |
29,311 | 72,080 | Which 3D cards support full scene antialiasing? | Is there a list of 3D cards available that provide full scene antialiasing as well as which are able to do it in hardware (decent performance)? | Pretty much all cards since DX7-level technology (GeForce 2 / Radeon 7000) can do it. Most notable exceptions are Intel cards (Intel 945 aka GMA 950 and earlier can't do it; I think Intel 965 aka GMA X3100 can't do it either). Older cards (GeForce 2 / 4MX, Radeon 7000-9250) were using supersampling (render everything into internally larger buffer, downsample at the end). All later cards have multisampling, where this expensive process is only performed at polygon edges (simply speaking, shaders are run for each pixel, while depth/coverage is stored for each sample). | Which 3D cards support full scene antialiasing? Is there a list of 3D cards available that provide full scene antialiasing as well as which are able to do it in hardware (decent performance)? | TITLE:
Which 3D cards support full scene antialiasing?
QUESTION:
Is there a list of 3D cards available that provide full scene antialiasing as well as which are able to do it in hardware (decent performance)?
ANSWER:
Pretty much all cards since DX7-level technology (GeForce 2 / Radeon 7000) can do it. Most notable exceptions are Intel cards (Intel 945 aka GMA 950 and earlier can't do it; I think Intel 965 aka GMA X3100 can't do it either). Older cards (GeForce 2 / 4MX, Radeon 7000-9250) were using supersampling (render everything into internally larger buffer, downsample at the end). All later cards have multisampling, where this expensive process is only performed at polygon edges (simply speaking, shaders are run for each pixel, while depth/coverage is stored for each sample). | [
"opengl",
"antialiasing"
] | 3 | 4 | 1,252 | 6 | 0 | 2008-08-27T01:23:29.503000 | 2008-09-16T13:19:19.477000 |
29,324 | 29,336 | How do I create a hash table in Java? | What is the most straightforward way to create a hash table (or associative array...) in Java? My google-fu has turned up a couple examples, but is there a standard way to do this? And is there a way to populate the table with a list of key->value pairs without individually calling an add method on the object for each pair? | Map map = new HashMap(); Hashtable ht = new Hashtable(); Both classes can be found from the java.util package. The difference between the 2 is explained in the following jGuru FAQ entry. | How do I create a hash table in Java? What is the most straightforward way to create a hash table (or associative array...) in Java? My google-fu has turned up a couple examples, but is there a standard way to do this? And is there a way to populate the table with a list of key->value pairs without individually calling an add method on the object for each pair? | TITLE:
How do I create a hash table in Java?
QUESTION:
What is the most straightforward way to create a hash table (or associative array...) in Java? My google-fu has turned up a couple examples, but is there a standard way to do this? And is there a way to populate the table with a list of key->value pairs without individually calling an add method on the object for each pair?
ANSWER:
Map map = new HashMap(); Hashtable ht = new Hashtable(); Both classes can be found from the java.util package. The difference between the 2 is explained in the following jGuru FAQ entry. | [
"java",
"hash",
"hashmap"
] | 14 | 28 | 80,340 | 8 | 0 | 2008-08-27T01:32:15.177000 | 2008-08-27T01:40:43.020000 |
29,370 | 29,914 | SQL1159 Initialization error with DB2 .NET Data Provider, reason code 7, tokens 9.5.0.DEF.2, SOFTWARE\IBM\DB2\InstalledCopies | I am trying to get the DB2 data provider from a 32-bit.Net application to connect to DB2 running as a 32-bit application on Vista 64 (is that confusing enough yet)? Unfortunately, I am getting the following error: SQL1159 Initialization error with DB2.NET Data Provider, reason code 7, tokens 9.5.0.DEF.2, SOFTWARE\IBM\DB2\InstalledCopies There are several IBM forum posts mentioning it, but little useful guidance. Has anyone experienced this before? Or do you have better ideas for fixing it? | Are you required to have it run as x86? I had similar issues with web apps under Visual Studio's dev web server (which is x86), but switching over to IIS (x64) worked for me. Since I was deploying to IIS x64, I called it a day at that point. I tried tracing with Filemon and Regmon, but didn't get any denied or missing keys errors. If I were to look again, I'd check HKLM\Software\WOW6432Node, guessing that the installer writes to the x64 HKLM\Software node, but not the x86 one. | SQL1159 Initialization error with DB2 .NET Data Provider, reason code 7, tokens 9.5.0.DEF.2, SOFTWARE\IBM\DB2\InstalledCopies I am trying to get the DB2 data provider from a 32-bit.Net application to connect to DB2 running as a 32-bit application on Vista 64 (is that confusing enough yet)? Unfortunately, I am getting the following error: SQL1159 Initialization error with DB2.NET Data Provider, reason code 7, tokens 9.5.0.DEF.2, SOFTWARE\IBM\DB2\InstalledCopies There are several IBM forum posts mentioning it, but little useful guidance. Has anyone experienced this before? Or do you have better ideas for fixing it? | TITLE:
SQL1159 Initialization error with DB2 .NET Data Provider, reason code 7, tokens 9.5.0.DEF.2, SOFTWARE\IBM\DB2\InstalledCopies
QUESTION:
I am trying to get the DB2 data provider from a 32-bit.Net application to connect to DB2 running as a 32-bit application on Vista 64 (is that confusing enough yet)? Unfortunately, I am getting the following error: SQL1159 Initialization error with DB2.NET Data Provider, reason code 7, tokens 9.5.0.DEF.2, SOFTWARE\IBM\DB2\InstalledCopies There are several IBM forum posts mentioning it, but little useful guidance. Has anyone experienced this before? Or do you have better ideas for fixing it?
ANSWER:
Are you required to have it run as x86? I had similar issues with web apps under Visual Studio's dev web server (which is x86), but switching over to IIS (x64) worked for me. Since I was deploying to IIS x64, I called it a day at that point. I tried tracing with Filemon and Regmon, but didn't get any denied or missing keys errors. If I were to look again, I'd check HKLM\Software\WOW6432Node, guessing that the installer writes to the x64 HKLM\Software node, but not the x86 one. | [
".net",
"db2",
"db2-luw",
"vista64"
] | 4 | 2 | 23,186 | 10 | 0 | 2008-08-27T02:20:39.913000 | 2008-08-27T11:21:12.093000 |
29,382 | 29,404 | Rails requires RubyGems >= 0.9.4. Please install RubyGems | I'm deploying to Ubuntu slice on slicehost, using Rails 2.1.0 (from gem ) If I try mongrel_rails start or script/server I get this error: Rails requires RubyGems >= 0.9.4. Please install RubyGems When I type gem -v I have version 1.2.0 installed. Any quick tips on what to look at to fix? | Just finally found this answer... I was missing a gem, and thrown off by bad error message from Rails... | Rails requires RubyGems >= 0.9.4. Please install RubyGems I'm deploying to Ubuntu slice on slicehost, using Rails 2.1.0 (from gem ) If I try mongrel_rails start or script/server I get this error: Rails requires RubyGems >= 0.9.4. Please install RubyGems When I type gem -v I have version 1.2.0 installed. Any quick tips on what to look at to fix? | TITLE:
Rails requires RubyGems >= 0.9.4. Please install RubyGems
QUESTION:
I'm deploying to Ubuntu slice on slicehost, using Rails 2.1.0 (from gem ) If I try mongrel_rails start or script/server I get this error: Rails requires RubyGems >= 0.9.4. Please install RubyGems When I type gem -v I have version 1.2.0 installed. Any quick tips on what to look at to fix?
ANSWER:
Just finally found this answer... I was missing a gem, and thrown off by bad error message from Rails... | [
"ruby-on-rails",
"deployment",
"rubygems"
] | 0 | 0 | 1,225 | 2 | 0 | 2008-08-27T02:32:15.033000 | 2008-08-27T02:47:39.380000 |
29,383 | 29,571 | Converting bool to text in C++ | Maybe this is a dumb question, but is there any way to convert a boolean value to a string such that 1 turns to "true" and 0 turns to "false"? I could just use an if statement, but it would be nice to know if there is a way to do that with the language or standard libraries. Plus, I'm a pedant.:) | How about using the C++ language itself? bool t = true; bool f = false; std::cout << std::noboolalpha << t << " == " << std::boolalpha << t << std::endl; std::cout << std::noboolalpha << f << " == " << std::boolalpha << f << std::endl; UPDATE: If you want more than 4 lines of code without any console output, please go to cppreference.com's page talking about std::boolalpha and std::noboolalpha which shows you the console output and explains more about the API. Additionally using std::boolalpha will modify the global state of std::cout, you may want to restore the original behavior go here for more info on restoring the state of std::cout. | Converting bool to text in C++ Maybe this is a dumb question, but is there any way to convert a boolean value to a string such that 1 turns to "true" and 0 turns to "false"? I could just use an if statement, but it would be nice to know if there is a way to do that with the language or standard libraries. Plus, I'm a pedant.:) | TITLE:
Converting bool to text in C++
QUESTION:
Maybe this is a dumb question, but is there any way to convert a boolean value to a string such that 1 turns to "true" and 0 turns to "false"? I could just use an if statement, but it would be nice to know if there is a way to do that with the language or standard libraries. Plus, I'm a pedant.:)
ANSWER:
How about using the C++ language itself? bool t = true; bool f = false; std::cout << std::noboolalpha << t << " == " << std::boolalpha << t << std::endl; std::cout << std::noboolalpha << f << " == " << std::boolalpha << f << std::endl; UPDATE: If you want more than 4 lines of code without any console output, please go to cppreference.com's page talking about std::boolalpha and std::noboolalpha which shows you the console output and explains more about the API. Additionally using std::boolalpha will modify the global state of std::cout, you may want to restore the original behavior go here for more info on restoring the state of std::cout. | [
"c++",
"string",
"boolean"
] | 124 | 142 | 263,159 | 17 | 0 | 2008-08-27T02:32:34.953000 | 2008-08-27T05:10:23.017000 |
29,399 | 29,471 | Is using an obfuscator enough to secure my JavaScript code? | I'm working on building a development tool that is written in JavaScript. This will not be an open source project and will be sold (hopefully) as a commercial product. I'm looking for the best way to protect my investment. Is using an obfuscator (code mangler) enough to reasonably secure the code? Are there other alternatives that I am not aware of? (I'm not sure if obfuscator is the right word, it's one of the apps that takes your code and makes it very unreadable.) | I'm going to tell you a secret. Once you understand it, you'll feel a lot better about the fact that Javascript obfuscation is only really useful for saving bandwidth when sending scripts over the wire. Your source-code is not worth stealing. I know this comes as a shock to the ego, but I can say this confidently without ever having seen a line of code you've written because outside the very few realms of development where serious magic happens, it's true of all source-code. Say, tomorrow, someone dumped a pile of DVDs on your doorstep containing the source code for Windows Vista. What would you be able to do with it? Sure, you could compile it and give away copies, but that's just one step more effort than copying the retail version. You could painstakingly find and remove the license-checking code, but that's something some bright kid has already done to the binaries. Replace the logo and graphics, pretend you wrote it yourself and market it as "Vicrosoft Mista"? You'll get caught. You could spend an enormous amount of time reading the code, trying to understand it and truly "stealing the intellectual property" that Microsoft invested in developing the product. But you'd be disappointed. You'd find the code was a long series of mundane decisions, made one after the other. Some would be smarter than you could think of. Some would leave you shaking your head wondering what kind of monkeys they're hiring over there. Most would just make you shrug and say "yeah, that's how you do that." In the process you'll learn a lot about writing operating systems, but that's not going to hurt Microsoft. Replace "Vista" with "Leopard" and the above paragraphs don't change one bit. It's not Microsoft, it's software. Half the people on this site could probably develop a Stack Overflow clone, with or without looking at the source of this site. They just haven't. The source-code of Firefox and WebKit are out there for anyone to read. Now go write your own browser from scratch. See you in a few years. Software development is an investment of time. It's utter hubris to imagine that what you're doing is so special that nobody could clone it without looking at your source, or even that it would make their job that much easier without an actionable (and easily detectable) amount of cut and paste. | Is using an obfuscator enough to secure my JavaScript code? I'm working on building a development tool that is written in JavaScript. This will not be an open source project and will be sold (hopefully) as a commercial product. I'm looking for the best way to protect my investment. Is using an obfuscator (code mangler) enough to reasonably secure the code? Are there other alternatives that I am not aware of? (I'm not sure if obfuscator is the right word, it's one of the apps that takes your code and makes it very unreadable.) | TITLE:
Is using an obfuscator enough to secure my JavaScript code?
QUESTION:
I'm working on building a development tool that is written in JavaScript. This will not be an open source project and will be sold (hopefully) as a commercial product. I'm looking for the best way to protect my investment. Is using an obfuscator (code mangler) enough to reasonably secure the code? Are there other alternatives that I am not aware of? (I'm not sure if obfuscator is the right word, it's one of the apps that takes your code and makes it very unreadable.)
ANSWER:
I'm going to tell you a secret. Once you understand it, you'll feel a lot better about the fact that Javascript obfuscation is only really useful for saving bandwidth when sending scripts over the wire. Your source-code is not worth stealing. I know this comes as a shock to the ego, but I can say this confidently without ever having seen a line of code you've written because outside the very few realms of development where serious magic happens, it's true of all source-code. Say, tomorrow, someone dumped a pile of DVDs on your doorstep containing the source code for Windows Vista. What would you be able to do with it? Sure, you could compile it and give away copies, but that's just one step more effort than copying the retail version. You could painstakingly find and remove the license-checking code, but that's something some bright kid has already done to the binaries. Replace the logo and graphics, pretend you wrote it yourself and market it as "Vicrosoft Mista"? You'll get caught. You could spend an enormous amount of time reading the code, trying to understand it and truly "stealing the intellectual property" that Microsoft invested in developing the product. But you'd be disappointed. You'd find the code was a long series of mundane decisions, made one after the other. Some would be smarter than you could think of. Some would leave you shaking your head wondering what kind of monkeys they're hiring over there. Most would just make you shrug and say "yeah, that's how you do that." In the process you'll learn a lot about writing operating systems, but that's not going to hurt Microsoft. Replace "Vista" with "Leopard" and the above paragraphs don't change one bit. It's not Microsoft, it's software. Half the people on this site could probably develop a Stack Overflow clone, with or without looking at the source of this site. They just haven't. The source-code of Firefox and WebKit are out there for anyone to read. Now go write your own browser from scratch. See you in a few years. Software development is an investment of time. It's utter hubris to imagine that what you're doing is so special that nobody could clone it without looking at your source, or even that it would make their job that much easier without an actionable (and easily detectable) amount of cut and paste. | [
"javascript",
"obfuscation"
] | 27 | 145 | 8,943 | 9 | 0 | 2008-08-27T02:44:58.107000 | 2008-08-27T03:48:07.377000 |
29,406 | 29,411 | Guidelines for writing a framework | I'm faced with writing a framework to simplify working with a large and complex object library ( ArcObjects ). What guidelines would you suggest for creating a framework of this kind? Are static methods preferred? How do you handle things like logging? How do you future proof your framework code from changes that a vendor might introduce? I think of all of the various wrappers and helpers I've seen for NHibernate, log4net, and code I've read from projects like NLog and NetTopologySuite and I see so many good approaches, but honestly I'm at a loss where to start. BTW - I'm working in C# 3.5 but it's more about recommended approach rather than language. | Brad Abrams' Framework Design Guidelines book is all about this. Might be worth a look. | Guidelines for writing a framework I'm faced with writing a framework to simplify working with a large and complex object library ( ArcObjects ). What guidelines would you suggest for creating a framework of this kind? Are static methods preferred? How do you handle things like logging? How do you future proof your framework code from changes that a vendor might introduce? I think of all of the various wrappers and helpers I've seen for NHibernate, log4net, and code I've read from projects like NLog and NetTopologySuite and I see so many good approaches, but honestly I'm at a loss where to start. BTW - I'm working in C# 3.5 but it's more about recommended approach rather than language. | TITLE:
Guidelines for writing a framework
QUESTION:
I'm faced with writing a framework to simplify working with a large and complex object library ( ArcObjects ). What guidelines would you suggest for creating a framework of this kind? Are static methods preferred? How do you handle things like logging? How do you future proof your framework code from changes that a vendor might introduce? I think of all of the various wrappers and helpers I've seen for NHibernate, log4net, and code I've read from projects like NLog and NetTopologySuite and I see so many good approaches, but honestly I'm at a loss where to start. BTW - I'm working in C# 3.5 but it's more about recommended approach rather than language.
ANSWER:
Brad Abrams' Framework Design Guidelines book is all about this. Might be worth a look. | [
"frameworks"
] | 8 | 5 | 7,520 | 4 | 0 | 2008-08-27T02:48:39.550000 | 2008-08-27T02:51:35.987000 |
29,423 | 29,449 | How automated is too automated when it comes to deployment? | I have ci, so our staging environment builds itself. Should I have a script that not only builds production but does all the branching for it as well? When you have one code base on two different urls with skinning, should they be required to build at once? | The only way to be too automated is if you are spending more time fighting with building or fixing automation scripts than you would just doing the job manually. As long as your automation scripts take less time and produce fewer errors than doing the job manually, then automation is great. Scripts to build and branch for production are a great idea! | How automated is too automated when it comes to deployment? I have ci, so our staging environment builds itself. Should I have a script that not only builds production but does all the branching for it as well? When you have one code base on two different urls with skinning, should they be required to build at once? | TITLE:
How automated is too automated when it comes to deployment?
QUESTION:
I have ci, so our staging environment builds itself. Should I have a script that not only builds production but does all the branching for it as well? When you have one code base on two different urls with skinning, should they be required to build at once?
ANSWER:
The only way to be too automated is if you are spending more time fighting with building or fixing automation scripts than you would just doing the job manually. As long as your automation scripts take less time and produce fewer errors than doing the job manually, then automation is great. Scripts to build and branch for production are a great idea! | [
"build-automation",
"production"
] | 7 | 8 | 289 | 4 | 0 | 2008-08-27T03:02:00.250000 | 2008-08-27T03:21:03.467000 |
29,426 | 3,816,214 | Best GUI designer for eclipse? | I'm looking for a good GUI designer for swing in eclipse. My preference is for a free/open-source plugin. | Window Builder Pro is a great GUI Designer for eclipse and is now offered for free by google. | Best GUI designer for eclipse? I'm looking for a good GUI designer for swing in eclipse. My preference is for a free/open-source plugin. | TITLE:
Best GUI designer for eclipse?
QUESTION:
I'm looking for a good GUI designer for swing in eclipse. My preference is for a free/open-source plugin.
ANSWER:
Window Builder Pro is a great GUI Designer for eclipse and is now offered for free by google. | [
"java",
"eclipse",
"swing",
"gui-designer"
] | 125 | 72 | 423,929 | 12 | 0 | 2008-08-27T03:06:06.760000 | 2010-09-28T19:12:29.963000 |
29,436 | 29,472 | Compact Framework - how do I dynamically create type with no default constructor? | I'm using the.NET CF 3.5. The type I want to create does not have a default constructor so I want to pass a string to an overloaded constructor. How do I do this? Code: Assembly a = Assembly.LoadFrom("my.dll"); Type t = a.GetType("type info here"); // All ok so far, assembly loads and I can get my type
string s = "Pass me to the constructor of Type t"; MyObj o = Activator.CreateInstance(t); // throws MissMethodException | MyObj o = null; Assembly a = Assembly.LoadFrom("my.dll"); Type t = a.GetType("type info here");
ConstructorInfo ctor = t.GetConstructor(new Type[] { typeof(string) }); if(ctor!= null) o = ctor.Invoke(new object[] { s }); | Compact Framework - how do I dynamically create type with no default constructor? I'm using the.NET CF 3.5. The type I want to create does not have a default constructor so I want to pass a string to an overloaded constructor. How do I do this? Code: Assembly a = Assembly.LoadFrom("my.dll"); Type t = a.GetType("type info here"); // All ok so far, assembly loads and I can get my type
string s = "Pass me to the constructor of Type t"; MyObj o = Activator.CreateInstance(t); // throws MissMethodException | TITLE:
Compact Framework - how do I dynamically create type with no default constructor?
QUESTION:
I'm using the.NET CF 3.5. The type I want to create does not have a default constructor so I want to pass a string to an overloaded constructor. How do I do this? Code: Assembly a = Assembly.LoadFrom("my.dll"); Type t = a.GetType("type info here"); // All ok so far, assembly loads and I can get my type
string s = "Pass me to the constructor of Type t"; MyObj o = Activator.CreateInstance(t); // throws MissMethodException
ANSWER:
MyObj o = null; Assembly a = Assembly.LoadFrom("my.dll"); Type t = a.GetType("type info here");
ConstructorInfo ctor = t.GetConstructor(new Type[] { typeof(string) }); if(ctor!= null) o = ctor.Invoke(new object[] { s }); | [
"c#",
"reflection",
"compact-framework"
] | 6 | 9 | 5,099 | 3 | 0 | 2008-08-27T03:12:43.267000 | 2008-08-27T03:48:10.140000 |
29,437 | 29,492 | How to shift an array of bytes by 12-bits | I want to shift the contents of an array of bytes by 12-bit to the left. For example, starting with this array of type uint8_t shift[10]: {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0xBC} I'd like to shift it to the left by 12-bits resulting in: {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xAB, 0xC0, 0x00} | Hurray for pointers! This code works by looking ahead 12 bits for each byte and copying the proper bits forward. 12 bits is the bottom half (nybble) of the next byte and the top half of 2 bytes away. unsigned char length = 10; unsigned char data[10] = {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0A,0xBC}; unsigned char *shift = data; while (shift < data+(length-2)) { *shift = (*(shift+1)&0x0F)<<4 | (*(shift+2)&0xF0)>>4; shift++; } *(data+length-2) = (*(data+length-1)&0x0F)<<4; *(data+length-1) = 0x00; Justin wrote: @Mike, your solution works, but does not carry. Well, I'd say a normal shift operation does just that (called overflow), and just lets the extra bits fall off the right or left. It's simple enough to carry if you wanted to - just save the 12 bits before you start to shift. Maybe you want a circular shift, to put the overflowed bits back at the bottom? Maybe you want to realloc the array and make it larger? Return the overflow to the caller? Return a boolean if non-zero data was overflowed? You'd have to define what carry means to you. unsigned char overflow[2]; *overflow = (*data&0xF0)>>4; *(overflow+1) = (*data&0x0F)<<4 | (*(data+1)&0xF0)>>4; while (shift < data+(length-2)) { /* normal shifting */ } /* now would be the time to copy it back if you want to carry it somewhere */ *(data+length-2) = (*(data+length-1)&0x0F)<<4 | (*(overflow)&0x0F); *(data+length-1) = *(overflow+1);
/* You could return a 16-bit carry int, * but endian-ness makes that look weird * if you care about the physical layout */ unsigned short carry = *(overflow+1)<<8 | *overflow; | How to shift an array of bytes by 12-bits I want to shift the contents of an array of bytes by 12-bit to the left. For example, starting with this array of type uint8_t shift[10]: {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0xBC} I'd like to shift it to the left by 12-bits resulting in: {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xAB, 0xC0, 0x00} | TITLE:
How to shift an array of bytes by 12-bits
QUESTION:
I want to shift the contents of an array of bytes by 12-bit to the left. For example, starting with this array of type uint8_t shift[10]: {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0xBC} I'd like to shift it to the left by 12-bits resulting in: {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xAB, 0xC0, 0x00}
ANSWER:
Hurray for pointers! This code works by looking ahead 12 bits for each byte and copying the proper bits forward. 12 bits is the bottom half (nybble) of the next byte and the top half of 2 bytes away. unsigned char length = 10; unsigned char data[10] = {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0A,0xBC}; unsigned char *shift = data; while (shift < data+(length-2)) { *shift = (*(shift+1)&0x0F)<<4 | (*(shift+2)&0xF0)>>4; shift++; } *(data+length-2) = (*(data+length-1)&0x0F)<<4; *(data+length-1) = 0x00; Justin wrote: @Mike, your solution works, but does not carry. Well, I'd say a normal shift operation does just that (called overflow), and just lets the extra bits fall off the right or left. It's simple enough to carry if you wanted to - just save the 12 bits before you start to shift. Maybe you want a circular shift, to put the overflowed bits back at the bottom? Maybe you want to realloc the array and make it larger? Return the overflow to the caller? Return a boolean if non-zero data was overflowed? You'd have to define what carry means to you. unsigned char overflow[2]; *overflow = (*data&0xF0)>>4; *(overflow+1) = (*data&0x0F)<<4 | (*(data+1)&0xF0)>>4; while (shift < data+(length-2)) { /* normal shifting */ } /* now would be the time to copy it back if you want to carry it somewhere */ *(data+length-2) = (*(data+length-1)&0x0F)<<4 | (*(overflow)&0x0F); *(data+length-1) = *(overflow+1);
/* You could return a 16-bit carry int, * but endian-ness makes that look weird * if you care about the physical layout */ unsigned short carry = *(overflow+1)<<8 | *overflow; | [
"c",
"arrays",
"bit-shift",
"bitset"
] | 16 | 9 | 22,450 | 7 | 0 | 2008-08-27T03:13:12.283000 | 2008-08-27T04:02:45.970000 |
29,460 | 29,491 | Stop the taskbar flashing | I know I can programatically make the taskbar item for a particular window start flashing when something changes, but is there any way I can stop it from flashing either programatically after a certain period of time or at least is there a keyboard shortcur I can give to my users to somehow stop the flashing? | The FlashWindowEx function which controls the flashing takes a FLASHWINFO struct which has a uCount field to control how many times it flashes. Also, a possible value for the dwFlags field is FLASHW_STOP to cause the flashing to stop. EDIT: Forgot was a C# tagged question... so P/Invoke goodness found here. | Stop the taskbar flashing I know I can programatically make the taskbar item for a particular window start flashing when something changes, but is there any way I can stop it from flashing either programatically after a certain period of time or at least is there a keyboard shortcur I can give to my users to somehow stop the flashing? | TITLE:
Stop the taskbar flashing
QUESTION:
I know I can programatically make the taskbar item for a particular window start flashing when something changes, but is there any way I can stop it from flashing either programatically after a certain period of time or at least is there a keyboard shortcur I can give to my users to somehow stop the flashing?
ANSWER:
The FlashWindowEx function which controls the flashing takes a FLASHWINFO struct which has a uCount field to control how many times it flashes. Also, a possible value for the dwFlags field is FLASHW_STOP to cause the flashing to stop. EDIT: Forgot was a C# tagged question... so P/Invoke goodness found here. | [
"c#",
"winforms",
"taskbar"
] | 5 | 5 | 6,851 | 3 | 0 | 2008-08-27T03:38:10.537000 | 2008-08-27T04:02:17.640000 |
29,461 | 29,573 | What is a MUST COVER in my Groovy presentation? | I'm working on getting an Introduction to Groovy presentation ready for my local Java User's Group and I've pretty much got it together. What I'd like to see is what you all think I just have to cover. Remember, this is an introductory presentation. Most of the people are experienced Java developers, but I'm pretty sure they have little to no Groovy knowledge. I won't poison the well by mentioning what I've already got down to cover as I want to see what the community has to offer. What are the best things I can cover (in a 1 hour time frame) that will help me effectively communicate to these Java developers how useful Groovy could be to them? p.s. I'll share my presentation here later for anyone interested. as promised now that my presentation has been presented here it is | I don't know anything about groovy so in a sense I've qualified to answer this... I would want you to: Tell me why I would want to use Scripting (in general) as opposed to Java-- what does it let me do quicker (as in development time), what does it make more readable. Give tantalising examples of ways I can use chunks of scripting in my mostly Java app. You want to make this relevant to Java devs moreso than tech-junkies. With that out of the way, why Groovy? Why not Ruby, Python or whatever (which are all runnable on the JVM). Don't show me syntax that Java can already do (if statements, loops etc) or if you do make it quick. It's as boring as hell to watch someone walk through language syntax 101 for 20min. For syntax that has a comparible feature in Java maybe show them side by side quickly. For syntax that is not in Java (closures etc) you can talk to them in a bit more detail. Remember those examples from the first point. Show me one, fully working (or at least looking like it is). At the end have question time. That is crazy important, and with that comes a burden on you to be a psuedo-guru:P. I'm not sure about how the Java6 scripting support works but I'm fairly sure it can be made secure. I remember something about defining the API the script can use before it's run. If this is the case then an example you could show would be some thick-client application (e.g. a music player) where users can write their own scripts with an API you provide them in Groovy which allows them to script their app in interesting and secure ways (e.g. creating custom columns in the playlist) | What is a MUST COVER in my Groovy presentation? I'm working on getting an Introduction to Groovy presentation ready for my local Java User's Group and I've pretty much got it together. What I'd like to see is what you all think I just have to cover. Remember, this is an introductory presentation. Most of the people are experienced Java developers, but I'm pretty sure they have little to no Groovy knowledge. I won't poison the well by mentioning what I've already got down to cover as I want to see what the community has to offer. What are the best things I can cover (in a 1 hour time frame) that will help me effectively communicate to these Java developers how useful Groovy could be to them? p.s. I'll share my presentation here later for anyone interested. as promised now that my presentation has been presented here it is | TITLE:
What is a MUST COVER in my Groovy presentation?
QUESTION:
I'm working on getting an Introduction to Groovy presentation ready for my local Java User's Group and I've pretty much got it together. What I'd like to see is what you all think I just have to cover. Remember, this is an introductory presentation. Most of the people are experienced Java developers, but I'm pretty sure they have little to no Groovy knowledge. I won't poison the well by mentioning what I've already got down to cover as I want to see what the community has to offer. What are the best things I can cover (in a 1 hour time frame) that will help me effectively communicate to these Java developers how useful Groovy could be to them? p.s. I'll share my presentation here later for anyone interested. as promised now that my presentation has been presented here it is
ANSWER:
I don't know anything about groovy so in a sense I've qualified to answer this... I would want you to: Tell me why I would want to use Scripting (in general) as opposed to Java-- what does it let me do quicker (as in development time), what does it make more readable. Give tantalising examples of ways I can use chunks of scripting in my mostly Java app. You want to make this relevant to Java devs moreso than tech-junkies. With that out of the way, why Groovy? Why not Ruby, Python or whatever (which are all runnable on the JVM). Don't show me syntax that Java can already do (if statements, loops etc) or if you do make it quick. It's as boring as hell to watch someone walk through language syntax 101 for 20min. For syntax that has a comparible feature in Java maybe show them side by side quickly. For syntax that is not in Java (closures etc) you can talk to them in a bit more detail. Remember those examples from the first point. Show me one, fully working (or at least looking like it is). At the end have question time. That is crazy important, and with that comes a burden on you to be a psuedo-guru:P. I'm not sure about how the Java6 scripting support works but I'm fairly sure it can be made secure. I remember something about defining the API the script can use before it's run. If this is the case then an example you could show would be some thick-client application (e.g. a music player) where users can write their own scripts with an API you provide them in Groovy which allows them to script their app in interesting and secure ways (e.g. creating custom columns in the playlist) | [
"java",
"groovy"
] | 11 | 8 | 1,053 | 5 | 0 | 2008-08-27T03:40:05.807000 | 2008-08-27T05:11:06.477000 |
29,466 | 29,523 | Writing a game for the Nintendo Wii | I'd like to write a game for the Nintendo Wii. How do I go about obtaining an SDK and/or any other tools necessary for writing a game? | The Wii Remote and Wii Balance Board use bluetooth. You can pair them with your PC and write your own PC apps that interact with them (like this guy ). If you want to make something that actually runs on the Wii, you can try finding some homebrew development help. If you want to actually sell your software for Wii, you need: game development experience secure office facilities $2,000 - $10,000 for dev kit (WiiWare is cheapest) The Nintendo Software Development Support Group Authorized Developer Application UPDATE: Also see the Wii U Developer Site. Nintendo now has a simple application for individual developers to makes games for the Wii U, giving you access to the SDK and dev-kits. | Writing a game for the Nintendo Wii I'd like to write a game for the Nintendo Wii. How do I go about obtaining an SDK and/or any other tools necessary for writing a game? | TITLE:
Writing a game for the Nintendo Wii
QUESTION:
I'd like to write a game for the Nintendo Wii. How do I go about obtaining an SDK and/or any other tools necessary for writing a game?
ANSWER:
The Wii Remote and Wii Balance Board use bluetooth. You can pair them with your PC and write your own PC apps that interact with them (like this guy ). If you want to make something that actually runs on the Wii, you can try finding some homebrew development help. If you want to actually sell your software for Wii, you need: game development experience secure office facilities $2,000 - $10,000 for dev kit (WiiWare is cheapest) The Nintendo Software Development Support Group Authorized Developer Application UPDATE: Also see the Wii U Developer Site. Nintendo now has a simple application for individual developers to makes games for the Wii U, giving you access to the SDK and dev-kits. | [
"wii"
] | 23 | 25 | 15,083 | 7 | 0 | 2008-08-27T03:43:11.743000 | 2008-08-27T04:35:02.540000 |
29,482 | 29,485 | How do I cast int to enum in C#? | How do I cast an int to an enum in C#? | From an int: YourEnum foo = (YourEnum)yourInt; From a string: YourEnum foo = (YourEnum) Enum.Parse(typeof(YourEnum), yourString);
// The foo.ToString().Contains(",") check is necessary for // enumerations marked with a [Flags] attribute. if (!Enum.IsDefined(typeof(YourEnum), foo) &&!foo.ToString().Contains(",")) { throw new InvalidOperationException( $"{yourString} is not an underlying value of the YourEnum enumeration." ); } From a number: YourEnum foo = (YourEnum)Enum.ToObject(typeof(YourEnum), yourInt); | How do I cast int to enum in C#? How do I cast an int to an enum in C#? | TITLE:
How do I cast int to enum in C#?
QUESTION:
How do I cast an int to an enum in C#?
ANSWER:
From an int: YourEnum foo = (YourEnum)yourInt; From a string: YourEnum foo = (YourEnum) Enum.Parse(typeof(YourEnum), yourString);
// The foo.ToString().Contains(",") check is necessary for // enumerations marked with a [Flags] attribute. if (!Enum.IsDefined(typeof(YourEnum), foo) &&!foo.ToString().Contains(",")) { throw new InvalidOperationException( $"{yourString} is not an underlying value of the YourEnum enumeration." ); } From a number: YourEnum foo = (YourEnum)Enum.ToObject(typeof(YourEnum), yourInt); | [
"c#",
"enums",
"casting",
"integer"
] | 3,897 | 4,662 | 2,044,744 | 32 | 0 | 2008-08-27T03:58:21.253000 | 2008-08-27T03:59:42.483000 |
29,496 | 29,609 | Automated script to zip IIS logs? | I'd like to write a script/batch that will bunch up my daily IIS logs and zip them up by month. ex080801.log which is in the format of ex yymmdd.log ex080801.log - ex080831.log gets zipped up and the log files deleted. The reason we do this is because on a heavy site a log file for one day could be 500mb to 1gb so we zip them up which compresses them by 98% and dump the real log file. We use webtrend to analyze the log files and it is capable of reading into a zip file. Does anyone have any ideas on how to script this or would be willing to share some code? | You'll need a command line tool to zip up the files. I recommend 7-Zip which is free and easy to use. The self-contained command line version (7za.exe) is the most portable choice. Here's a two-line batch file that would zip the log files and delete them afterwards: 7za.exe a -tzip ex%1-logs.zip %2\ex%1*.log del %2\ex%1*.log The first parameter is the 4 digit year-and-month, and the second parameter is the path to the directory containing your logs. For example: ziplogs.bat 0808 c:\logs It's possible to get more elaborate (i.e. searching the filenames to determine which months to archive). You might want to check out the Windows FINDSTR command for searching input text with regular expressions. | Automated script to zip IIS logs? I'd like to write a script/batch that will bunch up my daily IIS logs and zip them up by month. ex080801.log which is in the format of ex yymmdd.log ex080801.log - ex080831.log gets zipped up and the log files deleted. The reason we do this is because on a heavy site a log file for one day could be 500mb to 1gb so we zip them up which compresses them by 98% and dump the real log file. We use webtrend to analyze the log files and it is capable of reading into a zip file. Does anyone have any ideas on how to script this or would be willing to share some code? | TITLE:
Automated script to zip IIS logs?
QUESTION:
I'd like to write a script/batch that will bunch up my daily IIS logs and zip them up by month. ex080801.log which is in the format of ex yymmdd.log ex080801.log - ex080831.log gets zipped up and the log files deleted. The reason we do this is because on a heavy site a log file for one day could be 500mb to 1gb so we zip them up which compresses them by 98% and dump the real log file. We use webtrend to analyze the log files and it is capable of reading into a zip file. Does anyone have any ideas on how to script this or would be willing to share some code?
ANSWER:
You'll need a command line tool to zip up the files. I recommend 7-Zip which is free and easy to use. The self-contained command line version (7za.exe) is the most portable choice. Here's a two-line batch file that would zip the log files and delete them afterwards: 7za.exe a -tzip ex%1-logs.zip %2\ex%1*.log del %2\ex%1*.log The first parameter is the 4 digit year-and-month, and the second parameter is the path to the directory containing your logs. For example: ziplogs.bat 0808 c:\logs It's possible to get more elaborate (i.e. searching the filenames to determine which months to archive). You might want to check out the Windows FINDSTR command for searching input text with regular expressions. | [
"iis",
"batch-file",
"zip",
"scripting",
"logging"
] | 15 | 12 | 29,791 | 7 | 0 | 2008-08-27T04:08:39.980000 | 2008-08-27T06:00:40.507000 |
29,499 | 29,515 | How do you troubleshoot character encoding problems? | If all you see is the ugly no-char boxes, what tools or strategies do you use to figure out what went wrong? (The specific scenario I'm facing is no-char boxes within a when it should be showing Japanese chars.) | Firstly, "ugly no-char boxes" might not be an encoding problem, they might just be a sign you don't have a font installed that can display the glyphs in the page. Most character encoding problems happen when strings are being passed from one system to another. For webapps, this is usually between the browser and the application, between the application and the filesystem and between the application and the database. So you need to check where the mis-encoded data is coming from, what character encoding it has at the source, and what encoding it is being received as. The best way is to send through characters you know the system is having problems with, and examine them at each level of the app. What do they look like inside the app? In the database? When you get them back from the database? When they're displayed in the browser? Sorry to be so general, but the question doesn't give much more to work with. | How do you troubleshoot character encoding problems? If all you see is the ugly no-char boxes, what tools or strategies do you use to figure out what went wrong? (The specific scenario I'm facing is no-char boxes within a when it should be showing Japanese chars.) | TITLE:
How do you troubleshoot character encoding problems?
QUESTION:
If all you see is the ugly no-char boxes, what tools or strategies do you use to figure out what went wrong? (The specific scenario I'm facing is no-char boxes within a when it should be showing Japanese chars.)
ANSWER:
Firstly, "ugly no-char boxes" might not be an encoding problem, they might just be a sign you don't have a font installed that can display the glyphs in the page. Most character encoding problems happen when strings are being passed from one system to another. For webapps, this is usually between the browser and the application, between the application and the filesystem and between the application and the database. So you need to check where the mis-encoded data is coming from, what character encoding it has at the source, and what encoding it is being received as. The best way is to send through characters you know the system is having problems with, and examine them at each level of the app. What do they look like inside the app? In the database? When you get them back from the database? When they're displayed in the browser? Sorry to be so general, but the question doesn't give much more to work with. | [
"encoding",
"localization"
] | 1 | 3 | 3,753 | 3 | 0 | 2008-08-27T04:11:18.820000 | 2008-08-27T04:26:58.737000 |
29,505 | 29,524 | Deserialize in a different language | The log4j network adapter sends events as a serialised java object. I would like to be able to capture this object and deserialise it in a different language (python). Is this possible? NOTE The network capturing is easy; its just a TCP socket and reading in a stream. The difficulty is the deserialising part | Generally, no. The stream format for Java serialization is defined in this document, but you need access to the original class definitions (and a Java runtime to load them into) to turn the stream data back into something approaching the original objects. For example, classes may define writeObject() and readObject() methods to customise their own serialized form. ( edit: lubos hasko suggests having a little java program to deserialize the objects in front of Python, but the problem is that for this to work, your "little java program" needs to load the same versions of all the same classes that it might deserialize. Which is tricky if you're receiving log messages from one app, and really tricky if you're multiplexing more than one log stream. Either way, it's not going to be a little program any more. edit2: I could be wrong here, I don't know what gets serialized. If it's just log4j classes you should be fine. On the other hand, it's possible to log arbitrary exceptions, and if they get put in the stream as well my point stands.) It would be much easier to customise the log4j network adapter and replace the raw serialization with some more easily-deserialized form (for example you could use XStream to turn the object into an XML representation) | Deserialize in a different language The log4j network adapter sends events as a serialised java object. I would like to be able to capture this object and deserialise it in a different language (python). Is this possible? NOTE The network capturing is easy; its just a TCP socket and reading in a stream. The difficulty is the deserialising part | TITLE:
Deserialize in a different language
QUESTION:
The log4j network adapter sends events as a serialised java object. I would like to be able to capture this object and deserialise it in a different language (python). Is this possible? NOTE The network capturing is easy; its just a TCP socket and reading in a stream. The difficulty is the deserialising part
ANSWER:
Generally, no. The stream format for Java serialization is defined in this document, but you need access to the original class definitions (and a Java runtime to load them into) to turn the stream data back into something approaching the original objects. For example, classes may define writeObject() and readObject() methods to customise their own serialized form. ( edit: lubos hasko suggests having a little java program to deserialize the objects in front of Python, but the problem is that for this to work, your "little java program" needs to load the same versions of all the same classes that it might deserialize. Which is tricky if you're receiving log messages from one app, and really tricky if you're multiplexing more than one log stream. Either way, it's not going to be a little program any more. edit2: I could be wrong here, I don't know what gets serialized. If it's just log4j classes you should be fine. On the other hand, it's possible to log arbitrary exceptions, and if they get put in the stream as well my point stands.) It would be much easier to customise the log4j network adapter and replace the raw serialization with some more easily-deserialized form (for example you could use XStream to turn the object into an XML representation) | [
"java",
"serialization",
"log4j"
] | 6 | 5 | 5,289 | 6 | 0 | 2008-08-27T04:18:10.347000 | 2008-08-27T04:35:57.700000 |
29,511 | 29,521 | Ruby - Convert Integer to String | In Ruby, trying to print out the individual elements of a String is giving me trouble. Instead of seeing each character, I'm seeing their ASCII values instead: >> a = "0123" => "0123" >> a[0] => 48 I've looked online but can't find any way to get the original "0" back out of it. I'm a little new to Ruby to I know it has to be something simple but I just can't seem to find it. | Or you can convert the integer to its character value: a[0].chr | Ruby - Convert Integer to String In Ruby, trying to print out the individual elements of a String is giving me trouble. Instead of seeing each character, I'm seeing their ASCII values instead: >> a = "0123" => "0123" >> a[0] => 48 I've looked online but can't find any way to get the original "0" back out of it. I'm a little new to Ruby to I know it has to be something simple but I just can't seem to find it. | TITLE:
Ruby - Convert Integer to String
QUESTION:
In Ruby, trying to print out the individual elements of a String is giving me trouble. Instead of seeing each character, I'm seeing their ASCII values instead: >> a = "0123" => "0123" >> a[0] => 48 I've looked online but can't find any way to get the original "0" back out of it. I'm a little new to Ruby to I know it has to be something simple but I just can't seem to find it.
ANSWER:
Or you can convert the integer to its character value: a[0].chr | [
"ruby",
"arrays"
] | 17 | 15 | 12,234 | 7 | 0 | 2008-08-27T04:19:42.047000 | 2008-08-27T04:34:03.493000 |
29,525 | 29,570 | Opcode cache impact on memory usage | Can anyone tell me what is the memory usage overhead associated with PHP opcode cache? I've seen a lot of reviews of opcode cache but all of them only concentrate on the performance increase. I have a small entry level VPS and memory limits are a concern for me. | Most of the memory overhead will come from the opcode cache size. Each opcode cacher has their own default(e.g. 30MB for APC) which you can change through the config file. Other than the cache size, the actual memory overhead of the cacher itself is negligible. | Opcode cache impact on memory usage Can anyone tell me what is the memory usage overhead associated with PHP opcode cache? I've seen a lot of reviews of opcode cache but all of them only concentrate on the performance increase. I have a small entry level VPS and memory limits are a concern for me. | TITLE:
Opcode cache impact on memory usage
QUESTION:
Can anyone tell me what is the memory usage overhead associated with PHP opcode cache? I've seen a lot of reviews of opcode cache but all of them only concentrate on the performance increase. I have a small entry level VPS and memory limits are a concern for me.
ANSWER:
Most of the memory overhead will come from the opcode cache size. Each opcode cacher has their own default(e.g. 30MB for APC) which you can change through the config file. Other than the cache size, the actual memory overhead of the cacher itself is negligible. | [
"php",
"opcode-cache"
] | 1 | 5 | 723 | 3 | 0 | 2008-08-27T04:36:49.757000 | 2008-08-27T05:09:39.740000 |
29,531 | 29,534 | Using .NET CodeDOM to declare and initialize a field in one statement | I want to use CodeDOM to both declare and initialize my static field in one statement. How can I do this? // for example public static int MyField = 5; I can seem to figure out how to declare a static field, and I can set its value later, but I can't seem to get the above effect. @lomaxx, Naw, I just want static. I don't want const. This value can change. I just wanted the simplicity of declaring and init'ing in one fell swoop. As if anything in the codedom world is simple. Every type name is 20+ characters long and you end up building these huge expression trees. Makes my eyes bug out. I'm only alive today thanks to resharper's reformatting. | Once you create your CodeMemberField instance to represent the static field, you can assign the InitExpression property to the expression you want to use to populate the field. | Using .NET CodeDOM to declare and initialize a field in one statement I want to use CodeDOM to both declare and initialize my static field in one statement. How can I do this? // for example public static int MyField = 5; I can seem to figure out how to declare a static field, and I can set its value later, but I can't seem to get the above effect. @lomaxx, Naw, I just want static. I don't want const. This value can change. I just wanted the simplicity of declaring and init'ing in one fell swoop. As if anything in the codedom world is simple. Every type name is 20+ characters long and you end up building these huge expression trees. Makes my eyes bug out. I'm only alive today thanks to resharper's reformatting. | TITLE:
Using .NET CodeDOM to declare and initialize a field in one statement
QUESTION:
I want to use CodeDOM to both declare and initialize my static field in one statement. How can I do this? // for example public static int MyField = 5; I can seem to figure out how to declare a static field, and I can set its value later, but I can't seem to get the above effect. @lomaxx, Naw, I just want static. I don't want const. This value can change. I just wanted the simplicity of declaring and init'ing in one fell swoop. As if anything in the codedom world is simple. Every type name is 20+ characters long and you end up building these huge expression trees. Makes my eyes bug out. I'm only alive today thanks to resharper's reformatting.
ANSWER:
Once you create your CodeMemberField instance to represent the static field, you can assign the InitExpression property to the expression you want to use to populate the field. | [
".net",
"codedom"
] | 4 | 8 | 2,785 | 3 | 0 | 2008-08-27T04:43:00.537000 | 2008-08-27T04:45:27.617000 |
29,539 | 86,325 | How to create an exit message | Is there a one line function call that quits the program and displays a message? I know in Perl it's as simple as: die("Message goes here") I'm tired of typing this: puts "Message goes here" exit | The abort function does this. For example: abort("Message goes here") Note: the abort message will be written to STDERR as opposed to puts which will write to STDOUT. | How to create an exit message Is there a one line function call that quits the program and displays a message? I know in Perl it's as simple as: die("Message goes here") I'm tired of typing this: puts "Message goes here" exit | TITLE:
How to create an exit message
QUESTION:
Is there a one line function call that quits the program and displays a message? I know in Perl it's as simple as: die("Message goes here") I'm tired of typing this: puts "Message goes here" exit
ANSWER:
The abort function does this. For example: abort("Message goes here") Note: the abort message will be written to STDERR as opposed to puts which will write to STDOUT. | [
"ruby",
"error-handling",
"exit"
] | 214 | 371 | 106,897 | 3 | 0 | 2008-08-27T04:48:50.417000 | 2008-09-17T18:50:05.210000 |
29,557 | 30,700 | How to Ease TDD with MSTest / VS2008 | I've read time and time again that TDD/test first is more difficult with MSTest than it is with other testing frameworks such as nUnit, MBUnit, etc... What are some suggested manual workarounds and/or 3rd party bits that you suggest when MSTest is the only option due to infrastructure policy? I'm mainly wondering about VS 2008 Team Suite, but I suppose tips for VS 2008 Pro on up would be suitable too since some MSTest functionality is now included with those versions as well. | MSTest is certainly not as efficient or extensible as some of the open source frameworks, but it is workable. Since the question asks about making life easier with MSTest and not about alternatives, here are my MSTest tips. Shortcuts. Like Haacked said, take a few seconds to learn the shortcuts. Current Context. Since MSTest is so slow, run tests only in the current context when you can. ( CTRL + R, CTRL + T ). If your cursor is in a test method, this will only run the method. If your cursor is outside a method, but in a test class, this will only run the test. And with namespace, etc etc Efficient tests and organization. It's dog slow. Make things as best as you can by writing efficient tests. Move slow tests to other test classes or projects so you can run the fast tests more frequently. Testing with WCF. If you're testing services, be sure to DEBUG tests rather than RUN tests so Visual Studio can fire up the ASP.NET development web servers. After these are up, then you can go back to RUN, but it can be easier to just always DEBUG so you don't have to think about it. Config Files. Edit your test-run configuration to move.config files into the test execution folder. Integration with Source Safe. You need to be aware that MSTest hates SourceSafe and the feeling is mutual. Because MSTest wants to put test files under source control, and add them to the solution, it must check out the solution every time you run tests. So SourceSafe must be running in multi-check-out mode to avoid killing your fellow developers. Ignore the fluff With MSTest, you get a dozen different windows and views. Test Runs, Test View, Test Lists... they're all less-than-helpful. Stick with Test Results and you'll be much happier. Stick with "Unit Tests". When you add a new test, you can add an ordered test, a unit test, or run through a wizard. Stick with just plain simple unit tests. | How to Ease TDD with MSTest / VS2008 I've read time and time again that TDD/test first is more difficult with MSTest than it is with other testing frameworks such as nUnit, MBUnit, etc... What are some suggested manual workarounds and/or 3rd party bits that you suggest when MSTest is the only option due to infrastructure policy? I'm mainly wondering about VS 2008 Team Suite, but I suppose tips for VS 2008 Pro on up would be suitable too since some MSTest functionality is now included with those versions as well. | TITLE:
How to Ease TDD with MSTest / VS2008
QUESTION:
I've read time and time again that TDD/test first is more difficult with MSTest than it is with other testing frameworks such as nUnit, MBUnit, etc... What are some suggested manual workarounds and/or 3rd party bits that you suggest when MSTest is the only option due to infrastructure policy? I'm mainly wondering about VS 2008 Team Suite, but I suppose tips for VS 2008 Pro on up would be suitable too since some MSTest functionality is now included with those versions as well.
ANSWER:
MSTest is certainly not as efficient or extensible as some of the open source frameworks, but it is workable. Since the question asks about making life easier with MSTest and not about alternatives, here are my MSTest tips. Shortcuts. Like Haacked said, take a few seconds to learn the shortcuts. Current Context. Since MSTest is so slow, run tests only in the current context when you can. ( CTRL + R, CTRL + T ). If your cursor is in a test method, this will only run the method. If your cursor is outside a method, but in a test class, this will only run the test. And with namespace, etc etc Efficient tests and organization. It's dog slow. Make things as best as you can by writing efficient tests. Move slow tests to other test classes or projects so you can run the fast tests more frequently. Testing with WCF. If you're testing services, be sure to DEBUG tests rather than RUN tests so Visual Studio can fire up the ASP.NET development web servers. After these are up, then you can go back to RUN, but it can be easier to just always DEBUG so you don't have to think about it. Config Files. Edit your test-run configuration to move.config files into the test execution folder. Integration with Source Safe. You need to be aware that MSTest hates SourceSafe and the feeling is mutual. Because MSTest wants to put test files under source control, and add them to the solution, it must check out the solution every time you run tests. So SourceSafe must be running in multi-check-out mode to avoid killing your fellow developers. Ignore the fluff With MSTest, you get a dozen different windows and views. Test Runs, Test View, Test Lists... they're all less-than-helpful. Stick with Test Results and you'll be much happier. Stick with "Unit Tests". When you add a new test, you can add an ordered test, a unit test, or run through a wizard. Stick with just plain simple unit tests. | [
"visual-studio-2008",
"tdd",
"mstest"
] | 19 | 29 | 4,266 | 10 | 0 | 2008-08-27T05:01:30.087000 | 2008-08-27T17:40:52.447000 |
29,558 | 29,574 | Split data access class into reader and writer or combine them? | This might be on the "discussy" side, but I would really like to hear your view on this. Previously I have often written data access classes that handled both reading and writing, which often led to poor naming, like FooIoHandler etc. The rule of thumb that classes that are hard to name probably are poorly designed suggests that this is not a good solution. So, I have recently started splitting the data access into FooWriter and FooReader, which leads to nicer names and gives some additional flexibility, but at the same time I kind of like keeping it together, if the classes are not to big. Is a reader/writer separation a better design, or should I combine them? If I should combine them, what the heck should I name the class? Thanks /Erik | ORM might be your best solution. Or use a repository type pattern, with a "thingContext" object that is responsible for state persistence. Personally, I use the activeRecord pattern, where save logic is baked into a base class, but I'm leaving it in favor of an nHibernate style repository pattern. The allowance for DDD and testing things without a db is very nice to have in a framework type situation, where my business logic is now gaining traction for a new UI. | Split data access class into reader and writer or combine them? This might be on the "discussy" side, but I would really like to hear your view on this. Previously I have often written data access classes that handled both reading and writing, which often led to poor naming, like FooIoHandler etc. The rule of thumb that classes that are hard to name probably are poorly designed suggests that this is not a good solution. So, I have recently started splitting the data access into FooWriter and FooReader, which leads to nicer names and gives some additional flexibility, but at the same time I kind of like keeping it together, if the classes are not to big. Is a reader/writer separation a better design, or should I combine them? If I should combine them, what the heck should I name the class? Thanks /Erik | TITLE:
Split data access class into reader and writer or combine them?
QUESTION:
This might be on the "discussy" side, but I would really like to hear your view on this. Previously I have often written data access classes that handled both reading and writing, which often led to poor naming, like FooIoHandler etc. The rule of thumb that classes that are hard to name probably are poorly designed suggests that this is not a good solution. So, I have recently started splitting the data access into FooWriter and FooReader, which leads to nicer names and gives some additional flexibility, but at the same time I kind of like keeping it together, if the classes are not to big. Is a reader/writer separation a better design, or should I combine them? If I should combine them, what the heck should I name the class? Thanks /Erik
ANSWER:
ORM might be your best solution. Or use a repository type pattern, with a "thingContext" object that is responsible for state persistence. Personally, I use the activeRecord pattern, where save logic is baked into a base class, but I'm leaving it in favor of an nHibernate style repository pattern. The allowance for DDD and testing things without a db is very nice to have in a framework type situation, where my business logic is now gaining traction for a new UI. | [
"architecture",
"oop",
"data-access"
] | 5 | 3 | 1,722 | 5 | 0 | 2008-08-27T05:02:33.847000 | 2008-08-27T05:12:08.580000 |
29,562 | 29,575 | How to use Python distutils? | I wrote a quick program in python to add a gtk GUI to a cli program. I was wondering how I can create an installer using distutils. Since it's just a GUI frontend for a command line app it only works in *nix anyway so I'm not worried about it being cross platform. my main goal is to create a.deb package for debian/ubuntu users, but I don't understand make/configure files. I've primarily been a web developer up until now. edit: Does anyone know of a project that uses distutils so I could see it in action and, you know, actually try building it? Here are a few useful links Ubuntu Python Packaging Guide This Guide is very helpful. I don't know how I missed it during my initial wave of gooling. It even walks you through packaging up an existing python application The Ubuntu MOTU Project This is the official package maintaining project at ubuntu. Anyone can join, and there are lots of tutorials and info about creating packages, of all types, which include the above 'python packaging guide'. "Python distutils to deb?" - Ars Technica Forum discussion According to this conversation, you can't just use distutils. It doesn't follow the debian packaging format (or something like that). I guess that's why you need dh_make as seen in the Ubuntu Packaging guide "A bdist_deb command for distutils This one has some interesting discussion (it's also how I found the ubuntu guide) about concatenating a zip-file and a shell script to create some kind of universal executable (anything with python and bash that is). weird. Let me know if anyone finds more info on this practice because I've never heard of it. Description of the deb format and how distutils fit in - python mailing list | See the distutils simple example. That's basically what it is like, except real install scripts usually contain a bit more information. I have not seen any that are fundamentally more complicated, though. In essence, you just give it a list of what needs to be installed. Sometimes you need to give it some mapping dicts since the source and installed trees might not be the same. Here is a real-life (anonymized) example: #!/usr/bin/python
from distutils.core import setup
setup (name = 'Initech Package 3', description = "Services and libraries ABC, DEF", author = "That Guy, Initech Ltd", author_email = "that.guy@initech.com", version = '1.0.5', package_dir = {'Package3': 'site-packages/Package3'}, packages = ['Package3', 'Package3.Queries'], data_files = [ ('/etc/Package3', ['etc/Package3/ExternalResources.conf']) ]) | How to use Python distutils? I wrote a quick program in python to add a gtk GUI to a cli program. I was wondering how I can create an installer using distutils. Since it's just a GUI frontend for a command line app it only works in *nix anyway so I'm not worried about it being cross platform. my main goal is to create a.deb package for debian/ubuntu users, but I don't understand make/configure files. I've primarily been a web developer up until now. edit: Does anyone know of a project that uses distutils so I could see it in action and, you know, actually try building it? Here are a few useful links Ubuntu Python Packaging Guide This Guide is very helpful. I don't know how I missed it during my initial wave of gooling. It even walks you through packaging up an existing python application The Ubuntu MOTU Project This is the official package maintaining project at ubuntu. Anyone can join, and there are lots of tutorials and info about creating packages, of all types, which include the above 'python packaging guide'. "Python distutils to deb?" - Ars Technica Forum discussion According to this conversation, you can't just use distutils. It doesn't follow the debian packaging format (or something like that). I guess that's why you need dh_make as seen in the Ubuntu Packaging guide "A bdist_deb command for distutils This one has some interesting discussion (it's also how I found the ubuntu guide) about concatenating a zip-file and a shell script to create some kind of universal executable (anything with python and bash that is). weird. Let me know if anyone finds more info on this practice because I've never heard of it. Description of the deb format and how distutils fit in - python mailing list | TITLE:
How to use Python distutils?
QUESTION:
I wrote a quick program in python to add a gtk GUI to a cli program. I was wondering how I can create an installer using distutils. Since it's just a GUI frontend for a command line app it only works in *nix anyway so I'm not worried about it being cross platform. my main goal is to create a.deb package for debian/ubuntu users, but I don't understand make/configure files. I've primarily been a web developer up until now. edit: Does anyone know of a project that uses distutils so I could see it in action and, you know, actually try building it? Here are a few useful links Ubuntu Python Packaging Guide This Guide is very helpful. I don't know how I missed it during my initial wave of gooling. It even walks you through packaging up an existing python application The Ubuntu MOTU Project This is the official package maintaining project at ubuntu. Anyone can join, and there are lots of tutorials and info about creating packages, of all types, which include the above 'python packaging guide'. "Python distutils to deb?" - Ars Technica Forum discussion According to this conversation, you can't just use distutils. It doesn't follow the debian packaging format (or something like that). I guess that's why you need dh_make as seen in the Ubuntu Packaging guide "A bdist_deb command for distutils This one has some interesting discussion (it's also how I found the ubuntu guide) about concatenating a zip-file and a shell script to create some kind of universal executable (anything with python and bash that is). weird. Let me know if anyone finds more info on this practice because I've never heard of it. Description of the deb format and how distutils fit in - python mailing list
ANSWER:
See the distutils simple example. That's basically what it is like, except real install scripts usually contain a bit more information. I have not seen any that are fundamentally more complicated, though. In essence, you just give it a list of what needs to be installed. Sometimes you need to give it some mapping dicts since the source and installed trees might not be the same. Here is a real-life (anonymized) example: #!/usr/bin/python
from distutils.core import setup
setup (name = 'Initech Package 3', description = "Services and libraries ABC, DEF", author = "That Guy, Initech Ltd", author_email = "that.guy@initech.com", version = '1.0.5', package_dir = {'Package3': 'site-packages/Package3'}, packages = ['Package3', 'Package3.Queries'], data_files = [ ('/etc/Package3', ['etc/Package3/ExternalResources.conf']) ]) | [
"python",
"linux",
"installation",
"debian",
"distutils"
] | 25 | 14 | 11,254 | 5 | 0 | 2008-08-27T05:03:07.993000 | 2008-08-27T05:12:47.643000 |
29,580 | 29,588 | Why is pagination so resource-expensive? | It's one of those things that seems to have an odd curve where the more I think about it, the more it makes sense. To a certain extent, of course. And then it doesn't make sense to me at all. Care to enlighten me? | Because in most cases you've got to sort your results first. For example, when you search on Google, you can view only up to 100 pages of results. They don't bother sorting by page-rank beyond 1000 websites for given keyword (or combination of keywords). Pagination is fast. Sorting is slow. | Why is pagination so resource-expensive? It's one of those things that seems to have an odd curve where the more I think about it, the more it makes sense. To a certain extent, of course. And then it doesn't make sense to me at all. Care to enlighten me? | TITLE:
Why is pagination so resource-expensive?
QUESTION:
It's one of those things that seems to have an odd curve where the more I think about it, the more it makes sense. To a certain extent, of course. And then it doesn't make sense to me at all. Care to enlighten me?
ANSWER:
Because in most cases you've got to sort your results first. For example, when you search on Google, you can view only up to 100 pages of results. They don't bother sorting by page-rank beyond 1000 websites for given keyword (or combination of keywords). Pagination is fast. Sorting is slow. | [
"performance",
"pagination"
] | 7 | 19 | 1,716 | 6 | 0 | 2008-08-27T05:21:23.003000 | 2008-08-27T05:26:17.237000 |
29,593 | 29,629 | What does ServerVariables["APPL_MD_PATH"] retrieves the metabase path for the Application for the ISAPI DLL mean? | I've trying to get an ASP.net (v2) app to work in the debugger and keep running into a problem because the value returned by the following code is an empty string: HttpContext.Current.Request.ServerVariables["APPL_MD_PATH"].ToLower() I have found out that this "Retrieves the metabase path for the Application for the ISAPI DLL". Can anybody shed some light on what this means and why it might be empty? This code works in our live environment, but I want it to work on my PC and be able to step through source code so I can look at another problem... | Are you running your application locally inside of IIS or inside of the development web server? If it's the latter, then that's probably why: Cassini (the development web server) doesn't do ISAPI, so this value will be empty. | What does ServerVariables["APPL_MD_PATH"] retrieves the metabase path for the Application for the ISAPI DLL mean? I've trying to get an ASP.net (v2) app to work in the debugger and keep running into a problem because the value returned by the following code is an empty string: HttpContext.Current.Request.ServerVariables["APPL_MD_PATH"].ToLower() I have found out that this "Retrieves the metabase path for the Application for the ISAPI DLL". Can anybody shed some light on what this means and why it might be empty? This code works in our live environment, but I want it to work on my PC and be able to step through source code so I can look at another problem... | TITLE:
What does ServerVariables["APPL_MD_PATH"] retrieves the metabase path for the Application for the ISAPI DLL mean?
QUESTION:
I've trying to get an ASP.net (v2) app to work in the debugger and keep running into a problem because the value returned by the following code is an empty string: HttpContext.Current.Request.ServerVariables["APPL_MD_PATH"].ToLower() I have found out that this "Retrieves the metabase path for the Application for the ISAPI DLL". Can anybody shed some light on what this means and why it might be empty? This code works in our live environment, but I want it to work on my PC and be able to step through source code so I can look at another problem...
ANSWER:
Are you running your application locally inside of IIS or inside of the development web server? If it's the latter, then that's probably why: Cassini (the development web server) doesn't do ISAPI, so this value will be empty. | [
".net",
"asp.net",
"visual-studio",
".net-2.0",
"debugging"
] | 0 | 3 | 3,452 | 1 | 0 | 2008-08-27T05:35:58.977000 | 2008-08-27T06:38:29.717000 |
29,621 | 29,623 | Change priority of the current process in C | On Windows I can do: HANDLE hCurrentProcess = GetCurrentProcess();
SetPriorityClass(hCurrentProcess, ABOVE_NORMAL_PRIORITY_CLASS); How can I do the same thing on *nix? | Try: #include #include int main(){ setpriority(PRIO_PROCESS, 0, -20); } Note that you must be running as superuser for this to work. (for more info, type 'man setpriority' at a prompt.) | Change priority of the current process in C On Windows I can do: HANDLE hCurrentProcess = GetCurrentProcess();
SetPriorityClass(hCurrentProcess, ABOVE_NORMAL_PRIORITY_CLASS); How can I do the same thing on *nix? | TITLE:
Change priority of the current process in C
QUESTION:
On Windows I can do: HANDLE hCurrentProcess = GetCurrentProcess();
SetPriorityClass(hCurrentProcess, ABOVE_NORMAL_PRIORITY_CLASS); How can I do the same thing on *nix?
ANSWER:
Try: #include #include int main(){ setpriority(PRIO_PROCESS, 0, -20); } Note that you must be running as superuser for this to work. (for more info, type 'man setpriority' at a prompt.) | [
"c",
"unix",
"cross-platform",
"process-management"
] | 14 | 25 | 23,208 | 3 | 0 | 2008-08-27T06:17:47.533000 | 2008-08-27T06:20:54.843000 |
29,624 | 194,969 | How to Maintain Correct Javascript Event After Using cloneNode(true) | I have a form element that contains multiple lines of inputs. Think of each line as attributes of a new object that I want to create in my web application. And, I want to be able to create multiple new objects in one HTTP POST. I'm using Javascript's built-in cloneNode(true) method to clone each line. The problem is that each input-line also has a removal link attached to its onclick-event: // prototype based Remove When the cloned input-line's removal link is clicked, it also removes any input-lines that were cloned from the same dom object. Is it possible to rebind the "this" object to the proper anchor tag after using cloneNode(true) on the above DOM element? | Don't put handler on each link (this really should be a button, BTW). Use event bubbling to handle all buttons with one handler: formObject.onclick = function(e) { e=e||event; // IE sucks var target = e.target||e.srcElement; // and sucks again
// target is the element that has been clicked if (target && target.className=='remove') { target.parentNode.parentNode.removeChild(target.parentNode); return false; // stop event from bubbling elsewhere } } + Remove without JS handler! | How to Maintain Correct Javascript Event After Using cloneNode(true) I have a form element that contains multiple lines of inputs. Think of each line as attributes of a new object that I want to create in my web application. And, I want to be able to create multiple new objects in one HTTP POST. I'm using Javascript's built-in cloneNode(true) method to clone each line. The problem is that each input-line also has a removal link attached to its onclick-event: // prototype based Remove When the cloned input-line's removal link is clicked, it also removes any input-lines that were cloned from the same dom object. Is it possible to rebind the "this" object to the proper anchor tag after using cloneNode(true) on the above DOM element? | TITLE:
How to Maintain Correct Javascript Event After Using cloneNode(true)
QUESTION:
I have a form element that contains multiple lines of inputs. Think of each line as attributes of a new object that I want to create in my web application. And, I want to be able to create multiple new objects in one HTTP POST. I'm using Javascript's built-in cloneNode(true) method to clone each line. The problem is that each input-line also has a removal link attached to its onclick-event: // prototype based Remove When the cloned input-line's removal link is clicked, it also removes any input-lines that were cloned from the same dom object. Is it possible to rebind the "this" object to the proper anchor tag after using cloneNode(true) on the above DOM element?
ANSWER:
Don't put handler on each link (this really should be a button, BTW). Use event bubbling to handle all buttons with one handler: formObject.onclick = function(e) { e=e||event; // IE sucks var target = e.target||e.srcElement; // and sucks again
// target is the element that has been clicked if (target && target.className=='remove') { target.parentNode.parentNode.removeChild(target.parentNode); return false; // stop event from bubbling elsewhere } } + Remove without JS handler! | [
"javascript",
"events",
"dom",
"prototypejs",
"clonenode"
] | 5 | 7 | 8,857 | 6 | 0 | 2008-08-27T06:27:51.643000 | 2008-10-12T01:53:07.863000 |
29,630 | 29,719 | What is the best way to package and distribute an Excel application | I've writen an Excel-based, database reporting tool. Currentely, all the VBA code is associated with a single XLS file. The user generates the report by clicking a button on the toolbar. Unfortunately, unless the user has saved the file under another file name, all the reported data gets wiped-out. When I have created similar tools in Word, I can put all the code in a template (.dot) file and call it from there. If I put the template file in the Office startup folder, it will launch everytime I start Word. Is there a similar way, to package and distribute my code in Excel? I've tried using Add-ins, but I didn't find a way to call the code from the application window. | You can modify the user's personal.xls file, stored in the excel startup directory (varies between Office versions). If you have lots of users though, that can be fiddly. An alternative way to get over your problem is to store the macro in a template (.xlt) file. Then when the users opens it they can't save it back over the original file, but have to specify a new filename to save it as. The disadvantage of this method is that you then get multiple copies of your original code all over the place with each saved file. If you modify the original.xlt and someone reruns the old macro in a previously-saved.xls file then things can get out of step. | What is the best way to package and distribute an Excel application I've writen an Excel-based, database reporting tool. Currentely, all the VBA code is associated with a single XLS file. The user generates the report by clicking a button on the toolbar. Unfortunately, unless the user has saved the file under another file name, all the reported data gets wiped-out. When I have created similar tools in Word, I can put all the code in a template (.dot) file and call it from there. If I put the template file in the Office startup folder, it will launch everytime I start Word. Is there a similar way, to package and distribute my code in Excel? I've tried using Add-ins, but I didn't find a way to call the code from the application window. | TITLE:
What is the best way to package and distribute an Excel application
QUESTION:
I've writen an Excel-based, database reporting tool. Currentely, all the VBA code is associated with a single XLS file. The user generates the report by clicking a button on the toolbar. Unfortunately, unless the user has saved the file under another file name, all the reported data gets wiped-out. When I have created similar tools in Word, I can put all the code in a template (.dot) file and call it from there. If I put the template file in the Office startup folder, it will launch everytime I start Word. Is there a similar way, to package and distribute my code in Excel? I've tried using Add-ins, but I didn't find a way to call the code from the application window.
ANSWER:
You can modify the user's personal.xls file, stored in the excel startup directory (varies between Office versions). If you have lots of users though, that can be fiddly. An alternative way to get over your problem is to store the macro in a template (.xlt) file. Then when the users opens it they can't save it back over the original file, but have to specify a new filename to save it as. The disadvantage of this method is that you then get multiple copies of your original code all over the place with each saved file. If you modify the original.xlt and someone reruns the old macro in a previously-saved.xls file then things can get out of step. | [
"excel",
"vba",
"office-addins"
] | 4 | 2 | 17,118 | 5 | 0 | 2008-08-27T06:40:13.253000 | 2008-08-27T08:13:04.667000 |
29,643 | 29,652 | Which is a better approach in logging - files or DB? | Okay, here's the scenario. I have a utility that processes tons of records, and enters information to the Database accordingly. It works on these records in multi-threaded batches. Each such batch writes to the same log file for creating a workflow trace for each record. Potentially, we could be making close to a million log writes in a day. Should this log be made into a database residing on another server? Considerations: The obvious disadvantage of multiple threads writing to the same log file is that the log messages are shuffled amongst each other. In the database, they can be grouped by batch id. Performance - which would slow down the batch processing more? writing to a local file or sending log data to a database on another server on the same network. Theoretically, the log file is faster, but is there a gotcha here? Are there any optimizations that can be done on either approach? Thanks. | I second the other answers here, depends on what you are doing with the data. We have two scenarios here: The majority of the logging is to a DB since admin users for the products we build need to be able to view them in their nice little app with all the bells and whistles. We log all of our diagnostics and debug info to file. We have no need for really "prettifying" it and TBH, we don't even often need it, so we just log and archive for the most part. I would say if the user is doing anything with it, then log to DB, if its for you, then a file will probably suffice. | Which is a better approach in logging - files or DB? Okay, here's the scenario. I have a utility that processes tons of records, and enters information to the Database accordingly. It works on these records in multi-threaded batches. Each such batch writes to the same log file for creating a workflow trace for each record. Potentially, we could be making close to a million log writes in a day. Should this log be made into a database residing on another server? Considerations: The obvious disadvantage of multiple threads writing to the same log file is that the log messages are shuffled amongst each other. In the database, they can be grouped by batch id. Performance - which would slow down the batch processing more? writing to a local file or sending log data to a database on another server on the same network. Theoretically, the log file is faster, but is there a gotcha here? Are there any optimizations that can be done on either approach? Thanks. | TITLE:
Which is a better approach in logging - files or DB?
QUESTION:
Okay, here's the scenario. I have a utility that processes tons of records, and enters information to the Database accordingly. It works on these records in multi-threaded batches. Each such batch writes to the same log file for creating a workflow trace for each record. Potentially, we could be making close to a million log writes in a day. Should this log be made into a database residing on another server? Considerations: The obvious disadvantage of multiple threads writing to the same log file is that the log messages are shuffled amongst each other. In the database, they can be grouped by batch id. Performance - which would slow down the batch processing more? writing to a local file or sending log data to a database on another server on the same network. Theoretically, the log file is faster, but is there a gotcha here? Are there any optimizations that can be done on either approach? Thanks.
ANSWER:
I second the other answers here, depends on what you are doing with the data. We have two scenarios here: The majority of the logging is to a DB since admin users for the products we build need to be able to view them in their nice little app with all the bells and whistles. We log all of our diagnostics and debug info to file. We have no need for really "prettifying" it and TBH, we don't even often need it, so we just log and archive for the most part. I would say if the user is doing anything with it, then log to DB, if its for you, then a file will probably suffice. | [
"multithreading",
"logging"
] | 7 | 2 | 948 | 10 | 0 | 2008-08-27T06:58:51.617000 | 2008-08-27T07:10:02.527000 |
29,645 | 29,649 | Set up PowerShell Script for Automatic Execution | I have a few lines of PowerShell code that I would like to use as an automated script. The way I would like it to be able to work is to be able to call it using one of the following options: One command line that opens PowerShell, executes script and closes PowerShell (this would be used for a global build-routine) A file that I can double-click to run the above (I would use this method when manually testing components of my build process) I have been going through PowerShell documentation online, and although I can find lots of scripts, I have been unable to find instructions on how to do what I need. Thanks for the help. | Save your script as a.ps1 file and launch it using powershell.exe, like this: powershell.exe.\foo.ps1 Make sure you specify the full path to the script, and make sure you have set your execution policy level to at least "RemoteSigned" so that unsigned local scripts can be run. | Set up PowerShell Script for Automatic Execution I have a few lines of PowerShell code that I would like to use as an automated script. The way I would like it to be able to work is to be able to call it using one of the following options: One command line that opens PowerShell, executes script and closes PowerShell (this would be used for a global build-routine) A file that I can double-click to run the above (I would use this method when manually testing components of my build process) I have been going through PowerShell documentation online, and although I can find lots of scripts, I have been unable to find instructions on how to do what I need. Thanks for the help. | TITLE:
Set up PowerShell Script for Automatic Execution
QUESTION:
I have a few lines of PowerShell code that I would like to use as an automated script. The way I would like it to be able to work is to be able to call it using one of the following options: One command line that opens PowerShell, executes script and closes PowerShell (this would be used for a global build-routine) A file that I can double-click to run the above (I would use this method when manually testing components of my build process) I have been going through PowerShell documentation online, and although I can find lots of scripts, I have been unable to find instructions on how to do what I need. Thanks for the help.
ANSWER:
Save your script as a.ps1 file and launch it using powershell.exe, like this: powershell.exe.\foo.ps1 Make sure you specify the full path to the script, and make sure you have set your execution policy level to at least "RemoteSigned" so that unsigned local scripts can be run. | [
"command-line",
"powershell",
"scripting"
] | 21 | 9 | 70,889 | 5 | 0 | 2008-08-27T07:00:43.093000 | 2008-08-27T07:06:22.393000 |
29,647 | 29,656 | How do you get the filename of a tempfile to use in Linux? | Let's say I'm creating a program in C that needs to use a tempfile. Creating an ad hoc tempfile in /tmp is probably not a good idea. Is there a function or OS call to supply me with a tempfile name so that I can begin to write and read from it? | You can use the mkstemp(3) function for this purpose. Another alternative is the tmpfile(3) function. Which one of them you choose depends on whether you want the file to be opened as a C library file stream (which tmpfile does), or a direct file descriptor ( mkstemp ). The tmpfile function also deletes the file automatically when you program finishes. The advantage of using these functions is that they avoid race conditions between determining the unique filename and creating the file -- so that two programs won't try to create the same file at the same time, for example. See the man pages for both functions for more details. | How do you get the filename of a tempfile to use in Linux? Let's say I'm creating a program in C that needs to use a tempfile. Creating an ad hoc tempfile in /tmp is probably not a good idea. Is there a function or OS call to supply me with a tempfile name so that I can begin to write and read from it? | TITLE:
How do you get the filename of a tempfile to use in Linux?
QUESTION:
Let's say I'm creating a program in C that needs to use a tempfile. Creating an ad hoc tempfile in /tmp is probably not a good idea. Is there a function or OS call to supply me with a tempfile name so that I can begin to write and read from it?
ANSWER:
You can use the mkstemp(3) function for this purpose. Another alternative is the tmpfile(3) function. Which one of them you choose depends on whether you want the file to be opened as a C library file stream (which tmpfile does), or a direct file descriptor ( mkstemp ). The tmpfile function also deletes the file automatically when you program finishes. The advantage of using these functions is that they avoid race conditions between determining the unique filename and creating the file -- so that two programs won't try to create the same file at the same time, for example. See the man pages for both functions for more details. | [
"c",
"linux"
] | 11 | 21 | 10,687 | 7 | 0 | 2008-08-27T07:05:07.060000 | 2008-08-27T07:12:14.470000 |
29,654 | 281,963 | WinForms databinding and foreign key relationships | I'm developing a WinForms application (.Net 3.5, no WPF) where I want to be able to display foreign key lookups in a databound DataGridView. An example of the sort of relationship is that I have a table of OrderLines. Orderlines have a foreign key relationship to Products and Products in turn have a foreign key relationship to ProductTypes. I'd like to have a databound DataGridView where each row represents an orderline, displaying the line's product and producttype. Users can add or edit orderlines direct to the grid and choose the product for the order line from a comboBoxColumn - this should then update the producttype column, showing the producttype for the selected product, in the same row. The closest to a good fit that I've found so far is to introduce a domain object representing an orderline then bind the DataGridView to a collection of these orderlines. I then add properties to the orderline object that expose the product and the producttype, and raise relevant notifypropertychanged events to keep everything up to date. In my orderline repository I can then wire up the mappings between this orderline object and the three tables in my database. This works for the databinding side of things, but having to hand code all that OR-mapping in the repository seems bad. I thought nHibernate would be able to help with this wiring up but am struggling with the mappings through all the foreign keys - they seem to work ok (the foreignkey lookup for an orderline's product creates the correct product object based on the foreign key) until I try to do the databinding, I can't get the databound id columns to update my product or producttype objects. Is my general approach even in the right ballpark? If it is, what is a good solution to the mapping problem? Or, is there a better solution to databinding rows including foreign key lookups that I haven't even considered? | I think the problem you're having is that when you are binding to a grid, it is not enough to support INotifyPropertyChanged, but you have to fire the ListChanged events in your IBindingList implementation and make sure that you override and return true for the SupportsChangeNotification property. If you don't return true for this, the grid won't look for it to know if the data has changed. In.NET 2.0+, you can create a generic collection using the BindingList class, this will take care of most of the nastiness (just don't forget to override and return true for the SupportsChangeNotification property). If the class you use for data binding has a property that is a collection (such as IBindingList or BindingList), then you can bind the foreign key grid to that property directly. When you configure the bindings in the Forms designer, just select the collection property as the data source for the grid. It should "just work". The only sneaky part is making sure that you handle empty or null collections the right way. | WinForms databinding and foreign key relationships I'm developing a WinForms application (.Net 3.5, no WPF) where I want to be able to display foreign key lookups in a databound DataGridView. An example of the sort of relationship is that I have a table of OrderLines. Orderlines have a foreign key relationship to Products and Products in turn have a foreign key relationship to ProductTypes. I'd like to have a databound DataGridView where each row represents an orderline, displaying the line's product and producttype. Users can add or edit orderlines direct to the grid and choose the product for the order line from a comboBoxColumn - this should then update the producttype column, showing the producttype for the selected product, in the same row. The closest to a good fit that I've found so far is to introduce a domain object representing an orderline then bind the DataGridView to a collection of these orderlines. I then add properties to the orderline object that expose the product and the producttype, and raise relevant notifypropertychanged events to keep everything up to date. In my orderline repository I can then wire up the mappings between this orderline object and the three tables in my database. This works for the databinding side of things, but having to hand code all that OR-mapping in the repository seems bad. I thought nHibernate would be able to help with this wiring up but am struggling with the mappings through all the foreign keys - they seem to work ok (the foreignkey lookup for an orderline's product creates the correct product object based on the foreign key) until I try to do the databinding, I can't get the databound id columns to update my product or producttype objects. Is my general approach even in the right ballpark? If it is, what is a good solution to the mapping problem? Or, is there a better solution to databinding rows including foreign key lookups that I haven't even considered? | TITLE:
WinForms databinding and foreign key relationships
QUESTION:
I'm developing a WinForms application (.Net 3.5, no WPF) where I want to be able to display foreign key lookups in a databound DataGridView. An example of the sort of relationship is that I have a table of OrderLines. Orderlines have a foreign key relationship to Products and Products in turn have a foreign key relationship to ProductTypes. I'd like to have a databound DataGridView where each row represents an orderline, displaying the line's product and producttype. Users can add or edit orderlines direct to the grid and choose the product for the order line from a comboBoxColumn - this should then update the producttype column, showing the producttype for the selected product, in the same row. The closest to a good fit that I've found so far is to introduce a domain object representing an orderline then bind the DataGridView to a collection of these orderlines. I then add properties to the orderline object that expose the product and the producttype, and raise relevant notifypropertychanged events to keep everything up to date. In my orderline repository I can then wire up the mappings between this orderline object and the three tables in my database. This works for the databinding side of things, but having to hand code all that OR-mapping in the repository seems bad. I thought nHibernate would be able to help with this wiring up but am struggling with the mappings through all the foreign keys - they seem to work ok (the foreignkey lookup for an orderline's product creates the correct product object based on the foreign key) until I try to do the databinding, I can't get the databound id columns to update my product or producttype objects. Is my general approach even in the right ballpark? If it is, what is a good solution to the mapping problem? Or, is there a better solution to databinding rows including foreign key lookups that I haven't even considered?
ANSWER:
I think the problem you're having is that when you are binding to a grid, it is not enough to support INotifyPropertyChanged, but you have to fire the ListChanged events in your IBindingList implementation and make sure that you override and return true for the SupportsChangeNotification property. If you don't return true for this, the grid won't look for it to know if the data has changed. In.NET 2.0+, you can create a generic collection using the BindingList class, this will take care of most of the nastiness (just don't forget to override and return true for the SupportsChangeNotification property). If the class you use for data binding has a property that is a collection (such as IBindingList or BindingList), then you can bind the foreign key grid to that property directly. When you configure the bindings in the Forms designer, just select the collection property as the data source for the grid. It should "just work". The only sneaky part is making sure that you handle empty or null collections the right way. | [
"c#",
".net",
"winforms"
] | 6 | 2 | 4,992 | 5 | 0 | 2008-08-27T07:11:46.407000 | 2008-11-11T19:51:11.033000 |
29,664 | 62,688 | How to catch SQLServer timeout exceptions | I need to specifically catch SQL server timeout exceptions so that they can be handled differently. I know I could catch the SqlException and then check if the message string Contains "Timeout" but was wondering if there is a better way to do it? try { //some code } catch (SqlException ex) {
if (ex.Message.Contains("Timeout")) { //handle timeout } else { throw; } } | To check for a timeout, I believe you check the value of ex.Number. If it is -2, then you have a timeout situation. -2 is the error code for timeout, returned from DBNETLIB, the MDAC driver for SQL Server. This can be seen by downloading Reflector, and looking under System.Data.SqlClient.TdsEnums for TIMEOUT_EXPIRED. Your code would read: if (ex.Number == -2) { //handle timeout } Code to demonstrate failure: try { SqlConnection sql = new SqlConnection(@"Network Library=DBMSSOCN;Data Source=YourServer,1433;Initial Catalog=YourDB;Integrated Security=SSPI;"); sql.Open();
SqlCommand cmd = sql.CreateCommand(); cmd.CommandText = "DECLARE @i int WHILE EXISTS (SELECT 1 from sysobjects) BEGIN SELECT @i = 1 END"; cmd.ExecuteNonQuery(); // This line will timeout.
cmd.Dispose(); sql.Close(); } catch (SqlException ex) { if (ex.Number == -2) { Console.WriteLine ("Timeout occurred"); } } | How to catch SQLServer timeout exceptions I need to specifically catch SQL server timeout exceptions so that they can be handled differently. I know I could catch the SqlException and then check if the message string Contains "Timeout" but was wondering if there is a better way to do it? try { //some code } catch (SqlException ex) {
if (ex.Message.Contains("Timeout")) { //handle timeout } else { throw; } } | TITLE:
How to catch SQLServer timeout exceptions
QUESTION:
I need to specifically catch SQL server timeout exceptions so that they can be handled differently. I know I could catch the SqlException and then check if the message string Contains "Timeout" but was wondering if there is a better way to do it? try { //some code } catch (SqlException ex) {
if (ex.Message.Contains("Timeout")) { //handle timeout } else { throw; } }
ANSWER:
To check for a timeout, I believe you check the value of ex.Number. If it is -2, then you have a timeout situation. -2 is the error code for timeout, returned from DBNETLIB, the MDAC driver for SQL Server. This can be seen by downloading Reflector, and looking under System.Data.SqlClient.TdsEnums for TIMEOUT_EXPIRED. Your code would read: if (ex.Number == -2) { //handle timeout } Code to demonstrate failure: try { SqlConnection sql = new SqlConnection(@"Network Library=DBMSSOCN;Data Source=YourServer,1433;Initial Catalog=YourDB;Integrated Security=SSPI;"); sql.Open();
SqlCommand cmd = sql.CreateCommand(); cmd.CommandText = "DECLARE @i int WHILE EXISTS (SELECT 1 from sysobjects) BEGIN SELECT @i = 1 END"; cmd.ExecuteNonQuery(); // This line will timeout.
cmd.Dispose(); sql.Close(); } catch (SqlException ex) { if (ex.Number == -2) { Console.WriteLine ("Timeout occurred"); } } | [
"c#",
".net",
"sql-server",
"error-handling"
] | 137 | 187 | 124,131 | 6 | 0 | 2008-08-27T07:18:54.173000 | 2008-09-15T13:09:29.943000 |
29,665 | 30,452 | Free Wavetable Synthesizer? | I need to implement a wavetable synthesizer in an ARM Cortex-M3 core. I'm looking for any code or tools to help me get started. I'm aware of this AVR implementation. I actually converted it to a PIC a while back. Now I am looking for something similar, but a little better sounding. ANSI C code would be great. Any code snippets (C or C++), samples, tools, or just general information would be greatly appreciated. Thanks. | The Synthesis Toolkit (STK) is excellent, but it is C++ only: http://ccrma.stanford.edu/software/stk/ You may be able to extract the wavetable synthesizer code from the STK though. | Free Wavetable Synthesizer? I need to implement a wavetable synthesizer in an ARM Cortex-M3 core. I'm looking for any code or tools to help me get started. I'm aware of this AVR implementation. I actually converted it to a PIC a while back. Now I am looking for something similar, but a little better sounding. ANSI C code would be great. Any code snippets (C or C++), samples, tools, or just general information would be greatly appreciated. Thanks. | TITLE:
Free Wavetable Synthesizer?
QUESTION:
I need to implement a wavetable synthesizer in an ARM Cortex-M3 core. I'm looking for any code or tools to help me get started. I'm aware of this AVR implementation. I actually converted it to a PIC a while back. Now I am looking for something similar, but a little better sounding. ANSI C code would be great. Any code snippets (C or C++), samples, tools, or just general information would be greatly appreciated. Thanks.
ANSWER:
The Synthesis Toolkit (STK) is excellent, but it is C++ only: http://ccrma.stanford.edu/software/stk/ You may be able to extract the wavetable synthesizer code from the STK though. | [
"audio",
"arm",
"microcontroller",
"synthesizer",
"sound-synthesis"
] | 2 | 5 | 4,754 | 3 | 0 | 2008-08-27T07:20:38.617000 | 2008-08-27T15:31:08.967000 |
29,668 | 38,889 | Remote debugging across domains | I have two machines in two different domains. On both I have VS 2005 installed. I want remote debug between them. Without authentication it is possible but I want to debug managed code. I don't want to debug directly since it is really crappy machine. When I try to attach with debugger I get message "The trust relationship between this workstation and primary domain failed." Any idea how to overcome this? I tried tricks with adding same local username on both machines but with no luck. EDIT: I have same local users on both machines. I started both VS2005 and Debugging monitor with RunAs using local users. I turned Windows Auditing on debug machine and I see that local user from VS2005 machine is trying to logon. But he fails with error 0xC000018D (ERROR_TRUSTED_RELATIONSHIP_FAILURE) | Gregg Miskely has a blog post on this. You might get it to work if both local accounts have the same user name and password. You might also try dropping your good box from it's domain so that you are going from a workgroup to a domain rather than domain to domain. | Remote debugging across domains I have two machines in two different domains. On both I have VS 2005 installed. I want remote debug between them. Without authentication it is possible but I want to debug managed code. I don't want to debug directly since it is really crappy machine. When I try to attach with debugger I get message "The trust relationship between this workstation and primary domain failed." Any idea how to overcome this? I tried tricks with adding same local username on both machines but with no luck. EDIT: I have same local users on both machines. I started both VS2005 and Debugging monitor with RunAs using local users. I turned Windows Auditing on debug machine and I see that local user from VS2005 machine is trying to logon. But he fails with error 0xC000018D (ERROR_TRUSTED_RELATIONSHIP_FAILURE) | TITLE:
Remote debugging across domains
QUESTION:
I have two machines in two different domains. On both I have VS 2005 installed. I want remote debug between them. Without authentication it is possible but I want to debug managed code. I don't want to debug directly since it is really crappy machine. When I try to attach with debugger I get message "The trust relationship between this workstation and primary domain failed." Any idea how to overcome this? I tried tricks with adding same local username on both machines but with no luck. EDIT: I have same local users on both machines. I started both VS2005 and Debugging monitor with RunAs using local users. I turned Windows Auditing on debug machine and I see that local user from VS2005 machine is trying to logon. But he fails with error 0xC000018D (ERROR_TRUSTED_RELATIONSHIP_FAILURE)
ANSWER:
Gregg Miskely has a blog post on this. You might get it to work if both local accounts have the same user name and password. You might also try dropping your good box from it's domain so that you are going from a workgroup to a domain rather than domain to domain. | [
"visual-studio",
"debugging",
"managed-code"
] | 4 | 5 | 2,520 | 3 | 0 | 2008-08-27T07:21:35.353000 | 2008-09-02T05:34:25.157000 |
29,677 | 29,692 | How do I make the manifest of a .net assembly private? | What should I do if I want to release a.net assembly but wish to keep its internals detailed in the manifest private (from a utility such as ildasm.exe )? | I think what you're talking about is "obfuscation". There are lots of articles about it on the net: http://en.wikipedia.org/wiki/Obfuscation The "standard" tool for obfuscation on.NET is by Preemptive Solutions: http://www.preemptive.com/obfuscator.html They have a community edition that ships with Visual Studio which you can use. You mentioned ILDasm, have you looked at the.NET Reflector? http://aisto.com/roeder/dotnet/ It gives you an even better idea as to what people can see if you release a manifest! | How do I make the manifest of a .net assembly private? What should I do if I want to release a.net assembly but wish to keep its internals detailed in the manifest private (from a utility such as ildasm.exe )? | TITLE:
How do I make the manifest of a .net assembly private?
QUESTION:
What should I do if I want to release a.net assembly but wish to keep its internals detailed in the manifest private (from a utility such as ildasm.exe )?
ANSWER:
I think what you're talking about is "obfuscation". There are lots of articles about it on the net: http://en.wikipedia.org/wiki/Obfuscation The "standard" tool for obfuscation on.NET is by Preemptive Solutions: http://www.preemptive.com/obfuscator.html They have a community edition that ships with Visual Studio which you can use. You mentioned ILDasm, have you looked at the.NET Reflector? http://aisto.com/roeder/dotnet/ It gives you an even better idea as to what people can see if you release a manifest! | [
".net",
"security",
"obfuscation"
] | 3 | 7 | 758 | 2 | 0 | 2008-08-27T07:38:06.593000 | 2008-08-27T07:55:52.837000 |
29,678 | 29,784 | How to aggregate data from SQL Server 2005 | I have about 150 000 rows of data written to a database everyday. These row represent outgoing articles for example. Now I need to show a graph using SSRS that show the average number of articles per day over time. I also need to have a information about the actual number of articles from yesterday. The idea is to have a aggregated view on all our transactions and have something that can indicate that something is wrong (that we for example send out 20% less articles than the average). My idea is to have yesterdays data moved into SSAS every night and there store the aggregated value of number of transactions and the actual number of transaction from yesterdays data. Using SSAS would hopefully speed up the reports. Do you think this is the right idea? Should I skip SSAS and have reports straight on the raw data? I know how use reporting services on raw data using standard SQL queries but how would this change when querying SSAS? I don't know SSAS - where do I start..? | The neat thing with SSAS is that you can get those indicators that you talk about quite easily either by creating calculated measures or by using KPIs. I started with Delivering Business Intelligence with Microsoft SQL Server 2005. It had some good introduction, but unfortunately it's too verbose when it comes to the details. But if you want to understand SSAS, OLAP and reporting using this framework it's a good start. Mosha Pasumansky has a blog on SSAS and MDX with great links. Other than that I would recommend Microsofts Online books. | How to aggregate data from SQL Server 2005 I have about 150 000 rows of data written to a database everyday. These row represent outgoing articles for example. Now I need to show a graph using SSRS that show the average number of articles per day over time. I also need to have a information about the actual number of articles from yesterday. The idea is to have a aggregated view on all our transactions and have something that can indicate that something is wrong (that we for example send out 20% less articles than the average). My idea is to have yesterdays data moved into SSAS every night and there store the aggregated value of number of transactions and the actual number of transaction from yesterdays data. Using SSAS would hopefully speed up the reports. Do you think this is the right idea? Should I skip SSAS and have reports straight on the raw data? I know how use reporting services on raw data using standard SQL queries but how would this change when querying SSAS? I don't know SSAS - where do I start..? | TITLE:
How to aggregate data from SQL Server 2005
QUESTION:
I have about 150 000 rows of data written to a database everyday. These row represent outgoing articles for example. Now I need to show a graph using SSRS that show the average number of articles per day over time. I also need to have a information about the actual number of articles from yesterday. The idea is to have a aggregated view on all our transactions and have something that can indicate that something is wrong (that we for example send out 20% less articles than the average). My idea is to have yesterdays data moved into SSAS every night and there store the aggregated value of number of transactions and the actual number of transaction from yesterdays data. Using SSAS would hopefully speed up the reports. Do you think this is the right idea? Should I skip SSAS and have reports straight on the raw data? I know how use reporting services on raw data using standard SQL queries but how would this change when querying SSAS? I don't know SSAS - where do I start..?
ANSWER:
The neat thing with SSAS is that you can get those indicators that you talk about quite easily either by creating calculated measures or by using KPIs. I started with Delivering Business Intelligence with Microsoft SQL Server 2005. It had some good introduction, but unfortunately it's too verbose when it comes to the details. But if you want to understand SSAS, OLAP and reporting using this framework it's a good start. Mosha Pasumansky has a blog on SSAS and MDX with great links. Other than that I would recommend Microsofts Online books. | [
"sql-server",
"reporting-services",
"ssas"
] | 3 | 2 | 906 | 5 | 0 | 2008-08-27T07:38:29.367000 | 2008-08-27T09:26:46.177000 |
29,680 | 165,867 | Suppress NTLM dialog box after unauthorized request | In a recent sharepoint project, I implemented an authentication webpart which should replace the NTLM authentication dialog box. It works fine as long as the user provides valid credentials. Whenever the user provides invalid credentials, the NTLM dialog box pops up in Internet Explorer. My Javascript code which does the authentication via XmlHttpRequest looks like this: function Login() { var request = GetRequest(); // retrieves XmlHttpRequest request.onreadystatechange = function() { if (this.status == 401) { // unauthorized request -> invalid credentials // do something to suppress NTLM dialog box... // already tried location.reload(); and window.location =; } } request.open("GET", "http://myServer", false, "domain\\username", "password"); request.send(null); } I don't want the NTLM dialog box to be displayed when the user provides invalid credentials. Instead the postback by the login button in the authentication form should be executed. In other words, the browser should not find out about my unauthorized request. Is there any way to do this via Javascript? | Mark 's comment is correct; The NTLM auth prompt is triggered by a 401 response code and the presence of NTLM as the first mechanism offered in the WWW-Authenticate header (Ref: The NTLM Authentication Protocol ). I'm not sure if I understand the question description correctly, but I think you are trying to wrap the NTLM authentication for SharePoint, which means you don't have control over the server-side authentication protocol, correct? If you're not able to manipulate the server side to avoid sending a 401 response on failed credentials, then you will not be able to avoid this problem, because it's part of the (client-side) spec: The XMLHttpRequest Object If the UA supports HTTP Authentication [RFC2617] it SHOULD consider requests originating from this object to be part of the protection space that includes the accessed URIs and send Authorization headers and handle 401 Unauthorised requests appropriately. if authentication fails, UAs should prompt the users for credentials. So the spec actually calls for the browser to prompt the user accordingly if any 401 response is received in an XMLHttpRequest, just as if the user had accessed the URL directly. As far as I can tell the only way to really avoid this would be for you to have control over the server side and cause 401 Unauthorized responses to be avoided, as Mark mentioned. One last thought is that you may be able to get around this using a proxy, such a separate server side script on another webserver. That script then takes a user and pass parameter and checks the authentication, so that the user's browser isn't what's making the original HTTP request and therefore isn't receiving the 401 response that's causing the prompt. If you do it this way you can find out from your "proxy" script if it failed, and if so then prompt the user again until it succeeds. On a successful authentication event, you can simply fetch the HTTP request as you are now, since everything works if the credentials are correctly specified. | Suppress NTLM dialog box after unauthorized request In a recent sharepoint project, I implemented an authentication webpart which should replace the NTLM authentication dialog box. It works fine as long as the user provides valid credentials. Whenever the user provides invalid credentials, the NTLM dialog box pops up in Internet Explorer. My Javascript code which does the authentication via XmlHttpRequest looks like this: function Login() { var request = GetRequest(); // retrieves XmlHttpRequest request.onreadystatechange = function() { if (this.status == 401) { // unauthorized request -> invalid credentials // do something to suppress NTLM dialog box... // already tried location.reload(); and window.location =; } } request.open("GET", "http://myServer", false, "domain\\username", "password"); request.send(null); } I don't want the NTLM dialog box to be displayed when the user provides invalid credentials. Instead the postback by the login button in the authentication form should be executed. In other words, the browser should not find out about my unauthorized request. Is there any way to do this via Javascript? | TITLE:
Suppress NTLM dialog box after unauthorized request
QUESTION:
In a recent sharepoint project, I implemented an authentication webpart which should replace the NTLM authentication dialog box. It works fine as long as the user provides valid credentials. Whenever the user provides invalid credentials, the NTLM dialog box pops up in Internet Explorer. My Javascript code which does the authentication via XmlHttpRequest looks like this: function Login() { var request = GetRequest(); // retrieves XmlHttpRequest request.onreadystatechange = function() { if (this.status == 401) { // unauthorized request -> invalid credentials // do something to suppress NTLM dialog box... // already tried location.reload(); and window.location =; } } request.open("GET", "http://myServer", false, "domain\\username", "password"); request.send(null); } I don't want the NTLM dialog box to be displayed when the user provides invalid credentials. Instead the postback by the login button in the authentication form should be executed. In other words, the browser should not find out about my unauthorized request. Is there any way to do this via Javascript?
ANSWER:
Mark 's comment is correct; The NTLM auth prompt is triggered by a 401 response code and the presence of NTLM as the first mechanism offered in the WWW-Authenticate header (Ref: The NTLM Authentication Protocol ). I'm not sure if I understand the question description correctly, but I think you are trying to wrap the NTLM authentication for SharePoint, which means you don't have control over the server-side authentication protocol, correct? If you're not able to manipulate the server side to avoid sending a 401 response on failed credentials, then you will not be able to avoid this problem, because it's part of the (client-side) spec: The XMLHttpRequest Object If the UA supports HTTP Authentication [RFC2617] it SHOULD consider requests originating from this object to be part of the protection space that includes the accessed URIs and send Authorization headers and handle 401 Unauthorised requests appropriately. if authentication fails, UAs should prompt the users for credentials. So the spec actually calls for the browser to prompt the user accordingly if any 401 response is received in an XMLHttpRequest, just as if the user had accessed the URL directly. As far as I can tell the only way to really avoid this would be for you to have control over the server side and cause 401 Unauthorized responses to be avoided, as Mark mentioned. One last thought is that you may be able to get around this using a proxy, such a separate server side script on another webserver. That script then takes a user and pass parameter and checks the authentication, so that the user's browser isn't what's making the original HTTP request and therefore isn't receiving the 401 response that's causing the prompt. If you do it this way you can find out from your "proxy" script if it failed, and if so then prompt the user again until it succeeds. On a successful authentication event, you can simply fetch the HTTP request as you are now, since everything works if the credentials are correctly specified. | [
"asp.net",
"javascript",
"sharepoint"
] | 8 | 5 | 4,285 | 3 | 0 | 2008-08-27T07:40:01.597000 | 2008-10-03T06:06:29.120000 |
29,686 | 29,754 | Set ASP.net executionTimeout in code / "refresh" request | I'll have an ASP.net page that creates some Excel Sheets and sends them to the user. The problem is, sometimes I get Http timeouts, presumably because the Request runs longer than executionTimeout (110 seconds per default). I just wonder what my options are to prevent this, without wanting to generally increase the executionTimeout in web.config? In PHP, set_time_limit exists which can be used in a function to extend its life, but I did not see anything like that in C#/ASP.net? How do you handle long-running functions in ASP.net? | If you want to increase the execution timeout for this one request you can set HttpContext.Current.Server.ScriptTimeout But you still may have the problem of the client timing out which you can't reliably solve directly from the server. To get around that you could implement a "processing" page (like Rob suggests) that posts back until the response is ready. Or you might want to look into AJAX to do something similar. | Set ASP.net executionTimeout in code / "refresh" request I'll have an ASP.net page that creates some Excel Sheets and sends them to the user. The problem is, sometimes I get Http timeouts, presumably because the Request runs longer than executionTimeout (110 seconds per default). I just wonder what my options are to prevent this, without wanting to generally increase the executionTimeout in web.config? In PHP, set_time_limit exists which can be used in a function to extend its life, but I did not see anything like that in C#/ASP.net? How do you handle long-running functions in ASP.net? | TITLE:
Set ASP.net executionTimeout in code / "refresh" request
QUESTION:
I'll have an ASP.net page that creates some Excel Sheets and sends them to the user. The problem is, sometimes I get Http timeouts, presumably because the Request runs longer than executionTimeout (110 seconds per default). I just wonder what my options are to prevent this, without wanting to generally increase the executionTimeout in web.config? In PHP, set_time_limit exists which can be used in a function to extend its life, but I did not see anything like that in C#/ASP.net? How do you handle long-running functions in ASP.net?
ANSWER:
If you want to increase the execution timeout for this one request you can set HttpContext.Current.Server.ScriptTimeout But you still may have the problem of the client timing out which you can't reliably solve directly from the server. To get around that you could implement a "processing" page (like Rob suggests) that posts back until the response is ready. Or you might want to look into AJAX to do something similar. | [
"c#",
"asp.net"
] | 14 | 16 | 10,192 | 2 | 0 | 2008-08-27T07:50:05.957000 | 2008-08-27T08:45:58.973000 |
29,689 | 31,946 | Javadoc template generator | I have a large codebase without Javadoc, and I want to run a program to write a skeleton with the basic Javadoc information (e.g., for each method's parameter write @param...), so I just have to fill the gaps left. Anyone know a good solution for this? Edit: JAutodoc is what I was looking for. It has Ant tasks, an Eclipse plugin, and uses Velocity for the template definition. | The JAutodoc plugin for eclipse does exactly what you need, but with a package granularity: right click on a package, select "Add javadoc for members..." and the skeleton will be added. There are numerous interesting options: templates for javadoc, adding a TODO in the header of every file saying: "template javadoc, must be filled...", etc. | Javadoc template generator I have a large codebase without Javadoc, and I want to run a program to write a skeleton with the basic Javadoc information (e.g., for each method's parameter write @param...), so I just have to fill the gaps left. Anyone know a good solution for this? Edit: JAutodoc is what I was looking for. It has Ant tasks, an Eclipse plugin, and uses Velocity for the template definition. | TITLE:
Javadoc template generator
QUESTION:
I have a large codebase without Javadoc, and I want to run a program to write a skeleton with the basic Javadoc information (e.g., for each method's parameter write @param...), so I just have to fill the gaps left. Anyone know a good solution for this? Edit: JAutodoc is what I was looking for. It has Ant tasks, an Eclipse plugin, and uses Velocity for the template definition.
ANSWER:
The JAutodoc plugin for eclipse does exactly what you need, but with a package granularity: right click on a package, select "Add javadoc for members..." and the skeleton will be added. There are numerous interesting options: templates for javadoc, adding a TODO in the header of every file saying: "template javadoc, must be filled...", etc. | [
"java",
"documentation",
"javadoc"
] | 32 | 39 | 42,111 | 6 | 0 | 2008-08-27T07:55:06.443000 | 2008-08-28T10:02:10.887000 |
29,694 | 29,804 | How to work around unsupported unsigned integer field types in MS SQL? | Trying to make a MySQL-based application support MS SQL, I ran into the following issue: I keep MySQL's auto_increment as unsigned integer fields (of various sizes) in order to make use of the full range, as I know there will never be negative values. MS SQL does not support the unsigned attribute on all integer types, so I have to choose between ditching half the value range or creating some workaround. One very naive approach would be to put some code in the database abstraction code or in a stored procedure that converts between negative values on the db side and values from the larger portion of the unsigned range. This would mess up sorting of course, and also it would not work with the auto-id feature (or would it some way?). I can't think of a good workaround right now, is there any? Or am I just being fanatic and should simply forget about half the range? Edit: @Mike Woodhouse: Yeah, I guess you're right. There's still a voice in my head saying that maybe I could reduce the field's size if I optimize its utilization. But if there's no easy way to do this, it's probably not worth worrying about it. | When is the problem likely to become a real issue? Given current growth rates, how soon do you expect signed integer overflow to happen in the MS SQL version? Be pessimistic. How long do you expect the application to live? Do you still think the factor of 2 difference is something you should worry about? (I have no idea what the answers are, but I think we should be sure that we really have a problem before searching any harder for a solution) | How to work around unsupported unsigned integer field types in MS SQL? Trying to make a MySQL-based application support MS SQL, I ran into the following issue: I keep MySQL's auto_increment as unsigned integer fields (of various sizes) in order to make use of the full range, as I know there will never be negative values. MS SQL does not support the unsigned attribute on all integer types, so I have to choose between ditching half the value range or creating some workaround. One very naive approach would be to put some code in the database abstraction code or in a stored procedure that converts between negative values on the db side and values from the larger portion of the unsigned range. This would mess up sorting of course, and also it would not work with the auto-id feature (or would it some way?). I can't think of a good workaround right now, is there any? Or am I just being fanatic and should simply forget about half the range? Edit: @Mike Woodhouse: Yeah, I guess you're right. There's still a voice in my head saying that maybe I could reduce the field's size if I optimize its utilization. But if there's no easy way to do this, it's probably not worth worrying about it. | TITLE:
How to work around unsupported unsigned integer field types in MS SQL?
QUESTION:
Trying to make a MySQL-based application support MS SQL, I ran into the following issue: I keep MySQL's auto_increment as unsigned integer fields (of various sizes) in order to make use of the full range, as I know there will never be negative values. MS SQL does not support the unsigned attribute on all integer types, so I have to choose between ditching half the value range or creating some workaround. One very naive approach would be to put some code in the database abstraction code or in a stored procedure that converts between negative values on the db side and values from the larger portion of the unsigned range. This would mess up sorting of course, and also it would not work with the auto-id feature (or would it some way?). I can't think of a good workaround right now, is there any? Or am I just being fanatic and should simply forget about half the range? Edit: @Mike Woodhouse: Yeah, I guess you're right. There's still a voice in my head saying that maybe I could reduce the field's size if I optimize its utilization. But if there's no easy way to do this, it's probably not worth worrying about it.
ANSWER:
When is the problem likely to become a real issue? Given current growth rates, how soon do you expect signed integer overflow to happen in the MS SQL version? Be pessimistic. How long do you expect the application to live? Do you still think the factor of 2 difference is something you should worry about? (I have no idea what the answers are, but I think we should be sure that we really have a problem before searching any harder for a solution) | [
"mysql",
"sql-server",
"database",
"interop"
] | 1 | 1 | 3,220 | 3 | 0 | 2008-08-27T07:57:16.110000 | 2008-08-27T09:39:12.323000 |
29,696 | 29,720 | How do you stop the Designer generating code for public properties on a User Control? | How do you stop the designer from auto generating code that sets the value for public properties on a user control? | Use the DesignerSerializationVisibilityAttribute on the properties that you want to hide from the designer serialization and set the parameter to Hidden. [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Name { get; set; } | How do you stop the Designer generating code for public properties on a User Control? How do you stop the designer from auto generating code that sets the value for public properties on a user control? | TITLE:
How do you stop the Designer generating code for public properties on a User Control?
QUESTION:
How do you stop the designer from auto generating code that sets the value for public properties on a user control?
ANSWER:
Use the DesignerSerializationVisibilityAttribute on the properties that you want to hide from the designer serialization and set the parameter to Hidden. [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public string Name { get; set; } | [
"c#",
"winforms"
] | 39 | 66 | 13,335 | 3 | 0 | 2008-08-27T07:59:21.020000 | 2008-08-27T08:13:13.420000 |
29,699 | 29,727 | How do I deal with quotes ' in SQL | I have a database with names in it such as John Doe etc. Unfortunately some of these names contain quotes like Keiran O'Keefe. Now when I try and search for such names as follows: SELECT * FROM PEOPLE WHERE SURNAME='O'Keefe' I (understandably) get an error. How do I prevent this error from occurring. I am using Oracle and PLSQL. | The escape character is ', so you would need to replace the quote with two quotes. For example, SELECT * FROM PEOPLE WHERE SURNAME='O'Keefe' becomes SELECT * FROM PEOPLE WHERE SURNAME='O''Keefe' That said, it's probably incorrect to do this yourself. Your language may have a function to escape strings for use in SQL, but an even better option is to use parameters. Usually this works as follows. Your SQL command would be: SELECT * FROM PEOPLE WHERE SURNAME=? Then, when you execute it, you pass in "O'Keefe" as a parameter. Because the SQL is parsed before the parameter value is set, there's no way for the parameter value to alter the structure of the SQL (and it's even a little faster if you want to run the same statement several times with different parameters). I should also point out that, while your example just causes an error, you open youself up to a lot of other problems by not escaping strings appropriately. See http://en.wikipedia.org/wiki/SQL_injection for a good starting point or the following classic xkcd comic. | How do I deal with quotes ' in SQL I have a database with names in it such as John Doe etc. Unfortunately some of these names contain quotes like Keiran O'Keefe. Now when I try and search for such names as follows: SELECT * FROM PEOPLE WHERE SURNAME='O'Keefe' I (understandably) get an error. How do I prevent this error from occurring. I am using Oracle and PLSQL. | TITLE:
How do I deal with quotes ' in SQL
QUESTION:
I have a database with names in it such as John Doe etc. Unfortunately some of these names contain quotes like Keiran O'Keefe. Now when I try and search for such names as follows: SELECT * FROM PEOPLE WHERE SURNAME='O'Keefe' I (understandably) get an error. How do I prevent this error from occurring. I am using Oracle and PLSQL.
ANSWER:
The escape character is ', so you would need to replace the quote with two quotes. For example, SELECT * FROM PEOPLE WHERE SURNAME='O'Keefe' becomes SELECT * FROM PEOPLE WHERE SURNAME='O''Keefe' That said, it's probably incorrect to do this yourself. Your language may have a function to escape strings for use in SQL, but an even better option is to use parameters. Usually this works as follows. Your SQL command would be: SELECT * FROM PEOPLE WHERE SURNAME=? Then, when you execute it, you pass in "O'Keefe" as a parameter. Because the SQL is parsed before the parameter value is set, there's no way for the parameter value to alter the structure of the SQL (and it's even a little faster if you want to run the same statement several times with different parameters). I should also point out that, while your example just causes an error, you open youself up to a lot of other problems by not escaping strings appropriately. See http://en.wikipedia.org/wiki/SQL_injection for a good starting point or the following classic xkcd comic. | [
"sql",
"oracle"
] | 11 | 30 | 23,509 | 8 | 0 | 2008-08-27T08:01:04.417000 | 2008-08-27T08:17:56.293000 |
29,731 | 29,740 | What is the best way to sort a data bound combo box? | I have done a bit of research into this and it seems that the only way to sort a data bound combo box is to sort the data source itself (a DataTable in a DataSet in this case). If that is the case then the question becomes what is the best way to sort a DataTable? The combo box bindings are set in the designer initialize using myCombo.DataSource = this.typedDataSet; myCombo.DataMember = "Table1"; myCombo.DisplayMember = "ColumnB"; myCombo.ValueMember = "ColumnA"; I have tried setting this.typedDataSet.Table1.DefaultView.Sort = "ColumnB DESC"; But that makes no difference, I have tried setting this in the control constructor, before and after a typedDataSet.Merge call. | If you're using a DataTable, you can use the (DataTable.DefaultView) DataView.Sort property. For greater flexibility you can use the BindingSource component. BindingSource will be the DataSource of your combobox. Then you can change your data source from a DataTable to List without changing the DataSource of the combobox. The BindingSource component serves many purposes. First, it simplifies binding controls on a form to data by providing currency management, change notification, and other services between Windows Forms controls and data sources. | What is the best way to sort a data bound combo box? I have done a bit of research into this and it seems that the only way to sort a data bound combo box is to sort the data source itself (a DataTable in a DataSet in this case). If that is the case then the question becomes what is the best way to sort a DataTable? The combo box bindings are set in the designer initialize using myCombo.DataSource = this.typedDataSet; myCombo.DataMember = "Table1"; myCombo.DisplayMember = "ColumnB"; myCombo.ValueMember = "ColumnA"; I have tried setting this.typedDataSet.Table1.DefaultView.Sort = "ColumnB DESC"; But that makes no difference, I have tried setting this in the control constructor, before and after a typedDataSet.Merge call. | TITLE:
What is the best way to sort a data bound combo box?
QUESTION:
I have done a bit of research into this and it seems that the only way to sort a data bound combo box is to sort the data source itself (a DataTable in a DataSet in this case). If that is the case then the question becomes what is the best way to sort a DataTable? The combo box bindings are set in the designer initialize using myCombo.DataSource = this.typedDataSet; myCombo.DataMember = "Table1"; myCombo.DisplayMember = "ColumnB"; myCombo.ValueMember = "ColumnA"; I have tried setting this.typedDataSet.Table1.DefaultView.Sort = "ColumnB DESC"; But that makes no difference, I have tried setting this in the control constructor, before and after a typedDataSet.Merge call.
ANSWER:
If you're using a DataTable, you can use the (DataTable.DefaultView) DataView.Sort property. For greater flexibility you can use the BindingSource component. BindingSource will be the DataSource of your combobox. Then you can change your data source from a DataTable to List without changing the DataSource of the combobox. The BindingSource component serves many purposes. First, it simplifies binding controls on a form to data by providing currency management, change notification, and other services between Windows Forms controls and data sources. | [
"c#",
"data-binding"
] | 5 | 7 | 12,744 | 8 | 0 | 2008-08-27T08:22:55.643000 | 2008-08-27T08:30:13.223000 |
29,734 | 29,739 | Why stateless session beans are single threaded? | As per my understanding stateless session beans are used to code the business logic. They can not store data in their instance variables because their instance is shared by multiple requests. So they seem to be more like Singleton classes. However the difference is contain creates (or reuses from pool) the separate instance of stateless session beans for every request. After googling I could find the reasoning that the Java EE specification says they are suppose to be single threaded. But I can't get the reason why the are specified to be SINGLE THREADED? | The SLSBs are single threaded because of the TX Context, Principal is associated with a bean instance when it is called. These beans are pooled and unless the max pool size is reached are processed in separate threads ( Vendor dependent). If SLSBs were designed thread safe every call would have looked like a servlet doGet/Post with request info containing Tx Context, Security Context info and etc. So at least the code looks clean (developer dependent). | Why stateless session beans are single threaded? As per my understanding stateless session beans are used to code the business logic. They can not store data in their instance variables because their instance is shared by multiple requests. So they seem to be more like Singleton classes. However the difference is contain creates (or reuses from pool) the separate instance of stateless session beans for every request. After googling I could find the reasoning that the Java EE specification says they are suppose to be single threaded. But I can't get the reason why the are specified to be SINGLE THREADED? | TITLE:
Why stateless session beans are single threaded?
QUESTION:
As per my understanding stateless session beans are used to code the business logic. They can not store data in their instance variables because their instance is shared by multiple requests. So they seem to be more like Singleton classes. However the difference is contain creates (or reuses from pool) the separate instance of stateless session beans for every request. After googling I could find the reasoning that the Java EE specification says they are suppose to be single threaded. But I can't get the reason why the are specified to be SINGLE THREADED?
ANSWER:
The SLSBs are single threaded because of the TX Context, Principal is associated with a bean instance when it is called. These beans are pooled and unless the max pool size is reached are processed in separate threads ( Vendor dependent). If SLSBs were designed thread safe every call would have looked like a servlet doGet/Post with request info containing Tx Context, Security Context info and etc. So at least the code looks clean (developer dependent). | [
"java",
"ejb"
] | 6 | 5 | 2,772 | 2 | 0 | 2008-08-27T08:25:05.450000 | 2008-08-27T08:29:56.780000 |
29,743 | 29,750 | How to select an SQL database? | We're living in a golden age of databases, with numerous high quality commercial and free databases. This is great, but the downside is there's not a simple obvious choice for someone who needs a database for his next project. What are the constraints/criteria you use for selecting a database? How well do the various databases you've used meet those constraints/criteria? What special features do the databases have? Which databases do you feel comfortable recommending to others? etc... | I would think first on what the system requirements are for data access, data security, scalability, performance, disconnected scenarios, data transformation, data sizing. On the other side, consider also the experience and background of developers, operators, platform administrators. You should also think on what constraints you have regarding programming languages, operating systems, memory footprint, network bandwidth, hardware. Last, but not least, you have to think about business issues like budget for licences, support, operation. After all those considerations you should end up with just a couple of options and the selection should be easier. In other words, select the technology that suits the best the constraints and needs of your organization and project. I certainly think that you are right on saying that it is not an obvious choice given the wide number of alternatives, but this is the only way I think you can narrow them to the ones that are really feasible for your project. | How to select an SQL database? We're living in a golden age of databases, with numerous high quality commercial and free databases. This is great, but the downside is there's not a simple obvious choice for someone who needs a database for his next project. What are the constraints/criteria you use for selecting a database? How well do the various databases you've used meet those constraints/criteria? What special features do the databases have? Which databases do you feel comfortable recommending to others? etc... | TITLE:
How to select an SQL database?
QUESTION:
We're living in a golden age of databases, with numerous high quality commercial and free databases. This is great, but the downside is there's not a simple obvious choice for someone who needs a database for his next project. What are the constraints/criteria you use for selecting a database? How well do the various databases you've used meet those constraints/criteria? What special features do the databases have? Which databases do you feel comfortable recommending to others? etc...
ANSWER:
I would think first on what the system requirements are for data access, data security, scalability, performance, disconnected scenarios, data transformation, data sizing. On the other side, consider also the experience and background of developers, operators, platform administrators. You should also think on what constraints you have regarding programming languages, operating systems, memory footprint, network bandwidth, hardware. Last, but not least, you have to think about business issues like budget for licences, support, operation. After all those considerations you should end up with just a couple of options and the selection should be easier. In other words, select the technology that suits the best the constraints and needs of your organization and project. I certainly think that you are right on saying that it is not an obvious choice given the wide number of alternatives, but this is the only way I think you can narrow them to the ones that are really feasible for your project. | [
"sql",
"database"
] | 1 | 8 | 726 | 6 | 0 | 2008-08-27T08:33:18.287000 | 2008-08-27T08:43:45.577000 |
29,744 | 29,801 | How do you manage schema upgrades to a production database? | This seems to be an overlooked area that could really use some insight. What are your best practices for: making an upgrade procedure backing out in case of errors syncing code and database changes testing prior to deployment mechanics of modifying the table etc... | That's a great question. ( There is a high chance this is going to end up a normalised versus denormalised database debate..which I am not going to start... okay now for some input.) some off the top of my head things I have done (will add more when I have some more time or need a break) client design - this is where the VB method of inline sql (even with prepared statements) gets you into trouble. You can spend AGES just finding those statements. If you use something like Hibernate and put as much SQL into named queries you have a single place for most of the sql (nothing worse than trying to test sql that is inside of some IF statement and you just don't hit the "trigger" criteria in your testing for that IF statement). Prior to using hibernate (or other orms') when I would do SQL directly in JDBC or ODBC I would put all the sql statements as either public fields of an object (with a naming convention) or in a property file (also with a naming convention for the values say PREP_STMT_xxxx. And use either reflection or iterate over the values at startup in a) test cases b) startup of the application (some rdbms allow you to pre-compile with prepared statements before execution, so on startup post login I would pre-compile the prep-stmts at startup to make the application self testing. Even for 100's of statements on a good rdbms thats only a few seconds. and only once. And it has saved my butt a lot. On one project the DBA's wouldn't communicate (a different team, in a different country) and the schema seemed to change NIGHTLY, for no reason. And each morning we got a list of exactly where it broke the application, on startup. If you need adhoc functionality, put it in a well named class (ie. again a naming convention helps with auto mated testing) that acts as some sort of factory for you query (ie. it builds the query). You are going to have to write the equivalent code anyway right, just put in a place you can test it. You can even write some basic test methods on the same object or in a separate class. If you can, also try to use stored procedures. They are a bit harder to test as above. Some db's also don't pre-validate the sql in stored procs against the schema at compile time only at run time. It usually involves say taking a copy of the schema structure (no data) and then creating all stored procs against this copy (in case the db team making the changes DIDn't validate correctly). Thus the structure can be checked. but as a point of change management stored procs are great. On change all get it. Especially when the db changes are a result of business process changes. And all languages (java, vb, etc get the change ) I usually also setup a table I use called system_setting etc. In this table we keep a VERSION identifier. This is so that client libraries can connection and validate if they are valid for this version of the schema. Depending on the changes to your schema, you don't want to allow clients to connect if they can corrupt your schema (ie. you don't have a lot of referential rules in the db, but on the client). It depends if you are also going to have multiple client versions (which does happen in NON - web apps, ie. they are running the wrong binary). You could also have batch tools etc. Another approach which I have also done is define a set of schema to operation versions in some sort of property file or again in a system_info table. This table is loaded on login, and then used by each "manager" (I usually have some sort of client side api to do most db stuff) to validate for that operation if it is the right version. Thus most operations can succeed, but you can also fail (throw some exception) on out of date methods and tells you WHY. managing the change to schema -> do you update the table or add 1-1 relationships to new tables? I have seen a lot of shops which always access data via a view for this reason. This allows table names to change, columns etc. I have played with the idea of actually treating views like interfaces in COM. ie. you add a new VIEW for new functionality / versions. Often, what gets you here is that you can have a lot of reports (especially end user custom reports) that assume table formats. The views allow you to deploy a new table format but support existing client apps (remember all those pesky adhoc reports). Also, need to write update and rollback scripts. and again TEST, TEST, TEST... ------------ OKAY - THIS IS A BIT RANDOM DISCUSSION TIME -------------- Actually had a large commercial project (ie. software shop) where we had the same problem. The architecture was a 2 tier and they were using a product a bit like PHP but pre-php. Same thing. different name. anyway i came in in version 2.... It was costing A LOT OF MONEY to do upgrades. A lot. ie. give away weeks of free consulting time on site. And it was getting to the point of wanting to either add new features or optimize the code. Some of the existing code used stored procedures, so we had common points where we could manage code. but other areas were this embedded sql markup in html. Which was great for getting to market quickly but with each interaction of new features the cost at least doubled to test and maintain. So when we were looking at pulling out the php type code out, putting in data layers (this was 2001-2002, pre any ORM's etc) and adding a lot of new features (customer feedback) looked at this issue of how to engineer UPGRADES into the system. Which is a big deal, as upgrades cost a lot of money to do correctly. Now, most patterns and all the other stuff people discuss with a degree of energy deals with OO code that is running, but what about the fact that your data has to a) integrate to this logic, b) the meaning and also the structure of the data can change over time, and often due to the way data works you end up with a lot of sub process / applications in your clients organisation that needs that data -> ad hoc reporting or any complex custom reporting, as well as batch jobs that have been done for custom data feeds etc. With this in mind i started playing with something a bit left of field. It also has a few assumptions. a) data is heavily read more than write. b) updates do happen, but not at bank levels ie. one or 2 a second say. The idea was to apply a COM / Interface view to how data was accessed by clients over a set of CONCRETE tables (which varied with schema changes). You could create a seperate view for each type operation - update, delete, insert and read. This is important. The views would either map directly to a table, or allow you to trigger of a dummy table that does the real updates or inserts etc. What i actually wanted was some sort of trappable level indirection that could still be used by crystal reports etc. NOTE - For inserts, update and deletes you could also use stored procs. And you had a version for each version of the product. That way your version 1.0 had its version of the schema, and if the tables changed, you would still have the version 1.0 VIEWS but with NEW backend logic to map to the new tables as needed, but you also had version 2.0 views that would support new fields etc. This was really just to support ad hoc reporting, which if your a BUSINESS person and not a coder is probably the whole point of why you have the product. (your product can be crap but if you have the best reporting in the world you can still win, the reverse is true - your product can be the best feature wise, but if its the worse on reporting you can very easily loose). okay, hope some of those ideas help. | How do you manage schema upgrades to a production database? This seems to be an overlooked area that could really use some insight. What are your best practices for: making an upgrade procedure backing out in case of errors syncing code and database changes testing prior to deployment mechanics of modifying the table etc... | TITLE:
How do you manage schema upgrades to a production database?
QUESTION:
This seems to be an overlooked area that could really use some insight. What are your best practices for: making an upgrade procedure backing out in case of errors syncing code and database changes testing prior to deployment mechanics of modifying the table etc...
ANSWER:
That's a great question. ( There is a high chance this is going to end up a normalised versus denormalised database debate..which I am not going to start... okay now for some input.) some off the top of my head things I have done (will add more when I have some more time or need a break) client design - this is where the VB method of inline sql (even with prepared statements) gets you into trouble. You can spend AGES just finding those statements. If you use something like Hibernate and put as much SQL into named queries you have a single place for most of the sql (nothing worse than trying to test sql that is inside of some IF statement and you just don't hit the "trigger" criteria in your testing for that IF statement). Prior to using hibernate (or other orms') when I would do SQL directly in JDBC or ODBC I would put all the sql statements as either public fields of an object (with a naming convention) or in a property file (also with a naming convention for the values say PREP_STMT_xxxx. And use either reflection or iterate over the values at startup in a) test cases b) startup of the application (some rdbms allow you to pre-compile with prepared statements before execution, so on startup post login I would pre-compile the prep-stmts at startup to make the application self testing. Even for 100's of statements on a good rdbms thats only a few seconds. and only once. And it has saved my butt a lot. On one project the DBA's wouldn't communicate (a different team, in a different country) and the schema seemed to change NIGHTLY, for no reason. And each morning we got a list of exactly where it broke the application, on startup. If you need adhoc functionality, put it in a well named class (ie. again a naming convention helps with auto mated testing) that acts as some sort of factory for you query (ie. it builds the query). You are going to have to write the equivalent code anyway right, just put in a place you can test it. You can even write some basic test methods on the same object or in a separate class. If you can, also try to use stored procedures. They are a bit harder to test as above. Some db's also don't pre-validate the sql in stored procs against the schema at compile time only at run time. It usually involves say taking a copy of the schema structure (no data) and then creating all stored procs against this copy (in case the db team making the changes DIDn't validate correctly). Thus the structure can be checked. but as a point of change management stored procs are great. On change all get it. Especially when the db changes are a result of business process changes. And all languages (java, vb, etc get the change ) I usually also setup a table I use called system_setting etc. In this table we keep a VERSION identifier. This is so that client libraries can connection and validate if they are valid for this version of the schema. Depending on the changes to your schema, you don't want to allow clients to connect if they can corrupt your schema (ie. you don't have a lot of referential rules in the db, but on the client). It depends if you are also going to have multiple client versions (which does happen in NON - web apps, ie. they are running the wrong binary). You could also have batch tools etc. Another approach which I have also done is define a set of schema to operation versions in some sort of property file or again in a system_info table. This table is loaded on login, and then used by each "manager" (I usually have some sort of client side api to do most db stuff) to validate for that operation if it is the right version. Thus most operations can succeed, but you can also fail (throw some exception) on out of date methods and tells you WHY. managing the change to schema -> do you update the table or add 1-1 relationships to new tables? I have seen a lot of shops which always access data via a view for this reason. This allows table names to change, columns etc. I have played with the idea of actually treating views like interfaces in COM. ie. you add a new VIEW for new functionality / versions. Often, what gets you here is that you can have a lot of reports (especially end user custom reports) that assume table formats. The views allow you to deploy a new table format but support existing client apps (remember all those pesky adhoc reports). Also, need to write update and rollback scripts. and again TEST, TEST, TEST... ------------ OKAY - THIS IS A BIT RANDOM DISCUSSION TIME -------------- Actually had a large commercial project (ie. software shop) where we had the same problem. The architecture was a 2 tier and they were using a product a bit like PHP but pre-php. Same thing. different name. anyway i came in in version 2.... It was costing A LOT OF MONEY to do upgrades. A lot. ie. give away weeks of free consulting time on site. And it was getting to the point of wanting to either add new features or optimize the code. Some of the existing code used stored procedures, so we had common points where we could manage code. but other areas were this embedded sql markup in html. Which was great for getting to market quickly but with each interaction of new features the cost at least doubled to test and maintain. So when we were looking at pulling out the php type code out, putting in data layers (this was 2001-2002, pre any ORM's etc) and adding a lot of new features (customer feedback) looked at this issue of how to engineer UPGRADES into the system. Which is a big deal, as upgrades cost a lot of money to do correctly. Now, most patterns and all the other stuff people discuss with a degree of energy deals with OO code that is running, but what about the fact that your data has to a) integrate to this logic, b) the meaning and also the structure of the data can change over time, and often due to the way data works you end up with a lot of sub process / applications in your clients organisation that needs that data -> ad hoc reporting or any complex custom reporting, as well as batch jobs that have been done for custom data feeds etc. With this in mind i started playing with something a bit left of field. It also has a few assumptions. a) data is heavily read more than write. b) updates do happen, but not at bank levels ie. one or 2 a second say. The idea was to apply a COM / Interface view to how data was accessed by clients over a set of CONCRETE tables (which varied with schema changes). You could create a seperate view for each type operation - update, delete, insert and read. This is important. The views would either map directly to a table, or allow you to trigger of a dummy table that does the real updates or inserts etc. What i actually wanted was some sort of trappable level indirection that could still be used by crystal reports etc. NOTE - For inserts, update and deletes you could also use stored procs. And you had a version for each version of the product. That way your version 1.0 had its version of the schema, and if the tables changed, you would still have the version 1.0 VIEWS but with NEW backend logic to map to the new tables as needed, but you also had version 2.0 views that would support new fields etc. This was really just to support ad hoc reporting, which if your a BUSINESS person and not a coder is probably the whole point of why you have the product. (your product can be crap but if you have the best reporting in the world you can still win, the reverse is true - your product can be the best feature wise, but if its the worse on reporting you can very easily loose). okay, hope some of those ideas help. | [
"oracle",
"database-administration"
] | 34 | 4 | 6,088 | 8 | 0 | 2008-08-27T08:36:37.013000 | 2008-08-27T09:37:14.123000 |
29,746 | 29,755 | Get the Directory sizes on a Remote Host with a PHP script | I'm looking for something that will show me the size of each folder within my main folder recursively. This is a LAMP server with a CGI-Bin so most any PHP script should work or anything that will work in the CGI-Bin. My hosting company does not provide an interface for me to see which folders are consuming the most amount of space. I don't know of anything on the Internet and did a few searches however I came up with no results. Something implementing graphs ( GD / ImageMagick ) would be best but not required. My host supports only Perl in the CGI-BIN. | Strange, I came up on Google with many relevant results and this one is probably the most complete. The function "getDirectorySize" will ignore link/shorcuts to files/directory. The function "sizeFormat" will suffix the size with bytes,KB,MB or GB accordingly. Code function getDirectorySize($path) { $totalsize = 0; $totalcount = 0; $dircount = 0; if ($handle = opendir ($path)) { while (false!== ($file = readdir($handle))) { $nextpath = $path. '/'. $file; if ($file!= '.' && $file!= '..' &&!is_link ($nextpath)) { if (is_dir ($nextpath)) { $dircount++; $result = getDirectorySize($nextpath); $totalsize += $result['size']; $totalcount += $result['count']; $dircount += $result['dircount']; } elseif (is_file ($nextpath)) { $totalsize += filesize ($nextpath); $totalcount++; } } } } closedir ($handle); $total['size'] = $totalsize; $total['count'] = $totalcount; $total['dircount'] = $dircount; return $total; }
function sizeFormat($size) { if($size<1024) { return $size." bytes"; } else if($size<(1024*1024)) { $size=round($size/1024,1); return $size." KB"; } else if($size<(1024*1024*1024)) { $size=round($size/(1024*1024),1); return $size." MB"; } else { $size=round($size/(1024*1024*1024),1); return $size." GB"; }
} Usage $path="/httpd/html/pradeep/"; $ar=getDirectorySize($path);
echo " Details for the path: $path "; echo "Total size: ".sizeFormat($ar['size'])." "; echo "No. of files: ".$ar['count']." "; echo "No. of directories: ".$ar['dircount']." "; Output Details for the path: /httpd/html/pradeep/ Total size: 2.9 MB No. of files: 196 No. of directories: 20 | Get the Directory sizes on a Remote Host with a PHP script I'm looking for something that will show me the size of each folder within my main folder recursively. This is a LAMP server with a CGI-Bin so most any PHP script should work or anything that will work in the CGI-Bin. My hosting company does not provide an interface for me to see which folders are consuming the most amount of space. I don't know of anything on the Internet and did a few searches however I came up with no results. Something implementing graphs ( GD / ImageMagick ) would be best but not required. My host supports only Perl in the CGI-BIN. | TITLE:
Get the Directory sizes on a Remote Host with a PHP script
QUESTION:
I'm looking for something that will show me the size of each folder within my main folder recursively. This is a LAMP server with a CGI-Bin so most any PHP script should work or anything that will work in the CGI-Bin. My hosting company does not provide an interface for me to see which folders are consuming the most amount of space. I don't know of anything on the Internet and did a few searches however I came up with no results. Something implementing graphs ( GD / ImageMagick ) would be best but not required. My host supports only Perl in the CGI-BIN.
ANSWER:
Strange, I came up on Google with many relevant results and this one is probably the most complete. The function "getDirectorySize" will ignore link/shorcuts to files/directory. The function "sizeFormat" will suffix the size with bytes,KB,MB or GB accordingly. Code function getDirectorySize($path) { $totalsize = 0; $totalcount = 0; $dircount = 0; if ($handle = opendir ($path)) { while (false!== ($file = readdir($handle))) { $nextpath = $path. '/'. $file; if ($file!= '.' && $file!= '..' &&!is_link ($nextpath)) { if (is_dir ($nextpath)) { $dircount++; $result = getDirectorySize($nextpath); $totalsize += $result['size']; $totalcount += $result['count']; $dircount += $result['dircount']; } elseif (is_file ($nextpath)) { $totalsize += filesize ($nextpath); $totalcount++; } } } } closedir ($handle); $total['size'] = $totalsize; $total['count'] = $totalcount; $total['dircount'] = $dircount; return $total; }
function sizeFormat($size) { if($size<1024) { return $size." bytes"; } else if($size<(1024*1024)) { $size=round($size/1024,1); return $size." KB"; } else if($size<(1024*1024*1024)) { $size=round($size/(1024*1024),1); return $size." MB"; } else { $size=round($size/(1024*1024*1024),1); return $size." GB"; }
} Usage $path="/httpd/html/pradeep/"; $ar=getDirectorySize($path);
echo " Details for the path: $path "; echo "Total size: ".sizeFormat($ar['size'])." "; echo "No. of files: ".$ar['count']." "; echo "No. of directories: ".$ar['dircount']." "; Output Details for the path: /httpd/html/pradeep/ Total size: 2.9 MB No. of files: 196 No. of directories: 20 | [
"php",
"hosting",
"cgi"
] | 2 | 6 | 1,618 | 3 | 0 | 2008-08-27T08:40:50.530000 | 2008-08-27T08:49:05.547000 |
29,760 | 29,772 | Stopping MSI from launching an EXE in the SYSTEM context | I've got a problem here with an MSI deployment that I'm working on (using InstallShield ). We have a program running in the background that needs to run per-user, and it needs to start automatically without user intervention. The problem is with Group Policy Object / Active Directory (GPO/AD) deployment the application is started in the SYSTEM context before anyone is logged in rather than as the user who is about to log in. The application can only run once per user, and it seems that the SYSTEM process prevents the USER process from starting. This means the PCs need to be rebooted twice before the software can be deployed to the users. How do we to stop this? Basically the current workflow is: Installation/upgrade runs... kill background application Install new files Startup background application This works for published applications and interactive MSI installations - it's only 'assigned' applications that seem to have the problem. As step 3 happens in the SYSTEM context rather than the user context:( Ideally, I'd have the development team patch the EXE file to prevent launching in the SYSTEM context, but that's a release cycle away, and I'm looking for an installer-based solution for the interim. (I don't know Installscript... So I'm guessing VBScript is probably the way to go if there's no native InstallShield stuff I can use.) | You can use the LogonUser property of Windows Installer as a condition to the action launching the EXE. | Stopping MSI from launching an EXE in the SYSTEM context I've got a problem here with an MSI deployment that I'm working on (using InstallShield ). We have a program running in the background that needs to run per-user, and it needs to start automatically without user intervention. The problem is with Group Policy Object / Active Directory (GPO/AD) deployment the application is started in the SYSTEM context before anyone is logged in rather than as the user who is about to log in. The application can only run once per user, and it seems that the SYSTEM process prevents the USER process from starting. This means the PCs need to be rebooted twice before the software can be deployed to the users. How do we to stop this? Basically the current workflow is: Installation/upgrade runs... kill background application Install new files Startup background application This works for published applications and interactive MSI installations - it's only 'assigned' applications that seem to have the problem. As step 3 happens in the SYSTEM context rather than the user context:( Ideally, I'd have the development team patch the EXE file to prevent launching in the SYSTEM context, but that's a release cycle away, and I'm looking for an installer-based solution for the interim. (I don't know Installscript... So I'm guessing VBScript is probably the way to go if there's no native InstallShield stuff I can use.) | TITLE:
Stopping MSI from launching an EXE in the SYSTEM context
QUESTION:
I've got a problem here with an MSI deployment that I'm working on (using InstallShield ). We have a program running in the background that needs to run per-user, and it needs to start automatically without user intervention. The problem is with Group Policy Object / Active Directory (GPO/AD) deployment the application is started in the SYSTEM context before anyone is logged in rather than as the user who is about to log in. The application can only run once per user, and it seems that the SYSTEM process prevents the USER process from starting. This means the PCs need to be rebooted twice before the software can be deployed to the users. How do we to stop this? Basically the current workflow is: Installation/upgrade runs... kill background application Install new files Startup background application This works for published applications and interactive MSI installations - it's only 'assigned' applications that seem to have the problem. As step 3 happens in the SYSTEM context rather than the user context:( Ideally, I'd have the development team patch the EXE file to prevent launching in the SYSTEM context, but that's a release cycle away, and I'm looking for an installer-based solution for the interim. (I don't know Installscript... So I'm guessing VBScript is probably the way to go if there's no native InstallShield stuff I can use.)
ANSWER:
You can use the LogonUser property of Windows Installer as a condition to the action launching the EXE. | [
"installation",
"windows-installer",
"installshield"
] | 3 | 6 | 2,286 | 3 | 0 | 2008-08-27T08:52:35.087000 | 2008-08-27T09:18:24.917000 |
29,761 | 30,768 | Good Git repository viewer for Mac | Can anyone recommend a good repository viewer for Git, similar to gitk, that works on Mac OS X Leopard? (I'm not saying gitk doesn't work) Of course I would like a native Mac application, but as I haven't found any, what are the best options to gitk? I know about gitview, but I'm looking forward to evaluate as many alternatives as possible. http://sourceforge.net/projects/gitview | There's also gitx, it's progressing well and under active development (multiple commits per day). | Good Git repository viewer for Mac Can anyone recommend a good repository viewer for Git, similar to gitk, that works on Mac OS X Leopard? (I'm not saying gitk doesn't work) Of course I would like a native Mac application, but as I haven't found any, what are the best options to gitk? I know about gitview, but I'm looking forward to evaluate as many alternatives as possible. http://sourceforge.net/projects/gitview | TITLE:
Good Git repository viewer for Mac
QUESTION:
Can anyone recommend a good repository viewer for Git, similar to gitk, that works on Mac OS X Leopard? (I'm not saying gitk doesn't work) Of course I would like a native Mac application, but as I haven't found any, what are the best options to gitk? I know about gitview, but I'm looking forward to evaluate as many alternatives as possible. http://sourceforge.net/projects/gitview
ANSWER:
There's also gitx, it's progressing well and under active development (multiple commits per day). | [
"git",
"macos",
"version-control"
] | 16 | 27 | 15,645 | 14 | 0 | 2008-08-27T08:54:50.293000 | 2008-08-27T18:13:49.793000 |
29,777 | 29,780 | Visual Studio 2005 Project options | I have a solution in Visual Studio 2005(professional Edition) which in turn has 8 projects.I am facing a problem that even after i set the Command Arguments in the Project settings of the relevant project, it doesnt accept those command line arguments and it shows argc = 1, inspite of me giving more than 1 command arguments. Tried making the settings of this Solution similar to a working solution, but no success. Any pointers? -Ajit. | Hmm.. Are you sure the specified project is set as the start project (right click > set as startup project)?? Oh, and obviously you need to be in the correct configuration mode ^_^ (Notice it can be changed to debug | build | all configurations ) | Visual Studio 2005 Project options I have a solution in Visual Studio 2005(professional Edition) which in turn has 8 projects.I am facing a problem that even after i set the Command Arguments in the Project settings of the relevant project, it doesnt accept those command line arguments and it shows argc = 1, inspite of me giving more than 1 command arguments. Tried making the settings of this Solution similar to a working solution, but no success. Any pointers? -Ajit. | TITLE:
Visual Studio 2005 Project options
QUESTION:
I have a solution in Visual Studio 2005(professional Edition) which in turn has 8 projects.I am facing a problem that even after i set the Command Arguments in the Project settings of the relevant project, it doesnt accept those command line arguments and it shows argc = 1, inspite of me giving more than 1 command arguments. Tried making the settings of this Solution similar to a working solution, but no success. Any pointers? -Ajit.
ANSWER:
Hmm.. Are you sure the specified project is set as the start project (right click > set as startup project)?? Oh, and obviously you need to be in the correct configuration mode ^_^ (Notice it can be changed to debug | build | all configurations ) | [
"visual-studio-2005",
"projects"
] | 0 | 1 | 251 | 2 | 0 | 2008-08-27T09:21:34.613000 | 2008-08-27T09:23:21.067000 |
29,782 | 29,815 | Windows XP Default Routes | I use my mobile phone for connection to the internet on my laptop, I also have a wired connection to a LAN which doesn't have internet conectivity, it just has our TFS server on it. The problem is that I can't use the internet (from the phone) with the LAN cable plugged in. Is there a way to set the default route to my phone? I'm running Windows XP. | There's many OS specific ways to force routing over specific interfaces. What OS are you using? XP? Vista? *nix? The simplest way is to configure your network card with a static IP and NO GATEWAY, the only gateway (ie. internet access) your laptop will find is then via the mobile. The disadvantage of this method is that you'll need to access your TFS server by IP address (or netbios name) as all DNS requests will be going out over the internet and not through your private LAN. EDIT: If you can't use the phone when the LAN is plugged in, that's because you've got it setup for DHCP and the DHCP server is advertising (incorrectly for you) that it will accept and route internet traffic. As previously mentioned, setup with a static IP and no gateway... if you insist on using DHCP you'll need to learn the ROUTE command in DOS, find the IP address of your phone (assuming it's acting as a router) set that as the default route, and remove whatever default route was assigned from the DHCP server. EDIT2: @dan - you can't use the internet from your phone directly (eg. mobile browser), or you can't make your laptop use your phone for internet when the cable is plugged in? (ie. routing issues)... if it's the former, then your phone is probably configuring a PAN with your phone and trying to route internet back over the LAN EDIT @Jorge - IP routing is the responsibility of the network layer, not the application. Go review the OSI model;) | Windows XP Default Routes I use my mobile phone for connection to the internet on my laptop, I also have a wired connection to a LAN which doesn't have internet conectivity, it just has our TFS server on it. The problem is that I can't use the internet (from the phone) with the LAN cable plugged in. Is there a way to set the default route to my phone? I'm running Windows XP. | TITLE:
Windows XP Default Routes
QUESTION:
I use my mobile phone for connection to the internet on my laptop, I also have a wired connection to a LAN which doesn't have internet conectivity, it just has our TFS server on it. The problem is that I can't use the internet (from the phone) with the LAN cable plugged in. Is there a way to set the default route to my phone? I'm running Windows XP.
ANSWER:
There's many OS specific ways to force routing over specific interfaces. What OS are you using? XP? Vista? *nix? The simplest way is to configure your network card with a static IP and NO GATEWAY, the only gateway (ie. internet access) your laptop will find is then via the mobile. The disadvantage of this method is that you'll need to access your TFS server by IP address (or netbios name) as all DNS requests will be going out over the internet and not through your private LAN. EDIT: If you can't use the phone when the LAN is plugged in, that's because you've got it setup for DHCP and the DHCP server is advertising (incorrectly for you) that it will accept and route internet traffic. As previously mentioned, setup with a static IP and no gateway... if you insist on using DHCP you'll need to learn the ROUTE command in DOS, find the IP address of your phone (assuming it's acting as a router) set that as the default route, and remove whatever default route was assigned from the DHCP server. EDIT2: @dan - you can't use the internet from your phone directly (eg. mobile browser), or you can't make your laptop use your phone for internet when the cable is plugged in? (ie. routing issues)... if it's the former, then your phone is probably configuring a PAN with your phone and trying to route internet back over the LAN EDIT @Jorge - IP routing is the responsibility of the network layer, not the application. Go review the OSI model;) | [
"windows",
"networking",
"tcp"
] | 0 | 2 | 453 | 2 | 0 | 2008-08-27T09:25:45.257000 | 2008-08-27T09:44:18.287000 |
29,806 | 29,813 | How to change Instantiated Objects Font Colour in Visual Studio | I know the colours are changed in Environment > Fonts and Colors but I haven't found out which Display Item the object is. Can someone please tell how I can colour the following code: lblMessage.Text = "You have successfully answered my question!" I have the string coloured pink, I would like the lblMessage purple and the.Text a light green. For me the darker the colour the less it will "change". I won't often change object names, I'll more often change properties and am always changing strings - although I have another question about this that I'll post later. Thanks | Go to Environment > Fonts and Colors > Display Item s and change Identifier String I was hoping that their is I can be more specific with the colours - if their isn't then that's an acceptable answer - just disappointing for me. Yeah, I don't think you can do that.:) | How to change Instantiated Objects Font Colour in Visual Studio I know the colours are changed in Environment > Fonts and Colors but I haven't found out which Display Item the object is. Can someone please tell how I can colour the following code: lblMessage.Text = "You have successfully answered my question!" I have the string coloured pink, I would like the lblMessage purple and the.Text a light green. For me the darker the colour the less it will "change". I won't often change object names, I'll more often change properties and am always changing strings - although I have another question about this that I'll post later. Thanks | TITLE:
How to change Instantiated Objects Font Colour in Visual Studio
QUESTION:
I know the colours are changed in Environment > Fonts and Colors but I haven't found out which Display Item the object is. Can someone please tell how I can colour the following code: lblMessage.Text = "You have successfully answered my question!" I have the string coloured pink, I would like the lblMessage purple and the.Text a light green. For me the darker the colour the less it will "change". I won't often change object names, I'll more often change properties and am always changing strings - although I have another question about this that I'll post later. Thanks
ANSWER:
Go to Environment > Fonts and Colors > Display Item s and change Identifier String I was hoping that their is I can be more specific with the colours - if their isn't then that's an acceptable answer - just disappointing for me. Yeah, I don't think you can do that.:) | [
"visual-studio-2005",
"colors",
"environment"
] | 0 | 1 | 1,768 | 2 | 0 | 2008-08-27T09:40:00.107000 | 2008-08-27T09:43:49.550000 |
29,810 | 29,837 | Is version control (ie. Subversion) applicable in document tracking? | I am in charge of about 100+ documents (word document, not source code) that needs revision by different people in my department. Currently all the documents are in a shared folder where they will retrieve, revise and save back into the folder. What I am doing now is looking up the "date modified" in the shared folder, opened up recent modified documents and use the "Track Change" function in MS Word to apply the changes. I find this a bit tedious. So will it be better and easier if I commit this in a version control database? Basically I want to keep different version of a file. What have I learn from answers: Use Time Machine to save different version (or Shadow copy in Vista) There is a difference between text and binary documents when you use version control app. (I didn't know that) Diff won't work on binary files A notification system (ie email) for revision is great Google Docs revision feature. Update: I played around with Google Docs revision feature and feel that it is almost right for me. Just a bit annoyed with the too frequent versioning (autosaving). But what feels right for me doesn't mean it feels right for my dept. Will they be okay with saving all these documents with Google? | I guess one thing that nobody seems to have asked is if you have a legal requirement to store history of changes to the doc's? Whether you do or don't is going to have an impact on what solutions you can consider. Also a notification mechanism for out of date copies is also a bundle of fun. If engineer A has a copy of a document and engineer B then edits it and commits the changes you want engineer A to be notified that his copy is out of date. Document control can become a real can of worms quite easily. Maybe keep the doc's under CVS or SVN and set it up so that emails are generated to whoever has checked out a copy when updates for the same doc. are checked in to the repository? Edit: I forgot to add don't forget to use the binary switch, e.g. -kb for CVS, when adding the new doc. Otherwise, you will get any sequences of data that happen to match the ascii for keyword strings having the relevant config management data appended thereby corrupting your doc. data. | Is version control (ie. Subversion) applicable in document tracking? I am in charge of about 100+ documents (word document, not source code) that needs revision by different people in my department. Currently all the documents are in a shared folder where they will retrieve, revise and save back into the folder. What I am doing now is looking up the "date modified" in the shared folder, opened up recent modified documents and use the "Track Change" function in MS Word to apply the changes. I find this a bit tedious. So will it be better and easier if I commit this in a version control database? Basically I want to keep different version of a file. What have I learn from answers: Use Time Machine to save different version (or Shadow copy in Vista) There is a difference between text and binary documents when you use version control app. (I didn't know that) Diff won't work on binary files A notification system (ie email) for revision is great Google Docs revision feature. Update: I played around with Google Docs revision feature and feel that it is almost right for me. Just a bit annoyed with the too frequent versioning (autosaving). But what feels right for me doesn't mean it feels right for my dept. Will they be okay with saving all these documents with Google? | TITLE:
Is version control (ie. Subversion) applicable in document tracking?
QUESTION:
I am in charge of about 100+ documents (word document, not source code) that needs revision by different people in my department. Currently all the documents are in a shared folder where they will retrieve, revise and save back into the folder. What I am doing now is looking up the "date modified" in the shared folder, opened up recent modified documents and use the "Track Change" function in MS Word to apply the changes. I find this a bit tedious. So will it be better and easier if I commit this in a version control database? Basically I want to keep different version of a file. What have I learn from answers: Use Time Machine to save different version (or Shadow copy in Vista) There is a difference between text and binary documents when you use version control app. (I didn't know that) Diff won't work on binary files A notification system (ie email) for revision is great Google Docs revision feature. Update: I played around with Google Docs revision feature and feel that it is almost right for me. Just a bit annoyed with the too frequent versioning (autosaving). But what feels right for me doesn't mean it feels right for my dept. Will they be okay with saving all these documents with Google?
ANSWER:
I guess one thing that nobody seems to have asked is if you have a legal requirement to store history of changes to the doc's? Whether you do or don't is going to have an impact on what solutions you can consider. Also a notification mechanism for out of date copies is also a bundle of fun. If engineer A has a copy of a document and engineer B then edits it and commits the changes you want engineer A to be notified that his copy is out of date. Document control can become a real can of worms quite easily. Maybe keep the doc's under CVS or SVN and set it up so that emails are generated to whoever has checked out a copy when updates for the same doc. are checked in to the repository? Edit: I forgot to add don't forget to use the binary switch, e.g. -kb for CVS, when adding the new doc. Otherwise, you will get any sequences of data that happen to match the ascii for keyword strings having the relevant config management data appended thereby corrupting your doc. data. | [
"version-control",
"tracking"
] | 75 | 19 | 45,799 | 20 | 0 | 2008-08-27T09:42:59.710000 | 2008-08-27T10:01:47.277000 |
29,814 | 29,906 | How to do crossdomain calls from Silverlight? | What's needed to succesfully make a crossdomain call from Silverlight? | If I understand your question correctly you would need to have a clientaccesspolicy.xml file in the domain web root of the server that you wish to call (ie www.example.com/clientaccesspolicy.xml) that defines that it is ok for services from other domains to call services on that domain. Read the How to Make a Service Available Across Domain Boundaries MSDN article for more detailed information. | How to do crossdomain calls from Silverlight? What's needed to succesfully make a crossdomain call from Silverlight? | TITLE:
How to do crossdomain calls from Silverlight?
QUESTION:
What's needed to succesfully make a crossdomain call from Silverlight?
ANSWER:
If I understand your question correctly you would need to have a clientaccesspolicy.xml file in the domain web root of the server that you wish to call (ie www.example.com/clientaccesspolicy.xml) that defines that it is ok for services from other domains to call services on that domain. Read the How to Make a Service Available Across Domain Boundaries MSDN article for more detailed information. | [
"silverlight",
"web-services"
] | 5 | 5 | 858 | 4 | 0 | 2008-08-27T09:44:06.023000 | 2008-08-27T11:07:19.943000 |
29,820 | 29,826 | Java return copy to hide future changes | In Java, say you have a class that wraps an ArrayList (or any collection) of objects. How would you return one of those objects such that the caller will not see any future changes to the object made in the ArrayList? i.e. you want to return a deep copy of the object, but you don't know if it is cloneable. | Turn that into a spec: -that objects need to implement an interface in order to be allowed into the collection Something like ArrayList () Then you can be assured that you always do a deep copy - the interface should have a method that is guaranteed to return a deep copy. I think that's the best you can do. | Java return copy to hide future changes In Java, say you have a class that wraps an ArrayList (or any collection) of objects. How would you return one of those objects such that the caller will not see any future changes to the object made in the ArrayList? i.e. you want to return a deep copy of the object, but you don't know if it is cloneable. | TITLE:
Java return copy to hide future changes
QUESTION:
In Java, say you have a class that wraps an ArrayList (or any collection) of objects. How would you return one of those objects such that the caller will not see any future changes to the object made in the ArrayList? i.e. you want to return a deep copy of the object, but you don't know if it is cloneable.
ANSWER:
Turn that into a spec: -that objects need to implement an interface in order to be allowed into the collection Something like ArrayList () Then you can be assured that you always do a deep copy - the interface should have a method that is guaranteed to return a deep copy. I think that's the best you can do. | [
"java",
"deep-copy",
"cloning"
] | 5 | 4 | 1,094 | 3 | 0 | 2008-08-27T09:48:00.960000 | 2008-08-27T09:52:49.997000 |
29,822 | 29,904 | Giant NodeManagerLogs from hibernate in weblogic | One of our weblogic 8.1s has suddenly started logging giant amounts of logs and filling the disk. The logs giving us hassle resides in mydrive:\bea\weblogic81\common\nodemanager\NodeManagerLogs\generatedManagedServer1\managedserveroutput.log and the entries in the logfile is just the some kind of entries repeated again and again. Stuff like 19:21:24,470 DEBUG [StdRowLockSemaphore] Lock 'TRIGGER_ACCESS' returned by: LLL-SCHEDULER_QuartzSchedulerThread 19:21:31,923 DEBUG [StdRowLockSemaphore] Lock 'STATE_ACCESS' is deLLLred by: QuartzScheduler_LLL-SCHEDULER-NACDLLLF011219763113220_ClusterManager 19:21:31,923 DEBUG [StdRowLockSemaphore] Lock 'STATE_ACCESS' is being obtained: QuartzScheduler_LLL-SCHEDULER-NACDLLLF011219763113220_ClusterManager 19:21:31,923 DEBUG [StdRowLockSemaphore] Lock 'STATE_ACCESS' given to: QuartzScheduler_LLL-SCHEDULER-NACDLLLF011219763113220_ClusterManager 19:21:31,923 DEBUG [StdRowLockSemaphore] Lock 'TRIGGER_ACCESS' is deLLLred by: QuartzScheduler_LLL-SCHEDULER-NACDLLLF011219763113220_ClusterManager... 19:17:46,798 DEBUG [CascadingAction] cascading to saveOrUpdate: mypackage.config.common.Share 19:17:46,798 DEBUG [DefaultSaveOrUpdateEventListener] reassociated uninitialized proxy 19:17:46,798 DEBUG [Cascade] done processing cascade ACTION_SAVE_UPDATE for: mypackage.config.common.FileLocation 19:17:46,798 DEBUG [Cascade] processing cascade ACTION_SAVE_UPDATE for: mypackage.config.common.FileLocation 19:17:46,798 DEBUG [CascadingAction] cascading to saveOrUpdate: mypackage.config.common.Share 19:17:46,798 DEBUG [DefaultSaveOrUpdateEventListener] reassociated uninitialized proxy I can't find any debug settings set anywhere. I've looked in the Remote Start classpath and Arguments for the managed server. Can anyone point me in the direction to gain control over this logfile? | Since those log entries aren't problems, it sounds like the global log level has been turned up to DEBUG. Alternatively, perhaps a new Logging mechanism has been implemented or a new log Appender that writes to stdout, and thus is being re-logged by Weblogic. I would look at the configuration of your logger. (Or provide it with one, if it is using a default config) For example, when using Hibernate with an active Log4J setup, Hibernate will automatically join in with the Log4J instance that you set up in your own application It can be tuned, as per the normal Log4J config. This example uses the properties configuration style: log4j.category.org.hibernate=WARN Hibernate may join in with other logging mechanisms via the apache commons logging API. Look at how to configure your own logger and tune out the org.hibernate.* frequencies. n.b. When debugging, switching back on log4j.category.org.hibernate.SQL=INFO or DEBUG can be useful. | Giant NodeManagerLogs from hibernate in weblogic One of our weblogic 8.1s has suddenly started logging giant amounts of logs and filling the disk. The logs giving us hassle resides in mydrive:\bea\weblogic81\common\nodemanager\NodeManagerLogs\generatedManagedServer1\managedserveroutput.log and the entries in the logfile is just the some kind of entries repeated again and again. Stuff like 19:21:24,470 DEBUG [StdRowLockSemaphore] Lock 'TRIGGER_ACCESS' returned by: LLL-SCHEDULER_QuartzSchedulerThread 19:21:31,923 DEBUG [StdRowLockSemaphore] Lock 'STATE_ACCESS' is deLLLred by: QuartzScheduler_LLL-SCHEDULER-NACDLLLF011219763113220_ClusterManager 19:21:31,923 DEBUG [StdRowLockSemaphore] Lock 'STATE_ACCESS' is being obtained: QuartzScheduler_LLL-SCHEDULER-NACDLLLF011219763113220_ClusterManager 19:21:31,923 DEBUG [StdRowLockSemaphore] Lock 'STATE_ACCESS' given to: QuartzScheduler_LLL-SCHEDULER-NACDLLLF011219763113220_ClusterManager 19:21:31,923 DEBUG [StdRowLockSemaphore] Lock 'TRIGGER_ACCESS' is deLLLred by: QuartzScheduler_LLL-SCHEDULER-NACDLLLF011219763113220_ClusterManager... 19:17:46,798 DEBUG [CascadingAction] cascading to saveOrUpdate: mypackage.config.common.Share 19:17:46,798 DEBUG [DefaultSaveOrUpdateEventListener] reassociated uninitialized proxy 19:17:46,798 DEBUG [Cascade] done processing cascade ACTION_SAVE_UPDATE for: mypackage.config.common.FileLocation 19:17:46,798 DEBUG [Cascade] processing cascade ACTION_SAVE_UPDATE for: mypackage.config.common.FileLocation 19:17:46,798 DEBUG [CascadingAction] cascading to saveOrUpdate: mypackage.config.common.Share 19:17:46,798 DEBUG [DefaultSaveOrUpdateEventListener] reassociated uninitialized proxy I can't find any debug settings set anywhere. I've looked in the Remote Start classpath and Arguments for the managed server. Can anyone point me in the direction to gain control over this logfile? | TITLE:
Giant NodeManagerLogs from hibernate in weblogic
QUESTION:
One of our weblogic 8.1s has suddenly started logging giant amounts of logs and filling the disk. The logs giving us hassle resides in mydrive:\bea\weblogic81\common\nodemanager\NodeManagerLogs\generatedManagedServer1\managedserveroutput.log and the entries in the logfile is just the some kind of entries repeated again and again. Stuff like 19:21:24,470 DEBUG [StdRowLockSemaphore] Lock 'TRIGGER_ACCESS' returned by: LLL-SCHEDULER_QuartzSchedulerThread 19:21:31,923 DEBUG [StdRowLockSemaphore] Lock 'STATE_ACCESS' is deLLLred by: QuartzScheduler_LLL-SCHEDULER-NACDLLLF011219763113220_ClusterManager 19:21:31,923 DEBUG [StdRowLockSemaphore] Lock 'STATE_ACCESS' is being obtained: QuartzScheduler_LLL-SCHEDULER-NACDLLLF011219763113220_ClusterManager 19:21:31,923 DEBUG [StdRowLockSemaphore] Lock 'STATE_ACCESS' given to: QuartzScheduler_LLL-SCHEDULER-NACDLLLF011219763113220_ClusterManager 19:21:31,923 DEBUG [StdRowLockSemaphore] Lock 'TRIGGER_ACCESS' is deLLLred by: QuartzScheduler_LLL-SCHEDULER-NACDLLLF011219763113220_ClusterManager... 19:17:46,798 DEBUG [CascadingAction] cascading to saveOrUpdate: mypackage.config.common.Share 19:17:46,798 DEBUG [DefaultSaveOrUpdateEventListener] reassociated uninitialized proxy 19:17:46,798 DEBUG [Cascade] done processing cascade ACTION_SAVE_UPDATE for: mypackage.config.common.FileLocation 19:17:46,798 DEBUG [Cascade] processing cascade ACTION_SAVE_UPDATE for: mypackage.config.common.FileLocation 19:17:46,798 DEBUG [CascadingAction] cascading to saveOrUpdate: mypackage.config.common.Share 19:17:46,798 DEBUG [DefaultSaveOrUpdateEventListener] reassociated uninitialized proxy I can't find any debug settings set anywhere. I've looked in the Remote Start classpath and Arguments for the managed server. Can anyone point me in the direction to gain control over this logfile?
ANSWER:
Since those log entries aren't problems, it sounds like the global log level has been turned up to DEBUG. Alternatively, perhaps a new Logging mechanism has been implemented or a new log Appender that writes to stdout, and thus is being re-logged by Weblogic. I would look at the configuration of your logger. (Or provide it with one, if it is using a default config) For example, when using Hibernate with an active Log4J setup, Hibernate will automatically join in with the Log4J instance that you set up in your own application It can be tuned, as per the normal Log4J config. This example uses the properties configuration style: log4j.category.org.hibernate=WARN Hibernate may join in with other logging mechanisms via the apache commons logging API. Look at how to configure your own logger and tune out the org.hibernate.* frequencies. n.b. When debugging, switching back on log4j.category.org.hibernate.SQL=INFO or DEBUG can be useful. | [
"hibernate",
"logging",
"weblogic"
] | 2 | 2 | 664 | 2 | 0 | 2008-08-27T09:50:27.460000 | 2008-08-27T11:05:59.917000 |
29,838 | 29,854 | Visual Source Safe --> TFS Migration | Around here we have been working with a bunch of Visual Source Safe repositories for about 10 years or so. Now I want to get rid of sourcesafe and move on to Team Foundation Server. Do you have any tips or tricks for me before I embark on this migration? What are the things I have to be careful about? I am sure this migration will mean that our working habits have to be modified in some way. Do you think that these changes could be a problem for the organization? Think about a group of about 20.NET developers in a single site. | I just googled, but this walkthrough seems like a good reference, and it mentions the tool VSSConverter which should help you make the migration as painless as possible. I would like to recommend one thing though: Backup. Backup everything before you do this. Should anything go wrong it's better to be safe than sorry. My links aren't showing up. This is the address: http://msdn.microsoft.com/en-us/library/ms181247(VS.80).aspx | Visual Source Safe --> TFS Migration Around here we have been working with a bunch of Visual Source Safe repositories for about 10 years or so. Now I want to get rid of sourcesafe and move on to Team Foundation Server. Do you have any tips or tricks for me before I embark on this migration? What are the things I have to be careful about? I am sure this migration will mean that our working habits have to be modified in some way. Do you think that these changes could be a problem for the organization? Think about a group of about 20.NET developers in a single site. | TITLE:
Visual Source Safe --> TFS Migration
QUESTION:
Around here we have been working with a bunch of Visual Source Safe repositories for about 10 years or so. Now I want to get rid of sourcesafe and move on to Team Foundation Server. Do you have any tips or tricks for me before I embark on this migration? What are the things I have to be careful about? I am sure this migration will mean that our working habits have to be modified in some way. Do you think that these changes could be a problem for the organization? Think about a group of about 20.NET developers in a single site.
ANSWER:
I just googled, but this walkthrough seems like a good reference, and it mentions the tool VSSConverter which should help you make the migration as painless as possible. I would like to recommend one thing though: Backup. Backup everything before you do this. Should anything go wrong it's better to be safe than sorry. My links aren't showing up. This is the address: http://msdn.microsoft.com/en-us/library/ms181247(VS.80).aspx | [
"version-control",
"tfs",
"visual-sourcesafe",
"vssconverter"
] | 16 | 2 | 11,523 | 8 | 0 | 2008-08-27T10:02:57.103000 | 2008-08-27T10:20:38.153000 |
29,841 | 29,920 | Thread not waking up from Thread.Sleep() | We have a Windows Service written in C#. The service spawns a thread that does this: private void ThreadWorkerFunction() { while(false == _stop) // stop flag set by other thread { try { openConnection();
doStuff();
closeConnection(); } catch (Exception ex) { log.Error("Something went wrong.", ex);
Thread.Sleep(TimeSpan.FromMinutes(10)); } } } We put the Thread.Sleep in after a couple of times when the database had gone away and we came back to 3Gb logs files full of database connection errors. This has been running fine for months, but recently we've seen a few instances where the log.Error() statement logs a "System.InvalidOperationException: This SqlTransaction has completed; it is no longer usable" exception and then never ever comes back. The service can be left running for days but nothing more will be logged. Having done some reading I know that Thread.Sleep is not ideal, but why would it simply never come back? | Dig in and find out? Stick a debugger on that bastard! I can see at least the following possibilities: the logging system hangs; the thread exited just fine but the service is still running because some other part has a logic error. And maybe, but almost certainly not, the following: Sleep() hangs. But in any case, attaching a debugger will show you whether the thread is still there and whether it really has hung. | Thread not waking up from Thread.Sleep() We have a Windows Service written in C#. The service spawns a thread that does this: private void ThreadWorkerFunction() { while(false == _stop) // stop flag set by other thread { try { openConnection();
doStuff();
closeConnection(); } catch (Exception ex) { log.Error("Something went wrong.", ex);
Thread.Sleep(TimeSpan.FromMinutes(10)); } } } We put the Thread.Sleep in after a couple of times when the database had gone away and we came back to 3Gb logs files full of database connection errors. This has been running fine for months, but recently we've seen a few instances where the log.Error() statement logs a "System.InvalidOperationException: This SqlTransaction has completed; it is no longer usable" exception and then never ever comes back. The service can be left running for days but nothing more will be logged. Having done some reading I know that Thread.Sleep is not ideal, but why would it simply never come back? | TITLE:
Thread not waking up from Thread.Sleep()
QUESTION:
We have a Windows Service written in C#. The service spawns a thread that does this: private void ThreadWorkerFunction() { while(false == _stop) // stop flag set by other thread { try { openConnection();
doStuff();
closeConnection(); } catch (Exception ex) { log.Error("Something went wrong.", ex);
Thread.Sleep(TimeSpan.FromMinutes(10)); } } } We put the Thread.Sleep in after a couple of times when the database had gone away and we came back to 3Gb logs files full of database connection errors. This has been running fine for months, but recently we've seen a few instances where the log.Error() statement logs a "System.InvalidOperationException: This SqlTransaction has completed; it is no longer usable" exception and then never ever comes back. The service can be left running for days but nothing more will be logged. Having done some reading I know that Thread.Sleep is not ideal, but why would it simply never come back?
ANSWER:
Dig in and find out? Stick a debugger on that bastard! I can see at least the following possibilities: the logging system hangs; the thread exited just fine but the service is still running because some other part has a logic error. And maybe, but almost certainly not, the following: Sleep() hangs. But in any case, attaching a debugger will show you whether the thread is still there and whether it really has hung. | [
".net",
"multithreading"
] | 5 | 5 | 5,258 | 8 | 0 | 2008-08-27T10:05:02.963000 | 2008-08-27T11:29:58.797000 |
29,845 | 29,866 | Dynamic reference to resource files in C# | I have an application on which I am implementing localization. I now need to dynamically reference a name in the resouce file. assume I have a resource file called Login.resx, an a number of strings: foo="hello", bar="cruel" and baz="world" normally, I will refer as: String result =Login.foo; and result=="hello"; my problem is, that at code time, I do not know if I want to refer to foo, bar or baz - I have a string that contains either "foo", "bar" or "baz". I need something like: Login["foo"]; Does anyone know if there is any way to dynamically reference a string in a resource file? | You'll need to instance a ResourceManager for the Login.resx: var resman = new System.Resources.ResourceManager( "RootNamespace.Login", System.Reflection.Assembly.GetExecutingAssembly() ) var text = resman.GetString("resname"); It might help to look at the generated code in the code-behind files of the resource files that are created by the IDE. These files basically contain readonly properties for each resource that makes a query to an internal resource manager. | Dynamic reference to resource files in C# I have an application on which I am implementing localization. I now need to dynamically reference a name in the resouce file. assume I have a resource file called Login.resx, an a number of strings: foo="hello", bar="cruel" and baz="world" normally, I will refer as: String result =Login.foo; and result=="hello"; my problem is, that at code time, I do not know if I want to refer to foo, bar or baz - I have a string that contains either "foo", "bar" or "baz". I need something like: Login["foo"]; Does anyone know if there is any way to dynamically reference a string in a resource file? | TITLE:
Dynamic reference to resource files in C#
QUESTION:
I have an application on which I am implementing localization. I now need to dynamically reference a name in the resouce file. assume I have a resource file called Login.resx, an a number of strings: foo="hello", bar="cruel" and baz="world" normally, I will refer as: String result =Login.foo; and result=="hello"; my problem is, that at code time, I do not know if I want to refer to foo, bar or baz - I have a string that contains either "foo", "bar" or "baz". I need something like: Login["foo"]; Does anyone know if there is any way to dynamically reference a string in a resource file?
ANSWER:
You'll need to instance a ResourceManager for the Login.resx: var resman = new System.Resources.ResourceManager( "RootNamespace.Login", System.Reflection.Assembly.GetExecutingAssembly() ) var text = resman.GetString("resname"); It might help to look at the generated code in the code-behind files of the resource files that are created by the IDE. These files basically contain readonly properties for each resource that makes a query to an internal resource manager. | [
"c#",
"localization"
] | 14 | 20 | 21,078 | 2 | 0 | 2008-08-27T10:12:08.657000 | 2008-08-27T10:35:46.290000 |
29,847 | 29,862 | Get last item in a table - SQL | I have a History Table in SQL Server that basically tracks an item through a process. The item has some fixed fields that don't change throughout the process, but has a few other fields including status and Id which increment as the steps of the process increase. Basically I want to retrieve the last step for each item given a Batch Reference. So if I do a Select * from HistoryTable where BatchRef = @BatchRef It will return all the steps for all the items in the batch - eg Id Status BatchRef ItemCount 1 1 Batch001 100 1 2 Batch001 110 2 1 Batch001 60 2 2 Batch001 100 But what I really want is: Id Status BatchRef ItemCount 1 2 Batch001 110 2 2 Batch001 100 Edit: Appologies - can't seem to get the TABLE tags to work with Markdown - followed the help to the letter, and looks fine in the preview | It's kind of hard to make sense of your table design - I think SO ate your delimiters. The basic way of handling this is to GROUP BY your fixed fields, and select a MAX (or MIN) for some unqiue value (a datetime usually works well). In your case, I think that the GROUP BY would be BatchRef and ItemCount, and Id will be your unique column. Then, join back to the table to get all columns. Something like: SELECT * FROM HistoryTable JOIN ( SELECT MAX(Id) as Id. BatchRef, ItemCount FROM HsitoryTable WHERE BacthRef = @batchRef GROUP BY BatchRef, ItemCount ) as Latest ON HistoryTable.Id = Latest.Id | Get last item in a table - SQL I have a History Table in SQL Server that basically tracks an item through a process. The item has some fixed fields that don't change throughout the process, but has a few other fields including status and Id which increment as the steps of the process increase. Basically I want to retrieve the last step for each item given a Batch Reference. So if I do a Select * from HistoryTable where BatchRef = @BatchRef It will return all the steps for all the items in the batch - eg Id Status BatchRef ItemCount 1 1 Batch001 100 1 2 Batch001 110 2 1 Batch001 60 2 2 Batch001 100 But what I really want is: Id Status BatchRef ItemCount 1 2 Batch001 110 2 2 Batch001 100 Edit: Appologies - can't seem to get the TABLE tags to work with Markdown - followed the help to the letter, and looks fine in the preview | TITLE:
Get last item in a table - SQL
QUESTION:
I have a History Table in SQL Server that basically tracks an item through a process. The item has some fixed fields that don't change throughout the process, but has a few other fields including status and Id which increment as the steps of the process increase. Basically I want to retrieve the last step for each item given a Batch Reference. So if I do a Select * from HistoryTable where BatchRef = @BatchRef It will return all the steps for all the items in the batch - eg Id Status BatchRef ItemCount 1 1 Batch001 100 1 2 Batch001 110 2 1 Batch001 60 2 2 Batch001 100 But what I really want is: Id Status BatchRef ItemCount 1 2 Batch001 110 2 2 Batch001 100 Edit: Appologies - can't seem to get the TABLE tags to work with Markdown - followed the help to the letter, and looks fine in the preview
ANSWER:
It's kind of hard to make sense of your table design - I think SO ate your delimiters. The basic way of handling this is to GROUP BY your fixed fields, and select a MAX (or MIN) for some unqiue value (a datetime usually works well). In your case, I think that the GROUP BY would be BatchRef and ItemCount, and Id will be your unique column. Then, join back to the table to get all columns. Something like: SELECT * FROM HistoryTable JOIN ( SELECT MAX(Id) as Id. BatchRef, ItemCount FROM HsitoryTable WHERE BacthRef = @batchRef GROUP BY BatchRef, ItemCount ) as Latest ON HistoryTable.Id = Latest.Id | [
"sql",
"sql-server",
"database",
"t-sql"
] | 4 | 7 | 17,866 | 6 | 0 | 2008-08-27T10:13:16.220000 | 2008-08-27T10:29:03.920000 |
29,855 | 29,859 | Is there a wxWidgets framework for C? | My understanding is that wxWidgets is for a number of programming languages (C++, Python, Perl, and C#/.NET) but that does not include C. Is there a similar framework for the C programming language, or is this not something that C is used for? | You can try GTK+. I believe wxWidgets implementation for linux is written in GTK+. | Is there a wxWidgets framework for C? My understanding is that wxWidgets is for a number of programming languages (C++, Python, Perl, and C#/.NET) but that does not include C. Is there a similar framework for the C programming language, or is this not something that C is used for? | TITLE:
Is there a wxWidgets framework for C?
QUESTION:
My understanding is that wxWidgets is for a number of programming languages (C++, Python, Perl, and C#/.NET) but that does not include C. Is there a similar framework for the C programming language, or is this not something that C is used for?
ANSWER:
You can try GTK+. I believe wxWidgets implementation for linux is written in GTK+. | [
"c",
"user-interface"
] | 5 | 2 | 9,921 | 3 | 0 | 2008-08-27T10:21:16.433000 | 2008-08-27T10:24:54.430000 |
29,856 | 31,384 | Install Python to match directory layout in OS X 10.5 | The default Python install on OS X 10.5 is 2.5.1 with a FAT 32 bit (Intel and PPC) client. I want to setup apache and mysql to run django. In the past, I have run Apache and MySQL to match this install in 32 bit mode (even stripping out the 64 bit stuff from Apache to make it work). I want to upgrade Python to 64 bit. I am completely comfortable with compiling it from source with one caveat. How do I match the way that the default install is laid out? Especially, with regards to site-packages being in /Library/Python/2.5/ and not the one in buried at the top of the framework once I compile it. | Personally, I wouldn't worry about it until you see a problem. Messing with the default python install on a *Nix system can cause more trouble than it's worth. I can say from personal experience that you never truly understand what python has done for the nix world until you have a problem with it. You can also add a second python installation, but that also causes more problems than it's worth IMO. So I suppose the best question to start out with would be why exactly do you want to use the 64 bit version of python? | Install Python to match directory layout in OS X 10.5 The default Python install on OS X 10.5 is 2.5.1 with a FAT 32 bit (Intel and PPC) client. I want to setup apache and mysql to run django. In the past, I have run Apache and MySQL to match this install in 32 bit mode (even stripping out the 64 bit stuff from Apache to make it work). I want to upgrade Python to 64 bit. I am completely comfortable with compiling it from source with one caveat. How do I match the way that the default install is laid out? Especially, with regards to site-packages being in /Library/Python/2.5/ and not the one in buried at the top of the framework once I compile it. | TITLE:
Install Python to match directory layout in OS X 10.5
QUESTION:
The default Python install on OS X 10.5 is 2.5.1 with a FAT 32 bit (Intel and PPC) client. I want to setup apache and mysql to run django. In the past, I have run Apache and MySQL to match this install in 32 bit mode (even stripping out the 64 bit stuff from Apache to make it work). I want to upgrade Python to 64 bit. I am completely comfortable with compiling it from source with one caveat. How do I match the way that the default install is laid out? Especially, with regards to site-packages being in /Library/Python/2.5/ and not the one in buried at the top of the framework once I compile it.
ANSWER:
Personally, I wouldn't worry about it until you see a problem. Messing with the default python install on a *Nix system can cause more trouble than it's worth. I can say from personal experience that you never truly understand what python has done for the nix world until you have a problem with it. You can also add a second python installation, but that also causes more problems than it's worth IMO. So I suppose the best question to start out with would be why exactly do you want to use the 64 bit version of python? | [
"python",
"macos",
"64-bit"
] | 4 | 1 | 679 | 5 | 0 | 2008-08-27T10:22:09.427000 | 2008-08-28T00:09:56.910000 |
29,869 | 29,917 | Regex to match all HTML tags except <p> and </p> | I need to match and remove all tags using a regular expression in Perl. I have the following: <\\??(?!p).+?> But this still matches with the closing tag. Any hint on how to match with the closing tag as well? Note, this is being performed on xhtml. | I came up with this: <(?!\/?p(?=>|\s.*>))\/?.*?>
x/ < # Match open angle bracket (?! # Negative lookahead (Not matching and not consuming) \/? # 0 or 1 / p # p (?= # Positive lookahead (Matching and not consuming) > # > - No attributes | # or \s # whitespace.* # anything up to > # close angle brackets - with attributes ) # close positive lookahead ) # close negative lookahead # if we have got this far then we don't match # a p tag or closing p tag # with or without attributes \/? # optional close tag symbol (/).*? # and anything up to > # first closing tag / This will now deal with p tags with or without attributes and the closing p tags, but will match pre and similar tags, with or without attributes. It doesn't strip out attributes, but my source data does not put them in. I may change this later to do this, but this will suffice for now. | Regex to match all HTML tags except <p> and </p> I need to match and remove all tags using a regular expression in Perl. I have the following: <\\??(?!p).+?> But this still matches with the closing tag. Any hint on how to match with the closing tag as well? Note, this is being performed on xhtml. | TITLE:
Regex to match all HTML tags except <p> and </p>
QUESTION:
I need to match and remove all tags using a regular expression in Perl. I have the following: <\\??(?!p).+?> But this still matches with the closing tag. Any hint on how to match with the closing tag as well? Note, this is being performed on xhtml.
ANSWER:
I came up with this: <(?!\/?p(?=>|\s.*>))\/?.*?>
x/ < # Match open angle bracket (?! # Negative lookahead (Not matching and not consuming) \/? # 0 or 1 / p # p (?= # Positive lookahead (Matching and not consuming) > # > - No attributes | # or \s # whitespace.* # anything up to > # close angle brackets - with attributes ) # close positive lookahead ) # close negative lookahead # if we have got this far then we don't match # a p tag or closing p tag # with or without attributes \/? # optional close tag symbol (/).*? # and anything up to > # first closing tag / This will now deal with p tags with or without attributes and the closing p tags, but will match pre and similar tags, with or without attributes. It doesn't strip out attributes, but my source data does not put them in. I may change this later to do this, but this will suffice for now. | [
"html",
"regex",
"perl"
] | 24 | 14 | 43,390 | 14 | 0 | 2008-08-27T10:41:44.793000 | 2008-08-27T11:26:12.957000 |
29,870 | 29,903 | How to bring in a web app | I run a game and the running is done by hand, I have a few scripts that help me but essentially it's me doing the work. I am at the moment working on web app that will allow the users to input directly some of their game actions and thus save me a lot of work. The problem is that I'm one man working on a moderately sized (upwards of 20 tables) project, the workload isn't the issue, it's that bugs will have slipped in even though I test as I write. So my question is thus two-fold. Beta testing, I love open beta's but would a closed beta be somehow more effective and give better results? How should I bring in the app? Should I one turn drop it in and declare it's being used or should I use it alongside the normal construct of the game? | This is my general approach to testing/launching. How you test/launch depends mostly on: What your application is. Who your users are. If you application is a technical application and is geared to the technically-minded, the word "beta" won't really scare them - but provide an opportunity to test the product before it goes 'live', and help to improve the system. This is the ideal circumstance in which to use either an open or closed beta. It's usually beneficial to start off 'closed' with a group of people you select and trust to bug-find quickly and reliably - after you're more confident that all the critical bugs are gone, open it up with an invite system (for example). If, however, your application is 'trivial' from a technical standpoint (i.e. it's something like Twitter, or Facebook, or Flickr - nothing that is inherently geared towards technical usage), then you're going to have to be more careful in how you plan your testing. Closed testing is most definitely your first port of call, and this should last for longer than a closed beta on a more 'technical' product. The reason? Your 'average Joe' doesn't necessarily know what the word "beta" means, and others may well be scared by it, or judge your service prematurely (not understanding the concept of this 'public testing' phase). Many won't want to be used as guinea pigs. | How to bring in a web app I run a game and the running is done by hand, I have a few scripts that help me but essentially it's me doing the work. I am at the moment working on web app that will allow the users to input directly some of their game actions and thus save me a lot of work. The problem is that I'm one man working on a moderately sized (upwards of 20 tables) project, the workload isn't the issue, it's that bugs will have slipped in even though I test as I write. So my question is thus two-fold. Beta testing, I love open beta's but would a closed beta be somehow more effective and give better results? How should I bring in the app? Should I one turn drop it in and declare it's being used or should I use it alongside the normal construct of the game? | TITLE:
How to bring in a web app
QUESTION:
I run a game and the running is done by hand, I have a few scripts that help me but essentially it's me doing the work. I am at the moment working on web app that will allow the users to input directly some of their game actions and thus save me a lot of work. The problem is that I'm one man working on a moderately sized (upwards of 20 tables) project, the workload isn't the issue, it's that bugs will have slipped in even though I test as I write. So my question is thus two-fold. Beta testing, I love open beta's but would a closed beta be somehow more effective and give better results? How should I bring in the app? Should I one turn drop it in and declare it's being used or should I use it alongside the normal construct of the game?
ANSWER:
This is my general approach to testing/launching. How you test/launch depends mostly on: What your application is. Who your users are. If you application is a technical application and is geared to the technically-minded, the word "beta" won't really scare them - but provide an opportunity to test the product before it goes 'live', and help to improve the system. This is the ideal circumstance in which to use either an open or closed beta. It's usually beneficial to start off 'closed' with a group of people you select and trust to bug-find quickly and reliably - after you're more confident that all the critical bugs are gone, open it up with an invite system (for example). If, however, your application is 'trivial' from a technical standpoint (i.e. it's something like Twitter, or Facebook, or Flickr - nothing that is inherently geared towards technical usage), then you're going to have to be more careful in how you plan your testing. Closed testing is most definitely your first port of call, and this should last for longer than a closed beta on a more 'technical' product. The reason? Your 'average Joe' doesn't necessarily know what the word "beta" means, and others may well be scared by it, or judge your service prematurely (not understanding the concept of this 'public testing' phase). Many won't want to be used as guinea pigs. | [
"web-applications",
"beta",
"launching"
] | 0 | 2 | 177 | 3 | 0 | 2008-08-27T10:43:53.620000 | 2008-08-27T11:04:47.203000 |
29,883 | 29,888 | Printing DOM Changes | What I am trying to do is change the background colour of a table cell and then when a user goes to print the page, the changes are now showing. I am currently using an unobtrusive script to run the following command on a range of cells: element.style.backgroundColor = "#f00" This works on screen in IE and FF, however, when you go to Print Preview, the background colours are lost. Am I doing something wrong? | Have you tried hard-coding the values just to see if background-colors are showing on the print-preview at all? I think it is a setting in the Browser. | Printing DOM Changes What I am trying to do is change the background colour of a table cell and then when a user goes to print the page, the changes are now showing. I am currently using an unobtrusive script to run the following command on a range of cells: element.style.backgroundColor = "#f00" This works on screen in IE and FF, however, when you go to Print Preview, the background colours are lost. Am I doing something wrong? | TITLE:
Printing DOM Changes
QUESTION:
What I am trying to do is change the background colour of a table cell and then when a user goes to print the page, the changes are now showing. I am currently using an unobtrusive script to run the following command on a range of cells: element.style.backgroundColor = "#f00" This works on screen in IE and FF, however, when you go to Print Preview, the background colours are lost. Am I doing something wrong?
ANSWER:
Have you tried hard-coding the values just to see if background-colors are showing on the print-preview at all? I think it is a setting in the Browser. | [
"internet-explorer",
"firefox",
"dom",
"browser",
"printing"
] | 1 | 0 | 298 | 2 | 0 | 2008-08-27T10:51:38.873000 | 2008-08-27T10:54:01.410000 |
29,890 | 29,916 | How to get your own (local) IP-Address from an udp-socket (C/C++) | You have multiple network adapters. Bind a UDP socket to an local port, without specifying an address. Receive packets on one of the adapters. How do you get the local ip address of the adapter which received the packet? The question is, "What is the ip address from the receiver adapter?" not the address from the sender which we get in the receive_from(..., &senderAddr,... ); call. | You could enumerate all the network adapters, get their IP addresses and compare the part covered by the subnet mask with the sender's address. Like: IPAddress FindLocalIPAddressOfIncomingPacket( senderAddr ) { foreach( adapter in EnumAllNetworkAdapters() ) { adapterSubnet = adapter.subnetmask & adapter.ipaddress; senderSubnet = adapter.subnetmask & senderAddr; if( adapterSubnet == senderSubnet ) { return adapter.ipaddress; } } } | How to get your own (local) IP-Address from an udp-socket (C/C++) You have multiple network adapters. Bind a UDP socket to an local port, without specifying an address. Receive packets on one of the adapters. How do you get the local ip address of the adapter which received the packet? The question is, "What is the ip address from the receiver adapter?" not the address from the sender which we get in the receive_from(..., &senderAddr,... ); call. | TITLE:
How to get your own (local) IP-Address from an udp-socket (C/C++)
QUESTION:
You have multiple network adapters. Bind a UDP socket to an local port, without specifying an address. Receive packets on one of the adapters. How do you get the local ip address of the adapter which received the packet? The question is, "What is the ip address from the receiver adapter?" not the address from the sender which we get in the receive_from(..., &senderAddr,... ); call.
ANSWER:
You could enumerate all the network adapters, get their IP addresses and compare the part covered by the subnet mask with the sender's address. Like: IPAddress FindLocalIPAddressOfIncomingPacket( senderAddr ) { foreach( adapter in EnumAllNetworkAdapters() ) { adapterSubnet = adapter.subnetmask & adapter.ipaddress; senderSubnet = adapter.subnetmask & senderAddr; if( adapterSubnet == senderSubnet ) { return adapter.ipaddress; } } } | [
"c++",
"sockets",
"udp"
] | 11 | 4 | 18,530 | 7 | 0 | 2008-08-27T10:54:29.427000 | 2008-08-27T11:24:50.680000 |
29,927 | 30,077 | vmware-cmd causes "perl.exe - Ordinal Not Found" error | My automated script for starting and stopping VMWare Server virtual machines has stopped working. vmware-cmd has started raising the error: The ordinal 3288 could not be located in the dynamic link library LIBEAY32.dll. I am not aware of any specific change or update when this started happening. I have found a bunch of other people reporting this problem (or very similar) but no solution. Do you know what caused this error, and/or how to fix this? | Have discovered that this only occurs when the script is run on a different drive to the one where the EXE is located. As a work around for this I have simply moved the scripts execution. Apparently the DLL relates to SSL, which isn't relevant to what I'm doing, so this is a suitable workaround. I'm guessing that the problem is caused by changes in the EXE for how it determines relative paths (unlikley as nothing (AFAICT) has changed). Or the %PATH% environmental variable has changed (more likely). Hope this helps someone in the future. | vmware-cmd causes "perl.exe - Ordinal Not Found" error My automated script for starting and stopping VMWare Server virtual machines has stopped working. vmware-cmd has started raising the error: The ordinal 3288 could not be located in the dynamic link library LIBEAY32.dll. I am not aware of any specific change or update when this started happening. I have found a bunch of other people reporting this problem (or very similar) but no solution. Do you know what caused this error, and/or how to fix this? | TITLE:
vmware-cmd causes "perl.exe - Ordinal Not Found" error
QUESTION:
My automated script for starting and stopping VMWare Server virtual machines has stopped working. vmware-cmd has started raising the error: The ordinal 3288 could not be located in the dynamic link library LIBEAY32.dll. I am not aware of any specific change or update when this started happening. I have found a bunch of other people reporting this problem (or very similar) but no solution. Do you know what caused this error, and/or how to fix this?
ANSWER:
Have discovered that this only occurs when the script is run on a different drive to the one where the EXE is located. As a work around for this I have simply moved the scripts execution. Apparently the DLL relates to SSL, which isn't relevant to what I'm doing, so this is a suitable workaround. I'm guessing that the problem is caused by changes in the EXE for how it determines relative paths (unlikley as nothing (AFAICT) has changed). Or the %PATH% environmental variable has changed (more likely). Hope this helps someone in the future. | [
"vmware"
] | 0 | 1 | 3,137 | 3 | 0 | 2008-08-27T11:42:05.430000 | 2008-08-27T13:24:28.850000 |
29,943 | 29,987 | How do I submit a form when the return key is pressed? | How do I submit an HTML form when the return key is pressed and if there are no buttons in the form? The submit button is not there. I am using a custom div instead of that. | This is the cleanest answer: Name: Pwd: Better yet, if you are using JavaScript to submit the form using the custom div, you should also use JavaScript to create it, and to set the display:none style on the button. This way users with JavaScript disabled will still see the submit button and can click on it. It has been noted that display:none will cause IE to ignore the input. I created a new JSFiddle example that starts as a standard form, and uses progressive enhancement to hide the submit and create the new div. I did use the CSS styling from StriplingWarrior. | How do I submit a form when the return key is pressed? How do I submit an HTML form when the return key is pressed and if there are no buttons in the form? The submit button is not there. I am using a custom div instead of that. | TITLE:
How do I submit a form when the return key is pressed?
QUESTION:
How do I submit an HTML form when the return key is pressed and if there are no buttons in the form? The submit button is not there. I am using a custom div instead of that.
ANSWER:
This is the cleanest answer: Name: Pwd: Better yet, if you are using JavaScript to submit the form using the custom div, you should also use JavaScript to create it, and to set the display:none style on the button. This way users with JavaScript disabled will still see the submit button and can click on it. It has been noted that display:none will cause IE to ignore the input. I created a new JSFiddle example that starts as a standard form, and uses progressive enhancement to hide the submit and create the new div. I did use the CSS styling from StriplingWarrior. | [
"javascript",
"html"
] | 88 | 70 | 253,246 | 15 | 0 | 2008-08-27T11:56:50.060000 | 2008-08-27T12:38:30.893000 |
29,971 | 29,978 | What is the best way to setup an integration testing server? | Setting up an integration server, I’m in doubt about the best approach regarding using multiple tasks to complete the build. Is the best way to set all in just one big-job or make small dependent ones? | You definitely want to break up the tasks. Here is a nice example of CruiseControl.NET configuration that has different targets (tasks) for each step. It also uses a common.build file which can be shared among projects with little customization. http://code.google.com/p/dot-net-reference-app/source/browse/#svn/trunk | What is the best way to setup an integration testing server? Setting up an integration server, I’m in doubt about the best approach regarding using multiple tasks to complete the build. Is the best way to set all in just one big-job or make small dependent ones? | TITLE:
What is the best way to setup an integration testing server?
QUESTION:
Setting up an integration server, I’m in doubt about the best approach regarding using multiple tasks to complete the build. Is the best way to set all in just one big-job or make small dependent ones?
ANSWER:
You definitely want to break up the tasks. Here is a nice example of CruiseControl.NET configuration that has different targets (tasks) for each step. It also uses a common.build file which can be shared among projects with little customization. http://code.google.com/p/dot-net-reference-app/source/browse/#svn/trunk | [
"continuous-integration",
"integration-testing"
] | 5 | 3 | 477 | 7 | 0 | 2008-08-27T12:20:48.237000 | 2008-08-27T12:27:58.113000 |
29,976 | 30,536 | Best practice for dynamically added Web.UI.ITemplate classes | We have a couple of ASP.Net dataview column templates that are dynamically added to the dataview depending on columns selected by users. These templated cells need to handle custom databindings: public class CustomColumnTemplate: ITemplate { public void InstantiateIn( Control container ) { //create a new label Label contentLabel = new Label();
//add a custom data binding contentLabel.DataBinding += ( sender, e ) => { //do custom stuff at databind time contentLabel.Text = //bound content };
//add the label to the cell container.Controls.Add( contentLabel ); } }...
myGridView.Columns.Add( new TemplateField { ItemTemplate = new CustomColumnTemplate(), HeaderText = "Custom column" } ); Firstly this seems rather messy, but there is also a resource issue. The Label is generated, and can't be disposed in the InstantiateIn because then it wouldn't be there to databind. Is there a better pattern for these controls? Is there a way to make sure that the label is disposed after the databind and render? | I have worked extensively with templated control and I have not found a better solution. Why are you referencing the contentLable in the event handler? The sender is the label you can cast it to the label and have the reference to the label. Like below. //add a custom data binding contentLabel.DataBinding += (object sender, EventArgs e ) => { //do custom stuff at databind time ((Label)sender).Text = //bound content }; Then you should be able to dispose of the label reference in InstantiateIn. Please note I have not tested this. | Best practice for dynamically added Web.UI.ITemplate classes We have a couple of ASP.Net dataview column templates that are dynamically added to the dataview depending on columns selected by users. These templated cells need to handle custom databindings: public class CustomColumnTemplate: ITemplate { public void InstantiateIn( Control container ) { //create a new label Label contentLabel = new Label();
//add a custom data binding contentLabel.DataBinding += ( sender, e ) => { //do custom stuff at databind time contentLabel.Text = //bound content };
//add the label to the cell container.Controls.Add( contentLabel ); } }...
myGridView.Columns.Add( new TemplateField { ItemTemplate = new CustomColumnTemplate(), HeaderText = "Custom column" } ); Firstly this seems rather messy, but there is also a resource issue. The Label is generated, and can't be disposed in the InstantiateIn because then it wouldn't be there to databind. Is there a better pattern for these controls? Is there a way to make sure that the label is disposed after the databind and render? | TITLE:
Best practice for dynamically added Web.UI.ITemplate classes
QUESTION:
We have a couple of ASP.Net dataview column templates that are dynamically added to the dataview depending on columns selected by users. These templated cells need to handle custom databindings: public class CustomColumnTemplate: ITemplate { public void InstantiateIn( Control container ) { //create a new label Label contentLabel = new Label();
//add a custom data binding contentLabel.DataBinding += ( sender, e ) => { //do custom stuff at databind time contentLabel.Text = //bound content };
//add the label to the cell container.Controls.Add( contentLabel ); } }...
myGridView.Columns.Add( new TemplateField { ItemTemplate = new CustomColumnTemplate(), HeaderText = "Custom column" } ); Firstly this seems rather messy, but there is also a resource issue. The Label is generated, and can't be disposed in the InstantiateIn because then it wouldn't be there to databind. Is there a better pattern for these controls? Is there a way to make sure that the label is disposed after the databind and render?
ANSWER:
I have worked extensively with templated control and I have not found a better solution. Why are you referencing the contentLable in the event handler? The sender is the label you can cast it to the label and have the reference to the label. Like below. //add a custom data binding contentLabel.DataBinding += (object sender, EventArgs e ) => { //do custom stuff at databind time ((Label)sender).Text = //bound content }; Then you should be able to dispose of the label reference in InstantiateIn. Please note I have not tested this. | [
".net",
"asp.net"
] | 4 | 2 | 2,067 | 2 | 0 | 2008-08-27T12:26:28.520000 | 2008-08-27T16:00:03.640000 |
29,980 | 30,678 | How should I test a method that populates a list from a DataReader? | So I'm working on some legacy code that's heavy on the manual database operations. I'm trying to maintain some semblance of quality here, so I'm going TDD as much as possible. The code I'm working on needs to populate, let's say a List from a DataReader that returns all the fields required for a functioning Foo. However, if I want to verify that the code in fact returns one list item per one database row, I'm writing test code that looks something like this: Expect.Call(reader.Read()).Return(true); Expect.Call(reader["foo_id"]).Return((long) 1); //.... Expect.Call(reader.Read()).Return(true); Expect.Call(reader["foo_id"]).Return((long) 2); //.... Expect.Call(reader.Read()).Return(false); Which is rather tedious and rather easily broken, too. How should I be approaching this issue so that the result won't be a huge mess of brittle tests? Btw I'm currently using Rhino.Mocks for this, but I can change it if the result is convincing enough. Just as long as the alternative isn't TypeMock, because their EULA was a bit too scary for my tastes last I checked. Edit: I'm also currently limited to C# 2. | To make this less tedious, you will need to encapsulate/refactor the mapping between the DataReader and the Object you hold in the list. There is quite of few steps to encapsulate that logic out. If that is the road you want to take, I can post code for you. I am just not sure how practical it would be to post the code here on StackOverflow, but I can give it a shot to keep it concise and to the point. Otherwise, you are stuck with the tedious task of repeating each expectation on the index accessor for the reader. The encapsulation process will also get rid of the strings and make those strings more reusable through your tests. Also, I am not sure at this point how much you want to make the existing code more testable. Since this is legacy code that wasn't built with testing in mind. | How should I test a method that populates a list from a DataReader? So I'm working on some legacy code that's heavy on the manual database operations. I'm trying to maintain some semblance of quality here, so I'm going TDD as much as possible. The code I'm working on needs to populate, let's say a List from a DataReader that returns all the fields required for a functioning Foo. However, if I want to verify that the code in fact returns one list item per one database row, I'm writing test code that looks something like this: Expect.Call(reader.Read()).Return(true); Expect.Call(reader["foo_id"]).Return((long) 1); //.... Expect.Call(reader.Read()).Return(true); Expect.Call(reader["foo_id"]).Return((long) 2); //.... Expect.Call(reader.Read()).Return(false); Which is rather tedious and rather easily broken, too. How should I be approaching this issue so that the result won't be a huge mess of brittle tests? Btw I'm currently using Rhino.Mocks for this, but I can change it if the result is convincing enough. Just as long as the alternative isn't TypeMock, because their EULA was a bit too scary for my tastes last I checked. Edit: I'm also currently limited to C# 2. | TITLE:
How should I test a method that populates a list from a DataReader?
QUESTION:
So I'm working on some legacy code that's heavy on the manual database operations. I'm trying to maintain some semblance of quality here, so I'm going TDD as much as possible. The code I'm working on needs to populate, let's say a List from a DataReader that returns all the fields required for a functioning Foo. However, if I want to verify that the code in fact returns one list item per one database row, I'm writing test code that looks something like this: Expect.Call(reader.Read()).Return(true); Expect.Call(reader["foo_id"]).Return((long) 1); //.... Expect.Call(reader.Read()).Return(true); Expect.Call(reader["foo_id"]).Return((long) 2); //.... Expect.Call(reader.Read()).Return(false); Which is rather tedious and rather easily broken, too. How should I be approaching this issue so that the result won't be a huge mess of brittle tests? Btw I'm currently using Rhino.Mocks for this, but I can change it if the result is convincing enough. Just as long as the alternative isn't TypeMock, because their EULA was a bit too scary for my tastes last I checked. Edit: I'm also currently limited to C# 2.
ANSWER:
To make this less tedious, you will need to encapsulate/refactor the mapping between the DataReader and the Object you hold in the list. There is quite of few steps to encapsulate that logic out. If that is the road you want to take, I can post code for you. I am just not sure how practical it would be to post the code here on StackOverflow, but I can give it a shot to keep it concise and to the point. Otherwise, you are stuck with the tedious task of repeating each expectation on the index accessor for the reader. The encapsulation process will also get rid of the strings and make those strings more reusable through your tests. Also, I am not sure at this point how much you want to make the existing code more testable. Since this is legacy code that wasn't built with testing in mind. | [
"c#",
"unit-testing",
"tdd",
"mocking"
] | 5 | 1 | 825 | 6 | 0 | 2008-08-27T12:29:09.200000 | 2008-08-27T17:22:46.140000 |
29,988 | 30,001 | How to send email from a program _without_ using a preexisting account? | I'd like my program to be able to email me error reports. How can I do this without hard-coding a username/password/SMTP server/etc. into the code? (Doing so would allow users to decompile the program and take over this email account.) I've been told you could do some stuff with telneting to port 25, but I'm very fuzzy on the details. Most of the code snippets on Google assume you have a preexisting account, which doesn't work in this situation. I am using.NET v3.5 (C# in particular), but I would imagine the ideas are similar enough in most languages. As long as you realize I'm doing this for an offline app, and don't supply me with PHP code or something, we should be fine. | As long as your account is on gmail.com, set up gmail-smtp-in.l.google.com as the outgoing SMTP-server in your program. You do not need to provide a password to send email to gmail-accounts when using that server. | How to send email from a program _without_ using a preexisting account? I'd like my program to be able to email me error reports. How can I do this without hard-coding a username/password/SMTP server/etc. into the code? (Doing so would allow users to decompile the program and take over this email account.) I've been told you could do some stuff with telneting to port 25, but I'm very fuzzy on the details. Most of the code snippets on Google assume you have a preexisting account, which doesn't work in this situation. I am using.NET v3.5 (C# in particular), but I would imagine the ideas are similar enough in most languages. As long as you realize I'm doing this for an offline app, and don't supply me with PHP code or something, we should be fine. | TITLE:
How to send email from a program _without_ using a preexisting account?
QUESTION:
I'd like my program to be able to email me error reports. How can I do this without hard-coding a username/password/SMTP server/etc. into the code? (Doing so would allow users to decompile the program and take over this email account.) I've been told you could do some stuff with telneting to port 25, but I'm very fuzzy on the details. Most of the code snippets on Google assume you have a preexisting account, which doesn't work in this situation. I am using.NET v3.5 (C# in particular), but I would imagine the ideas are similar enough in most languages. As long as you realize I'm doing this for an offline app, and don't supply me with PHP code or something, we should be fine.
ANSWER:
As long as your account is on gmail.com, set up gmail-smtp-in.l.google.com as the outgoing SMTP-server in your program. You do not need to provide a password to send email to gmail-accounts when using that server. | [
".net",
"email",
"smtp"
] | 10 | 8 | 6,420 | 6 | 0 | 2008-08-27T12:40:40.373000 | 2008-08-27T12:50:09.120000 |
30,003 | 30,020 | How to compare an html entity with jQuery | I have the following html code: ⇑ Header title I would like to toggle between up arrow and down arrow each time the user clicks the span tag. function expandCollapse(id) { var arrow = $("#"+id+" span").html(); // I have tried with.text() too if(arrow == "⇓") { $("#"+id+" span").html("⇑"); } else { $("#"+id+" span").html("⇓"); } } My function is going always the else path. If I make a javacript:alert of arrow variable I am getting the html entity represented as an arrow. How can I tell jQuery to interpret the arrow variable as a string and not as html. | When the HTML is parsed, what JQuery sees in the DOM is a UPWARDS DOUBLE ARROW ("⇑"), not the entity reference. Thus, in your Javascript code you should test for "⇑" or "\u21d1". Also, you need to change what you're switching to: function expandCollapse(id) { var arrow = $("#"+id+" span").html(); if(arrow == "\u21d1") { $("#"+id+" span").html("\u21d3"); } else { $("#"+id+" span").html("\u21d1"); } } | How to compare an html entity with jQuery I have the following html code: ⇑ Header title I would like to toggle between up arrow and down arrow each time the user clicks the span tag. function expandCollapse(id) { var arrow = $("#"+id+" span").html(); // I have tried with.text() too if(arrow == "⇓") { $("#"+id+" span").html("⇑"); } else { $("#"+id+" span").html("⇓"); } } My function is going always the else path. If I make a javacript:alert of arrow variable I am getting the html entity represented as an arrow. How can I tell jQuery to interpret the arrow variable as a string and not as html. | TITLE:
How to compare an html entity with jQuery
QUESTION:
I have the following html code: ⇑ Header title I would like to toggle between up arrow and down arrow each time the user clicks the span tag. function expandCollapse(id) { var arrow = $("#"+id+" span").html(); // I have tried with.text() too if(arrow == "⇓") { $("#"+id+" span").html("⇑"); } else { $("#"+id+" span").html("⇓"); } } My function is going always the else path. If I make a javacript:alert of arrow variable I am getting the html entity represented as an arrow. How can I tell jQuery to interpret the arrow variable as a string and not as html.
ANSWER:
When the HTML is parsed, what JQuery sees in the DOM is a UPWARDS DOUBLE ARROW ("⇑"), not the entity reference. Thus, in your Javascript code you should test for "⇑" or "\u21d1". Also, you need to change what you're switching to: function expandCollapse(id) { var arrow = $("#"+id+" span").html(); if(arrow == "\u21d1") { $("#"+id+" span").html("\u21d3"); } else { $("#"+id+" span").html("\u21d1"); } } | [
"javascript",
"jquery",
"html-entities"
] | 11 | 17 | 7,412 | 5 | 0 | 2008-08-27T12:51:26.073000 | 2008-08-27T13:03:20.977000 |
30,004 | 30,388 | Can you use LINQ tools such as SQLMetal with an access database? | I'm creating a small database application to teach myself the following concepts C# programming.Net 3.5 framework WPF LINQ ORM I want to use Microsoft Access as the database but I can't seem to find any mention of whether its possible to use SQLMetal to generate the ORM code from a Microsoft Access database. Does anyone know if this is possible? If not, are there any small database or embedded databases I could use? I think SQL express would be overkill for me at this point. | For an embedded database, you can use SQL Server Compact Edition. Unlike SQL Server Express, it is not compatible with the LINQ to SQL designer, but it is fully compatible with the command-line SQLMetal. It has a few advantages over SQL Express, like to ability to use embedded or run from a file. Microsoft has a very handy chart outlining the differences between Express and Compact. | Can you use LINQ tools such as SQLMetal with an access database? I'm creating a small database application to teach myself the following concepts C# programming.Net 3.5 framework WPF LINQ ORM I want to use Microsoft Access as the database but I can't seem to find any mention of whether its possible to use SQLMetal to generate the ORM code from a Microsoft Access database. Does anyone know if this is possible? If not, are there any small database or embedded databases I could use? I think SQL express would be overkill for me at this point. | TITLE:
Can you use LINQ tools such as SQLMetal with an access database?
QUESTION:
I'm creating a small database application to teach myself the following concepts C# programming.Net 3.5 framework WPF LINQ ORM I want to use Microsoft Access as the database but I can't seem to find any mention of whether its possible to use SQLMetal to generate the ORM code from a Microsoft Access database. Does anyone know if this is possible? If not, are there any small database or embedded databases I could use? I think SQL express would be overkill for me at this point.
ANSWER:
For an embedded database, you can use SQL Server Compact Edition. Unlike SQL Server Express, it is not compatible with the LINQ to SQL designer, but it is fully compatible with the command-line SQLMetal. It has a few advantages over SQL Express, like to ability to use embedded or run from a file. Microsoft has a very handy chart outlining the differences between Express and Compact. | [
"c#",
"linq-to-sql",
"ms-access"
] | 6 | 4 | 1,959 | 4 | 0 | 2008-08-27T12:51:57.353000 | 2008-08-27T15:08:31.610000 |
30,005 | 32,878 | How do I fire an event when a iframe has finished loading in jQuery? | I have to load a PDF within a page. Ideally I would like to have a loading animated gif which is replaced once the PDF has loaded. | I'm pretty certain that it cannot be done. Pretty much anything else than PDF works, even Flash. (Tested on Safari, Firefox 3, IE 7) Too bad. | How do I fire an event when a iframe has finished loading in jQuery? I have to load a PDF within a page. Ideally I would like to have a loading animated gif which is replaced once the PDF has loaded. | TITLE:
How do I fire an event when a iframe has finished loading in jQuery?
QUESTION:
I have to load a PDF within a page. Ideally I would like to have a loading animated gif which is replaced once the PDF has loaded.
ANSWER:
I'm pretty certain that it cannot be done. Pretty much anything else than PDF works, even Flash. (Tested on Safari, Firefox 3, IE 7) Too bad. | [
"javascript",
"jquery"
] | 99 | 38 | 189,791 | 14 | 0 | 2008-08-27T12:52:29.927000 | 2008-08-28T17:38:18.357000 |
30,018 | 30,023 | How do I select an XML-node based on its content? | How can I use XPath to select an XML-node based on its content? If I e.g. have the following xml and I want to select the -node that contains Ritchie to get the author's full name: The C Programming Language Ritchie, Dennis M. Kernighan, Brian W. Joel on Software Spolsky, Joel | /books/book/authors/author[contains(., 'Ritchie')] or //author[contains(., 'Ritchie')] | How do I select an XML-node based on its content? How can I use XPath to select an XML-node based on its content? If I e.g. have the following xml and I want to select the -node that contains Ritchie to get the author's full name: The C Programming Language Ritchie, Dennis M. Kernighan, Brian W. Joel on Software Spolsky, Joel | TITLE:
How do I select an XML-node based on its content?
QUESTION:
How can I use XPath to select an XML-node based on its content? If I e.g. have the following xml and I want to select the -node that contains Ritchie to get the author's full name: The C Programming Language Ritchie, Dennis M. Kernighan, Brian W. Joel on Software Spolsky, Joel
ANSWER:
/books/book/authors/author[contains(., 'Ritchie')] or //author[contains(., 'Ritchie')] | [
"xml",
"xpath"
] | 16 | 23 | 11,825 | 3 | 0 | 2008-08-27T13:01:25.770000 | 2008-08-27T13:04:16.217000 |
30,026 | 30,034 | Features common to all regex flavors? | I've seen a lot of commonality in regex capabilities of different regex-enabled tools/languages (e.g. perl, sed, java, vim, etc), but I've also many differences. Is there a standard subset of regex capabilities that all regex-enabled tools/languages will support? How do regex capabilities vary between tools/languages? | Compare Regular Expression Flavors http://www.regular-expressions.info/refflavors.html | Features common to all regex flavors? I've seen a lot of commonality in regex capabilities of different regex-enabled tools/languages (e.g. perl, sed, java, vim, etc), but I've also many differences. Is there a standard subset of regex capabilities that all regex-enabled tools/languages will support? How do regex capabilities vary between tools/languages? | TITLE:
Features common to all regex flavors?
QUESTION:
I've seen a lot of commonality in regex capabilities of different regex-enabled tools/languages (e.g. perl, sed, java, vim, etc), but I've also many differences. Is there a standard subset of regex capabilities that all regex-enabled tools/languages will support? How do regex capabilities vary between tools/languages?
ANSWER:
Compare Regular Expression Flavors http://www.regular-expressions.info/refflavors.html | [
"regex",
"language-agnostic"
] | 10 | 12 | 1,491 | 6 | 0 | 2008-08-27T13:05:38.600000 | 2008-08-27T13:08:30.010000 |
30,036 | 30,197 | JavaScript and Threads | Is there some way to do multi-threading in JavaScript? | See http://caniuse.com/#search=worker for the most up-to-date support info. The following was the state of support circa 2009. The words you want to google for are JavaScript Worker Threads Apart from from Gears there's nothing available right now, but there's plenty of talk about how to implement this so I guess watch this question as the answer will no doubt change in future. Here's the relevant documentation for Gears: WorkerPool API WHATWG has a Draft Recommendation for worker threads: Web Workers And there's also Mozilla’s DOM Worker Threads Update: June 2009, current state of browser support for JavaScript threads Firefox 3.5 has web workers. Some demos of web workers, if you want to see them in action: Simulated Annealing ("Try it" link) Space Invaders (link at end of post) MoonBat JavaScript Benchmark (first link) The Gears plugin can also be installed in Firefox. Safari 4, and the WebKit nightlies have worker threads: JavaScript Ray Tracer Chrome has Gears baked in, so it can do threads, although it requires a confirmation prompt from the user (and it uses a different API to web workers, although it will work in any browser with the Gears plugin installed): Google Gears WorkerPool Demo (not a good example as it runs too fast to test in Chrome and Firefox, although IE runs it slow enough to see it blocking interaction) IE8 and IE9 can only do threads with the Gears plugin installed | JavaScript and Threads Is there some way to do multi-threading in JavaScript? | TITLE:
JavaScript and Threads
QUESTION:
Is there some way to do multi-threading in JavaScript?
ANSWER:
See http://caniuse.com/#search=worker for the most up-to-date support info. The following was the state of support circa 2009. The words you want to google for are JavaScript Worker Threads Apart from from Gears there's nothing available right now, but there's plenty of talk about how to implement this so I guess watch this question as the answer will no doubt change in future. Here's the relevant documentation for Gears: WorkerPool API WHATWG has a Draft Recommendation for worker threads: Web Workers And there's also Mozilla’s DOM Worker Threads Update: June 2009, current state of browser support for JavaScript threads Firefox 3.5 has web workers. Some demos of web workers, if you want to see them in action: Simulated Annealing ("Try it" link) Space Invaders (link at end of post) MoonBat JavaScript Benchmark (first link) The Gears plugin can also be installed in Firefox. Safari 4, and the WebKit nightlies have worker threads: JavaScript Ray Tracer Chrome has Gears baked in, so it can do threads, although it requires a confirmation prompt from the user (and it uses a different API to web workers, although it will work in any browser with the Gears plugin installed): Google Gears WorkerPool Demo (not a good example as it runs too fast to test in Chrome and Firefox, although IE runs it slow enough to see it blocking interaction) IE8 and IE9 can only do threads with the Gears plugin installed | [
"javascript",
"multithreading"
] | 158 | 112 | 173,507 | 13 | 0 | 2008-08-27T13:09:10.760000 | 2008-08-27T14:02:12.037000 |
30,049 | 45,869 | Should DOM splitText and normalise compose to give the identity? | I got embroiled in a discussion about DOM implementation quirks yesterday, with gave rise to an interesting question regarding Text.splitText and Element.normalise behaviours, and how they should behave. In DOM Level 1 Core, Text.splitText is defined as... Breaks this Text node into two Text nodes at the specified offset, keeping both in the tree as siblings. This node then only contains all the content up to the offset point. And a new Text node, which is inserted as the next sibling of this node, contains all the content at and after the offset point. Normalise is... Puts all Text nodes in the full depth of the sub-tree underneath this Element into a "normal" form where only markup (e.g., tags, comments, processing instructions, CDATA sections, and entity references) separates Text nodes, i.e., there are no adjacent Text nodes. This can be used to ensure that the DOM view of a document is the same as if it were saved and re-loaded, and is useful when operations (such as XPointer lookups) that depend on a particular document tree structure are to be used. So, if I take a text node containing "Hello World", referenced in textNode, and do textNode.splitText(3) textNode now has the content "Hello", and a new sibling containing " World" If I then textNode.parent.normalize() what is textNode? The specification doesn't make it clear that textNode has to still be a child of it's previous parent, just updated to contain all adjacent text nodes (which are then removed). It seems to be to be a conforment behaviour to remove all the adjacent text nodes, and then recreate a new node with the concatenation of the values, leaving textNode pointing to something that is no longer part of the tree. Or, we can update textNode in the same fashion as in splitText, so it retains it's tree position, and gets a new value. The choice of behaviour is really quite different, and I can't find a clarification on which is correct, or if this is simply an oversight in the specification (it doesn't seem to be clarified in levels 2 or 3). Can any DOM/XML gurus out there shed some light? | I was on the DOM Working Group in the early days; I'm sure we meant for textNode to contain the new joined value, but if we didn't say it in the spec, it's possible that some implementation might create a new node instead of reusing textNode, though that would require more work for the implementors. When in doubt, program defensively. | Should DOM splitText and normalise compose to give the identity? I got embroiled in a discussion about DOM implementation quirks yesterday, with gave rise to an interesting question regarding Text.splitText and Element.normalise behaviours, and how they should behave. In DOM Level 1 Core, Text.splitText is defined as... Breaks this Text node into two Text nodes at the specified offset, keeping both in the tree as siblings. This node then only contains all the content up to the offset point. And a new Text node, which is inserted as the next sibling of this node, contains all the content at and after the offset point. Normalise is... Puts all Text nodes in the full depth of the sub-tree underneath this Element into a "normal" form where only markup (e.g., tags, comments, processing instructions, CDATA sections, and entity references) separates Text nodes, i.e., there are no adjacent Text nodes. This can be used to ensure that the DOM view of a document is the same as if it were saved and re-loaded, and is useful when operations (such as XPointer lookups) that depend on a particular document tree structure are to be used. So, if I take a text node containing "Hello World", referenced in textNode, and do textNode.splitText(3) textNode now has the content "Hello", and a new sibling containing " World" If I then textNode.parent.normalize() what is textNode? The specification doesn't make it clear that textNode has to still be a child of it's previous parent, just updated to contain all adjacent text nodes (which are then removed). It seems to be to be a conforment behaviour to remove all the adjacent text nodes, and then recreate a new node with the concatenation of the values, leaving textNode pointing to something that is no longer part of the tree. Or, we can update textNode in the same fashion as in splitText, so it retains it's tree position, and gets a new value. The choice of behaviour is really quite different, and I can't find a clarification on which is correct, or if this is simply an oversight in the specification (it doesn't seem to be clarified in levels 2 or 3). Can any DOM/XML gurus out there shed some light? | TITLE:
Should DOM splitText and normalise compose to give the identity?
QUESTION:
I got embroiled in a discussion about DOM implementation quirks yesterday, with gave rise to an interesting question regarding Text.splitText and Element.normalise behaviours, and how they should behave. In DOM Level 1 Core, Text.splitText is defined as... Breaks this Text node into two Text nodes at the specified offset, keeping both in the tree as siblings. This node then only contains all the content up to the offset point. And a new Text node, which is inserted as the next sibling of this node, contains all the content at and after the offset point. Normalise is... Puts all Text nodes in the full depth of the sub-tree underneath this Element into a "normal" form where only markup (e.g., tags, comments, processing instructions, CDATA sections, and entity references) separates Text nodes, i.e., there are no adjacent Text nodes. This can be used to ensure that the DOM view of a document is the same as if it were saved and re-loaded, and is useful when operations (such as XPointer lookups) that depend on a particular document tree structure are to be used. So, if I take a text node containing "Hello World", referenced in textNode, and do textNode.splitText(3) textNode now has the content "Hello", and a new sibling containing " World" If I then textNode.parent.normalize() what is textNode? The specification doesn't make it clear that textNode has to still be a child of it's previous parent, just updated to contain all adjacent text nodes (which are then removed). It seems to be to be a conforment behaviour to remove all the adjacent text nodes, and then recreate a new node with the concatenation of the values, leaving textNode pointing to something that is no longer part of the tree. Or, we can update textNode in the same fashion as in splitText, so it retains it's tree position, and gets a new value. The choice of behaviour is really quite different, and I can't find a clarification on which is correct, or if this is simply an oversight in the specification (it doesn't seem to be clarified in levels 2 or 3). Can any DOM/XML gurus out there shed some light?
ANSWER:
I was on the DOM Working Group in the early days; I'm sure we meant for textNode to contain the new joined value, but if we didn't say it in the spec, it's possible that some implementation might create a new node instead of reusing textNode, though that would require more work for the implementors. When in doubt, program defensively. | [
"xml",
"dom"
] | 8 | 5 | 379 | 3 | 0 | 2008-08-27T13:13:34.600000 | 2008-09-05T13:51:00.943000 |
30,058 | 30,079 | How can I launch the Google Maps iPhone application from within my own native application? | The Apple Developer Documentation (link is dead now) explains that if you place a link in a web page and then click it whilst using Mobile Safari on the iPhone, the Google Maps application that is provided as standard with the iPhone will launch. How can I launch the same Google Maps application with a specific address from within my own native iPhone application (i.e. not a web page through Mobile Safari) in the same way that tapping an address in Contacts launches the map? NOTE: THIS ONLY WORKS ON THE DEVICE ITSELF. NOT IN THE SIMULATOR. | For iOS 5.1.1 and lower, use the openURL method of UIApplication. It will perform the normal iPhone magical URL reinterpretation. so [someUIApplication openURL:[NSURL URLWithString:@"http://maps.google.com/maps?q=London"]] should invoke the Google maps app. From iOS 6, you'll be invoking Apple's own Maps app. For this, configure an MKMapItem object with the location you want to display, and then send it the openInMapsWithLaunchOptions message. To start at the current location, try: [[MKMapItem mapItemForCurrentLocation] openInMapsWithLaunchOptions:nil]; You'll need to be linked against MapKit for this (and it will prompt for location access, I believe). | How can I launch the Google Maps iPhone application from within my own native application? The Apple Developer Documentation (link is dead now) explains that if you place a link in a web page and then click it whilst using Mobile Safari on the iPhone, the Google Maps application that is provided as standard with the iPhone will launch. How can I launch the same Google Maps application with a specific address from within my own native iPhone application (i.e. not a web page through Mobile Safari) in the same way that tapping an address in Contacts launches the map? NOTE: THIS ONLY WORKS ON THE DEVICE ITSELF. NOT IN THE SIMULATOR. | TITLE:
How can I launch the Google Maps iPhone application from within my own native application?
QUESTION:
The Apple Developer Documentation (link is dead now) explains that if you place a link in a web page and then click it whilst using Mobile Safari on the iPhone, the Google Maps application that is provided as standard with the iPhone will launch. How can I launch the same Google Maps application with a specific address from within my own native iPhone application (i.e. not a web page through Mobile Safari) in the same way that tapping an address in Contacts launches the map? NOTE: THIS ONLY WORKS ON THE DEVICE ITSELF. NOT IN THE SIMULATOR.
ANSWER:
For iOS 5.1.1 and lower, use the openURL method of UIApplication. It will perform the normal iPhone magical URL reinterpretation. so [someUIApplication openURL:[NSURL URLWithString:@"http://maps.google.com/maps?q=London"]] should invoke the Google maps app. From iOS 6, you'll be invoking Apple's own Maps app. For this, configure an MKMapItem object with the location you want to display, and then send it the openInMapsWithLaunchOptions message. To start at the current location, try: [[MKMapItem mapItemForCurrentLocation] openInMapsWithLaunchOptions:nil]; You'll need to be linked against MapKit for this (and it will prompt for location access, I believe). | [
"ios",
"objective-c",
"google-maps"
] | 70 | 65 | 99,385 | 16 | 0 | 2008-08-27T13:15:40.493000 | 2008-08-27T13:26:18.517000 |
30,062 | 30,072 | Boolean Field in Oracle | Yesterday I wanted to add a boolean field to an Oracle table. However, there isn't actually a boolean data type in Oracle. Does anyone here know the best way to simulate a boolean? Googling the subject discovered several approaches Use an integer and just don't bother assigning anything other than 0 or 1 to it. Use a char field with 'Y' or 'N' as the only two values. Use an enum with the CHECK constraint. Do experienced Oracle developers know which approach is preferred/canonical? | I found this link useful. Here is the paragraph highlighting some of the pros/cons of each approach. The most commonly seen design is to imitate the many Boolean-like flags that Oracle's data dictionary views use, selecting 'Y' for true and 'N' for false. However, to interact correctly with host environments, such as JDBC, OCCI, and other programming environments, it's better to select 0 for false and 1 for true so it can work correctly with the getBoolean and setBoolean functions. Basically they advocate method number 2, for efficiency's sake, using values of 0/1 (because of interoperability with JDBC's getBoolean() etc.) with a check constraint a type of CHAR (because it uses less space than NUMBER). Their example: create table tbool (bool char check (bool in (0,1)); insert into tbool values(0); insert into tbool values(1);` | Boolean Field in Oracle Yesterday I wanted to add a boolean field to an Oracle table. However, there isn't actually a boolean data type in Oracle. Does anyone here know the best way to simulate a boolean? Googling the subject discovered several approaches Use an integer and just don't bother assigning anything other than 0 or 1 to it. Use a char field with 'Y' or 'N' as the only two values. Use an enum with the CHECK constraint. Do experienced Oracle developers know which approach is preferred/canonical? | TITLE:
Boolean Field in Oracle
QUESTION:
Yesterday I wanted to add a boolean field to an Oracle table. However, there isn't actually a boolean data type in Oracle. Does anyone here know the best way to simulate a boolean? Googling the subject discovered several approaches Use an integer and just don't bother assigning anything other than 0 or 1 to it. Use a char field with 'Y' or 'N' as the only two values. Use an enum with the CHECK constraint. Do experienced Oracle developers know which approach is preferred/canonical?
ANSWER:
I found this link useful. Here is the paragraph highlighting some of the pros/cons of each approach. The most commonly seen design is to imitate the many Boolean-like flags that Oracle's data dictionary views use, selecting 'Y' for true and 'N' for false. However, to interact correctly with host environments, such as JDBC, OCCI, and other programming environments, it's better to select 0 for false and 1 for true so it can work correctly with the getBoolean and setBoolean functions. Basically they advocate method number 2, for efficiency's sake, using values of 0/1 (because of interoperability with JDBC's getBoolean() etc.) with a check constraint a type of CHAR (because it uses less space than NUMBER). Their example: create table tbool (bool char check (bool in (0,1)); insert into tbool values(0); insert into tbool values(1);` | [
"oracle",
"boolean",
"sqldatatypes"
] | 153 | 89 | 219,569 | 9 | 0 | 2008-08-27T13:16:58.883000 | 2008-08-27T13:23:06.247000 |
30,067 | 52,893 | Should I migrate to ASP.NET MVC? | I just listened to the StackOverflow team's 17th podcast, and they talked so highly of ASP.NET MVC that I decided to check it out. But first, I want to be sure it's worth it. I already created a base web application (for other developers to build on) for a project that's starting in a few days and wanted to know, based on your experience, if I should take the time to learn the basics of MVC and re-create the base web application with this model. Are there really big pros that'd make it worthwhile? EDIT: It's not an existing project, it's a project about to start, so if I'm going to do it it should be now... I just found this It does not, however, use the existing post-back model for interactions back to the server. Instead, you'll route all end-user interactions to a Controller class instead - which helps ensure clean separation of concerns and testability ( it also means no viewstate or page lifecycle with MVC based views ). How would that work? No viewstate? No events? | If you are quite happy with WebForms today, then maybe ASP.NET MVC isn't for you. I have been frustrated with WebForms for a really long time. I'm definitely not alone here. The smart-client, stateful abstraction over the web breaks down severely in complex scenarios. I happen to love HTML, Javascript, and CSS. WebForms tries to hide that from me. It also has some really complex solutions to problems that are really not that complex. Webforms is also inherently difficult to test, and while you can use MVP, it's not a great solution for a web environment...(compared to MVC). MVC will appeal to you if... - you want more control over your HTML - want a seamless ajax experience like every other platform has - want testability through-and-through - want meaningful URLs - HATE dealing with postback & viewstate issues And as for the framework being Preview 5, it is quite stable, the design is mostly there, and upgrading is not difficult. I started an app on Preview 1 and have upgraded within a few hours of the newest preview being available. | Should I migrate to ASP.NET MVC? I just listened to the StackOverflow team's 17th podcast, and they talked so highly of ASP.NET MVC that I decided to check it out. But first, I want to be sure it's worth it. I already created a base web application (for other developers to build on) for a project that's starting in a few days and wanted to know, based on your experience, if I should take the time to learn the basics of MVC and re-create the base web application with this model. Are there really big pros that'd make it worthwhile? EDIT: It's not an existing project, it's a project about to start, so if I'm going to do it it should be now... I just found this It does not, however, use the existing post-back model for interactions back to the server. Instead, you'll route all end-user interactions to a Controller class instead - which helps ensure clean separation of concerns and testability ( it also means no viewstate or page lifecycle with MVC based views ). How would that work? No viewstate? No events? | TITLE:
Should I migrate to ASP.NET MVC?
QUESTION:
I just listened to the StackOverflow team's 17th podcast, and they talked so highly of ASP.NET MVC that I decided to check it out. But first, I want to be sure it's worth it. I already created a base web application (for other developers to build on) for a project that's starting in a few days and wanted to know, based on your experience, if I should take the time to learn the basics of MVC and re-create the base web application with this model. Are there really big pros that'd make it worthwhile? EDIT: It's not an existing project, it's a project about to start, so if I'm going to do it it should be now... I just found this It does not, however, use the existing post-back model for interactions back to the server. Instead, you'll route all end-user interactions to a Controller class instead - which helps ensure clean separation of concerns and testability ( it also means no viewstate or page lifecycle with MVC based views ). How would that work? No viewstate? No events?
ANSWER:
If you are quite happy with WebForms today, then maybe ASP.NET MVC isn't for you. I have been frustrated with WebForms for a really long time. I'm definitely not alone here. The smart-client, stateful abstraction over the web breaks down severely in complex scenarios. I happen to love HTML, Javascript, and CSS. WebForms tries to hide that from me. It also has some really complex solutions to problems that are really not that complex. Webforms is also inherently difficult to test, and while you can use MVP, it's not a great solution for a web environment...(compared to MVC). MVC will appeal to you if... - you want more control over your HTML - want a seamless ajax experience like every other platform has - want testability through-and-through - want meaningful URLs - HATE dealing with postback & viewstate issues And as for the framework being Preview 5, it is quite stable, the design is mostly there, and upgrading is not difficult. I started an app on Preview 1 and have upgraded within a few hours of the newest preview being available. | [
"asp.net-mvc"
] | 52 | 65 | 9,792 | 20 | 0 | 2008-08-27T13:20:15.287000 | 2008-09-09T21:00:18.693000 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.