Notes

  1. bootstrapping projects

    Automate project creation

    Lately I’m doing a lot of small web projects that, more ore less, have the same folder structure, are based on the same framework, and leverage the same version control system, clearly Git. Therefore I’ve decided to spend some time to automate the project setup process.

    Meet projectBootstrap

    The result of my tinkering is projectBootstrap, a small script in node.js, that given a target folder and a configuration file. Take care of populating it, downloading the dependencies, init the Git repo and crete a .taskpaper file to hold the project todo list.

    When the script is executed it will look for an init.json file inside the target folder. If this is not provided the script will use the default one, that do exist in the script root folder.

    init.json

    The init.json is the configuration file used to bootstrap the project, and it’s where the components for the projects are specified. It is possible to request the following elements:

    • a boilerplate, used to setup the initial folder and files structure
    • one ore more Git submodules
    • a series of libraries
    • a folder name to organize the libraries in
    • the initial commit message
    • and the name of the todo list file

    This is the default init.json you can find on the github project:

    {
                              "boilerplate": "https://github.com/federicoweber/vgHear/raw/master/boilerplate.zip"
                          ,   "subModules": [
                                  "https://github.com/federicoweber/vgHear.git"
                              ]
                          ,   "libs": [
                      
                              ]
                          ,   "commit": "init Repo"
                          ,   "libsPath": "app/js/libs"
                          ,   "todoName": "todo.taskpaper"
                      
                      }
                      

    Running the script

    The target folder is passed with a target environment variable when the script is executed.

    Ex.

    $ target=PROJECT_FOLDER node projectBootstrapp.js
                      

    To make the process faster I’m also leverging a keyboard maestro macro to run the script on the current selected folder in finder.

    here is the macro

    You can find the script on Github.

  2. Is Github the most important social network?

    John G. Norman:

    TL;DR: GitHub is the largest public repository of the everyday experience of work. Ever. If you’re a scholar or journalist interested in collaboration, this is perhaps the most important archive you will find regarding what actually happens as people work together.

    I do think Github is great and on the long run it is a rich log of the history and evolution of software development. That is one of the fields that is pushing the human race forward. But on a mass scale, it can not be as relevant as Twitter, Facebook or Linkein.

  3. The new TBR 7 days content delay business model

    New interesting approach on payment subscription for opinion based websites by the Ben Brooks. Please read the original article for a better insight.

    All non-members of the site will have access to every post that members have access too, with one caveat: non-members won’t see those posts until seven days after I posted them.

    I realize this isn’t ideal, but being as what I write is not time relevant, I feel that this is a decent tradeoff. If you aren’t a member you won’t be able to see what you are, in fact, missing — thus the content is indeed new to you when it does become “unlocked”. (This is the plan at least.)

  4. Street Fighter, combos like, keyboard shortcuts in javascript

    MouseTrap is a lightweight, 1.4kb minified and gzipped, javascript library. Developed by Creaig Campbell. That allow you to, easily create, and listen to keyboard shortcuts.

    The sintax for the implementation is as simple as:

    Mousetrap.bind(['command+s', 'ctrl+s'],function(){
                          //callback goes here
                      });
                      

    And it also allow you to declare sequences of keys like this:

    Mousetrap.bind('up up down down left right left right b a enter', function() {
                          //callback goes here
                      });
                      

    You can find it on github, or test it’s awesomeness firing an Hadoken (down down right right a)

  5. Google Chrome for iOS

    Google have just released Chrome for iOS on the App Store. Unfortunately it’s not running on v8, Apple is not allowing that, and it’s significatively slower than mobile safari. Still it do pack some interesting features. Like the unified address and search bar, and the synchronization of current opened tabs between multiple devices.

  6. My mobile notes taking workflow

    When I stumbled upon Drafts, by Agile Tortoise, I dediced to use it as my mobile note taking app. My choise was dictated by three main reasons:

    • it’s among the fastest writing app on iOS, ready to write as soon as you start it
    • it support textExpander
    • it can save the entries to dropbox

    Integrate it in the overall workflow

    The only problem was to integrate it within my workflow. On the mac I am an nvAlt user and I’m also using a strict naming convention for my files. More or less all my notes files names look like this 20120628-193211-NT-0-tag, where the third element NT is the type of the file, in this case a note. Unfortunately drafts did not allow me to specify the file name and it can only save the file on the sandboxed /Apps/Drafts folder inside dropbox.

    Hazel comes to rescue

    I did fixed that with the help of TextExpander, Hazel and a little bit of appleScript.

    The file name problem is solved using the first paragraph of the note to write it down, the date is included thanks to TextExpander.

    Then on the mac i do have an hazel rule that watch the file content for the notes related tokens, run an appleScipt on it and finally move the files to my main notes folder.

    Here is the script. I think it can be done better, but I’ve just started learning appleScript.

    -- This script is meant to be executed from Hazel
                      -- it will change the file name to the first paragraph 
                      -- set the extension to .md
                      -- and delete the filename from the file content
                      -- by Federico Weber | http://federicoweber.com
                      
                      on hazelProcessFile(theFile)
                          -- get the file name
                          set content to read theFile
                          set newFileName to first paragraph of content
                      
                          -- rename the file
                          tell application "Finder"
                              set name of theFile to newFileName & ".md"
                          end tell
                      
                          -- delete the name of the file from the content 
                          set newContent to get replaceText(newFileName, "", content)
                          set openFile to open for access theFile with write permission
                          set eof of openFile to 0
                          write newContent to openFile starting at eof as text
                          close access openFile
                          return true
                      end hazelProcessFile
                      
                      -- replaceText method by Buce Phillis 
                      -- http://foolsworkshop.com/applescript/2008/05/an-applescript-replace-text-method/
                      on replaceText(find, replace, subject)
                          set prevTIDs to text item delimiters of AppleScript
                          set text item delimiters of AppleScript to find
                          set subject to text items of subject
                      
                          set text item delimiters of AppleScript to replace
                          set subject to "" & subject
                          set text item delimiters of AppleScript to prevTIDs
                      
                          return subject
                      end replaceText
                      
  7. Walrus.js

    Walrus is a new templating library with a interesting twist on presentation logic, and an useful collection of view helpers.

    I’m currently testing it to use it as the default templating language in vgHear

  8. SublimeText 2

    SublimeText 2.0 is officially out, and it’s great. If you do write code for living, do yourself a favor and get it.

    Here is the official article and the comments on HakerNews.