Skip to content

Instantly share code, notes, and snippets.

View marcusshepp's full-sized avatar
🎯
Focusing

Marcus Shepherd marcusshepp

🎯
Focusing
View GitHub Profile
@marcusshepp
marcusshepp / add_attr.js
Created August 4, 2016 12:51
vanilla js add attribute
document.createElement("div").setAttribute("style", "color:blue;")
@marcusshepp
marcusshepp / ip.sh
Created August 2, 2016 18:40
find public ip address
dig +short myip.opendns.com @resolver1.opendns.com
@marcusshepp
marcusshepp / pop_commit.sh
Last active July 20, 2016 12:47
pop last commit
# with changes to become unstaged
git reset HEAD~
# to blow away commit and changes
git reset --hard HEAD~
# http://stackoverflow.com/questions/927358/how-do-you-undo-the-last-commit
@marcusshepp
marcusshepp / count_commits.sh
Last active July 18, 2016 19:48
count commits
git shortlog -s -n
# for all branches
git shortlog -s -n --all
@marcusshepp
marcusshepp / what_changed.sh
Created July 18, 2016 13:28
list changed files between two commits
# between two commit sha's
git diff --name-only SHA1 SHA2
# see the differences between the tenth latest commit and the fifth latest (or so).
git diff --name-only HEAD~10 HEAD~5
@marcusshepp
marcusshepp / ec2_setup.sh
Last active July 13, 2016 19:13
new amazon ec2 instance
# create instance
# download keypair
chmod 400 path/to/key
ssh -i path/to/key.pem [email protected]
sudo apt-get update && sudo apt-get upgrade
sudo apt-get install git
# python
sudo apt-get install python-virtualenv
sudo mkdir /opt/envs
@marcusshepp
marcusshepp / new_gist_file.sh
Last active July 13, 2016 19:30
view a diff without the +\n+\n+ etc..
# print a git diff on a file between two commit hashes
# pipe to cut and `-c` is chars `2-` to 2 from beginning then to end.
git diff <sha 1> <sha 2> foo/bar/file | cut -c 2-
@marcusshepp
marcusshepp / onelinewithauthors.sh
Created July 11, 2016 13:34
git log oneline with authors
git log --pretty=format:"%h%x09%an%x09%ad%x09%s"
@marcusshepp
marcusshepp / rebase.sh
Created July 7, 2016 13:49
git rebase
git rebase --interactive HEAD~2 # 2 being the number of commits you wish to use
# should see commits listed:
# pick <foo bar pop>
# pick <foo2 ba2r pop2>
# change the commits that should squash to `s` instead of pick:
# pick <foo bar pop>
@marcusshepp
marcusshepp / grep.md
Last active July 7, 2016 12:41
git grep

git grep foo

The main advantage of git grep is that it can find the patterns in the git repository, i. e. also in others than the current version of the source. This cannot be done using the standard grep of course. Also there are a lot more features in the git grep like pattern arithmetic (things like git grep -e pattern1 --and --not \( -e pattern2 -e pattern3 \)), tree search using glob (things like git grep pattern -- '*.[ch]' to search only in .c and .h files) and some more.

Here's an example session for searching in an older revision:

$ mkdir git-test                 # create fresh repository
$ cd git-test/