Skip to content

Instantly share code, notes, and snippets.

View putermancer's full-sized avatar

Ben Loveridge putermancer

View GitHub Profile
@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;
@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: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 / .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 / 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 / .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 / gist:908842
Created April 7, 2011 21:59
one-liner jscoverage command, excluding test scripts
for y in 1; do TMPVAR__=; for x in `find ${DIRNAME} -name "tests" -type d`; do TMPVAR__+="--no-instrument=`echo $x | awk -F${DIRNAME}/ '{print $2}'` "; done; jscoverage ${DIRNAME} ${DIRNAME}_coverage $TMPVAR__; TMPVAR__=; done;
@putermancer
putermancer / gist:847755
Created February 28, 2011 18:24
git + gitolite shell access, user-based
#!/bin/bash
shift # get rid of -c
# if no commands, just open a shell
if [[ $# -eq 0 ]]; then
/bin/bash -l
# if the first arg is a git- command, that means it is something like git-push, etc... so forward it
elif [[ $1 == git-* ]]; then
ssh -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no git@localhost $*
@putermancer
putermancer / .gitconfig
Last active June 15, 2022 08:37
git aliases
[alias]
man = help
unadd = reset HEAD
#co = checkout
co = "!f(){ git checkout \"$@\" && git sup; }; f"
feature = "!git reset HEAD && git checkout -b feature/\"$1\" && git commit --allow-empty -m \"Created feature branch $1\" && git push --set-upstream origin feature/\"$1\" && echo Branch feature/$1 published to origin"
cp = cherry-pick
sma = submodule add
st = status
br = branch
@putermancer
putermancer / gitinit.sh
Created November 2, 2010 16:36
Quickly set up a shared git repository
REPONAME=${1%/} # trim trailing slash
if [ ! -d "$REPONAME" ]; then
# Make a temporary working directory
mkdir $REPONAME && cd $REPONAME
echo .DS_Store > .gitignore # ignore a common MacOS file
# make an initial commit
git init && git add .gitignore && git commit -m "initial commit"
else