View base.rb
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
module DataService | |
RELATION_ID = 'relation' | |
module DataApi | |
def self.included base | |
base.singleton_class.send :attr_accessor, # private method | |
:json_attributes, # 数据模型的json属性定义 | |
:expire_time, # 数据模型的过期时间 | |
:model_class, # 数据模型对应的Activerecord, 默认值是根据类名推断, 可以在这里覆盖 | |
:cache_key # 缓存的key, 有默认值, 通常不需要设置 |
View jshint_pre-commit
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
#!/bin/sh | |
files=$(git diff --cached --name-only --diff-filter=ACM | grep ".js$") | |
if [ "$files" = "" ]; then | |
exit 0 | |
fi | |
if ! type "jshint" > /dev/null; then | |
echo "\t\033[31mPlease install jshint first: npm install jshint -g\033[0m" | |
exit 1 |
View quick_sort
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
var rawNumbers = [4,4,3,1,8,5,13,9,2,7,18,10,4]; | |
function qsort(numbers, startIndex, endIndex) { | |
var first = startIndex, | |
last = endIndex, | |
key = numbers[first]; | |
if(first >= last) { |
View prepare-commit-msg
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
#!/bin/sh | |
BRANCH=`git rev-parse --abbrev-ref HEAD` | |
RM_NUMBER=`echo $BRANCH | grep -o -e 'rm[0-9]*' || echo $BRANCH` | |
echo "[$RM_NUMBER]" > "$1.msg" | |
cat "$1" >> "$1.msg" | |
cat "$1.msg" > "$1" |
View blame_after_grep
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/env ruby | |
grep = `git grep -n #{ARGV[0]} #{ARGV[1]}` | |
interrupt = false | |
grep.lines.each do |file_with_line| | |
exit if interrupt | |
file, line_number, line = file_with_line.split(':', 3) |