How to install and build a custom Zepto library

If you’re searching for a light-weight JavaScript library similar to jQuery to use in your development for mobile hybrid app (i.e. with PhoneGap) then Zepto is your choice! This library it’s really compact, open source (MIT license), weights just 9.2kB and if you already know jQuery (who doesn’t?) Zepto APIs match jQuery ones…

Zepto’s default package contains these modules: zepto, event, ajax, form and ie (check Zepto site for explanations and full list of modules!).

A very cool thing about Zepto is that you can create your own package with only needed modules! To build a custom Zepto library you should have Node.js installed on your system and follow these steps (for linux and OSX):

  • download Zepto source code from Github (i.e. in zip archive)
  • unzip it and open a terminal in that directory (i.e. you should be inside something like ‘/tmp/zepto-master/’)
  • execute following command:
    • npm install
    • npm run-script dist
    • MODULES=”zepto event data” npm run-script dist

…where “zepto event data” is a space-separated list of wanted modules! After this you should find your Zepto custom library (uncompressed, minified and gzipped) inside ‘dist’ directory (i.e. ‘/tmp/zepto-master/dist/’)…

Please note that inside your custom library you can find in the first line a comment with your choosen modules.

Modify apple keyboard “home” and “end” button behavior

I recently switched for work to a new Apple Mackbook Pro. Excellent machine even if, coming from KDE, I have something to complain about windows management… but let’s skip to the problem. For my desk setup I use an old Apple Keyboard with Numeric Keypad: I was getting frustrated about the “Home” and “End” button… their actual behavior (e.g. in libreoffice) is to bring you to the beginning/ending of the document instead of beginning/ending of the line you’re on like on Linux (and Windows perhaps).

After a 2 minutes googling I found a solution: you got to create a file (and relative containing directory) with a configuration file tweak for keys bindings. The file is “~/Library/KeyBindings/DefaultKeyBinding.dict” and what you got to in is the following code:

   "\UF729"  = moveToBeginningOfLine:; // home
   "\UF72B"  = moveToEndOfLine:; // end
   "$\UF729" = moveToBeginningOfLineAndModifySelection:; // shift-home
   "$\UF72B" = moveToEndOfLineAndModifySelection:; // shift-end

This solution it’s not universal… so for example Xcode, Terminal and other cross-platform applications wouldn’t understand them.