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: http://wordpress-hackers.1065353.n5.nabble.com/custom-post-types-and-child-pages-td38595.html http://wordpress.org/support/topic/custom-post-type-sub-post-template?replies=2 http://wordpress.org/support/topic/custom-post-types-content-subpages?replies=3 http://wordpress.org/support/topic/custom-post-type-creating-sub-pages?replies=4 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 Duration.new recieves a string describing a duration of time, and converts it into: seconds, and a standard readable format. Or, you can pass Duration.new 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. http://svn.ahabman.com/public/many_to_many_view/ 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