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
155,892
155,904
Unicode URL decoding
The usual method of URL-encoding a unicode character is to split it into 2 %HH codes. ( \u4161 => %41%61 ) But, how is unicode distinguished when decoding? How do you know that %41%61 is \u4161 vs. \x41\x61 ("Aa")? Are 8-bit characters, that require encoding, preceded by %00? Or, is the point that unicode characters ar...
According to Wikipedia: Current standard The generic URI syntax mandates that new URI schemes that provide for the representation of character data in a URI must, in effect, represent characters from the unreserved set without translation, and should convert all other characters to bytes according to UTF-8, and then pe...
Unicode URL decoding The usual method of URL-encoding a unicode character is to split it into 2 %HH codes. ( \u4161 => %41%61 ) But, how is unicode distinguished when decoding? How do you know that %41%61 is \u4161 vs. \x41\x61 ("Aa")? Are 8-bit characters, that require encoding, preceded by %00? Or, is the point that ...
TITLE: Unicode URL decoding QUESTION: The usual method of URL-encoding a unicode character is to split it into 2 %HH codes. ( \u4161 => %41%61 ) But, how is unicode distinguished when decoding? How do you know that %41%61 is \u4161 vs. \x41\x61 ("Aa")? Are 8-bit characters, that require encoding, preceded by %00? Or, ...
[ "unicode", "urldecode" ]
7
7
9,315
3
0
2008-10-01T01:44:45.693000
2008-10-01T01:50:55.023000
155,903
160,151
How to detect the number of context switches that occurred while running C# code?
From C#, is it possible to detect the number of context switches that occurred while executing a block of code on a particular thread? Ideally, I'd like to know how many times and what CPU my thread code was scheduled on. I know I can use tools like Event Tracing for Windows and the associated viewers, but this seemed ...
It looks like procexp might be using the kernel thread (KTHREAD) or executive thread (ETHREAD) data structures that have a ContextSwitches field on them. It might be possible to get this from managed code.
How to detect the number of context switches that occurred while running C# code? From C#, is it possible to detect the number of context switches that occurred while executing a block of code on a particular thread? Ideally, I'd like to know how many times and what CPU my thread code was scheduled on. I know I can use...
TITLE: How to detect the number of context switches that occurred while running C# code? QUESTION: From C#, is it possible to detect the number of context switches that occurred while executing a block of code on a particular thread? Ideally, I'd like to know how many times and what CPU my thread code was scheduled on...
[ "c#", "multithreading" ]
4
0
2,707
3
0
2008-10-01T01:50:38.957000
2008-10-01T22:58:05.883000
155,906
156,164
Creating A Private Photo Gallery Using Asp.Net MVC
I need to create a photo gallery service that is managed by users. I've done this a million times using just Asp.net but I was wondering if there are any special considerations that I need to make when using Asp.net MVC. Basically, I will be storing the actual images on the filesystem and storing the locations in a dat...
This link explains how to create a custom ImageResult class. I was able to do exactly what I needed following it https://blog.maartenballiauw.be/post/2008/05/13/aspnet-mvc-custom-actionresult.html
Creating A Private Photo Gallery Using Asp.Net MVC I need to create a photo gallery service that is managed by users. I've done this a million times using just Asp.net but I was wondering if there are any special considerations that I need to make when using Asp.net MVC. Basically, I will be storing the actual images o...
TITLE: Creating A Private Photo Gallery Using Asp.Net MVC QUESTION: I need to create a photo gallery service that is managed by users. I've done this a million times using just Asp.net but I was wondering if there are any special considerations that I need to make when using Asp.net MVC. Basically, I will be storing t...
[ "asp.net-mvc", "image-gallery" ]
9
5
10,823
2
0
2008-10-01T01:52:19.933000
2008-10-01T03:44:00.773000
155,911
155,942
How do you handle unit/regression tests which are expected to fail during development?
During software development, there may be bugs in the codebase which are known issues. These bugs will cause the regression/unit tests to fail, if the tests have been written well. There is constant debate in our teams about how failing tests should be managed: Comment out failing test cases with a REVISIT or TODO comm...
I would leave your test cases in. In my experience, commenting out code with something like // TODO: fix test case is akin to doing: // HAHA: you'll never revisit me In all seriousness, as you get closer to shipping, the desire to revisit TODO's in code tends to fade, especially with things like unit tests because you ...
How do you handle unit/regression tests which are expected to fail during development? During software development, there may be bugs in the codebase which are known issues. These bugs will cause the regression/unit tests to fail, if the tests have been written well. There is constant debate in our teams about how fail...
TITLE: How do you handle unit/regression tests which are expected to fail during development? QUESTION: During software development, there may be bugs in the codebase which are known issues. These bugs will cause the regression/unit tests to fail, if the tests have been written well. There is constant debate in our te...
[ "automated-tests" ]
7
6
1,752
7
0
2008-10-01T01:54:05.250000
2008-10-01T02:04:28.487000
155,912
155,925
How to throw a XmlSchemaException on XML Schema validation errors?
Calling Validate() on an XmlDocument requires passing in a ValidationEventHandler delegate. That event function gets a ValidationEventArgs parameter which in turn has an Exception property of the type XmlSchemaException. Whew! My current code looks like this: ValidationEventHandler onValidationError = delegate(object s...
Because the Validate method takes the ValidationEventHandler delegate, it is left up to the developer to decide what to do with the excpetion. What you are doing is correct.
How to throw a XmlSchemaException on XML Schema validation errors? Calling Validate() on an XmlDocument requires passing in a ValidationEventHandler delegate. That event function gets a ValidationEventArgs parameter which in turn has an Exception property of the type XmlSchemaException. Whew! My current code looks like...
TITLE: How to throw a XmlSchemaException on XML Schema validation errors? QUESTION: Calling Validate() on an XmlDocument requires passing in a ValidationEventHandler delegate. That event function gets a ValidationEventArgs parameter which in turn has an Exception property of the type XmlSchemaException. Whew! My curre...
[ "c#", ".net", "xml", "schema" ]
1
2
2,360
2
0
2008-10-01T01:54:41.613000
2008-10-01T01:59:10.790000
155,913
155,967
Business Entity Loading Pattern
The project I'm working is using n-tier architecture. Our layers are as follows: Data Access Business Logic Business Entities Presentation The Business Logic calls down into the data access layer, and the Presentation layer calls down into the Business Logic layer, and the Business entities are referenced by all of the...
I highly recommend looking at Fowler's Patterns of Enterprise Architecture book. There are a few different approaches to solving this sort of problem that he outlines nicely, including entity relationships. One of the more compelling items would be the Unit Of Work pattern, which is basically a collector, that observes...
Business Entity Loading Pattern The project I'm working is using n-tier architecture. Our layers are as follows: Data Access Business Logic Business Entities Presentation The Business Logic calls down into the data access layer, and the Presentation layer calls down into the Business Logic layer, and the Business entit...
TITLE: Business Entity Loading Pattern QUESTION: The project I'm working is using n-tier architecture. Our layers are as follows: Data Access Business Logic Business Entities Presentation The Business Logic calls down into the data access layer, and the Presentation layer calls down into the Business Logic layer, and ...
[ ".net", "vb.net", "n-tier-architecture" ]
0
2
985
3
0
2008-10-01T01:54:59.927000
2008-10-01T02:17:28.703000
155,920
159,948
PHP Session data not being saved
I have one of those "I swear I didn't touch the server" situations. I honestly didn't touch any of the php scripts. The problem I am having is that php data is not being saved across different pages or page refreshes. I know a new session is being created correctly because I can set a session variable (e.g. $_SESSION['...
Thanks for all the helpful info. It turns out that my host changed servers and started using a different session save path other than /var/php_sessions which didn't exist anymore. A solution would have been to declare ini_set(' session.save_path','SOME WRITABLE PATH'); in all my script files but that would have been a ...
PHP Session data not being saved I have one of those "I swear I didn't touch the server" situations. I honestly didn't touch any of the php scripts. The problem I am having is that php data is not being saved across different pages or page refreshes. I know a new session is being created correctly because I can set a s...
TITLE: PHP Session data not being saved QUESTION: I have one of those "I swear I didn't touch the server" situations. I honestly didn't touch any of the php scripts. The problem I am having is that php data is not being saved across different pages or page refreshes. I know a new session is being created correctly bec...
[ "php", "session" ]
58
42
114,545
22
0
2008-10-01T01:57:49.127000
2008-10-01T21:57:04.140000
155,930
155,946
Launch web page from my application in Linux
I have an application that launches a webpage in the "current" browser when the user selects it. This part of my app works fine in the Windows version but I can't figure out how to do this in Linux build. Right now the Linux version is hardcoded for Firefox in a specific directory and runs a new instance of it each tim...
If you're writing this for modern distros, you can use xdg-open: $ xdg-open http://google.com/ If you're on an older version you'll have to use a desktop-specific command like gnome-open or exo-open.
Launch web page from my application in Linux I have an application that launches a webpage in the "current" browser when the user selects it. This part of my app works fine in the Windows version but I can't figure out how to do this in Linux build. Right now the Linux version is hardcoded for Firefox in a specific dir...
TITLE: Launch web page from my application in Linux QUESTION: I have an application that launches a webpage in the "current" browser when the user selects it. This part of my app works fine in the Windows version but I can't figure out how to do this in Linux build. Right now the Linux version is hardcoded for Firefox...
[ "c++", "c", "linux", "browser" ]
5
7
4,029
4
0
2008-10-01T02:00:53.923000
2008-10-01T02:06:09.837000
155,932
163,873
How do you loop through each line in a text file using a windows batch file?
I would like to know how to loop through each line in a text file using a Windows batch file and process each line of text in succession.
I needed to process the entire line as a whole. Here is what I found to work. for /F "tokens=*" %%A in (myfile.txt) do [process] %%A The tokens keyword with an asterisk (*) will pull all text for the entire line. If you don't put in the asterisk it will only pull the first word on the line. I assume it has to do with s...
How do you loop through each line in a text file using a windows batch file? I would like to know how to loop through each line in a text file using a Windows batch file and process each line of text in succession.
TITLE: How do you loop through each line in a text file using a windows batch file? QUESTION: I would like to know how to loop through each line in a text file using a Windows batch file and process each line of text in succession. ANSWER: I needed to process the entire line as a whole. Here is what I found to work. ...
[ "windows", "batch-file" ]
297
377
646,798
12
0
2008-10-01T02:01:38.070000
2008-10-02T18:33:46.133000
155,934
155,956
What GNU/Linux command-line tool would I use for performing a search and replace on a file?
What GNU/Linux command-line tool would I use for performing a search and replace on a file? Can the search text, and replacement, be specified in a regex format?
sed 's/a.*b/xyz/g;' old_file > new_file GNU sed (which you probably have) is even more versatile: sed -r --in-place 's/a(.*)b/x\1y/g;' your_file Here is a brief explanation of those options: -i[SUFFIX], --in-place[=SUFFIX] edit files in place (makes backup if extension supplied) -r, --regexp-extended use extended regul...
What GNU/Linux command-line tool would I use for performing a search and replace on a file? What GNU/Linux command-line tool would I use for performing a search and replace on a file? Can the search text, and replacement, be specified in a regex format?
TITLE: What GNU/Linux command-line tool would I use for performing a search and replace on a file? QUESTION: What GNU/Linux command-line tool would I use for performing a search and replace on a file? Can the search text, and replacement, be specified in a regex format? ANSWER: sed 's/a.*b/xyz/g;' old_file > new_file...
[ "regex", "linux", "sed", "gnu" ]
28
55
23,000
4
0
2008-10-01T02:02:55.790000
2008-10-01T02:08:34.980000
155,948
155,970
Do you design/sketch/draw a development solution first and then develop it? If so how?
I work a lot with decision makers looking to use technology better in their businesses. I have found that a picture is worth a thousand words and prototyping a system in a diagram of some sorts always lends a lot to a discussion. I have used Visio, UML (somewhat), Mind Maps, Flow Charts and Mocked Up WinForms to start ...
Paper or whiteboard! For the lone deveoper, I'd recommend paper. At least at first, eventually you may want to formalize it with UML, but I don't think its necessary. For a group of developers that work together (physically), I'd recommend a whiteboard. That way its visible for everyone and everyone can improve and con...
Do you design/sketch/draw a development solution first and then develop it? If so how? I work a lot with decision makers looking to use technology better in their businesses. I have found that a picture is worth a thousand words and prototyping a system in a diagram of some sorts always lends a lot to a discussion. I h...
TITLE: Do you design/sketch/draw a development solution first and then develop it? If so how? QUESTION: I work a lot with decision makers looking to use technology better in their businesses. I have found that a picture is worth a thousand words and prototyping a system in a diagram of some sorts always lends a lot to...
[ "uml", "system" ]
7
3
1,281
10
0
2008-10-01T02:06:37.107000
2008-10-01T02:18:40.213000
155,959
155,961
OleDbException System Resources Exceeded
The following code executes a simple insert command. If it is called 2,000 times consecutively (to insert 2,000 rows) an OleDbException with message = "System Resources Exceeded" is thrown. Is there something else I should be doing to free up resources? using (OleDbConnection conn = new OleDbConnection(connectionString...
The system resources exceeded error is not coming from the managed code, its coming from you killing your database (JET?) You are opening way too many connections, way too fast... Some tips: Avoid round trips by not opening a new connection for every single command, and perform the inserts using a single connection. En...
OleDbException System Resources Exceeded The following code executes a simple insert command. If it is called 2,000 times consecutively (to insert 2,000 rows) an OleDbException with message = "System Resources Exceeded" is thrown. Is there something else I should be doing to free up resources? using (OleDbConnection co...
TITLE: OleDbException System Resources Exceeded QUESTION: The following code executes a simple insert command. If it is called 2,000 times consecutively (to insert 2,000 rows) an OleDbException with message = "System Resources Exceeded" is thrown. Is there something else I should be doing to free up resources? using (...
[ "c#", "oledbexception" ]
8
7
17,530
5
0
2008-10-01T02:10:10.407000
2008-10-01T02:12:17.140000
155,964
156,098
What are best practices that you use when writing Objective-C and Cocoa?
I know about the HIG (which is quite handy!), but what programming practices do you use when writing Objective-C, and more specifically when using Cocoa (or CocoaTouch).
There are a few things I have started to do that I do not think are standard: 1) With the advent of properties, I no longer use "_" to prefix "private" class variables. After all, if a variable can be accessed by other classes shouldn't there be a property for it? I always disliked the "_" prefix for making code uglier...
What are best practices that you use when writing Objective-C and Cocoa? I know about the HIG (which is quite handy!), but what programming practices do you use when writing Objective-C, and more specifically when using Cocoa (or CocoaTouch).
TITLE: What are best practices that you use when writing Objective-C and Cocoa? QUESTION: I know about the HIG (which is quite handy!), but what programming practices do you use when writing Objective-C, and more specifically when using Cocoa (or CocoaTouch). ANSWER: There are a few things I have started to do that I...
[ "iphone", "objective-c", "cocoa", "cocoa-touch", "ios" ]
346
398
123,870
33
0
2008-10-01T02:13:42.270000
2008-10-01T03:17:10.090000
155,977
156,027
jQuery match multiple attributes
I have the following markup, and I want to make the All radio button checked. All New Removed Updated I'd like to match via attribute, but I need to match on 2 attributes, @name='Foo' and @value='All'. Something like this: $("input[@name='Foo' @value='all']").attr('checked','checked'); Can someone show how this can be ...
The following HTML file shows how you can do this: All New Removed Updated Click here When you click on the link, the desired radio button is selected. The important line is the one setting the checked attribute.
jQuery match multiple attributes I have the following markup, and I want to make the All radio button checked. All New Removed Updated I'd like to match via attribute, but I need to match on 2 attributes, @name='Foo' and @value='All'. Something like this: $("input[@name='Foo' @value='all']").attr('checked','checked'); ...
TITLE: jQuery match multiple attributes QUESTION: I have the following markup, and I want to make the All radio button checked. All New Removed Updated I'd like to match via attribute, but I need to match on 2 attributes, @name='Foo' and @value='All'. Something like this: $("input[@name='Foo' @value='all']").attr('che...
[ "jquery", "html", "jquery-selectors" ]
45
69
48,056
2
0
2008-10-01T02:21:07.650000
2008-10-01T02:43:34.430000
155,996
156,040
VB.Net MessageBox.Show() moves my form to the back
I have an MDI application. When I show a message box using MessageBox.Show(), the entire application disappears behind all of my open windows when I dismiss the message box. The code is not doing anything special. In fact, here is the line that invokes the message box from within an MDI Child form: MessageBox.Show(Stri...
Remove the last parameter, MessageBoxOptions.DefaultDesktopOnly. From MSDN: DefaultDesktopOnly will cause the application that raised the MessageBox to lose focus. The MessageBox that is displayed will not use visual styles. For more information, see Rendering Controls with Visual Styles. The last parameter allows comm...
VB.Net MessageBox.Show() moves my form to the back I have an MDI application. When I show a message box using MessageBox.Show(), the entire application disappears behind all of my open windows when I dismiss the message box. The code is not doing anything special. In fact, here is the line that invokes the message box ...
TITLE: VB.Net MessageBox.Show() moves my form to the back QUESTION: I have an MDI application. When I show a message box using MessageBox.Show(), the entire application disappears behind all of my open windows when I dismiss the message box. The code is not doing anything special. In fact, here is the line that invoke...
[ "vb.net", "mdi", "messagebox", "mdichild" ]
3
5
8,195
3
0
2008-10-01T02:30:15.147000
2008-10-01T02:48:17.617000
155,998
156,008
How can I assign an event to a timer at runtime in vb.net?
Given this: Public Sub timReminder_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) If DateTime.Now() > g_RemindTime Then Reminders.ShowDialog() timReminder.Enabled = False End If End Sub I want to be able to say this (as I would in Delphi): timReminder.Tick = timReminder_Tick But I get errors when I tr...
Use the 'AddHandler' and 'AddressOf' keywords to add a handler to the Tick event. AddHandler timeReminder.Tick, AddressOf timeReminder_Tick
How can I assign an event to a timer at runtime in vb.net? Given this: Public Sub timReminder_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) If DateTime.Now() > g_RemindTime Then Reminders.ShowDialog() timReminder.Enabled = False End If End Sub I want to be able to say this (as I would in Delphi): tim...
TITLE: How can I assign an event to a timer at runtime in vb.net? QUESTION: Given this: Public Sub timReminder_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) If DateTime.Now() > g_RemindTime Then Reminders.ShowDialog() timReminder.Enabled = False End If End Sub I want to be able to say this (as I wou...
[ "vb.net" ]
1
4
1,196
2
0
2008-10-01T02:30:30.153000
2008-10-01T02:34:16.150000
156,002
2,046,033
Protecting internal view layer template pages in servlet applications
I have a very basic question about MVC web applications in Java. Since the olden days of raw JSP up until current technologies like Seam, a very basic pattern has always been the internal dispatch from the controller that initially accepted the request to the view layer that creates the output to be sent to the client....
I have now seen a couple of applications that put their internal JSP into WEB-INF/jsp. That seems to do the trick, at least for JSP, and also for Velocity. It does not seem to work for JSF, though.
Protecting internal view layer template pages in servlet applications I have a very basic question about MVC web applications in Java. Since the olden days of raw JSP up until current technologies like Seam, a very basic pattern has always been the internal dispatch from the controller that initially accepted the reque...
TITLE: Protecting internal view layer template pages in servlet applications QUESTION: I have a very basic question about MVC web applications in Java. Since the olden days of raw JSP up until current technologies like Seam, a very basic pattern has always been the internal dispatch from the controller that initially ...
[ "java", "architecture", "servlets" ]
1
0
789
4
0
2008-10-01T02:31:34.147000
2010-01-12T01:06:58.110000
156,004
156,402
Is it possible to rename an SQL Server 2005 instance
I would like to change the name of my SQL Server instance. Is there a simple way of doing this or is a significant effort required? Note, this is a named instance - not the default instance.
I have seen a few makeshift ways of doing this, but I don't have confidence in any of them. I think I will simply install a new instance and transfer my information over.
Is it possible to rename an SQL Server 2005 instance I would like to change the name of my SQL Server instance. Is there a simple way of doing this or is a significant effort required? Note, this is a named instance - not the default instance.
TITLE: Is it possible to rename an SQL Server 2005 instance QUESTION: I would like to change the name of my SQL Server instance. Is there a simple way of doing this or is a significant effort required? Note, this is a named instance - not the default instance. ANSWER: I have seen a few makeshift ways of doing this, b...
[ "sql-server", "sql-server-2005" ]
6
0
6,457
5
0
2008-10-01T02:32:41.413000
2008-10-01T06:06:02.133000
156,009
156,063
Perl: Grabbing the nth and mth delimited words from each line in a file
Because of the more tedious way of adding hosts to be monitored in Nagios (it requires defining a host object, as opposed to the previous program which only required the IP and hostname), I figured it'd be best to automate this, and it'd be a great time to learn Perl, because all I know at the moment is C/C++ and Java....
The one-liner is great, if you're not writing more Perl to handle the result. More generally though, in the context of a larger Perl program, you would either write a custom regular expression, for example: if($line =~ m/(\S+)\s+(\S+)/) { $ip = $1; $hostname = $2; }... or you would use the split operator. my @arr = spl...
Perl: Grabbing the nth and mth delimited words from each line in a file Because of the more tedious way of adding hosts to be monitored in Nagios (it requires defining a host object, as opposed to the previous program which only required the IP and hostname), I figured it'd be best to automate this, and it'd be a great...
TITLE: Perl: Grabbing the nth and mth delimited words from each line in a file QUESTION: Because of the more tedious way of adding hosts to be monitored in Nagios (it requires defining a host object, as opposed to the previous program which only required the IP and hostname), I figured it'd be best to automate this, a...
[ "regex", "perl", "file-io" ]
9
9
13,324
7
0
2008-10-01T02:34:20.020000
2008-10-01T03:01:16.930000
156,013
156,050
Haskell syntax for a case expression in a do block
I can't quite figure out this syntax problem with a case expression in a do block. What is the correct syntax? If you could correct my example and explain it that would be the best. module Main where main = do putStrLn "This is a test" s <- foo putStrLn s foo = do args <- getArgs return case args of [] -> "No Args" [...
return is an (overloaded) function, and it's not expecting its first argument to be a keyword. You can either parenthesize: module Main where import System(getArgs) main = do putStrLn "This is a test" s <- foo putStrLn s foo = do args <- getArgs return (case args of [] -> "No Args" [s]-> "Some Args") or use the handy...
Haskell syntax for a case expression in a do block I can't quite figure out this syntax problem with a case expression in a do block. What is the correct syntax? If you could correct my example and explain it that would be the best. module Main where main = do putStrLn "This is a test" s <- foo putStrLn s foo = do ar...
TITLE: Haskell syntax for a case expression in a do block QUESTION: I can't quite figure out this syntax problem with a case expression in a do block. What is the correct syntax? If you could correct my example and explain it that would be the best. module Main where main = do putStrLn "This is a test" s <- foo putSt...
[ "haskell", "syntax", "monads" ]
29
36
22,667
2
0
2008-10-01T02:36:51.230000
2008-10-01T02:51:27.407000
156,032
156,639
How do you store Date ranges, which are actually timestamps
Java & Oracle both have a timestamp type called Date. Developers tend to manipulate these as if they were calendar dates, which I've seen cause nasty one-off bugs. For a basic date quantity you can simply chop off the time portion upon input, i.e., reduce the precision. But if you do that with a date range, (e.g.: 9/29...
Here's how we do it. Use timestamps. Use Half-open intervals for comparison: start <= now < end. Ignore the whiners who insist that BETWEEN is somehow essential to successful SQL. With this a series of date ranges is really easy to audit. The database value for 9/30 to 10/1 encompass one day (9/30). The next interval's...
How do you store Date ranges, which are actually timestamps Java & Oracle both have a timestamp type called Date. Developers tend to manipulate these as if they were calendar dates, which I've seen cause nasty one-off bugs. For a basic date quantity you can simply chop off the time portion upon input, i.e., reduce the ...
TITLE: How do you store Date ranges, which are actually timestamps QUESTION: Java & Oracle both have a timestamp type called Date. Developers tend to manipulate these as if they were calendar dates, which I've seen cause nasty one-off bugs. For a basic date quantity you can simply chop off the time portion upon input,...
[ "java", "oracle", "architecture", "types", "date-range" ]
7
7
6,016
11
0
2008-10-01T02:45:06.047000
2008-10-01T08:00:36.490000
156,035
170,048
How can you limit a TFS Check-In notes to a custom path?
You can limit "Check-In Policy" rules via the "Custom Paths" policy. But the "Check-in Notes" tab doesn't seem to fit in to the same system. Why isn't "Check-In notes" just another "Check-In policy"?? I'm using Team Foundation Server 2008 SP1
We had a similar problem some time ago. For some sub tree we wanted to require entering a code reviewer. I ended up implementing a custom policy and used the Custom Path Policy to restrict it to certain folders. That works well, except that you have to deploy your policy assembly and TFS has no built-in mechanism for t...
How can you limit a TFS Check-In notes to a custom path? You can limit "Check-In Policy" rules via the "Custom Paths" policy. But the "Check-in Notes" tab doesn't seem to fit in to the same system. Why isn't "Check-In notes" just another "Check-In policy"?? I'm using Team Foundation Server 2008 SP1
TITLE: How can you limit a TFS Check-In notes to a custom path? QUESTION: You can limit "Check-In Policy" rules via the "Custom Paths" policy. But the "Check-in Notes" tab doesn't seem to fit in to the same system. Why isn't "Check-In notes" just another "Check-In policy"?? I'm using Team Foundation Server 2008 SP1 A...
[ "tfs" ]
3
3
1,297
2
0
2008-10-01T02:46:44.140000
2008-10-04T09:30:23.667000
156,044
156,190
How do you manage database revisions on a medium sized project with branches?
At work we have 4 people working together on a few different projects. For each project we each have a local copy we work on and then there is a development, staging, and live deployment, along with any branches we have (we use subversion). Our database is MySQL. So my question is, what is a good way to manage which re...
If your database maps nicely to a set of data access objects, consider using 'migrations'. The idea is to store your data model as application code with steps for moving forward and backward through each database version. I believe Rails did it first. Java has at least one project. And here's a.NET migration library. T...
How do you manage database revisions on a medium sized project with branches? At work we have 4 people working together on a few different projects. For each project we each have a local copy we work on and then there is a development, staging, and live deployment, along with any branches we have (we use subversion). O...
TITLE: How do you manage database revisions on a medium sized project with branches? QUESTION: At work we have 4 people working together on a few different projects. For each project we each have a local copy we work on and then there is a development, staging, and live deployment, along with any branches we have (we ...
[ "version-control", "deployment", "project-management", "database-versioning" ]
11
2
2,709
3
0
2008-10-01T02:49:05.757000
2008-10-01T03:53:53.277000
156,046
157,843
Show a Form without stealing focus?
I'm using a Form to show notifications (it appears at the bottom right of the screen), but when I show this form it steals the focus from the main Form. Is there a way to show this "notification" form without stealing focus?
Hmmm, isn't simply overriding Form.ShowWithoutActivation enough? protected override bool ShowWithoutActivation { get { return true; } } And if you don't want the user to click this notification window either, you can override CreateParams: protected override CreateParams CreateParams { get { CreateParams baseParams = b...
Show a Form without stealing focus? I'm using a Form to show notifications (it appears at the bottom right of the screen), but when I show this form it steals the focus from the main Form. Is there a way to show this "notification" form without stealing focus?
TITLE: Show a Form without stealing focus? QUESTION: I'm using a Form to show notifications (it appears at the bottom right of the screen), but when I show this form it steals the focus from the main Form. Is there a way to show this "notification" form without stealing focus? ANSWER: Hmmm, isn't simply overriding Fo...
[ "c#", ".net", "winforms" ]
156
181
82,439
20
0
2008-10-01T02:49:25.833000
2008-10-01T14:21:18.713000
156,051
156,065
Update viewstate after populating a list with ASP.NET AJAX
I've got a dropdown list that is being populated via a webservice using ASP>NET AJAX. On the success callback of the method in javascript, I'm populating the dropdown via a loop: function populateDropDown(dropdownId, list, enable, showCount) { var dropdown = $get(dropdownId); dropdown.options.length = 1; for (var i = 0...
Although I'm not really sure how it does it the CascadingDropDown in the AJAX Control Toolkit does support this. This is the line that appears to do it: AjaxControlToolkit.CascadingDropDownBehavior.callBaseMethod(this, 'set_ClientState', [ this._selectedValue+':::'+text ]); But the simplest idea would be to put the sel...
Update viewstate after populating a list with ASP.NET AJAX I've got a dropdown list that is being populated via a webservice using ASP>NET AJAX. On the success callback of the method in javascript, I'm populating the dropdown via a loop: function populateDropDown(dropdownId, list, enable, showCount) { var dropdown = $g...
TITLE: Update viewstate after populating a list with ASP.NET AJAX QUESTION: I've got a dropdown list that is being populated via a webservice using ASP>NET AJAX. On the success callback of the method in javascript, I'm populating the dropdown via a loop: function populateDropDown(dropdownId, list, enable, showCount) {...
[ ".net", "asp.net", "javascript", "asp.net-ajax" ]
1
3
4,313
2
0
2008-10-01T02:51:47.670000
2008-10-01T03:01:22
156,083
156,088
How do screen scrapers work?
I hear people writing these programs all the time and I know what they do, but how do they actually do it? I'm looking for general concepts.
Technically, screenscraping is any program that grabs the display data of another program and ingests it for it's own use. Quite often, screenscaping refers to a web client that parses the HTML pages of targeted website to extract formatted data. This is done when a website does not offer an RSS feed or a REST API for ...
How do screen scrapers work? I hear people writing these programs all the time and I know what they do, but how do they actually do it? I'm looking for general concepts.
TITLE: How do screen scrapers work? QUESTION: I hear people writing these programs all the time and I know what they do, but how do they actually do it? I'm looking for general concepts. ANSWER: Technically, screenscraping is any program that grabs the display data of another program and ingests it for it's own use. ...
[ "screen-scraping" ]
19
24
22,500
9
0
2008-10-01T03:10:54.737000
2008-10-01T03:14:21.313000
156,084
156,104
Sorting ADO recordset text field as numeric
Using VBA i have a set of functions that return an ADODB.Recordset where all the columns as adVarChar. Unfortunately this means numerics get sorted as text. So 1,7,16,22 becomes 1,16,22,7 Is there any methods that can sort numerics as text columns without resorting to changing the type of the column? Sub TestSortVarCha...
Left pad with Zeros with at least as many as maximum number digits. e.g. 0001 0010 0022 1000 You can use Right$() to accomplish this.
Sorting ADO recordset text field as numeric Using VBA i have a set of functions that return an ADODB.Recordset where all the columns as adVarChar. Unfortunately this means numerics get sorted as text. So 1,7,16,22 becomes 1,16,22,7 Is there any methods that can sort numerics as text columns without resorting to changin...
TITLE: Sorting ADO recordset text field as numeric QUESTION: Using VBA i have a set of functions that return an ADODB.Recordset where all the columns as adVarChar. Unfortunately this means numerics get sorted as text. So 1,7,16,22 becomes 1,16,22,7 Is there any methods that can sort numerics as text columns without re...
[ "vba", "ado", "adodb" ]
3
3
6,546
2
0
2008-10-01T03:11:41.460000
2008-10-01T03:19:27.040000
156,113
156,365
LinqToSql and abstract base classes
I have some linq entities that inherit something like this: public abstract class EntityBase { public int Identifier { get; } } public interface IDeviceEntity { int DeviceId { get; set; } } public abstract class DeviceEntityBase: EntityBase, IDeviceEntity { public abstract int DeviceId { get; set; } } public partial...
LINQ-to-SQL has some support for inheritance via a discriminator ( here, here ), but you can only query on classes that are defined in the LINQ model - i.e. data classes themselves, and (more perhaps importantly for this example) the query itself must be phrased in terms of data classes: although TEntity is a data clas...
LinqToSql and abstract base classes I have some linq entities that inherit something like this: public abstract class EntityBase { public int Identifier { get; } } public interface IDeviceEntity { int DeviceId { get; set; } } public abstract class DeviceEntityBase: EntityBase, IDeviceEntity { public abstract int Devi...
TITLE: LinqToSql and abstract base classes QUESTION: I have some linq entities that inherit something like this: public abstract class EntityBase { public int Identifier { get; } } public interface IDeviceEntity { int DeviceId { get; set; } } public abstract class DeviceEntityBase: EntityBase, IDeviceEntity { public...
[ "c#", "linq-to-sql" ]
6
4
2,222
4
0
2008-10-01T03:23:07.877000
2008-10-01T05:43:47.553000
156,116
156,482
What's the CSS Filter alternative for Firefox?
I'm using CSS Filters to modify images on the fly within the browser. These work perfectly in Internet Explorer, but aren't supported in Firefox. Does anyone know what the CSS Filter equivalent for these is for Firefox? An answer that would work cross browser (Safari, WebKit, Firefox, etc.) would be preferred. Update: ...
Please check the Nihilogic Javascript Image Effect Library: supports IE and Fx pretty well has a lot of effects You can find many other effects in the CVI Projects: they are also JS based there's a Lab to experiment Good Luck
What's the CSS Filter alternative for Firefox? I'm using CSS Filters to modify images on the fly within the browser. These work perfectly in Internet Explorer, but aren't supported in Firefox. Does anyone know what the CSS Filter equivalent for these is for Firefox? An answer that would work cross browser (Safari, WebK...
TITLE: What's the CSS Filter alternative for Firefox? QUESTION: I'm using CSS Filters to modify images on the fly within the browser. These work perfectly in Internet Explorer, but aren't supported in Firefox. Does anyone know what the CSS Filter equivalent for these is for Firefox? An answer that would work cross bro...
[ "css", "internet-explorer", "firefox", "cross-browser", "filter" ]
10
6
30,408
9
0
2008-10-01T03:23:56.437000
2008-10-01T06:41:26.540000
156,120
159,274
Source code management strategies - branching, tagging, forking, etc. - for web apps
This posting here ( How do you manage database revisions on a medium sized project with branches? ) got me wondering how best to work on a web project using branching and deploying to dev, staging, and production (along with local copies). We don't have "releases" per se: if a feature is big enough to be noticeable, we...
Branching is handy if you expect the work to NOT be completed on time, and you do not have a sufficient body of tests to make continuous integration work. I tend to see branch-crazy development in shops where the programming tasks are far too big to complete predictably and so management wants to wait until just before...
Source code management strategies - branching, tagging, forking, etc. - for web apps This posting here ( How do you manage database revisions on a medium sized project with branches? ) got me wondering how best to work on a web project using branching and deploying to dev, staging, and production (along with local copi...
TITLE: Source code management strategies - branching, tagging, forking, etc. - for web apps QUESTION: This posting here ( How do you manage database revisions on a medium sized project with branches? ) got me wondering how best to work on a web project using branching and deploying to dev, staging, and production (alo...
[ "svn", "git", "version-control", "web-applications", "branch" ]
2
2
4,034
4
0
2008-10-01T03:25:16.653000
2008-10-01T19:21:08.743000
156,133
156,200
Loading XHTML fragments over AJAX with jQuery
I'm trying to load fragments of XHTML markup using jQuery's $.fn.load function, but it raises an error trying to add the new markup into the DOM. I've narrowed this down to the XML declaration ( ) -- the view works if I return static text without the declaration. I don't understand why this would cause failure, or if t...
Try this instead (I just did a quick test and it seems to work): $body = $("#div-to-fill"); $.get ("/testfile.xhtml", function (data) { $body.html($(data).children()); }, 'xml'); Basically,.children() will get you the root node and replace the content of your div with it. I guess you can't exactly insert an xml documen...
Loading XHTML fragments over AJAX with jQuery I'm trying to load fragments of XHTML markup using jQuery's $.fn.load function, but it raises an error trying to add the new markup into the DOM. I've narrowed this down to the XML declaration ( ) -- the view works if I return static text without the declaration. I don't un...
TITLE: Loading XHTML fragments over AJAX with jQuery QUESTION: I'm trying to load fragments of XHTML markup using jQuery's $.fn.load function, but it raises an error trying to add the new markup into the DOM. I've narrowed this down to the XML declaration ( ) -- the view works if I return static text without the decla...
[ "jquery", "ajax", "xhtml" ]
9
15
9,862
1
0
2008-10-01T03:29:52.773000
2008-10-01T03:59:50.237000
156,165
156,211
Best way to render hand-drawn figures
I guess I'll illustrate with an example: In this game you are able to draw 2D shapes using the mouse and what you draw is rendered to the screen in real-time. I want to know what the best ways are to render this type of drawing using hardware acceleration (OpenGL). I had two ideas: Create a screen-size texture when dra...
I love crayon physics (music gets me every time). Great game! But back to the point... He has created brush sprites that follow your mouse position. He's created a few brushes that account for a little variation. Once the mouse goes down, I imagine he is adding these sprites to a data structure and sending that structu...
Best way to render hand-drawn figures I guess I'll illustrate with an example: In this game you are able to draw 2D shapes using the mouse and what you draw is rendered to the screen in real-time. I want to know what the best ways are to render this type of drawing using hardware acceleration (OpenGL). I had two ideas:...
TITLE: Best way to render hand-drawn figures QUESTION: I guess I'll illustrate with an example: In this game you are able to draw 2D shapes using the mouse and what you draw is rendered to the screen in real-time. I want to know what the best ways are to render this type of drawing using hardware acceleration (OpenGL)...
[ "opengl", "graphics", "rendering" ]
1
2
1,658
3
0
2008-10-01T03:44:18.807000
2008-10-01T04:08:02.057000
156,176
156,187
How do you measure if an interface change improved or reduced usability?
For an ecommerce website how do you measure if a change to your site actually improved usability? What kind of measurements should you gather and how would you set up a framework for making this testing part of development?
Multivariate testing and reporting is a great way to actually measure these kind of things. It allows you to test what combination of page elements has the greatest conversion rate, providing continual improvement on your site design and usability. Google Web Optimiser has support for this.
How do you measure if an interface change improved or reduced usability? For an ecommerce website how do you measure if a change to your site actually improved usability? What kind of measurements should you gather and how would you set up a framework for making this testing part of development?
TITLE: How do you measure if an interface change improved or reduced usability? QUESTION: For an ecommerce website how do you measure if a change to your site actually improved usability? What kind of measurements should you gather and how would you set up a framework for making this testing part of development? ANSW...
[ "statistics", "e-commerce", "usability", "testing-strategies" ]
2
2
430
5
0
2008-10-01T03:47:08.613000
2008-10-01T03:53:44.697000
156,177
156,184
How do you update an object with Linq 2 SQL without rowversion or timestamp?
I'm trying to take a POCO object and update it with Linq2SQL using an XML mapping file... This what what I have: using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Business.Objects { public class AchievementType { public int Id { get; set; } public string Name { get; set; }...
Bah, right after I asked I found some documentation on it. Since Context isn't tracking the changes, you need to do the following: ctx.Refresh(RefreshMode.KeepCurrentValues, entities);
How do you update an object with Linq 2 SQL without rowversion or timestamp? I'm trying to take a POCO object and update it with Linq2SQL using an XML mapping file... This what what I have: using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Business.Objects { public class A...
TITLE: How do you update an object with Linq 2 SQL without rowversion or timestamp? QUESTION: I'm trying to take a POCO object and update it with Linq2SQL using an XML mapping file... This what what I have: using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Business.Object...
[ "c#", "linq-to-sql", ".net-3.5" ]
0
2
1,557
1
0
2008-10-01T03:48:05.600000
2008-10-01T03:53:02.407000
156,181
156,185
Retrieve only a portion of a matched string using regex in Javascript
I've got a string like foo (123) bar I want to retrieve all numbers surrounded with the delimiters ( and ). If I use varname.match(/\([0-9]+\)/), my delimiters are included in the response, and I get "(123)" when what I really want is "123". How can I retrieve only a portion of the matched string without following it u...
Yes, use capturing (non-escaped) parens: varname.match(/\(([0-9]+)\)/)[1]
Retrieve only a portion of a matched string using regex in Javascript I've got a string like foo (123) bar I want to retrieve all numbers surrounded with the delimiters ( and ). If I use varname.match(/\([0-9]+\)/), my delimiters are included in the response, and I get "(123)" when what I really want is "123". How can ...
TITLE: Retrieve only a portion of a matched string using regex in Javascript QUESTION: I've got a string like foo (123) bar I want to retrieve all numbers surrounded with the delimiters ( and ). If I use varname.match(/\([0-9]+\)/), my delimiters are included in the response, and I get "(123)" when what I really want ...
[ "javascript", "regex" ]
4
7
254
1
0
2008-10-01T03:49:09.840000
2008-10-01T03:53:11.953000
156,212
156,229
Reorder PDF Page Order
Is it possible to reorder an already generated PDF file programmatically, and using as little resources as possible, as this will need to be ran on ~8000 PDFs every month or so? We are currently using iTextSharp to merge the PDF’s in to larger PDF’s, but iTextsharp’s Documentation does not really explain much.
I've used iTextSharp -- check out this code sample, it's what I used to write a (simpler) splitting utility. I've used this on over 10,000 PDFs in a shot, and I can't remember the exact performance, but it was certainly acceptable for a batch job.
Reorder PDF Page Order Is it possible to reorder an already generated PDF file programmatically, and using as little resources as possible, as this will need to be ran on ~8000 PDFs every month or so? We are currently using iTextSharp to merge the PDF’s in to larger PDF’s, but iTextsharp’s Documentation does not really...
TITLE: Reorder PDF Page Order QUESTION: Is it possible to reorder an already generated PDF file programmatically, and using as little resources as possible, as this will need to be ran on ~8000 PDFs every month or so? We are currently using iTextSharp to merge the PDF’s in to larger PDF’s, but iTextsharp’s Documentati...
[ "c#", ".net", "pdf" ]
2
1
2,831
2
0
2008-10-01T04:09:47.950000
2008-10-01T04:23:54.937000
156,213
163,528
What is a decent beginner graph puzzle?
I'm trying to get more acquainted with problems that require Graphs to be solved (are are best solved by graphs). If someone has an old ACM Programming Competition problem that utilized graphs, or have another problem that they found particularly enlightening as they worked it out I would appreciate it. I want to famil...
I found this book to be extremely useful (Amazon Link): Programming Challenges Not only does it give a pretty indepth explanation of graphs, trees, basic data structures it gives a handful of programming challenges involving each type! This document is more useful to me than my textbook! Here are some of the Graph Prob...
What is a decent beginner graph puzzle? I'm trying to get more acquainted with problems that require Graphs to be solved (are are best solved by graphs). If someone has an old ACM Programming Competition problem that utilized graphs, or have another problem that they found particularly enlightening as they worked it ou...
TITLE: What is a decent beginner graph puzzle? QUESTION: I'm trying to get more acquainted with problems that require Graphs to be solved (are are best solved by graphs). If someone has an old ACM Programming Competition problem that utilized graphs, or have another problem that they found particularly enlightening as...
[ "algorithm", "graph-theory" ]
2
1
2,009
6
0
2008-10-01T04:11:14.157000
2008-10-02T17:22:17.833000
156,243
156,289
Object allocate and init in Objective C
What is the difference between the following 2 ways to allocate and init an object? AController *tempAController = [[AController alloc] init]; self.aController = tempAController; [tempAController release]; and self.aController= [[AController alloc] init]; Most of the apple example use the first method. Why would you al...
Every object has a reference count. When it goes to 0, the object is deallocated. Assuming the property was declared as @property (retain): Your first example, line by line: The object is created by alloc, it has a reference count of 1. The object is handed over to self 's setAController: method, which sends it a retai...
Object allocate and init in Objective C What is the difference between the following 2 ways to allocate and init an object? AController *tempAController = [[AController alloc] init]; self.aController = tempAController; [tempAController release]; and self.aController= [[AController alloc] init]; Most of the apple exampl...
TITLE: Object allocate and init in Objective C QUESTION: What is the difference between the following 2 ways to allocate and init an object? AController *tempAController = [[AController alloc] init]; self.aController = tempAController; [tempAController release]; and self.aController= [[AController alloc] init]; Most o...
[ "objective-c", "cocoa", "cocoa-touch", "memory-management" ]
56
71
34,565
6
0
2008-10-01T04:31:43.607000
2008-10-01T04:54:29.090000
156,248
156,264
Notification of object destruction in Ruby
I have written a custom Rails model. This model is backed by an actually server not by a database table (so it does not inherit from ActiveRecord::Base ). In order to get the requested information from the server I open a SSH connection to it. Because rails does not reuse object a new object, as well as a new SSH conne...
If you need to control what happens when an object is destroyed, you really should be explicitly destroying it yourself - this is by design. You're not supposed to be able to destroy an object explicitly either - this is also by design. In other words, from the perspective of your program, an object is never destroyed ...
Notification of object destruction in Ruby I have written a custom Rails model. This model is backed by an actually server not by a database table (so it does not inherit from ActiveRecord::Base ). In order to get the requested information from the server I open a SSH connection to it. Because rails does not reuse obje...
TITLE: Notification of object destruction in Ruby QUESTION: I have written a custom Rails model. This model is backed by an actually server not by a database table (so it does not inherit from ActiveRecord::Base ). In order to get the requested information from the server I open a SSH connection to it. Because rails d...
[ "ruby-on-rails", "ruby", "garbage-collection" ]
16
21
6,920
1
0
2008-10-01T04:34:34.817000
2008-10-01T04:45:23.043000
156,257
156,420
AI Applications in C++: How costly are virtual functions? What are the possible optimizations?
In an AI application I am writing in C++, there is not much numerical computation there are lot of structures for which run-time polymorphism is needed very often, several polymorphic structures interact during computation In such a situation, are there any optimization techniques? While I won't care to optimize the ap...
Virtual functions are very efficient. Assuming 32 bit pointers the memory layout is approximately: classptr -> [vtable:4][classdata:x] vtable -> [first:4][second:4][third:4][fourth:4][...] first -> [code:x] second -> [code:x]... The classptr points to memory that is typically on the heap, occasionally on the stack, and...
AI Applications in C++: How costly are virtual functions? What are the possible optimizations? In an AI application I am writing in C++, there is not much numerical computation there are lot of structures for which run-time polymorphism is needed very often, several polymorphic structures interact during computation In...
TITLE: AI Applications in C++: How costly are virtual functions? What are the possible optimizations? QUESTION: In an AI application I am writing in C++, there is not much numerical computation there are lot of structures for which run-time polymorphism is needed very often, several polymorphic structures interact dur...
[ "c++", "optimization" ]
17
28
6,524
15
0
2008-10-01T04:41:49.963000
2008-10-01T06:17:25.163000
156,275
156,685
What is the equivalent of the C++ Pair<L,R> in Java?
Is there a good reason why there is no Pair in Java? What would be the equivalent of this C++ construct? I would rather avoid reimplementing my own. It seems that 1.6 is providing something similar ( AbstractMap.SimpleEntry ), but this looks quite convoluted.
In a thread on comp.lang.java.help, Hunter Gratzner gives some arguments against the presence of a Pair construct in Java. The main argument is that a class Pair doesn't convey any semantics about the relationship between the two values (how do you know what "first" and "second" mean?). A better practice is to write a ...
What is the equivalent of the C++ Pair<L,R> in Java? Is there a good reason why there is no Pair in Java? What would be the equivalent of this C++ construct? I would rather avoid reimplementing my own. It seems that 1.6 is providing something similar ( AbstractMap.SimpleEntry ), but this looks quite convoluted.
TITLE: What is the equivalent of the C++ Pair<L,R> in Java? QUESTION: Is there a good reason why there is no Pair in Java? What would be the equivalent of this C++ construct? I would rather avoid reimplementing my own. It seems that 1.6 is providing something similar ( AbstractMap.SimpleEntry ), but this looks quite c...
[ "java", "tuples", "std-pair" ]
716
425
503,951
37
0
2008-10-01T04:48:41.553000
2008-10-01T08:18:24.500000
156,278
156,321
Does setbuf() affect cout?
Yet again, my teacher was unable to answer my question. I knew who may be able to... So, I've never really learned C. In C++, I would, obviously, use a cout statement all of the time. In a recent assignment, my teacher told us to make sure to put setbuf( stdout, NULL ); at the top of main() in order to get an unbuffere...
By default, iostreams and stdio are synchronised. Reference. This doesn't mean that manually adjusting the stdio buffering is a good idea, though! You may wish to utilise std::endl or std::flush (from ), which may help you. e.g., std::cout << "Hello, world!" << std::endl; or std::cout << "Hello, world!\n" << std::flush...
Does setbuf() affect cout? Yet again, my teacher was unable to answer my question. I knew who may be able to... So, I've never really learned C. In C++, I would, obviously, use a cout statement all of the time. In a recent assignment, my teacher told us to make sure to put setbuf( stdout, NULL ); at the top of main() i...
TITLE: Does setbuf() affect cout? QUESTION: Yet again, my teacher was unable to answer my question. I knew who may be able to... So, I've never really learned C. In C++, I would, obviously, use a cout statement all of the time. In a recent assignment, my teacher told us to make sure to put setbuf( stdout, NULL ); at t...
[ "c++", "class-library" ]
2
5
3,221
3
0
2008-10-01T04:49:53.750000
2008-10-01T05:20:48.403000
156,279
156,479
How to import a SQL Server .bak file into MySQL?
The title is self explanatory. Is there a way of directly doing such kind of importing?
The.BAK files from SQL server are in Microsoft Tape Format (MTF) ref: http://www.fpns.net/willy/msbackup.htm The bak file will probably contain the LDF and MDF files that SQL server uses to store the database. You will need to use SQL server to extract these. SQL Server Express is free and will do the job. So, install ...
How to import a SQL Server .bak file into MySQL? The title is self explanatory. Is there a way of directly doing such kind of importing?
TITLE: How to import a SQL Server .bak file into MySQL? QUESTION: The title is self explanatory. Is there a way of directly doing such kind of importing? ANSWER: The.BAK files from SQL server are in Microsoft Tape Format (MTF) ref: http://www.fpns.net/willy/msbackup.htm The bak file will probably contain the LDF and ...
[ "mysql", "sql-server", "migration", "backup" ]
77
75
257,835
10
0
2008-10-01T04:49:53.797000
2008-10-01T06:39:07.780000
156,280
164,566
Using Mercurial, is there an easy way to diff my working copy with the tip file in the default remote repository
When using mercurial, I'd like to be able to diff the working copy of a file with the tip file in my default remote repository. Is there an easy way to do this? I know I can do an "hg incoming -p" to see the patch sets of changes coming in, but it'd be nice to just directly see the actual changes for a particular file ...
After some digging, I came across the Rdiff extension that does most of what I want it to. It doesn't come with mercurial, but it can be installed by cloning the repository: hg clone http://hg.kublai.com/mercurial/extensions/rdiff And then modifing your ~/.hgrc file to load the extension: [extensions] rdiff=~/path/to/r...
Using Mercurial, is there an easy way to diff my working copy with the tip file in the default remote repository When using mercurial, I'd like to be able to diff the working copy of a file with the tip file in my default remote repository. Is there an easy way to do this? I know I can do an "hg incoming -p" to see the...
TITLE: Using Mercurial, is there an easy way to diff my working copy with the tip file in the default remote repository QUESTION: When using mercurial, I'd like to be able to diff the working copy of a file with the tip file in my default remote repository. Is there an easy way to do this? I know I can do an "hg incom...
[ "svn", "http", "mercurial", "diff", "scp" ]
13
5
3,424
4
0
2008-10-01T04:50:20.817000
2008-10-02T20:57:34.837000
156,292
156,400
How should I order my ctor parameters for DI/IOC?
I'm a bit of a DI newbie, so forgive me if this is the wrong approach or a silly question. Let's say I have a form which creates/updates an order, and I know it's going to need to retrieve a list of products and customers to display. I want to pass in the Order object that it's editing, but I also want to inject the Pr...
I disagree with @aku's answer. I think what you're doing is fine and there are also other ways to do it that are no more or less right. For instance, one may question whether this object should be depending on services in the first place. Regardless of DI, I feel it is helpful to clarify in your mind at least the kind ...
How should I order my ctor parameters for DI/IOC? I'm a bit of a DI newbie, so forgive me if this is the wrong approach or a silly question. Let's say I have a form which creates/updates an order, and I know it's going to need to retrieve a list of products and customers to display. I want to pass in the Order object t...
TITLE: How should I order my ctor parameters for DI/IOC? QUESTION: I'm a bit of a DI newbie, so forgive me if this is the wrong approach or a silly question. Let's say I have a form which creates/updates an order, and I know it's going to need to retrieve a list of products and customers to display. I want to pass in ...
[ "dependency-injection", "inversion-of-control" ]
5
4
870
4
0
2008-10-01T04:57:13.593000
2008-10-01T06:05:17.393000
156,304
156,319
C# Attributes On Fields
How do I set an attribute on a field anywhere in my assembly, then reflect on those field attributes in my entire assembly and get/set the field values that the attribute is attached too?
1) Create custom attribute targeted for fields 2) Add it to desired fields 3) Iterate through types defined in your assembly 4) For each type: 4a) iterate through it's fields 4b) if field has your custom attribute go to step 4c 4c) get or set values of field
C# Attributes On Fields How do I set an attribute on a field anywhere in my assembly, then reflect on those field attributes in my entire assembly and get/set the field values that the attribute is attached too?
TITLE: C# Attributes On Fields QUESTION: How do I set an attribute on a field anywhere in my assembly, then reflect on those field attributes in my entire assembly and get/set the field values that the attribute is attached too? ANSWER: 1) Create custom attribute targeted for fields 2) Add it to desired fields 3) Ite...
[ ".net", "custom-attributes" ]
13
24
10,484
1
0
2008-10-01T05:07:43.100000
2008-10-01T05:18:31.390000
156,315
156,323
Mask redirect to temporary domain with mod_rewrite
We are putting up a company blog at companyname.com/blog but for now the blog is a Wordpress installation that lives on a different server (blog.companyname.com). The intention is to have the blog and web site both on the same server in a month or two, but that leaves a problem in the interim. At the moment I am using ...
Rather than using mod_rewrite, you could use mod_proxy to set up a reverse proxy on companyname.com, so that requests to http://companyname.com/blog/article-name are proxied (rather than redirected) to http://blog.companyname.com/article-name. Here are more instructions and examples.
Mask redirect to temporary domain with mod_rewrite We are putting up a company blog at companyname.com/blog but for now the blog is a Wordpress installation that lives on a different server (blog.companyname.com). The intention is to have the blog and web site both on the same server in a month or two, but that leaves ...
TITLE: Mask redirect to temporary domain with mod_rewrite QUESTION: We are putting up a company blog at companyname.com/blog but for now the blog is a Wordpress installation that lives on a different server (blog.companyname.com). The intention is to have the blog and web site both on the same server in a month or two...
[ "apache", "url", "mod-rewrite", "url-rewriting" ]
2
3
2,719
3
0
2008-10-01T05:14:32.240000
2008-10-01T05:22:45.997000
156,329
156,670
unwanted leading blank space on oracle number format
I need to pad numbers with leading zeros (total 8 digits) for display. I'm using oracle. select to_char(1011,'00000000') OPE_NO from dual; select length(to_char(1011,'00000000')) OPE_NO from dual; Instead of '00001011' I get ' 00001011'. Why do I get an extra leading blank space? What is the correct number formatting s...
Use FM (Fill Mode), e.g. select to_char(1011,'FM00000000') OPE_NO from dual;
unwanted leading blank space on oracle number format I need to pad numbers with leading zeros (total 8 digits) for display. I'm using oracle. select to_char(1011,'00000000') OPE_NO from dual; select length(to_char(1011,'00000000')) OPE_NO from dual; Instead of '00001011' I get ' 00001011'. Why do I get an extra leading...
TITLE: unwanted leading blank space on oracle number format QUESTION: I need to pad numbers with leading zeros (total 8 digits) for display. I'm using oracle. select to_char(1011,'00000000') OPE_NO from dual; select length(to_char(1011,'00000000')) OPE_NO from dual; Instead of '00001011' I get ' 00001011'. Why do I ge...
[ "sql", "oracle" ]
18
33
17,366
2
0
2008-10-01T05:24:23.543000
2008-10-01T08:11:33.347000
156,330
157,423
Get timer ticks in Python
I'm just trying to time a piece of code. The pseudocode looks like: start = get_ticks() do_long_code() print "It took " + (get_ticks() - start) + " seconds." How does this look in Python? More specifically, how do I get the number of ticks since midnight (or however Python organizes that timing)?
In the time module, there are two timing functions: time and clock. time gives you "wall" time, if this is what you care about. However, the python docs say that clock should be used for benchmarking. Note that clock behaves different in separate systems: on MS Windows, it uses the Win32 function QueryPerformanceCounte...
Get timer ticks in Python I'm just trying to time a piece of code. The pseudocode looks like: start = get_ticks() do_long_code() print "It took " + (get_ticks() - start) + " seconds." How does this look in Python? More specifically, how do I get the number of ticks since midnight (or however Python organizes that timin...
TITLE: Get timer ticks in Python QUESTION: I'm just trying to time a piece of code. The pseudocode looks like: start = get_ticks() do_long_code() print "It took " + (get_ticks() - start) + " seconds." How does this look in Python? More specifically, how do I get the number of ticks since midnight (or however Python or...
[ "python", "timer" ]
45
37
122,100
6
0
2008-10-01T05:24:38.333000
2008-10-01T12:49:11.290000
156,338
156,345
Does a (.net) COM+ assembly need to be installed in the GAC?
I have a.net assembly that has a COM+ ServicedCopmonent in it and at the moment I install it into the GAC to get everything working. This means that I need to have every assembly that it references in the GAC as well. During development it is quite painful to make changes to thes assemblies, re-install them to the GAC ...
No, you don't have to install it in the GAC. You can use regsvcs ( http://msdn.microsoft.com/en-us/library/04za0hca.aspx ) with /appdir parameter to specify explicitly where the app is located.
Does a (.net) COM+ assembly need to be installed in the GAC? I have a.net assembly that has a COM+ ServicedCopmonent in it and at the moment I install it into the GAC to get everything working. This means that I need to have every assembly that it references in the GAC as well. During development it is quite painful to...
TITLE: Does a (.net) COM+ assembly need to be installed in the GAC? QUESTION: I have a.net assembly that has a COM+ ServicedCopmonent in it and at the moment I install it into the GAC to get everything working. This means that I need to have every assembly that it references in the GAC as well. During development it i...
[ ".net", "gac", "com+" ]
13
10
1,475
2
0
2008-10-01T05:27:54.377000
2008-10-01T05:31:15.383000
156,360
156,736
Get all items from thread Queue
I have one thread that writes results into a Queue. In another thread (GUI), I periodically (in the IDLE event) check if there are results in the queue, like this: def queue_get_all(q): items = [] while 1: try: items.append(q.get_nowait()) except Empty, e: break return items Is this a good way to do it? Edit: I'm askin...
I'd be very surprised if the get_nowait() call caused the pause by not returning if the list was empty. Could it be that you're posting a large number of (maybe big?) items between checks which means the receiving thread has a large amount of data to pull out of the Queue? You could try limiting the number you retrieve...
Get all items from thread Queue I have one thread that writes results into a Queue. In another thread (GUI), I periodically (in the IDLE event) check if there are results in the queue, like this: def queue_get_all(q): items = [] while 1: try: items.append(q.get_nowait()) except Empty, e: break return items Is this a go...
TITLE: Get all items from thread Queue QUESTION: I have one thread that writes results into a Queue. In another thread (GUI), I periodically (in the IDLE event) check if there are results in the queue, like this: def queue_get_all(q): items = [] while 1: try: items.append(q.get_nowait()) except Empty, e: break return ...
[ "python", "multithreading", "queue" ]
20
9
42,501
6
0
2008-10-01T05:40:06.080000
2008-10-01T08:45:02.640000
156,362
156,927
What is the difference between include and extend in Ruby?
Just getting my head around Ruby metaprogramming. The mixin/modules always manage to confuse me. include: mixes in specified module methods as instance methods in the target class extend: mixes in specified module methods as class methods in the target class So is the major difference just this or is a bigger dragon lu...
What you have said is correct. However, there is more to it than that. If you have a class Klazz and module Mod, including Mod in Klazz gives instances of Klazz access to Mod 's methods. Or you can extend Klazz with Mod giving the class Klazz access to Mod 's methods. But you can also extend an arbitrary object with o....
What is the difference between include and extend in Ruby? Just getting my head around Ruby metaprogramming. The mixin/modules always manage to confuse me. include: mixes in specified module methods as instance methods in the target class extend: mixes in specified module methods as class methods in the target class So...
TITLE: What is the difference between include and extend in Ruby? QUESTION: Just getting my head around Ruby metaprogramming. The mixin/modules always manage to confuse me. include: mixes in specified module methods as instance methods in the target class extend: mixes in specified module methods as class methods in t...
[ "ruby", "module", "include", "extend" ]
484
284
114,820
8
0
2008-10-01T05:40:58.463000
2008-10-01T09:59:38.203000
156,372
156,414
in-house projects: to stable release or not?
Suppose you work at a medium-to-large software company with many independently-developed projects (independent coders) but which rely on each other (dependent code). If it were up to you, would you make sure each project produced stable branches so that the other projects could more reliably use those branches, or woul...
As always, there are pros and cons for each of the options. Using branches may be more stable but it requires more maintenance when you're required to update to a newer branch. It also requires their development team to spent extra time when the branch is merged with the trunk. On the other hand, using the trunk may fo...
in-house projects: to stable release or not? Suppose you work at a medium-to-large software company with many independently-developed projects (independent coders) but which rely on each other (dependent code). If it were up to you, would you make sure each project produced stable branches so that the other projects co...
TITLE: in-house projects: to stable release or not? QUESTION: Suppose you work at a medium-to-large software company with many independently-developed projects (independent coders) but which rely on each other (dependent code). If it were up to you, would you make sure each project produced stable branches so that the...
[ "svn" ]
4
3
171
3
0
2008-10-01T05:48:58.850000
2008-10-01T06:10:11.657000
156,373
156,382
Using .reset() to free a boost::shared_ptr with sole ownership
I'm storing an object ( TTF_Font ) in a shared_ptr that is provided to me from a third-party API. I cannot use new or delete on the object, so the shared_ptr is also provided a "freeing" functor. // Functor struct CloseFont { void operator()(TTF_Font* font) const { if(font!= NULL) { TTF_CloseFont(font); } } }; boost::...
shared_ptr<>::reset() will drop the refcount by one. If that results in the count dropping to zero, the resource pointed to by the shared_ptr<> will be freed. So I think the answer for you is, yes that will work. Or you can simply let the screenFont variable be destructed due to dropping out of scope or whatever, if th...
Using .reset() to free a boost::shared_ptr with sole ownership I'm storing an object ( TTF_Font ) in a shared_ptr that is provided to me from a third-party API. I cannot use new or delete on the object, so the shared_ptr is also provided a "freeing" functor. // Functor struct CloseFont { void operator()(TTF_Font* font)...
TITLE: Using .reset() to free a boost::shared_ptr with sole ownership QUESTION: I'm storing an object ( TTF_Font ) in a shared_ptr that is provided to me from a third-party API. I cannot use new or delete on the object, so the shared_ptr is also provided a "freeing" functor. // Functor struct CloseFont { void operator...
[ "c++", "memory-management", "boost", "sdl-image" ]
7
16
21,706
2
0
2008-10-01T05:49:11.160000
2008-10-01T05:53:37.687000
156,394
156,408
Method access in Ruby
How is it that Ruby allows a class access methods outside of the class implicitly? Example: class Candy def land homer end end def homer puts "Hello" end Candy.new.land #Outputs Hello
The definition of the "homer" method is adding the method to the Object class. It is not defining a free function. Class Candy implicitly inherits from Object, and so has access to the methods in Object. When you call "homer" in the "land" method, the method resolution can't find a definition in the current class, goes...
Method access in Ruby How is it that Ruby allows a class access methods outside of the class implicitly? Example: class Candy def land homer end end def homer puts "Hello" end Candy.new.land #Outputs Hello
TITLE: Method access in Ruby QUESTION: How is it that Ruby allows a class access methods outside of the class implicitly? Example: class Candy def land homer end end def homer puts "Hello" end Candy.new.land #Outputs Hello ANSWER: The definition of the "homer" method is adding the method to the Object class. It is ...
[ "ruby", "methods" ]
9
24
3,581
4
0
2008-10-01T05:59:54.770000
2008-10-01T06:08:02.923000
156,395
156,463
Sending a message to nil in Objective-C
As a Java developer who is reading Apple's Objective-C 2.0 documentation: I wonder what " sending a message to nil " means - let alone how it is actually useful. Taking an excerpt from the documentation: There are several patterns in Cocoa that take advantage of this fact. The value returned from a message to nil may a...
Well, I think it can be described using a very contrived example. Let's say you have a method in Java which prints out all of the elements in an ArrayList: void foo(ArrayList list) { for(int i = 0; i < list.size(); ++i){ System.out.println(list.get(i).toString()); } } Now, if you call that method like so: someObject.fo...
Sending a message to nil in Objective-C As a Java developer who is reading Apple's Objective-C 2.0 documentation: I wonder what " sending a message to nil " means - let alone how it is actually useful. Taking an excerpt from the documentation: There are several patterns in Cocoa that take advantage of this fact. The va...
TITLE: Sending a message to nil in Objective-C QUESTION: As a Java developer who is reading Apple's Objective-C 2.0 documentation: I wonder what " sending a message to nil " means - let alone how it is actually useful. Taking an excerpt from the documentation: There are several patterns in Cocoa that take advantage of...
[ "objective-c" ]
107
93
51,232
11
0
2008-10-01T06:00:47.357000
2008-10-01T06:32:29.183000
156,430
156,441
Is regular expression recognition of an email address hard?
I recently read somewhere that writing a regexp to match an email address, taking into account all the variations and possibilities of the standard is extremely hard and is significantly more complicated than what one would initially assume. Why is that? Are there any known and proven regexps that actually do this full...
For the formal e-mail spec, yes, it is technically impossible via Regex due to the recursion of things like comments (especially if you don't remove comments to whitespace first), and the various different formats (an e-mail address isn't always someone@somewhere.tld). You can get close (with some massive and incompreh...
Is regular expression recognition of an email address hard? I recently read somewhere that writing a regexp to match an email address, taking into account all the variations and possibilities of the standard is extremely hard and is significantly more complicated than what one would initially assume. Why is that? Are t...
TITLE: Is regular expression recognition of an email address hard? QUESTION: I recently read somewhere that writing a regexp to match an email address, taking into account all the variations and possibilities of the standard is extremely hard and is significantly more complicated than what one would initially assume. ...
[ "regex", "email", "validation", "textmatching" ]
62
65
21,995
19
0
2008-10-01T06:22:22.233000
2008-10-01T06:26:38.853000
156,436
156,611
Sorting a collection in classic ASP
It's quite a simple question - how do I sort a collection? I've got a CSV file with rows in a random order. I'd like to sort the rows according to the date in one column. Do I add the rows to a recordset? Can I sort with a Scripting.Dictionary? I've clearly been spoilt with.NET and Linq, and now I find myself back in t...
In this case I would get help from big brother.net. It's possible to use System.Collections.Sortedlist within your ASP app and get your key value pairs sorted. set list = server.createObject("System.Collections.Sortedlist") with list.add "something", "YY".add "something else", "XX" end with for i = 0 to list.count - 1...
Sorting a collection in classic ASP It's quite a simple question - how do I sort a collection? I've got a CSV file with rows in a random order. I'd like to sort the rows according to the date in one column. Do I add the rows to a recordset? Can I sort with a Scripting.Dictionary? I've clearly been spoilt with.NET and L...
TITLE: Sorting a collection in classic ASP QUESTION: It's quite a simple question - how do I sort a collection? I've got a CSV file with rows in a random order. I'd like to sort the rows according to the date in one column. Do I add the rows to a recordset? Can I sort with a Scripting.Dictionary? I've clearly been spo...
[ "sorting", "asp-classic" ]
8
18
11,208
5
0
2008-10-01T06:24:39.700000
2008-10-01T07:50:42.957000
156,438
156,458
What Does It Mean For a C++ Function To Be Inline?
See title: what does it mean for a C++ function to be inline?
The function is placed in the code, rather than being called, similar to using macros (conceptually). This can improve speed (no function call), but causes code bloat (if the function is used 100 times, you now have 100 copies). You should note this does not force the compiler to make the function inline, and it will i...
What Does It Mean For a C++ Function To Be Inline? See title: what does it mean for a C++ function to be inline?
TITLE: What Does It Mean For a C++ Function To Be Inline? QUESTION: See title: what does it mean for a C++ function to be inline? ANSWER: The function is placed in the code, rather than being called, similar to using macros (conceptually). This can improve speed (no function call), but causes code bloat (if the funct...
[ "c++", "inline-functions" ]
33
39
22,012
9
0
2008-10-01T06:25:18.093000
2008-10-01T06:30:10.157000
156,445
156,454
Is buffer overflow/overrun possible in completely managed asp.net c# web application
Can there be buffer overflow/overrun vulnerabilities in completely managed asp.net web portal.If yes how can this be tested.
Not unless you exploit the webserver or.NET/ASP.NET stack itself.
Is buffer overflow/overrun possible in completely managed asp.net c# web application Can there be buffer overflow/overrun vulnerabilities in completely managed asp.net web portal.If yes how can this be tested.
TITLE: Is buffer overflow/overrun possible in completely managed asp.net c# web application QUESTION: Can there be buffer overflow/overrun vulnerabilities in completely managed asp.net web portal.If yes how can this be tested. ANSWER: Not unless you exploit the webserver or.NET/ASP.NET stack itself.
[ "c#", "asp.net", "buffer-overflow", "buffer-overrun" ]
12
7
8,550
3
0
2008-10-01T06:27:34.467000
2008-10-01T06:29:28.240000
156,457
156,473
Enumerate errors in an error provider
Is it possible to enumerate all the current errors being displayed through an "Error Provider" without having to access the controls?
There is a summary validator that will give you all of the errors, but it's pretty ugly, and I'm not sure if you can use it without displaying it on the page. Technically, if you are doing things the "right way", all of you error handling should be handled in your midddle teir and then bubbled to the screen that way, s...
Enumerate errors in an error provider Is it possible to enumerate all the current errors being displayed through an "Error Provider" without having to access the controls?
TITLE: Enumerate errors in an error provider QUESTION: Is it possible to enumerate all the current errors being displayed through an "Error Provider" without having to access the controls? ANSWER: There is a summary validator that will give you all of the errors, but it's pretty ugly, and I'm not sure if you can use ...
[ ".net", "error-handling", "errorprovider" ]
3
1
3,098
4
0
2008-10-01T06:30:07.707000
2008-10-01T06:35:44.933000
156,472
156,489
Is there a good drop-in replacement for Java's JEditorPane?
I'm not happy with the rendering of HTML by Swing's JEditorPane. In particular bullets for unordered lists are hideous. Customising the rendering seems extremely difficult. Therefore I'm looking for a replacement with better HTML rendering. Does this exist? (I asked Google, and found nothing except a promising dead lin...
Something that I looked at extensively a while back - and there are many options - however I nearly ended up using http://lobobrowser.org/cobra.jsp, but then the project was cancelled so I can't tell you how it all turned out...
Is there a good drop-in replacement for Java's JEditorPane? I'm not happy with the rendering of HTML by Swing's JEditorPane. In particular bullets for unordered lists are hideous. Customising the rendering seems extremely difficult. Therefore I'm looking for a replacement with better HTML rendering. Does this exist? (I...
TITLE: Is there a good drop-in replacement for Java's JEditorPane? QUESTION: I'm not happy with the rendering of HTML by Swing's JEditorPane. In particular bullets for unordered lists are hideous. Customising the rendering seems extremely difficult. Therefore I'm looking for a replacement with better HTML rendering. D...
[ "java", "swing", "jeditorpane" ]
1
1
1,171
4
0
2008-10-01T06:35:26.727000
2008-10-01T06:48:00.097000
156,478
156,506
Implementing cache correctly in a class library for use in an asp.net application
I'm implementing a cache in a class library that i'm using in an asp.net application. I created my cache object as a singleton pattern with a static method to update the cache which is really just loading a member variable/property with a collection of data i need cached (got some locking logic ofcourse). I figured it ...
In my opinion, the best solution would have the following characteristics: Uses the available caching services provided by the platform trying to avoid writing your own. Does not couple your class library to System.Web, in order to have the layers coherent. But if the class library is running inside an ASP.NET applicat...
Implementing cache correctly in a class library for use in an asp.net application I'm implementing a cache in a class library that i'm using in an asp.net application. I created my cache object as a singleton pattern with a static method to update the cache which is really just loading a member variable/property with a...
TITLE: Implementing cache correctly in a class library for use in an asp.net application QUESTION: I'm implementing a cache in a class library that i'm using in an asp.net application. I created my cache object as a singleton pattern with a static method to update the cache which is really just loading a member variab...
[ "c#", "asp.net", "caching", "garbage-collection", "singleton" ]
9
9
9,067
2
0
2008-10-01T06:38:25.923000
2008-10-01T06:59:10.850000
156,492
240,702
How to properly implement a shared cache in ColdFusion?
I have built a CFC designed to serve as a dynamic, aging cache intended for almost everything worth caching. LDAP queries, function results, arrays, ojects, you name it. Whatever takes time or resources to calculate and is needed more than once. I'd like to be able to do a few things: share the CFC between applications...
I understand your desire to avoid passing in the actual scope structure that you want to cache to, but your alternatives are limited. The first thing that comes to mind is just passing the name (a string) of the scope you want your cache stored in, and evaluating. By its nature, evaluation is inefficient and should be ...
How to properly implement a shared cache in ColdFusion? I have built a CFC designed to serve as a dynamic, aging cache intended for almost everything worth caching. LDAP queries, function results, arrays, ojects, you name it. Whatever takes time or resources to calculate and is needed more than once. I'd like to be abl...
TITLE: How to properly implement a shared cache in ColdFusion? QUESTION: I have built a CFC designed to serve as a dynamic, aging cache intended for almost everything worth caching. LDAP queries, function results, arrays, ojects, you name it. Whatever takes time or resources to calculate and is needed more than once. ...
[ "caching", "coldfusion", "scope", "locking" ]
1
1
734
2
0
2008-10-01T06:49:56.287000
2008-10-27T17:19:09.650000
156,503
156,528
How do you assert that a certain exception is thrown in JUnit tests?
How can I use JUnit idiomatically to test that some code throws an exception? While I can certainly do something like this: @Test public void testFooThrowsIndexOutOfBoundsException() { boolean thrown = false; try { foo.doStuff(); } catch (IndexOutOfBoundsException e) { thrown = true; } assertTrue(thrown); } I recall...
It depends on the JUnit version and what assert libraries you use. For JUnit5 and 4.13 see answer If you use AssertJ or google-truth, see answer The original answer for JUnit <= 4.12 was: @Test(expected = IndexOutOfBoundsException.class) public void testIndexOutOfBoundsException() { ArrayList emptyList = new ArrayList...
How do you assert that a certain exception is thrown in JUnit tests? How can I use JUnit idiomatically to test that some code throws an exception? While I can certainly do something like this: @Test public void testFooThrowsIndexOutOfBoundsException() { boolean thrown = false; try { foo.doStuff(); } catch (IndexOutOf...
TITLE: How do you assert that a certain exception is thrown in JUnit tests? QUESTION: How can I use JUnit idiomatically to test that some code throws an exception? While I can certainly do something like this: @Test public void testFooThrowsIndexOutOfBoundsException() { boolean thrown = false; try { foo.doStuff(); }...
[ "java", "exception", "junit", "junit4", "assert" ]
2,296
2,563
1,933,342
35
0
2008-10-01T06:56:08.127000
2008-10-01T07:12:13.440000
156,504
156,513
How to skip the docstring using regex
I'm trying to insert some import lines into a python source file, but i would ideally like to place them right after the initial docstring. Let's say I load the file into the lines variable like this: lines = open('filename.py').readlines() How to find the line number, where the docstring ends?
If you're using the standard docstring format, you can do something like this: count = 0 for line in lines: if line.startswith ('"""'): count += 1 if count < 3: # Before or during end of the docstring continue # Line is after docstring Might need some adaptation for files with no docstrings, but if your files are forma...
How to skip the docstring using regex I'm trying to insert some import lines into a python source file, but i would ideally like to place them right after the initial docstring. Let's say I load the file into the lines variable like this: lines = open('filename.py').readlines() How to find the line number, where the do...
TITLE: How to skip the docstring using regex QUESTION: I'm trying to insert some import lines into a python source file, but i would ideally like to place them right after the initial docstring. Let's say I load the file into the lines variable like this: lines = open('filename.py').readlines() How to find the line nu...
[ "python" ]
2
2
1,247
3
0
2008-10-01T06:56:35.133000
2008-10-01T07:01:51.017000
156,507
158,686
Does a Silverlight memory profiler exist?
CLR profiler does not seem to work with the Silverlight CLR. Does another memory profiler exist?
Doesn't seem to be one available yet. However, as recommended in this forum thread, you can convert your Silverlight app to a WPF application and profile that: There is no tool as of now but as a workaround you can easily create a desktop (WPF) version of your Silverlight client from the same code base and few tweaks (...
Does a Silverlight memory profiler exist? CLR profiler does not seem to work with the Silverlight CLR. Does another memory profiler exist?
TITLE: Does a Silverlight memory profiler exist? QUESTION: CLR profiler does not seem to work with the Silverlight CLR. Does another memory profiler exist? ANSWER: Doesn't seem to be one available yet. However, as recommended in this forum thread, you can convert your Silverlight app to a WPF application and profile ...
[ ".net", "silverlight", "memory-leaks", "clr", "profiler" ]
8
2
6,698
10
0
2008-10-01T06:59:15.767000
2008-10-01T17:12:30.970000
156,508
156,889
Closing a Java FileInputStream
Alright, I have been doing the following (variable names have been changed): FileInputStream fis = null; try { fis = new FileInputStream(file);... process... } catch (IOException e) {... handle error... } finally { if (fis!= null) fis.close(); } Recently, I started using FindBugs, which suggests that I am not properly...
For Java 7 and above try-with-resources should be used: try (InputStream in = new FileInputStream(file)) { // TODO: work } catch (IOException e) { // TODO: handle error } If you're stuck on Java 6 or below... This pattern avoids mucking around with null: try { InputStream in = new FileInputStream(file); try { // TODO: ...
Closing a Java FileInputStream Alright, I have been doing the following (variable names have been changed): FileInputStream fis = null; try { fis = new FileInputStream(file);... process... } catch (IOException e) {... handle error... } finally { if (fis!= null) fis.close(); } Recently, I started using FindBugs, which ...
TITLE: Closing a Java FileInputStream QUESTION: Alright, I have been doing the following (variable names have been changed): FileInputStream fis = null; try { fis = new FileInputStream(file);... process... } catch (IOException e) {... handle error... } finally { if (fis!= null) fis.close(); } Recently, I started usin...
[ "java", "exception", "stream" ]
37
48
56,612
9
0
2008-10-01T07:00:42.250000
2008-10-01T09:44:16.553000
156,527
156,531
How to determine if a class is a subclass of other class?
I'd like to check if a Class object represents a subclass of other class for example Class class1 = Class.forName("Class1"); Class class2 = Class.forName("Class2"); if(class1.isSubClassOf(class2)) // fake methos isSubClassOf { // do sth } How can I implement this isSubClassOf method?
Class.isAssignableFrom() provides more-or-less what you're after, although it handle interfaces also, so may need to do a bit more extra work to be sure that it's a subclass, direct or otherwise.
How to determine if a class is a subclass of other class? I'd like to check if a Class object represents a subclass of other class for example Class class1 = Class.forName("Class1"); Class class2 = Class.forName("Class2"); if(class1.isSubClassOf(class2)) // fake methos isSubClassOf { // do sth } How can I implement th...
TITLE: How to determine if a class is a subclass of other class? QUESTION: I'd like to check if a Class object represents a subclass of other class for example Class class1 = Class.forName("Class1"); Class class2 = Class.forName("Class2"); if(class1.isSubClassOf(class2)) // fake methos isSubClassOf { // do sth } How ...
[ "java" ]
7
13
2,972
1
0
2008-10-01T07:12:06.483000
2008-10-01T07:13:01.910000
156,529
156,551
What is the best way to do Java development in Emacs?
What modes are the best? And any tips or tricks that make developing java in emacs a bit better.
For anything else than casual Java editing, many people recommend the Java Development Environment for Emacs.
What is the best way to do Java development in Emacs? What modes are the best? And any tips or tricks that make developing java in emacs a bit better.
TITLE: What is the best way to do Java development in Emacs? QUESTION: What modes are the best? And any tips or tricks that make developing java in emacs a bit better. ANSWER: For anything else than casual Java editing, many people recommend the Java Development Environment for Emacs.
[ "java", "emacs" ]
20
14
5,175
5
0
2008-10-01T07:12:33.987000
2008-10-01T07:20:00.067000
156,532
156,550
How do I import a whitespace-delimited text file into MySQL?
I need to import largish (24MB) text files into a MySQL table. Each line looks like this: 1 1 0.008 0 0 0 0 0 There are one or more spaces after each field, and the last field is tailed by about 36 spaces before the newline. How do I import such a file into MySQL? From the documentation it seems that LOAD DATA expects ...
If you're on unix/linux then you can put it through sed. open a terminal and type: sed 's/ \+/ /g' thefile > thefile.new this replaces all sequences of multiple spaces with one space.
How do I import a whitespace-delimited text file into MySQL? I need to import largish (24MB) text files into a MySQL table. Each line looks like this: 1 1 0.008 0 0 0 0 0 There are one or more spaces after each field, and the last field is tailed by about 36 spaces before the newline. How do I import such a file into M...
TITLE: How do I import a whitespace-delimited text file into MySQL? QUESTION: I need to import largish (24MB) text files into a MySQL table. Each line looks like this: 1 1 0.008 0 0 0 0 0 There are one or more spaces after each field, and the last field is tailed by about 36 spaces before the newline. How do I import ...
[ "mysql", "load-data-infile", "mysqlimport" ]
5
10
14,422
4
0
2008-10-01T07:13:13.377000
2008-10-01T07:19:51.923000
156,538
157,519
Dependence on DependencyObject and DependencyProperty
I'm building a Silverlight application and one of my caveats from last time was that if you need anything done right in Silverlight/WPF way you'd need to model your objects as a DependecyObject and use DependencyProperty(ies) I find this model to be rather cumbersome, requiring static fields and initializers in half th...
Actually, in Silverlight you cannot inherit DependencyObjects, and so you should (and have to) implement INotifyPropertyChanged instead. Implementing INotifyPropertyChanged has many advantages over DependencyObjects (I will abbreviate this DO to make it easier) and using DependencyProperties (DPs): This is more lightwe...
Dependence on DependencyObject and DependencyProperty I'm building a Silverlight application and one of my caveats from last time was that if you need anything done right in Silverlight/WPF way you'd need to model your objects as a DependecyObject and use DependencyProperty(ies) I find this model to be rather cumbersom...
TITLE: Dependence on DependencyObject and DependencyProperty QUESTION: I'm building a Silverlight application and one of my caveats from last time was that if you need anything done right in Silverlight/WPF way you'd need to model your objects as a DependecyObject and use DependencyProperty(ies) I find this model to b...
[ "silverlight", "xaml" ]
3
4
3,501
3
0
2008-10-01T07:15:04.540000
2008-10-01T13:13:27.863000
156,552
156,603
Creating a two-pass PHP cache system with mutable items
I want to implement a two-pass cache system: The first pass generates a PHP file, with all of the common stuff (e.g. news items), hardcoded. The database then has a cache table to link these with the pages (eg "index.php page=1 style=default"), the database also stores an uptodate field, which if false causes the first...
I second Ken's rec of PEAR's Cache_Lite library, you can use it to easily cache either parts of pages or entire pages. If you're running your own server(s), I'd strongly recommend memcached instead. It's much faster since it runs entirely in memory and is used extensively by a lot of high-volume sites. It's a very easy...
Creating a two-pass PHP cache system with mutable items I want to implement a two-pass cache system: The first pass generates a PHP file, with all of the common stuff (e.g. news items), hardcoded. The database then has a cache table to link these with the pages (eg "index.php page=1 style=default"), the database also s...
TITLE: Creating a two-pass PHP cache system with mutable items QUESTION: I want to implement a two-pass cache system: The first pass generates a PHP file, with all of the common stuff (e.g. news items), hardcoded. The database then has a cache table to link these with the pages (eg "index.php page=1 style=default"), t...
[ "php", "caching" ]
5
6
1,668
6
0
2008-10-01T07:20:17.337000
2008-10-01T07:46:25.947000
156,563
158,238
How do you manage asp.net SQL membership roles/users in production?
How do you setup an asp.net sql membership role/membership provider on a production machine? I'm trying to setup BlogEngine.NET and all the documentation says to use the ASP.NET Website Administration tool from Visual Studio but that isn't available on a production machine. Am I the first BlogEngine user to use it on a...
I solved this problem by setting up a default super user at application start up. By adding this to gobal.asax void Application_Start(object sender, EventArgs e) { // Code that runs on application startup // check that the minimal security settings are created Security.SetupSecurity(); } Then in the security class: us...
How do you manage asp.net SQL membership roles/users in production? How do you setup an asp.net sql membership role/membership provider on a production machine? I'm trying to setup BlogEngine.NET and all the documentation says to use the ASP.NET Website Administration tool from Visual Studio but that isn't available on...
TITLE: How do you manage asp.net SQL membership roles/users in production? QUESTION: How do you setup an asp.net sql membership role/membership provider on a production machine? I'm trying to setup BlogEngine.NET and all the documentation says to use the ASP.NET Website Administration tool from Visual Studio but that ...
[ ".net", "asp.net", "security", "asp.net-membership", "blogengine.net" ]
9
5
9,546
5
0
2008-10-01T07:25:19.103000
2008-10-01T15:31:50.930000
156,582
857,062
Namespace documentation on a .Net project (Sandcastle)?
I started using Sandcastle some time ago to generate a Documentation Website for one of our projects. It's working quite well but we've always only written documentation for classes, methods, properties (...) in our project and had completely separate documentation for the overall project and project parts/modules/name...
Sandcastle also supports the ndoc-style namespace documentation, which allows you to stick the documentation in the source files: Simply create a non-public class called NamespaceDoc in the namespace you want to document, and the xml doc comment for that class will be used for the namespace. Adorn it with a [CompilerGe...
Namespace documentation on a .Net project (Sandcastle)? I started using Sandcastle some time ago to generate a Documentation Website for one of our projects. It's working quite well but we've always only written documentation for classes, methods, properties (...) in our project and had completely separate documentatio...
TITLE: Namespace documentation on a .Net project (Sandcastle)? QUESTION: I started using Sandcastle some time ago to generate a Documentation Website for one of our projects. It's working quite well but we've always only written documentation for classes, methods, properties (...) in our project and had completely sep...
[ ".net", "documentation", "sandcastle" ]
67
81
27,871
7
0
2008-10-01T07:32:00.290000
2009-05-13T09:49:25.783000
156,585
156,638
Can Dns.GetHostEntry ever return an IPHostEntry with an empty AddressList?
I'm just wondering if there can be a case where the hostname can be successfully resolved but the returned hostEntry.AddressList is empty. Currently I'm doing something like this: IPHostEntry hostEntry = Dns.GetHostEntry("some.hostname.tld"); if (hostEntry.AddressList.Count() < 1) { // can that ever happen? throw new A...
No, you'll not see an empty address list: even if you query a DNS label that does exist, but has no A or AAAA (IPv6) records, a SocketException ("No Such Host is Known") will be thrown. You can verify this by looking at the function InternalGetHostByName(string hostName, bool includeIPv6) in DNS.cs from the.NET Referen...
Can Dns.GetHostEntry ever return an IPHostEntry with an empty AddressList? I'm just wondering if there can be a case where the hostname can be successfully resolved but the returned hostEntry.AddressList is empty. Currently I'm doing something like this: IPHostEntry hostEntry = Dns.GetHostEntry("some.hostname.tld"); if...
TITLE: Can Dns.GetHostEntry ever return an IPHostEntry with an empty AddressList? QUESTION: I'm just wondering if there can be a case where the hostname can be successfully resolved but the returned hostEntry.AddressList is empty. Currently I'm doing something like this: IPHostEntry hostEntry = Dns.GetHostEntry("some....
[ "c#", "dns" ]
3
1
6,655
4
0
2008-10-01T07:34:42.560000
2008-10-01T08:00:25.617000
156,586
156,754
In Java, how to reload dynamically resources bundles in a web application?
We are using fmt:setBundle to load a resource bundle from a database (we extended the ResourceBundle class to do that). When we modify a value in database, we have to reload the web server to display the new value on the web app. Is there any simple way to use the new value without restarting the web server? (We do not...
As others have pointed out in the comments, you might want to look into Spring - particularly the ReloadableResourceBundleMessageSource.
In Java, how to reload dynamically resources bundles in a web application? We are using fmt:setBundle to load a resource bundle from a database (we extended the ResourceBundle class to do that). When we modify a value in database, we have to reload the web server to display the new value on the web app. Is there any si...
TITLE: In Java, how to reload dynamically resources bundles in a web application? QUESTION: We are using fmt:setBundle to load a resource bundle from a database (we extended the ResourceBundle class to do that). When we modify a value in database, we have to reload the web server to display the new value on the web ap...
[ "java", "resources", "resourcebundle" ]
8
3
8,553
3
0
2008-10-01T07:34:43.777000
2008-10-01T08:50:40.850000
156,610
156,718
What is the best way to handle English and Chinese in a Flex application?
I have a requirement to be able to provide a flex component in English and several asian languages. I have looked at the flex documentation and it seems that I have to build several swf's, which feels wrong. Does anyone know of a straightforward and practical way of bundling string resources in different languages and ...
I guess you know the basics of how to localize a Flex application, but if you would like to know more there's a good and thorough description here: Runtime Localization. In Flex 3 you have three options on how to solve your problem: compile all languages into the SWF and switch language at runtime compile a separate SW...
What is the best way to handle English and Chinese in a Flex application? I have a requirement to be able to provide a flex component in English and several asian languages. I have looked at the flex documentation and it seems that I have to build several swf's, which feels wrong. Does anyone know of a straightforward ...
TITLE: What is the best way to handle English and Chinese in a Flex application? QUESTION: I have a requirement to be able to provide a flex component in English and several asian languages. I have looked at the flex documentation and it seems that I have to build several swf's, which feels wrong. Does anyone know of ...
[ "apache-flex" ]
2
7
2,015
5
0
2008-10-01T07:49:56.860000
2008-10-01T08:36:07.733000
156,650
156,681
Does the last element in a loop deserve a separate treatment?
When reviewing, I sometimes encounter this kind of loop: i = begin while ( i!= end ) { //... do stuff if ( i == end-1 (the one-but-last element) ) {... do other stuff } increment i } Then I ask the question: would you write this? i = begin mid = ( end - begin ) / 2 // (the middle element) while ( i!= end ) { //... do s...
@xtofl, I agree with your concern. Million times I encountered similar problem. Either developer adds special handling for first or for last element. In most cases it is worth to just loop from startIdx + 1 or to endIdx - 1 element or even split one long loop into multiple shorter loops. In a very rare cases it's not p...
Does the last element in a loop deserve a separate treatment? When reviewing, I sometimes encounter this kind of loop: i = begin while ( i!= end ) { //... do stuff if ( i == end-1 (the one-but-last element) ) {... do other stuff } increment i } Then I ask the question: would you write this? i = begin mid = ( end - begi...
TITLE: Does the last element in a loop deserve a separate treatment? QUESTION: When reviewing, I sometimes encounter this kind of loop: i = begin while ( i!= end ) { //... do stuff if ( i == end-1 (the one-but-last element) ) {... do other stuff } increment i } Then I ask the question: would you write this? i = begin ...
[ "language-agnostic", "loops", "for-loop", "while-loop", "control-structure" ]
20
7
4,856
13
0
2008-10-01T08:04:28.387000
2008-10-01T08:15:34.037000
156,683
156,870
What is the best XSLT engine for Perl?
I would like to know what of the many XSLT engines out there works well with Perl. I will use Apache (2.0) and Perl, and I want to obtain PDFs and XHTMLs. I'm new to this kind of projects so any comment or suggestion will be welcome. Thanks. Doing a simple search on Google I found a lot and I suppose that there are to ...
First mistake - search on CPAN, not Google:) This throws up a bunch of results, but does rather highlight the problem of CPAN, that there's more than one solution, and it's not always clear which ones work, have been abandoned, are broken, slow or whatever. And disturbingly, the best answer (or at least, one of the bes...
What is the best XSLT engine for Perl? I would like to know what of the many XSLT engines out there works well with Perl. I will use Apache (2.0) and Perl, and I want to obtain PDFs and XHTMLs. I'm new to this kind of projects so any comment or suggestion will be welcome. Thanks. Doing a simple search on Google I found...
TITLE: What is the best XSLT engine for Perl? QUESTION: I would like to know what of the many XSLT engines out there works well with Perl. I will use Apache (2.0) and Perl, and I want to obtain PDFs and XHTMLs. I'm new to this kind of projects so any comment or suggestion will be welcome. Thanks. Doing a simple search...
[ "perl", "apache", "pdf", "xhtml", "xslt" ]
10
28
8,094
5
0
2008-10-01T08:18:03.547000
2008-10-01T09:32:02.980000
156,686
156,715
How to start automatic download of a file in Internet Explorer?
How do I initialize an automatic download of a file in Internet Explorer? For example, in the download page, I want the download link to appear and a message: "If you download doesn't start automatically.... etc". The download should begin shortly after the page loads. In Firefox this is easy, you just need to include ...
SourceForge uses an element with the src="" attribute pointing to the file to download. (Side effect: no redirect, no JavaScript, original URL remains unchanged.)
How to start automatic download of a file in Internet Explorer? How do I initialize an automatic download of a file in Internet Explorer? For example, in the download page, I want the download link to appear and a message: "If you download doesn't start automatically.... etc". The download should begin shortly after th...
TITLE: How to start automatic download of a file in Internet Explorer? QUESTION: How do I initialize an automatic download of a file in Internet Explorer? For example, in the download page, I want the download link to appear and a message: "If you download doesn't start automatically.... etc". The download should begi...
[ "javascript", "html", "internet-explorer", "meta-tags" ]
77
112
302,329
19
0
2008-10-01T08:19:29.050000
2008-10-01T08:34:41.370000
156,688
342,688
Community server Username issue - User Username not found in membership store does not exist
I have an error occuring frequently from our community server installation whenever the googlesitemap.ashx is traversed on a specific sectionID. I suspect that a username has been amended but the posts havn't recached to reflect this. Is there a way a can check the data integruity by performing a select statement on th...
This error could be thrown by community server if it finds users that aren't in the instance of MemberRoleProfileProvider. See CommunityServer.Users AddMembershipDataToUser() as an example UPDATE: I Solved this problem for my case by noticing that the usernames are stored in two tables - cs_Users and aspnet_Users. Turn...
Community server Username issue - User Username not found in membership store does not exist I have an error occuring frequently from our community server installation whenever the googlesitemap.ashx is traversed on a specific sectionID. I suspect that a username has been amended but the posts havn't recached to reflec...
TITLE: Community server Username issue - User Username not found in membership store does not exist QUESTION: I have an error occuring frequently from our community server installation whenever the googlesitemap.ashx is traversed on a specific sectionID. I suspect that a username has been amended but the posts havn't ...
[ "asp.net", "sql", "community-server" ]
1
1
499
2
0
2008-10-01T08:20:56.457000
2008-12-05T01:50:29.907000
156,689
156,986
Do you have a common base class for Hibernate entities?
Do you have a common base class for Hibernate entities, i.e. a MappedSuperclass with id, version and other common properties? Are there any drawbacks? Example: @MappedSuperclass() public class BaseEntity { private Long id; private Long version;... @Id @GeneratedValue(strategy = GenerationType.AUTO) public Long getId(...
This works fine for us. As well as the ID and creation date, we also have a modified date. We also have an intermediate TaggedBaseEntity that implements a Taggable interface, because some of our web application's entities have tags, like questions on Stack Overflow.
Do you have a common base class for Hibernate entities? Do you have a common base class for Hibernate entities, i.e. a MappedSuperclass with id, version and other common properties? Are there any drawbacks? Example: @MappedSuperclass() public class BaseEntity { private Long id; private Long version;... @Id @Generated...
TITLE: Do you have a common base class for Hibernate entities? QUESTION: Do you have a common base class for Hibernate entities, i.e. a MappedSuperclass with id, version and other common properties? Are there any drawbacks? Example: @MappedSuperclass() public class BaseEntity { private Long id; private Long version;....
[ "java", "hibernate", "entities", "base-class" ]
20
5
8,967
5
0
2008-10-01T08:23:02.053000
2008-10-01T10:20:56.607000
156,694
157,680
Is it safe to run Access 2003 and 2007 at the same time?
My question about the reconfiguration delay when switching between Access 2003 and 2007 the comment was made: Btw, you can't avoid the reconfiguration between Access 2007 and earlier versions. Access 2007 uses some of the same registry keys as earlier versions and they have to be rewritten when opening Access 2007. If ...
It works most of the time but it's not perfectly safe, which is why Microsft refuses to support multiple installations of Microsoft Office on the same pc. The recommended solution is to install a virtual machine and install the second Microsoft Office version on the virtual machine. Then you can switch from one version...
Is it safe to run Access 2003 and 2007 at the same time? My question about the reconfiguration delay when switching between Access 2003 and 2007 the comment was made: Btw, you can't avoid the reconfiguration between Access 2007 and earlier versions. Access 2007 uses some of the same registry keys as earlier versions an...
TITLE: Is it safe to run Access 2003 and 2007 at the same time? QUESTION: My question about the reconfiguration delay when switching between Access 2003 and 2007 the comment was made: Btw, you can't avoid the reconfiguration between Access 2007 and earlier versions. Access 2007 uses some of the same registry keys as e...
[ "ms-access", "ms-access-2007" ]
1
2
3,780
3
0
2008-10-01T08:26:16.743000
2008-10-01T13:49:04.547000
156,696
156,794
Which web browsers natively support Array.forEach()
Which browsers other than Firefox support Array.forEach()? Mozilla say it's an extension to the standard and I realise it's trivial to add to the array prototype, I'm just wondering what other browsers support it?
The JavaScript article of Wikipedia lists the JS versions by browser. forEach is part of JavaScript 1.6. So it is supported indeed by most browsers, except Opera 9.02 (which I just tested). Opera 9.5 (which I just installed!) supports it, along with indexOf for Array. Surprisingly, it is not official. I don't see its s...
Which web browsers natively support Array.forEach() Which browsers other than Firefox support Array.forEach()? Mozilla say it's an extension to the standard and I realise it's trivial to add to the array prototype, I'm just wondering what other browsers support it?
TITLE: Which web browsers natively support Array.forEach() QUESTION: Which browsers other than Firefox support Array.forEach()? Mozilla say it's an extension to the standard and I realise it's trivial to add to the array prototype, I'm just wondering what other browsers support it? ANSWER: The JavaScript article of W...
[ "javascript", "cross-browser" ]
41
12
30,685
7
0
2008-10-01T08:26:55.790000
2008-10-01T09:04:35.747000
156,697
156,744
How to encode characters from Oracle to XML?
In my environment here I use Java to serialize the result set to XML. It happens basically like this: //foreach column of each row xmlHandler.startElement(uri, lname, "column", attributes); String chars = rs.getString(i); xmlHandler.characters(chars.toCharArray(), 0, chars.length()); xmlHandler.endElement(uri, lname, "...
I found an interesting list in the Xml Spec: According to that List its discouraged to use the Character #26 (Hex: #x1A ). The characters defined in the following ranges are also discouraged. They are either control characters or permanently undefined Unicode characters See the complete ranges. This code replaces all n...
How to encode characters from Oracle to XML? In my environment here I use Java to serialize the result set to XML. It happens basically like this: //foreach column of each row xmlHandler.startElement(uri, lname, "column", attributes); String chars = rs.getString(i); xmlHandler.characters(chars.toCharArray(), 0, chars.l...
TITLE: How to encode characters from Oracle to XML? QUESTION: In my environment here I use Java to serialize the result set to XML. It happens basically like this: //foreach column of each row xmlHandler.startElement(uri, lname, "column", attributes); String chars = rs.getString(i); xmlHandler.characters(chars.toCharA...
[ "java", "xml", "oracle", "encoding" ]
8
7
9,561
3
0
2008-10-01T08:27:24.413000
2008-10-01T08:46:37.893000
156,701
157,111
Dealing with "global" data structures in an object-oriented world
This is a question with many answers - I am interested in knowing what others consider to be "best practice". Consider the following situation: you have an object-oriented program that contains one or more data structures that are needed by many different classes. How do you make these data structures accessible? You c...
Global data isn't as bad as many OO purists claim! After all, when implementing OO classes you've usually using an API to your OS. What the heck is this if it isn't a huge pile of global data and services! If you use some global stuff in your program, you're merely extending this huge environment your class implementat...
Dealing with "global" data structures in an object-oriented world This is a question with many answers - I am interested in knowing what others consider to be "best practice". Consider the following situation: you have an object-oriented program that contains one or more data structures that are needed by many differen...
TITLE: Dealing with "global" data structures in an object-oriented world QUESTION: This is a question with many answers - I am interested in knowing what others consider to be "best practice". Consider the following situation: you have an object-oriented program that contains one or more data structures that are neede...
[ "oop" ]
15
9
5,276
9
0
2008-10-01T08:29:08.420000
2008-10-01T11:01:27.400000
156,707
156,716
In Eclipse, how do I replace a character by a new line?
In Eclipse 3.3.2, I would like to replace a character (say ',') by a new line in a file. What should I write in the "Replace with" box in order to do so? EDIT: Many answers seems to be for Eclipse 3.4. Is there a solution for Eclipse 3.3.X?
Check box 'Regular Expressions' and use '\R' in the 'Replace with' box It's a new feature introduced with Eclipse 3.4, See What's New in 3.4
In Eclipse, how do I replace a character by a new line? In Eclipse 3.3.2, I would like to replace a character (say ',') by a new line in a file. What should I write in the "Replace with" box in order to do so? EDIT: Many answers seems to be for Eclipse 3.4. Is there a solution for Eclipse 3.3.X?
TITLE: In Eclipse, how do I replace a character by a new line? QUESTION: In Eclipse 3.3.2, I would like to replace a character (say ',') by a new line in a file. What should I write in the "Replace with" box in order to do so? EDIT: Many answers seems to be for Eclipse 3.4. Is there a solution for Eclipse 3.3.X? ANSW...
[ "eclipse", "editor", "text-editor", "eclipse-3.4" ]
93
156
60,849
6
0
2008-10-01T08:32:21.407000
2008-10-01T08:35:18.280000
156,712
156,725
What is the default lifetime of a session?
If I hit a page which calls session_start(), how long would I have to wait before I get a new session ID when I refresh the page?
Check out php.ini the value set for session.gc_maxlifetime is the ID lifetime in seconds. I believe the default is 1440 seconds (24 mins) http://www.php.net/manual/en/session.configuration.php Edit: As some comments point out, the above is not entirely accurate. A wonderful explanation of why, and how to implement sess...
What is the default lifetime of a session? If I hit a page which calls session_start(), how long would I have to wait before I get a new session ID when I refresh the page?
TITLE: What is the default lifetime of a session? QUESTION: If I hit a page which calls session_start(), how long would I have to wait before I get a new session ID when I refresh the page? ANSWER: Check out php.ini the value set for session.gc_maxlifetime is the ID lifetime in seconds. I believe the default is 1440 ...
[ "php", "session" ]
72
65
205,406
6
0
2008-10-01T08:34:13.057000
2008-10-01T08:39:06.930000
156,724
158,611
Seam Problem: Could not set field value by reflection
I'm having a problem with my Seam code and I can't seem to figure out what I'm doing wrong. It's doing my head in:) Here's an excerpt of the stack trace: Caused by: java.lang.IllegalArgumentException: Can not set java.lang.Long field com.oobjects.sso.manager.home.PresenceHome.customerId to java.lang.String I'm trying t...
You want to add a converter to your pages.xml file. Like this: See the seampay example provided with seam for more details.
Seam Problem: Could not set field value by reflection I'm having a problem with my Seam code and I can't seem to figure out what I'm doing wrong. It's doing my head in:) Here's an excerpt of the stack trace: Caused by: java.lang.IllegalArgumentException: Can not set java.lang.Long field com.oobjects.sso.manager.home.Pr...
TITLE: Seam Problem: Could not set field value by reflection QUESTION: I'm having a problem with my Seam code and I can't seem to figure out what I'm doing wrong. It's doing my head in:) Here's an excerpt of the stack trace: Caused by: java.lang.IllegalArgumentException: Can not set java.lang.Long field com.oobjects.s...
[ "java", "seam" ]
6
7
6,332
4
0
2008-10-01T08:38:28.630000
2008-10-01T16:51:50.100000
156,740
329,298
Hooking up Reporting Services 2005SP2 to SQL Server 2008
I am trying to configure Reporting Services 2005SP2 on a machine with SQL 2008 on another hosting the ReportServer DB. When I create the ReportServerDB the DB is created as version C.0.9.45: When, afterwards, I try to initialise Reporting Services, I get an error about an incorrect version number. Reporting Services cr...
I got a reply from microsoft support saying that it is impossible on the same box. http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=4153333&SiteID=1
Hooking up Reporting Services 2005SP2 to SQL Server 2008 I am trying to configure Reporting Services 2005SP2 on a machine with SQL 2008 on another hosting the ReportServer DB. When I create the ReportServerDB the DB is created as version C.0.9.45: When, afterwards, I try to initialise Reporting Services, I get an error...
TITLE: Hooking up Reporting Services 2005SP2 to SQL Server 2008 QUESTION: I am trying to configure Reporting Services 2005SP2 on a machine with SQL 2008 on another hosting the ReportServer DB. When I create the ReportServerDB the DB is created as version C.0.9.45: When, afterwards, I try to initialise Reporting Servic...
[ "sql-server", "sql-server-2005", "sql-server-2008", "system-administration" ]
1
1
1,034
2
0
2008-10-01T08:45:55.930000
2008-11-30T20:18:56.333000
156,745
161,493
Best Practices for Eclipse's Problems View
I am using Eclipse for quite some time and I still haven't found how to configure the Problems View to display only the Errors and Warnings of interest. Is there an easy way to filter out warnings from a specific resource or from a specific path? For example, when I generate javadoc I get tons of irrelevant html warnin...
I feel that filtering "On selected element and its children" is the best mode of Problems view filter, because it allows you to very quickly narrow down the scope of reported problems: click on Working Set (in Package Explorer), and it shows all problems in all projects in the set; click on a project - and only problem...
Best Practices for Eclipse's Problems View I am using Eclipse for quite some time and I still haven't found how to configure the Problems View to display only the Errors and Warnings of interest. Is there an easy way to filter out warnings from a specific resource or from a specific path? For example, when I generate j...
TITLE: Best Practices for Eclipse's Problems View QUESTION: I am using Eclipse for quite some time and I still haven't found how to configure the Problems View to display only the Errors and Warnings of interest. Is there an easy way to filter out warnings from a specific resource or from a specific path? For example,...
[ "eclipse" ]
64
65
46,700
8
0
2008-10-01T08:46:39.003000
2008-10-02T09:25:14.890000
156,748
2,359,061
SSL pages under ASP.NET MVC
How do I go about using HTTPS for some of the pages in my ASP.NET MVC based site? Steve Sanderson has a pretty good tutorial on how to do this in a DRY way on Preview 4 at: http://blog.codeville.net/2008/08/05/adding-httpsssl-support-to-aspnet-mvc-routing/ Is there a better / updated way with Preview 5?,
If you are using ASP.NET MVC 2 Preview 2 or higher, you can now simply use: [RequireHttps] public ActionResult Login() { return View(); } Though, the order parameter is worth noting, as mentioned here.
SSL pages under ASP.NET MVC How do I go about using HTTPS for some of the pages in my ASP.NET MVC based site? Steve Sanderson has a pretty good tutorial on how to do this in a DRY way on Preview 4 at: http://blog.codeville.net/2008/08/05/adding-httpsssl-support-to-aspnet-mvc-routing/ Is there a better / updated way wit...
TITLE: SSL pages under ASP.NET MVC QUESTION: How do I go about using HTTPS for some of the pages in my ASP.NET MVC based site? Steve Sanderson has a pretty good tutorial on how to do this in a DRY way on Preview 4 at: http://blog.codeville.net/2008/08/05/adding-httpsssl-support-to-aspnet-mvc-routing/ Is there a better...
[ "asp.net", "asp.net-mvc", "ssl", "https" ]
81
92
49,572
12
0
2008-10-01T08:47:53.057000
2010-03-01T21:03:31.480000
156,767
156,787
What's the difference between an argument and a parameter?
When verbally talking about methods, I'm never sure whether to use the word argument or parameter or something else. Either way the other people know what I mean, but what's correct, and what's the history of the terms? I'm a C# programmer, but I also wonder whether people use different terms in different languages. Fo...
A parameter is a variable in a method definition. When a method is called, the arguments are the data you pass into the method's parameters. public void MyMethod(string myParam) { }... string myArg1 = "this is my argument"; myClass.MyMethod(myArg1);
What's the difference between an argument and a parameter? When verbally talking about methods, I'm never sure whether to use the word argument or parameter or something else. Either way the other people know what I mean, but what's correct, and what's the history of the terms? I'm a C# programmer, but I also wonder wh...
TITLE: What's the difference between an argument and a parameter? QUESTION: When verbally talking about methods, I'm never sure whether to use the word argument or parameter or something else. Either way the other people know what I mean, but what's correct, and what's the history of the terms? I'm a C# programmer, bu...
[ "parameters", "language-agnostic", "arguments", "terminology" ]
1,059
1,351
437,719
38
0
2008-10-01T08:57:20.130000
2008-10-01T09:03:34.763000
156,769
156,809
How can I find similar address records?
The workflow is like this: I receive a scan of a coupon with data (firstname, lastname, zip, city + misc information) on it. Before I create a new customer, I have to search the database if the customer might exist already. Now my question: What's the best way to find an existing customer, when there is no unique ID av...
We are using the Levenshtein distance algorithm to check users for duplication. However we have quite strict rules to enter the data itself, so we have to check only for misstyping, case differences and such.
How can I find similar address records? The workflow is like this: I receive a scan of a coupon with data (firstname, lastname, zip, city + misc information) on it. Before I create a new customer, I have to search the database if the customer might exist already. Now my question: What's the best way to find an existing...
TITLE: How can I find similar address records? QUESTION: The workflow is like this: I receive a scan of a coupon with data (firstname, lastname, zip, city + misc information) on it. Before I create a new customer, I have to search the database if the customer might exist already. Now my question: What's the best way t...
[ "sql", "database" ]
2
3
1,661
5
0
2008-10-01T08:58:01.113000
2008-10-01T09:09:36.950000
156,774
156,793
Distributed corporate collaboration tools
I'm looking for a corporate collaboration tool to help bring together my team, who are geographically and organisationally distributed. Some team members operate on client sites, behind corporate firewalls and similar. The restrictions I have are: Must allow creation of persistent 'channels' (i.e. not just one-to-one o...
Just use Skype. It's free, it has excellent chatting capabilities, works over firewalls, supports lots of collaboration features out of box and plenty more as plugins. P.S. It is also supported natively on Windows Mobile and has good clients on other mobile platforms (like Fring on S60)
Distributed corporate collaboration tools I'm looking for a corporate collaboration tool to help bring together my team, who are geographically and organisationally distributed. Some team members operate on client sites, behind corporate firewalls and similar. The restrictions I have are: Must allow creation of persist...
TITLE: Distributed corporate collaboration tools QUESTION: I'm looking for a corporate collaboration tool to help bring together my team, who are geographically and organisationally distributed. Some team members operate on client sites, behind corporate firewalls and similar. The restrictions I have are: Must allow c...
[ "collaboration", "instant-messaging" ]
1
1
516
6
0
2008-10-01T08:59:28.720000
2008-10-01T09:04:23.017000
156,777
157,635
How to output a CDATA section from a Sax XmlHandler
This is a followup question of How to encode characters from Oracle to Xml? In my environment here I use Java to serialize the result set to xml. I have no access to the output stream itself, only to a org.xml.sax.ContentHandler. When I try to output characters in a CDATA Section: It happens basically like this: xmlHan...
It is getting escaped because the handler.characters function is designed to escape and the </code> part isn't considered part of the value.</p> <p>You need to use the newly exposed methods in <code>DefaultHandler2</code> or use the <code>TransformerHandler</code> approach where you can set the output key <code>CDATA_...
How to output a CDATA section from a Sax XmlHandler This is a followup question of How to encode characters from Oracle to Xml? In my environment here I use Java to serialize the result set to xml. I have no access to the output stream itself, only to a org.xml.sax.ContentHandler. When I try to output characters in a C...
TITLE: How to output a CDATA section from a Sax XmlHandler QUESTION: This is a followup question of How to encode characters from Oracle to Xml? In my environment here I use Java to serialize the result set to xml. I have no access to the output stream itself, only to a org.xml.sax.ContentHandler. When I try to output...
[ "java", "xml", "sax" ]
4
5
9,858
2
0
2008-10-01T09:00:23.633000
2008-10-01T13:36:44.873000
156,779
156,802
C# - How do I define an inline method Func<T> as a parameter?
I've written a simple SessionItem management class to handle all those pesky null checks and insert a default value if none exists. Here is my GetItem method: public static T GetItem (string key, Func defaultValue) { if (HttpContext.Current.Session[key] == null) { HttpContext.Current.Session[key] = defaultValue.Invoke(...
Since that is a func, a lambda would be the simplest way: Foo foo = GetItem ("abc", () => new Foo("blah")); Where [new Foo("blah")] is the func that is invoked as a default. You could also simplify to: return ((T)HttpContext.Current.Session[key])?? defaultValue(); Where?? is the null-coalescing operator - if the first ...
C# - How do I define an inline method Func<T> as a parameter? I've written a simple SessionItem management class to handle all those pesky null checks and insert a default value if none exists. Here is my GetItem method: public static T GetItem (string key, Func defaultValue) { if (HttpContext.Current.Session[key] == n...
TITLE: C# - How do I define an inline method Func<T> as a parameter? QUESTION: I've written a simple SessionItem management class to handle all those pesky null checks and insert a default value if none exists. Here is my GetItem method: public static T GetItem (string key, Func defaultValue) { if (HttpContext.Current...
[ "c#", "generics", "func", "inline-method" ]
9
16
23,334
3
0
2008-10-01T09:00:33.447000
2008-10-01T09:08:07.717000
156,799
156,879
What is data area?
In C++ the storage class specifier static allocates memory from the data area. What does "data area" mean?
In addition to what Konrad said, declaring a variable as static basically means that the memory for it gets allocated with the program as it is loaded, as opposed to on the heap or the stack. Historically, using only static variables in a critical applications meant that the memory footprint of the application would no...
What is data area? In C++ the storage class specifier static allocates memory from the data area. What does "data area" mean?
TITLE: What is data area? QUESTION: In C++ the storage class specifier static allocates memory from the data area. What does "data area" mean? ANSWER: In addition to what Konrad said, declaring a variable as static basically means that the memory for it gets allocated with the program as it is loaded, as opposed to o...
[ "c++", "memory", "static", "storage" ]
3
5
4,526
8
0
2008-10-01T09:05:19.440000
2008-10-01T09:39:07.393000
156,800
225,662
Silverlight display problem
I have created a nice silverlight control doing exactly what I want it to do, and it looks great:) When I host it in the test projects ASPX sample file or the HTML sample file it shows up nicely. I now have to use the control in my existing ASP.NET 2.0 project, which has a fancy design. The problem I'm having is that t...
Found the cause myself... It turns out Silverlight has a display problem when the control is placed in a html table. Found information about this on the silverlight forum. It was about the beta 2, but I have upgraded to the release version, and it's still a problem. Try this. Add a height and a width to the table conta...
Silverlight display problem I have created a nice silverlight control doing exactly what I want it to do, and it looks great:) When I host it in the test projects ASPX sample file or the HTML sample file it shows up nicely. I now have to use the control in my existing ASP.NET 2.0 project, which has a fancy design. The ...
TITLE: Silverlight display problem QUESTION: I have created a nice silverlight control doing exactly what I want it to do, and it looks great:) When I host it in the test projects ASPX sample file or the HTML sample file it shows up nicely. I now have to use the control in my existing ASP.NET 2.0 project, which has a ...
[ "css", "silverlight" ]
0
3
1,867
4
0
2008-10-01T09:05:20.797000
2008-10-22T13:10:41.907000