rvm get latest --auto rvm install 1.9.3 gem update --system # 1.3.7 # that's it for downgrading
gem update bundler # which I actually keep in my Gemfile bundle update
Tech stuff around computer programming, basically for web development, especially opensource. Topics will go round Ruby on Rails (git gems etc.), Ubuntu (admin and basic shell) and work organization (agile philosophy)
rvm get latest --auto rvm install 1.9.3 gem update --system # 1.3.7 # that's it for downgrading
gem update bundler # which I actually keep in my Gemfile bundle update
find . -name file_name # path first option without equal grep -rn string . --context=5 # path last # count the lines of ruby ( find ./ -name '*.rb' -print0 | xargs -0 cat ) | wc -l rails -e production rake x:y x:z RAILS_ENV=test # chain tasks and env is loaded only once rails c production --sandbox rails dbconsole -p'whatever' tailf log/development.log | grep -v ECONNREFUSED -E 'Processing|Render|Parameters' # show actions and templates only ssh user@host 'ls -l' scp -C user@host /tmp/db.sql /tmp/db.sql # -C will compress the data over the wire curl -Lk --user user:pwd --data "param1=value1¶m2=value2" http://url service --status-all netstat -an | grep "LISTEN " # check the open ports free -m # check the ram df -H # check the disk curl --user usr:pwd -Lkv --data "param1=value1¶m2=value2" www.url.com/post_here scp -C urs@url:/origin/ destination/
ncdu / # disk usage
# Search for a word in log diff
git log -S"def email_required"
# display branches in activity order
git for-each-ref --sort=-committerdate --format='%(committerdate:short) %(refname)' refs/heads refs/remotes
# checkout previous branch
git checkout -
git checkout @{-1}
# get rid of the latest changes and restore to the sha
git checkout sha1
# undo latest pull
git reset HEAD@{1}
git checkout .
# discard conflicting changes in a dir (after merge)
git co --theirs dir/ # discard their changes
git co --ours dir/ # discard our changes
# stash
git stash save "name of the stash"
git stash apply
git stash help
# checkout a new branch from origin
git checkout -b new origin/new
# tags
git tag "tag-name"
git push --tags
# bisect for debugging
git bisect start
git bisect bad
git co 32c4bf6 # (known good sha)
git bisect good
# create a patch
git format-patch -1 sha1
# and to apply it
git am 0001-commit-name.patch
# ignore a committed file
# add the file to .gitignore
git rm --cache your_file
# ignore the repo
git update-index --assume-unchanged .ruby-version
# delete a remote branch
git push origin --delete branch_name
# rename a branch
git branch -m old_name new_name
# all your commits on any branch in the last x months
git log --pretty=format:"%ad:%h:%B" --date=short --reverse --all --author=erik --since=1.day.ago
# count the lines of code of your app
git ls-files app/ | xargs wc -l
# undo a merge that was already pushed:
git revert -m 1 merge_hash
#
#
Here great post on git tips
.gitignore_global (add .rbenv-gemsets)echo "-d=postgresql --skip-bundle -T" > ~/.railsrc # $ rvm gemset create opera_wbe # $ gem install bundler --no-rdoc --no-riNOTE: the `-T` option will change the `config/application.rb` as this following top group instead of loading `rails/all` (very nice!):
# Pick the frameworks you want:
require "active_record/railtie"
require "action_controller/railtie"
require "action_mailer/railtie"
require "active_resource/railtie"
require "sprockets/railtie"
# require "rails/test_unit/railtie"
module OperaWbe
class Application < Rails::Application
# migration with numbers (001, 002, ...) in stead of timestamp
config.active_record.timestamped_migrations = false
# in production actually
# prepend assets path
# config.action_controller.asset_host = ASSETS_PATH
# in development actually
# Remove assets logging
config.assets.logger = false # ~only~ one line each asset request
# [...]
Also I find the following files very useful
~/.irbrc # with global functions to call in the console ~/workspace/.rvmrc # which loads my @new gemset ~/workspace/every_app/.rvmrc # with the following...
rvm ruby-1.9.2-p290@new # with bundler and rails only rvm gemdir # show the gemdir everytime you change project
# .irbrc puts 'Using irb console helper functions from ~/.irbrc' # returns the list of methods not inherited from Object # it will not show methods overwritten from `Object.new` # eg: `y ml String.new` def ml(object) (String.public_methods - object.methods).sort endThen my prompt looks like this:
21:43:02-6950 - ~/workspace> cat ~/.bashrc
[...]
# some more ls aliases
alias ll='ls -l'
alias la='ls -A'
alias lo='ls -o'
# colorful, with time, history id and path (also in window title)
# export PS1="\[\e]0;\w\a\]\e[1;36m\t-\! - \w>\e[m "
export PS1="\[\e]0;\w\a\e[1;36m\]\t-\! - \w>\[\e[m\] "
# TODO: git branch in prompt
# ror workspace available everywhere
export CDPATH=$CDPATH':/home/erik/workspace/'
## big bash history
export HISTSIZE=20000
# append all commands to the history file, don't overwrite it at the start of every new session
shopt -s histappend
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # This loads RVM into a shell session.
cd .
And yes, I know, at the moment without without the git branch, it's messing with the color.
echo 'gem: --no-ri --no-rdoc' >~/.gemrc # never install gem docA couple of config for git, get the book here
[color] diff = true status = true branch = true [alias] co = checkoutSetup Sublime Text and customize it as such