Skip to content

Instantly share code, notes, and snippets.

// Hello! I am Ben Hodgson.
// 1: how could you rewrite the following to make it shorter?
if (foo) {
bar.doSomething(el);
} else {
bar.doSomethingElse(el);
}
// A:
@benhodgson
benhodgson / pythonrc.py
Created May 4, 2011 12:41
Add history between sessions and auto-completion via the ESC and tab keys to the interactive Python interpreter with this dot-file.
"""
Python Startup File (from https://gist.github.com/955154)
Add this file to ~/.pythonrc.py to add history between sessions and
auto-completion via the ESC key to the interactive Python interpreter. After
adding this file, put something like the following line in your .bash_profile:
export PYTHONSTARTUP=$HOME/.pythonrc.py
Requires a recent version of Python and the readline package, which you can
@benhodgson
benhodgson / github-repo-stats.js
Created November 1, 2011 18:17
Fetch the Watchers and Forks counts for a GitHub repo
// What up, @mdo. You'll need a recent version of jQuery.
// You can try this out by pasting it into the console on http://api.jquery.com/jQuery.ajax/
window.repoCallback = function (obj) {
console.log("Watchers:" + obj['repository']['watchers']);
console.log("Forks:" + obj['repository']['forks']);
}
$.ajax("http://github.com/api/v2/json/repos/show/twitter/bootstrap?callback=repoCallback", {dataType: "jsonp"});