Skip to content

Instantly share code, notes, and snippets.

View lenage's full-sized avatar
:octocat:
Focusing

Yuan He lenage

:octocat:
Focusing
View GitHub Profile
@lenage
lenage / test.rb
Created August 28, 2012 17:45
Get mp3info from a fold use ruby
require 'mp3info'
dir = File.expand_path("../", __FILE__)
Dir["#{dir}/*"].each do |sub_dir|
if File.directory?(sub_dir)
Dir.entries(sub_dir).each do |file|
if file =~ /mp3/
title = file.split("-").last.sub(/.mp3/, "")
artist = file.scan(/_(\w+)/).flatten.first
Mp3Info.open( sub_dir + "/" + file ) do |mp3|
@lenage
lenage / gist:1924529
Created February 27, 2012 15:19 — forked from toamitkumar/gist:952211
Inspect and test routes on console (Rails 3)
$ rails console
Loading development environment (Rails 3.0.6)
ruby-1.8.7-p334 :001 > r = Rails.application.routes
Gives you a handle of all the routes (config/routes.rb)
#Inspect a named route:
ruby-1.8.7-p334 :005 > r.recognize_path(app.destroy_user_session_path)
=> {:action=>"destroy", :controller=>"sessions"}
@lenage
lenage / commit-msg
Created August 3, 2011 07:51 — forked from mmrwoods/commit-msg
Commit and merge hooks for Github and Lighthouse
#!/usr/bin/env ruby
# When committing directly to master, look for lighthouse ticket number in commit msg and, if necessary, append in format recognised by github
# When committing to a topic/feature branch, barf if the branch name doesn't include a ticket number that can be parsed by the post-merge hook
# Note: this hook only applies when -m option used and can also be skipped by using --no-verify option
COMMIT_MASTER_STATE = 'coding-done'
branchname = `git branch --no-color 2> /dev/null`[/^\* (.+)/, 1]
@lenage
lenage / gist:1115580
Created July 30, 2011 14:22
Ruby Style Guide
Original Source: https://github.com/chneukirchen/styleguide
= Christian Neukirchen's Ruby Style Guide
You may not like all rules presented here, but they work very well for
me and have helped producing high quality code. Everyone is free to
code however they want, write and follow their own style guides, but
when you contribute to my code, please follow these rules: