This file contains hidden or 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
(function($) { | |
$.fn.clippy = function(text, bgcolor) { | |
if (!bgcolor) { | |
var node = $(this); | |
while (node.css('background-color') == 'transparent' && node.length) { | |
node = node.parent(); | |
} | |
if (!node.length) { | |
bgcolor = '#ffffff'; | |
} else { |
This file contains hidden or 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
# rails new NAME -OJ -m https://gist.github.com/raw/903515/rails-template.rb | |
remove_file 'README' | |
remove_file 'public/index.html' | |
remove_file 'public/images/rails.png' | |
prepend_file 'config/boot.rb' do <<-RB | |
begin | |
require 'yaml' | |
YAML::ENGINE.yamler = 'syck' |
This file contains hidden or 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
# coding: UTF-8 | |
# | |
# 以下为 Rake 任务,功能是将普通文件系统里面的东西转移到 MongoDB GridFS 里面 | |
# 此代码片段来自于 Homeland 项目: https://github.com/huacnlee/homeland/tree/mysql | |
# 场景: | |
# 老架构 Linux File Store, Paperclip, hash 目录:"https://github.com/huacnlee/homeland/blob/ca0bdd8ab26da7b780e2dae7eba12b79f41e6d65/config/initializers/paperclip_hashpath.rb" | |
# 新架构 Mongodb GridFS, Garrierwave, 继续沿用 Paperclip 目录兼容: https://github.com/huacnlee/homeland/tree/7100ce4c506cc2c4387f25e50c533e5bbcac6cc2/app/uploaders | |
# 整个过程不会修改任何原始数据库和上传文件 | |
# | |
require 'mongo' |
This file contains hidden or 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
[alias] | |
st = status | |
rso = remote show origin | |
# e.g. git graphviz --first-parent master | dotty /dev/stdin | |
graphviz = "!f() { echo 'digraph git {' ; git log --pretty='format: %h -> { %p }' \"$@\" | sed 's/[0-9a-f][0-9a-f]*/\"&\"/g' ; echo '}'; }; f" | |
# Pretty log | |
lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative | |
# Print out all commits whose hash starts with a given string | |
abbr = "!sh -c 'git rev-list --all | grep ^$1 | while read commit; do git --no-pager log -n1 --pretty=format:\"%H %ci %an %s%n\" $commit; done' -" | |
# Two little tweaks to diff |
This file contains hidden or 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
CREATE DATABASE `databasename` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; | |
CREATE USER 'user'@'localhost' IDENTIFIED BY 'mypass'; | |
GRANT ALL ON databasename.* TO 'user'@'localhost'; |
This file contains hidden or 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
~/project $ git init | |
~/project $ git add . | |
~/project $ git commit -m "first commit" | |
~/project $ cd ~/Dropbox/git | |
~/Dropbox/git $ mkdir project.git | |
~/Dropbox/git $ cd project.git | |
~/Dropbox/git $ git init --bare | |
~/Dropbox/git $ cd ~/project |
This file contains hidden or 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
# | |
# lib/mongoid/counter_cache.rb | |
# ruby | |
# | |
# Created by Zhang Alex on 2011-06-17. | |
# Copyright 2011 __ZhangHanDong__. All rights reserved. | |
# | |
# =================================== | |
# class Forum | |
# references_many :topics |
This file contains hidden or 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
# Chinese (China) translations for Devise 2.0 | |
# by HungYuhei (https://github.com/HungYuHei) | |
# forked from https://gist.github.com/1319590 | |
zh-CN: | |
errors: | |
messages: | |
expired: "您已过期,请重新申请" | |
not_found: "没有找到" | |
already_confirmed: "已经激活,请重新登录." |
This file contains hidden or 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
class PostsController < ActionController::Base | |
def create | |
Post.create(post_params) | |
end | |
def update | |
Post.find(params[:id]).update_attributes!(post_params) | |
end | |
private |
This file contains hidden or 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
- Install "Command Line Tools for XCode" (Get it from Apple Developer Program) or Install XCode via Appstore | |
where option one is the faster one, 170MB vs 1.xGB | |
- Install https://github.com/sstephenson/rbenv | |
git clone into your home folder; | |
set environment variables, see install docs of rbenv; | |
- Get libyaml | |
wget http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz | |
configure |
OlderNewer