Sunday, July 27, 2008

WSE 2.0 in Visual Studio 2008

A slightly older .Net 2 application I wrote for a client to upload files to Amazon S3 makes use of the Amazon S3 SOAP API. The SOAP API has the advantage over the REST API of being able to stream large files as DIME attachements when uploading to the S3 servers, rather than trying to load them up in one go, which is handy when uploading large files. The S3 WS API requires Microsoft’s Web Services Enhancements (WSE) 2.0 though, rather than the later WSE 3.0, because in WSE 3.0 DIME is replaced by MTOM (which Amazon doesn’t support - in typical WS-* way).

However, when I tried to install this, I got the following error:

Unknown error in CorBindToRuntimeHost

Error 1001.InstallUtilLib.dll: Unknown error in CorBindToRuntimeHost

The workaround (a reminder to myself) is to use the WSE 2.0 SP3 installer rather than the older versions that come up when searching for WSE 2.0 on google.

posted by Nick at 6:24 pm - filed in .net, windows  

Saturday, March 15, 2008

Dvorak keyboard in Ubuntu/Xubuntu

For my own reference, a couple of ways of setting up the Dvorak keyboard in Ubuntu Linux.

In Gnome:

System > Preferences > Keyboard > Layouts tab > Add button > Dvorak

For a single terminal session:

loadkeys dvorak

Adding this line to your .bashrc should result in it applying to all your terminal sessions.

All X sessions (including the GDM logon screen and Gnome):

For all X sessions (including the GDM logon screen and Gnome), add Option "XbdLayout" "dvorak" to /etc/X11/xorg.conf as such:

Section "InputDevice"
  Identifier "Generic Keyboard"
  Driver "kbd"
  Option "CoreKeyboard"
  Option "XkbRules" "xorg"
  Option "XkbModel" "pc105"
  Option "XkbLayout" "dvorak,gb" #use the dvorak keyboard layout

This allows switching between the Dvorak and GB layouts by pressing both shift keys at once.


Simply make sure that /etc/default/console-setup contains the following lines (replacing any options with the same names that might already exist):


The change will take place after the next reboot. This is equivalent to choosing Dvorak as the default keyboard layout during installation, or running sudo dpkg-reconfigure console-setup from the command line.

posted by Nick at 2:20 am - filed in dvorak, linux  

Saturday, January 12, 2008

Paul Graham’s “On Lisp” - in a single HTML page

Paul Graham kindly made this available free of charge in PDF and Postscript formats (here). However, because I wanted to change the printing format (to print it in booklet format, which is two A5 pages per A4 sheet), I was looking for something I could change the layout of, which proved hard to do in PDF (unsurprisingly, since the aim of the PDF and PS formats is fixing layout for print). I found a multi-page HTML file here; this wasn’t too convenient for printing though, so I concatenated it to a single file. I’m posting it here (860k) in case anyone else finds it useful.

posted by Nick at 5:01 pm - filed in lisp  

Monday, December 17, 2007

Vi! Vi! Vi!

I’ve been using Vim for about 4 months now, and I must admit that I’m not sure how I did without it. Modal editing seems like a natural paradigm to me (similar to lifting your hands off the keyboard to perform operations with the mouse, except without lifting hands from the keyboard :-), and the movement commands seemed intuitive and somehow logical, much easier than remember all the different keybindings Emacs has. Vim is a great text editor; however, it isn’t as well suited to more specific tasks, such as being an IDE or a document editor, as dedicated software such as IntelliJ IDEA or Word/OpenOffice are. The problem with those, in turn, is that text editing isn’t half as smooth as with Vim.

So, I was quite pleased when I stumbled upon this:


A Netbeans module for Vi-like editing in Netbeans. I’ve been playing with it a bit and it definitely looks promising; this goes at least some way to resolving the IDE question, as I’ve found Netbeans to be great for Ruby/Rails and second only to IntelliJ as a Java IDE. For work, I’m thinking of splashing out on this:


I’ve had a go with the demo and it works great. They have a version for Word/Outlook too, which is definitely very enticing - even though I already find editing text with Vim a lot more efficient than with a traditional editor, I still feel like I could be quite a bit more productive, and the more I get to practice, the easier this should hopefully become. Now if only I could find an equivalent for Open Office and Thunderbird…

posted by Nick at 11:15 pm - filed in linux, windows  

Monday, October 1, 2007

Dvorak touchtyping - week 4

Well, I broke the 55WPM mark on the home row this week, but things go downhill pretty rapidly from there. On other exercises I hover between 35 and 45WPM, and on a general typing test I fare much worse (around 33-35WPM on this typing test). So, I’m still pretty far off the mark from my ambitious ‘60WPW in a month’ aim, but I guess the idea was to aim loftily, and then reassess after a month…

I’ll definitely need a lot more practice to reach 60WPM. My overall speed is still slower than my quick hunt-and-peck QWERTY skills, which was probably to be expected but is still disappointing. I also still have to think about where letters are on the keyboard when I type most of the time, and in the real world (i.e. not typing tests) I still make a lot of mistakes even on the keys I’ve practiced the most on. On the positive side, I can actually type mostly without looking at the keyboard, and I’ve more or less assimilated using the basic copy-cut-paste keyboard shortcuts with the DVORAK layout.

The key to faster speeds will obviously be more practice (which I’d let up on a little in the past couple of weeks) - with regular practice, I’m hoping to make 60WPM overall in the next month or so.

posted by Nick at 6:19 pm - filed in dvorak  

Friday, September 28, 2007

Using SSL/HTTPS for Gmail and Google Apps

Today, I was thinking about Google Apps and wondering whether it used SSL to encrypt email. Now the Gmail POP/SMTP facilities use encryption for any data transferred between the mail client and Google’s mail servers, so I would have thought it natural that SSL was used to encrypt any email sent via the web interface as well. As it turns out though, that isn’t the case; firing up my trusty copy of Fiddler, I sent an email to myself using the Google Apps web interface and monitored the resulting HTTP exchange. This is the result (this is the POST request transcript - the relevant bits are in bold).

The same applies to Gmail itself. I know for most people this is a non-issue as email is generally insecure (as it gets transmitted unencrypted from mail server to mail server). I was thinking about local malicious users or sysadmins viewing the email I am sending or receiving. There are quite a few cases I can think of when I’d like to know local sysadmins can’t read my mail: a public internet cafe (in China for example, or another country free speech not a given), a corporate VPN, a non-encrypted (or WEP-encrypted) WiFi hotspot, etc… 

With Gmail, the solution is to access Gmail via https://mail.google.com rather than https://mail.google.com. In this case, a secure session is maintained throughout and all communication between Gmail and the browser is encrypted.

With Google Apps, the solution is to log in using a URL like this:


However, I couldn’t get https://mail.mydomain.com to forward to the above, which is a shame as it’s my main gateway to Google Apps (and others’ too I suspect - and therefore possibly a minor security issue for sysadmins administering domains using Google Apps…).

posted by Nick at 3:50 pm - filed in Uncategorized  

Saturday, September 22, 2007

Dvorak touchtyping - week 3

Well, better but still far from perfect. I broke the 50WPM barrier on the home row this week, at 98% accuracy too, but I also let up on the regular practise a little (I must have practised two or three times this week for an hour or so at a time, down from 6 the two first weeks at an hour and a half or so each). I’m still nowhere near as good at any of the other exercises though, and I still catch myself looking at the keyboard quite regularly.

Interestingly, I noticed myself being rather verbose in some of by emails this week, presumably as a subconscious reaction to the joy of finally being able to type at something approaching reasonable speeds. I’m also starting to get a feel for the positions of the keys other than the home row without having to look at them too, although I’m noticing that I frequently get the ‘e’ and the ‘o’ mixed up. Another interesting thing is that I seem to be in a different mindset when typing freely and doing the exercises; for some reason, some of the keys I remember well typing freely don’t seem to make it over to the exercises - I guess the different visuals (the terminal for dvorakng and Windows for daytime work) disassociate the two in my mind, which is a shame…

