Skip to content

Instantly share code, notes, and snippets.

View ouyangzhiping's full-sized avatar

Zhiping Yang ouyangzhiping

View GitHub Profile
@ouyangzhiping
ouyangzhiping / lisp.rb
Created November 11, 2010 07:45 — forked from dahlia/lisp.rb
# 30 minutes Lisp in Ruby
# Hong Minhee <http://dahlia.kr/>
#
# This Lisp implementation does not provide a s-expression reader.
# Instead, it uses Ruby syntax like following code:
#
# [:def, :factorial,
# [:lambda, [:n],
# [:if, [:"=", :n, 1],
# 1,
# zh-CN translations for Typus (template)
# by ZoOL <http://github.com/zhooul>
zh-CN:
"A valid token is required": "需要验证令牌"
"Actions": "动作"
"Active": "已激活"
"Add": "新增"
"Add %{resource}": "新增 %{resource}"
"Add new": "新增"
@ouyangzhiping
ouyangzhiping / restfull controller textmate snippet
Created June 16, 2011 09:37 — forked from psousa/restfull controller textmate snippet
snippet for resftull controllers in rails. Scope selector: source.ruby.rails
def index
@${1:things} = ${2:Thing}.find :all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @$1 }
end
end
def show
@ouyangzhiping
ouyangzhiping / class_base_003.js.coffee
Created June 20, 2011 01:05 — forked from cnruby/class_base_003.js.coffee
HOW TO USE PROTOTYPE for CofffeeScript
# 理解JavaScript的prototype属性
#
# 类Dog - 类名称
# 属性name - 类Dog的对象属性
# 类属性species - 类Dog的类属性
# 对象dog_a - 类Dog的对象
# 对象dog_b - 类Dog的对象
#
# 类属性species是prototype对象的属性;
# 类Dog.prototype是实例对象共享的对象;
@ouyangzhiping
ouyangzhiping / class_base_004.js
Created June 20, 2011 06:34 — forked from cnruby/class_base_004.js
HOW TO USE METHODS for CofffeeScript
// 理解类的方法
//
// 第一段代码是使用默认类,定义和使用函数
// 第二段代码是使用类<类Person>,定义和使用函数
//
// 函数吃 - 函数名称
// 属性修饰 - 属性名称
// 属性食品 - 属性名称
// 类人 - 类名称
// 对象道喜 - 类的对象名称
@ouyangzhiping
ouyangzhiping / gist:1048632
Created June 27, 2011 10:22 — forked from xdite/gist:1031760
Best Practice of Installing Ruby on Rails on Ubuntu 11.04 ( 2011 version )
  • 警告:請絕對不要跳著裝!*

系統套件

進行 Ubuntu 系統更新 / 安裝 MySQL

 > sudo apt-get update
 > sudo apt-get upgrade
 > sudo apt-get install git
@ouyangzhiping
ouyangzhiping / gist:1048633
Created June 27, 2011 10:22 — forked from xdite/gist:1031760
Best Practice of Installing Ruby on Rails on Ubuntu 11.04 ( 2011 version )
  • 警告:請絕對不要跳著裝!*

系統套件

進行 Ubuntu 系統更新 / 安裝 MySQL

 > sudo apt-get update
 > sudo apt-get upgrade
 > sudo apt-get install git
@ouyangzhiping
ouyangzhiping / .bash_login
Created July 11, 2011 15:58
My .bash_login file with git+brew support+textmate
# PATH ------------------------------------------------------------
export PATH="/usr/local/bin:/usr/local/Cellar/ruby/1.9.2-p180/bin/:/usr/local/sbin:~/bin/:$PATH"
# Add Bash Completion ---------------------------------------------
if [ -f `brew --prefix`/etc/bash_completion ]; then
. `brew --prefix`/etc/bash_completion
fi
# Add Bash Completion support for Brew ----------------------------
source `brew --prefix`/Library/Contributions/brew_bash_completion.sh
@ouyangzhiping
ouyangzhiping / nginx.sh
Created September 6, 2011 08:47 — forked from marshluca/nginx.sh
/etc/init.d/nginx
# /etc/init.d/nginx
#! /bin/sh
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
@ouyangzhiping
ouyangzhiping / gist:1479171
Created December 14, 2011 23:55 — forked from samqiu/railscasts.rb
download railscast video
#!/usr/bin/ruby
require 'rss'
p 'Downloading rss index'
rss_string = open('http://feeds.feedburner.com/railscasts').read
rss = RSS::Parser.parse(rss_string, false)
videos_urls = rss.items.map { |it| it.enclosure.url }.reverse
videos_filenames = videos_urls.map {|url| url.split('/').last }