This file contains 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 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 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 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 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 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 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 ApplicationController < ActionController::Base | |
include ColorizedPrint if Rails.env.development? | |
end |
This file contains 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 | |
# Returns an array of arrays containing the field values. | |
# Order is the same as that returned by +columns+. | |
# select_rows("id, type") => [[1, 'one'], [2, 'one'], [3, 'two']] | |
def select_rows(fields = nil) | |
scope = fields ? self.scoped.select(fields) : self.scoped | |
connection.select_rows(scope.to_sql) | |
end |