Category Archives: code

dot-vimrc/vimrc at master · humiaozuzu/dot-vimrc · GitHub

  Source: dot-vimrc/vimrc at master · humiaozuzu/dot-vimrc · GitHub   Many usability improvements here.   source ~/.vim/bundles.vim ” encoding dectection set fileencodings=utf-8,gb2312,gb18030,gbk,ucs-bom,cp936,latin1 ” enable filetype dectection and ft specific plugin/indent filetype plugin indent on ” enable syntax hightlight and completion syntax on “——– ” Vim UI “——– ” color scheme set background=dark color solarized ” […]

Posted in code | Tagged | Leave a comment

WordPress Custom Post Type Dynamic Sub Pages

The Problem You can’t separate a Custom Post Type into multiple pages. e.g. a project home page, and a project details sub page, and a project activity sub page, etc. Related Links: A Solution Utilize add_rewrite_tag and add_rewrite rule inside functions.php. This will allow you to have URLs like: /project/project-title (default […]

Posted in code | 1 Comment

Rhythm visualization

Launch the rhythm visualization demo Continuing from my first iteration on a visual metronome, this is an improvement to simplify things while providing greater control in the UI for: tempo, cycles (bars), beats, and emphasis highlighting (nth). My intention is for this to evolve toward a metric modulation visualization. I moved from the traditional European […]

Also posted in javascript, jQuery, music | Leave a comment

Command finished notification with Ruby

I wanted a visual notification in Ubuntu when long running commands finished in Terminal. My solution, run the command and pipe it into notify. $ a-long-running-command | notify notify.rb Make it executable add an alias to it in ~/.bashrc Requires: ruby, rubygems, and libnotify. Similar solutions: “alert” alias (I’ll be switching to this in Maverick), […]

Also posted in ruby, ubuntu | Leave a comment

Visual Metronome

Also posted in javascript | 2 Comments

Ruby Duration

Download ruby duration lib recieves a string describing a duration of time, and converts it into: seconds, and a standard readable format. Or, you can pass an integer representing seconds, and receive the same standard readable format. Usage: Passing a String Passing an Fixnum (of seconds)   Example valid input strings: “2 weeks”, […]

Also posted in ruby | 1 Comment

rails template

Usage $ rails app_name -m ./ahabman_template.rb

Also posted in rails | Leave a comment

ruby on rails – has and belongs to many view plugin

So I’ll never have to write another has_and_belongs_to_many view again, here’s a plugin that dynamically makes 2 <ul> lists which you drag and drop both ways to manage the association. From the readme: Assumming you have an @project var and you want to associate people with it. “shared/m2m”, :locals => { :thing => @project, […]

Also posted in rails | Leave a comment

You can’t use class variables in rails.

You can’t use class variables in rails. Unless you’d like to develop in production mode (specifically with config.cache_classes = true). In development mode all classes are reloaded on each request, which clears all class variables. I had the perfect place to use them – while running a mass synchronization, and needing to store the timestamp […]

Also posted in rails | Leave a comment

ruby csv to structured hash

I had a csv like this: object color flavor shape apple red sweet round banana yellow sweet long lemon yellow sour round and I wanted a ruby hash structured like this: So I wrote this, which does the job:

Also posted in rails, ruby | 1 Comment