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
| # put this function in your .zshrc | |
| function v() {vim ${${=*/:/ +}/:*}} |
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
| require 'open-uri' | |
| class Http | |
| def self./(url) | |
| open("http://#{url}").read | |
| end | |
| end | |
| class String | |
| def com | |
| self + '.com' |
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
| ruby-1.9.3-p0> Benchmark.ms { 100000.times { 'a-b-c-d-e'.gsub /-/, '_' } } | |
| => 422.281 | |
| ruby-1.9.3-p0> Benchmark.ms { 100000.times { 'a-b-c-d-e'.gsub '-', '_' } } | |
| => 471.096 |
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
| SRC_DIR = '/Users/a_matsuda/Music/iTunes/iTunes Media/Music' | |
| TARGET_DIR = '/Users/a_matsuda/Bitcasa/backup/Music/iTunes/iTunes Media/Music' | |
| def cache_is_empty? | |
| s = `du -s ~/Library/Caches/com.bitcasa.Bitcasa/Data/bks/outgoing | awk '{print $1}'` | |
| s.to_i.zero? | |
| end | |
| def already_copied?(artist) | |
| File.exists? "#{TARGET_DIR}/#{artist}" |
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 Hash | |
| def try(*a, &b) | |
| if (a.size == 1) && a.first.is_a?(Array) && (a.first.size == 1) | |
| self.fetch a.first.first | |
| else | |
| super | |
| end | |
| end | |
| 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
| git :init | |
| git :add => '.' | |
| git :commit => "-m 'Initial commit'" | |
| remove_file 'public/index.html' | |
| git :add => 'public' | |
| git :commit => "-a -m 'rm public/index.html'" | |
| generate :model, 'user name' | |
| generate :model, 'recipe title user:references' |
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
| #!/bin/zsh | |
| for b in `git branch -r | grep "^ origin" | cut -c 10- | fgrep -v HEAD | grep -v master`; do | |
| git checkout -t origin/${b} | |
| done |
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
| # do not shallow_clone from Git repo | |
| namespace :deploy do | |
| namespace :assets do | |
| # perform precompile only when any of the asset files has changed since the last deploy | |
| task :precompile, :roles => :web, :except => {:no_release => true} do | |
| from = source.next_revision(current_revision) | |
| asset_changing_files = ['vendor/assets/', 'app/assets/', 'lib/assets', 'Gemfile', 'Gemfile.lock'].select {|f| File.exists? f} | |
| if capture("cd #{latest_release} && #{source.local.log(from)} #{asset_changing_files.join(' ')} | wc -l").to_i > 0 |
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
| % rake stats | |
| +----------------------+-------+-------+---------+---------+-----+-------+ | |
| | Name | Lines | LOC | Classes | Methods | M/C | LOC/M | | |
| +----------------------+-------+-------+---------+---------+-----+-------+ | |
| | Controllers | 4327 | 3478 | 110 | 361 | 3 | 7 | | |
| | Helpers | 384 | 331 | 0 | 35 | 0 | 7 | | |
| | Models | 2912 | 2177 | 84 | 226 | 2 | 7 | | |
| | Libraries | 281 | 230 | 8 | 39 | 4 | 3 | | |
| | Model specs | 3096 | 2663 | 0 | 0 | 0 | 0 | | |
| | Controller specs | 1005 | 783 | 0 | 3 | 0 | 259 | |
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
| require 'cases/helper' | |
| require 'cases/migration/helper' | |
| require MIGRATIONS_ROOT + '/valid/2_we_need_reminders' | |
| class Reminder < ActiveRecord::Base; end | |
| class FailingMigrationTest < ActiveRecord::TestCase | |
| self.use_transactional_fixtures = false |