Microsoft Natural Ergonomic Keyboard 4000

IT WAS TIME to finally replace the old dinosaur keyboard. My Microsoft Natural Keyboard at work had sustained some unfixable sticky keys after many years of writings, so a replacement had to be found.

Microsoft Natural Keyboard

Once more I was thinking of finding another used Microsoft Natural Keyboard (done this before to have a keyboard both at home and at work), but then by coincident, I had a hands on experience on another Microsoft keyboard, the Microsoft Natural Ergonomic Keyboard 4000. Instantly it was clear – I had to have one!

Microsoft Natural Ergonomic Keyboard 4000

This is truly an absolutely awesome keyboard! It really feels as good as it looks. Its has some cool features, but most important is that your hands and fingers simply just “fits” the keyboard, and all the frequently used keys are easy accessible. It is clear that it was made for hardcore typing (more information on the design can be found at Microsoft).

Features include:

  1. 1. Programmable shortcuts.
  2. 2. USB connection.
  3. 3. Additional calculator keys.
  4. 4. Function indicator LED’s.
  5. 5. Back, Forward keys.
  6. 6. Zoom/Scroll pin.
  7. 7. Padded hand rest.

The keyboard has just the right amount of special features. No bloating, but keeping it simple with only the most essential functionality (an USB hub could have been nice though).

A killer feature is the “leather-imitate” padded hand rest, which provides really good hand support. This I’m sure will be a relief to my hands when doing long work-stints.

In general I like that the keyboard its not that different from my old Natural keyboard (you know what they say: “If it ain’t broken. Don’t fix it”) so the transition has been easy. However, I did read several reviews noticing the slimmed Enter key. I agree that such a modification is not for the better, but on my Danish keyboard layout the Enter key is placed vertically like on the Microsoft Natural Keyboard. I find this layout to be much more friendly for locating the Enter key, so the slimming is not is not that big a deal for me.

As a final note, then I’m sure this ends with me having to buy another one, so that I have one at home for my Linux-box too ;-)

Rating: ★★★★★

Help On Python Regular Expressions

REGULAR EXPRESSIONS ARE a powerful friend, but the friendship doesn’t come easy. Regular expressions can be somewhat baffling getting a grasp on, but when finally understood, the possibilities are almost endless.

When developing the searching expression used in HTML Parsing With Beautiful Soup I realized that my regular expression knowledge had gotten a bit rusty. Fortunately I had double-up on the luck. 1) It was a Python program, hence the Python shell was available. 2) I found David Mertz‘s book Text Processing in Python.

The Python shell makes it easy to experiment and tweak any regular expressions on the fly, but the downside is that its not easy to visually evaluate the outcome of your current expression. David’s book helped two folds. It has extensive theory on Python regular expression syntax, but most superhero-like is the small function provided, that makes it possible to see the outcome of an evaluated expression.

# Credits: David Mertz
def re_show(pat, s):
    print re.compile( pat, re.M ).sub( "{\g<0>}", s.rstrip() ), '\n'

Using regular expressions in Python requires importing of the regular expression libirary.

import re

If using the Python shell just enter the same in the shell prompt. The function by David Mertz can also be typed directly into the shell

>>> import re
>>> def re_show(pat, s):
...    print re.compile( pat, re.M ).sub( "{\g<0>}", s.rstrip() ), '\n'
>>>

The re_show wrapper displays the source and emphasizes the result of the expression, as being the contents between the ‘{‘ and ‘}’ pair.

Next is creation of some example text on which to experiment.

>>> s = 'if (Hulk.color != "green"): print "Grey Hulk"'

Now the experiments can begin. The following searches for everything between the first ‘(‘ to the last ‘)’.

>>> re_show(r'\(.*\)', s)

Result:

if{(Hulk.color != "green")}: print "Grey Hulk"

Another example could be an case-insensitive match on the colors of Hulk.

>>> re_show(r'(?i)green|(?i)grey', s)

Result:

if (Hulk.color != "{green}"): print "{Grey}Hulk"

This is just at minuscule introduction to the powers of regular expressions. If your into regular expressions in Python, I highly recommend to buying the book – or donate and read it online.

HTML Parsing With Beautiful Soup

BEAUTIFUL SOUP IS an HTML/XML parser written in Python. Beautiful Soup excels as an easy to use parser that requires no knowledge of actual parsing theory and techniques. And thanks to the excellent documentation with many code examples, it is easy to fabricate some working code very quickly.

On Debian, Beautiful Soup can be install via apt-get / aptitude:
aptitude install python-beautifulsoup

The example below extracts the hit counter from this very page. Note that this is perhaps not the best example in the world (the only parse value used is the “footer” section), but it does exemplifies how easily the process of extracting data from a HTML page can be done when utilizing the Beautiful Soup parser.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env python
# coding=utf-8
 
from BeautifulSoup import BeautifulSoup          # For processing HTML
import urllib2                                   # URL tools
import re                                        # Regular expressions
 
