Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
#!/usr/bin/env python | |
# Copyright (c) 2010 Jacobo de Vera | |
# Permission is hereby granted, free of charge, to any person obtaining a copy | |
# of this software and associated documentation files (the "Software"), to deal | |
# in the Software without restriction, including without limitation the rights | |
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
# copies of the Software, and to permit persons to whom the Software is | |
# furnished to do so, subject to the following conditions: |
:+1: | |
:-1: | |
:airplane: | |
:art: | |
:bear: | |
:beer: | |
:bike: | |
:bomb: | |
:book: | |
:bulb: |
Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
#!/bin/bash | |
# Watch paths (given as arguments), automatically build when something changes. | |
# The script does a couple opinionated things to make my life easier: | |
# | |
# * Terminal scrollbuffer is reset before each iteration, simplifying scrolling. | |
# * I use a filter script to colorize gcc output (clang errors would be nicer). | |
# * Output is copied to a log file (/tmp/build.log). | |
# - I open this file in Sublime or vim, which reloads the file on change (each build). | |
# | |
# Usage: |
#!/bin/bash | |
# License: Public Domain. | |
# Author: Joseph Wecker, 2012 | |
# | |
# -- DEPRICATED -- | |
# This gist is slow and is missing .bashrc_once | |
# Use the one in the repo instead! https://github.com/josephwecker/bashrc_dispatch | |
# (Thanks gioele) | |
# | |
# Are you tired of trying to remember what .bashrc does vs .bash_profile vs .profile? |
Locate the section for your github remote in the .git/config
file. It looks like this:
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = [email protected]:joyent/node.git
Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/*
to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:
#!/bin/sh | |
# Watch xscreensaver and react to status changes. | |
# | |
# Replaced my previous perl-based recipe with this: | |
# http://semicomplete.googlecode.com/svn/tools/xscreensaver-watch.sh | |
# | |
# Include somewhere in X session startup with: | |
# | |
# xscreensaver-watch & |
javascript:(function(e,a,g,h,f,c,b,d)%7Bif(!(f=e.jQuery)%7C%7Cg%3Ef.fn.jquery%7C%7Ch(f))%7Bc=a.createElement(%22script%22);c.type=%22text/javascript%22;c.src=%22http://ajax.googleapis.com/ajax/libs/jquery/%22+g+%22/jquery.min.js%22;c.onload=c.onreadystatechange=function()%7Bif(!b&&(!(d=this.readyState)%7C%7Cd==%22loaded%22%7C%7Cd==%22complete%22))%7Bh((f=e.jQuery).noConflict(1),b=1);f(c).remove()%7D%7D;a.documentElement.childNodes%5B0%5D.appendChild(c)%7D%7D)(window,document,%221.3.2%22,function($,L)%7B$('%23header,%20.pagehead,%20.breadcrumb,%20.commit,%20.meta,%20%23footer,%20%23footer-push,%20.wiki-actions,%20%23last-edit,%20.actions,%20.header').remove();%20$('%23files,%20.file').css(%7B%22background%22:%22none%22,%20%22border%22:%22none%22%7D);%20$('link').removeAttr('media');%7D); |
# prompt examples: | |
# [3 jobs master virtualenv] ~/code/myproject/foo | |
# [1 job my-branch virtualenv] ~/code/bar/ | |
# [virtualenv] ~/code/ | |
# ~ | |
# Very, very fast, only requiring a couple of fork()s (and no forking at all to determine the current git branch) | |
if [[ "$USER" == "root" ]] | |
then | |
export PS1="\e[1;31m\]\u \[\e[1;33m\]\w\[\e[0m\] "; |
#!/bin/bash | |
# The "tmuxifier" | |
# Execute parallel processes in an arbitrary number of tmux panes | |
# This script requires the path to an existing script to | |
# execute in parallel. Optionally, the number of threads to | |
# and the name of the tmux session can be input. If threads | |
# and session name are not entered, threads are determined | |
# automatically and session names is set to a default. |