curl ifconfig.me
thanks to AskUbuntu
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)
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)