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
43,591
43,633
Override WebClientProtocol.Timeout via web.config
Is it possible to override default value of WebClientProtocol.Timeout property via web.config?
I cant think of a way to have just the Timeout property changed automatically via the webconfig. Manually configure the value or use DI to read the value in for you. It maybe possible also to change the value globally on the machine config.
Override WebClientProtocol.Timeout via web.config Is it possible to override default value of WebClientProtocol.Timeout property via web.config?
TITLE: Override WebClientProtocol.Timeout via web.config QUESTION: Is it possible to override default value of WebClientProtocol.Timeout property via web.config? ANSWER: I cant think of a way to have just the Timeout property changed automatically via the webconfig. Manually configure the value or use DI to read the value in for you. It maybe possible also to change the value globally on the machine config.
[ ".net", "configuration" ]
6
2
2,330
1
0
2008-09-04T12:14:13.760000
2008-09-04T12:33:30.890000
43,596
44,218
How well does WPF blend with XNA in real life?
I understand that there are several ways to blend XNA and WPF within the same application. I find it enticing to use WPF for all GUI and HUD stuff in my XNA games. Does anyone have any practical experience on how well this approach works in real life using.NET 3.5 SP1? Any pitfalls (such as the "airspace problem" )? Any hint on what appoach works best?
There is an addition in 3.5 SP1 that allows better interaction between DirectX and WPF (D3DImage), and one way to get to that is through XNA. Here are some details: http://jmorrill.hjtcentral.com/Default.aspx?tabid=428&EntryID=259
How well does WPF blend with XNA in real life? I understand that there are several ways to blend XNA and WPF within the same application. I find it enticing to use WPF for all GUI and HUD stuff in my XNA games. Does anyone have any practical experience on how well this approach works in real life using.NET 3.5 SP1? Any pitfalls (such as the "airspace problem" )? Any hint on what appoach works best?
TITLE: How well does WPF blend with XNA in real life? QUESTION: I understand that there are several ways to blend XNA and WPF within the same application. I find it enticing to use WPF for all GUI and HUD stuff in my XNA games. Does anyone have any practical experience on how well this approach works in real life using.NET 3.5 SP1? Any pitfalls (such as the "airspace problem" )? Any hint on what appoach works best? ANSWER: There is an addition in 3.5 SP1 that allows better interaction between DirectX and WPF (D3DImage), and one way to get to that is through XNA. Here are some details: http://jmorrill.hjtcentral.com/Default.aspx?tabid=428&EntryID=259
[ "wpf", "interop", "xna", "direct3d" ]
15
6
13,281
6
0
2008-09-04T12:16:42.083000
2008-09-04T17:19:47.957000
43,632
43,636
Can you make just part of a regex case-insensitive?
I've seen lots of examples of making an entire regular expression case-insensitive. What I'm wondering about is having just part of the expression be case-insensitive. For example, let's say I have a string like this: fooFOOfOoFoOBARBARbarbarbAr What if I want to match all occurrences of "foo" regardless of case but I only want to match the upper-case "BAR"s? The ideal solution would be something that works across regex flavors but I'm interested in hearing language-specific ones as well (Thanks Espo ) Edit The link Espo provided was very helpful. There's a good example in there about turning modifiers on and off within the expression. For my contrived example, I can do something like this: (?i)foo*(?-i)|BAR which makes the match case-insensitive for just the foo portion of the match. That seemed to work in most regex implementations except Javascript, Python, and a few others (as Espo mentioned). The big ones that I was wondering about (Perl, PHP,.NET) all support inline mode changes.
Perl lets you make part of your regular expression case-insensitive by using the (?i:) pattern modifier. Modern regex flavors allow you to apply modifiers to only part of the regular expression. If you insert the modifier (?ism) in the middle of the regex, the modifier only applies to the part of the regex to the right of the modifier. You can turn off modes by preceding them with a minus sign. All modes after the minus sign will be turned off. E.g. (?i-sm) turns on case insensitivity, and turns off both single-line mode and multi-line mode. Not all regex flavors support this. JavaScript and Python apply all mode modifiers to the entire regular expression. They don't support the (?-ismx) syntax, since turning off an option is pointless when mode modifiers apply to the whole regular expressions. All options are off by default. You can quickly test how the regex flavor you're using handles mode modifiers. The regex (?i)te(?-i)st should match test and TEst, but not teST or TEST. Source
Can you make just part of a regex case-insensitive? I've seen lots of examples of making an entire regular expression case-insensitive. What I'm wondering about is having just part of the expression be case-insensitive. For example, let's say I have a string like this: fooFOOfOoFoOBARBARbarbarbAr What if I want to match all occurrences of "foo" regardless of case but I only want to match the upper-case "BAR"s? The ideal solution would be something that works across regex flavors but I'm interested in hearing language-specific ones as well (Thanks Espo ) Edit The link Espo provided was very helpful. There's a good example in there about turning modifiers on and off within the expression. For my contrived example, I can do something like this: (?i)foo*(?-i)|BAR which makes the match case-insensitive for just the foo portion of the match. That seemed to work in most regex implementations except Javascript, Python, and a few others (as Espo mentioned). The big ones that I was wondering about (Perl, PHP,.NET) all support inline mode changes.
TITLE: Can you make just part of a regex case-insensitive? QUESTION: I've seen lots of examples of making an entire regular expression case-insensitive. What I'm wondering about is having just part of the expression be case-insensitive. For example, let's say I have a string like this: fooFOOfOoFoOBARBARbarbarbAr What if I want to match all occurrences of "foo" regardless of case but I only want to match the upper-case "BAR"s? The ideal solution would be something that works across regex flavors but I'm interested in hearing language-specific ones as well (Thanks Espo ) Edit The link Espo provided was very helpful. There's a good example in there about turning modifiers on and off within the expression. For my contrived example, I can do something like this: (?i)foo*(?-i)|BAR which makes the match case-insensitive for just the foo portion of the match. That seemed to work in most regex implementations except Javascript, Python, and a few others (as Espo mentioned). The big ones that I was wondering about (Perl, PHP,.NET) all support inline mode changes. ANSWER: Perl lets you make part of your regular expression case-insensitive by using the (?i:) pattern modifier. Modern regex flavors allow you to apply modifiers to only part of the regular expression. If you insert the modifier (?ism) in the middle of the regex, the modifier only applies to the part of the regex to the right of the modifier. You can turn off modes by preceding them with a minus sign. All modes after the minus sign will be turned off. E.g. (?i-sm) turns on case insensitivity, and turns off both single-line mode and multi-line mode. Not all regex flavors support this. JavaScript and Python apply all mode modifiers to the entire regular expression. They don't support the (?-ismx) syntax, since turning off an option is pointless when mode modifiers apply to the whole regular expressions. All options are off by default. You can quickly test how the regex flavor you're using handles mode modifiers. The regex (?i)te(?-i)st should match test and TEst, but not teST or TEST. Source
[ "regex" ]
121
98
97,244
5
0
2008-09-04T12:33:26.553000
2008-09-04T12:35:25.520000
43,643
44,043
How do I style (css) radio buttons and labels?
Given the code bellow, how do I style the radio buttons to be next to the labels and style the label of the selected radio button differently than the other labels? What color is the sky? A strange radient green. A dark gloomy orange A perfect glittering blue Also let me state that I use the yui css styles as base. If you are not familir with them, they can be found here: reset-fonts-grids.css base-min.css Documentation for them both here: Yahoo! UI Library @pkaeding: Thanks. I tried some floating both thing that just looked messed up. The styling active radio button seemed to be doable with some input[type=radio]:active nomination on a google search, but I didnt get it to work properly. So the question I guess is more: Is this possible on all of todays modern browsers, and if not, what is the minimal JS needed?
The first part of your question can be solved with just HTML & CSS; you'll need to use Javascript for the second part. Getting the Label Near the Radio Button I'm not sure what you mean by "next to": on the same line and near, or on separate lines? If you want all of the radio buttons on the same line, just use margins to push them apart. If you want each of them on their own line, you have two options (unless you want to venture into float: territory): Use s to split the options apart and some CSS to vertically align them: What color is the sky? A strange radient green. A dark gloomy orange A perfect glittering blue Follow A List Apart 's article: Prettier Accessible Forms Applying a Style to the Currently Selected Label + Radio Button Styling the is why you'll need to resort to Javascript. A library like jQuery is perfect for this: The focus and blur hooks are needed to make this work in IE.
How do I style (css) radio buttons and labels? Given the code bellow, how do I style the radio buttons to be next to the labels and style the label of the selected radio button differently than the other labels? What color is the sky? A strange radient green. A dark gloomy orange A perfect glittering blue Also let me state that I use the yui css styles as base. If you are not familir with them, they can be found here: reset-fonts-grids.css base-min.css Documentation for them both here: Yahoo! UI Library @pkaeding: Thanks. I tried some floating both thing that just looked messed up. The styling active radio button seemed to be doable with some input[type=radio]:active nomination on a google search, but I didnt get it to work properly. So the question I guess is more: Is this possible on all of todays modern browsers, and if not, what is the minimal JS needed?
TITLE: How do I style (css) radio buttons and labels? QUESTION: Given the code bellow, how do I style the radio buttons to be next to the labels and style the label of the selected radio button differently than the other labels? What color is the sky? A strange radient green. A dark gloomy orange A perfect glittering blue Also let me state that I use the yui css styles as base. If you are not familir with them, they can be found here: reset-fonts-grids.css base-min.css Documentation for them both here: Yahoo! UI Library @pkaeding: Thanks. I tried some floating both thing that just looked messed up. The styling active radio button seemed to be doable with some input[type=radio]:active nomination on a google search, but I didnt get it to work properly. So the question I guess is more: Is this possible on all of todays modern browsers, and if not, what is the minimal JS needed? ANSWER: The first part of your question can be solved with just HTML & CSS; you'll need to use Javascript for the second part. Getting the Label Near the Radio Button I'm not sure what you mean by "next to": on the same line and near, or on separate lines? If you want all of the radio buttons on the same line, just use margins to push them apart. If you want each of them on their own line, you have two options (unless you want to venture into float: territory): Use s to split the options apart and some CSS to vertically align them: What color is the sky? A strange radient green. A dark gloomy orange A perfect glittering blue Follow A List Apart 's article: Prettier Accessible Forms Applying a Style to the Currently Selected Label + Radio Button Styling the is why you'll need to resort to Javascript. A library like jQuery is perfect for this: The focus and blur hooks are needed to make this work in IE.
[ "html", "css", "radio-button", "styles" ]
31
33
184,568
3
0
2008-09-04T12:37:58.617000
2008-09-04T15:49:41.010000
43,644
43,664
Can I update/select from a table in one query?
I need to select data when a page is viewed and update the 'views' column is there a way to do this in one query, or do I have to use to distinct queries?
If you do not want/need to use a transaction, you could create a stored procedure that first updates the view count and then selects the values and return them to the user.
Can I update/select from a table in one query? I need to select data when a page is viewed and update the 'views' column is there a way to do this in one query, or do I have to use to distinct queries?
TITLE: Can I update/select from a table in one query? QUESTION: I need to select data when a page is viewed and update the 'views' column is there a way to do this in one query, or do I have to use to distinct queries? ANSWER: If you do not want/need to use a transaction, you could create a stored procedure that first updates the view count and then selects the values and return them to the user.
[ "mysql", "sql-update" ]
2
2
2,972
5
0
2008-09-04T12:38:30.690000
2008-09-04T12:45:18.943000
43,672
43,704
What types of executables can be decompiled?
I think that java executables (jar files) are trivial to decompile and get the source code. What about other languages?.net and all? Which all languages can compile only to a decompile-able code?
In general, languages like Java, C#, and VB.NET are relatively easy to decompile because they are compiled to an intermediary language, not pure machine language. In their IL form, they retain more metadata than C code does when compiled to machine language. Technically you aren't getting the original source code out, but a variation on the source code that, when compiled, will give you the compiled code back. It isn't identical to the source code, as things like comments, annotations, and compiler directives usually aren't carried forward into the compiled code.
What types of executables can be decompiled? I think that java executables (jar files) are trivial to decompile and get the source code. What about other languages?.net and all? Which all languages can compile only to a decompile-able code?
TITLE: What types of executables can be decompiled? QUESTION: I think that java executables (jar files) are trivial to decompile and get the source code. What about other languages?.net and all? Which all languages can compile only to a decompile-able code? ANSWER: In general, languages like Java, C#, and VB.NET are relatively easy to decompile because they are compiled to an intermediary language, not pure machine language. In their IL form, they retain more metadata than C code does when compiled to machine language. Technically you aren't getting the original source code out, but a variation on the source code that, when compiled, will give you the compiled code back. It isn't identical to the source code, as things like comments, annotations, and compiler directives usually aren't carried forward into the compiled code.
[ "decompiling" ]
5
11
2,163
5
0
2008-09-04T12:47:39.343000
2008-09-04T12:57:54.980000
43,711
43,720
What's a good way to overwrite DateTime.Now during testing?
I've got some (C#) code that relies on today's date to correctly calculate things in the future. If I use today's date in the testing, I have to repeat the calculation in the test, which doesn't feel right. What's the best way to set the date to a known value within the test so that I can test that the result is a known value?
My preference is to have classes that use time actually rely on an interface, such as interface IClock { DateTime Now { get; } } With a concrete implementation class SystemClock: IClock { DateTime Now { get { return DateTime.Now; } } } Then if you want, you can provide any other kind of clock you want for testing, such as class StaticClock: IClock { DateTime Now { get { return new DateTime(2008, 09, 3, 9, 6, 13); } } } There may be some overhead in providing the clock to the class that relies on it, but that could be handled by any number of dependency injection solutions (using an Inversion of Control container, plain old constructor/setter injection, or even a Static Gateway Pattern ). Other mechanisms of delivering an object or method that provides desired times also work, but I think the key thing is to avoid resetting the system clock, as that's just going to introduce pain on other levels. Also, using DateTime.Now and including it in your calculations doesn't just not feel right - it robs you of the ability to test particular times, for example if you discover a bug that only happens near a midnight boundary, or on Tuesdays. Using the current time won't allow you to test those scenarios. Or at least not whenever you want.
What's a good way to overwrite DateTime.Now during testing? I've got some (C#) code that relies on today's date to correctly calculate things in the future. If I use today's date in the testing, I have to repeat the calculation in the test, which doesn't feel right. What's the best way to set the date to a known value within the test so that I can test that the result is a known value?
TITLE: What's a good way to overwrite DateTime.Now during testing? QUESTION: I've got some (C#) code that relies on today's date to correctly calculate things in the future. If I use today's date in the testing, I have to repeat the calculation in the test, which doesn't feel right. What's the best way to set the date to a known value within the test so that I can test that the result is a known value? ANSWER: My preference is to have classes that use time actually rely on an interface, such as interface IClock { DateTime Now { get; } } With a concrete implementation class SystemClock: IClock { DateTime Now { get { return DateTime.Now; } } } Then if you want, you can provide any other kind of clock you want for testing, such as class StaticClock: IClock { DateTime Now { get { return new DateTime(2008, 09, 3, 9, 6, 13); } } } There may be some overhead in providing the clock to the class that relies on it, but that could be handled by any number of dependency injection solutions (using an Inversion of Control container, plain old constructor/setter injection, or even a Static Gateway Pattern ). Other mechanisms of delivering an object or method that provides desired times also work, but I think the key thing is to avoid resetting the system clock, as that's just going to introduce pain on other levels. Also, using DateTime.Now and including it in your calculations doesn't just not feel right - it robs you of the ability to test particular times, for example if you discover a bug that only happens near a midnight boundary, or on Tuesdays. Using the current time won't allow you to test those scenarios. Or at least not whenever you want.
[ "c#", "unit-testing", "datetime", "testing" ]
129
167
51,571
13
0
2008-09-04T13:02:12.007000
2008-09-04T13:06:28.843000
43,742
43,760
SQL Profiler on SQL Server 2005 Professional Edition
I want to use SQL Profiler to trace the queries executed agains my database, track performance, etc. However it seems that the SQL Profiler is only available in the Enterprise edition of SQL Server 2005. Is this the case indeed, and can I do something about it?
You don't need any SQL license to run the client tools (Management Studio, Profiler, etc). If your organization has a copy of the installation media for Developer, Standard, or Enterprise, you can install the client tools on your local machine under the same license. If you're working solo, I would recommend purchasing SQL Developer edition, it's only $50.
SQL Profiler on SQL Server 2005 Professional Edition I want to use SQL Profiler to trace the queries executed agains my database, track performance, etc. However it seems that the SQL Profiler is only available in the Enterprise edition of SQL Server 2005. Is this the case indeed, and can I do something about it?
TITLE: SQL Profiler on SQL Server 2005 Professional Edition QUESTION: I want to use SQL Profiler to trace the queries executed agains my database, track performance, etc. However it seems that the SQL Profiler is only available in the Enterprise edition of SQL Server 2005. Is this the case indeed, and can I do something about it? ANSWER: You don't need any SQL license to run the client tools (Management Studio, Profiler, etc). If your organization has a copy of the installation media for Developer, Standard, or Enterprise, you can install the client tools on your local machine under the same license. If you're working solo, I would recommend purchasing SQL Developer edition, it's only $50.
[ "sql", "sql-server", "sql-server-2005" ]
2
7
7,946
4
0
2008-09-04T13:19:58.937000
2008-09-04T13:29:17.573000
43,743
46,200
ASP.NET MVC Performance
I found some wild remarks that ASP.NET MVC is 30x faster than ASP.NET WebForms. What real performance difference is there, has this been measured and what are the performance benefits. This is to help me consider moving from ASP.NET WebForms to ASP.NET MVC.
We haven't performed the type of scalability and perf tests necessary to come up with any conclusions. I think ScottGu may have been discussing potential perf targets. As we move towards Beta and RTM, we will internally be doing more perf testing. However, I'm not sure what our policy is on publishing results of perf tests. In any case, any such tests really need to consider real world applications...
ASP.NET MVC Performance I found some wild remarks that ASP.NET MVC is 30x faster than ASP.NET WebForms. What real performance difference is there, has this been measured and what are the performance benefits. This is to help me consider moving from ASP.NET WebForms to ASP.NET MVC.
TITLE: ASP.NET MVC Performance QUESTION: I found some wild remarks that ASP.NET MVC is 30x faster than ASP.NET WebForms. What real performance difference is there, has this been measured and what are the performance benefits. This is to help me consider moving from ASP.NET WebForms to ASP.NET MVC. ANSWER: We haven't performed the type of scalability and perf tests necessary to come up with any conclusions. I think ScottGu may have been discussing potential perf targets. As we move towards Beta and RTM, we will internally be doing more perf testing. However, I'm not sure what our policy is on publishing results of perf tests. In any case, any such tests really need to consider real world applications...
[ "asp.net", "asp.net-mvc", "performance", "webforms" ]
102
69
30,696
14
0
2008-09-04T13:20:03.057000
2008-09-05T16:19:02.927000
43,764
79,273
MS Access Reporting - can it be pretty?
I am working on a project converting a "spreadsheet application" to a database solution. A macro was written that takes screen shots of each page and pastes them into a PowerPoint presentation. Because of the nice formatting options in Excel, the presentation looks very pretty. The problem I'm having is that I haven't ever seen an Access report that would be pretty enough to display to upper management. I think the output still has to be a PowerPoint presentation. It needs to look as close as possible to the original output. I am currently trying to write some code to use a.pot (presentation template) and fill in the data programmatically. Putting the data into a PowerPoint table has been tricky because the tables are not easy to manipulate. For example, if a particular description is too long, I need to break into the next cell down (word-wrap isn't allowed because I can only have n lines per page). Is there a way to make an Access report pretty, am I headed down the right path, or should I just try to programmatically fill in the Excel spreadsheet and use the code that already exists there to produce the presentation? (I'd still need to figure out how to know when to break a line when using a non-monospaced font, as the users are currently doing that manually when they enter the data in the spreadsheet) Jason Z: If I set it to wrap, and I already have n lines, it would make n +1 or 2 lines on the slide, which is unacceptable. Dennis: That article looks very good, I should be able to glean something from it. Thanks!
Access has the capability to create downright beautiful reports. The problem is that it can't make a spreadsheet look better than Excel. You have to know when to use each tool. Use Excel when you have spreadsheet-like formatting, need a lot of boxes and lines, or want to draw charts. Use Access when you will output a report as a PDF. It's very useful for one-record-per-page detail reports, formatting where you need to position things very precisely, and where you need to embed subreports with related or unrelated data. Think about the reports that would be nasty in Excel because you'd have to merge cells all over the place and do funny things with the placement and the layout would never work. That's where Access shines.
MS Access Reporting - can it be pretty? I am working on a project converting a "spreadsheet application" to a database solution. A macro was written that takes screen shots of each page and pastes them into a PowerPoint presentation. Because of the nice formatting options in Excel, the presentation looks very pretty. The problem I'm having is that I haven't ever seen an Access report that would be pretty enough to display to upper management. I think the output still has to be a PowerPoint presentation. It needs to look as close as possible to the original output. I am currently trying to write some code to use a.pot (presentation template) and fill in the data programmatically. Putting the data into a PowerPoint table has been tricky because the tables are not easy to manipulate. For example, if a particular description is too long, I need to break into the next cell down (word-wrap isn't allowed because I can only have n lines per page). Is there a way to make an Access report pretty, am I headed down the right path, or should I just try to programmatically fill in the Excel spreadsheet and use the code that already exists there to produce the presentation? (I'd still need to figure out how to know when to break a line when using a non-monospaced font, as the users are currently doing that manually when they enter the data in the spreadsheet) Jason Z: If I set it to wrap, and I already have n lines, it would make n +1 or 2 lines on the slide, which is unacceptable. Dennis: That article looks very good, I should be able to glean something from it. Thanks!
TITLE: MS Access Reporting - can it be pretty? QUESTION: I am working on a project converting a "spreadsheet application" to a database solution. A macro was written that takes screen shots of each page and pastes them into a PowerPoint presentation. Because of the nice formatting options in Excel, the presentation looks very pretty. The problem I'm having is that I haven't ever seen an Access report that would be pretty enough to display to upper management. I think the output still has to be a PowerPoint presentation. It needs to look as close as possible to the original output. I am currently trying to write some code to use a.pot (presentation template) and fill in the data programmatically. Putting the data into a PowerPoint table has been tricky because the tables are not easy to manipulate. For example, if a particular description is too long, I need to break into the next cell down (word-wrap isn't allowed because I can only have n lines per page). Is there a way to make an Access report pretty, am I headed down the right path, or should I just try to programmatically fill in the Excel spreadsheet and use the code that already exists there to produce the presentation? (I'd still need to figure out how to know when to break a line when using a non-monospaced font, as the users are currently doing that manually when they enter the data in the spreadsheet) Jason Z: If I set it to wrap, and I already have n lines, it would make n +1 or 2 lines on the slide, which is unacceptable. Dennis: That article looks very good, I should be able to glean something from it. Thanks! ANSWER: Access has the capability to create downright beautiful reports. The problem is that it can't make a spreadsheet look better than Excel. You have to know when to use each tool. Use Excel when you have spreadsheet-like formatting, need a lot of boxes and lines, or want to draw charts. Use Access when you will output a report as a PDF. It's very useful for one-record-per-page detail reports, formatting where you need to position things very precisely, and where you need to embed subreports with related or unrelated data. Think about the reports that would be nasty in Excel because you'd have to merge cells all over the place and do funny things with the placement and the layout would never work. That's where Access shines.
[ "ms-access", "reporting", "powerpoint" ]
1
3
7,615
10
0
2008-09-04T13:31:53.590000
2008-09-17T02:27:02.267000
43,765
65,992
Pin Emacs buffers to windows (for cscope)
For my day job, I live in Emacs. Utterly. I also have become pretty dependent on CScope to help me find things in the code. Normally, I have 2 windows in a split (C-x 3): alt text http://bitthicket.com/files/emacs-2split.JPG And I use the right window for code buffers and the left window for the CScope search buffer. When you do a CScope search and select a result, it automatically updates the right-side window to show the buffer referred to by the result. This is all well and good, except that it causes me to lose my place in some other buffer that I was studying. Sometimes this is no biggie, because [C-s u] gets me back to where I was. What would be better, though, is to have 3 split windows like this ([C-x 2] in the left window): alt text http://bitthicket.com/files/emacs-3split.jpg And have the bottom left window contain the CScope search buffer, and the top left window be the only buffer that CScope ever updates. That way, I can see my CScope searches and navigate around the code without losing the buffer I'm focused on. Anyone know how I can do that?
Put this in your.emacs file:;; Toggle window dedication (defun toggle-window-dedicated () "Toggle whether the current active window is dedicated or not" (interactive) (message (if (let (window (get-buffer-window (current-buffer))) (set-window-dedicated-p window (not (window-dedicated-p window)))) "Window '%s' is dedicated" "Window '%s' is normal") (current-buffer))) Then bind it to some key - I use the Pause key: (global-set-key [pause] 'toggle-window-dedicated) And then use it to "dedicate" the window you want locked. then cscope can only open files from its result window in some OTHER window. Works a charm. I specifically use it for exactly this purpose - keeping one source file always on screen, while using cscope in a second buffer/window, and looking at cscope results in a third.
Pin Emacs buffers to windows (for cscope) For my day job, I live in Emacs. Utterly. I also have become pretty dependent on CScope to help me find things in the code. Normally, I have 2 windows in a split (C-x 3): alt text http://bitthicket.com/files/emacs-2split.JPG And I use the right window for code buffers and the left window for the CScope search buffer. When you do a CScope search and select a result, it automatically updates the right-side window to show the buffer referred to by the result. This is all well and good, except that it causes me to lose my place in some other buffer that I was studying. Sometimes this is no biggie, because [C-s u] gets me back to where I was. What would be better, though, is to have 3 split windows like this ([C-x 2] in the left window): alt text http://bitthicket.com/files/emacs-3split.jpg And have the bottom left window contain the CScope search buffer, and the top left window be the only buffer that CScope ever updates. That way, I can see my CScope searches and navigate around the code without losing the buffer I'm focused on. Anyone know how I can do that?
TITLE: Pin Emacs buffers to windows (for cscope) QUESTION: For my day job, I live in Emacs. Utterly. I also have become pretty dependent on CScope to help me find things in the code. Normally, I have 2 windows in a split (C-x 3): alt text http://bitthicket.com/files/emacs-2split.JPG And I use the right window for code buffers and the left window for the CScope search buffer. When you do a CScope search and select a result, it automatically updates the right-side window to show the buffer referred to by the result. This is all well and good, except that it causes me to lose my place in some other buffer that I was studying. Sometimes this is no biggie, because [C-s u] gets me back to where I was. What would be better, though, is to have 3 split windows like this ([C-x 2] in the left window): alt text http://bitthicket.com/files/emacs-3split.jpg And have the bottom left window contain the CScope search buffer, and the top left window be the only buffer that CScope ever updates. That way, I can see my CScope searches and navigate around the code without losing the buffer I'm focused on. Anyone know how I can do that? ANSWER: Put this in your.emacs file:;; Toggle window dedication (defun toggle-window-dedicated () "Toggle whether the current active window is dedicated or not" (interactive) (message (if (let (window (get-buffer-window (current-buffer))) (set-window-dedicated-p window (not (window-dedicated-p window)))) "Window '%s' is dedicated" "Window '%s' is normal") (current-buffer))) Then bind it to some key - I use the Pause key: (global-set-key [pause] 'toggle-window-dedicated) And then use it to "dedicate" the window you want locked. then cscope can only open files from its result window in some OTHER window. Works a charm. I specifically use it for exactly this purpose - keeping one source file always on screen, while using cscope in a second buffer/window, and looking at cscope results in a third.
[ "emacs", "cscope" ]
24
35
5,969
2
0
2008-09-04T13:31:57.893000
2008-09-15T19:31:43.363000
43,768
43,771
WPF control performance
What is a good (and preferably simple) way to test the rendering performance of WPF custom controls? I have several complex controls in which rendering performance is highly crucial. I want to be able to make sure that I can have lots of them drawwing out in a designer with a minimal impact on performance.
Tool called Perforator will help you. See following article for details: Performance Profiling Tools for WPF
WPF control performance What is a good (and preferably simple) way to test the rendering performance of WPF custom controls? I have several complex controls in which rendering performance is highly crucial. I want to be able to make sure that I can have lots of them drawwing out in a designer with a minimal impact on performance.
TITLE: WPF control performance QUESTION: What is a good (and preferably simple) way to test the rendering performance of WPF custom controls? I have several complex controls in which rendering performance is highly crucial. I want to be able to make sure that I can have lots of them drawwing out in a designer with a minimal impact on performance. ANSWER: Tool called Perforator will help you. See following article for details: Performance Profiling Tools for WPF
[ ".net", "wpf", "performance" ]
10
2
576
1
0
2008-09-04T13:32:36.130000
2008-09-04T13:33:44.893000
43,775
43,794
Modulus operation with negatives values - weird thing?
Can you please tell me how much is (-2) % 5? According to my Python interpreter is 3, but do you have a wise explanation for this? I've read that in some languages the result can be machine-dependent, but I'm not sure though.
By the way: most programming languages would disagree with Python and give the result -2. Depending on the interpretation of modulus this is correct. However, the most agreed-upon mathematical definition states that the modulus of a and b is the (strictly positive) rest r of the division of a / b. More precisely, 0 <= r < b by definition.
Modulus operation with negatives values - weird thing? Can you please tell me how much is (-2) % 5? According to my Python interpreter is 3, but do you have a wise explanation for this? I've read that in some languages the result can be machine-dependent, but I'm not sure though.
TITLE: Modulus operation with negatives values - weird thing? QUESTION: Can you please tell me how much is (-2) % 5? According to my Python interpreter is 3, but do you have a wise explanation for this? I've read that in some languages the result can be machine-dependent, but I'm not sure though. ANSWER: By the way: most programming languages would disagree with Python and give the result -2. Depending on the interpretation of modulus this is correct. However, the most agreed-upon mathematical definition states that the modulus of a and b is the (strictly positive) rest r of the division of a / b. More precisely, 0 <= r < b by definition.
[ "python", "math", "modulo" ]
18
16
12,545
12
0
2008-09-04T13:36:46.917000
2008-09-04T13:46:23.663000
43,777
43,792
'method' vs. 'message' vs. 'function' vs. '???'
I recently asked a question about what I called "method calls". The answer referred to "messages". As a self-taught hobby programmer trying to phrase questions that don't make me look like an idiot, I'm realizing that the terminology that I use reveals a lot about how I learned to program. Is there a distinction between the various terms for methods/messages/etc. in OO programming? Is this a difference that comes from different programming languages using different terminology to describe similar concepts? I seem to remember that in pre-OO languages, a distinction would sometimes be made between "subroutines" and "functions" based on whether a return value was expected, but even then, was this a language-by-language distinction?
I've found this to be a language and programming-paradigm thing. One paradigm — OOP — refers to objects with member methods, which conceptually are how you send messages to those objects (this view is reflected in UML, for example). Another paradigm — functional — may or may not involve classes of objects, but functions are the atomic unit of work. In structured programming, you had sub-routines (notice that the prefix "sub" implies structure). In imperative programming (which overlaps with structured quite a lot, but a slightly different way of looking at things), you have a more formulaic view of the world, and so 'functions' represent some operation (often mathematical). All you have to do to not sound like a rube is to use the terminology used by the language reference for the language you're using.
'method' vs. 'message' vs. 'function' vs. '???' I recently asked a question about what I called "method calls". The answer referred to "messages". As a self-taught hobby programmer trying to phrase questions that don't make me look like an idiot, I'm realizing that the terminology that I use reveals a lot about how I learned to program. Is there a distinction between the various terms for methods/messages/etc. in OO programming? Is this a difference that comes from different programming languages using different terminology to describe similar concepts? I seem to remember that in pre-OO languages, a distinction would sometimes be made between "subroutines" and "functions" based on whether a return value was expected, but even then, was this a language-by-language distinction?
TITLE: 'method' vs. 'message' vs. 'function' vs. '???' QUESTION: I recently asked a question about what I called "method calls". The answer referred to "messages". As a self-taught hobby programmer trying to phrase questions that don't make me look like an idiot, I'm realizing that the terminology that I use reveals a lot about how I learned to program. Is there a distinction between the various terms for methods/messages/etc. in OO programming? Is this a difference that comes from different programming languages using different terminology to describe similar concepts? I seem to remember that in pre-OO languages, a distinction would sometimes be made between "subroutines" and "functions" based on whether a return value was expected, but even then, was this a language-by-language distinction? ANSWER: I've found this to be a language and programming-paradigm thing. One paradigm — OOP — refers to objects with member methods, which conceptually are how you send messages to those objects (this view is reflected in UML, for example). Another paradigm — functional — may or may not involve classes of objects, but functions are the atomic unit of work. In structured programming, you had sub-routines (notice that the prefix "sub" implies structure). In imperative programming (which overlaps with structured quite a lot, but a slightly different way of looking at things), you have a more formulaic view of the world, and so 'functions' represent some operation (often mathematical). All you have to do to not sound like a rube is to use the terminology used by the language reference for the language you're using.
[ "language-agnostic", "terminology" ]
34
18
11,059
11
0
2008-09-04T13:39:15.443000
2008-09-04T13:45:18.877000
43,778
43,840
sqlite3-ruby gem: Failed to build gem native extension
Update: Check out this follow-up question: Gem Update on Windows - is it broken? On Windows, when I do this: gem install sqlite3-ruby I get the following error: Building native extensions. This could take a while... ERROR: Error installing sqlite3-ruby: ERROR: Failed to build gem native extension. c:/ruby/bin/ruby.exe extconf.rb install sqlite3-ruby --platform Win32 checking for fdatasync() in rt.lib... no checking for sqlite3.h... no nmake 'nmake' is not recognized as an internal or external command, operable program or batch file. Gem files will remain installed in c:/ruby/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.4 for inspection. Results logged to c:/ruby/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.4/ext/sqlite3_api/gem_make.out Same thing happens with the hpricot gem. I seem to remember these gems installed just fine on < 1.0 gems, but now I'm on 1.2.0, things have gone screwy. I have also tried this: gem install sqlite3-ruby --platform Win32 Needless to say, this doesn't work either (same error) Does anyone know what is going on here and how to fix this? Update: Check out this follow-up question: Gem Update on Windows - is it broken?
As Nathan suggests, this does appear to be related to the fact that the latest versions of the sqlite3-ruby and hpricot gems don't appear to have Windows versions. Here's what to do when faced with this situation (note, the name of the gem is automatically wildcarded, so you can type just sql and get a list of all gems beginning with sql ): $ gem list --remote --all sqlite *** REMOTE GEMS *** sqlite (2.0.1, 2.0.0, 1.3.1, 1.3.0, 1.2.9.1, 1.2.0, 1.1.3, 1.1.2, 1.1.1, 1.1) sqlite-ruby (2.2.3, 2.2.2, 2.2.1, 2.2.0, 2.1.0, 2.0.3, 2.0.2) sqlite3-ruby (1.2.4, 1.2.3, 1.2.2, 1.2.1, 1.2.0, 1.1.0, 1.0.1, 1.0.0, 0.9.0, 0.6.0, 0.5.0) Then you can choose the version you would like to install: gem install sqlite3-ruby -v 1.2.3 To successfully install hpricot, I did this: gem install hpricot -v 0.6 Annoyingly, doing a gem update tries to update the gems to their latest, broken-on-Windows, versions. When the update routine encounters an error, it ditches you out of the whole process. There's a (hacky) solution to this problem here. So, is this issue a bug in gems? Should gems not automatically detect the platform and install the latest compatible version?
sqlite3-ruby gem: Failed to build gem native extension Update: Check out this follow-up question: Gem Update on Windows - is it broken? On Windows, when I do this: gem install sqlite3-ruby I get the following error: Building native extensions. This could take a while... ERROR: Error installing sqlite3-ruby: ERROR: Failed to build gem native extension. c:/ruby/bin/ruby.exe extconf.rb install sqlite3-ruby --platform Win32 checking for fdatasync() in rt.lib... no checking for sqlite3.h... no nmake 'nmake' is not recognized as an internal or external command, operable program or batch file. Gem files will remain installed in c:/ruby/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.4 for inspection. Results logged to c:/ruby/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.4/ext/sqlite3_api/gem_make.out Same thing happens with the hpricot gem. I seem to remember these gems installed just fine on < 1.0 gems, but now I'm on 1.2.0, things have gone screwy. I have also tried this: gem install sqlite3-ruby --platform Win32 Needless to say, this doesn't work either (same error) Does anyone know what is going on here and how to fix this? Update: Check out this follow-up question: Gem Update on Windows - is it broken?
TITLE: sqlite3-ruby gem: Failed to build gem native extension QUESTION: Update: Check out this follow-up question: Gem Update on Windows - is it broken? On Windows, when I do this: gem install sqlite3-ruby I get the following error: Building native extensions. This could take a while... ERROR: Error installing sqlite3-ruby: ERROR: Failed to build gem native extension. c:/ruby/bin/ruby.exe extconf.rb install sqlite3-ruby --platform Win32 checking for fdatasync() in rt.lib... no checking for sqlite3.h... no nmake 'nmake' is not recognized as an internal or external command, operable program or batch file. Gem files will remain installed in c:/ruby/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.4 for inspection. Results logged to c:/ruby/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.4/ext/sqlite3_api/gem_make.out Same thing happens with the hpricot gem. I seem to remember these gems installed just fine on < 1.0 gems, but now I'm on 1.2.0, things have gone screwy. I have also tried this: gem install sqlite3-ruby --platform Win32 Needless to say, this doesn't work either (same error) Does anyone know what is going on here and how to fix this? Update: Check out this follow-up question: Gem Update on Windows - is it broken? ANSWER: As Nathan suggests, this does appear to be related to the fact that the latest versions of the sqlite3-ruby and hpricot gems don't appear to have Windows versions. Here's what to do when faced with this situation (note, the name of the gem is automatically wildcarded, so you can type just sql and get a list of all gems beginning with sql ): $ gem list --remote --all sqlite *** REMOTE GEMS *** sqlite (2.0.1, 2.0.0, 1.3.1, 1.3.0, 1.2.9.1, 1.2.0, 1.1.3, 1.1.2, 1.1.1, 1.1) sqlite-ruby (2.2.3, 2.2.2, 2.2.1, 2.2.0, 2.1.0, 2.0.3, 2.0.2) sqlite3-ruby (1.2.4, 1.2.3, 1.2.2, 1.2.1, 1.2.0, 1.1.0, 1.0.1, 1.0.0, 0.9.0, 0.6.0, 0.5.0) Then you can choose the version you would like to install: gem install sqlite3-ruby -v 1.2.3 To successfully install hpricot, I did this: gem install hpricot -v 0.6 Annoyingly, doing a gem update tries to update the gems to their latest, broken-on-Windows, versions. When the update routine encounters an error, it ditches you out of the whole process. There's a (hacky) solution to this problem here. So, is this issue a bug in gems? Should gems not automatically detect the platform and install the latest compatible version?
[ "windows", "ruby", "rubygems" ]
22
28
54,915
6
0
2008-09-04T13:40:19.670000
2008-09-04T14:13:02.227000
43,802
43,807
How to convert a date String to a Date or Calendar object?
I have a String representation of a date that I need to create a Date or Calendar object from. I've looked through Date and Calendar APIs but haven't found anything that can do this other than creating my own ugly parse method. I know there must be a way, does anyone know of a solution?
In brief: DateFormat formatter = new SimpleDateFormat("MM/dd/yy"); try { Date date = formatter.parse("01/29/02"); } catch (ParseException e) { e.printStackTrace(); } See SimpleDateFormat javadoc for more. And to turn it into a Calendar, do: Calendar calendar = Calendar.getInstance(); calendar.setTime(date);
How to convert a date String to a Date or Calendar object? I have a String representation of a date that I need to create a Date or Calendar object from. I've looked through Date and Calendar APIs but haven't found anything that can do this other than creating my own ugly parse method. I know there must be a way, does anyone know of a solution?
TITLE: How to convert a date String to a Date or Calendar object? QUESTION: I have a String representation of a date that I need to create a Date or Calendar object from. I've looked through Date and Calendar APIs but haven't found anything that can do this other than creating my own ugly parse method. I know there must be a way, does anyone know of a solution? ANSWER: In brief: DateFormat formatter = new SimpleDateFormat("MM/dd/yy"); try { Date date = formatter.parse("01/29/02"); } catch (ParseException e) { e.printStackTrace(); } See SimpleDateFormat javadoc for more. And to turn it into a Calendar, do: Calendar calendar = Calendar.getInstance(); calendar.setTime(date);
[ "java", "date", "calendar" ]
63
126
134,330
5
0
2008-09-04T13:54:17.683000
2008-09-04T13:56:37.320000
43,803
43,894
How do I best populate an HTML table in ASP.NET?
This is what I've got. It works. But, is there a simpler or better way? ASPX Page… Published Title Author Price ASPX.VB Code Behind… Protected Sub Page_Load( ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim db As New BookstoreDataContext RepeaterBooks.DataSource = From b In db.Books _ Order By b.Published _ Select b RepeaterBooks.DataBind() End Sub Sub RepeaterBooks_ItemDataBound( ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles RepeaterBooks.ItemDataBound If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then Dim b As Book = DirectCast(e.Item.DataItem, Book) DirectCast(e.Item.FindControl("LiteralPublished"), Literal).Text = " " + b.Published.ToShortDateString + " " DirectCast(e.Item.FindControl("LiteralTitle"), Literal).Text = " " + TryNbsp(HttpContext.Current.Server.HtmlEncode(b.Title)) + " " DirectCast(e.Item.FindControl("LiteralAuthor"), Literal).Text = " " + TryNbsp(HttpContext.Current.Server.HtmlEncode(b.Author)) + " " DirectCast(e.Item.FindControl("LiteralPrice"), Literal).Text = " " + Format(b.Price, "c") + " " End If End Sub Function TryNbsp(ByVal s As String) As String If s = "" Then Return " " Else Return s End If End Function
@Geoff That sort of Eval statement was actually added in 2.0, but if performance is important Eval should be avoided since it uses Reflection. The repeater is a pretty good way of doing it, although it might be faster to generate the table in code: ASPX Page: Published Title Author Price Code Behind: Protected Sub Page_Load( ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Not Page.IsPostback Then BuildTable() End If End Sub Private Sub BuildTable() Dim db As New BookstoreDataContext Dim bookCollection = from b in db.Books _ Order By b.Published _ Select b Dim row As HtmlTableRow Dim cell As HtmlTableCell For Each book As Books In bookCollection row = New HtmlTableRow() cell = New HtmlTableCell With {.InnerText = b.Published.ToShortDateString } row.Controls.Add(cell) cell = New HtmlTableCell With {.InnerText = TryNbsp(HttpContext.Current.Server.HtmlEncode(b.Title)) } row.Controls.Add(cell) cell = New HtmlTableCell With {.InnerText = TryNbsp(HttpContext.Current.Server.HtmlEncode(b.Author)) row.Controls.Add(cell) cell = New HtmlTableCell With {.InnerText = Format(b.Price, "c") } row.Controls.Add(cell) bookTable.Controls.Add(row) Next I guess it depends on how important speed is to you. For simplicity's sake I think I would go with the Repeater.
How do I best populate an HTML table in ASP.NET? This is what I've got. It works. But, is there a simpler or better way? ASPX Page… Published Title Author Price ASPX.VB Code Behind… Protected Sub Page_Load( ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim db As New BookstoreDataContext RepeaterBooks.DataSource = From b In db.Books _ Order By b.Published _ Select b RepeaterBooks.DataBind() End Sub Sub RepeaterBooks_ItemDataBound( ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles RepeaterBooks.ItemDataBound If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then Dim b As Book = DirectCast(e.Item.DataItem, Book) DirectCast(e.Item.FindControl("LiteralPublished"), Literal).Text = " " + b.Published.ToShortDateString + " " DirectCast(e.Item.FindControl("LiteralTitle"), Literal).Text = " " + TryNbsp(HttpContext.Current.Server.HtmlEncode(b.Title)) + " " DirectCast(e.Item.FindControl("LiteralAuthor"), Literal).Text = " " + TryNbsp(HttpContext.Current.Server.HtmlEncode(b.Author)) + " " DirectCast(e.Item.FindControl("LiteralPrice"), Literal).Text = " " + Format(b.Price, "c") + " " End If End Sub Function TryNbsp(ByVal s As String) As String If s = "" Then Return " " Else Return s End If End Function
TITLE: How do I best populate an HTML table in ASP.NET? QUESTION: This is what I've got. It works. But, is there a simpler or better way? ASPX Page… Published Title Author Price ASPX.VB Code Behind… Protected Sub Page_Load( ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim db As New BookstoreDataContext RepeaterBooks.DataSource = From b In db.Books _ Order By b.Published _ Select b RepeaterBooks.DataBind() End Sub Sub RepeaterBooks_ItemDataBound( ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles RepeaterBooks.ItemDataBound If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then Dim b As Book = DirectCast(e.Item.DataItem, Book) DirectCast(e.Item.FindControl("LiteralPublished"), Literal).Text = " " + b.Published.ToShortDateString + " " DirectCast(e.Item.FindControl("LiteralTitle"), Literal).Text = " " + TryNbsp(HttpContext.Current.Server.HtmlEncode(b.Title)) + " " DirectCast(e.Item.FindControl("LiteralAuthor"), Literal).Text = " " + TryNbsp(HttpContext.Current.Server.HtmlEncode(b.Author)) + " " DirectCast(e.Item.FindControl("LiteralPrice"), Literal).Text = " " + Format(b.Price, "c") + " " End If End Sub Function TryNbsp(ByVal s As String) As String If s = "" Then Return " " Else Return s End If End Function ANSWER: @Geoff That sort of Eval statement was actually added in 2.0, but if performance is important Eval should be avoided since it uses Reflection. The repeater is a pretty good way of doing it, although it might be faster to generate the table in code: ASPX Page: Published Title Author Price Code Behind: Protected Sub Page_Load( ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Not Page.IsPostback Then BuildTable() End If End Sub Private Sub BuildTable() Dim db As New BookstoreDataContext Dim bookCollection = from b in db.Books _ Order By b.Published _ Select b Dim row As HtmlTableRow Dim cell As HtmlTableCell For Each book As Books In bookCollection row = New HtmlTableRow() cell = New HtmlTableCell With {.InnerText = b.Published.ToShortDateString } row.Controls.Add(cell) cell = New HtmlTableCell With {.InnerText = TryNbsp(HttpContext.Current.Server.HtmlEncode(b.Title)) } row.Controls.Add(cell) cell = New HtmlTableCell With {.InnerText = TryNbsp(HttpContext.Current.Server.HtmlEncode(b.Author)) row.Controls.Add(cell) cell = New HtmlTableCell With {.InnerText = Format(b.Price, "c") } row.Controls.Add(cell) bookTable.Controls.Add(row) Next I guess it depends on how important speed is to you. For simplicity's sake I think I would go with the Repeater.
[ "asp.net", "html", "vb.net" ]
5
4
18,545
8
0
2008-09-04T13:54:43.177000
2008-09-04T14:36:54.977000
43,805
43,810
Example of c# based rule language?
Can you provide a good example of rule definition language written in C#. Java guys have JESS, is there anything good for C#?
This page shows some examples of open-source rules engines in C#: http://csharp-source.net/open-source/rule-engines
Example of c# based rule language? Can you provide a good example of rule definition language written in C#. Java guys have JESS, is there anything good for C#?
TITLE: Example of c# based rule language? QUESTION: Can you provide a good example of rule definition language written in C#. Java guys have JESS, is there anything good for C#? ANSWER: This page shows some examples of open-source rules engines in C#: http://csharp-source.net/open-source/rule-engines
[ "c#", "rule-engine" ]
16
9
22,079
8
0
2008-09-04T13:54:48.463000
2008-09-04T13:57:24.557000
43,808
43,830
How to prefetch Oracle sequence ID-s in a distributed environment
I have a distributed Java application running on 5 application servers. The servers all use the same Oracle 9i database running on a 6th machine. The application need to prefetch a batch of 100 IDs from a sequence. It's relatively easy to do in a single-threaded, non-distributed environment, you can just issue these queries: SELECT seq.nextval FROM dual; ALTER SEQUENCE seq INCREMENT BY 100; SELECT seq.nextval FROM dual; The first select fetches the first sequence ID that the application can use, the second select returns the last one that can be used. Things get way more interesting in a multithreaded environment. You can't be sure that before the second select another thread doesn't increase the sequence by 100 again. This issue can be solved by synchronizing the access on the Java side - you only let one thread begin fetching the IDs at one time. The situation becomes really hard when you can't synchronize because parts of the application doesn't run on the same JVM, not even on the same physical machine. I found some references on forums that others have problems with solving this problem too, but none of the answers are really working not to mention being reasonable. Can the community provide a solution for this problem? Some more information: I can't really play with the transaction isolation levels. I use JPA and the change would affect the entire application, not only the prefetching queries and that's not acceptable for me. On PostgreSQL I could do the following: SELECT setval('seq', NEXTVAL('seq') + n - 1) The solution by Matthew works when you can use a fixed increment value (which is perfectly acceptable in my case). However is there a solution when you don't want to fix the size of the increment, but want to adjust it dynamically?
Why not just have the sequence as increment by 100 all the time? each "nextval" gives you 100 sequence numbers to work with SQL> create sequence so_test start with 100 increment by 100 nocache; Sequence created. SQL> select so_test.nextval - 99 as first_seq, so_test.currval as last_seq from dual; FIRST_SEQ LAST_SEQ ---------- ---------- 1 100 SQL> / FIRST_SEQ LAST_SEQ ---------- ---------- 101 200 SQL> / FIRST_SEQ LAST_SEQ ---------- ---------- 201 300 SQL> A note on your example.. Watch out for DDL.. It will produce an implicit commit Example of commit produced by DDL SQL> select * from xx; no rows selected SQL> insert into xx values ('x'); 1 row created. SQL> alter sequence so_test increment by 100; Sequence altered. SQL> rollback; Rollback complete. SQL> select * from xx; Y ----- x SQL>
How to prefetch Oracle sequence ID-s in a distributed environment I have a distributed Java application running on 5 application servers. The servers all use the same Oracle 9i database running on a 6th machine. The application need to prefetch a batch of 100 IDs from a sequence. It's relatively easy to do in a single-threaded, non-distributed environment, you can just issue these queries: SELECT seq.nextval FROM dual; ALTER SEQUENCE seq INCREMENT BY 100; SELECT seq.nextval FROM dual; The first select fetches the first sequence ID that the application can use, the second select returns the last one that can be used. Things get way more interesting in a multithreaded environment. You can't be sure that before the second select another thread doesn't increase the sequence by 100 again. This issue can be solved by synchronizing the access on the Java side - you only let one thread begin fetching the IDs at one time. The situation becomes really hard when you can't synchronize because parts of the application doesn't run on the same JVM, not even on the same physical machine. I found some references on forums that others have problems with solving this problem too, but none of the answers are really working not to mention being reasonable. Can the community provide a solution for this problem? Some more information: I can't really play with the transaction isolation levels. I use JPA and the change would affect the entire application, not only the prefetching queries and that's not acceptable for me. On PostgreSQL I could do the following: SELECT setval('seq', NEXTVAL('seq') + n - 1) The solution by Matthew works when you can use a fixed increment value (which is perfectly acceptable in my case). However is there a solution when you don't want to fix the size of the increment, but want to adjust it dynamically?
TITLE: How to prefetch Oracle sequence ID-s in a distributed environment QUESTION: I have a distributed Java application running on 5 application servers. The servers all use the same Oracle 9i database running on a 6th machine. The application need to prefetch a batch of 100 IDs from a sequence. It's relatively easy to do in a single-threaded, non-distributed environment, you can just issue these queries: SELECT seq.nextval FROM dual; ALTER SEQUENCE seq INCREMENT BY 100; SELECT seq.nextval FROM dual; The first select fetches the first sequence ID that the application can use, the second select returns the last one that can be used. Things get way more interesting in a multithreaded environment. You can't be sure that before the second select another thread doesn't increase the sequence by 100 again. This issue can be solved by synchronizing the access on the Java side - you only let one thread begin fetching the IDs at one time. The situation becomes really hard when you can't synchronize because parts of the application doesn't run on the same JVM, not even on the same physical machine. I found some references on forums that others have problems with solving this problem too, but none of the answers are really working not to mention being reasonable. Can the community provide a solution for this problem? Some more information: I can't really play with the transaction isolation levels. I use JPA and the change would affect the entire application, not only the prefetching queries and that's not acceptable for me. On PostgreSQL I could do the following: SELECT setval('seq', NEXTVAL('seq') + n - 1) The solution by Matthew works when you can use a fixed increment value (which is perfectly acceptable in my case). However is there a solution when you don't want to fix the size of the increment, but want to adjust it dynamically? ANSWER: Why not just have the sequence as increment by 100 all the time? each "nextval" gives you 100 sequence numbers to work with SQL> create sequence so_test start with 100 increment by 100 nocache; Sequence created. SQL> select so_test.nextval - 99 as first_seq, so_test.currval as last_seq from dual; FIRST_SEQ LAST_SEQ ---------- ---------- 1 100 SQL> / FIRST_SEQ LAST_SEQ ---------- ---------- 101 200 SQL> / FIRST_SEQ LAST_SEQ ---------- ---------- 201 300 SQL> A note on your example.. Watch out for DDL.. It will produce an implicit commit Example of commit produced by DDL SQL> select * from xx; no rows selected SQL> insert into xx values ('x'); 1 row created. SQL> alter sequence so_test increment by 100; Sequence altered. SQL> rollback; Rollback complete. SQL> select * from xx; Y ----- x SQL>
[ "java", "oracle" ]
6
11
7,325
4
0
2008-09-04T13:56:45.057000
2008-09-04T14:10:39.940000
43,809
43,872
Which JSTL URL should I reference in my JSPs?
I'm getting the following error when trying to run a JSP. I'm using Tomcat 6.0.18, and I'd like to use the latest version of JSTL. What version of JSTL should I use, and which URL goes with which version of JSTL? I'm getting this error "According to TLD or attribute directive in tag file, attribute key does not accept any expressions" <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %> I'll just say I had this working, but I want to switch the JSTL jar file that has the TLD files in the jar file. (instead of having to deploy them somewhere in the web application and define the references in web.xml).
Go with <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> More on this topic here
Which JSTL URL should I reference in my JSPs? I'm getting the following error when trying to run a JSP. I'm using Tomcat 6.0.18, and I'd like to use the latest version of JSTL. What version of JSTL should I use, and which URL goes with which version of JSTL? I'm getting this error "According to TLD or attribute directive in tag file, attribute key does not accept any expressions" <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %> I'll just say I had this working, but I want to switch the JSTL jar file that has the TLD files in the jar file. (instead of having to deploy them somewhere in the web application and define the references in web.xml).
TITLE: Which JSTL URL should I reference in my JSPs? QUESTION: I'm getting the following error when trying to run a JSP. I'm using Tomcat 6.0.18, and I'd like to use the latest version of JSTL. What version of JSTL should I use, and which URL goes with which version of JSTL? I'm getting this error "According to TLD or attribute directive in tag file, attribute key does not accept any expressions" <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %> I'll just say I had this working, but I want to switch the JSTL jar file that has the TLD files in the jar file. (instead of having to deploy them somewhere in the web application and define the references in web.xml). ANSWER: Go with <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> More on this topic here
[ "jsp", "jstl", "uri", "taglib" ]
7
5
1,254
1
0
2008-09-04T13:57:15.243000
2008-09-04T14:28:30.550000
43,811
43,824
jQuery slicing and click events
This is probably a really simple jQuery question, but I couldn't answer it after 10 minutes in the documentation so... I have a list of checkboxes, and I can get them with the selector 'input[type=checkbox]'. I want the user to be able to shift-click and select a range of checkboxes. To accomplish this, I need to get the index of a checkbox in the list, so I can pass that index to.slice(start, end). How do I get the index when the user clicks a box?
The following selector should also work in jQuery: input:checkbox. You can then string the:gt(index) and:lt(index) filters together, so if you want the 5th to 7th checkboxes, you'd use input:checkbox:gt(4):lt(2). To get the index of the currently clicked checkbox, just use $("input:checkbox").index($(this)).
jQuery slicing and click events This is probably a really simple jQuery question, but I couldn't answer it after 10 minutes in the documentation so... I have a list of checkboxes, and I can get them with the selector 'input[type=checkbox]'. I want the user to be able to shift-click and select a range of checkboxes. To accomplish this, I need to get the index of a checkbox in the list, so I can pass that index to.slice(start, end). How do I get the index when the user clicks a box?
TITLE: jQuery slicing and click events QUESTION: This is probably a really simple jQuery question, but I couldn't answer it after 10 minutes in the documentation so... I have a list of checkboxes, and I can get them with the selector 'input[type=checkbox]'. I want the user to be able to shift-click and select a range of checkboxes. To accomplish this, I need to get the index of a checkbox in the list, so I can pass that index to.slice(start, end). How do I get the index when the user clicks a box? ANSWER: The following selector should also work in jQuery: input:checkbox. You can then string the:gt(index) and:lt(index) filters together, so if you want the 5th to 7th checkboxes, you'd use input:checkbox:gt(4):lt(2). To get the index of the currently clicked checkbox, just use $("input:checkbox").index($(this)).
[ "javascript", "jquery" ]
7
9
1,578
4
0
2008-09-04T13:57:25.697000
2008-09-04T14:07:16.437000
43,823
47,083
How well will WCF scale to a large number of client users?
Does anyone have any experience with how well web services build with Microsoft's WCF will scale to a large number of users? The level I'm thinking of is in the region of 1000+ client users connecting to a collection of WCF services providing the business logic for our application, and these talking to a database - similar to a traditional 3-tier architecture. Are there any particular gotchas that have slowed down performance, or any design lessons learnt that have enabled this level of scalability?
To ensure your WCF application can scale to the desired level I think you might need to tweak your thinking about the stats your services have to meet. You mention servicing "1000+ client users" but to gauge if your services can perform at that level you'll also need to have some estimated usage figures, which will help you calculate some simpler stats such as the number of requests per second your app needs to handle. Having just finished working on a WCF project we managed to get 400 requests per second on our test hardware, which combined with our expected usage pattern of each user making 300 requests a day indicated we could handle an average of 100,000 users a day (assuming a flat usage graph across the day). In addition, since it's fairly common to make the WCF service code stateless, it's pretty easy to scale out the actual WCF code by adding additional boxes, which means the overall performance of your system is much more likely to be limited by your business logic and persistence layer than it is by WCF.
How well will WCF scale to a large number of client users? Does anyone have any experience with how well web services build with Microsoft's WCF will scale to a large number of users? The level I'm thinking of is in the region of 1000+ client users connecting to a collection of WCF services providing the business logic for our application, and these talking to a database - similar to a traditional 3-tier architecture. Are there any particular gotchas that have slowed down performance, or any design lessons learnt that have enabled this level of scalability?
TITLE: How well will WCF scale to a large number of client users? QUESTION: Does anyone have any experience with how well web services build with Microsoft's WCF will scale to a large number of users? The level I'm thinking of is in the region of 1000+ client users connecting to a collection of WCF services providing the business logic for our application, and these talking to a database - similar to a traditional 3-tier architecture. Are there any particular gotchas that have slowed down performance, or any design lessons learnt that have enabled this level of scalability? ANSWER: To ensure your WCF application can scale to the desired level I think you might need to tweak your thinking about the stats your services have to meet. You mention servicing "1000+ client users" but to gauge if your services can perform at that level you'll also need to have some estimated usage figures, which will help you calculate some simpler stats such as the number of requests per second your app needs to handle. Having just finished working on a WCF project we managed to get 400 requests per second on our test hardware, which combined with our expected usage pattern of each user making 300 requests a day indicated we could handle an average of 100,000 users a day (assuming a flat usage graph across the day). In addition, since it's fairly common to make the WCF service code stateless, it's pretty easy to scale out the actual WCF code by adding additional boxes, which means the overall performance of your system is much more likely to be limited by your business logic and persistence layer than it is by WCF.
[ "wcf", "scalability", "soa" ]
19
15
9,382
3
0
2008-09-04T14:06:57.920000
2008-09-05T23:32:19.750000
43,842
43,852
How Would You Programmatically Create a Pattern from a Date that is Stored in a String?
I have a string that contains the representation of a date. It looks like: Thu Nov 30 19:00:00 EST 2006 I'm trying to create a Date object using SimpleDateFormat and have 2 problems. 1.) I can't figure out the pattern to hard-code the solution into the SimpleDateFormat constructor 2.) I can't find a way I could parse the string using API to determine the pattern so I could reuse this for different patterns of date output If anyone knows a solution using API or a custom solution I would greatly appreciate it.
The format to pass to SimpleDateFormat could be looked up at http://java.sun.com/javase/6/docs/api/java/text/SimpleDateFormat.html new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy") As for your second question, I don't know of any Java library to figure out a date format and parse it without knowing in advance what the format is.
How Would You Programmatically Create a Pattern from a Date that is Stored in a String? I have a string that contains the representation of a date. It looks like: Thu Nov 30 19:00:00 EST 2006 I'm trying to create a Date object using SimpleDateFormat and have 2 problems. 1.) I can't figure out the pattern to hard-code the solution into the SimpleDateFormat constructor 2.) I can't find a way I could parse the string using API to determine the pattern so I could reuse this for different patterns of date output If anyone knows a solution using API or a custom solution I would greatly appreciate it.
TITLE: How Would You Programmatically Create a Pattern from a Date that is Stored in a String? QUESTION: I have a string that contains the representation of a date. It looks like: Thu Nov 30 19:00:00 EST 2006 I'm trying to create a Date object using SimpleDateFormat and have 2 problems. 1.) I can't figure out the pattern to hard-code the solution into the SimpleDateFormat constructor 2.) I can't find a way I could parse the string using API to determine the pattern so I could reuse this for different patterns of date output If anyone knows a solution using API or a custom solution I would greatly appreciate it. ANSWER: The format to pass to SimpleDateFormat could be looked up at http://java.sun.com/javase/6/docs/api/java/text/SimpleDateFormat.html new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy") As for your second question, I don't know of any Java library to figure out a date format and parse it without knowing in advance what the format is.
[ "java", "date" ]
6
8
2,569
11
0
2008-09-04T14:15:26.340000
2008-09-04T14:21:12.283000
43,866
43,901
How SID is different from Service name in Oracle tnsnames.ora
Why do I need two of them? When I have to use one or another?
Quote by @DAC In short: SID = the unique name of your DB, ServiceName = the alias used when connecting Not strictly true. SID = unique name of the INSTANCE (eg the oracle process running on the machine). Oracle considers the "Database" to be the files. Service Name = alias to an INSTANCE (or many instances). The main purpose of this is if you are running a cluster, the client can say "connect me to SALES.acme.com ", the DBA can on the fly change the number of instances which are available to SALES.acme.com requests, or even move SALES.acme.com to a completely different database without the client needing to change any settings.
How SID is different from Service name in Oracle tnsnames.ora Why do I need two of them? When I have to use one or another?
TITLE: How SID is different from Service name in Oracle tnsnames.ora QUESTION: Why do I need two of them? When I have to use one or another? ANSWER: Quote by @DAC In short: SID = the unique name of your DB, ServiceName = the alias used when connecting Not strictly true. SID = unique name of the INSTANCE (eg the oracle process running on the machine). Oracle considers the "Database" to be the files. Service Name = alias to an INSTANCE (or many instances). The main purpose of this is if you are running a cluster, the client can say "connect me to SALES.acme.com ", the DBA can on the fly change the number of instances which are available to SALES.acme.com requests, or even move SALES.acme.com to a completely different database without the client needing to change any settings.
[ "database", "oracle", "service", "administration", "sid" ]
201
169
617,225
5
0
2008-09-04T14:26:06.593000
2008-09-04T14:39:55.250000
43,870
43,944
How to concatenate strings of a string field in a PostgreSQL 'group by' query?
I am looking for a way to concatenate the strings of a field within a group by query. So for example, I have a table: ID COMPANY_ID EMPLOYEE 1 1 Anna 2 1 Bill 3 2 Carol 4 2 Dave and I wanted to group by company_id to get something like: COMPANY_ID EMPLOYEE 1 Anna, Bill 2 Carol, Dave There is a built-in function in mySQL to do this group_concat
PostgreSQL 9.0 or later: Modern Postgres (since 2010) has the string_agg(expression, delimiter) function which will do exactly what the asker was looking for: SELECT company_id, string_agg(employee, ', ') FROM mytable GROUP BY company_id; Postgres 9 also added the ability to specify an ORDER BY clause in any aggregate expression; otherwise you have to order all your results or deal with an undefined order. So you can now write: SELECT company_id, string_agg(employee, ', ' ORDER BY employee) FROM mytable GROUP BY company_id; PostgreSQL 8.4.x: Please note that support for Postgres 8.4 ended in 2014, so you should probably upgrade for more important reasons than string aggregation. PostgreSQL 8.4 (in 2009) introduced the aggregate function array_agg(expression) which collects the values in an array. Then array_to_string() can be used to give the desired result: SELECT company_id, array_to_string(array_agg(employee), ', ') FROM mytable GROUP BY company_id; PostgreSQL 8.3.x and older: When this question was originally posed, there was no built-in aggregate function to concatenate strings. The simplest custom implementation ( suggested by Vajda Gabo in this mailing list post, among many others) is to use the built-in textcat function: CREATE AGGREGATE textcat_all( basetype = text, sfunc = textcat, stype = text, initcond = '' ); Here is the CREATE AGGREGATE documentation. This simply glues all the strings together, with no separator. In order to get a ", " inserted in between them without having it at the end, you might want to make your own concatenation function and substitute it for the "textcat" above. Here is one I put together and tested on 8.3.12: CREATE FUNCTION commacat(acc text, instr text) RETURNS text AS $$ BEGIN IF acc IS NULL OR acc = '' THEN RETURN instr; ELSE RETURN acc || ', ' || instr; END IF; END; $$ LANGUAGE plpgsql; This version will output a comma even if the value in the row is null or empty, so you get output like this: a, b, c,, e,, g If you would prefer to remove extra commas to output this: a, b, c, e, g Then add an ELSIF check to the function like this: CREATE FUNCTION commacat_ignore_nulls(acc text, instr text) RETURNS text AS $$ BEGIN IF acc IS NULL OR acc = '' THEN RETURN instr; ELSIF instr IS NULL OR instr = '' THEN RETURN acc; ELSE RETURN acc || ', ' || instr; END IF; END; $$ LANGUAGE plpgsql;
How to concatenate strings of a string field in a PostgreSQL 'group by' query? I am looking for a way to concatenate the strings of a field within a group by query. So for example, I have a table: ID COMPANY_ID EMPLOYEE 1 1 Anna 2 1 Bill 3 2 Carol 4 2 Dave and I wanted to group by company_id to get something like: COMPANY_ID EMPLOYEE 1 Anna, Bill 2 Carol, Dave There is a built-in function in mySQL to do this group_concat
TITLE: How to concatenate strings of a string field in a PostgreSQL 'group by' query? QUESTION: I am looking for a way to concatenate the strings of a field within a group by query. So for example, I have a table: ID COMPANY_ID EMPLOYEE 1 1 Anna 2 1 Bill 3 2 Carol 4 2 Dave and I wanted to group by company_id to get something like: COMPANY_ID EMPLOYEE 1 Anna, Bill 2 Carol, Dave There is a built-in function in mySQL to do this group_concat ANSWER: PostgreSQL 9.0 or later: Modern Postgres (since 2010) has the string_agg(expression, delimiter) function which will do exactly what the asker was looking for: SELECT company_id, string_agg(employee, ', ') FROM mytable GROUP BY company_id; Postgres 9 also added the ability to specify an ORDER BY clause in any aggregate expression; otherwise you have to order all your results or deal with an undefined order. So you can now write: SELECT company_id, string_agg(employee, ', ' ORDER BY employee) FROM mytable GROUP BY company_id; PostgreSQL 8.4.x: Please note that support for Postgres 8.4 ended in 2014, so you should probably upgrade for more important reasons than string aggregation. PostgreSQL 8.4 (in 2009) introduced the aggregate function array_agg(expression) which collects the values in an array. Then array_to_string() can be used to give the desired result: SELECT company_id, array_to_string(array_agg(employee), ', ') FROM mytable GROUP BY company_id; PostgreSQL 8.3.x and older: When this question was originally posed, there was no built-in aggregate function to concatenate strings. The simplest custom implementation ( suggested by Vajda Gabo in this mailing list post, among many others) is to use the built-in textcat function: CREATE AGGREGATE textcat_all( basetype = text, sfunc = textcat, stype = text, initcond = '' ); Here is the CREATE AGGREGATE documentation. This simply glues all the strings together, with no separator. In order to get a ", " inserted in between them without having it at the end, you might want to make your own concatenation function and substitute it for the "textcat" above. Here is one I put together and tested on 8.3.12: CREATE FUNCTION commacat(acc text, instr text) RETURNS text AS $$ BEGIN IF acc IS NULL OR acc = '' THEN RETURN instr; ELSE RETURN acc || ', ' || instr; END IF; END; $$ LANGUAGE plpgsql; This version will output a comma even if the value in the row is null or empty, so you get output like this: a, b, c,, e,, g If you would prefer to remove extra commas to output this: a, b, c, e, g Then add an ELSIF check to the function like this: CREATE FUNCTION commacat_ignore_nulls(acc text, instr text) RETURNS text AS $$ BEGIN IF acc IS NULL OR acc = '' THEN RETURN instr; ELSIF instr IS NULL OR instr = '' THEN RETURN acc; ELSE RETURN acc || ', ' || instr; END IF; END; $$ LANGUAGE plpgsql;
[ "sql", "postgresql", "group-by", "string-aggregation" ]
481
714
428,998
14
0
2008-09-04T14:27:16.263000
2008-09-04T15:03:25.147000
43,874
43,931
Restrict selection of SELECT option without disabling the field
I have a multiple selection SELECT field which I don't want the end user to be able to change the value of. For UI reasons, I would like to be able to do this without using the disabled="true" attribute. I've tried using onmousedown, onfocus, onclick and setting each to blur or return false but with no success. Can this be done or am I trying to do the impossible?
I know you mentioned that you don't want to, but I actually think that using the disabled attribute is a better solution: Volvo Saab Opel Audi If necessary, you can always give the select a class and style it with CSS. This solution will work in all browsers regardless of scripting capabilities.
Restrict selection of SELECT option without disabling the field I have a multiple selection SELECT field which I don't want the end user to be able to change the value of. For UI reasons, I would like to be able to do this without using the disabled="true" attribute. I've tried using onmousedown, onfocus, onclick and setting each to blur or return false but with no success. Can this be done or am I trying to do the impossible?
TITLE: Restrict selection of SELECT option without disabling the field QUESTION: I have a multiple selection SELECT field which I don't want the end user to be able to change the value of. For UI reasons, I would like to be able to do this without using the disabled="true" attribute. I've tried using onmousedown, onfocus, onclick and setting each to blur or return false but with no success. Can this be done or am I trying to do the impossible? ANSWER: I know you mentioned that you don't want to, but I actually think that using the disabled attribute is a better solution: Volvo Saab Opel Audi If necessary, you can always give the select a class and style it with CSS. This solution will work in all browsers regardless of scripting capabilities.
[ "html", "user-interface", "html-select" ]
7
9
10,102
6
0
2008-09-04T14:30:06.193000
2008-09-04T14:56:08.287000
43,877
47,768
Managing web services in FlexBuilder - How does the manager work?
In FlexBuilder 3, there are two items under the 'Data' menu to import and manage web services. After importing a webservice, I can update it with the manage option. However, the webservices seems to disappear after they are imported. The manager does however recognize that a certain WSDL URL was imported and refuses to do anything with it. How does the manager know this, and how can I make it refresh a certain WSDL URL?
In your src folder of the flexbuilder project you should see the generated classes. For instance, if you use the manager to generate the proxy classes for www.example.com you should see the folders /com/example with the generated proxy classes inside. To consume these webservices in ActionScript use the statement: "import com.example.*;" To consume the webservice in mxml include the.as file using: To refresh the generated proxy classes, consuming the latest WSDL, simply open the manager and select "update". Also, I found this article very useful for consuming web services. I hope that helps, the question was kind of vague about the problem.
Managing web services in FlexBuilder - How does the manager work? In FlexBuilder 3, there are two items under the 'Data' menu to import and manage web services. After importing a webservice, I can update it with the manage option. However, the webservices seems to disappear after they are imported. The manager does however recognize that a certain WSDL URL was imported and refuses to do anything with it. How does the manager know this, and how can I make it refresh a certain WSDL URL?
TITLE: Managing web services in FlexBuilder - How does the manager work? QUESTION: In FlexBuilder 3, there are two items under the 'Data' menu to import and manage web services. After importing a webservice, I can update it with the manage option. However, the webservices seems to disappear after they are imported. The manager does however recognize that a certain WSDL URL was imported and refuses to do anything with it. How does the manager know this, and how can I make it refresh a certain WSDL URL? ANSWER: In your src folder of the flexbuilder project you should see the generated classes. For instance, if you use the manager to generate the proxy classes for www.example.com you should see the folders /com/example with the generated proxy classes inside. To consume these webservices in ActionScript use the statement: "import com.example.*;" To consume the webservice in mxml include the.as file using: To refresh the generated proxy classes, consuming the latest WSDL, simply open the manager and select "update". Also, I found this article very useful for consuming web services. I hope that helps, the question was kind of vague about the problem.
[ "apache-flex", "web-services", "flexbuilder" ]
0
1
976
1
0
2008-09-04T14:30:52.760000
2008-09-06T19:43:54.190000
43,890
44,032
Crop MP3 to first 30 seconds
Original Question I want to be able to generate a new (fully valid) MP3 file from an existing MP3 file to be used as a preview -- try-before-you-buy style. The new file should only contain the first n seconds of the track. Now, I know I could just "chop the stream" at n seconds (calculating from the bitrate and header size) when delivering the file, but this is a bit dirty and a real PITA on a VBR track. I'd like to be able to generate a proper MP3 file. Anyone any ideas? Answers Both mp3split and ffmpeg are both good solutions. I chose ffmpeg as it is commonly installed on linux servers and is also easily available for windows. Here's some more good command line parameters for generating previews with ffmpeg -t chop after specified number of seconds -y force file overwrite -ab set bitrate e.g. -ab 96k -ar set sampling rate e.g. -ar 22050 for 22.05kHz -map_meta_data: copy track metadata from infile to outfile instead of setting -ab and -ar, you can copy the original track settings, as Tim Farley suggests, with: -acodec copy
I also recommend ffmpeg, but the command line suggested by John Boker has an unintended side effect: it re-encodes the file to the default bitrate (which is 64 kb/s in the version I have here at least). This might give your customers a false impression of the quality of your sound files, and it also takes longer to do. Here's a command line that will slice to 30 seconds without transcoding: ffmpeg -t 30 -i inputfile.mp3 -acodec copy outputfile.mp3 The -acodec switch tells ffmpeg to use the special "copy" codec which does not transcode. It is lightning fast. NOTE: the command was updated based on comment from Oben Sonne
Crop MP3 to first 30 seconds Original Question I want to be able to generate a new (fully valid) MP3 file from an existing MP3 file to be used as a preview -- try-before-you-buy style. The new file should only contain the first n seconds of the track. Now, I know I could just "chop the stream" at n seconds (calculating from the bitrate and header size) when delivering the file, but this is a bit dirty and a real PITA on a VBR track. I'd like to be able to generate a proper MP3 file. Anyone any ideas? Answers Both mp3split and ffmpeg are both good solutions. I chose ffmpeg as it is commonly installed on linux servers and is also easily available for windows. Here's some more good command line parameters for generating previews with ffmpeg -t chop after specified number of seconds -y force file overwrite -ab set bitrate e.g. -ab 96k -ar set sampling rate e.g. -ar 22050 for 22.05kHz -map_meta_data: copy track metadata from infile to outfile instead of setting -ab and -ar, you can copy the original track settings, as Tim Farley suggests, with: -acodec copy
TITLE: Crop MP3 to first 30 seconds QUESTION: Original Question I want to be able to generate a new (fully valid) MP3 file from an existing MP3 file to be used as a preview -- try-before-you-buy style. The new file should only contain the first n seconds of the track. Now, I know I could just "chop the stream" at n seconds (calculating from the bitrate and header size) when delivering the file, but this is a bit dirty and a real PITA on a VBR track. I'd like to be able to generate a proper MP3 file. Anyone any ideas? Answers Both mp3split and ffmpeg are both good solutions. I chose ffmpeg as it is commonly installed on linux servers and is also easily available for windows. Here's some more good command line parameters for generating previews with ffmpeg -t chop after specified number of seconds -y force file overwrite -ab set bitrate e.g. -ab 96k -ar set sampling rate e.g. -ar 22050 for 22.05kHz -map_meta_data: copy track metadata from infile to outfile instead of setting -ab and -ar, you can copy the original track settings, as Tim Farley suggests, with: -acodec copy ANSWER: I also recommend ffmpeg, but the command line suggested by John Boker has an unintended side effect: it re-encodes the file to the default bitrate (which is 64 kb/s in the version I have here at least). This might give your customers a false impression of the quality of your sound files, and it also takes longer to do. Here's a command line that will slice to 30 seconds without transcoding: ffmpeg -t 30 -i inputfile.mp3 -acodec copy outputfile.mp3 The -acodec switch tells ffmpeg to use the special "copy" codec which does not transcode. It is lightning fast. NOTE: the command was updated based on comment from Oben Sonne
[ "mp3", "ffmpeg" ]
118
166
83,704
8
0
2008-09-04T14:35:14.437000
2008-09-04T15:42:02.153000
43,903
43,925
SQL Server 2005 Temporary Tables
In a stored procedure, when is #Temptable created in SQL Server 2005? When creating the query execution plan or when executing the stored procedure? if (@x = 1) begin select 1 as Text into #Temptable end else begin select 2 as Text into #Temptable end
Interesting question. For the type of temporary table you're creating, I think it's when the stored procedure is executed. Tables created with the # prefix are accessible to the SQL Server session they're created in. Once the session ends, they're dropped. This url: http://www.sql-server-performance.com/tips/query_execution_plan_analysis_p1.aspx seems to indicate that temp tables aren't created when query execution plans are created.
SQL Server 2005 Temporary Tables In a stored procedure, when is #Temptable created in SQL Server 2005? When creating the query execution plan or when executing the stored procedure? if (@x = 1) begin select 1 as Text into #Temptable end else begin select 2 as Text into #Temptable end
TITLE: SQL Server 2005 Temporary Tables QUESTION: In a stored procedure, when is #Temptable created in SQL Server 2005? When creating the query execution plan or when executing the stored procedure? if (@x = 1) begin select 1 as Text into #Temptable end else begin select 2 as Text into #Temptable end ANSWER: Interesting question. For the type of temporary table you're creating, I think it's when the stored procedure is executed. Tables created with the # prefix are accessible to the SQL Server session they're created in. Once the session ends, they're dropped. This url: http://www.sql-server-performance.com/tips/query_execution_plan_analysis_p1.aspx seems to indicate that temp tables aren't created when query execution plans are created.
[ "sql-server", "sql-server-2005", "temp-tables" ]
1
1
4,839
4
0
2008-09-04T14:41:09.680000
2008-09-04T14:51:41.557000
43,908
43,917
Resources for building a Visual Studio plug-in?
I'd like to build a pretty simple plug-in for Visual Studio, but I don't really know how this has to be done. Is this doable in (non-managed) C++? I'd like to know what resources you'd recommend me.
I've never tried, so I don't know about doing it in C++, but this website has loads of information: http://msdn.microsoft.com/en-us/vsx/default.aspx
Resources for building a Visual Studio plug-in? I'd like to build a pretty simple plug-in for Visual Studio, but I don't really know how this has to be done. Is this doable in (non-managed) C++? I'd like to know what resources you'd recommend me.
TITLE: Resources for building a Visual Studio plug-in? QUESTION: I'd like to build a pretty simple plug-in for Visual Studio, but I don't really know how this has to be done. Is this doable in (non-managed) C++? I'd like to know what resources you'd recommend me. ANSWER: I've never tried, so I don't know about doing it in C++, but this website has loads of information: http://msdn.microsoft.com/en-us/vsx/default.aspx
[ "visual-studio", "add-in" ]
7
1
2,738
6
0
2008-09-04T14:43:18.957000
2008-09-04T14:46:13.503000
43,926
43,937
Can jQuery select by CSS rule, not class?
A.container can contain many.components, and.components themselves can contain.containers (which in turn can contain.components etc. etc.) Given code like this: $(".container.component").each(function(){ $(".container", this).css('border', '1px solid #f00'); }); What do I need to add to the line within the braces to select only the nested.containers that have their width in CSS set to auto? I'm sure it's something simple, but I haven't really used jQuery all that much.
$(".container.component").each(function() { $(".container", this).each(function() { if($(this).css('width') == 'auto') { $(this).css('border', '1px solid #f00'); } }); }); Similar to the other answer but since components can also have multiple containers, also needs the.each() check in here too for the width.
Can jQuery select by CSS rule, not class? A.container can contain many.components, and.components themselves can contain.containers (which in turn can contain.components etc. etc.) Given code like this: $(".container.component").each(function(){ $(".container", this).css('border', '1px solid #f00'); }); What do I need to add to the line within the braces to select only the nested.containers that have their width in CSS set to auto? I'm sure it's something simple, but I haven't really used jQuery all that much.
TITLE: Can jQuery select by CSS rule, not class? QUESTION: A.container can contain many.components, and.components themselves can contain.containers (which in turn can contain.components etc. etc.) Given code like this: $(".container.component").each(function(){ $(".container", this).css('border', '1px solid #f00'); }); What do I need to add to the line within the braces to select only the nested.containers that have their width in CSS set to auto? I'm sure it's something simple, but I haven't really used jQuery all that much. ANSWER: $(".container.component").each(function() { $(".container", this).each(function() { if($(this).css('width') == 'auto') { $(this).css('border', '1px solid #f00'); } }); }); Similar to the other answer but since components can also have multiple containers, also needs the.each() check in here too for the width.
[ "javascript", "jquery", "css-selectors" ]
24
19
24,621
3
0
2008-09-04T14:53:14.440000
2008-09-04T14:59:39.323000
43,939
43,946
Targeting multiple versions of .net framework
Suppose I have some code that would, in theory, compile against any version of the.net framework. Think "Hello World", if you like. If I actually compile the code, though, I'll get an executable that runs against one particular version. Is there any way to arrange things so that the compiled exe will just run against whatever version it finds? I strongly suspect that the answer is no, but I'd be happy to be proven wrong... Edit: Well, I'll go to the foot of our stairs. I had no idea that later frameworks would happily run exe's compiled under earlier versions. Thanks for all the responses!
Im not sure if this is correct, but i'd try to compile it for the lowest version, the higher versions should be able to run the lower versions exe's.
Targeting multiple versions of .net framework Suppose I have some code that would, in theory, compile against any version of the.net framework. Think "Hello World", if you like. If I actually compile the code, though, I'll get an executable that runs against one particular version. Is there any way to arrange things so that the compiled exe will just run against whatever version it finds? I strongly suspect that the answer is no, but I'd be happy to be proven wrong... Edit: Well, I'll go to the foot of our stairs. I had no idea that later frameworks would happily run exe's compiled under earlier versions. Thanks for all the responses!
TITLE: Targeting multiple versions of .net framework QUESTION: Suppose I have some code that would, in theory, compile against any version of the.net framework. Think "Hello World", if you like. If I actually compile the code, though, I'll get an executable that runs against one particular version. Is there any way to arrange things so that the compiled exe will just run against whatever version it finds? I strongly suspect that the answer is no, but I'd be happy to be proven wrong... Edit: Well, I'll go to the foot of our stairs. I had no idea that later frameworks would happily run exe's compiled under earlier versions. Thanks for all the responses! ANSWER: Im not sure if this is correct, but i'd try to compile it for the lowest version, the higher versions should be able to run the lower versions exe's.
[ ".net", "compilation", "version" ]
4
6
3,619
7
0
2008-09-04T15:00:35.187000
2008-09-04T15:03:33.167000
43,947
43,968
What is the best way of adding in regularly used blocks of code when marking up in TextMate?
Caveat: I'm relatively new to coding as well as TextMate, so apologies if there is an obvious answer I'm missing here. I do a lot of HTML/CSS markup, there are certain patterns that I use a lot, for example, forms, navigation menus etc. What I would like is a way to store those patterns and insert them quickly when I need them. Is there a way to do this using TextMate?
You can do this very easily in TextMate using Snippets. Just add a new snippet in the bundle editor, and set up how you want to trigger it. You can set a key shortcut, or have it pop up when you hit Tab after a certain word/pattern. There are many things you can do with them—in your case, it would probably be very useful to set so-called "placeholders" in your snippets, which are the parts that change every time (e.g. the names of the fields in the form). Then, as soon as you insert the snippet, you can hit Tab to move between these.
What is the best way of adding in regularly used blocks of code when marking up in TextMate? Caveat: I'm relatively new to coding as well as TextMate, so apologies if there is an obvious answer I'm missing here. I do a lot of HTML/CSS markup, there are certain patterns that I use a lot, for example, forms, navigation menus etc. What I would like is a way to store those patterns and insert them quickly when I need them. Is there a way to do this using TextMate?
TITLE: What is the best way of adding in regularly used blocks of code when marking up in TextMate? QUESTION: Caveat: I'm relatively new to coding as well as TextMate, so apologies if there is an obvious answer I'm missing here. I do a lot of HTML/CSS markup, there are certain patterns that I use a lot, for example, forms, navigation menus etc. What I would like is a way to store those patterns and insert them quickly when I need them. Is there a way to do this using TextMate? ANSWER: You can do this very easily in TextMate using Snippets. Just add a new snippet in the bundle editor, and set up how you want to trigger it. You can set a key shortcut, or have it pop up when you hit Tab after a certain word/pattern. There are many things you can do with them—in your case, it would probably be very useful to set so-called "placeholders" in your snippets, which are the parts that change every time (e.g. the names of the fields in the form). Then, as soon as you insert the snippet, you can hit Tab to move between these.
[ "html", "design-patterns", "textmate", "markup" ]
1
6
148
3
0
2008-09-04T15:03:33.667000
2008-09-04T15:09:35.053000
43,955
43,959
Changing the default title of confirm() in JavaScript?
Is it possible to modify the title of the message box the confirm() function opens in JavaScript? I could create a modal popup box, but I would like to do this as minimalistic as possible. I would like to do something like this: confirm("This is the content of the message box", "Modified title"); The default title in Internet Explorer is "Windows Internet Explorer" and in Firefox it's "[JavaScript-program]." Not very informative. Though I can understand from a browser security stand point that you shouldn't be able to do this.
This is not possible, as you say, from a security stand point. The only way you could simulate it, is by creating a modeless dialog window. There are many third-party javascript-plugins that you could use to fake this effect so you do not have to write all that code.
Changing the default title of confirm() in JavaScript? Is it possible to modify the title of the message box the confirm() function opens in JavaScript? I could create a modal popup box, but I would like to do this as minimalistic as possible. I would like to do something like this: confirm("This is the content of the message box", "Modified title"); The default title in Internet Explorer is "Windows Internet Explorer" and in Firefox it's "[JavaScript-program]." Not very informative. Though I can understand from a browser security stand point that you shouldn't be able to do this.
TITLE: Changing the default title of confirm() in JavaScript? QUESTION: Is it possible to modify the title of the message box the confirm() function opens in JavaScript? I could create a modal popup box, but I would like to do this as minimalistic as possible. I would like to do something like this: confirm("This is the content of the message box", "Modified title"); The default title in Internet Explorer is "Windows Internet Explorer" and in Firefox it's "[JavaScript-program]." Not very informative. Though I can understand from a browser security stand point that you shouldn't be able to do this. ANSWER: This is not possible, as you say, from a security stand point. The only way you could simulate it, is by creating a modeless dialog window. There are many third-party javascript-plugins that you could use to fake this effect so you do not have to write all that code.
[ "javascript" ]
87
92
181,806
8
0
2008-09-04T15:06:01.133000
2008-09-04T15:07:26.713000
43,970
107,795
Configuring sendmail behind a firewall
I'm setting up a server which is on a network behind a firewall and I want programs on this computer to be able to use sendmail to send emails to any email address. We have an SMTP server running on this network (let's call it mailrelay.example.com) which is how we're supposed to get outgoing emails through the firewall. So how do I configure sendmail to send all mail through mailrelay.example.com? Googling hasn't given me the answer yet, and has only revealed that sendmail configuration is extremely complex and annoying.
@eli: modifying sendmail.cf directly is not usually recommended, since it is generated by the macro compiler. Edit /etc/mail/sendmail.mc to include the line: define(`SMART_HOST',`mailrelay.example.com')dnl After changing the sendmail.mc macro configuration file, it must be recompiled to produce the sendmail configuration file. # m4 /etc/mail/sendmail.mc > /etc/sendmail.cf And restart the sendmail service (Linux): # /etc/init.d/sendmail restart As well as setting the smarthost, you might want to also disable name resolution configuration and possibly shift your sendmail to non-standard port, or disable daemon mode. Disable Name Resolution Servers that are within fire-walled networks or using Network Address Translation (NAT) may not have DNS or NIS services available. This creates a problem for sendmail, since it will use DNS by default, and if it is not available you will see messages like this in mailq: host map: lookup (mydomain.com): deferred) Unless you are prepared to setup an appropriate DNS or NIS service that sendmail can use, in this situation you will typically configure name resolution to be done using the /etc/hosts file. This is done by enabling a 'service.switch' file and specifying resolution by file, as follows: 1: Enable service.switch for sendmail Edit /etc/mail/sendmail.mc to include the lines: define(`confSERVICE_SWITCH_FILE',`/etc/mail/service.switch')dnl 2: Configure service.switch for files Create or modify /etc/mail/service.switch to refer only to /etc/hosts for name resolution: # cat /etc/mail/service.switch hosts files 3: Recompile sendmail.mc and restart sendmail for this setting to take effect. Shift sendmail to non-standard port, or disable daemon mode By default, sendmail will listen on port 25. You may want to change this port or disable the sendmail daemon mode altogether for various reasons: - if there is a security policy prohibiting the use of well-known ports - if another SMTP product/process is to be running on the same host on the standard port - if you don't want to accept mail via smtp at all, just send it using sendmail 1: To shift sendmail to use non-standard port. Edit /etc/mail/sendmail.mc and modify the "Port" setting in the line: DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA') For example, to get sendmail to use port 125: DAEMON_OPTIONS(`Port=125,Addr=127.0.0.1, Name=MTA') This will require sendmail.mc to be recompiled and sendmail to be restarted. 2: Alternatively, to disable sendmail daemon mode altogether (Linux) Edit /etc/sysconfig/sendmail and modify the "DAEMON" setting to: DAEMON=no This change will require sendmail to be restarted.
Configuring sendmail behind a firewall I'm setting up a server which is on a network behind a firewall and I want programs on this computer to be able to use sendmail to send emails to any email address. We have an SMTP server running on this network (let's call it mailrelay.example.com) which is how we're supposed to get outgoing emails through the firewall. So how do I configure sendmail to send all mail through mailrelay.example.com? Googling hasn't given me the answer yet, and has only revealed that sendmail configuration is extremely complex and annoying.
TITLE: Configuring sendmail behind a firewall QUESTION: I'm setting up a server which is on a network behind a firewall and I want programs on this computer to be able to use sendmail to send emails to any email address. We have an SMTP server running on this network (let's call it mailrelay.example.com) which is how we're supposed to get outgoing emails through the firewall. So how do I configure sendmail to send all mail through mailrelay.example.com? Googling hasn't given me the answer yet, and has only revealed that sendmail configuration is extremely complex and annoying. ANSWER: @eli: modifying sendmail.cf directly is not usually recommended, since it is generated by the macro compiler. Edit /etc/mail/sendmail.mc to include the line: define(`SMART_HOST',`mailrelay.example.com')dnl After changing the sendmail.mc macro configuration file, it must be recompiled to produce the sendmail configuration file. # m4 /etc/mail/sendmail.mc > /etc/sendmail.cf And restart the sendmail service (Linux): # /etc/init.d/sendmail restart As well as setting the smarthost, you might want to also disable name resolution configuration and possibly shift your sendmail to non-standard port, or disable daemon mode. Disable Name Resolution Servers that are within fire-walled networks or using Network Address Translation (NAT) may not have DNS or NIS services available. This creates a problem for sendmail, since it will use DNS by default, and if it is not available you will see messages like this in mailq: host map: lookup (mydomain.com): deferred) Unless you are prepared to setup an appropriate DNS or NIS service that sendmail can use, in this situation you will typically configure name resolution to be done using the /etc/hosts file. This is done by enabling a 'service.switch' file and specifying resolution by file, as follows: 1: Enable service.switch for sendmail Edit /etc/mail/sendmail.mc to include the lines: define(`confSERVICE_SWITCH_FILE',`/etc/mail/service.switch')dnl 2: Configure service.switch for files Create or modify /etc/mail/service.switch to refer only to /etc/hosts for name resolution: # cat /etc/mail/service.switch hosts files 3: Recompile sendmail.mc and restart sendmail for this setting to take effect. Shift sendmail to non-standard port, or disable daemon mode By default, sendmail will listen on port 25. You may want to change this port or disable the sendmail daemon mode altogether for various reasons: - if there is a security policy prohibiting the use of well-known ports - if another SMTP product/process is to be running on the same host on the standard port - if you don't want to accept mail via smtp at all, just send it using sendmail 1: To shift sendmail to use non-standard port. Edit /etc/mail/sendmail.mc and modify the "Port" setting in the line: DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA') For example, to get sendmail to use port 125: DAEMON_OPTIONS(`Port=125,Addr=127.0.0.1, Name=MTA') This will require sendmail.mc to be recompiled and sendmail to be restarted. 2: Alternatively, to disable sendmail daemon mode altogether (Linux) Edit /etc/sysconfig/sendmail and modify the "DAEMON" setting to: DAEMON=no This change will require sendmail to be restarted.
[ "configuration", "firewall", "sendmail", "smarthost" ]
8
14
23,429
3
0
2008-09-04T15:10:13.960000
2008-09-20T10:05:40.757000
43,971
43,983
Dynamic robots.txt
Let's say I have a web site for hosting community generated content that targets a very specific set of users. Now, let's say in the interest of fostering a better community I have an off-topic area where community members can post or talk about anything they want, regardless of the site's main theme. Now, I want most of the content to get indexed by Google. The notable exception is the off-topic content. Each thread has it's own page, but all the threads are listed in the same folder so I can't just exclude search engines from a folder somewhere. It has to be per-page. A traditional robots.txt file would get huge, so how else could I accomplish this?
This will work for all well-behaving search engines, just add it to the:
Dynamic robots.txt Let's say I have a web site for hosting community generated content that targets a very specific set of users. Now, let's say in the interest of fostering a better community I have an off-topic area where community members can post or talk about anything they want, regardless of the site's main theme. Now, I want most of the content to get indexed by Google. The notable exception is the off-topic content. Each thread has it's own page, but all the threads are listed in the same folder so I can't just exclude search engines from a folder somewhere. It has to be per-page. A traditional robots.txt file would get huge, so how else could I accomplish this?
TITLE: Dynamic robots.txt QUESTION: Let's say I have a web site for hosting community generated content that targets a very specific set of users. Now, let's say in the interest of fostering a better community I have an off-topic area where community members can post or talk about anything they want, regardless of the site's main theme. Now, I want most of the content to get indexed by Google. The notable exception is the off-topic content. Each thread has it's own page, but all the threads are listed in the same folder so I can't just exclude search engines from a folder somewhere. It has to be per-page. A traditional robots.txt file would get huge, so how else could I accomplish this? ANSWER: This will work for all well-behaving search engines, just add it to the:
[ "seo" ]
11
22
5,921
8
0
2008-09-04T15:10:22.137000
2008-09-04T15:13:30.537000
43,992
50,977
How to safely embed any flash file (swf)?
I want to allow my users to embed their own Flash animations in their posts. Usually the actual file is hosted on some free image hosting site. I wouldn't actually load the flash unless the user clicked a button to play (so that nothing auto-plays on page load). I know people can make some really annoying crap in flash, but I can't find any information about potential serious damage a flash app could cause to the viewer. Is it unsafe to embed just any flash file from the internets? If so, how can I let users embed innocent animations but still keep out the harmful apps? edit: From what I can gather, the most obvious threat is for actionscript to redirect you to a malicious site. Adobe says you can set allowScriptAccess=never and allowNetworking=none and the swf should have no access to anything outside of itself. Will this solve all my problems?
Adobe says you can set allowScriptAccess =never and allowNetworking =none and the swf should have no access to anything outside of itself. Although allowNetworking is only in Flash Player 9, so users with earlier versions of Flash would still be susceptible to some exploits. Creating more secure SWF web applications: Security Controls Within the HTML Code How to restrict SWF content from HTML
How to safely embed any flash file (swf)? I want to allow my users to embed their own Flash animations in their posts. Usually the actual file is hosted on some free image hosting site. I wouldn't actually load the flash unless the user clicked a button to play (so that nothing auto-plays on page load). I know people can make some really annoying crap in flash, but I can't find any information about potential serious damage a flash app could cause to the viewer. Is it unsafe to embed just any flash file from the internets? If so, how can I let users embed innocent animations but still keep out the harmful apps? edit: From what I can gather, the most obvious threat is for actionscript to redirect you to a malicious site. Adobe says you can set allowScriptAccess=never and allowNetworking=none and the swf should have no access to anything outside of itself. Will this solve all my problems?
TITLE: How to safely embed any flash file (swf)? QUESTION: I want to allow my users to embed their own Flash animations in their posts. Usually the actual file is hosted on some free image hosting site. I wouldn't actually load the flash unless the user clicked a button to play (so that nothing auto-plays on page load). I know people can make some really annoying crap in flash, but I can't find any information about potential serious damage a flash app could cause to the viewer. Is it unsafe to embed just any flash file from the internets? If so, how can I let users embed innocent animations but still keep out the harmful apps? edit: From what I can gather, the most obvious threat is for actionscript to redirect you to a malicious site. Adobe says you can set allowScriptAccess=never and allowNetworking=none and the swf should have no access to anything outside of itself. Will this solve all my problems? ANSWER: Adobe says you can set allowScriptAccess =never and allowNetworking =none and the swf should have no access to anything outside of itself. Although allowNetworking is only in Flash Player 9, so users with earlier versions of Flash would still be susceptible to some exploits. Creating more secure SWF web applications: Security Controls Within the HTML Code How to restrict SWF content from HTML
[ "security", "flash", "embed" ]
5
1
6,704
6
0
2008-09-04T15:15:24.137000
2008-09-08T23:51:04.047000
43,995
44,708
Why is branching and merging easier in Mercurial than in Subversion?
Handling multiple merges onto branches in Subversion or CVS is just one of those things that has to be experienced. It is inordinately easier to keep track of branches and merges in Mercurial (and probably any other distributed system) but I don't know why. Does anyone else know? My question stems from the fact that with Mercurial you can adopt a working practice similar to that of Subversions/CVSs central repository and everything will work just fine. You can do multiple merges on the same branch and you won't need endless scraps of paper with commit numbers and tag names. I know the latest version of Subversion has the ability to track merges to branches so you don't get quite the same degree of hassle but it was a huge and major development on their side and it still doesn't do everything the development team would like it to do. There must be a fundamental difference in the way it all works.
In Subversion (and CVS), the repository is first and foremost. In git and mercurial there is not really the concept of a repository in the same way; here changes are the central theme. +1 The hassle in CVS/SVN comes from the fact that these systems do not remember the parenthood of changes. In Git and Mercurial, not only can a commit have multiple children, it can also have multiple parents! That can easily observed using one of the graphical tools, gitk or hg view. In the following example, branch #2 was forked from #1 at commit A, and has since been merged once (at M, merged with commit B): o---A---o---B---o---C (branch #1) \ \ o---o---M---X---? (branch #2) Note how A and B have two children, whereas M has two parents. These relationships are recorded in the repository. Let's say the maintainer of branch #2 now wants to merge the latest changes from branch #1, they can issue a command such as: $ git merge branch-1 and the tool will automatically know that the base is B--because it was recorded in commit M, an ancestor of the tip of #2--and that it has to merge whatever happened between B and C. CVS does not record this information, nor did SVN prior to version 1.5. In these systems, the graph would look like: o---A---o---B---o---C (branch #1) \ o---o---M---X---? (branch #2) where M is just a gigantic "squashed" commit of everything that happened between A and B, applied on top of M. Note that after the deed is done, there is no trace left (except potentially in human-readable comments) of where M did originate from, nor of how many commits were collapsed together--making history much more impenetrable. Worse still, performing a second merge becomes a nightmare: one has to figure out what the merge base was at the time of the first merge (and one has to know that there has been a merge in the first place!), then present that information to the tool so that it does not try to replay A..B on top of M. All of this is difficult enough when working in close collaboration, but is simply impossible in a distributed environment. A (related) problem is that there is no way to answer the question: "does X contain B?" where B is a potentially important bug fix. So, why not just record that information in the commit, since it is known at merge time! P.-S. -- I have no experience with SVN 1.5+ merge recording abilities, but the workflow seems to be much more contrived than in the distributed systems. If that is indeed the case, it's probably because--as mentioned in the above comment--the focus is put on repository organization rather than on the changes themselves.
Why is branching and merging easier in Mercurial than in Subversion? Handling multiple merges onto branches in Subversion or CVS is just one of those things that has to be experienced. It is inordinately easier to keep track of branches and merges in Mercurial (and probably any other distributed system) but I don't know why. Does anyone else know? My question stems from the fact that with Mercurial you can adopt a working practice similar to that of Subversions/CVSs central repository and everything will work just fine. You can do multiple merges on the same branch and you won't need endless scraps of paper with commit numbers and tag names. I know the latest version of Subversion has the ability to track merges to branches so you don't get quite the same degree of hassle but it was a huge and major development on their side and it still doesn't do everything the development team would like it to do. There must be a fundamental difference in the way it all works.
TITLE: Why is branching and merging easier in Mercurial than in Subversion? QUESTION: Handling multiple merges onto branches in Subversion or CVS is just one of those things that has to be experienced. It is inordinately easier to keep track of branches and merges in Mercurial (and probably any other distributed system) but I don't know why. Does anyone else know? My question stems from the fact that with Mercurial you can adopt a working practice similar to that of Subversions/CVSs central repository and everything will work just fine. You can do multiple merges on the same branch and you won't need endless scraps of paper with commit numbers and tag names. I know the latest version of Subversion has the ability to track merges to branches so you don't get quite the same degree of hassle but it was a huge and major development on their side and it still doesn't do everything the development team would like it to do. There must be a fundamental difference in the way it all works. ANSWER: In Subversion (and CVS), the repository is first and foremost. In git and mercurial there is not really the concept of a repository in the same way; here changes are the central theme. +1 The hassle in CVS/SVN comes from the fact that these systems do not remember the parenthood of changes. In Git and Mercurial, not only can a commit have multiple children, it can also have multiple parents! That can easily observed using one of the graphical tools, gitk or hg view. In the following example, branch #2 was forked from #1 at commit A, and has since been merged once (at M, merged with commit B): o---A---o---B---o---C (branch #1) \ \ o---o---M---X---? (branch #2) Note how A and B have two children, whereas M has two parents. These relationships are recorded in the repository. Let's say the maintainer of branch #2 now wants to merge the latest changes from branch #1, they can issue a command such as: $ git merge branch-1 and the tool will automatically know that the base is B--because it was recorded in commit M, an ancestor of the tip of #2--and that it has to merge whatever happened between B and C. CVS does not record this information, nor did SVN prior to version 1.5. In these systems, the graph would look like: o---A---o---B---o---C (branch #1) \ o---o---M---X---? (branch #2) where M is just a gigantic "squashed" commit of everything that happened between A and B, applied on top of M. Note that after the deed is done, there is no trace left (except potentially in human-readable comments) of where M did originate from, nor of how many commits were collapsed together--making history much more impenetrable. Worse still, performing a second merge becomes a nightmare: one has to figure out what the merge base was at the time of the first merge (and one has to know that there has been a merge in the first place!), then present that information to the tool so that it does not try to replay A..B on top of M. All of this is difficult enough when working in close collaboration, but is simply impossible in a distributed environment. A (related) problem is that there is no way to answer the question: "does X contain B?" where B is a potentially important bug fix. So, why not just record that information in the commit, since it is known at merge time! P.-S. -- I have no experience with SVN 1.5+ merge recording abilities, but the workflow seems to be much more contrived than in the distributed systems. If that is indeed the case, it's probably because--as mentioned in the above comment--the focus is put on repository organization rather than on the changes themselves.
[ "svn", "git", "version-control", "mercurial" ]
93
115
12,083
6
0
2008-09-04T15:16:36.723000
2008-09-04T20:32:43.123000
44,007
190,097
ncover with nunit2 task in NAnt
Is there any chance to get this work? I want my tests to be run by nunit2 task in NAnt. In addition I want to run NCover without running tests again.
I figured it out. You change the path of the NUnit launcher to that of TeamCity's own. Here is an example: As you can see, I have some of my own variables in there, but you should be able to figure out what is going on. The property you are concerned with is teamcity.dotnet.nunitlauncher. You can read more about it here at http://www.jetbrains.net/confluence/display/TCD4/TeamCity+NUnit+Test+Launcher.
ncover with nunit2 task in NAnt Is there any chance to get this work? I want my tests to be run by nunit2 task in NAnt. In addition I want to run NCover without running tests again.
TITLE: ncover with nunit2 task in NAnt QUESTION: Is there any chance to get this work? I want my tests to be run by nunit2 task in NAnt. In addition I want to run NCover without running tests again. ANSWER: I figured it out. You change the path of the NUnit launcher to that of TeamCity's own. Here is an example: As you can see, I have some of my own variables in there, but you should be able to figure out what is going on. The property you are concerned with is teamcity.dotnet.nunitlauncher. You can read more about it here at http://www.jetbrains.net/confluence/display/TCD4/TeamCity+NUnit+Test+Launcher.
[ "nunit", "nant", "task", "ncover" ]
3
3
1,796
3
0
2008-09-04T15:22:18.130000
2008-10-10T04:11:11.453000
44,019
44,033
An easy way to diff log files, ignoring the time stamps?
I need to diff two log files but ignore the time stamp part of each line (the first 12 characters to be exact). Is there a good tool, or a clever awk command, that could help me out?
Depending on the shell you are using, you can turn the approach @Blair suggested into a 1-liner diff <(cut -b13- file1) <(cut -b13- file2) (+1 to @Blair for the original suggestion:-)
An easy way to diff log files, ignoring the time stamps? I need to diff two log files but ignore the time stamp part of each line (the first 12 characters to be exact). Is there a good tool, or a clever awk command, that could help me out?
TITLE: An easy way to diff log files, ignoring the time stamps? QUESTION: I need to diff two log files but ignore the time stamp part of each line (the first 12 characters to be exact). Is there a good tool, or a clever awk command, that could help me out? ANSWER: Depending on the shell you are using, you can turn the approach @Blair suggested into a 1-liner diff <(cut -b13- file1) <(cut -b13- file2) (+1 to @Blair for the original suggestion:-)
[ "parsing", "shell", "diff", "compare", "logging" ]
56
56
27,477
6
0
2008-09-04T15:33:35.730000
2008-09-04T15:44:17.700000
44,034
44,045
How can I get the definition (body) of a trigger in SQL Server?
Unable to find a SQL diff tool that meets my needs, I am writing my own. Between the INFORMATION_SCHEMA and sys tables, I have a mostly-complete working version. But one thing I can't find in the metadata is the definition of a trigger, you know, the actual SQL code. Am I overlooking something? Thanks. Thanks, Pete, I didn't know about that! Scott, I'm working with very basic hosting packages that don't allow remote connections to the DB. I don't know from the specs on RedGate (which I can't afford anyway) whether they provide a workaround for that, and although there are also API's out there (such as the one from Apex), I didn't see the point in investing in a solution that was still going to require more programming on my part.:) My solution is to drop an ASPX page on the site that acts as a kind of "schema service", returning the collected metadata as XML. I set up a little AJAX app that compares any number of catalog instances to a master and shows the diffs. It's not perfect, but a major step forward for me. Thanks again!
sp_helptext works to get the sql that makes up a trigger. The text column in the syscomments view also contains the sql used for object creation.
How can I get the definition (body) of a trigger in SQL Server? Unable to find a SQL diff tool that meets my needs, I am writing my own. Between the INFORMATION_SCHEMA and sys tables, I have a mostly-complete working version. But one thing I can't find in the metadata is the definition of a trigger, you know, the actual SQL code. Am I overlooking something? Thanks. Thanks, Pete, I didn't know about that! Scott, I'm working with very basic hosting packages that don't allow remote connections to the DB. I don't know from the specs on RedGate (which I can't afford anyway) whether they provide a workaround for that, and although there are also API's out there (such as the one from Apex), I didn't see the point in investing in a solution that was still going to require more programming on my part.:) My solution is to drop an ASPX page on the site that acts as a kind of "schema service", returning the collected metadata as XML. I set up a little AJAX app that compares any number of catalog instances to a master and shows the diffs. It's not perfect, but a major step forward for me. Thanks again!
TITLE: How can I get the definition (body) of a trigger in SQL Server? QUESTION: Unable to find a SQL diff tool that meets my needs, I am writing my own. Between the INFORMATION_SCHEMA and sys tables, I have a mostly-complete working version. But one thing I can't find in the metadata is the definition of a trigger, you know, the actual SQL code. Am I overlooking something? Thanks. Thanks, Pete, I didn't know about that! Scott, I'm working with very basic hosting packages that don't allow remote connections to the DB. I don't know from the specs on RedGate (which I can't afford anyway) whether they provide a workaround for that, and although there are also API's out there (such as the one from Apex), I didn't see the point in investing in a solution that was still going to require more programming on my part.:) My solution is to drop an ASPX page on the site that acts as a kind of "schema service", returning the collected metadata as XML. I set up a little AJAX app that compares any number of catalog instances to a master and shows the diffs. It's not perfect, but a major step forward for me. Thanks again! ANSWER: sp_helptext works to get the sql that makes up a trigger. The text column in the syscomments view also contains the sql used for object creation.
[ "sql-server", "triggers", "metadata" ]
31
28
57,270
6
0
2008-09-04T15:46:07.743000
2008-09-04T15:50:34.193000
44,046
44,052
Truncate (not round) decimal places in SQL Server
I'm trying to determine the best way to truncate or drop extra decimal places in SQL without rounding. For example: declare @value decimal(18,2) set @value = 123.456 This will automatically round @value to be 123.46, which is good in most cases. However, for this project, I don't need that. Is there a simple way to truncate the decimals I don't need? I know I can use the left() function and convert back to a decimal. Are there any other ways?
You will need to provide 3 numbers to the ROUND function. number Required. The number to be rounded decimals Required. The number of decimal places to round number to operation Optional. If 0, it rounds the result to the number of decimal. If another value than 0, it truncates the result to the number of decimals. Default value is 0 Example: select round(123.456, 2, 1) Works in: SQL Server (starting with 2008), Azure SQL Database, Azure SQL Data Warehouse, Parallel Data Warehouse Additional Info: https://www.w3schools.com/sql/func_sqlserver_round.asp
Truncate (not round) decimal places in SQL Server I'm trying to determine the best way to truncate or drop extra decimal places in SQL without rounding. For example: declare @value decimal(18,2) set @value = 123.456 This will automatically round @value to be 123.46, which is good in most cases. However, for this project, I don't need that. Is there a simple way to truncate the decimals I don't need? I know I can use the left() function and convert back to a decimal. Are there any other ways?
TITLE: Truncate (not round) decimal places in SQL Server QUESTION: I'm trying to determine the best way to truncate or drop extra decimal places in SQL without rounding. For example: declare @value decimal(18,2) set @value = 123.456 This will automatically round @value to be 123.46, which is good in most cases. However, for this project, I don't need that. Is there a simple way to truncate the decimals I don't need? I know I can use the left() function and convert back to a decimal. Are there any other ways? ANSWER: You will need to provide 3 numbers to the ROUND function. number Required. The number to be rounded decimals Required. The number of decimal places to round number to operation Optional. If 0, it rounds the result to the number of decimal. If another value than 0, it truncates the result to the number of decimals. Default value is 0 Example: select round(123.456, 2, 1) Works in: SQL Server (starting with 2008), Azure SQL Database, Azure SQL Data Warehouse, Parallel Data Warehouse Additional Info: https://www.w3schools.com/sql/func_sqlserver_round.asp
[ "sql", "sql-server", "t-sql", "rounding" ]
227
210
794,340
21
0
2008-09-04T15:50:41.837000
2008-09-04T15:54:24.090000
44,048
44,053
Best way to rotate Apache log files
I've got an Apache server that has one access log file that is topping 600MB. This makes it really hard to search the file or parse it. What software or modules for Apache are available that will make a daily copy of my access file to make it more manageable?
Have you looked at logrotate - this is probably the simplest, most widely available and well understood method of achieving this. It is highly configurable and will probably do 90% of what you need.
Best way to rotate Apache log files I've got an Apache server that has one access log file that is topping 600MB. This makes it really hard to search the file or parse it. What software or modules for Apache are available that will make a daily copy of my access file to make it more manageable?
TITLE: Best way to rotate Apache log files QUESTION: I've got an Apache server that has one access log file that is topping 600MB. This makes it really hard to search the file or parse it. What software or modules for Apache are available that will make a daily copy of my access file to make it more manageable? ANSWER: Have you looked at logrotate - this is probably the simplest, most widely available and well understood method of achieving this. It is highly configurable and will probably do 90% of what you need.
[ "apache", "logging", "webserver", "apache2", "apache2.4" ]
70
50
112,859
7
0
2008-09-04T15:51:59.977000
2008-09-04T15:54:38.737000
44,066
44,079
Pass functions in F#
Is it possible to pass a reference to a function to another function in F#? Specifically, I'd like to pass lambda functions like foo(fun x -> x ** 3) More specifically, I need to know how I would refer to the passed function in a function that I wrote myself.
Yes, it is possible. The manual has this example: > List.map (fun x -> x % 2 = 0) [1.. 5];; val it: bool list = [false; true; false; true; false]
Pass functions in F# Is it possible to pass a reference to a function to another function in F#? Specifically, I'd like to pass lambda functions like foo(fun x -> x ** 3) More specifically, I need to know how I would refer to the passed function in a function that I wrote myself.
TITLE: Pass functions in F# QUESTION: Is it possible to pass a reference to a function to another function in F#? Specifically, I'd like to pass lambda functions like foo(fun x -> x ** 3) More specifically, I need to know how I would refer to the passed function in a function that I wrote myself. ANSWER: Yes, it is possible. The manual has this example: > List.map (fun x -> x % 2 = 0) [1.. 5];; val it: bool list = [false; true; false; true; false]
[ "f#", "functional-programming", "lambda" ]
10
8
5,996
3
0
2008-09-04T15:59:36.463000
2008-09-04T16:05:28.273000
44,078
44,124
Strip all HTML tags except links
I am trying to write a regular expression to strip all HTML with the exception of links (the and tags respectively. It does not have to be 100% secure (I am not worried about injection attacks or anything as I am parsing content that has already been approved and published into a SWF movie). The original "strip tags" regular expression I'm using was <(.|\n)+?>, and I tried to modify it to <([^a]|\n)+?>, but that of course will allow any tag that has an a in it rather than one that has it in the beginning, with a space. Not that it should really matter, but in case anyone cares to know I am writing this in ActionScript 3.0 for a Flash movie.
<(?!\/?a(?=>|\s.*>))\/?.*?> Try this. Had something similar for p tags. Worked for them so don't see why not. Uses negative lookahead to check that it doesn't match a (prefixed with an optional / character) where (using positive lookahead) a (with optional / prefix) is followed by a > or a space, stuff and then >. This then matches up until the next > character. Put this in a subst with s/<(?!\/?a(?=>|\s.*>))\/?.*?>//g; This should leave only the opening and closing a tags
Strip all HTML tags except links I am trying to write a regular expression to strip all HTML with the exception of links (the and tags respectively. It does not have to be 100% secure (I am not worried about injection attacks or anything as I am parsing content that has already been approved and published into a SWF movie). The original "strip tags" regular expression I'm using was <(.|\n)+?>, and I tried to modify it to <([^a]|\n)+?>, but that of course will allow any tag that has an a in it rather than one that has it in the beginning, with a space. Not that it should really matter, but in case anyone cares to know I am writing this in ActionScript 3.0 for a Flash movie.
TITLE: Strip all HTML tags except links QUESTION: I am trying to write a regular expression to strip all HTML with the exception of links (the and tags respectively. It does not have to be 100% secure (I am not worried about injection attacks or anything as I am parsing content that has already been approved and published into a SWF movie). The original "strip tags" regular expression I'm using was <(.|\n)+?>, and I tried to modify it to <([^a]|\n)+?>, but that of course will allow any tag that has an a in it rather than one that has it in the beginning, with a space. Not that it should really matter, but in case anyone cares to know I am writing this in ActionScript 3.0 for a Flash movie. ANSWER: <(?!\/?a(?=>|\s.*>))\/?.*?> Try this. Had something similar for p tags. Worked for them so don't see why not. Uses negative lookahead to check that it doesn't match a (prefixed with an optional / character) where (using positive lookahead) a (with optional / prefix) is followed by a > or a space, stuff and then >. This then matches up until the next > character. Put this in a subst with s/<(?!\/?a(?=>|\s.*>))\/?.*?>//g; This should leave only the opening and closing a tags
[ "html", "regex", "actionscript-3", "string", "tags" ]
27
28
20,282
6
0
2008-09-04T16:04:57.870000
2008-09-04T16:29:23.193000
44,080
44,137
Does Microsoft ASP.NET Ajax Cause DOM Object Leaks?
We've been using "Drip" to try and identify why pages with UpdatePanels in them tend to use a lot of client-side memory. With a page with a regular postback, we are seeing 0 leaks detected by Drip. However, when we add an update panel to the mix, every single DOM object that is inside of the update panel appears to leak (according to Drip). I am not certain is Drip is reliable enough to report these kinds of things - the reported leaks do seem to indicate Drip is modifying the page slightly. Does anyone have any experience with this? Should I panic and stop using Microsoft Ajax? I'm not above doubting Microsoft, but it seems fishy to me that it could be this bad. Also, if you know of a tool that is better than Drip, that would be helpful as well.
According to ASP.NET AJAX in Action, p. 257 Just before the old markup is replaced with the updated HTML, all the DOM elements in the panel are examined for Microsoft Ajax behaviours or controls attached to them. To avoid memory leaks, the components associated with DOM elements are disposed, and then destroyed when the HTMl is replaced. So as far as I know, any asp.net ajax components within the update panel are disposed to prevent memory leaks, but anything else in there will just be replaced with the html received. So if you don't have any asp.net ajax components in the target container for the response, it would be basically the same as an inner html replacement with any other js framework / ajax request, so i would say that it's just the how the browser handles this, rather than asp.net ajax causing this. Also, while it may be "leaking", it may be by design, meaning that the browser might not have reclaimed the dom elements yet and released them. Also, drip might be causing those to leak, as it is attaching to those dom elements.
Does Microsoft ASP.NET Ajax Cause DOM Object Leaks? We've been using "Drip" to try and identify why pages with UpdatePanels in them tend to use a lot of client-side memory. With a page with a regular postback, we are seeing 0 leaks detected by Drip. However, when we add an update panel to the mix, every single DOM object that is inside of the update panel appears to leak (according to Drip). I am not certain is Drip is reliable enough to report these kinds of things - the reported leaks do seem to indicate Drip is modifying the page slightly. Does anyone have any experience with this? Should I panic and stop using Microsoft Ajax? I'm not above doubting Microsoft, but it seems fishy to me that it could be this bad. Also, if you know of a tool that is better than Drip, that would be helpful as well.
TITLE: Does Microsoft ASP.NET Ajax Cause DOM Object Leaks? QUESTION: We've been using "Drip" to try and identify why pages with UpdatePanels in them tend to use a lot of client-side memory. With a page with a regular postback, we are seeing 0 leaks detected by Drip. However, when we add an update panel to the mix, every single DOM object that is inside of the update panel appears to leak (according to Drip). I am not certain is Drip is reliable enough to report these kinds of things - the reported leaks do seem to indicate Drip is modifying the page slightly. Does anyone have any experience with this? Should I panic and stop using Microsoft Ajax? I'm not above doubting Microsoft, but it seems fishy to me that it could be this bad. Also, if you know of a tool that is better than Drip, that would be helpful as well. ANSWER: According to ASP.NET AJAX in Action, p. 257 Just before the old markup is replaced with the updated HTML, all the DOM elements in the panel are examined for Microsoft Ajax behaviours or controls attached to them. To avoid memory leaks, the components associated with DOM elements are disposed, and then destroyed when the HTMl is replaced. So as far as I know, any asp.net ajax components within the update panel are disposed to prevent memory leaks, but anything else in there will just be replaced with the html received. So if you don't have any asp.net ajax components in the target container for the response, it would be basically the same as an inner html replacement with any other js framework / ajax request, so i would say that it's just the how the browser handles this, rather than asp.net ajax causing this. Also, while it may be "leaking", it may be by design, meaning that the browser might not have reclaimed the dom elements yet and released them. Also, drip might be causing those to leak, as it is attaching to those dom elements.
[ "asp.net", "dom", "asp.net-ajax", "memory-leaks" ]
2
3
1,239
3
0
2008-09-04T16:05:57.930000
2008-09-04T16:36:57.450000
44,084
44,095
How do I document a module in Python?
That's it. If you want to document a function or a class, you put a string just after the definition. For instance: def foo(): """This function does nothing.""" pass But what about a module? How can I document what a file.py does?
For the packages, you can document it in __init__.py. For the modules, you can add a docstring simply in the module file. All the information is here: http://www.python.org/dev/peps/pep-0257/
How do I document a module in Python? That's it. If you want to document a function or a class, you put a string just after the definition. For instance: def foo(): """This function does nothing.""" pass But what about a module? How can I document what a file.py does?
TITLE: How do I document a module in Python? QUESTION: That's it. If you want to document a function or a class, you put a string just after the definition. For instance: def foo(): """This function does nothing.""" pass But what about a module? How can I document what a file.py does? ANSWER: For the packages, you can document it in __init__.py. For the modules, you can add a docstring simply in the module file. All the information is here: http://www.python.org/dev/peps/pep-0257/
[ "python", "documentation", "python-module" ]
89
55
77,096
6
0
2008-09-04T16:06:48.957000
2008-09-04T16:12:23.127000
44,089
44,676
How To Extract SFTP SSH Key From Key Cache in FileZilla FTP Client
I have connected to a server via SFTP using FileZilla and accepted adding the server's SSH key to the key cache in FileZilla. How can I extract this cached key to a keyfile so that may use it through other SFTP applications that require a keyfile be made available? I have not been able to find anything in the FileZilla documentation related to this.
If you use the standard openssh console client (cygwin or from linux), host keys are stored, one-per-line, in ~/.ssh/known_hosts. From there, it's a simple matter of figuring out which bit of that host key is needed for your library. Putty also stores host keys, but it appears to encode them in hex. Those can be found at HKCUR\Software\SimonTatham\PuTTY\SshHostKeys
How To Extract SFTP SSH Key From Key Cache in FileZilla FTP Client I have connected to a server via SFTP using FileZilla and accepted adding the server's SSH key to the key cache in FileZilla. How can I extract this cached key to a keyfile so that may use it through other SFTP applications that require a keyfile be made available? I have not been able to find anything in the FileZilla documentation related to this.
TITLE: How To Extract SFTP SSH Key From Key Cache in FileZilla FTP Client QUESTION: I have connected to a server via SFTP using FileZilla and accepted adding the server's SSH key to the key cache in FileZilla. How can I extract this cached key to a keyfile so that may use it through other SFTP applications that require a keyfile be made available? I have not been able to find anything in the FileZilla documentation related to this. ANSWER: If you use the standard openssh console client (cygwin or from linux), host keys are stored, one-per-line, in ~/.ssh/known_hosts. From there, it's a simple matter of figuring out which bit of that host key is needed for your library. Putty also stores host keys, but it appears to encode them in hex. Those can be found at HKCUR\Software\SimonTatham\PuTTY\SshHostKeys
[ "ftp", "sftp", "filezilla" ]
20
22
81,104
5
0
2008-09-04T16:09:20.777000
2008-09-04T20:12:16.263000
44,100
44,106
Best way to use a property to reference a Key-Value pair in a dictionary
This is a fairly trivial matter, but I'm curious to hear people's opinions on it. If I have a Dictionary which I'm access through properties, which of these formats would you prefer for the property? /// /// This class's FirstProperty property /// [DefaultValue("myValue")] public string FirstProperty { get { return Dictionary["myKey"]; } set { Dictionary["myKey"] = value; } This is probably the typical way of doing it. It's fairly efficient, easy to understand, etc. The only disadvantage is with a longer or more complex key it would be possible to misspell it or change only one instance or something, leading me to this: /// /// This class's SecondProperty property /// [DefaultValue("myValue")] private const string DICT_MYKEY = "myKey" public string SecondProperty { get { return Dictionary[DICT_MYKEY]; } set { Dictionary[DICT_MYKEY] = value; } Which is marginally more complicated, but seems to offer additional safety, and is closer to what I would think of as the "Code Complete" solution. The downside is that when you also have a /// block and a [DefaultValue()] block above the property already, it starts getting a bit crowded up there. So which do you like better, and why? Does anybody have any better ideas?
I like the second one purely because any avoidance of magic strings/numbers in code is a good thing. IMO if you need to reference a number or string literal in code more than once, it should be a constant. In most cases even if it's only used once it should be in a constant
Best way to use a property to reference a Key-Value pair in a dictionary This is a fairly trivial matter, but I'm curious to hear people's opinions on it. If I have a Dictionary which I'm access through properties, which of these formats would you prefer for the property? /// /// This class's FirstProperty property /// [DefaultValue("myValue")] public string FirstProperty { get { return Dictionary["myKey"]; } set { Dictionary["myKey"] = value; } This is probably the typical way of doing it. It's fairly efficient, easy to understand, etc. The only disadvantage is with a longer or more complex key it would be possible to misspell it or change only one instance or something, leading me to this: /// /// This class's SecondProperty property /// [DefaultValue("myValue")] private const string DICT_MYKEY = "myKey" public string SecondProperty { get { return Dictionary[DICT_MYKEY]; } set { Dictionary[DICT_MYKEY] = value; } Which is marginally more complicated, but seems to offer additional safety, and is closer to what I would think of as the "Code Complete" solution. The downside is that when you also have a /// block and a [DefaultValue()] block above the property already, it starts getting a bit crowded up there. So which do you like better, and why? Does anybody have any better ideas?
TITLE: Best way to use a property to reference a Key-Value pair in a dictionary QUESTION: This is a fairly trivial matter, but I'm curious to hear people's opinions on it. If I have a Dictionary which I'm access through properties, which of these formats would you prefer for the property? /// /// This class's FirstProperty property /// [DefaultValue("myValue")] public string FirstProperty { get { return Dictionary["myKey"]; } set { Dictionary["myKey"] = value; } This is probably the typical way of doing it. It's fairly efficient, easy to understand, etc. The only disadvantage is with a longer or more complex key it would be possible to misspell it or change only one instance or something, leading me to this: /// /// This class's SecondProperty property /// [DefaultValue("myValue")] private const string DICT_MYKEY = "myKey" public string SecondProperty { get { return Dictionary[DICT_MYKEY]; } set { Dictionary[DICT_MYKEY] = value; } Which is marginally more complicated, but seems to offer additional safety, and is closer to what I would think of as the "Code Complete" solution. The downside is that when you also have a /// block and a [DefaultValue()] block above the property already, it starts getting a bit crowded up there. So which do you like better, and why? Does anybody have any better ideas? ANSWER: I like the second one purely because any avoidance of magic strings/numbers in code is a good thing. IMO if you need to reference a number or string literal in code more than once, it should be a constant. In most cases even if it's only used once it should be in a constant
[ ".net", "dictionary", "properties", "constants" ]
3
4
2,081
7
0
2008-09-04T16:15:13.650000
2008-09-04T16:18:09.977000
44,102
44,825
NT authentication login
I am working on a site where users can login to get more private information. My client has another site else where that uses nt authentication for accessing it. What they want to do is have a button on the site I am working on under the private area that will send them to the nt authenticated site, but not require them to log on to that site instead passing the username and password that they used to log into my site to the other site for them. Is it possible to do this? and how would I accomplish it? Is there a better way to do this?
Here's an (untested) theory, the details of which will greatly depend on what types of authentication the Sharepoint site will accept. I'll tackle Basic, since it's the easiest. You'll write out some JavaScript that uses XMLHttpRequest to submit a request to the Sharepoint site, and add their username and password to the request headers. Their browser will run that JavaScript, and get logged into the Sharepoint site. Now, when they click the link, the client's browser should have the cached credentials to send to the Sharepoint site. Possible issues: XMLHttpRequest does not allow cross domain auth Browser and XHR don't share auth info Sharepoint and XHR can't agree on auth method Another option is to proxy the connection to Sharepoint, which allows you to login server side (bypassing XHR limitations and browser security) - but requiring load on your server and possibly some URL target issues.
NT authentication login I am working on a site where users can login to get more private information. My client has another site else where that uses nt authentication for accessing it. What they want to do is have a button on the site I am working on under the private area that will send them to the nt authenticated site, but not require them to log on to that site instead passing the username and password that they used to log into my site to the other site for them. Is it possible to do this? and how would I accomplish it? Is there a better way to do this?
TITLE: NT authentication login QUESTION: I am working on a site where users can login to get more private information. My client has another site else where that uses nt authentication for accessing it. What they want to do is have a button on the site I am working on under the private area that will send them to the nt authenticated site, but not require them to log on to that site instead passing the username and password that they used to log into my site to the other site for them. Is it possible to do this? and how would I accomplish it? Is there a better way to do this? ANSWER: Here's an (untested) theory, the details of which will greatly depend on what types of authentication the Sharepoint site will accept. I'll tackle Basic, since it's the easiest. You'll write out some JavaScript that uses XMLHttpRequest to submit a request to the Sharepoint site, and add their username and password to the request headers. Their browser will run that JavaScript, and get logged into the Sharepoint site. Now, when they click the link, the client's browser should have the cached credentials to send to the Sharepoint site. Possible issues: XMLHttpRequest does not allow cross domain auth Browser and XHR don't share auth info Sharepoint and XHR can't agree on auth method Another option is to proxy the connection to Sharepoint, which allows you to login server side (bypassing XHR limitations and browser security) - but requiring load on your server and possibly some URL target issues.
[ "authentication", "ntlm" ]
1
1
1,111
5
0
2008-09-04T16:15:48.563000
2008-09-04T21:22:09.607000
44,109
44,178
What's the best way to extend the User model in Django?
What's the best way to extend the User model (bundled with Django's authentication app) with custom fields? I would also possibly like to use the email as the username (for authentication purposes). I've already seen a few ways to do it, but can't decide on which one is the best.
The least painful and indeed Django-recommended way of doing this is through a OneToOneField(User) property. Extending the existing User model … If you wish to store information related to User, you can use a one-to-one relationship to a model containing the fields for additional information. This one-to-one model is often called a profile model, as it might store non-auth related information about a site user. That said, extending django.contrib.auth.models.User and supplanting it also works... Substituting a custom User model Some kinds of projects may have authentication requirements for which Django’s built-in User model is not always appropriate. For instance, on some sites it makes more sense to use an email address as your identification token instead of a username. [Ed: Two warnings and a notification follow, mentioning that this is pretty drastic.] I would definitely stay away from changing the actual User class in your Django source tree and/or copying and altering the auth module.
What's the best way to extend the User model in Django? What's the best way to extend the User model (bundled with Django's authentication app) with custom fields? I would also possibly like to use the email as the username (for authentication purposes). I've already seen a few ways to do it, but can't decide on which one is the best.
TITLE: What's the best way to extend the User model in Django? QUESTION: What's the best way to extend the User model (bundled with Django's authentication app) with custom fields? I would also possibly like to use the email as the username (for authentication purposes). I've already seen a few ways to do it, but can't decide on which one is the best. ANSWER: The least painful and indeed Django-recommended way of doing this is through a OneToOneField(User) property. Extending the existing User model … If you wish to store information related to User, you can use a one-to-one relationship to a model containing the fields for additional information. This one-to-one model is often called a profile model, as it might store non-auth related information about a site user. That said, extending django.contrib.auth.models.User and supplanting it also works... Substituting a custom User model Some kinds of projects may have authentication requirements for which Django’s built-in User model is not always appropriate. For instance, on some sites it makes more sense to use an email address as your identification token instead of a username. [Ed: Two warnings and a notification follow, mentioning that this is pretty drastic.] I would definitely stay away from changing the actual User class in your Django source tree and/or copying and altering the auth module.
[ "python", "django", "django-models", "django-authentication", "django-users" ]
548
312
332,269
17
0
2008-09-04T16:19:49.083000
2008-09-04T17:02:18.403000
44,118
44,129
SQL Server Alter Computed Column
Does anyone know of a way to alter a computed column without dropping the column in SQL Server. I want to stop using the column as a computed column and start storing data directly in the column, but would like to retain the current values. Is this even possible?
Not that I know of but here is something you can do add another column to the table update that column with the values of the computed column then drop the computed column
SQL Server Alter Computed Column Does anyone know of a way to alter a computed column without dropping the column in SQL Server. I want to stop using the column as a computed column and start storing data directly in the column, but would like to retain the current values. Is this even possible?
TITLE: SQL Server Alter Computed Column QUESTION: Does anyone know of a way to alter a computed column without dropping the column in SQL Server. I want to stop using the column as a computed column and start storing data directly in the column, but would like to retain the current values. Is this even possible? ANSWER: Not that I know of but here is something you can do add another column to the table update that column with the values of the computed column then drop the computed column
[ "sql-server", "alter-table" ]
8
10
10,875
3
0
2008-09-04T16:25:17.400000
2008-09-04T16:30:52.973000
44,131
44,174
How do I hide the input caret in a System.Windows.Forms.TextBox?
I need to display a variable-length message and allow the text to be selectable. I have made the TextBox ReadOnly which does not allow the text to be edited, but the input caret is still shown. The blinking input caret is confusing. How do I hide it?
You can do through a win32 call [DllImport("user32.dll")] static extern bool HideCaret(IntPtr hWnd); public void HideCaret() { HideCaret(someTextBox.Handle); }
How do I hide the input caret in a System.Windows.Forms.TextBox? I need to display a variable-length message and allow the text to be selectable. I have made the TextBox ReadOnly which does not allow the text to be edited, but the input caret is still shown. The blinking input caret is confusing. How do I hide it?
TITLE: How do I hide the input caret in a System.Windows.Forms.TextBox? QUESTION: I need to display a variable-length message and allow the text to be selectable. I have made the TextBox ReadOnly which does not allow the text to be edited, but the input caret is still shown. The blinking input caret is confusing. How do I hide it? ANSWER: You can do through a win32 call [DllImport("user32.dll")] static extern bool HideCaret(IntPtr hWnd); public void HideCaret() { HideCaret(someTextBox.Handle); }
[ "winforms", "textbox" ]
11
18
17,869
6
0
2008-09-04T16:32:37.710000
2008-09-04T16:58:24.247000
44,135
135,468
Project design / FS layout for large django projects
What is the best way to layout a large django project? The tutorials provide simple instructions for setting up apps, models, and views, but there is less information about how apps and projects should be broken down, how much sharing is allowable/necessary between apps in a typical project (obviously that is largely dependent on the project) and how/where general templates should be kept. Does anyone have examples, suggestions, and explanations as to why a certain project layout is better than another? I am particularly interested in the incorporation of large numbers of unit tests (2-5x the size of the actual code base) and string externalization / templates.
The major guidelines are similar to any other large code project. Apps should address a single, clearly-defined responsibility. The name "application" is a misnomer; Django apps should be thought of more as reusable components which can be plugged together to create a real application. Tests for each app should be contained within that app. Apps should be decoupled from each other as much as possible, but clearly there will be dependencies, so the goal should be to keep the dependency graph as simple and sane as possible. I prefer to keep all the templates for a project under a single project-wide templates directory, with a subdirectory for each app (using a template subdirectory for each app is a very strong convention in Django, as it avoids template name collisions between apps). The reason for a single project-wide templates directory is that templates, template inheritance trees, and block names can be quite project-specific, so it's hard to provide "default" app templates that can plug in to any project. There have been some attempts to settle on standard naming conventions for base site-wide templates and the blocks they define, but I haven't seen a standard emerge yet (the way they do things over at Pinax is probably the closest we have to a standard). Re "string externalization", if you mean i18n and l10n, Django has strong support for that and standard places where it puts the.po files - check the docs.
Project design / FS layout for large django projects What is the best way to layout a large django project? The tutorials provide simple instructions for setting up apps, models, and views, but there is less information about how apps and projects should be broken down, how much sharing is allowable/necessary between apps in a typical project (obviously that is largely dependent on the project) and how/where general templates should be kept. Does anyone have examples, suggestions, and explanations as to why a certain project layout is better than another? I am particularly interested in the incorporation of large numbers of unit tests (2-5x the size of the actual code base) and string externalization / templates.
TITLE: Project design / FS layout for large django projects QUESTION: What is the best way to layout a large django project? The tutorials provide simple instructions for setting up apps, models, and views, but there is less information about how apps and projects should be broken down, how much sharing is allowable/necessary between apps in a typical project (obviously that is largely dependent on the project) and how/where general templates should be kept. Does anyone have examples, suggestions, and explanations as to why a certain project layout is better than another? I am particularly interested in the incorporation of large numbers of unit tests (2-5x the size of the actual code base) and string externalization / templates. ANSWER: The major guidelines are similar to any other large code project. Apps should address a single, clearly-defined responsibility. The name "application" is a misnomer; Django apps should be thought of more as reusable components which can be plugged together to create a real application. Tests for each app should be contained within that app. Apps should be decoupled from each other as much as possible, but clearly there will be dependencies, so the goal should be to keep the dependency graph as simple and sane as possible. I prefer to keep all the templates for a project under a single project-wide templates directory, with a subdirectory for each app (using a template subdirectory for each app is a very strong convention in Django, as it avoids template name collisions between apps). The reason for a single project-wide templates directory is that templates, template inheritance trees, and block names can be quite project-specific, so it's hard to provide "default" app templates that can plug in to any project. There have been some attempts to settle on standard naming conventions for base site-wide templates and the blocks they define, but I haven't seen a standard emerge yet (the way they do things over at Pinax is probably the closest we have to a standard). Re "string externalization", if you mean i18n and l10n, Django has strong support for that and standard places where it puts the.po files - check the docs.
[ "python", "django" ]
44
19
8,149
6
0
2008-09-04T16:36:12.180000
2008-09-25T19:30:33.117000
44,144
44,160
Hudson can't build my Maven 2 project because it says artifacts are missing from the repository? (they aren't)
I'm using Hudson and Maven 2 for my automated build/CI. I can build fine with maven from the command line, but when I run the same goal with Hudson, the build fails complaining of missing artifacts. I'm running Hudson as a windows XP service.
Obvious question, but have you got Hudson set up to point to the same Maven repository as your command line build? You can check this from the Hudson admin gui - look in the Maven section of the Manage Hudson page. This should have a MAVEN_HOME environment variable listed. Look in the settings.xml file under: MAVEN_HOME\conf\settings.xml The localRepository configuration item is the location of the Maven repository that the Hudson build is using.
Hudson can't build my Maven 2 project because it says artifacts are missing from the repository? (they aren't) I'm using Hudson and Maven 2 for my automated build/CI. I can build fine with maven from the command line, but when I run the same goal with Hudson, the build fails complaining of missing artifacts. I'm running Hudson as a windows XP service.
TITLE: Hudson can't build my Maven 2 project because it says artifacts are missing from the repository? (they aren't) QUESTION: I'm using Hudson and Maven 2 for my automated build/CI. I can build fine with maven from the command line, but when I run the same goal with Hudson, the build fails complaining of missing artifacts. I'm running Hudson as a windows XP service. ANSWER: Obvious question, but have you got Hudson set up to point to the same Maven repository as your command line build? You can check this from the Hudson admin gui - look in the Maven section of the Manage Hudson page. This should have a MAVEN_HOME environment variable listed. Look in the settings.xml file under: MAVEN_HOME\conf\settings.xml The localRepository configuration item is the location of the Maven repository that the Hudson build is using.
[ "maven-2", "continuous-integration", "hudson" ]
4
3
10,265
2
0
2008-09-04T16:39:56.413000
2008-09-04T16:49:26.813000
44,145
48,261
Database sharding and Rails
What's the best way to deal with a sharded database in Rails? Should the sharding be handled at the application layer, the active record layer, the database driver layer, a proxy layer, or something else altogether? What are the pros and cons of each?
FiveRuns have a gem named DataFabric that does application-level sharding and master/slave replication. It might be worth checking out.
Database sharding and Rails What's the best way to deal with a sharded database in Rails? Should the sharding be handled at the application layer, the active record layer, the database driver layer, a proxy layer, or something else altogether? What are the pros and cons of each?
TITLE: Database sharding and Rails QUESTION: What's the best way to deal with a sharded database in Rails? Should the sharding be handled at the application layer, the active record layer, the database driver layer, a proxy layer, or something else altogether? What are the pros and cons of each? ANSWER: FiveRuns have a gem named DataFabric that does application-level sharding and master/slave replication. It might be worth checking out.
[ "ruby-on-rails", "database", "activerecord", "sharding" ]
12
13
10,874
9
0
2008-09-04T16:40:10
2008-09-07T08:47:30.657000
44,177
44,203
Connecting private IPs
A friend of mine told me there was a way to connect two private IPs without using a proxy server. The idea was that both computers connected to a public server and some how the server joined the private connections and won't use any more bandwidth. Is this true? How's this technique named?
There is a technique called " Hole Punching " that works well with "Cone" NAT (Cone is a technical familly of router). That's not an 100% sure technique, today, it works well with UDP on about 80% of the router. There is some implementations of library to realize Hole Punching: STUN ( wikipedia )
Connecting private IPs A friend of mine told me there was a way to connect two private IPs without using a proxy server. The idea was that both computers connected to a public server and some how the server joined the private connections and won't use any more bandwidth. Is this true? How's this technique named?
TITLE: Connecting private IPs QUESTION: A friend of mine told me there was a way to connect two private IPs without using a proxy server. The idea was that both computers connected to a public server and some how the server joined the private connections and won't use any more bandwidth. Is this true? How's this technique named? ANSWER: There is a technique called " Hole Punching " that works well with "Cone" NAT (Cone is a technical familly of router). That's not an 100% sure technique, today, it works well with UDP on about 80% of the router. There is some implementations of library to realize Hole Punching: STUN ( wikipedia )
[ "tcp", "ip-address" ]
3
2
352
5
0
2008-09-04T17:01:13.647000
2008-09-04T17:12:42.357000
44,181
44,183
SQL: Select like column from two tables
I have a database with two tables ( Table1 and Table2 ). They both have a common column [ColumnA] which is an nvarchar. How can I select this column from both tables and return it as a single column in my result set? So I'm looking for something like: ColumnA in Table1: a b c ColumnA in Table2: d e f Result set should be: a b c d e f
SELECT ColumnA FROM Table1 UNION Select ColumnB FROM Table2 ORDER BY 1 Also, if you know the contents of Table1 and Table2 will NEVER overlap, you can use UNION ALL in place of UNION instead. Saves a little bit of resources that way. -- Kevin Fairchild
SQL: Select like column from two tables I have a database with two tables ( Table1 and Table2 ). They both have a common column [ColumnA] which is an nvarchar. How can I select this column from both tables and return it as a single column in my result set? So I'm looking for something like: ColumnA in Table1: a b c ColumnA in Table2: d e f Result set should be: a b c d e f
TITLE: SQL: Select like column from two tables QUESTION: I have a database with two tables ( Table1 and Table2 ). They both have a common column [ColumnA] which is an nvarchar. How can I select this column from both tables and return it as a single column in my result set? So I'm looking for something like: ColumnA in Table1: a b c ColumnA in Table2: d e f Result set should be: a b c d e f ANSWER: SELECT ColumnA FROM Table1 UNION Select ColumnB FROM Table2 ORDER BY 1 Also, if you know the contents of Table1 and Table2 will NEVER overlap, you can use UNION ALL in place of UNION instead. Saves a little bit of resources that way. -- Kevin Fairchild
[ "sql" ]
10
16
11,502
8
0
2008-09-04T17:03:25.250000
2008-09-04T17:04:15.327000
44,190
44,216
Looking for a simple JavaScript example that updates DOM
I am looking for a simple JavaScript example that updates DOM. Any suggestions?
Here is a short pure-javascript example. Assume you have a div with the id "maincontent". var newnode = document.createTextNode('Here is some text.'); document.getElementById('maincontent').appendChild(newnode); Of course, things are a lot easier (especially when you want to do more complicated things) with jQuery.
Looking for a simple JavaScript example that updates DOM I am looking for a simple JavaScript example that updates DOM. Any suggestions?
TITLE: Looking for a simple JavaScript example that updates DOM QUESTION: I am looking for a simple JavaScript example that updates DOM. Any suggestions? ANSWER: Here is a short pure-javascript example. Assume you have a div with the id "maincontent". var newnode = document.createTextNode('Here is some text.'); document.getElementById('maincontent').appendChild(newnode); Of course, things are a lot easier (especially when you want to do more complicated things) with jQuery.
[ "javascript", "dom" ]
5
5
2,365
5
0
2008-09-04T17:06:32.370000
2008-09-04T17:18:09.753000
44,194
44,219
How do I best generate a CSV (comma-delimited text file) for download with ASP.NET?
This is what I've got. It works. But, is there a simpler or better way? One an ASPX page, I've got the download link... Download as CSV file And then I've got the Download.aspx.vb Code Behind... Public Partial Class Download Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load 'set header Response.Clear() Response.ContentType = "text/csv" Dim FileName As String = "books.csv" Response.AppendHeader("Content-Disposition", "attachment;filename=" + FileName) 'generate file content Dim db As New bookDevelopmentDataContext Dim Allbooks = From b In db.books _ Order By b.Added _ Select b Dim CsvFile As New StringBuilder CsvFile.AppendLine(CsvHeader()) For Each b As Book In Allbooks CsvFile.AppendLine(bookString(b)) Next 'write the file Response.Write(CsvFile.ToString) Response.End() End Sub Function CsvHeader() As String Dim CsvLine As New StringBuilder CsvLine.Append("Published,") CsvLine.Append("Title,") CsvLine.Append("Author,") CsvLine.Append("Price") Return CsvLine.ToString End Function Function bookString(ByVal b As Book) As String Dim CsvLine As New StringBuilder CsvLine.Append(b.Published.ToShortDateString + ",") CsvLine.Append(b.Title.Replace(",", "") + ",") CsvLine.Append(b.Author.Replace(",", "") + ",") CsvLine.Append(Format(b.Price, "c").Replace(",", "")) Return CsvLine.ToString End Function End Class
CSV formatting has some gotchas. Have you asked yourself these questions: Does any of my data have embedded commas? Does any of my data have embedded double-quotes? Does any of my data have have newlines? Do I need to support Unicode strings? I see several problems in your code above. The comma thing first of all... you are stripping commas: CsvLine.Append(Format(b.Price, "c").Replace(",", "")) Why? In CSV, you should be surrounding anything which has commas with quotes: CsvLine.Append(String.Format("\"{0:c}\"", b.Price)) (or something like that... my VB is not very good). If you're not sure if there are commas, but put quotes around it. If there are quotes in the string, you need to escape them by doubling them. " becomes "". b.Title.Replace("\"", "\"\"") Then surround this by quotes if you want. If there are newlines in your string, you need to surround the string with quotes... yes, literal newlines are allowed in CSV files. It looks weird to humans, but it's all good. A good CSV writer requires some thought. A good CSV reader (parser) is just plain hard (and no, regex not good enough for parsing CSV... it will only get you about 95% of the way there). And then there is Unicode... or more generally I18N (Internationalization) issues. For example, you are stripping commas out of a formatted price. But that's assuming the price is formatted as you expect it in the US. In France, the number formatting is reversed (periods used instead of commas, and vice versa ). Bottom line, use culture-agnostic formatting wherever possible. While the issue here is generating CSV, inevitably you will need to parse CSV. In.NET, the best parser I have found (for free) is Fast CSV Reader on CodeProject. I've actually used it in production code and it is really really fast, and very easy to use!
How do I best generate a CSV (comma-delimited text file) for download with ASP.NET? This is what I've got. It works. But, is there a simpler or better way? One an ASPX page, I've got the download link... Download as CSV file And then I've got the Download.aspx.vb Code Behind... Public Partial Class Download Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load 'set header Response.Clear() Response.ContentType = "text/csv" Dim FileName As String = "books.csv" Response.AppendHeader("Content-Disposition", "attachment;filename=" + FileName) 'generate file content Dim db As New bookDevelopmentDataContext Dim Allbooks = From b In db.books _ Order By b.Added _ Select b Dim CsvFile As New StringBuilder CsvFile.AppendLine(CsvHeader()) For Each b As Book In Allbooks CsvFile.AppendLine(bookString(b)) Next 'write the file Response.Write(CsvFile.ToString) Response.End() End Sub Function CsvHeader() As String Dim CsvLine As New StringBuilder CsvLine.Append("Published,") CsvLine.Append("Title,") CsvLine.Append("Author,") CsvLine.Append("Price") Return CsvLine.ToString End Function Function bookString(ByVal b As Book) As String Dim CsvLine As New StringBuilder CsvLine.Append(b.Published.ToShortDateString + ",") CsvLine.Append(b.Title.Replace(",", "") + ",") CsvLine.Append(b.Author.Replace(",", "") + ",") CsvLine.Append(Format(b.Price, "c").Replace(",", "")) Return CsvLine.ToString End Function End Class
TITLE: How do I best generate a CSV (comma-delimited text file) for download with ASP.NET? QUESTION: This is what I've got. It works. But, is there a simpler or better way? One an ASPX page, I've got the download link... Download as CSV file And then I've got the Download.aspx.vb Code Behind... Public Partial Class Download Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load 'set header Response.Clear() Response.ContentType = "text/csv" Dim FileName As String = "books.csv" Response.AppendHeader("Content-Disposition", "attachment;filename=" + FileName) 'generate file content Dim db As New bookDevelopmentDataContext Dim Allbooks = From b In db.books _ Order By b.Added _ Select b Dim CsvFile As New StringBuilder CsvFile.AppendLine(CsvHeader()) For Each b As Book In Allbooks CsvFile.AppendLine(bookString(b)) Next 'write the file Response.Write(CsvFile.ToString) Response.End() End Sub Function CsvHeader() As String Dim CsvLine As New StringBuilder CsvLine.Append("Published,") CsvLine.Append("Title,") CsvLine.Append("Author,") CsvLine.Append("Price") Return CsvLine.ToString End Function Function bookString(ByVal b As Book) As String Dim CsvLine As New StringBuilder CsvLine.Append(b.Published.ToShortDateString + ",") CsvLine.Append(b.Title.Replace(",", "") + ",") CsvLine.Append(b.Author.Replace(",", "") + ",") CsvLine.Append(Format(b.Price, "c").Replace(",", "")) Return CsvLine.ToString End Function End Class ANSWER: CSV formatting has some gotchas. Have you asked yourself these questions: Does any of my data have embedded commas? Does any of my data have embedded double-quotes? Does any of my data have have newlines? Do I need to support Unicode strings? I see several problems in your code above. The comma thing first of all... you are stripping commas: CsvLine.Append(Format(b.Price, "c").Replace(",", "")) Why? In CSV, you should be surrounding anything which has commas with quotes: CsvLine.Append(String.Format("\"{0:c}\"", b.Price)) (or something like that... my VB is not very good). If you're not sure if there are commas, but put quotes around it. If there are quotes in the string, you need to escape them by doubling them. " becomes "". b.Title.Replace("\"", "\"\"") Then surround this by quotes if you want. If there are newlines in your string, you need to surround the string with quotes... yes, literal newlines are allowed in CSV files. It looks weird to humans, but it's all good. A good CSV writer requires some thought. A good CSV reader (parser) is just plain hard (and no, regex not good enough for parsing CSV... it will only get you about 95% of the way there). And then there is Unicode... or more generally I18N (Internationalization) issues. For example, you are stripping commas out of a formatted price. But that's assuming the price is formatted as you expect it in the US. In France, the number formatting is reversed (periods used instead of commas, and vice versa ). Bottom line, use culture-agnostic formatting wherever possible. While the issue here is generating CSV, inevitably you will need to parse CSV. In.NET, the best parser I have found (for free) is Fast CSV Reader on CodeProject. I've actually used it in production code and it is really really fast, and very easy to use!
[ "asp.net", "vb.net", "file-io", "csv" ]
18
23
61,067
8
0
2008-09-04T17:07:17.160000
2008-09-04T17:19:59.437000
44,205
44,236
Direct TCP/IP connections in P2P apps
From a Joel's post on Copilot: Direct Connect! We’ve always done everything we can to make sure that Fog Creek Copilot can connect in any networking situation, no matter what firewalls or NATs are in place. To make this happen, both parties make outbound connections to our server, which relays traffic on their behalf. Well, in many cases, this isn’t necessary. So version 2.0 does something rather clever: it sets up the initial connection through our servers, so you get connected right away with 100% reliability. But then once you’re all connected, it quietly, in the background, looks for a way to make a direct connection. If it can’t, no big deal: you just keep relaying through our server. If you can make a direct peer-to-peer connection, it silently shifts your data onto the direct connection. You won’t notice anything except, probably, much faster communication. How do they change the server connection to a P2P connection?
It's pretty tricky and interesting. I'm sure I have some details wrong, but the overview is this: The programs can already talk to each other through Joel's server, so they can exchange information with each other and Joel's server. Further, Joel has their external IP addresses, and they give joel information about their internal IP addresses. They decide to try this hole punch technique. Computer A initiates a TCP connection with Computer B using B's external IP address. It won't go through, but what it does is tell's A's router that it needs to allow incoming packets from B on a given port. Computer B does the same thing, but its message gets through to A since A's router opened a port/ip combination that matches what B sent (there's some port magic that happens here - this is non trivial, but doable). B's router remembers that B initiated a connection with A on a given port and IP, and so A's packets now flow into B past their router correctly as well. So it's actually pretty straight forward, but the implementation has details, especially regarding how ports are given to new TCP connections, and how NAT routers typically deal with TCP requests and how they map to external ports. These details are the interesting, and difficult, bit. -Adam
Direct TCP/IP connections in P2P apps From a Joel's post on Copilot: Direct Connect! We’ve always done everything we can to make sure that Fog Creek Copilot can connect in any networking situation, no matter what firewalls or NATs are in place. To make this happen, both parties make outbound connections to our server, which relays traffic on their behalf. Well, in many cases, this isn’t necessary. So version 2.0 does something rather clever: it sets up the initial connection through our servers, so you get connected right away with 100% reliability. But then once you’re all connected, it quietly, in the background, looks for a way to make a direct connection. If it can’t, no big deal: you just keep relaying through our server. If you can make a direct peer-to-peer connection, it silently shifts your data onto the direct connection. You won’t notice anything except, probably, much faster communication. How do they change the server connection to a P2P connection?
TITLE: Direct TCP/IP connections in P2P apps QUESTION: From a Joel's post on Copilot: Direct Connect! We’ve always done everything we can to make sure that Fog Creek Copilot can connect in any networking situation, no matter what firewalls or NATs are in place. To make this happen, both parties make outbound connections to our server, which relays traffic on their behalf. Well, in many cases, this isn’t necessary. So version 2.0 does something rather clever: it sets up the initial connection through our servers, so you get connected right away with 100% reliability. But then once you’re all connected, it quietly, in the background, looks for a way to make a direct connection. If it can’t, no big deal: you just keep relaying through our server. If you can make a direct peer-to-peer connection, it silently shifts your data onto the direct connection. You won’t notice anything except, probably, much faster communication. How do they change the server connection to a P2P connection? ANSWER: It's pretty tricky and interesting. I'm sure I have some details wrong, but the overview is this: The programs can already talk to each other through Joel's server, so they can exchange information with each other and Joel's server. Further, Joel has their external IP addresses, and they give joel information about their internal IP addresses. They decide to try this hole punch technique. Computer A initiates a TCP connection with Computer B using B's external IP address. It won't go through, but what it does is tell's A's router that it needs to allow incoming packets from B on a given port. Computer B does the same thing, but its message gets through to A since A's router opened a port/ip combination that matches what B sent (there's some port magic that happens here - this is non trivial, but doable). B's router remembers that B initiated a connection with A on a given port and IP, and so A's packets now flow into B past their router correctly as well. So it's actually pretty straight forward, but the implementation has details, especially regarding how ports are given to new TCP connections, and how NAT routers typically deal with TCP requests and how they map to external ports. These details are the interesting, and difficult, bit. -Adam
[ "networking", "tcp", "p2p" ]
4
10
8,188
3
0
2008-09-04T17:13:59.843000
2008-09-04T17:26:12.340000
44,220
44,225
Difference between foreach and for loops over an IEnumerable class in C#
I have been told that there is a performance difference between the following code blocks. foreach (Entity e in entityList) {.... } and for (int i=0; i where List entityList; I am no CLR expect but from what I can tell they should boil down to basically the same code. Does anybody have concrete (heck, I'd take packed dirt) evidence one way or the other?
foreach creates an instance of an enumerator (returned from GetEnumerator) and that enumerator also keeps state throughout the course of the foreach loop. It then repeatedly calls for the Next() object on the enumerator and runs your code for each object it returns. They don't boil down to the same code in any way, really, which you'd see if you wrote your own enumerator.
Difference between foreach and for loops over an IEnumerable class in C# I have been told that there is a performance difference between the following code blocks. foreach (Entity e in entityList) {.... } and for (int i=0; i where List entityList; I am no CLR expect but from what I can tell they should boil down to basically the same code. Does anybody have concrete (heck, I'd take packed dirt) evidence one way or the other?
TITLE: Difference between foreach and for loops over an IEnumerable class in C# QUESTION: I have been told that there is a performance difference between the following code blocks. foreach (Entity e in entityList) {.... } and for (int i=0; i where List entityList; I am no CLR expect but from what I can tell they should boil down to basically the same code. Does anybody have concrete (heck, I'd take packed dirt) evidence one way or the other? ANSWER: foreach creates an instance of an enumerator (returned from GetEnumerator) and that enumerator also keeps state throughout the course of the foreach loop. It then repeatedly calls for the Next() object on the enumerator and runs your code for each object it returns. They don't boil down to the same code in any way, really, which you'd see if you wrote your own enumerator.
[ "c#", "performance", "loops" ]
13
10
21,759
7
0
2008-09-04T17:20:16.677000
2008-09-04T17:22:27.043000
44,224
45,989
How to start learning JAVA for use with Oracle RDBMS?
I am looking for some advice on what should I concentrate my efforts to get the needed skills to become a Java developer for Oracle applications. I'm bit confused as there are lot of technologies in the Java world. Where should I start? What to avoid? Is JDeveloper a good IDE for a beginner?
To become an Oracle Developer there is a bit more to learn than jdbc. You should take a look at the Oracle web site. It is kind of slow and not very intuitive but has a lot of good information. There are OUGs that have good info as well. If you just want to access Oracle via JAVA then you should use a framework such as Spring. Takes away the pain of jdbc. Lets you write sql and map it to objects. If you don't know PL/SQL it might be good to learn what it is. My two cents from working with Oracle for the past 7 yrs.
How to start learning JAVA for use with Oracle RDBMS? I am looking for some advice on what should I concentrate my efforts to get the needed skills to become a Java developer for Oracle applications. I'm bit confused as there are lot of technologies in the Java world. Where should I start? What to avoid? Is JDeveloper a good IDE for a beginner?
TITLE: How to start learning JAVA for use with Oracle RDBMS? QUESTION: I am looking for some advice on what should I concentrate my efforts to get the needed skills to become a Java developer for Oracle applications. I'm bit confused as there are lot of technologies in the Java world. Where should I start? What to avoid? Is JDeveloper a good IDE for a beginner? ANSWER: To become an Oracle Developer there is a bit more to learn than jdbc. You should take a look at the Oracle web site. It is kind of slow and not very intuitive but has a lot of good information. There are OUGs that have good info as well. If you just want to access Oracle via JAVA then you should use a framework such as Spring. Takes away the pain of jdbc. Lets you write sql and map it to objects. If you don't know PL/SQL it might be good to learn what it is. My two cents from working with Oracle for the past 7 yrs.
[ "java", "oracle" ]
5
3
1,825
7
0
2008-09-04T17:21:54.753000
2008-09-05T15:02:54.687000
44,247
44,265
What is the best practice for estimating required time for development of the SDLC phases?
As a project manager, you are required to organize time so that the project meets a deadline. Is there some sort of equations to use for estimating how long the development will take? let's say the database time = sql storedprocedures * tables manipulated or something similar Or are you just stuck having to get the experience to get adequate estimations?
There's no set formula out there that I've seen that would really work. Fogbugz has its monte carlo simulator which has somewhat of a concept for this, but really, experience is going to be your best point of reference. Every developer and every project will be different!
What is the best practice for estimating required time for development of the SDLC phases? As a project manager, you are required to organize time so that the project meets a deadline. Is there some sort of equations to use for estimating how long the development will take? let's say the database time = sql storedprocedures * tables manipulated or something similar Or are you just stuck having to get the experience to get adequate estimations?
TITLE: What is the best practice for estimating required time for development of the SDLC phases? QUESTION: As a project manager, you are required to organize time so that the project meets a deadline. Is there some sort of equations to use for estimating how long the development will take? let's say the database time = sql storedprocedures * tables manipulated or something similar Or are you just stuck having to get the experience to get adequate estimations? ANSWER: There's no set formula out there that I've seen that would really work. Fogbugz has its monte carlo simulator which has somewhat of a concept for this, but really, experience is going to be your best point of reference. Every developer and every project will be different!
[ "project-management", "time-management" ]
1
0
569
3
0
2008-09-04T17:30:58.443000
2008-09-04T17:36:24.577000
44,260
44,310
Can .NET check other running programs command line parameters?
We've got an interesting case where we are trying to determine how different instances of our app were launched. Is there any way for.NET to be able to query another running instance and get the command line parameters passed to that instance? I've not been able to find any way to do it in.NET so far, so I thought I'd check here to see if anyone had done anything like this before.
You can retrieve this information through WMI. See the Win32_Process class, in particular its command line property. This Code Project article provides pointers on how to do this,
Can .NET check other running programs command line parameters? We've got an interesting case where we are trying to determine how different instances of our app were launched. Is there any way for.NET to be able to query another running instance and get the command line parameters passed to that instance? I've not been able to find any way to do it in.NET so far, so I thought I'd check here to see if anyone had done anything like this before.
TITLE: Can .NET check other running programs command line parameters? QUESTION: We've got an interesting case where we are trying to determine how different instances of our app were launched. Is there any way for.NET to be able to query another running instance and get the command line parameters passed to that instance? I've not been able to find any way to do it in.NET so far, so I thought I'd check here to see if anyone had done anything like this before. ANSWER: You can retrieve this information through WMI. See the Win32_Process class, in particular its command line property. This Code Project article provides pointers on how to do this,
[ ".net", "command-line", "parameters" ]
2
4
455
3
0
2008-09-04T17:34:27.157000
2008-09-04T17:54:11.337000
44,261
44,268
cmd defaults to F: drive
When I open cmd on my laptop it is defaulting to the F: drive. This is troubling me does anyone know how it got that way or how to get it back to where it opens to the C: drive by default?
I believe it defaults to %HOMEDRIVE%\%HOMEPATH% so if you can muck about with those environment variables that might be an option. I can't edit these environment variables on my company's network, so I had to use the AutoRun to change it to something sane.
cmd defaults to F: drive When I open cmd on my laptop it is defaulting to the F: drive. This is troubling me does anyone know how it got that way or how to get it back to where it opens to the C: drive by default?
TITLE: cmd defaults to F: drive QUESTION: When I open cmd on my laptop it is defaulting to the F: drive. This is troubling me does anyone know how it got that way or how to get it back to where it opens to the C: drive by default? ANSWER: I believe it defaults to %HOMEDRIVE%\%HOMEPATH% so if you can muck about with those environment variables that might be an option. I can't edit these environment variables on my company's network, so I had to use the AutoRun to change it to something sane.
[ "windows", "cmd" ]
9
2
28,663
11
0
2008-09-04T17:34:28.093000
2008-09-04T17:36:52.690000
44,281
44,454
Database Patterns
Does anyone know of papers/books/etc. that document patterns for databases? For example, one common rule of thumb is that every table should have a primary key and that the key should be devoid of information content. So I was wondering if anyone had written a book or published papers regarding design patterns for designing relational databases? @Gaius, That is the question that a database designer needs to weigh--what is the probable stability of the database structure? Given a long-enough horizon nothing is stable. Or to say the converse, given a long-enough horizon, everything is subject to change. A surrogate key (in theory) should never change its meaning because it never had meaning to begin with. I guess the other thing to consider in that particular design scenario is who is it that will be seeing the primary key? If the primary key is something that end-users will actually need to refer to then it makes sense to make it something they can understand. But I can't think of many cases where an end-user needs to see a primary key; usually the primary key is present to allow the DB engine to speed up certain operations. My original thought in asking the question was to find design patterns for database design that were codified by more experienced database designers than myself so as to, hopefully, avoid some easily avoidable errors. It would be interesting reading if anyone had ever codified database design anti-patterns.
Specifically, regarding keys: I strongly disagree with the strange idea that keys must be without meaning. In general, I consider a database a collection of facts; as soon as you start adding arbitrary numbers (like generated keys) and other irrelevant information into it, it should be a warning sign. I recommend this articly by Joe Celko for more on keys. More general notes: Suggestions for schema designs/data models for different businesses: David C. Hay: Data Model Patterns: Conventions of Thought Rather old, but there is a reason why it's still in print http://www.dorsethouse.com/books/dmp.html Maybe not very pattern-like, but still very good: Stephane Faroult, Peter Robson: The Art of SQL http://oreilly.com/catalog/9780596008949/ Another one which I can recommend: Vadim Tropashko: SQL Design Patterns - The Expert Guide to SQL Programming http://www.rampant-books.com/book_2006_1_sql_coding_styles.htm Systematic text-book about data modelling: Graeme Simsion & Graham Witt, "Data Modeling Essentials" http://www.elsevierdirect.com/product.jsp?isbn=9780126445510 Maybe you are actually looking for a "style guide"?. I that case: Joe Celko: SQL Programming Style http://www.elsevierdirect.com/product.jsp?isbn=9780120887972
Database Patterns Does anyone know of papers/books/etc. that document patterns for databases? For example, one common rule of thumb is that every table should have a primary key and that the key should be devoid of information content. So I was wondering if anyone had written a book or published papers regarding design patterns for designing relational databases? @Gaius, That is the question that a database designer needs to weigh--what is the probable stability of the database structure? Given a long-enough horizon nothing is stable. Or to say the converse, given a long-enough horizon, everything is subject to change. A surrogate key (in theory) should never change its meaning because it never had meaning to begin with. I guess the other thing to consider in that particular design scenario is who is it that will be seeing the primary key? If the primary key is something that end-users will actually need to refer to then it makes sense to make it something they can understand. But I can't think of many cases where an end-user needs to see a primary key; usually the primary key is present to allow the DB engine to speed up certain operations. My original thought in asking the question was to find design patterns for database design that were codified by more experienced database designers than myself so as to, hopefully, avoid some easily avoidable errors. It would be interesting reading if anyone had ever codified database design anti-patterns.
TITLE: Database Patterns QUESTION: Does anyone know of papers/books/etc. that document patterns for databases? For example, one common rule of thumb is that every table should have a primary key and that the key should be devoid of information content. So I was wondering if anyone had written a book or published papers regarding design patterns for designing relational databases? @Gaius, That is the question that a database designer needs to weigh--what is the probable stability of the database structure? Given a long-enough horizon nothing is stable. Or to say the converse, given a long-enough horizon, everything is subject to change. A surrogate key (in theory) should never change its meaning because it never had meaning to begin with. I guess the other thing to consider in that particular design scenario is who is it that will be seeing the primary key? If the primary key is something that end-users will actually need to refer to then it makes sense to make it something they can understand. But I can't think of many cases where an end-user needs to see a primary key; usually the primary key is present to allow the DB engine to speed up certain operations. My original thought in asking the question was to find design patterns for database design that were codified by more experienced database designers than myself so as to, hopefully, avoid some easily avoidable errors. It would be interesting reading if anyone had ever codified database design anti-patterns. ANSWER: Specifically, regarding keys: I strongly disagree with the strange idea that keys must be without meaning. In general, I consider a database a collection of facts; as soon as you start adding arbitrary numbers (like generated keys) and other irrelevant information into it, it should be a warning sign. I recommend this articly by Joe Celko for more on keys. More general notes: Suggestions for schema designs/data models for different businesses: David C. Hay: Data Model Patterns: Conventions of Thought Rather old, but there is a reason why it's still in print http://www.dorsethouse.com/books/dmp.html Maybe not very pattern-like, but still very good: Stephane Faroult, Peter Robson: The Art of SQL http://oreilly.com/catalog/9780596008949/ Another one which I can recommend: Vadim Tropashko: SQL Design Patterns - The Expert Guide to SQL Programming http://www.rampant-books.com/book_2006_1_sql_coding_styles.htm Systematic text-book about data modelling: Graeme Simsion & Graham Witt, "Data Modeling Essentials" http://www.elsevierdirect.com/product.jsp?isbn=9780126445510 Maybe you are actually looking for a "style guide"?. I that case: Joe Celko: SQL Programming Style http://www.elsevierdirect.com/product.jsp?isbn=9780120887972
[ "design-patterns", "database-design" ]
24
10
6,141
6
0
2008-09-04T17:42:13.330000
2008-09-04T18:48:03.143000
44,286
45,018
Program for working with large CSV Files
Are there any good programs for dealing with reading large CSV files? Some of the datafiles I deal with are in the 1 GB range. They have too many lines for Excel to even deal with. Using Access can be a little slow, as you have to actually import them into a database to work with them directly. Is there a program that can open large CSV files and give you a simple spreadsheet layout to help you easily and quickly scan through the data?
MySQL can import CSV files very quickly onto tables using the LOAD DATA INFILE command. It can also read from CSV files directly, bypassing any import procedures, by using the CSV storage engine. Importing it onto native tables with LOAD DATA INFILE has a start up cost, but after that you can INSERT/UPDATE much faster, as well as index fields. Using the CSV storage engine is almost instantaneous at first, but only sequential scan will be fast. Update: This article (scroll down to the section titled Instant Data Loads ) talks about using both approaches to loading CSV data onto MySQL, and gives examples.
Program for working with large CSV Files Are there any good programs for dealing with reading large CSV files? Some of the datafiles I deal with are in the 1 GB range. They have too many lines for Excel to even deal with. Using Access can be a little slow, as you have to actually import them into a database to work with them directly. Is there a program that can open large CSV files and give you a simple spreadsheet layout to help you easily and quickly scan through the data?
TITLE: Program for working with large CSV Files QUESTION: Are there any good programs for dealing with reading large CSV files? Some of the datafiles I deal with are in the 1 GB range. They have too many lines for Excel to even deal with. Using Access can be a little slow, as you have to actually import them into a database to work with them directly. Is there a program that can open large CSV files and give you a simple spreadsheet layout to help you easily and quickly scan through the data? ANSWER: MySQL can import CSV files very quickly onto tables using the LOAD DATA INFILE command. It can also read from CSV files directly, bypassing any import procedures, by using the CSV storage engine. Importing it onto native tables with LOAD DATA INFILE has a start up cost, but after that you can INSERT/UPDATE much faster, as well as index fields. Using the CSV storage engine is almost instantaneous at first, but only sequential scan will be fast. Update: This article (scroll down to the section titled Instant Data Loads ) talks about using both approaches to loading CSV data onto MySQL, and gives examples.
[ "csv", "load-data-infile" ]
13
8
19,854
7
0
2008-09-04T17:42:59.727000
2008-09-05T00:13:28.103000
44,288
44,373
Differences in string compare methods in C#
Comparing string in C# is pretty simple. In fact there are several ways to do it. I have listed some in the block below. What I am curious about are the differences between them and when one should be used over the others? Should one be avoided at all costs? Are there more I haven't listed? string testString = "Test"; string anotherString = "Another"; if (testString.CompareTo(anotherString) == 0) {} if (testString.Equals(anotherString)) {} if (testString == anotherString) {} (Note: I am looking for equality in this example, not less than or greater than but feel free to comment on that as well)
Here are the rules for how these functions work: stringValue.CompareTo(otherStringValue) null comes before a string it uses CultureInfo.CurrentCulture.CompareInfo.Compare, which means it will use a culture-dependent comparison. This might mean that ß will compare equal to SS in Germany, or similar stringValue.Equals(otherStringValue) null is not considered equal to anything unless you specify a StringComparison option, it will use what looks like a direct ordinal equality check, i.e. ß is not the same as SS, in any language or culture stringValue == otherStringValue Is not the same as stringValue.Equals(). The == operator calls the static Equals(string a, string b) method (which in turn goes to an internal EqualsHelper to do the comparison. Calling.Equals() on a null string gets null reference exception, while on == does not. Object.ReferenceEquals(stringValue, otherStringValue) Just checks that references are the same, i.e. it isn't just two strings with the same contents, you're comparing a string object with itself. Note that with the options above that use method calls, there are overloads with more options to specify how to compare. My advice if you just want to check for equality is to make up your mind whether you want to use a culture-dependent comparison or not, and then use.CompareTo or.Equals, depending on the choice.
Differences in string compare methods in C# Comparing string in C# is pretty simple. In fact there are several ways to do it. I have listed some in the block below. What I am curious about are the differences between them and when one should be used over the others? Should one be avoided at all costs? Are there more I haven't listed? string testString = "Test"; string anotherString = "Another"; if (testString.CompareTo(anotherString) == 0) {} if (testString.Equals(anotherString)) {} if (testString == anotherString) {} (Note: I am looking for equality in this example, not less than or greater than but feel free to comment on that as well)
TITLE: Differences in string compare methods in C# QUESTION: Comparing string in C# is pretty simple. In fact there are several ways to do it. I have listed some in the block below. What I am curious about are the differences between them and when one should be used over the others? Should one be avoided at all costs? Are there more I haven't listed? string testString = "Test"; string anotherString = "Another"; if (testString.CompareTo(anotherString) == 0) {} if (testString.Equals(anotherString)) {} if (testString == anotherString) {} (Note: I am looking for equality in this example, not less than or greater than but feel free to comment on that as well) ANSWER: Here are the rules for how these functions work: stringValue.CompareTo(otherStringValue) null comes before a string it uses CultureInfo.CurrentCulture.CompareInfo.Compare, which means it will use a culture-dependent comparison. This might mean that ß will compare equal to SS in Germany, or similar stringValue.Equals(otherStringValue) null is not considered equal to anything unless you specify a StringComparison option, it will use what looks like a direct ordinal equality check, i.e. ß is not the same as SS, in any language or culture stringValue == otherStringValue Is not the same as stringValue.Equals(). The == operator calls the static Equals(string a, string b) method (which in turn goes to an internal EqualsHelper to do the comparison. Calling.Equals() on a null string gets null reference exception, while on == does not. Object.ReferenceEquals(stringValue, otherStringValue) Just checks that references are the same, i.e. it isn't just two strings with the same contents, you're comparing a string object with itself. Note that with the options above that use method calls, there are overloads with more options to specify how to compare. My advice if you just want to check for equality is to make up your mind whether you want to use a culture-dependent comparison or not, and then use.CompareTo or.Equals, depending on the choice.
[ "c#", "string", "comparison" ]
286
244
210,026
11
0
2008-09-04T17:44:10.440000
2008-09-04T18:17:00.097000
44,294
46,226
Enabled Brigded Network in Vmware Server
I have the vmware server with this error, anyone knows how to fix it? VMware Server Error http://soporte.cardinalsystems.com.ar/errorvmwareserver.jpg
In the Network Connections on the host PC, you might try repairing the connections that are created by VMWare. Something like "VMWare Network Adapter VMnet1" I'm assuming that the network connections (to a LAN/Internet) are working on the host computer. If not, I'd start by fixing the host first.
Enabled Brigded Network in Vmware Server I have the vmware server with this error, anyone knows how to fix it? VMware Server Error http://soporte.cardinalsystems.com.ar/errorvmwareserver.jpg
TITLE: Enabled Brigded Network in Vmware Server QUESTION: I have the vmware server with this error, anyone knows how to fix it? VMware Server Error http://soporte.cardinalsystems.com.ar/errorvmwareserver.jpg ANSWER: In the Network Connections on the host PC, you might try repairing the connections that are created by VMWare. Something like "VMWare Network Adapter VMnet1" I'm assuming that the network connections (to a LAN/Internet) are working on the host computer. If not, I'd start by fixing the host first.
[ "vmware", "virtualization", "vmware-server" ]
2
2
1,357
3
0
2008-09-04T17:45:59.577000
2008-09-05T16:25:24.457000
44,298
47,663
Strong Validation in WPF
I have a databound TextBox in my application like so: (The type of Height is decimal? ) public class NullableConverter: IValueConverter { public object Convert(object o, Type type, object parameter, CultureInfo culture) { return o; } public object ConvertBack(object o, Type type, object parameter, CultureInfo culture) { if (o as string == null || (o as string).Trim() == string.Empty) return null; return o; } } Configured this way, any non-empty strings which cannot be converted to decimal result in a validation error which will immediately highlight the textbox. However, the TextBox can still lose focus and remain in an invalid state. What I would like to do is either: Not allow the TextBox to lose focus until it contains a valid value. Revert the value in the TextBox to the last valid value. What is the best way to do this? Update: I've found a way to do #2. I don't love it, but it works: private void TextBox_LostKeyboardFocus(object sender, RoutedEventArgs e) { var box = sender as TextBox; var binding = box.GetBindingExpression(TextBox.TextProperty); if (binding.HasError) binding.UpdateTarget(); } Does anyone know how to do this better? (Or do #1.)
You can force the keyboard focus to stay on the TextBox by handling the PreviewLostKeyBoardFocus event like this: private void TextBox_PreviewLostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e) { e.Handled = true; }
Strong Validation in WPF I have a databound TextBox in my application like so: (The type of Height is decimal? ) public class NullableConverter: IValueConverter { public object Convert(object o, Type type, object parameter, CultureInfo culture) { return o; } public object ConvertBack(object o, Type type, object parameter, CultureInfo culture) { if (o as string == null || (o as string).Trim() == string.Empty) return null; return o; } } Configured this way, any non-empty strings which cannot be converted to decimal result in a validation error which will immediately highlight the textbox. However, the TextBox can still lose focus and remain in an invalid state. What I would like to do is either: Not allow the TextBox to lose focus until it contains a valid value. Revert the value in the TextBox to the last valid value. What is the best way to do this? Update: I've found a way to do #2. I don't love it, but it works: private void TextBox_LostKeyboardFocus(object sender, RoutedEventArgs e) { var box = sender as TextBox; var binding = box.GetBindingExpression(TextBox.TextProperty); if (binding.HasError) binding.UpdateTarget(); } Does anyone know how to do this better? (Or do #1.)
TITLE: Strong Validation in WPF QUESTION: I have a databound TextBox in my application like so: (The type of Height is decimal? ) public class NullableConverter: IValueConverter { public object Convert(object o, Type type, object parameter, CultureInfo culture) { return o; } public object ConvertBack(object o, Type type, object parameter, CultureInfo culture) { if (o as string == null || (o as string).Trim() == string.Empty) return null; return o; } } Configured this way, any non-empty strings which cannot be converted to decimal result in a validation error which will immediately highlight the textbox. However, the TextBox can still lose focus and remain in an invalid state. What I would like to do is either: Not allow the TextBox to lose focus until it contains a valid value. Revert the value in the TextBox to the last valid value. What is the best way to do this? Update: I've found a way to do #2. I don't love it, but it works: private void TextBox_LostKeyboardFocus(object sender, RoutedEventArgs e) { var box = sender as TextBox; var binding = box.GetBindingExpression(TextBox.TextProperty); if (binding.HasError) binding.UpdateTarget(); } Does anyone know how to do this better? (Or do #1.) ANSWER: You can force the keyboard focus to stay on the TextBox by handling the PreviewLostKeyBoardFocus event like this: private void TextBox_PreviewLostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e) { e.Handled = true; }
[ "wpf", "validation", "data-binding" ]
1
2
2,734
2
0
2008-09-04T17:47:48.700000
2008-09-06T17:00:44.037000
44,337
44,579
preferred way to implement visitor pattern in dynamic languages?
As an exercise for myself, I was translating a sample program into various languages. Starting in C#, I had a visitor-pattern interface like so: interface Visitor { void Accept(Bedroom x); void Accept(Bathroom x); void Accept(Kitchen x); void Accept(LivingRoom x); } Moving to ruby (or python, or whatever), I no longer get dispatch from the compiler based on type. Should I do the dispatch in the visitor itself? class Cleaner def accept(x) acceptBedroom(x) if Bedroom === x acceptBathroom(x) if Bathroom === x acceptKitchen(x) if Kitchen===x acceptLivingRoom(x) if LivingRoom===x end... Or should I do the dispatch in the different specializaions of the room: class Bathroom Or is there another preferred idiom that is used in dynamic languages?
My recommendation is to use the former approach. There are pluses and minuses for each approach. The former is harder to maintain as the number of Room types grows; the latter is harder as the number of Cleaner types grows. In Ruby, you could try def accept(x) send "accept#{x.class}".to_sym, x end PS: not all dynamically typed languages are unable to do dispatch based on type; some can infer type, or failing that, can used forced casting to pick the proper method among the overloaded options.
preferred way to implement visitor pattern in dynamic languages? As an exercise for myself, I was translating a sample program into various languages. Starting in C#, I had a visitor-pattern interface like so: interface Visitor { void Accept(Bedroom x); void Accept(Bathroom x); void Accept(Kitchen x); void Accept(LivingRoom x); } Moving to ruby (or python, or whatever), I no longer get dispatch from the compiler based on type. Should I do the dispatch in the visitor itself? class Cleaner def accept(x) acceptBedroom(x) if Bedroom === x acceptBathroom(x) if Bathroom === x acceptKitchen(x) if Kitchen===x acceptLivingRoom(x) if LivingRoom===x end... Or should I do the dispatch in the different specializaions of the room: class Bathroom Or is there another preferred idiom that is used in dynamic languages?
TITLE: preferred way to implement visitor pattern in dynamic languages? QUESTION: As an exercise for myself, I was translating a sample program into various languages. Starting in C#, I had a visitor-pattern interface like so: interface Visitor { void Accept(Bedroom x); void Accept(Bathroom x); void Accept(Kitchen x); void Accept(LivingRoom x); } Moving to ruby (or python, or whatever), I no longer get dispatch from the compiler based on type. Should I do the dispatch in the visitor itself? class Cleaner def accept(x) acceptBedroom(x) if Bedroom === x acceptBathroom(x) if Bathroom === x acceptKitchen(x) if Kitchen===x acceptLivingRoom(x) if LivingRoom===x end... Or should I do the dispatch in the different specializaions of the room: class Bathroom Or is there another preferred idiom that is used in dynamic languages? ANSWER: My recommendation is to use the former approach. There are pluses and minuses for each approach. The former is harder to maintain as the number of Room types grows; the latter is harder as the number of Cleaner types grows. In Ruby, you could try def accept(x) send "accept#{x.class}".to_sym, x end PS: not all dynamically typed languages are unable to do dispatch based on type; some can infer type, or failing that, can used forced casting to pick the proper method among the overloaded options.
[ "c#", "ruby", "design-patterns", "dynamic-languages" ]
3
3
908
2
0
2008-09-04T17:59:52.073000
2008-09-04T19:31:52.880000
44,338
44,525
Unit testing with network-reliant code
I'm trying to be better about unit testing my code, but right now I'm writing a lot of code that deals with remote systems. SNMP, WMI, that sort of thing. With most classes I can mock up objects to test them, but how do you deal with unit testing a real system? For example, if my class goes out and gets the Win32_LogicalDisk object for a server, how could I possibly unit test it?
Assuming you meant "How do I test against things that are hard/impossible to mock": If you have a class that "goes out and gets the Win32_LogicalDisk object for a server" AND does something else (consumes the 'Win32_LogicalDisk' object in some way), assuming you want to test the pieces of the class that consume this object, you can use Dependency Injection to allow you to mock the 'Win32_LogicalDisk' object. For instance: class LogicalDiskConsumer(object): def __init__(self, arg1, arg2, LogicalDiskFactory) self.arg1=arg1 self.arg2=arg2 self.LogicalDisk=LogicalDiskFactory() def consumedisk(self): self.LogicalDisk.someaction() Then in your unit test code, pass in a 'LogicalDiskFactory' that returns a mock object for the 'Win32_LogicalDisk'.
Unit testing with network-reliant code I'm trying to be better about unit testing my code, but right now I'm writing a lot of code that deals with remote systems. SNMP, WMI, that sort of thing. With most classes I can mock up objects to test them, but how do you deal with unit testing a real system? For example, if my class goes out and gets the Win32_LogicalDisk object for a server, how could I possibly unit test it?
TITLE: Unit testing with network-reliant code QUESTION: I'm trying to be better about unit testing my code, but right now I'm writing a lot of code that deals with remote systems. SNMP, WMI, that sort of thing. With most classes I can mock up objects to test them, but how do you deal with unit testing a real system? For example, if my class goes out and gets the Win32_LogicalDisk object for a server, how could I possibly unit test it? ANSWER: Assuming you meant "How do I test against things that are hard/impossible to mock": If you have a class that "goes out and gets the Win32_LogicalDisk object for a server" AND does something else (consumes the 'Win32_LogicalDisk' object in some way), assuming you want to test the pieces of the class that consume this object, you can use Dependency Injection to allow you to mock the 'Win32_LogicalDisk' object. For instance: class LogicalDiskConsumer(object): def __init__(self, arg1, arg2, LogicalDiskFactory) self.arg1=arg1 self.arg2=arg2 self.LogicalDisk=LogicalDiskFactory() def consumedisk(self): self.LogicalDisk.someaction() Then in your unit test code, pass in a 'LogicalDiskFactory' that returns a mock object for the 'Win32_LogicalDisk'.
[ "unit-testing", "testing", "wmi" ]
10
6
4,094
3
0
2008-09-04T18:00:02.040000
2008-09-04T19:12:21.837000
44,350
44,361
What are the best keyboard macros for programming in windows?
I like putting shortcuts of the form "g - google.lnk" in my start menu so google is two keystrokes away. Win, g. My eight or so most frequent applications go there. I also make links to my solution files I am always opening "x - Popular Project.lnk" Are there any better ways to automate opening frequently used applications?
AutoHotkey is a reasonably good program for implementing windows key shortcuts. You might instead define WIN + G to be "open browser to google" which gives you a better response time (don't have to wait for start menu to popup, etc) There are macro programs that change the macros used based on the window that's in focus. I've never needed that much control, but you might want to look into that. -Adam
What are the best keyboard macros for programming in windows? I like putting shortcuts of the form "g - google.lnk" in my start menu so google is two keystrokes away. Win, g. My eight or so most frequent applications go there. I also make links to my solution files I am always opening "x - Popular Project.lnk" Are there any better ways to automate opening frequently used applications?
TITLE: What are the best keyboard macros for programming in windows? QUESTION: I like putting shortcuts of the form "g - google.lnk" in my start menu so google is two keystrokes away. Win, g. My eight or so most frequent applications go there. I also make links to my solution files I am always opening "x - Popular Project.lnk" Are there any better ways to automate opening frequently used applications? ANSWER: AutoHotkey is a reasonably good program for implementing windows key shortcuts. You might instead define WIN + G to be "open browser to google" which gives you a better response time (don't have to wait for start menu to popup, etc) There are macro programs that change the macros used based on the window that's in focus. I've never needed that much control, but you might want to look into that. -Adam
[ "keyboard", "macros", "performance" ]
3
3
10,377
6
0
2008-09-04T18:04:01.017000
2008-09-04T18:09:30.863000
44,352
44,381
Iterate over subclasses of a given class in a given module
In Python, given a module X and a class Y, how can I iterate or generate a list of all subclasses of Y that exist in module X?
Here's one way to do it: import inspect def get_subclasses(mod, cls): """Yield the classes in module ``mod`` that inherit from ``cls``""" for name, obj in inspect.getmembers(mod): if hasattr(obj, "__bases__") and cls in obj.__bases__: yield obj
Iterate over subclasses of a given class in a given module In Python, given a module X and a class Y, how can I iterate or generate a list of all subclasses of Y that exist in module X?
TITLE: Iterate over subclasses of a given class in a given module QUESTION: In Python, given a module X and a class Y, how can I iterate or generate a list of all subclasses of Y that exist in module X? ANSWER: Here's one way to do it: import inspect def get_subclasses(mod, cls): """Yield the classes in module ``mod`` that inherit from ``cls``""" for name, obj in inspect.getmembers(mod): if hasattr(obj, "__bases__") and cls in obj.__bases__: yield obj
[ "python", "oop" ]
19
15
12,725
4
0
2008-09-04T18:05:23.337000
2008-09-04T18:20:21.087000
44,364
44,375
How can I avoid global state?
So, I was reading the Google testing blog, and it says that global state is bad and makes it hard to write tests. I believe it--my code is difficult to test right now. So how do I avoid global state? The biggest things I use global state (as I understand it) for is managing key pieces of information between our development, acceptance, and production environments. For example, I have a static class named "Globals" with a static member called "DBConnectionString." When the application loads, it determines which connection string to load, and populates Globals.DBConnectionString. I load file paths, server names, and other information in the Globals class. Some of my functions rely on the global variables. So, when I test my functions, I have to remember to set certain globals first or else the tests will fail. I'd like to avoid this. Is there a good way to manage state information? (Or am I understanding global state incorrectly?)
Dependency injection is what you're looking for. Rather than have those functions go out and look for their dependencies, inject the dependencies into the functions. That is, when you call the functions pass the data they want to them. That way it's easy to put a testing framework around a class because you can simply inject mock objects where appropriate. It's hard to avoid some global state, but the best way to do this is to use factory classes at the highest level of your application, and everything below that very top level is based on dependency injection. Two main benefits: one, testing is a heck of a lot easier, and two, your application is much more loosely coupled. You rely on being able to program against the interface of a class rather than its implementation.
How can I avoid global state? So, I was reading the Google testing blog, and it says that global state is bad and makes it hard to write tests. I believe it--my code is difficult to test right now. So how do I avoid global state? The biggest things I use global state (as I understand it) for is managing key pieces of information between our development, acceptance, and production environments. For example, I have a static class named "Globals" with a static member called "DBConnectionString." When the application loads, it determines which connection string to load, and populates Globals.DBConnectionString. I load file paths, server names, and other information in the Globals class. Some of my functions rely on the global variables. So, when I test my functions, I have to remember to set certain globals first or else the tests will fail. I'd like to avoid this. Is there a good way to manage state information? (Or am I understanding global state incorrectly?)
TITLE: How can I avoid global state? QUESTION: So, I was reading the Google testing blog, and it says that global state is bad and makes it hard to write tests. I believe it--my code is difficult to test right now. So how do I avoid global state? The biggest things I use global state (as I understand it) for is managing key pieces of information between our development, acceptance, and production environments. For example, I have a static class named "Globals" with a static member called "DBConnectionString." When the application loads, it determines which connection string to load, and populates Globals.DBConnectionString. I load file paths, server names, and other information in the Globals class. Some of my functions rely on the global variables. So, when I test my functions, I have to remember to set certain globals first or else the tests will fail. I'd like to avoid this. Is there a good way to manage state information? (Or am I understanding global state incorrectly?) ANSWER: Dependency injection is what you're looking for. Rather than have those functions go out and look for their dependencies, inject the dependencies into the functions. That is, when you call the functions pass the data they want to them. That way it's easy to put a testing framework around a class because you can simply inject mock objects where appropriate. It's hard to avoid some global state, but the best way to do this is to use factory classes at the highest level of your application, and everything below that very top level is based on dependency injection. Two main benefits: one, testing is a heck of a lot easier, and two, your application is much more loosely coupled. You rely on being able to program against the interface of a class rather than its implementation.
[ "testing", "state", "global", "global-state" ]
10
12
2,600
4
0
2008-09-04T18:11:29.250000
2008-09-04T18:18:03.150000
44,372
44,434
BLOB Storage - 100+ GB, MySQL, SQLite, or PostgreSQL + Python
I have an idea for a simple application which will monitor a group of folders, index any files it finds. A gui will allow me quickly tag new files and move them into a single database for storage and also provide an easy mechanism for querying the db by tag, name, file type and date. At the moment I have about 100+ GB of files on a couple removable hard drives, the database will be at least that big. If possible I would like to support full text search of the embedded binary and text documents. This will be a single user application. Not trying to start a DB war, but what open source DB is going to work best for me? I am pretty sure SQLLite is off the table but I could be wrong.
I'm still researching this option for one of my own projects, but CouchDB may be worth a look.
BLOB Storage - 100+ GB, MySQL, SQLite, or PostgreSQL + Python I have an idea for a simple application which will monitor a group of folders, index any files it finds. A gui will allow me quickly tag new files and move them into a single database for storage and also provide an easy mechanism for querying the db by tag, name, file type and date. At the moment I have about 100+ GB of files on a couple removable hard drives, the database will be at least that big. If possible I would like to support full text search of the embedded binary and text documents. This will be a single user application. Not trying to start a DB war, but what open source DB is going to work best for me? I am pretty sure SQLLite is off the table but I could be wrong.
TITLE: BLOB Storage - 100+ GB, MySQL, SQLite, or PostgreSQL + Python QUESTION: I have an idea for a simple application which will monitor a group of folders, index any files it finds. A gui will allow me quickly tag new files and move them into a single database for storage and also provide an easy mechanism for querying the db by tag, name, file type and date. At the moment I have about 100+ GB of files on a couple removable hard drives, the database will be at least that big. If possible I would like to support full text search of the embedded binary and text documents. This will be a single user application. Not trying to start a DB war, but what open source DB is going to work best for me? I am pretty sure SQLLite is off the table but I could be wrong. ANSWER: I'm still researching this option for one of my own projects, but CouchDB may be worth a look.
[ "database", "blob" ]
1
2
2,645
6
0
2008-09-04T18:14:43.503000
2008-09-04T18:38:41.107000
44,376
44,378
Add alternating row color to SQL Server Reporting services report
How do you shade alternating rows in a SQL Server Reporting Services report? Edit: There are a bunch of good answers listed below--from quick and simple to complex and comprehensive. Alas, I can choose only one...
Go to the table row's BackgroundColor property and choose "Expression..." Use this expression: = IIf(RowNumber(Nothing) Mod 2 = 0, "Silver", "Transparent") This trick can be applied to many areas of the report. And in.NET 3.5+ You could use: = If(RowNumber(Nothing) Mod 2 = 0, "Silver", "Transparent") Not looking for rep--I just researched this question myself and thought I'd share.
Add alternating row color to SQL Server Reporting services report How do you shade alternating rows in a SQL Server Reporting Services report? Edit: There are a bunch of good answers listed below--from quick and simple to complex and comprehensive. Alas, I can choose only one...
TITLE: Add alternating row color to SQL Server Reporting services report QUESTION: How do you shade alternating rows in a SQL Server Reporting Services report? Edit: There are a bunch of good answers listed below--from quick and simple to complex and comprehensive. Alas, I can choose only one... ANSWER: Go to the table row's BackgroundColor property and choose "Expression..." Use this expression: = IIf(RowNumber(Nothing) Mod 2 = 0, "Silver", "Transparent") This trick can be applied to many areas of the report. And in.NET 3.5+ You could use: = If(RowNumber(Nothing) Mod 2 = 0, "Silver", "Transparent") Not looking for rep--I just researched this question myself and thought I'd share.
[ "sql-server", "reporting-services", "formatting" ]
150
221
290,201
18
0
2008-09-04T18:18:32.947000
2008-09-04T18:19:32.850000
44,383
44,393
Reading Email using Pop3 in C#
I am looking for a method of reading emails using Pop3 in C# 2.0. Currently, I am using code found in CodeProject. However, this solution is less than ideal. The biggest problem is that it doesn't support emails written in unicode.
I've successfully used OpenPop.NET to access emails via POP3.
Reading Email using Pop3 in C# I am looking for a method of reading emails using Pop3 in C# 2.0. Currently, I am using code found in CodeProject. However, this solution is less than ideal. The biggest problem is that it doesn't support emails written in unicode.
TITLE: Reading Email using Pop3 in C# QUESTION: I am looking for a method of reading emails using Pop3 in C# 2.0. Currently, I am using code found in CodeProject. However, this solution is less than ideal. The biggest problem is that it doesn't support emails written in unicode. ANSWER: I've successfully used OpenPop.NET to access emails via POP3.
[ "c#", "unicode", "pop3" ]
75
74
142,101
8
0
2008-09-04T18:21:06.653000
2008-09-04T18:24:34.477000
44,391
65,953
How do I prevent replay attacks?
This is related to another question I asked. In summary, I have a special case of a URL where, when a form is POSTed to it, I can't rely on cookies for authentication or to maintain the user's session, but I somehow need to know who they are, and I need to know they're logged in! I think I came up with a solution to my problem, but it needs fleshing out. Here's what I'm thinking. I create a hidden form field called "username", and place within it the user's username, encrypted. Then, when the form POSTs, even though I don't receive any cookies from the browser, I know they're logged in because I can decrypt the hidden form field and get the username. The major security flaw I can see is replay attacks. How do I prevent someone from getting ahold of that encrypted string, and POSTing as that user? I know I can use SSL to make it harder to steal that string, and maybe I can rotate the encryption key on a regular basis to limit the amount of time that the string is good for, but I'd really like to find a bulletproof solution. Anybody have any ideas? Does the ASP.Net ViewState prevent replay? If so, how do they do it? Edit: I'm hoping for a solution that doesn't require anything stored in a database. Application state would be okay, except that it won't survive an IIS restart or work at all in a web farm or garden scenario. I'm accepting Chris's answer, for now, because I'm not convinced it's even possible to secure this without a database. But if someone comes up with an answer that does not involve the database, I'll accept it!
If you hash in a time-stamp along with the user name and password, you can close the window for replay attacks to within a couple of seconds. I don't know if this meets your needs, but it is at least a partial solution.
How do I prevent replay attacks? This is related to another question I asked. In summary, I have a special case of a URL where, when a form is POSTed to it, I can't rely on cookies for authentication or to maintain the user's session, but I somehow need to know who they are, and I need to know they're logged in! I think I came up with a solution to my problem, but it needs fleshing out. Here's what I'm thinking. I create a hidden form field called "username", and place within it the user's username, encrypted. Then, when the form POSTs, even though I don't receive any cookies from the browser, I know they're logged in because I can decrypt the hidden form field and get the username. The major security flaw I can see is replay attacks. How do I prevent someone from getting ahold of that encrypted string, and POSTing as that user? I know I can use SSL to make it harder to steal that string, and maybe I can rotate the encryption key on a regular basis to limit the amount of time that the string is good for, but I'd really like to find a bulletproof solution. Anybody have any ideas? Does the ASP.Net ViewState prevent replay? If so, how do they do it? Edit: I'm hoping for a solution that doesn't require anything stored in a database. Application state would be okay, except that it won't survive an IIS restart or work at all in a web farm or garden scenario. I'm accepting Chris's answer, for now, because I'm not convinced it's even possible to secure this without a database. But if someone comes up with an answer that does not involve the database, I'll accept it!
TITLE: How do I prevent replay attacks? QUESTION: This is related to another question I asked. In summary, I have a special case of a URL where, when a form is POSTed to it, I can't rely on cookies for authentication or to maintain the user's session, but I somehow need to know who they are, and I need to know they're logged in! I think I came up with a solution to my problem, but it needs fleshing out. Here's what I'm thinking. I create a hidden form field called "username", and place within it the user's username, encrypted. Then, when the form POSTs, even though I don't receive any cookies from the browser, I know they're logged in because I can decrypt the hidden form field and get the username. The major security flaw I can see is replay attacks. How do I prevent someone from getting ahold of that encrypted string, and POSTing as that user? I know I can use SSL to make it harder to steal that string, and maybe I can rotate the encryption key on a regular basis to limit the amount of time that the string is good for, but I'd really like to find a bulletproof solution. Anybody have any ideas? Does the ASP.Net ViewState prevent replay? If so, how do they do it? Edit: I'm hoping for a solution that doesn't require anything stored in a database. Application state would be okay, except that it won't survive an IIS restart or work at all in a web farm or garden scenario. I'm accepting Chris's answer, for now, because I'm not convinced it's even possible to secure this without a database. But if someone comes up with an answer that does not involve the database, I'll accept it! ANSWER: If you hash in a time-stamp along with the user name and password, you can close the window for replay attacks to within a couple of seconds. I don't know if this meets your needs, but it is at least a partial solution.
[ "asp.net", "security", "encryption" ]
18
15
39,002
12
0
2008-09-04T18:23:22.093000
2008-09-15T19:27:12.720000
44,396
142,968
How to reference javadocs to dependencies in Maven's eclipse plugin when javadoc not attached to dependency
I use Eclipse, Maven, and Java in my development. I use Maven to download dependencies (jar files and javadoc when available) and Maven's eclipse plug-in to generate the.project and.classpath files for Eclipse. When the dependency downloaded does not have attached javadoc I manually add a link for the javadoc in the.classpath file so that I can see the javadoc for the dependency in Eclipse. Then when I run Maven's eclipse plugin to regenerate the.classpath file it of course wipes out that change. Is there a way to configure Maven's eclipse plug-in to automatically add classpath attributes for javadoc when running Maven's eclipse plug-in? I'm only interested in answers where the javadoc and/or sources are not provided for the dependency in the maven repository, which is the case most often for me. Using downloadSources and/or downloadJavadocs properties won't help this problem.
You might consider just avoiding this problem completely by installing the javadoc jar into your local repository manually using the install-file goal and passing in the -Dclassifier=javadoc option. Once you do that the.classpath that mvn generates should be correct. If you use a remote repo as a proxy to central you could also deploy the javadocs to that repo and then everyone else who uses that proxy will now get the javadocs automatically as well.
How to reference javadocs to dependencies in Maven's eclipse plugin when javadoc not attached to dependency I use Eclipse, Maven, and Java in my development. I use Maven to download dependencies (jar files and javadoc when available) and Maven's eclipse plug-in to generate the.project and.classpath files for Eclipse. When the dependency downloaded does not have attached javadoc I manually add a link for the javadoc in the.classpath file so that I can see the javadoc for the dependency in Eclipse. Then when I run Maven's eclipse plugin to regenerate the.classpath file it of course wipes out that change. Is there a way to configure Maven's eclipse plug-in to automatically add classpath attributes for javadoc when running Maven's eclipse plug-in? I'm only interested in answers where the javadoc and/or sources are not provided for the dependency in the maven repository, which is the case most often for me. Using downloadSources and/or downloadJavadocs properties won't help this problem.
TITLE: How to reference javadocs to dependencies in Maven's eclipse plugin when javadoc not attached to dependency QUESTION: I use Eclipse, Maven, and Java in my development. I use Maven to download dependencies (jar files and javadoc when available) and Maven's eclipse plug-in to generate the.project and.classpath files for Eclipse. When the dependency downloaded does not have attached javadoc I manually add a link for the javadoc in the.classpath file so that I can see the javadoc for the dependency in Eclipse. Then when I run Maven's eclipse plugin to regenerate the.classpath file it of course wipes out that change. Is there a way to configure Maven's eclipse plug-in to automatically add classpath attributes for javadoc when running Maven's eclipse plug-in? I'm only interested in answers where the javadoc and/or sources are not provided for the dependency in the maven repository, which is the case most often for me. Using downloadSources and/or downloadJavadocs properties won't help this problem. ANSWER: You might consider just avoiding this problem completely by installing the javadoc jar into your local repository manually using the install-file goal and passing in the -Dclassifier=javadoc option. Once you do that the.classpath that mvn generates should be correct. If you use a remote repo as a proxy to central you could also deploy the javadocs to that repo and then everyone else who uses that proxy will now get the javadocs automatically as well.
[ "java", "eclipse", "maven-2" ]
54
17
48,934
6
0
2008-09-04T18:25:44.537000
2008-09-27T04:15:29.997000
44,401
44,468
catching button clicks in javascript without server interaction
I've got a sign up form that requires the user to enter their email and password, both are in two separate text boxes. I want to provide a button that the user can click so that the password (which is masked) will appear in a popup when the user clicks the button. Currently my JavaScript code for this is as follows: function toggleShowPassword() { var button = $get('PASSWORD_TEXTBOX_ID'); var password; if (button) { password = button.value; alert(password); button.value = password; } } The problem is that every time the user clicks the button, the password is cleared in both Firefox and IE. I want them to be able to see their password in clear text to verify without having to retype their password. My questions are: Why does the password field keep getting reset with each button click? How can I make it so the password field is NOT cleared once the user has seen his/her password in clear text?
I did a quick example up of a working version: The key is that the input is of type button and not submit. I used the prototype library for retrieving the element by ID.
catching button clicks in javascript without server interaction I've got a sign up form that requires the user to enter their email and password, both are in two separate text boxes. I want to provide a button that the user can click so that the password (which is masked) will appear in a popup when the user clicks the button. Currently my JavaScript code for this is as follows: function toggleShowPassword() { var button = $get('PASSWORD_TEXTBOX_ID'); var password; if (button) { password = button.value; alert(password); button.value = password; } } The problem is that every time the user clicks the button, the password is cleared in both Firefox and IE. I want them to be able to see their password in clear text to verify without having to retype their password. My questions are: Why does the password field keep getting reset with each button click? How can I make it so the password field is NOT cleared once the user has seen his/her password in clear text?
TITLE: catching button clicks in javascript without server interaction QUESTION: I've got a sign up form that requires the user to enter their email and password, both are in two separate text boxes. I want to provide a button that the user can click so that the password (which is masked) will appear in a popup when the user clicks the button. Currently my JavaScript code for this is as follows: function toggleShowPassword() { var button = $get('PASSWORD_TEXTBOX_ID'); var password; if (button) { password = button.value; alert(password); button.value = password; } } The problem is that every time the user clicks the button, the password is cleared in both Firefox and IE. I want them to be able to see their password in clear text to verify without having to retype their password. My questions are: Why does the password field keep getting reset with each button click? How can I make it so the password field is NOT cleared once the user has seen his/her password in clear text? ANSWER: I did a quick example up of a working version: The key is that the input is of type button and not submit. I used the prototype library for retrieving the element by ID.
[ "javascript", "ajax" ]
1
1
753
8
0
2008-09-04T18:28:39.990000
2008-09-04T18:53:55.670000
44,408
44,461
How do you generate a random number in C#?
I would like to generate a random floating point number between 2 values. What is the best way to do this in C#?
The only thing I'd add to Eric 's response is an explanation; I feel that knowledge of why code works is better than knowing what code works. The explanation is this: let's say you want a number between 2.5 and 4.5. The range is 2.0 (4.5 - 2.5). NextDouble only returns a number between 0 and 1.0, but if you multiply this by the range you will get a number between 0 and range. So, this would give us random doubles between 0.0 and 2.0: rng.NextDouble() * 2.0 But, we want them between 2.5 and 4.5! How do we do this? Add the smallest number, 2.5: 2.5 + rng.NextDouble() * 2.0 Now, we get a number between 0.0 and 2.0; if you add 2.5 to each of these values we see that the range is now between 2.5 and 4.5. At first I thought that it mattered if b > a or a > b, but if you work it out both ways you'll find it works out identically so long as you don't mess up the order of the variables used. I like to express it with longer variable names so I don't get mixed up: double NextDouble(Random rng, double min, double max) { return min + (rng.NextDouble() * (max - min)); }
How do you generate a random number in C#? I would like to generate a random floating point number between 2 values. What is the best way to do this in C#?
TITLE: How do you generate a random number in C#? QUESTION: I would like to generate a random floating point number between 2 values. What is the best way to do this in C#? ANSWER: The only thing I'd add to Eric 's response is an explanation; I feel that knowledge of why code works is better than knowing what code works. The explanation is this: let's say you want a number between 2.5 and 4.5. The range is 2.0 (4.5 - 2.5). NextDouble only returns a number between 0 and 1.0, but if you multiply this by the range you will get a number between 0 and range. So, this would give us random doubles between 0.0 and 2.0: rng.NextDouble() * 2.0 But, we want them between 2.5 and 4.5! How do we do this? Add the smallest number, 2.5: 2.5 + rng.NextDouble() * 2.0 Now, we get a number between 0.0 and 2.0; if you add 2.5 to each of these values we see that the range is now between 2.5 and 4.5. At first I thought that it mattered if b > a or a > b, but if you work it out both ways you'll find it works out identically so long as you don't mess up the order of the variables used. I like to express it with longer variable names so I don't get mixed up: double NextDouble(Random rng, double min, double max) { return min + (rng.NextDouble() * (max - min)); }
[ "c#", "floating-point", "random" ]
33
60
42,215
6
0
2008-09-04T18:30:57.567000
2008-09-04T18:52:22.103000
44,421
44,433
Outlook Email via a Webpage
I have a web application developed with ASP.net and C# that is running on my companies' intranet. Because all the users for this application are all using Microsoft Outlook without exception, I would like for the the application to open up an Outlook message on the client-side. I understand that Office is designed to be run on the desktop and not from a server, however I have no trouble creating a Word or Excel document on the client-side. I have code that instantiates the Outlook object using the Microsoft.Office.Interop.Outlook namespace and Outlook installed on the server. When I try to run the code from the server, I get a DCOM source error message that states "The machine-default permission settings do not grant Local Activation permission for the COM Server application with CLSID {000C101C-0000-0000-C000-000000000046} to the user This security permission can be modified using the Component Services administrative tool." I have modified the permissions using the Component Services tool, but still get this same error. Is there a way to overcome this or is this a fruitless exercise because Outlook cannot be opened on the client side from the server-side code? Mailto will not work due to the extreme length that the emails can obtain. Also, the user that sends it needs add in eye-candy to the text for the recipients.
You cannot open something on the client from server side code. You'd have to use script on the page to do what you're wanting (or something else client-side like ActiveX or embedded.NET or something) Here's a sample Javascript that invokes an Outlook MailItem from an webpage. This could easily be injected into the page from your server-side code so it executes on the client. http://www.codeproject.com/KB/aspnet/EmailUsingJavascript.aspx
Outlook Email via a Webpage I have a web application developed with ASP.net and C# that is running on my companies' intranet. Because all the users for this application are all using Microsoft Outlook without exception, I would like for the the application to open up an Outlook message on the client-side. I understand that Office is designed to be run on the desktop and not from a server, however I have no trouble creating a Word or Excel document on the client-side. I have code that instantiates the Outlook object using the Microsoft.Office.Interop.Outlook namespace and Outlook installed on the server. When I try to run the code from the server, I get a DCOM source error message that states "The machine-default permission settings do not grant Local Activation permission for the COM Server application with CLSID {000C101C-0000-0000-C000-000000000046} to the user This security permission can be modified using the Component Services administrative tool." I have modified the permissions using the Component Services tool, but still get this same error. Is there a way to overcome this or is this a fruitless exercise because Outlook cannot be opened on the client side from the server-side code? Mailto will not work due to the extreme length that the emails can obtain. Also, the user that sends it needs add in eye-candy to the text for the recipients.
TITLE: Outlook Email via a Webpage QUESTION: I have a web application developed with ASP.net and C# that is running on my companies' intranet. Because all the users for this application are all using Microsoft Outlook without exception, I would like for the the application to open up an Outlook message on the client-side. I understand that Office is designed to be run on the desktop and not from a server, however I have no trouble creating a Word or Excel document on the client-side. I have code that instantiates the Outlook object using the Microsoft.Office.Interop.Outlook namespace and Outlook installed on the server. When I try to run the code from the server, I get a DCOM source error message that states "The machine-default permission settings do not grant Local Activation permission for the COM Server application with CLSID {000C101C-0000-0000-C000-000000000046} to the user This security permission can be modified using the Component Services administrative tool." I have modified the permissions using the Component Services tool, but still get this same error. Is there a way to overcome this or is this a fruitless exercise because Outlook cannot be opened on the client side from the server-side code? Mailto will not work due to the extreme length that the emails can obtain. Also, the user that sends it needs add in eye-candy to the text for the recipients. ANSWER: You cannot open something on the client from server side code. You'd have to use script on the page to do what you're wanting (or something else client-side like ActiveX or embedded.NET or something) Here's a sample Javascript that invokes an Outlook MailItem from an webpage. This could easily be injected into the page from your server-side code so it executes on the client. http://www.codeproject.com/KB/aspnet/EmailUsingJavascript.aspx
[ "c#", "asp.net", "outlook", "ms-office" ]
3
6
5,697
5
0
2008-09-04T18:34:16.060000
2008-09-04T18:38:23.930000
44,467
44,968
What can cause .NET assembly registration to fail?
We've seen an issue where one of our installers (msi) returns the error code 2908, which is used to indicate that an assembly failed to register. Later in the installation, we get the following (sanitized) error: MyAssemblyName, version="1.0.1.1", culture="neutral", publicKeyToken="119EFC79848A50". Please refer to Help and Support for more information. HRESULT: 0x8002802F. The assembly registers properly on most systems. Has anyone else encountered this issue? How did you solve it?
I found a pair of blog postings that appear to cover this topic.
What can cause .NET assembly registration to fail? We've seen an issue where one of our installers (msi) returns the error code 2908, which is used to indicate that an assembly failed to register. Later in the installation, we get the following (sanitized) error: MyAssemblyName, version="1.0.1.1", culture="neutral", publicKeyToken="119EFC79848A50". Please refer to Help and Support for more information. HRESULT: 0x8002802F. The assembly registers properly on most systems. Has anyone else encountered this issue? How did you solve it?
TITLE: What can cause .NET assembly registration to fail? QUESTION: We've seen an issue where one of our installers (msi) returns the error code 2908, which is used to indicate that an assembly failed to register. Later in the installation, we get the following (sanitized) error: MyAssemblyName, version="1.0.1.1", culture="neutral", publicKeyToken="119EFC79848A50". Please refer to Help and Support for more information. HRESULT: 0x8002802F. The assembly registers properly on most systems. Has anyone else encountered this issue? How did you solve it? ANSWER: I found a pair of blog postings that appear to cover this topic.
[ ".net", "windows", "windows-installer" ]
0
1
1,031
1
0
2008-09-04T18:53:00.570000
2008-09-04T23:26:59.993000
44,469
44,482
What's the best way to insert/update/delete multiple records in a database from an application?
Given a small set of entities (say, 10 or fewer) to insert, delete, or update in an application, what is the best way to perform the necessary database operations? Should multiple queries be issued, one for each entity to be affected? Or should some sort of XML construct that can be parsed by the database engine be used, so that only one command needs to be issued? I ask this because a common pattern at my current shop seems to be to format up an XML document containing all the changes, then send that string to the database to be processed by the database engine's XML functionality. However, using XML in this way seems rather cumbersome given the simple nature of the task to be performed.
It depends on how many you need to do, and how fast the operations need to run. If it's only a few, then doing them one at a time with whatever mechanism you have for doing single operations will work fine. If you need to do thousands or more, and it needs to run quickly, you should re-use the connection and command, changing the arguments for the parameters to the query during each iteration. This will minimize resource usage. You don't want to re-create the connection and command for each operation.
What's the best way to insert/update/delete multiple records in a database from an application? Given a small set of entities (say, 10 or fewer) to insert, delete, or update in an application, what is the best way to perform the necessary database operations? Should multiple queries be issued, one for each entity to be affected? Or should some sort of XML construct that can be parsed by the database engine be used, so that only one command needs to be issued? I ask this because a common pattern at my current shop seems to be to format up an XML document containing all the changes, then send that string to the database to be processed by the database engine's XML functionality. However, using XML in this way seems rather cumbersome given the simple nature of the task to be performed.
TITLE: What's the best way to insert/update/delete multiple records in a database from an application? QUESTION: Given a small set of entities (say, 10 or fewer) to insert, delete, or update in an application, what is the best way to perform the necessary database operations? Should multiple queries be issued, one for each entity to be affected? Or should some sort of XML construct that can be parsed by the database engine be used, so that only one command needs to be issued? I ask this because a common pattern at my current shop seems to be to format up an XML document containing all the changes, then send that string to the database to be processed by the database engine's XML functionality. However, using XML in this way seems rather cumbersome given the simple nature of the task to be performed. ANSWER: It depends on how many you need to do, and how fast the operations need to run. If it's only a few, then doing them one at a time with whatever mechanism you have for doing single operations will work fine. If you need to do thousands or more, and it needs to run quickly, you should re-use the connection and command, changing the arguments for the parameters to the query during each iteration. This will minimize resource usage. You don't want to re-create the connection and command for each operation.
[ "sql", "database" ]
3
1
1,465
5
0
2008-09-04T18:53:56.450000
2008-09-04T18:58:36.160000
44,470
152,493
How do I get the ClickOnce Publish version to match the AssemblyInfo.cs File version?
Every time I publish the application in ClickOnce I get get it to update the revision number by one. Is there a way to get this change automatically to change the version number in AssemblyInfo.cs file (all our error reporting looks at the Assembly Version)?
We use Team Foundation Server Team Build and have added a block to the TFSBuild.proj's AfterCompile target to trigger the ClickOnce publish with our preferred version number: The PublishApplicationVersion variable is generated by a custom MSBuild task to use the TFS Changeset number, but you could use your own custom task or an existing solution to get the version number from the AssemblyInfo file. This could theoretically be done in your project file (which is just an MSBuild script anyway), but I'd recommend against deploying from a developer machine. I'm sure other continuous integration (CI) solutions can handle this similarly. Edit: Sorry, got your question backwards. Going from the ClickOnce version number to the AssemblyInfo file should be doable. I'm sure the MSBuild Community Tasks (link above) have a task for updating the AssemblyInfo file, so you'd just need a custom task to pull the version number from the ClickOnce configuration XML. However, you may also consider changing your error reporting to include the ClickOnce publish version too: if (System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed) { Debug.WriteLine(System.Deployment.Application.ApplicationDeployment. CurrentDeployment.CurrentVersion); }
How do I get the ClickOnce Publish version to match the AssemblyInfo.cs File version? Every time I publish the application in ClickOnce I get get it to update the revision number by one. Is there a way to get this change automatically to change the version number in AssemblyInfo.cs file (all our error reporting looks at the Assembly Version)?
TITLE: How do I get the ClickOnce Publish version to match the AssemblyInfo.cs File version? QUESTION: Every time I publish the application in ClickOnce I get get it to update the revision number by one. Is there a way to get this change automatically to change the version number in AssemblyInfo.cs file (all our error reporting looks at the Assembly Version)? ANSWER: We use Team Foundation Server Team Build and have added a block to the TFSBuild.proj's AfterCompile target to trigger the ClickOnce publish with our preferred version number: The PublishApplicationVersion variable is generated by a custom MSBuild task to use the TFS Changeset number, but you could use your own custom task or an existing solution to get the version number from the AssemblyInfo file. This could theoretically be done in your project file (which is just an MSBuild script anyway), but I'd recommend against deploying from a developer machine. I'm sure other continuous integration (CI) solutions can handle this similarly. Edit: Sorry, got your question backwards. Going from the ClickOnce version number to the AssemblyInfo file should be doable. I'm sure the MSBuild Community Tasks (link above) have a task for updating the AssemblyInfo file, so you'd just need a custom task to pull the version number from the ClickOnce configuration XML. However, you may also consider changing your error reporting to include the ClickOnce publish version too: if (System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed) { Debug.WriteLine(System.Deployment.Application.ApplicationDeployment. CurrentDeployment.CurrentVersion); }
[ "visual-studio", "clickonce", "versioning" ]
31
33
21,016
4
0
2008-09-04T18:54:01.520000
2008-09-30T10:13:01.050000
44,476
45,131
Compressing a TIF file
I'm trying to convert a multipage color tiff file to a c# CompressionCCITT3 tiff in C#. I realize that I need to make sure that all pixels are 1 bit. I have not found a useful example of this online.
You need this conversion as CCITT3 and CCITT4 don't support color (if I remember right).
Compressing a TIF file I'm trying to convert a multipage color tiff file to a c# CompressionCCITT3 tiff in C#. I realize that I need to make sure that all pixels are 1 bit. I have not found a useful example of this online.
TITLE: Compressing a TIF file QUESTION: I'm trying to convert a multipage color tiff file to a c# CompressionCCITT3 tiff in C#. I realize that I need to make sure that all pixels are 1 bit. I have not found a useful example of this online. ANSWER: You need this conversion as CCITT3 and CCITT4 don't support color (if I remember right).
[ "c#", "tiff" ]
0
1
6,637
4
0
2008-09-04T18:55:37.447000
2008-09-05T02:21:06.953000
44,481
44,651
Is it possible to craft a glob that matches files in the current directory and all subdirectories?
For this directory structure:. |-- README.txt |-- firstlevel.rb `-- lib |-- models | |-- foo | | `-- fourthlevel.rb | `-- thirdlevel.rb `-- secondlevel.rb 3 directories, 5 files The glob would match: firstlevel.rb lib/secondlevel.rb lib/models/thirdlevel.rb lib/models/foo/fourthlevel.rb
Apologies if I've missed the real point of the question but, if I was using sh/bash/etc., then I would probably use find to do the job: find. -name '*.rb' -type f Globs can get a bit nasty when used from within a script and find is much more flexible.
Is it possible to craft a glob that matches files in the current directory and all subdirectories? For this directory structure:. |-- README.txt |-- firstlevel.rb `-- lib |-- models | |-- foo | | `-- fourthlevel.rb | `-- thirdlevel.rb `-- secondlevel.rb 3 directories, 5 files The glob would match: firstlevel.rb lib/secondlevel.rb lib/models/thirdlevel.rb lib/models/foo/fourthlevel.rb
TITLE: Is it possible to craft a glob that matches files in the current directory and all subdirectories? QUESTION: For this directory structure:. |-- README.txt |-- firstlevel.rb `-- lib |-- models | |-- foo | | `-- fourthlevel.rb | `-- thirdlevel.rb `-- secondlevel.rb 3 directories, 5 files The glob would match: firstlevel.rb lib/secondlevel.rb lib/models/thirdlevel.rb lib/models/foo/fourthlevel.rb ANSWER: Apologies if I've missed the real point of the question but, if I was using sh/bash/etc., then I would probably use find to do the job: find. -name '*.rb' -type f Globs can get a bit nasty when used from within a script and find is much more flexible.
[ "shell", "glob" ]
1
4
315
4
0
2008-09-04T18:58:16.707000
2008-09-04T20:01:53.510000
44,485
44,513
Arbitrary Naming Convention (Business Objects)
Ok, do you do Business.Name or Business.BusinessName SubCategory.ID or SubCategory.SubCategoryID What about in your database? Why? I'm torn with both. Would love there to be a "right answer"
The main drawback of using ID, Name etc is that you have to qualify them with the table name if you are writing an SQL join which overlaps two tables. Despite that, I find it far more concise and readable to just use ID and Name - your code and tables will 'flow' much more easily past the eyes. Easier to type and less redundant. And typing SELECT Business.Name FROM... in an SQL query is not really more troublesome than typing SELECT BusinessName FROM... In general, if I find myself repeating semantic information it alerts me to look for ways to eliminate it or at least recognise why it repeats. This could be on the small scale (attribute names) or the large scale (behaviour patterns or common class structures).
Arbitrary Naming Convention (Business Objects) Ok, do you do Business.Name or Business.BusinessName SubCategory.ID or SubCategory.SubCategoryID What about in your database? Why? I'm torn with both. Would love there to be a "right answer"
TITLE: Arbitrary Naming Convention (Business Objects) QUESTION: Ok, do you do Business.Name or Business.BusinessName SubCategory.ID or SubCategory.SubCategoryID What about in your database? Why? I'm torn with both. Would love there to be a "right answer" ANSWER: The main drawback of using ID, Name etc is that you have to qualify them with the table name if you are writing an SQL join which overlaps two tables. Despite that, I find it far more concise and readable to just use ID and Name - your code and tables will 'flow' much more easily past the eyes. Easier to type and less redundant. And typing SELECT Business.Name FROM... in an SQL query is not really more troublesome than typing SELECT BusinessName FROM... In general, if I find myself repeating semantic information it alerts me to look for ways to eliminate it or at least recognise why it repeats. This could be on the small scale (attribute names) or the large scale (behaviour patterns or common class structures).
[ "c#", "oop", "object", "naming" ]
0
2
946
5
0
2008-09-04T18:59:36.953000
2008-09-04T19:09:04.667000
44,516
44,739
JavaFX video encoding
On JavaFX's Wikipedia In May 2008 (...) Sun Also announced a multi-year agreement with On2 Technologies to bring comprehensive video capabilities to the JavaFX product family using the company's TrueMotion Video codec. Do you know if it will include encoding capabilities for Webcam Video like Flash or just playback/streaming? Thanks
The JavaFX API just supports media playback at the moment (see here: javafx.scene.media.MediaView ). There might very well be mere Java APIs for encoding, however.
JavaFX video encoding On JavaFX's Wikipedia In May 2008 (...) Sun Also announced a multi-year agreement with On2 Technologies to bring comprehensive video capabilities to the JavaFX product family using the company's TrueMotion Video codec. Do you know if it will include encoding capabilities for Webcam Video like Flash or just playback/streaming? Thanks
TITLE: JavaFX video encoding QUESTION: On JavaFX's Wikipedia In May 2008 (...) Sun Also announced a multi-year agreement with On2 Technologies to bring comprehensive video capabilities to the JavaFX product family using the company's TrueMotion Video codec. Do you know if it will include encoding capabilities for Webcam Video like Flash or just playback/streaming? Thanks ANSWER: The JavaFX API just supports media playback at the moment (see here: javafx.scene.media.MediaView ). There might very well be mere Java APIs for encoding, however.
[ "flash", "video", "javafx", "encoding" ]
1
1
1,395
1
0
2008-09-04T19:10:11.607000
2008-09-04T20:47:21.233000
44,517
44,559
Tools to convert asp.net dynamic site into static site
Are there any tools that will spider an asp.net website and create a static site?
http://www.httrack.com/ Have used for this purpose a few times, may need to do a little tidying up of urls, and some css linked images might not make it, depends on how good a job you want to do. If you have dreamweaver, you can use that to manage the links if you need to clean up the file names afterwards. Optionally use the link checker extension for firefox to check it all afterwards.
Tools to convert asp.net dynamic site into static site Are there any tools that will spider an asp.net website and create a static site?
TITLE: Tools to convert asp.net dynamic site into static site QUESTION: Are there any tools that will spider an asp.net website and create a static site? ANSWER: http://www.httrack.com/ Have used for this purpose a few times, may need to do a little tidying up of urls, and some css linked images might not make it, depends on how good a job you want to do. If you have dreamweaver, you can use that to manage the links if you need to clean up the file names afterwards. Optionally use the link checker extension for firefox to check it all afterwards.
[ "asp.net", "web-crawler" ]
0
2
1,697
4
0
2008-09-04T19:10:14.023000
2008-09-04T19:26:33.423000
44,542
44,844
Algorithm / pseudo-code to create paging links?
Can someome provide code or pseudo-code for how the paging links on StackOverflow are generated? I keep racking my brain but can't think of a decent way to build the dynamic links that always show the 2 pages around the current, plus the first and last. Example: 1... 5 6 7... 593
There are several other answers already, but I'd like to show you the approach I took to solve it: First, let's check out how Stack Overflow handles normal cases and edge cases. Each of my pages displays 10 results, so to find out what it does for 1 page, find a tag that has less than 11 entries: usability works today. We can see nothing is displayed, which makes sense. How about 2 pages? Find a tag that has between 11 and 20 entries ( emacs works today). We see: " 1 2 Next" or "Prev 1 2 ", depending on which page we're on. 3 pages? " 1 2 3... 3 Next", "Prev 1 2 3 Next", and "Prev 1... 2 3 ". Interestingly, we can see that Stack Overflow itself doesn't handle this edge case very well: it should display " 1 2... 3 Next" 4 pages? " 1 2 3... 4 Next", "Prev 1 2 3... 4 Next", "Prev 1... 2 3 4 Next" and "Prev 1... 3 4 " Finally let's look at the general case, N pages: " 1 2 3... N Next", "Prev 1 2 3... N Next", "Prev 1... 2 3 4... N Next", "Prev 1... 3 4 5... N Next", etc. Let's generalize based on what we've seen: The algorithm seems to have these traits in common: If we're not on the first page, display link to Prev Always display the first page number Always display the current page number Always display the page before this page, and the page after this page. Always display the last page number If we're not on the last page, display link to Next Let's ignore the edge case of a single page and make a good first attempt at the algorithm: (As has been mentioned, the code to actually print out the links would be more complicated. Imagine each place we place a page number, Prev or Next as a function call that will return the correct URL.) function printPageLinksFirstTry(num totalPages, num currentPage) if ( currentPage > 1 ) print "Prev" print "1" print "..." print currentPage - 1 print currentPage print currentPage + 1 print "..." print totalPages if ( currentPage < totalPages ) print "Next" endFunction This function works ok, but it doesn't take into account whether we're near the first or last page. Looking at the above examples, we only want to display the... if the current page is two or more away. function printPageLinksHandleCloseToEnds(num totalPages, num currentPage) if ( currentPage > 1 ) print "Prev" print "1" if ( currentPage > 2 ) print "..." if ( currentPage > 2 ) print currentPage - 1 print currentPage if ( currentPage < totalPages - 1 ) print currentPage + 1 if ( currentPage < totalPages - 1 ) print "..." print totalPages if ( currentPage < totalPages ) print "Next" endFunction As you can see, we have some duplication here. We can go ahead and clean that up for readibility: function printPageLinksCleanedUp(num totalPages, num currentPage) if ( currentPage > 1 ) print "Prev" print "1" if ( currentPage > 2 ) print "..." print currentPage - 1 print currentPage if ( currentPage < totalPages - 1 ) print currentPage + 1 print "..." print totalPages if ( currentPage < totalPages ) print "Next" endFunction There are only two problems left. First, we don't print out correctly for one page, and secondly, we'll print out "1" twice if we're on the first or last page. Let's clean those both up in one go: function printPageLinksFinal(num totalPages, num currentPage) if ( totalPages == 1 ) return if ( currentPage > 1 ) print "Prev" print "1" if ( currentPage > 2 ) print "..." print currentPage - 1 if ( currentPage!= 1 and currentPage!= totalPages ) print currentPage if ( currentPage < totalPages - 1 ) print currentPage + 1 print "..." print totalPages if ( currentPage < totalPages ) print "Next" endFunction Actually, I lied: We have one remaining issue. When you have at least 4 pages and are on the first or last page, you get an extra page in your display. Instead of " 1 2... 10 Next" you get " 1 2 3... 10 Next". To match what's going on at Stack Overflow exactly, you'll have to check for this situation: function printPageLinksFinalReally(num totalPages, num currentPage) if ( totalPages == 1 ) return if ( currentPage > 1 ) print "Prev" print "1" if ( currentPage > 2 ) print "..." if ( currentPage == totalPages and totalPages > 3 ) print currentPage - 2 print currentPage - 1 if ( currentPage!= 1 and currentPage!= totalPages ) print currentPage if ( currentPage < totalPages - 1 ) print currentPage + 1 if ( currentPage == 1 and totalPages > 3 ) print currentPage + 2 print "..." print totalPages if ( currentPage < totalPages ) print "Next" endFunction I hope this helps!
Algorithm / pseudo-code to create paging links? Can someome provide code or pseudo-code for how the paging links on StackOverflow are generated? I keep racking my brain but can't think of a decent way to build the dynamic links that always show the 2 pages around the current, plus the first and last. Example: 1... 5 6 7... 593
TITLE: Algorithm / pseudo-code to create paging links? QUESTION: Can someome provide code or pseudo-code for how the paging links on StackOverflow are generated? I keep racking my brain but can't think of a decent way to build the dynamic links that always show the 2 pages around the current, plus the first and last. Example: 1... 5 6 7... 593 ANSWER: There are several other answers already, but I'd like to show you the approach I took to solve it: First, let's check out how Stack Overflow handles normal cases and edge cases. Each of my pages displays 10 results, so to find out what it does for 1 page, find a tag that has less than 11 entries: usability works today. We can see nothing is displayed, which makes sense. How about 2 pages? Find a tag that has between 11 and 20 entries ( emacs works today). We see: " 1 2 Next" or "Prev 1 2 ", depending on which page we're on. 3 pages? " 1 2 3... 3 Next", "Prev 1 2 3 Next", and "Prev 1... 2 3 ". Interestingly, we can see that Stack Overflow itself doesn't handle this edge case very well: it should display " 1 2... 3 Next" 4 pages? " 1 2 3... 4 Next", "Prev 1 2 3... 4 Next", "Prev 1... 2 3 4 Next" and "Prev 1... 3 4 " Finally let's look at the general case, N pages: " 1 2 3... N Next", "Prev 1 2 3... N Next", "Prev 1... 2 3 4... N Next", "Prev 1... 3 4 5... N Next", etc. Let's generalize based on what we've seen: The algorithm seems to have these traits in common: If we're not on the first page, display link to Prev Always display the first page number Always display the current page number Always display the page before this page, and the page after this page. Always display the last page number If we're not on the last page, display link to Next Let's ignore the edge case of a single page and make a good first attempt at the algorithm: (As has been mentioned, the code to actually print out the links would be more complicated. Imagine each place we place a page number, Prev or Next as a function call that will return the correct URL.) function printPageLinksFirstTry(num totalPages, num currentPage) if ( currentPage > 1 ) print "Prev" print "1" print "..." print currentPage - 1 print currentPage print currentPage + 1 print "..." print totalPages if ( currentPage < totalPages ) print "Next" endFunction This function works ok, but it doesn't take into account whether we're near the first or last page. Looking at the above examples, we only want to display the... if the current page is two or more away. function printPageLinksHandleCloseToEnds(num totalPages, num currentPage) if ( currentPage > 1 ) print "Prev" print "1" if ( currentPage > 2 ) print "..." if ( currentPage > 2 ) print currentPage - 1 print currentPage if ( currentPage < totalPages - 1 ) print currentPage + 1 if ( currentPage < totalPages - 1 ) print "..." print totalPages if ( currentPage < totalPages ) print "Next" endFunction As you can see, we have some duplication here. We can go ahead and clean that up for readibility: function printPageLinksCleanedUp(num totalPages, num currentPage) if ( currentPage > 1 ) print "Prev" print "1" if ( currentPage > 2 ) print "..." print currentPage - 1 print currentPage if ( currentPage < totalPages - 1 ) print currentPage + 1 print "..." print totalPages if ( currentPage < totalPages ) print "Next" endFunction There are only two problems left. First, we don't print out correctly for one page, and secondly, we'll print out "1" twice if we're on the first or last page. Let's clean those both up in one go: function printPageLinksFinal(num totalPages, num currentPage) if ( totalPages == 1 ) return if ( currentPage > 1 ) print "Prev" print "1" if ( currentPage > 2 ) print "..." print currentPage - 1 if ( currentPage!= 1 and currentPage!= totalPages ) print currentPage if ( currentPage < totalPages - 1 ) print currentPage + 1 print "..." print totalPages if ( currentPage < totalPages ) print "Next" endFunction Actually, I lied: We have one remaining issue. When you have at least 4 pages and are on the first or last page, you get an extra page in your display. Instead of " 1 2... 10 Next" you get " 1 2 3... 10 Next". To match what's going on at Stack Overflow exactly, you'll have to check for this situation: function printPageLinksFinalReally(num totalPages, num currentPage) if ( totalPages == 1 ) return if ( currentPage > 1 ) print "Prev" print "1" if ( currentPage > 2 ) print "..." if ( currentPage == totalPages and totalPages > 3 ) print currentPage - 2 print currentPage - 1 if ( currentPage!= 1 and currentPage!= totalPages ) print currentPage if ( currentPage < totalPages - 1 ) print currentPage + 1 if ( currentPage == 1 and totalPages > 3 ) print currentPage + 2 print "..." print totalPages if ( currentPage < totalPages ) print "Next" endFunction I hope this helps!
[ "algorithm", "paging" ]
18
46
12,803
6
0
2008-09-04T19:20:15.250000
2008-09-04T21:32:07.723000
44,554
44,570
What’s your logging philosophy?
As Jeff Atwood asked: "What’s your logging philosophy? Should all code be littered with.logthis() and.logthat() calls? Or do you inject logging after the fact somehow?"
My logging philosophy is pretty easily summarized in four parts: Auditing, or business logic logging Log those things that are required to be logged. This comes from the application requirements, and may include logging every change made to any database (as in many financial applications) or logging accesses to data (as may be required in the health industry to meet industry regulations) As this is part of the program requirements many do not include it in their general discussions of logging, however there is overlap in these areas, and for some applications it is useful to consider all logging activities together. Program logging Messages which will help developers test and debug the application, and more easily follow the data flow and program logic to understand where implementation, integration, and other errors may exist. In general this logging is turned on and off as needed for debugging sessions. Performance logging Add later logging as needed to find and resolve performance bottlenecks and other program issues which aren't causing the program to fail, but will lead to better operation. Overlaps with Program logging in the case of memory leaks and some non-critical errors. Security logging Logging user actions and interactions with external systems where security is a concern. Useful for determining how an attacker broke a system after an attack, but may also tie into an intrusion detection system to detect new or ongoing attacks.
What’s your logging philosophy? As Jeff Atwood asked: "What’s your logging philosophy? Should all code be littered with.logthis() and.logthat() calls? Or do you inject logging after the fact somehow?"
TITLE: What’s your logging philosophy? QUESTION: As Jeff Atwood asked: "What’s your logging philosophy? Should all code be littered with.logthis() and.logthat() calls? Or do you inject logging after the fact somehow?" ANSWER: My logging philosophy is pretty easily summarized in four parts: Auditing, or business logic logging Log those things that are required to be logged. This comes from the application requirements, and may include logging every change made to any database (as in many financial applications) or logging accesses to data (as may be required in the health industry to meet industry regulations) As this is part of the program requirements many do not include it in their general discussions of logging, however there is overlap in these areas, and for some applications it is useful to consider all logging activities together. Program logging Messages which will help developers test and debug the application, and more easily follow the data flow and program logic to understand where implementation, integration, and other errors may exist. In general this logging is turned on and off as needed for debugging sessions. Performance logging Add later logging as needed to find and resolve performance bottlenecks and other program issues which aren't causing the program to fail, but will lead to better operation. Overlaps with Program logging in the case of memory leaks and some non-critical errors. Security logging Logging user actions and interactions with external systems where security is a concern. Useful for determining how an attacker broke a system after an attack, but may also tie into an intrusion detection system to detect new or ongoing attacks.
[ "logging" ]
22
21
2,521
12
0
2008-09-04T19:24:54.880000
2008-09-04T19:29:37.147000
44,566
44,700
How do I simultaneously work on version 1.1 and version 2.0?
The situation: We're out of beta and version 1.0 has been released to several customer sites. Team A is already busy working on version 1.1 that will have incremental bugfixes and usability tweaks, while another team works on version 2.0 with large-scale changes, where the core of the product may have been completely redesigned. Now, most of the changes made for 1.1 will have to make their way into 2.0 at some point, and some of the bug fixes made in the 2.0 branch might in fact need to be scheduled for an earlier release. The problem is that since 2.0 has fundamental differences, no changes from 1.1 can be merged in without manual conversion, nor vice versa. My question: What are the best revision control practises to minimise merge conflicts and duplicate work in this kind of situation? How can I ensure that my teams spend as little time and effort as possible on revision control issues, while still providing regular patches to customers?
One good way is to fix each bug in the stable branch and merge the stable branch into the development branch. This is the Parallel Maintenance/Development Lines pattern, and the key is to merge early and often. Merging infrequently and late means that the development branch is unrecognisable compared to the stable one, or the bug cannot be repeated in the same way. Subversion includes merge tracking since version 1.5 so you ensure that the same change set is not merged twice, causing silly conflicts. Other systems exist (e.g. Git, Mercurial, Accurev, Perforce ) that let you make queries of the type "what changes on branch A have not been merged into branch B?" and cherry-pick the fixes you need across to the dev branch.
How do I simultaneously work on version 1.1 and version 2.0? The situation: We're out of beta and version 1.0 has been released to several customer sites. Team A is already busy working on version 1.1 that will have incremental bugfixes and usability tweaks, while another team works on version 2.0 with large-scale changes, where the core of the product may have been completely redesigned. Now, most of the changes made for 1.1 will have to make their way into 2.0 at some point, and some of the bug fixes made in the 2.0 branch might in fact need to be scheduled for an earlier release. The problem is that since 2.0 has fundamental differences, no changes from 1.1 can be merged in without manual conversion, nor vice versa. My question: What are the best revision control practises to minimise merge conflicts and duplicate work in this kind of situation? How can I ensure that my teams spend as little time and effort as possible on revision control issues, while still providing regular patches to customers?
TITLE: How do I simultaneously work on version 1.1 and version 2.0? QUESTION: The situation: We're out of beta and version 1.0 has been released to several customer sites. Team A is already busy working on version 1.1 that will have incremental bugfixes and usability tweaks, while another team works on version 2.0 with large-scale changes, where the core of the product may have been completely redesigned. Now, most of the changes made for 1.1 will have to make their way into 2.0 at some point, and some of the bug fixes made in the 2.0 branch might in fact need to be scheduled for an earlier release. The problem is that since 2.0 has fundamental differences, no changes from 1.1 can be merged in without manual conversion, nor vice versa. My question: What are the best revision control practises to minimise merge conflicts and duplicate work in this kind of situation? How can I ensure that my teams spend as little time and effort as possible on revision control issues, while still providing regular patches to customers? ANSWER: One good way is to fix each bug in the stable branch and merge the stable branch into the development branch. This is the Parallel Maintenance/Development Lines pattern, and the key is to merge early and often. Merging infrequently and late means that the development branch is unrecognisable compared to the stable one, or the bug cannot be repeated in the same way. Subversion includes merge tracking since version 1.5 so you ensure that the same change set is not merged twice, causing silly conflicts. Other systems exist (e.g. Git, Mercurial, Accurev, Perforce ) that let you make queries of the type "what changes on branch A have not been merged into branch B?" and cherry-pick the fixes you need across to the dev branch.
[ "svn", "build-process", "release", "revision" ]
10
9
604
8
0
2008-09-04T19:28:52.793000
2008-09-04T20:27:06.477000
44,569
44,590
Octal number literals: When? Why? Ever?
I have never used octal numbers in my code nor come across any code that used it (hexadecimal and bit twiddling notwithstanding). I started programming in C/C++ about 1994 so maybe I'm too young for this? Does older code use octal? C includes support for these by prepending a 0, but where is the code that uses these base 8 number literals?
I recently had to write network protocol code that accesses 3-bit fields. Octal comes in handy when you want to debug that. Just for effect, can you tell me what the 3-bit fields of this are? 0x492492 On the other hand, this same number in octal: 022222222 Now, finally, in binary (in groups of 3): 010 010 010 010 010 010 010 010
Octal number literals: When? Why? Ever? I have never used octal numbers in my code nor come across any code that used it (hexadecimal and bit twiddling notwithstanding). I started programming in C/C++ about 1994 so maybe I'm too young for this? Does older code use octal? C includes support for these by prepending a 0, but where is the code that uses these base 8 number literals?
TITLE: Octal number literals: When? Why? Ever? QUESTION: I have never used octal numbers in my code nor come across any code that used it (hexadecimal and bit twiddling notwithstanding). I started programming in C/C++ about 1994 so maybe I'm too young for this? Does older code use octal? C includes support for these by prepending a 0, but where is the code that uses these base 8 number literals? ANSWER: I recently had to write network protocol code that accesses 3-bit fields. Octal comes in handy when you want to debug that. Just for effect, can you tell me what the 3-bit fields of this are? 0x492492 On the other hand, this same number in octal: 022222222 Now, finally, in binary (in groups of 3): 010 010 010 010 010 010 010 010
[ "c", "numbers" ]
51
55
40,187
13
0
2008-09-04T19:29:33.980000
2008-09-04T19:36:40.530000
44,588
44,595
How to convince a company to switch their Source Control
My current place of employment is currently in a transition, new ownership has taken over, things are finally getting standardized and proper guidelines are being enforced. But we are still using VSS, there really isn't any reason for using it other then that's what whats initially setup. We don't use Visual Studio, or any tool really that specifically requires it. What would be the absolute best argument I can bring up to help convince them that going to something like Subversion would be a much better solution, in the long run.
VSS totally relies on the clients to manage the database. If a client drops connection in the middle of a write over the network at just the wrong time, your file is trashed on the server. Not just the tip, but all the history. Hope you have a good backup. I've been through it. It's bad news. VSS usage over VPN or other remote connections is abysmal. It's using SMB to transfer the data, and you have to retrieve the file and all of its deltas just to get the tip. Nasty. I've seen VSS start to act up at 1GB of data. Database errors, etc. MS (somewhere in a FAQ or KB) says that 2GB is really the max safe limit. There are no good management tools (the clients run the asylum), so you don't really get any warning about this. Anything with a server process to provide some level of transactions and integrity control is a superior solution.
How to convince a company to switch their Source Control My current place of employment is currently in a transition, new ownership has taken over, things are finally getting standardized and proper guidelines are being enforced. But we are still using VSS, there really isn't any reason for using it other then that's what whats initially setup. We don't use Visual Studio, or any tool really that specifically requires it. What would be the absolute best argument I can bring up to help convince them that going to something like Subversion would be a much better solution, in the long run.
TITLE: How to convince a company to switch their Source Control QUESTION: My current place of employment is currently in a transition, new ownership has taken over, things are finally getting standardized and proper guidelines are being enforced. But we are still using VSS, there really isn't any reason for using it other then that's what whats initially setup. We don't use Visual Studio, or any tool really that specifically requires it. What would be the absolute best argument I can bring up to help convince them that going to something like Subversion would be a much better solution, in the long run. ANSWER: VSS totally relies on the clients to manage the database. If a client drops connection in the middle of a write over the network at just the wrong time, your file is trashed on the server. Not just the tip, but all the history. Hope you have a good backup. I've been through it. It's bad news. VSS usage over VPN or other remote connections is abysmal. It's using SMB to transfer the data, and you have to retrieve the file and all of its deltas just to get the tip. Nasty. I've seen VSS start to act up at 1GB of data. Database errors, etc. MS (somewhere in a FAQ or KB) says that 2GB is really the max safe limit. There are no good management tools (the clients run the asylum), so you don't really get any warning about this. Anything with a server process to provide some level of transactions and integrity control is a superior solution.
[ "svn", "version-control", "visual-sourcesafe" ]
12
16
1,417
14
0
2008-09-04T19:34:09.460000
2008-09-04T19:38:07.797000
44,601
44,750
.NET Development on a Mac Tips
I have just got a MacBook Pro and have been using it (+Fusion) to develop on for about a month now. The purpose of this question is similar to Hidden Features of C#; to become a how-to of tips and trick for windows development on a mac. I should clarify that I am aware of boot camp but do not use it (nor do I have any interest to), hence my use of steady state to make sure nothing happens to my OS partition without my knowledge. However; as Sara pointed out, Apple makes great hardware and I absolutely LOVE the form factor of my MBP so for someone who is looking for a windows only laptop a mac with boot camp should not be overlooked as the hardware is amazing. My environment is as follows * MacBook Pro 15" 2.4Ghz 2GB RAM (Going to upgrade to 4GB soon) * VMWare Fusion 2.0 Beta * Windows XP Pro SP3 (Slipstreamed BEFORE install) Tips: * Use Windows Steady State to keep OS consistent * Use svn+ssh to connect to the mac for small repositories then use time machine to backup. * Use spaces.
@Andrew - I'm exactly in your situation. I use a MBP while my company work is purely Microsoft based: i.e.,.NET, COM etc. While nothing can beat running Vista natively in Boot Camp (I've never seen Vista run so fast), the niceties of having your Mac OS be the "main" OS, for internet, mail etc. has gotten me to the following configuration. Works like a charm: Hardware Load up your MBP with the max possible - 4GB. It's really worth every $. Upgrade your hard drive (if not already) to 7200RPM. Major performance boost here. Software Parallels Desktop for Mac for virtualization. You can either have multiple VM, or use a boot camp partition. The latter is supposed to be faster, but I haven't really measured it (I use it for having the option to boot natively if I really need speed). The former allows you to have multiple OS. I gave my VM 1GB memory. I can do more if you want it more snappy. Micorsoft Visual Studio 2005/8 for.NET and C++. I have yet to see any IDE for.NET which beats this one. The intellisense is really amazing. Code Gear (yes we have some Delphi) For non development occasional need I also keep Microsoft Office 2007 installed. They do have MAC ports, but those don't always cut it.
.NET Development on a Mac Tips I have just got a MacBook Pro and have been using it (+Fusion) to develop on for about a month now. The purpose of this question is similar to Hidden Features of C#; to become a how-to of tips and trick for windows development on a mac. I should clarify that I am aware of boot camp but do not use it (nor do I have any interest to), hence my use of steady state to make sure nothing happens to my OS partition without my knowledge. However; as Sara pointed out, Apple makes great hardware and I absolutely LOVE the form factor of my MBP so for someone who is looking for a windows only laptop a mac with boot camp should not be overlooked as the hardware is amazing. My environment is as follows * MacBook Pro 15" 2.4Ghz 2GB RAM (Going to upgrade to 4GB soon) * VMWare Fusion 2.0 Beta * Windows XP Pro SP3 (Slipstreamed BEFORE install) Tips: * Use Windows Steady State to keep OS consistent * Use svn+ssh to connect to the mac for small repositories then use time machine to backup. * Use spaces.
TITLE: .NET Development on a Mac Tips QUESTION: I have just got a MacBook Pro and have been using it (+Fusion) to develop on for about a month now. The purpose of this question is similar to Hidden Features of C#; to become a how-to of tips and trick for windows development on a mac. I should clarify that I am aware of boot camp but do not use it (nor do I have any interest to), hence my use of steady state to make sure nothing happens to my OS partition without my knowledge. However; as Sara pointed out, Apple makes great hardware and I absolutely LOVE the form factor of my MBP so for someone who is looking for a windows only laptop a mac with boot camp should not be overlooked as the hardware is amazing. My environment is as follows * MacBook Pro 15" 2.4Ghz 2GB RAM (Going to upgrade to 4GB soon) * VMWare Fusion 2.0 Beta * Windows XP Pro SP3 (Slipstreamed BEFORE install) Tips: * Use Windows Steady State to keep OS consistent * Use svn+ssh to connect to the mac for small repositories then use time machine to backup. * Use spaces. ANSWER: @Andrew - I'm exactly in your situation. I use a MBP while my company work is purely Microsoft based: i.e.,.NET, COM etc. While nothing can beat running Vista natively in Boot Camp (I've never seen Vista run so fast), the niceties of having your Mac OS be the "main" OS, for internet, mail etc. has gotten me to the following configuration. Works like a charm: Hardware Load up your MBP with the max possible - 4GB. It's really worth every $. Upgrade your hard drive (if not already) to 7200RPM. Major performance boost here. Software Parallels Desktop for Mac for virtualization. You can either have multiple VM, or use a boot camp partition. The latter is supposed to be faster, but I haven't really measured it (I use it for having the option to boot natively if I really need speed). The former allows you to have multiple OS. I gave my VM 1GB memory. I can do more if you want it more snappy. Micorsoft Visual Studio 2005/8 for.NET and C++. I have yet to see any IDE for.NET which beats this one. The intellisense is really amazing. Code Gear (yes we have some Delphi) For non development occasional need I also keep Microsoft Office 2007 installed. They do have MAC ports, but those don't always cut it.
[ ".net", "macos", "vmware", "virtualization" ]
28
15
21,771
10
0
2008-09-04T19:38:53.987000
2008-09-04T20:51:21.240000
44,617
44,653
Adding more information to TestResult.xml file from NUnit
I would like to be able to add a "message" to a unit test, such that it actually appears within the TestResult.xml file generated by NUnit. For example, this is currently generated: I would like to be able to have an additional attribute (or node as the case may be), such as: The idea is that "message" above would somehow be defined within the test method itself (in my case, generated at run-time). Is there a property somewhere that I'm missing to be able to do something like this?
This may be missing the point, but how about naming the tests so they indicate what they test - then you may not even need the message. If it proves to be absolutely necessary, I think you'll need to produce your own testrunner that would (off the top of my head) read an additional attribute off the TestCase and attach it to the output.
Adding more information to TestResult.xml file from NUnit I would like to be able to add a "message" to a unit test, such that it actually appears within the TestResult.xml file generated by NUnit. For example, this is currently generated: I would like to be able to have an additional attribute (or node as the case may be), such as: The idea is that "message" above would somehow be defined within the test method itself (in my case, generated at run-time). Is there a property somewhere that I'm missing to be able to do something like this?
TITLE: Adding more information to TestResult.xml file from NUnit QUESTION: I would like to be able to add a "message" to a unit test, such that it actually appears within the TestResult.xml file generated by NUnit. For example, this is currently generated: I would like to be able to have an additional attribute (or node as the case may be), such as: The idea is that "message" above would somehow be defined within the test method itself (in my case, generated at run-time). Is there a property somewhere that I'm missing to be able to do something like this? ANSWER: This may be missing the point, but how about naming the tests so they indicate what they test - then you may not even need the message. If it proves to be absolutely necessary, I think you'll need to produce your own testrunner that would (off the top of my head) read an additional attribute off the TestCase and attach it to the output.
[ "unit-testing", "nunit" ]
6
2
5,249
4
0
2008-09-04T19:45:06.390000
2008-09-04T20:03:00.997000
44,619
45,791
How Do I Test Rails Logging In from the Console?
I was having a heck of a time figuring out how to login and logout using response objects from Rails. The standard blogs were ok, but I finally diagnosed it, and I wanted to record it here. app.get '/' assert_response:success app.get '/auth_only_url' assert_response 302 user = User.find(:user_to_login) app.post '/signin_url',:user_email => user.email,:user_password => ' ' assert_response 302 app.follow_redirect! assert_response:success app.get '/auth_only_url' assert_response:success Note, the above implies that you redirect after a failed auth request, and also that you redirect after logging in. To ensure that you load the fixtures into your test environment DB (which normally occurs during rake test), make sure you execute the following: rake db:fixtures:load RAILS_ENV=test (From Patrick Richie) The default URL will appear to be 'www.example.com', as this default host as set in ActionController::Integration::Session ActionController::Integration::Session.new.host=> "www.example.com" It is set in actionpack/lib/action_controller/integration.rb#75 To change it in the integration test, do the following: session = open_session do |s| s.host = 'my-example-host.com' end
'www.example.com' is the default host as set in ActionController::Integration::Session >> ActionController::Integration::Session.new.host => "www.example.com" It is set in actionpack/lib/action_controller/integration.rb#75 You should be able to change it in your integration test by doing the following: session = open_session do |s| s.host = 'my-example-host.com' end
How Do I Test Rails Logging In from the Console? I was having a heck of a time figuring out how to login and logout using response objects from Rails. The standard blogs were ok, but I finally diagnosed it, and I wanted to record it here. app.get '/' assert_response:success app.get '/auth_only_url' assert_response 302 user = User.find(:user_to_login) app.post '/signin_url',:user_email => user.email,:user_password => ' ' assert_response 302 app.follow_redirect! assert_response:success app.get '/auth_only_url' assert_response:success Note, the above implies that you redirect after a failed auth request, and also that you redirect after logging in. To ensure that you load the fixtures into your test environment DB (which normally occurs during rake test), make sure you execute the following: rake db:fixtures:load RAILS_ENV=test (From Patrick Richie) The default URL will appear to be 'www.example.com', as this default host as set in ActionController::Integration::Session ActionController::Integration::Session.new.host=> "www.example.com" It is set in actionpack/lib/action_controller/integration.rb#75 To change it in the integration test, do the following: session = open_session do |s| s.host = 'my-example-host.com' end
TITLE: How Do I Test Rails Logging In from the Console? QUESTION: I was having a heck of a time figuring out how to login and logout using response objects from Rails. The standard blogs were ok, but I finally diagnosed it, and I wanted to record it here. app.get '/' assert_response:success app.get '/auth_only_url' assert_response 302 user = User.find(:user_to_login) app.post '/signin_url',:user_email => user.email,:user_password => ' ' assert_response 302 app.follow_redirect! assert_response:success app.get '/auth_only_url' assert_response:success Note, the above implies that you redirect after a failed auth request, and also that you redirect after logging in. To ensure that you load the fixtures into your test environment DB (which normally occurs during rake test), make sure you execute the following: rake db:fixtures:load RAILS_ENV=test (From Patrick Richie) The default URL will appear to be 'www.example.com', as this default host as set in ActionController::Integration::Session ActionController::Integration::Session.new.host=> "www.example.com" It is set in actionpack/lib/action_controller/integration.rb#75 To change it in the integration test, do the following: session = open_session do |s| s.host = 'my-example-host.com' end ANSWER: 'www.example.com' is the default host as set in ActionController::Integration::Session >> ActionController::Integration::Session.new.host => "www.example.com" It is set in actionpack/lib/action_controller/integration.rb#75 You should be able to change it in your integration test by doing the following: session = open_session do |s| s.host = 'my-example-host.com' end
[ "ruby-on-rails", "ruby" ]
7
3
1,535
1
0
2008-09-04T19:45:31.193000
2008-09-05T13:21:07.833000