April 15th, 2010
An idea for a better keyboard
Topics: Idea, ThoughtsThe need for ergonomic keyboards is clear, and so far the only one is the Datahand.
It's clear that a keyboard should be shaped to your hand if it has any chance of being ergonomic. In fact it should fit you like a glove.
Well that's my idea, take some of those switches and wires that everyone currently uses to make stupid light-up t-shirts and apply them to something worthwhile.
Take a stretchy "one size fits all" glove, add switches to each finger tip and a usb cable and you could have a product BETTER than the Datahand for a fraction of the price.
Please someone take this idea and get rich, just give me a free pair of your new keyboard gloves.
Cheers, Dave
April 15th, 2010
Installing Compojure
Topics: Compojure, Clojure, HowtoThe Clojure webframework Compojure is dead easy to install and get running but I got stuck. Anyway it's working now and here are the steps I took:
Install Leiningen (as root)
cd /usr/local/bin/ wget http://github.com/technomancy/leiningen/raw/stable/bin/lein chmod a+x lein
Setup Leningen and install Compojure (as user)
lein self-install git clone git://github.com/weavejester/compojure.git cd compojure lein deps lein jar cp compojure.jar ~/.swank-clojure/ cp libs/* ~/.swank-clojure/
(~/.swank-clojure/ is inside my classpath because I use Emacs, replace that with the correct directory for your installation.)
Now a trial program straight from the Compojure homepage
(use 'compojure.core 'ring.adapter.jetty)
(defroutes main-routes
(GET "/" []
"<h1>Hello World</h1>")
(ANY "*" []
{:status 404, :body "<h1>Page not found</h1>"}))
(run-jetty main-routes {:port 8080})
Now browse to http://localhost:8080 and it should say "Hello World".
Cheers, Dave.
April 09th, 2010
Using the word "orthogonal" does not make you as smart as Rich Hickey
Topics: Clojure, ThoughtsThis is kind of a stupid post but here we go. Please can everyone tone down use of the word "orthogonal" a bit? it doesn't make you smarter and in fact if you don't even look the word up first you can end up looking pretty dumb. (Hell I didn't know what it meant and I had to pause the video and look it up.)
I noticed how everyone emulated Rich after watching through the Clojure videos and you could barely read anything about Clojure without every third word being orthogonal. The final straw was a interview I listened to where the host didn't know the difference between recursion and orthogonal and kept mixing them up.
April 07th, 2010
Dave's got a new blog
Topics: Project, NewsWell hello and welcome to the fresh new blog. I wrote it using web.py, couchdb and python.
It's looking pretty nice, comments are outsourced to Disqus. It's all pretty simple, I am quite pleased with it though.
It now means I can quick edit code samples by adding a < code> tag around the sample. It escapes everything and renders it in a <pre> tag when being displayed and it even highlights everything using the prettifier Javascript module.
(Doesn't sound like much but in Wordpress I had to add an I-frame to each code post by hand, save the code to HTML with Emacs, upload the html and reference the file for the I-frame. It was the only way I could stop Wordpress from fucking up my code let alone getting it to display properly.)
Everything is stored in Couchdb, the URL's are sensible, it's all under my control and I generate an atom feed using libxml.etree.
I spent a while getting Nginx forwarding on all the old URLs properly. Also I have added some nice features to the admin system so it's easy for me to maintain everything.
After writing it though I got thoroughly annoyed with Python, I've decided to go back to learn Clojure, I've just bought a copy of Programming Clojure and in a few months I expect to re-write everything using that.
So anyway all the code is really messy for now but it works nicely and most important of all It's not wordpress.
Let me know if something breaks, if an old URL doesn't work or if there are any issues :) Also if anyone is interested how I coded parts of the blog just ask and I can explain.
April 07th, 2010
Clean parameter based Nginx re-writes with map
Topics: Nginx, Howto, LinuxWhen switching to my new blog I needed to re-write all the old Wordpress URLs to point to the appropriate place. Problem is rewrites don't using arguments so I was stuck.
Luckily Curly060 and Seph in #nginx gave me some ideas and we ended up with this:
# Put this outside of server stanza
map $arg_cat $category {
6 /blog/topic/security;
11 /blog/topic/mac;
8.* /blog/topic/lisp;
9.* /blog/topic/code;
3 /blog/topic/linux;
14 /blog/topic/thoughts;
10 /blog/topic/php;
7 /blog/topic/security;
12 /blog/topic/emacs;
5 /blog/topic/projects;
9 /blog/topic/code;
13 /blog/topic/python;
1 /blog;
8 /blog/topic/lisp;
}
# Put this with other re-writes
if ($category) {
rewrite ^ $category;
}
If you want to do a permanent redirect you have to clear all the arguments to stop the browser being caught in a redirect loop. The last stanza would now look something like this:
if ($category) {
set $args "";
rewrite ^ $category permanent;
}