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
| # ターミナルのウインドウタイトルを変更 | |
| out_title () { echo -ne "\033P\033]0;$*\033\\ \r" ; } | |
| # gnu-screen の子ウインドウ名を変更 | |
| out_screen () { echo -ne "\033k$*\033\\ \r" ; } |
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
| # usage: rails new hogehoge -m https://raw.github.com/gist/946260 | |
| # Copy database.yml | |
| run "cp config/database.yml config/database.sample.yml" | |
| # Delete unnecessary files | |
| run "rm README" | |
| run "rm public/index.html" | |
| #git | |
| git :init |
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
| # reloads the environment | |
| # to read rails env => $ pry -r pry -r ./config/environment.rb | |
| def reload!(print=true) | |
| puts "Reloading..." if print | |
| # This triggers the to_prepare callbacks | |
| ActionDispatch::Callbacks.new(Proc.new {}, false).call({}) | |
| true | |
| end |
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
| # http://d.hatena.ne.jp/yarb/20110112/p1 | |
| line = line.encode("UTF-16BE", :invalid => :replace, :undef => :replace, :replace => '?').encode("UTF-8") |
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
| module Enumerable | |
| def to_proc | |
| proc { |obj, *args| self.map {|v| obj.send(v, *args)} } | |
| end | |
| end | |
| ["abc", "def"].map(&[:camelize, :upcase]) => [["Abc", "ABC"], ["Def", "DEF"]] |
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
| select curdate() - interval day(curdate()) - 1 day |
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
| // usage: | |
| // var target = {hoge: {fuga: 'muga'}}; | |
| // maybe(target, 'hoge', 'fuga') //=> 'muga' | |
| // maybe(target, 'moge', 'fuga') //=> undefined | |
| // maybe(target, 'hoge', 'fuga', ['match', /^m/]) //=> ['m'] | |
| // maybe(target, 'moge', 'fuga', ['match', /^m/]) //=> undefined | |
| function maybe() { | |
| var self = arguments[0]; | |
| var methodChain = [].slice.apply(arguments, [1]); | |
| var len = methodChain.length; |
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
| <input id="todoText" type="text" placeholder="ToDoを入力してね!" | |
| value="" speech x-webkit-speech> |
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 Never | |
| attr_accessor :value | |
| instance_methods.each do |v| | |
| undef_method(v) unless %w(object_id __id__ __send__).include?(v.to_s) | |
| end | |
| def method_missing(*args) | |
| self | |
| end |