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
| def expand_url(url) | |
| if url.first == '/' | |
| url = request.protocol + request.host + (request.port=='80' ? '' : ":#{request.port}") + url | |
| end | |
| url | |
| 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
| *.swo | |
| *.swp | |
| db/*.sqlite3 | |
| log/*.log | |
| mkmf.log | |
| nbproject | |
| public/system/datas/* | |
| tmp/* |
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
| #!/usr/bin/ruby | |
| def git_branch | |
| (%x{git branch 2> /dev/null}.grep(/^\*/).first || '').gsub(/^\* ([a-z0-9_]+)[[:space:]]+$/i, '\1') | |
| end | |
| def set_color color | |
| "\033[#{color}m" | |
| end | |
| def print_result result |
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 Paperclip | |
| class Attachment | |
| def geometry(style = :original) | |
| @geometry ||= {} | |
| @geometry[style] ||= Paperclip::Geometry.from_file(path(style)) | |
| 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
| ru: | |
| devise: | |
| sessions: | |
| link: 'Войти' | |
| signed_in: 'Вы вошли.' | |
| signed_out: 'Вы вышли.' | |
| unauthenticated: 'Вы должны войти или зарегистрироваться, прежде чем сможете продолжить.' | |
| unconfirmed: 'Вы должны подтвердить Ваш аккаунт, прежде чем сможете продолжить.' | |
| locked: 'Ваш аккаунт заблокирован.' | |
| invalid: 'Неверный пароль или email.' |
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
| ;(function($){ | |
| jQuery.fn.serializeJSON = function(){ | |
| var aData = $(this).serializeArray(); | |
| var result = {} | |
| for(key in aData){ | |
| result[aData[key].name] = aData[key].value; | |
| } | |
| return result; | |
| } |
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
| ;(function($){ | |
| jQuery.fn.serializeJSON = function(){ | |
| var aData = $(this).serializeArray(); | |
| var result = {} | |
| for(key in aData){ | |
| result[aData[key].name] = aData[key].value; | |
| } | |
| return result; | |
| } |
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/sh | |
| rsync -a --no-perms --no-owner --no-group -vz --exclude=".git" --exclude="*.swp" --exclude=".gitignore" --exclude="deploy.sh" ./ user@host:/path/to/htdocs/ |
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 ApplicationController < ActionController::Base | |
| # Add this to your application_controller | |
| def self.authorized_inherited_resources | |
| inherit_resources | |
| before_filter :authorize_resource_with_cancan | |
| define_method(:authorize_resource_with_cancan) do | |
| case action_name.to_sym | |
| when :new, :create |
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 symbolize_keys! | |
| self.each do |key, val| | |
| self.delete(key) | |
| if val.is_a? Hash | |
| self[key.to_sym] = val.symbolyze_keys | |
| elsif val.is_a? Array | |
| self[key.to_sym] = val.map{|el| el.symbolyze_keys} | |
| else |
OlderNewer