Skip to content

Instantly share code, notes, and snippets.

Justin Hileman bobthecow

View GitHub Profile
@mikehale
mikehale / jquery.copyable.js
Created Jan 21, 2010
A jquery API for ZeroClipBoard
View jquery.copyable.js
/*
Requirements:
This script requires the jquery.includeMany plugin and ZeroClipboard.
Example:
$("#elementToClickOn").copyable(function(e, clip) {
clip.setText($("#elementWithText").html());
});
@stephanschubert
stephanschubert / deferred_google_analytics.html
Created Apr 9, 2010
jQuery version of deferred Google Analytics. See http://neil.fraser.name/news/2010/04/07/ for more details.
View deferred_google_analytics.html
<script type="text/javascript">
(function($) {
$("body").load(function() {
setTimeout(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
}, 1);
});
})(jQuery);
@bobthecow
bobthecow / cdg.bash
Created Apr 29, 2010
cd relative to the current Git repo
View cdg.bash
#!/bin/bash
#
# cd relative to the current Git repo
#
# Author: Justin Hileman (http://justinhileman.com)
#
# Installation:
# Add the following function to your `.bashrc` or `.bash_profile`,
# or save it somewhere (e.g. `~/.cdg.bash`) and source it in `.bashrc`
#
View .gitconfig
[alias]
edit-unmerged = "!f() { git ls-files --unmerged | cut -f2 | sort -u ; }; $EDITOR `f`"
add-unmerged = "!f() { git ls-files --unmerged | cut -f2 | sort -u ; }; git add `f`"
lc = log ORIG_HEAD.. --stat --no-merges
smash = merge --no-commit --log
eat = branch -M
prune-all = !git remote | xargs -n 1 git remote prune
whois = "!sh -c 'git log -i --pretty=\"format:%an <%ae>\" --author=\"$1\" | sort -u' -"
whatis = show -s --pretty='tformat:%h (%s, %ad)' --date=short
@bobthecow
bobthecow / cdd.bash
Created Jun 21, 2010
Change directories really fast
View cdd.bash
#!/bin/bash
#
# Change directories really really fast
#
# Author: Justin Hileman (http://justinhileman.com)
#
# Installation:
# Add the following function to your `.bashrc` or `.bash_profile`,
# or save it somewhere (e.g. `~/.cdd.bash`) and source it in `.bashrc`
#
@bobthecow
bobthecow / .gitconfig
Created Jul 6, 2010
`git todo` alias is the hotness.
View .gitconfig
[alias]
# install t first: http://github.com/sjl/t
todo = !python ~/path/to/t.py --task-dir "$(git rev-parse --show-toplevel)" --list TODO
bug = !python ~/path/to/t.py --task-dir "$(git rev-parse --show-toplevel)" --list BUGS
View bench1
PASS #1 - SMALL FILE
=============================================
HTMLPurifier Pass #1 - Small File:
----------------------------------------------------
marker time index ex time perct
----------------------------------------------------
Start 1278617711.57713300 - 0.00%
----------------------------------------------------
Stop 1278617715.11053700 3.533404 100.00%
View prepare-deploy.rb
#! /usr/bin/env ruby
# this script takes your current commit, finds all the submodules in it,
# makes them static files in a new tree and updates a branch called 'heroku'
# - this way you can push a project with submodules to heroku easily
# just run this, then run "git push heroku heroku:master"
current_commit = `git rev-parse HEAD`
current_tree = `git rev-parse HEAD^{tree}`
puts "Starting at tree #{current_tree}"
@ken-reitz
ken-reitz / sync.py
Created Oct 10, 2010
GitHub Syncer. Clones or Pulls all GitHub repos (including watched list).
View sync.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Kenneth Reitz's GitHub Syncer
This script uses the GitHub API to get a list of all forked, mirrored, public, and
private repos in your GitHub account. If the repo already exists locally, it will
update it via git-pull. Otherwise, it will properly clone the repo.
It will organize your repos into the following directory structure:
View MustacheCallTest.php
<?php
require_once '../Mustache.php';
class MustacheCallTest extends PHPUnit_Framework_TestCase {
public function testCallEatsContext() {
$foo = new Foo();
$foo->name = 'Bob';
You can’t perform that action at this time.