Spray WD-40 using the nozzle around the lip of the stuck glass.
Run hot water around the bottom glass, fill the top glass up with cold water.
Smash on the lip with a skewer or more appropriate implement.
Bob's your uncle.
Merry Christmas
Monday, December 24, 2007
Sunday, December 9, 2007
Sventon for my homies
I'm a big fan of sventon, the guys have created one of the kickingest svn repository viewers around.
Much to my dismay after an upgrade to 1.3.0, stuff stopped working. I didn't have time to look at it until recently but I dived into the tomcat logs and pulled up this.
org.springframework.beans.MethodInvocationException: Property 'archiveFileCharset' threw exception; nested exception is java.nio.charset.UnsupportedCharsetException: cp437
Not so cool.
cp437 is the old dos-us character set which sure isn't installed on our svn box, hence the error.
So if this saves anyone else some time, go into the WEB-INF directory of sventon and edit sventon-servlet.xml. There is a property called archiveFileCharset. Change the value to whatever is appropriate for you. In my case it was cp1252 which is en-au amongst others, but should be good enough for most engrish speakers.
I thought Unicode had pretty much made Windows Code Pages obsolete, oh well.
Much to my dismay after an upgrade to 1.3.0, stuff stopped working. I didn't have time to look at it until recently but I dived into the tomcat logs and pulled up this.
org.springframework.beans.MethodInvocationException: Property 'archiveFileCharset' threw exception; nested exception is java.nio.charset.UnsupportedCharsetException: cp437
Not so cool.
cp437 is the old dos-us character set which sure isn't installed on our svn box, hence the error.
So if this saves anyone else some time, go into the WEB-INF directory of sventon and edit sventon-servlet.xml. There is a property called archiveFileCharset. Change the value to whatever is appropriate for you. In my case it was cp1252 which is en-au amongst others, but should be good enough for most engrish speakers.
I thought Unicode had pretty much made Windows Code Pages obsolete, oh well.
Friday, November 16, 2007
Get full name for Windows user from Ruby
Lately I've been writing a few automation programs and it was suggested by a colleague that I write one for logging a job with EDS, our "service" provider.
The web page is nasty to navigate, I think they make it hard so people decide to give up and go get a beer instead of logging a job :)
Anyway, one of the fields on the page requires the full name of the person logging the job. It's trivial to grab the username of the logged on user:
However, I wasn't sure of the easiest way to grab the user's full name. There are a few packages out there, for example the sys-admin gem. It didn't work though, I dug around in the source and it hardcodes a cimv2 path, no good.
Seeing this is a quick hack running on windows for windows, rah rah rah, might as well boogey with it.
Enter ADSI.
The following interrogates our AD and grabs what I want. Too easy.
The web page is nasty to navigate, I think they make it hard so people decide to give up and go get a beer instead of logging a job :)
Anyway, one of the fields on the page requires the full name of the person logging the job. It's trivial to grab the username of the logged on user:
1 puts ENV['USERNAME']
However, I wasn't sure of the easiest way to grab the user's full name. There are a few packages out there, for example the sys-admin gem. It didn't work though, I dug around in the source and it hardcodes a cimv2 path, no good.
Seeing this is a quick hack running on windows for windows, rah rah rah, might as well boogey with it.
Enter ADSI.
The following interrogates our AD and grabs what I want. Too easy.
1 require 'win32ole'
2 puts WIN32OLE.connect("WinNT://your.ad.box.sa.gov.au/#{ENV['USERNAME']}").FullName
2 puts WIN32OLE.connect("WinNT://your.ad.box.sa.gov.au/#{ENV['USERNAME']}").FullName
Wednesday, November 14, 2007
Blowing away IE
ASP.NET development is great fun, especially when you are targeting Internet Explorer 7 (as if there are any other browsers anyway) :).
It doesn't take much to confuse IE so I find myself in the continuous loop of trying a code change, clearing the cache in IE, rebuilding the app and running it again. Numerous times a day, too many. Dancing the Microsoft Visual Studio developer jig if you will.
Well, enough is enough. Time to automate it.
Consider the following ruby script that uses WSH. I'm aware of watir and other winole jiggery, but why not just send the keystrokes, I say. This script blows out the IE cache, quits it, goes into visual studio and restarts the project, hurrah. Obviously you'll want to replace the AppActivate parameters to match your window titles.
It doesn't take much to confuse IE so I find myself in the continuous loop of trying a code change, clearing the cache in IE, rebuilding the app and running it again. Numerous times a day, too many. Dancing the Microsoft Visual Studio developer jig if you will.
Well, enough is enough. Time to automate it.
Consider the following ruby script that uses WSH. I'm aware of watir and other winole jiggery, but why not just send the keystrokes, I say. This script blows out the IE cache, quits it, goes into visual studio and restarts the project, hurrah. Obviously you'll want to replace the AppActivate parameters to match your window titles.
1 require 'win32ole'
2
3 wsh = WIN32OLE.new('Wscript.Shell')
4 wsh.AppActivate('Generic Auditing Tool')
5 sleep(2)
6 wsh.SendKeys('%{T}') #ALT-T: select 'Tools'
7 sleep(1)
8 wsh.SendKeys('o') #select 'Internet Options'
9 sleep(1)
10 wsh.SendKeys('%{D}') #select 'Delete'
11 sleep(1)
12 wsh.SendKeys('a') #select 'Delete all'
13 sleep(1)
14 wsh.SendKeys('d') #select 'also delete files and settings stored by add-ons'
15 sleep(1)
16 wsh.SendKeys('y') #select 'Yes'
17 sleep(8)
18 wsh.SendKeys('%{F4}') #quit 'Internet Options'
19 sleep(1)
20 wsh.SendKeys('%{F4}') #quit IE
21
22 wsh.AppActivate('NAT - Microsoft Visual Studio') #grab the visual studio window
23 sleep(2)
24 wsh.SendKeys('^{F5}') #start the project without debugging
2
3 wsh = WIN32OLE.new('Wscript.Shell')
4 wsh.AppActivate('Generic Auditing Tool')
5 sleep(2)
6 wsh.SendKeys('%{T}') #ALT-T: select 'Tools'
7 sleep(1)
8 wsh.SendKeys('o') #select 'Internet Options'
9 sleep(1)
10 wsh.SendKeys('%{D}') #select 'Delete'
11 sleep(1)
12 wsh.SendKeys('a') #select 'Delete all'
13 sleep(1)
14 wsh.SendKeys('d') #select 'also delete files and settings stored by add-ons'
15 sleep(1)
16 wsh.SendKeys('y') #select 'Yes'
17 sleep(8)
18 wsh.SendKeys('%{F4}') #quit 'Internet Options'
19 sleep(1)
20 wsh.SendKeys('%{F4}') #quit IE
21
22 wsh.AppActivate('NAT - Microsoft Visual Studio') #grab the visual studio window
23 sleep(2)
24 wsh.SendKeys('^{F5}') #start the project without debugging
Wednesday, October 17, 2007
C# .NET Regular Expressions gotcha
I sure do love me some regular expressions but haven't really had the need in any of my C# code until now.
A few things did catch me out though, in particular the constructor for the Regex class.
The constructor signature I'm interested in is this one: (string pattern, RegexOptions options). All well and good until you want to set multiple options!
Now I might be slightly naive but why doesn't the constructor use the params keyword allowing it to accept a variable number of RegexOptions? The constructor would then look something like (string pattern, params RegexOptions[] options). I think this follows the LOLA, unlike the current method of passing multiple regex options to the constructor.
Oh, guess how you are supposed to do it? Via a bitwise OR of the enum values ofcourse! Like my NUnit fun, at least I can now just get on with it.
A few things did catch me out though, in particular the constructor for the Regex class.
The constructor signature I'm interested in is this one: (string pattern, RegexOptions options). All well and good until you want to set multiple options!
Now I might be slightly naive but why doesn't the constructor use the params keyword allowing it to accept a variable number of RegexOptions? The constructor would then look something like (string pattern, params RegexOptions[] options). I think this follows the LOLA, unlike the current method of passing multiple regex options to the constructor.
Oh, guess how you are supposed to do it? Via a bitwise OR of the enum values ofcourse! Like my NUnit fun, at least I can now just get on with it.
1 Regex matchFieldValue =
2 new Regex(@"
3 (?<Field>\w+) #capture 1 or more word characters to the named group 'Field'
4 \s*=\s* #followed by 0 or more spaces, an = sign and 0 or more spaces
5 (?<Value> ' #match an apostrophe
6 ([^'] | #match 0 or more of any character that is not an ' OR
7 ''.)* #double apostrophe's followed by any character
8 ') #match the closing ' and capture to named group 'Value'
9 ",
10 RegexOptions.Compiled |
11 RegexOptions.IgnoreCase |
12 RegexOptions.IgnorePatternWhitespace);
2 new Regex(@"
3 (?<Field>\w+) #capture 1 or more word characters to the named group 'Field'
4 \s*=\s* #followed by 0 or more spaces, an = sign and 0 or more spaces
5 (?<Value> ' #match an apostrophe
6 ([^'] | #match 0 or more of any character that is not an ' OR
7 ''.)* #double apostrophe's followed by any character
8 ') #match the closing ' and capture to named group 'Value'
9 ",
10 RegexOptions.Compiled |
11 RegexOptions.IgnoreCase |
12 RegexOptions.IgnorePatternWhitespace);
Friday, October 12, 2007
NUnit configuration woes
I've been going through writing NUnit tests for a .NET web app I'm writing at work and all was going well until I hit some code that was using the ConfigurationManager.
For backgrounds sake I've created a test dll that sits outside the web app that calls a dll used by the web app. The connection string information is stored in Web.config.
Whenever NUnit loaded up the tests requiring that connection it barfed this at me:
Test.TestDataAccessUtility.GetNameValueTOList : System.TypeInitializationException : The type initializer for 'DataAccessUtility' threw an exception.
----> System.NullReferenceException : Object reference not set to an instance of an object.
Nice, this essentially means that ConfigurationManager had crapped itself.
ConfigurationManager.ConnectionStrings.Count was returning 1.
ConfigurationManager.ConnectionStrings[0].ConnectionString sent back a conn string for a SQLExpress db with some configuration string I sure didn't set.
It would appear that the NUnit loads it's config file over your application's config file.
To fix, I just replaced the contents of the NUnit config file: Project1.config with the contents of my Web.config. There could be a better solution, but it's working now and I can move on with my life.
1 private static readonly string CONNECTION_STRING =
2 ConfigurationManager.ConnectionStrings["DBConn"].ConnectionString;
2 ConfigurationManager.ConnectionStrings["DBConn"].ConnectionString;
For backgrounds sake I've created a test dll that sits outside the web app that calls a dll used by the web app. The connection string information is stored in Web.config.
Whenever NUnit loaded up the tests requiring that connection it barfed this at me:
Test.TestDataAccessUtility.GetNameValueTOList : System.TypeInitializationException : The type initializer for 'DataAccessUtility' threw an exception.
----> System.NullReferenceException : Object reference not set to an instance of an object.
Nice, this essentially means that ConfigurationManager had crapped itself.
ConfigurationManager.ConnectionStrings.Count was returning 1.
ConfigurationManager.ConnectionStrings[0].ConnectionString sent back a conn string for a SQLExpress db with some configuration string I sure didn't set.
It would appear that the NUnit loads it's config file over your application's config file.
To fix, I just replaced the contents of the NUnit config file: Project1.config with the contents of my Web.config. There could be a better solution, but it's working now and I can move on with my life.
Thursday, October 4, 2007
Sequence Mapping Functions
I've slowly been making my way through Peter Seibel's Practical Common Lisp. Even though I'm also in between a few other books at the moment I've managed to let some of it soak in.
I came across the following example that shows off the quintessential map function.
It simply produces a new sequence by multiplying the subsequent elements of the supplied sequences, resulting in: => #(10 18 24 28 30)
To put it in perspective I decided to have a crack and see what an equivalent function would look like in Ruby. After a bit of mucking around I came up with this:
I'm sure someone could probably come up with something nicer as there is more than one way to skin a cat in ruby (I haven't tried, honest - ..to skin a cat that is). Regardless I think we should all sit back and appreciate the aesthetics of the lisp map.
I came across the following example that shows off the quintessential map function.
1 (map 'vector #'* #(1 2 3 4 5) #(10 9 8 7 6))
It simply produces a new sequence by multiplying the subsequent elements of the supplied sequences, resulting in: => #(10 18 24 28 30)
To put it in perspective I decided to have a crack and see what an equivalent function would look like in Ruby. After a bit of mucking around I came up with this:
1 [1,2,3,4,5].zip([10,9,8,7,6]).map{|x,y| x * y}
I'm sure someone could probably come up with something nicer as there is more than one way to skin a cat in ruby (I haven't tried, honest - ..to skin a cat that is). Regardless I think we should all sit back and appreciate the aesthetics of the lisp map.
Subscribe to:
Posts (Atom)




