Skip to content

Instantly share code, notes, and snippets.

View gonzaloserrano's full-sized avatar
☁️
🧑‍💻

Gonzalo Serrano gonzaloserrano

☁️
🧑‍💻
View GitHub Profile
@gonzaloserrano
gonzaloserrano / wifi_ip
Created February 7, 2014 14:37
Prints Macbook pro's wifi ip
#! /bin/sh
ifconfig | grep en1: -A 2 | tail -n 1 | awk '{print $2}'
@gonzaloserrano
gonzaloserrano / git-tagg
Created October 1, 2013 14:03
Show last 3 git tags plus last tag message
#!/bin/sh
git for-each-ref \
--format='%(taggerdate:iso8601) %(refname:short)' refs/tags |
grep -v '^ ' |
sort |
cut -d' ' -f4- |
tail -n 3
git lgg | head -n 1 | awk -F '=> ' '{print " "$2}'
@gonzaloserrano
gonzaloserrano / git-web
Created October 1, 2013 10:08
Open current git directory in github (branch compatible)
# /bin/bash
# Opens the github page for the current git repository in your browser
# https://github.com/jasonneylon/dotfiles/
giturl=$(git config --get remote.origin.url)
if [ "$giturl" == "" ]
then
echo "Not a git repository or no remote.origin.url set"
exit 1;
@gonzaloserrano
gonzaloserrano / gist:6594400
Created September 17, 2013 13:38
How to less stderr
# http://stackoverflow.com/questions/2342826/how-to-pipe-stderr-and-not-stdout
# This creates a new file descriptor (3) and assigns it to the same place as 1 (stdout),
# then assigns fd 1 (stdout) to the same place as fd 2 (stderr) and finally assigns fd 2 (stderr)
# to the same place as fd 3 (stdout). Stderr is now available as stdout and old stdout preserved in stderr.
command 3>&1 1>&2 2>&3
@gonzaloserrano
gonzaloserrano / gist:6448036
Created September 5, 2013 09:38
Monitor cassandra inserts/updates/deletes
while; do nodetool tpstats | grep MutationStage; sleep 1; done;
@gonzaloserrano
gonzaloserrano / git-vendor
Last active December 20, 2015 15:29
Execute git commands in all vendors. Display git repo name, branch, repo status (modified, committed, added and untracked files) and file path.
#! /bin/bash
# modify the find target directory as needed
#legend
echo -e " \033[1;31;m● Modified \033[32;m● Committed \033[34;m● Added \033[1;30;m● Untracked"
echo
i=0
for VENDOR in `find vendor/socialpoint -type d -name .git`; do
" Port of my favorite theme Made of Code by Mark Dodwell
" For Textmate Theme visit - http://madeofcode.com/posts/29-photo-my-new-textmate-theme-8220-made-of-code-8221-mdash-download-9-feb-2010-update-t
" Vim color file
set background=dark
highlight clear
if exists("syntax_on")
syntax reset
@gonzaloserrano
gonzaloserrano / gist:5944925
Created July 7, 2013 20:58
Remove node installed from dmg
#! /bin/bash
# needed this to install it from homebrew formula like http://madebyhoundstooth.com/blog/install-node-with-homebrew-on-os-x/
lsbom -f -l -s -pf /var/db/receipts/org.nodejs.pkg.bom | while read i; do
sudo rm /usr/local/${i}
done
sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /var/db/receipts/org.nodejs.*
@gonzaloserrano
gonzaloserrano / gist:5496751
Last active December 16, 2015 20:59
Download some computer science videos popular in the HackerNews community
# requires python, use at your own risk :-)
mkdir youtube-dl
cd youtube-dl
wget http://youtube-dl.org/downloads/2013.05.01/youtube-dl
chmod +x youtube-dl
wget https://dl.dropboxusercontent.com/u/16897247/cs-videos.txt
for i in `cat cs-videos.txt | awk '{print $1}'`; do ./youtube-dl $i; done;
@gonzaloserrano
gonzaloserrano / f11
Created March 1, 2013 11:08
Download all numbers of the f11 photography magazine http://www.f11magazine.com/site/all.html
for i in `curl http://www.f11magazine.com/site/all.html | grep "site\/pdf" | awk -F '"' '{print $2}'`; do echo $i; wget "$i"; done;