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
echo 'alias "поехали!"="bundle exec cap deploy"' >> ~/.bashrc |
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
#Based on https://github.com/jimeh/git-aware-prompt | |
find_git_branch() { | |
local branch | |
if branch=$(git rev-parse --abbrev-ref HEAD 2> /dev/null); then | |
if [[ "$branch" == "HEAD" ]]; then | |
branch='detached*' | |
fi | |
git_branch=" ($branch)" | |
else | |
git_branch="" |
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
set :unicorn_config, -> { current_path.join('config/unicorn.rb') } | |
set :unicorn_pid, -> { shared_path.join('tmp/pids/unicorn.pid') } | |
namespace :unicorn do | |
desc 'Stop Unicorn' | |
task :stop do | |
on roles(:app) do | |
if test("[ -f #{fetch(:unicorn_pid)} ]") | |
execute :kill, capture(:cat, fetch(:unicorn_pid)) | |
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
App.Router.reopen({ | |
location: 'history' | |
}); |
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
# Using instance_eval | |
# Time: 0.267886376 | |
Benchmark.measure do | |
1000000.times { 1.instance_eval { self+1 } } # => 2 | |
end | |
# Using tap+break | |
# Time: 0.304528147 | |
Benchmark.measure do | |
1000000.times { 1.tap { |o| break o+1 } } # => 2 |
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 FormTagHelper | |
# see http://api.rubyonrails.org/classes/ActionView/Helpers/FormTagHelper.html#method-i-utf8_enforcer_tag | |
def utf8_enforcer_tag | |
''.html_safe | |
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
class Product < ActiveRecord::Base | |
attr_accessor :publisher | |
# ... | |
before_save { publisher.try(:broadcast, :before_save self) } | |
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
#!/bin/bash | |
# Updates rbenv and it's plugins to latest versions | |
rbenv_path="$HOME/.rbenv" | |
plugins_path="$rbenv_path/plugins" | |
echo -e "\033[1;32mUpdating rbenv\033[0m" | |
cd "$rbenv_path" | |
git pull | |
for plugin in $(ls "$plugins_path"); do |
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
_ex_.backtrace[0].tap { |v| s = v.split(':'); `gvim --remote-tab +#{s[1]} #{s[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
#!/bin/bash | |
if [ "$1" = '-r' ] | |
then | |
dialog --clear --yesno 'Do you realy want to remove crontab?' 5 45 || exit | |
fi | |
/usr/bin/crontab $@ |
OlderNewer