This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
‹ruby-1.9.3@devel› $ irb | |
ruby-1.9.3-preview1 :001 > YAML | |
=> YAML | |
ruby-1.9.3-preview1 :002 > YAML.method(:load) | |
=> #<Method: Module(Kernel)#load> | |
ruby-1.9.3-preview1 :003 > YAML.load "--- hello world!" | |
NoMethodError: private method `load' called for YAML:Module | |
from (irb):3 | |
from /Users/kaichen/.rvm/rubies/ruby-1.9.3-preview1/bin/irb:16:in `<main>' | |
ruby-1.9.3-preview1 :004 > require 'yaml' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/osascript | |
# Get this from http://blog.xupeng.me/2011/09/23/precisely-adjust-volume-in-lion/ | |
# with one fix | |
on usage() | |
set _usage to "Usage: adjust-volume number\n" | |
set _usage to _usage & "For example:\n" | |
set _usage to _usage & " adjust-volume 2\t - increase volume by 2\n" | |
set _usage to _usage & " adjust-volume -2\t - decrease volume by 2" | |
return _usage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "rubygems" | |
require "active_record" | |
require "squeel" | |
n = 5000 | |
conn = { :adapter => 'sqlite3', :database => ':memory:' } | |
ActiveRecord::Base.establish_connection(conn) | |
class User < ActiveRecord::Base |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.Utils = class Utils | |
@className: (obj)-> | |
regex = /^function\s*([^\(]+)/ | |
fnSource = obj.constructor.toString() | |
regex.exec(fnSource)[1] | |
@underscore: (word) -> | |
hanlder = (str, p, offset, s) -> | |
l = p.toLowerCase() | |
if offset == 0 then l else "_#{l}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
foobar = (x) -> not_exist | |
foobar(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<title>Html5 video with jq.tmpl sample</title> | |
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.6.1.min.js"></script> | |
<script src="http://ajax.aspnetcdn.com/ajax/jquery.templates/beta1/jquery.tmpl.js"></script> | |
<script type="text/javascript"> | |
$(document).ready(function () { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})" | |
local current_dir='%{$terminfo[bold]$fg[blue]%} %~%{$reset_color%}' | |
local current_path='%{$terminfo[bold]$fg[blue]%}%c%{$reset_color%}' | |
local rvm_ruby='%{$fg[red]%}‹$(rvm-prompt i v g)›%{$reset_color%}' | |
local git_branch='$(git_prompt_info)%{$reset_color%}' | |
local current_time='%{$fg[yellow]%}%D{[%I:%M:%S]}%{$reset_color%}' | |
local arrow="%{$fg_bold[red]%}$%{$reset_color%}" | |
PROMPT="${current_dir} ${git_branch}${arrow} " |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sass/plugin/rack' | |
Sass::Plugin.options.merge!(:css_location => "./path/to/stylesheets") | |
use Sass::Plugin::Rack | |
run Rack::Directory.new(".") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
org_rails_cmd=`which rails` | |
function rails { | |
if [ $# -eq 0 ];then | |
$org_rails_cmd | |
elif [ -e script/rails ]; then | |
./script/rails $@ | |
elif [ $1 = 'c' ];then | |
shift | |
./script/console $@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// try ruby-like mixin in javascript | |
function mixin(object, name, fn) { | |
var orignal = object[name]; | |
object[name] = function() { | |
try { | |
this.super = orignal; | |
return fn.apply(this, arguments); | |
} finally { |