posted by Nick at 2:48 pm - filed in dvorak  

Sunday, September 16, 2007

Dvorak touchtyping - week 2

Well, there has been progress, but it has been slow. I’m on around 40-45WPM on the home row (which accounts for 70% of keys in English), but my error rate is still high at round 95-96%. The WPM drops dramatically once I leave the home row though, at around 30-35WPM for anything involving the top row (I haven’t even tried any exercises involving the bottom row). At least the frustration of typing letters at what seemed like 2WPM has abated, so I can stop resorting to using the mouse as much as possible and actually write emails without crying…

posted by Nick at 2:47 pm - filed in dvorak  

Saturday, September 8, 2007

Dvorak touchtyping - week 1

So I’m going to try to learn how to touch-type again; this will be my second attempt, the first being about three months ago. The difference is that this time I’m switching to Dvorak cold-turkey; the last time I had also tried to learn Dvorak, but I think that the constant swiching between Dvorak and Qwerty was what ended being discouraging, as progress was very slow.

It’s been just over a week now, and the first few days were among the most frustrating I remember having in a long time. The double-switch of Dvorak and touch-typing proved very difficult. On the first day, it took me almost 20 mins to write a 5-line email sheerly due to my typing speed; it got to the stage that I was not emailing people back because the frustration at not being able to type was so great. It’s not so bad now; I can type at a reasonable speed, I’m guessing around 10-20 WPM, which is still horrendously slow but at least workable. I had set myself an ambitious goal of 80 WPM in a month, which right now doesn’t seem achievable, especially given my still very high error rate - still worth trying though…

posted by Nick at 12:49 am - filed in dvorak  

Thursday, August 16, 2007

One line Ruby memoization

Memoization is a functional programming technique used to cache the result of expensive method calls for later re-use; this allows us to avoid repeatedly performing an expensive calculation when the result has already been calculated once. Today I stumbled accross an interesting method of achieving memoization in Javascript for nullary functions (i.e. functions taking no arguments); the author was re-defining the method called to perform the calculation to return the computed result, meaning the repeated invocations of the method would return the computed value once the initial calculation had been performed. This seemed like an elegant way to achieve result caching; I was curious to see if the same could be achieved with Ruby.

The standard method of result caching in Ruby might be:

class Cached
  def cached_method
    return @cache unless @cache.nil?
    puts 'computing expensive value'
    @cache= "hello world"
10.times do
  puts 'result: ' + c.cached_method

Using memoization:

class Memoized
  def memoized_method
      #expensive computation goes here
      puts 'computing expensive value'
      cache="hello world"
      self.class.send(:define_method, :memoized_method, lambda{cache}).call
10.times do
  puts 'result: ' + m.memoized_method

Here, we are re-defining memoized_method within the function itself so that it returns the computed value once it has been invoked. Disappointingly though, this isn’t much of an improvement line-count wise - the result is slightly less readable too, mainly because define_method is private (which is why we need to use the self.class.send hack above). What about performance (over 50000 iterations)?

nick@unintelligible:~/Desktop$ ruby perf.rb
Rehearsal ---------------------------------------------
cached:    0.120000   0.020000   0.140000 (  2.135206)
memoised:  0.110000   0.020000   0.130000 (  2.139923)
------------------------------------ total: 0.270000sec
                    user     system      total        real
cached:    0.100000   0.040000   0.140000 (  0.134768)
memoised:  0.130000   0.020000   0.150000 (  0.144927)

Nope - it’s roughly equivalent (very slightly slower in fact, presumably due to the extra cost of routing the method through define_method). So, although memoization is definitely a useful technique, result caching yields is still more readable and slightly more performant for nullary functions in Ruby than this particular implementation.

posted by Nick at 1:09 pm - filed in ruby  
� Previous PageNext Page �