Skip to content

Instantly share code, notes, and snippets.

View sadfuzzy's full-sized avatar
🎯
Focusing

Denis Savitskiy sadfuzzy

🎯
Focusing
View GitHub Profile
@sadfuzzy
sadfuzzy / rvm2rbenv.md
Last active October 2, 2015 11:08 — forked from brentertz/rvm2rbenv.txt
Switch from RVM to RBENV (Mac OS)

Prepare

Remove RVM

rvm implode

Ensure your homebrew is working properly and up to date

brew doctor
@sadfuzzy
sadfuzzy / restore_brew_bin_links.sh
Created December 28, 2012 21:43
If you, like me (during RMagick gem and ImageMagick lib install) removed all Brew links from /usr/local/bin, use this script to generate them back
@sadfuzzy
sadfuzzy / psql_cheatsheet.md
Last active September 26, 2015 14:20
PostgeSQL Cheatsheet

PostgreSQL Cheatsheet

PSQL main commands

Opening PostgreSQL console:

psql -h <hostname> -U <user> <db> # db is optional

Working with pgsql console

@sadfuzzy
sadfuzzy / dis_apache_enbl_nginx.md
Created April 22, 2014 15:07
Disable PostgreSQL EnterpriseDB's Apache server and enable nginx in Mac OS X

Disable PostgreSQL EnterpriseDB's Apache server and enable nginx in Mac OS X

Disable PostgreSQL EnterpriseDB's Apache server

sudo launchctl unload /Library/LaunchDaemons/com.edb.launchd.postgresql-x.x.plist
sudo rm -f /Library/LaunchDaemons/com.edb.launchd.postgresql-x.x.plist

Enable nginx, installed through brew

sudo cp /usr/local/opt/nginx/homebrew.mxcl.nginx.plist /Library/LaunchDaemons/

iTerm2 – Useful Shortcuts (Mac OS X)

with a hat tip to Sublime Text 2 Shortcuts

The Awesome

⌘; autocomplete
⌘⌥B instant replay
⌘⌥E search across all tabs
@sadfuzzy
sadfuzzy / prepare-commit-msg.sh
Last active August 29, 2015 14:04
Add branch name (and description) at the beginning of commit message
# Automatically adds branch name and description to every commit message.
#
DESCRIPTION=$(git config branch."$NAME".description)
if ! [[ $@ == *HEAD* ]] then
NAME=$(git branch | grep '*' | sed 's/* //')
echo "$NAME"': '"`cat "$1"`" > "$1"
fi
if [ -n "$DESCRIPTION" ] then
@sadfuzzy
sadfuzzy / .rubocop.yml
Created October 29, 2014 13:53
Rubocop config file (Mili), place it in your home directory
AllCops:
RunRailsCops: true
Style/Encoding:
Enabled: false
Style/AsciiComments:
Enabled: false
Lint/AssignmentInCondition:
@sadfuzzy
sadfuzzy / ruby_strings.md
Last active August 29, 2015 14:08
Ruby strgins operation

%Q (executes #{})

This is an alternative for double-quoted strings, when you have more quote characters in a string.Instead of putting backslashes in front of them, you can easily write:

>> %Q(Joe said: "Frank said: "#{what_frank_said}"")
=> "Joe said: "Frank said: "Hello!"""
@sadfuzzy
sadfuzzy / lunch_list.rb
Last active August 29, 2015 14:08
Lunch List generator
class LunchList
NAMES = %i(DimaS DimaG Denis SergeyStat SergeyAdm Oleg Alena).shuffle
MIN_EATERS = 3
MAX_EATERS = 4
def generated_list
decisions = {}
NAMES.map do |name|
decisions[name] = rand(0..1).zero? ? 'wait' : 'go!'
end
@sadfuzzy
sadfuzzy / session_generator.rb
Created December 3, 2014 10:35
Rails 3 session generator
class SessionCookieGenerator
def self.generate user_obj
new(user_obj).generate
end
def initialize user_obj
@user = user_obj
@cookie = {}
@session = {'rack.session' => {}}
end