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
| # download video from youtube subscription | |
| # depends: youtube-dl | |
| # OS: windows | |
| require 'open-uri' | |
| require 'hpricot' | |
| USERNAME = '' | |
| YOUTUBE_DL_PATH = "python C:\\programs\\Video\\youtube\\youtube-dl\\youtube-dl.py" | |
| YOUTUBE_DL_PARAMS = "--retries=30 --max-quality=22 -c -i -w" |
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
| curl -silent http://checkip.dyndns.org | grep -Eo '([0-9]{1,3}\.){3}[0-9]{1,3}' | pbcopy |
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
| # same as redirect_to(:back) but works even if no referer (e.g. via direct url) | |
| # include this module to ApplicationController | |
| module BackDefaultRedirect | |
| protected | |
| # use as redirect_to back_or_default(root_url) | |
| def back_or_default(default = '/') | |
| referer = request.env['HTTP_REFERER'] | |
| # if has HTTP_REFERER and it not equals current url | |
| if referer && !referer.include?(request.request_uri) |
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
| desc "Shortcut for functional tests" | |
| task :f => "test:functionals" | |
| desc "Shortcut for unit tests" | |
| task :u => "test:units" | |
| desc "Shortcut for integration tests" | |
| task :i => "test:integration" | |
| desc "Run unit and functional tests" |
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
| if Rails.logger.level = Logger::DEBUG | |
| ActiveRecord::Base.module_eval do | |
| class << self | |
| def find_by_sql_with_instantiate_logging(sql) | |
| message = connection.send(:format_log_entry, "#{name} Load+Instantiate") | |
| ActiveRecord::Base.benchmark(message, Logger::DEBUG, false) do | |
| find_by_sql_without_instantiate_logging(sql) | |
| 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
| server { | |
| listen 80; | |
| server_name APP.com; | |
| rewrite ^/(.*) http://www.APP.com/$1 permanent; | |
| } | |
| server { | |
| listen 80; | |
| server_name www.APP.com; | |
| root /home/USER/sites/APP/current/public; |
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 ActiveRecordSelectAttributesExtension | |
| def select_id(field = 'id') | |
| select_values(field) | |
| end | |
| def select_values(field = nil) | |
| scope = field ? self.scoped.select(field) : self.scoped | |
| connection.select_values(scope.to_sql) | |
| 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
| require 'json' | |
| require 'open-uri' | |
| gists = JSON.parse(open("http://gist.github.com/api/v1/json/gists/#{ENV['GIST_USER']}").read)['gists'] | |
| repos = gists.map{|g| g['repo']} | |
| existing, new = repos.partition{|r| File.exists?(r)} | |
| new.each do |r| | |
| puts "clone new #{r} gist" | |
| `git clone git://gist.github.com/#{r}.git` |