Skip to content

Instantly share code, notes, and snippets.

View mauro-oto's full-sized avatar

Mauro Otonelli mauro-oto

  • Buoy Software
  • Buenos Aires, Argentina
View GitHub Profile
# The goal of this problem is to extract headers from a block of text,
# and arrange them hierarchically.
#
# See the specs for more detail on the output
HEADER_HTML = /\<(h[\d])\>([^<>]+)\<\/h[\d]\>/
HEADER_LEVEL_AND_CONTENT = /h(?<level>[\d])(?<content>.*)/
def header_hierarchy(html)
html.scan(HEADER_HTML).map(&:join).map do |node|
@mauro-oto
mauro-oto / git_stash_reminder.sh
Created November 21, 2014 19:18
Show git stash count when opening a new terminal window
Add this to your .zshrc or .bashrc for a quick reminder of saved stashes:
git_stashes_count () {
st_num=$(/usr/bin/git stash list 2> /dev/null | wc -l | tr -d ' ')
if [[ $st_num != "0" ]]; then
echo "$fg[red]$st_num$reset_color"
else {
echo "0"
}
fi