def FindHits(proxyUrl):
    # URL to HTML parse
    url = 'http://monzool.net/blog/index.php'
 
    if len(proxyUrl) > 0:
        # Proxy set up
        proxy = urllib2.ProxyHandler( {'http': proxyUrl} )
 
        # Create an URL opener utilizing proxy
        opener = urllib2.build_opener( proxy )
        urllib2.install_opener( opener )
 
        # Aquire data from URL
        request = urllib2.Request( url )
        response = urllib2.urlopen( request )
    else:
        # Aquire data from URL
        response = urllib2.urlopen( url )
 
    # Extract data as HTML data
    html = response.read()
 
    # Parse HTML data
    soup = BeautifulSoup( html )
 
    # Search requested page for <div> section with id="footer"
    # (The result is returned in unicode)
    footer = soup.findAll( 'div', id="footer" )
 
    # Hint: on this site, it is known that only a single "footer" section
    # exists, and that the hit counter resides in that same section
 
    # Search for the frase "Hits=<some number>"
    pattern = re.compile( r'Hits=.*[0-9]' )
    items = re.findall( pattern, str(footer[0]) )
 
    # Print result
    print items[0]        # -> "Hits=<count>"
 
 
if __name__ == "__main__":
    print "Processing..."
    FindHits("")          # Supply proxy if required. 
                          # FindHist("http://<proxyname>:<port>")

Explanation: If connecting to the internet through a proxy, some additional setup must be done to urllib2. Although urllib2 do provide some automatic proxy configuration detection, but here the configuration is made explicitly.

When the URL is opened the HTML is feed to the Beautiful Soup parser. Here after the member call findAll is used for finding the HTML div section identified as “footer” (<div id="footer">). As noted, no further parsing is done, as this page on contains only one footer section, but otherwise Beautiful Soup provides functions like findAllNext and findNextSiblings to iterate through the parse tree (Beautiful Soup is unicode aware, but not using it in this example, so converting the found section to ascii before inputting it to findall).

The resulting output from the search is the hit counter is extracted from this page.

Mac OS X Keyboard Shortcuts

IT IS EASY to see why people really love their MacBooks. These computers are sleek and run a cool operating system. I also really love my MacBook that I bought at TheCamp 2007, just from the fact that its killing me!

Where feasible I prefer to use keyboard shortcuts instead of mouse navigation, but on Mac OS X there are annoying hurdles.

On a Danish PC keyboard some the often used programming characters are accessed via the AltGr key, e.g. ‘{‘ = AltGr+7, ‘[‘ = AltGr+8, ‘]’ = AltGr+9, ‘}’ = AltGr+0. This is fine as they can all be accessible one handed.

On my MacBook I am running an English Mac OS X with a Danish keyboard and keyboard layout. The PC keyboard and MacBook keyboard differs, so it was no surprise when I could not find those characters. Tried a few combinations, then referred to the manual – no help. The Apple support forum wasn’t really that helpful either (seems that every other link is a sales or marketing page), but did find a poor swede that had some of the same problems that I had. The comments luckily mentioned that the Mac OS X shortcut for ‘[‘ is Command+shift+8.

Going from a one hand operated shortcut to a two handed is not a change for the better, but at least I could now do some programming :-)

Having found the ‘[‘ I was a happy camper as Command+[ is the shortcut for Safari 3 and Finder to do history back actions. No more grapping the mouse for doing trivial back actions I thought… but nooo. It seems that neither Safari nor Finder recognizes the key combination – aaarrgh! I speculate that this is because the true shortcut is Command+[ and what I am pressing is actually Command+shift+[. One could suspect that those programs switch on the actual keys pressed, instead of receiving characters thats been outputted from a localizing filter?

Btw. how do I enter a directory in Finder? Pressing Enter just enables me to rename the directory! WTF! This is surely a sane default action; I’ll much rather rename a directory than look whats inside – NOOOT.

Well, I’ve finally “solved” my Safari and Finder problems. A long time Mac owning friend of mine, told me that back history in Safari could also be done with Command+left-arrow. ZOMG! A secret solution?! Argh, kiss my ass Safari, I’ve installed Firefox. This new shourtcut didn’t work in Finder of course, so I installed Xfolders and then Finder could go fuck it self.

Btw. every time a dialog pops up for an action (e.g. Accept/Cancel) – how the hell do I select the desired action using the keyboard? And why do I even have to ask this question in the first place?

I would characterize the Mac OS X shortcuts as being either, very long, very non-English unfriendly or both. Wouldn’t be surprised if Mac OS X were written in Emacs by non-non-Englishmen ;-)

All this is making just me really Charles Bronson angry of how stupid Mac OS X is. Not just different, but stupid! Arrrrgh. So the lesson is short: “Apple and others – Don’t use special characters for keyboard shortcuts! It’s fubar.”

Copyright © All Rights Reserved · Green Hope Theme by Sivan & schiy · Proudly powered by WordPress