LogPixels DPI hack

Here's a handy tip for those netbook users out there in dire need of more screen estate. You can force a DPI value of lower than 96 by using the Windows registry. To do so open regedit, navigate to HKEY_CURRENT_CONFIG/Software/Fonts/LogPixels and change the decimal value from 96 to something lower such as 80. Then log out and back in and you will see the changes. I'm using a value of 80 on my netbook and it is about the most that I will drop it while still keeping things (half) readable. You will notice that it really hinders the readability of fonts as well as having some strange bitmap scaling artifacts, but if you're like me and can adjust to it then the extra screen space gained is well worth it :)

You can view a side by side comparison of the my desktop with LogPixels at 80 and at 96 by viewing this imgur album.

http://i.imgur.com/DKnsWm.jpg http://i.imgur.com/JHrJim.jpg

Comment on this post.

Docstrings in my Chicken?

Here's a little bit of amateur code to enable the use of docstrings in Chicken Scheme. I haven't written any Scheme in a few months and don't have any formal training in the ninja art of explicit renaming macros so I'd appreciate any feedback from Scheme veterans:

;;; Docstrings for Chicken!

;; The hash-table that will contain the procedures and their associated
;; documentation strings as well as their code for later use.
(define *documentation-hash-table* (make-hash-table))

;; Documented define er-macro
(define-syntax (define* form r c)
  (let* ((args-form (second form))     ; (proc args)
         (proc-name (first args-form)) ;  proc
         (doc (third form))            ; "The docstring"
         (body (drop form 3)))         ; (everything else)
    (hash-table-set! *documentation-hash-table* proc-name (list doc body)) ; insert the doc and code body
    `(,(r 'define) ,args-form ,@body))) ; Define the procedure as normal

;; Example of a documented procedure, will print a nice-ish list of documented procedures
(define* (print-docs)
  "Print a list of documented procedures"
  (hash-table-walk *documentation-hash-table*
    (lambda (key val)
      (printf "~a => ~a~n  ~a~n~n" key (first val) (second val)))))

Another example of why Scheme is such a fun language to work with :)

Comment on this post.

Twitter's Bootstrap

To me, one of the most annoying parts of prototyping a new web application is getting a presentable look and feel up quickly. When I'm prototyping stuff I love to have a good looking interface from the start, even if that interface will be changed before going live.

Recently, Twitter released a wonderful CSS/JS framework named Bootstrap for this exact purpose. As stated it is a toolkit "[...] designed to kickstart development of webapps and sites.". It combines an aesthetically pleasing base styling (based somewhat off of Twitter itself) of HTML elements with an easy to use CSS grid, great browser compatibility, and various optional Javascript modules to extend functionality of things such as Drop-down menus and modal dialogs.


Das Keyboard Ultimate

I took the plunge recently and bought my first mechanical keyboard, the Das Keyboard Ultimate. It was very hard to find someone that would ship one to NZ, but eventually I found AusPCMarket that ships the Das as well as several other "clicky keyboards". The Das is known for being a bit pricey.. the Ultimate set me back $230NZD (incl shipping and GST) at the current exchange rate and was delivered in just over a week. If you need to justify the price by thinking of it as an investment, then do :)


Tiny Memcached Wrapper

No posts in a while huh! Been pretty busy and haven't thought of much to blog about lately. But I've been playing with Memcache and wanted to share a tiny class I made to add easy caching to my PHP projects. This PHP class just provides a nice simple interface to use by extending the Memcached class:

// Call the class whatever you want
class MyCache extends \Memcached {
    function cache($key, $time, $func) {
        if (($val = $this->get($key)) === false) {
            $val = $func();
            $this->set($key, $val, strtotime($time) - time());
        return $val;

Emacs Tip: Vimpulse

One thing I love about Emacs is that it is so extensible. I was an avid Vim user for a long time and it took me several tries to switch to Emacs, but I will never look back. With the Vimpulse addon to the built-in viper-mode, Emacs becomes a powerful Vim impersonator, capable of being extended with Emacs-Lisp.

A lot of my time is spent doing web development, and so strong HTML editing ability is essential in any editor I use. Vim has this amazing concept of text objects which allows you to be very efficient when transforming text; one of the most useful when doing web development is therefore the XML/HTML tag text object. I would use this all the time by invoking cit to change text between a pair of tags. To demonstrate, here's a piece of text you might have sitting in a file:

<title>Hello |World</title>

Now with the cursor somewhere in between the tags (visualized above by the pipe, '|') we can go into command mode and type cit and the above will be replaced with:


Ready to be edited!

Well sadly, Vimpulse doesn't have this feature by default, probably one of the very few parts of Vim that it doesn't emulate in fact! (NB. Evil contains emulation for this already) But not to worry, we can just add it in! This is Emacs after all.


Org-mode Conky Colorizer

Just whipped up a little script to colorize my org-mode todo lists for display via Conky. It's bound to be of use to someone so I thought I'd better share :)

Here's a screenshot of it in action, sitting in the corner of my desktop.



Adding FreeType to our Demo

Continuing on from my Chicken Scheme, and OpenGL tutorial, I'm going to show you how to extend it to render pretty FreeType text using the FTGL library. Follow the code below for details as always; it's really easy! :)

Users of ArchLinux can get FTGL with a simple sudo pacman -S ftgl. Debian should be something like sudo apt-get install libftgl-dev.

Alright lets start by loading up the code from last time ...



So my warmup for today was to rewrite my old org-mode agenda notification code to use Emacs lisp instead of Python. The aim of this code is to check your org-mode agenda for any headings with DEADLINEs and create a vcalendar for each, and then send them to your phone via Clickatell.


More Practical Chicken

As I love sharing code on my blog, and I love Chicken Scheme, I'm going to share a couple of handy and practical features that I've made use of recently.

Anyone that has used C++ for longer than a few minutes has probably noticed that literal constants (*numbers and such*) often have a suffix attached to them. The most common place that you'll see this is when writing floating-point decimals, ie. 1.0f.

They might seem a little pointless at first, but they have their uses; I swear that I once read of a way to add your own types into the language too.

But anyway, I searched for a way to do this in Chicken too, and it turns out it's really easy (of course!). Chicken provides a function called set-parameterized-read-syntax! that can emulate this functionality quite nicely.

Here's a real world case that I used recently, I wanted to be able to convert from inches into pixels, based on a known DPI (in this case 180). The code to set this up looks like this: