Basic authentication for ring (and compojure etc.)

Published at: 23.VIII.2010 21:26 CEST

I’ve always liked HTTP authentication (like basic and digest) over login pages because they look so.. technically savvy. Finally somebody who bothered to read an RFC to implement it and make me feel warm and welcome like peers do.

Okay, I must admit, it takes a customer just a couple of moments to request a logout button, which is a real pain to implement, if possible at all. And I wouldn’t want to login on something I care about from a public computer either. But it is very nice for web services!

Anyway here’s my implementation as ring middleware: ring-basic-authentication

elein.el: leiningen functions for emacs

Published at: 19.VIII.2010 19:41 CEST
Categories: clojure, english
Comments: 3 pieces

I’ve bundled my emacs leiningen convenience functions into a package and dropped it on github for other people to use. It’s a collection of interactive commands for common lein tasks used within a project; elein-clean, elein-deps etc.

Mosts of the commands basically run lein using the emacs compile function, with the exception of elein-swank and elein-reswank. These also handle (re)connecting slime.

Curious?

  • download elein.el
  • copy it somewhere in you emacs load-path
  • (require 'elein)
  • open up a file in a leiningenize project
  • M-x elein-version

I hope somebody finds this useful.

Announcing clj-base64

Published at: 20.IV.2010 16:22 CEST
Categories: clojars, clojure, english
Comments: 2 pieces

I’ve justed released a small clojure library called clj-base64 for encoding and decoding data using the Base64 coding scheme. The code’s at github (and gitorious) and a pom and jar have been pushed to clojars.

Lein it up:

(defproject..
  :dependencies [..
                 [clj-base64 "0.0.0-SNAPSHOT"]]..

And use it:

(use 'remvee.base64)
(encode-str "I 8> clojure!")        ; => "SSA4PiBjbG9qdXJlIQ=="
(decode-str "SSA4PiBjbG9qdXJlIQ==") ; => "I 8> clojure!"

Enjoy!

EXIFR 1.0.0

Published at: 7.IV.2010 22:11 CEST
Categories: english, exifr, programming, ruby

After 4 years EXIF Reader finally reaches it’s first major-version-day. It has been pretty stable for a while now and the API didn’t change in any painful way since the first release.

So here it is: version 1.0.0.

  gem install exifr

Enjoy!

Thanks to Makoto Kishimoto, Mark Lundquist, Victor Bogado, Forian Munz and other people I forgot to record in the CHANGELOG for sending me patches and test images.

git wazzup

Gepubliceerd op: 21.VII.2009 10:03 CEST
Categorieën: emacs, git, ruby
Reacties: 1 stuk

Het maken van nieuwe takken (branches) heb ik sinds ik git gebruik zo goed als onder een sneltoets zitten. Het is heerlijk om veilig op een tak te zitten knutselen zonder dat je het risico loopt de hele boom om te zagen.

Maar met zoveel takken is het gemakkelijk het overzicht te verliezen. Ik zat dan ook vaak met allerlei git GUI’s te kijken waar al m’n spik splinter nieuwe uitbreidingen uithangen. Tot ik de wazzup functie van Magit tegen kwam, die doet precies wat ik wil: laten zien welke commits uit welke branches er niet in de huidige branch zitten.

Ik zit echter zo vastgeroest aan git.el dat ik wazzup in een klein Ruby scriptje heb gevat:

#!/usr/bin/env ruby

branches = `git branch`.split("\n")
current = branches.grep(/^\*/).first[/[^ *]+/]
branches = branches.map{|v| v[/[^ *]+/]}

(branches - [current]).each do |branch|
  unless (cherries = `git cherry -v #{current} #{branch}`).empty?
    puts "#{branch}\n#{cherries}\n"
  end
end

Output ziet er bijvoorbeeld als volgt uit:

automated-tasks
+ 6ff08f983e4fefec813fb1b0c3fa444abf79d838 added task model
+ 174f42694ac862e37c3b04c03059b7f0c7814239 only allow admin to create/edit task
+ 8a6d5bfa83d8781551e3295a8461009c84e7829a task syntax checking validation
+ 748f08bee98f8902f7948964b833ca08404ce098 drop dead code
+ b84a5382ca0541f712b21dec3215a61f0d29a356 added automation task

sync-service
+ 410ef348e381950ad3bd0c481f9b4e5c09810056 added controller and routes
+ 6804abaf643ec6d2cba54629b5980102776a6d0d enforce POST method on update method

Oh! Cool! Die commits wil ik ook! :)

Radio 1 (Tour de France!) op Android

Gepubliceerd op: 13.VII.2009 23:37 CEST
Categorieën: android, wielrennen
Reacties: 3 stuks

Ik word tussen 16u en 18u altijd een beetje rusteloos rond deze tijd van het jaar. Wie gaat er het eerst over de meet en hoe staat het met het klassement?! De NOS heeft het nog niet helemaal begrepen; de Tour 2009 site is veel te lomp voor op een telefoon en eigenlijk wil ik gewoon Radio Tour de France luisteren!

M’n Android telefoon heeft helaas geen FM ontvanger ingebouwd en de Radio 1 live stream is slecht toegankelijk voor mobiele platformen. Na wat onderzoek heb ik dan eindelijk uitgevonden hoe ik de Radio 1 stream op een Android telefoon kan afspelen:

Tada! Radio 1 op je telefoon!

Hup! Lance! Hup!

Abel van 't Veer

Gepubliceerd op: 8.V.2009 05:21 CEST
Categorieën: privee
Reacties: 3 stuks

Op maandag 27 april is onze tweede zoon geboren; Abel van 't Veer. Z’n grote broer, moeder en vader zijn apetrots!