Skip to content

Instantly share code, notes, and snippets.

View putermancer's full-sized avatar

Ben Loveridge putermancer

View GitHub Profile
@putermancer
putermancer / .vimrc.local
Created April 12, 2011 20:41
.vimrc.local
" Version Control (handy for VCS where open files can be changed by a pull)
set autoread
" Keybinding to format JSON
map <leader>jt <Esc>:%!python -m json.tool<CR><Esc>:set filetype=json<CR>
" Auto-trim trailing whitespace
autocmd FileType css,javascript,html,php,python,xml autocmd BufWritePre <buffer> :call setline(1,map(getline(1,"$"),'substitute(v:val,"\\s\\+$","","")'))
" Set sync area to avoid broken syntax highlighting
@putermancer
putermancer / phantomjs-testrunner.js
Created May 19, 2011 21:30
Simple JasmineBDD test runner for PhantomJS
if (phantom.state.length === 0) {
if (phantom.args.length === 0) {
console.log("Simple JasmineBDD test runner for PhantomJS");
console.log("Usage: phantomjs-testrunner.js url_to_runner.html");
console.log("Accepts http:// and file:// urls");
console.log("");
console.log("NOTE: This script depends on jasmine.TrivialReporter being used\non the page, for the DOM elements it creates.\n");
phantom.exit();
} else {
var address = phantom.args[0];
@putermancer
putermancer / .profile
Created June 23, 2011 17:24
bash info in prompt
# prompt including cwd, username, hostname, git branch #
export PS1="\[\e[0;32m\]\u\[\e[m\]\[\e[1;33m\]@\[\e[m\]\[\e[1;32m\]\h\[\e[m\]\[\e[0;33m\]:\[\e[m\]\[\e[1;37m\]\w\[\e[m\] \[\e[0;33m\]\$(git branch 2> /dev/null | grep -e '\* ' | sed 's/^..\(.*\)/{\1} /')\[\e[0;35m\]$ \[\e[m\]"
export SUDO_PS1="\[\e[0;32m\]\u\[\e[m\]\[\e[1;33m\]@\[\e[m\]\[\e[1;32m\]\h\[\e[m\]\[\e[0;33m\]:\[\e[m\]\[\e[1;37m\]\w\[\e[m\] \[\e[0;33m\]\$(git branch 2> /dev/null | grep -e '\* ' | sed 's/^..\(.*\)/{\1} /')\[\e[0;35m\]$ \[\e[m\]"
# terminal colors #
export CLICOLOR='true'
@putermancer
putermancer / gist:1395160
Created November 26, 2011 06:18
jsonp (maybe not entirely cross-browser friendly)
/**
* Function: getRandomId
* Generates a unique-ish hex string between 1 and 32 characters long.
*/
rrandomidreplace : /x/g,
getRandomId : function(length) {
length = length && length > 0 && length <= 32 ? length : 32;
function getHexChar() {
var r = Math.random()*16|0;
return r.toString(16);
@putermancer
putermancer / blove-git-flow.rb
Created December 20, 2011 22:17
homebrew Formula to install blove's fork of gitflow
require 'formula'
class GitFlowCompletion < Formula
homepage 'https://github.com/bobthecow/git-flow-completion'
url 'https://github.com/bobthecow/git-flow-completion/tarball/0.4.1.0'
md5 '95c05d1a278c1c41067bd7cc6c281ecd'
head 'https://github.com/bobthecow/git-flow-completion.git', :branch => 'develop'
end
@putermancer
putermancer / gist:4261328
Created December 11, 2012 19:30
Proboards: jump to best post (first unread or most recent) in a thread
<script type="text/javascript">
<!--
// Jump to the best post (first first unread or most recent) in a thread.
// Originally by Todge, but completely rewritten by Ben Loveridge.
if(document.location.href.match('board=')&&!document.location.href.match('action=')) {
var table_cells = document.getElementsByTagName('td'),
create_cell_click_fn = function(href) {
return function() { if (!window.pb_bubble) { window.location.href = href; } };
},
cell, is_topic_cell, has_new_post, new_post_href, best_post_href, last_post_cell, last_post_groups, last_post_href;