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
| $('html,body').animate({scrollTop: 540}, 700); |
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
| # For RVM | |
| yum install -y bash curl git libxslt # NOTE: For git you need the EPEL repository enabled | |
| apt-get install bash curl git-core | |
| # OS => Redhat/CentOS/Fedora | |
| yum install -y gcc-c++ patch readline readline-devel zlib zlib-devel libyaml-devel libffi-devel openssl-devel | |
| yum install -y make bzip2 | |
| yum install -y iconv-devel # NOTE: For centos 5.4 final iconv-devel might not be available :( | |
| # OS => Debian/Ubuntu |
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
| MODEL.where(params[:student].select{|k,v| !v.blank?}) | |
| MODEL.where(params[:student].reject{|k,v| v.blank?}) |
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
| Array.reject(&:blank?) |
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
| has_many :doors | |
| accepts_nested_attributes_for :doors | |
| attr_accesible :address, :doors_attributes | |
| # 注意是复数 |
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
| 安装了rvm后,openssl和readline LoadError | |
| 当不能load openssl的时候,用以下方法解决 | |
| $ sudo apt-get install libssl-dev | |
| $ cd ~/.rvm/src/ruby-1.8.7/ext/openssl | |
| $ ruby extconf.rb | |
| $ make && make install |
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
| // VIEW: | |
| <% for category in Category.find(:all) %> | |
| <div> | |
| <%= check_box_tag "product[category_ids][]", category.id, @product.categories.include?(category) %> | |
| <%= category.name %> | |
| </div> | |
| <% end %> | |
| // CONTROLLER: |
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
| [core] | |
| editor = vim | |
| [user] | |
| name = HungYuHei | |
| email = [email protected] | |
| [alias] | |
| aa = add . | |
| st = status | |
| ss = stash | |
| sss = stash save |