Skip to content

Instantly share code, notes, and snippets.

@jeffutter
jeffutter / bootstrap_topbar_list.rb
Created March 8, 2012 07:27 — forked from tmaier/bootstrap_topbar_list.rb
BootstrapTopbarList for simple-navigation and Twitter Bootstrap integration
# This sort-of works. It got unnecessarily complicated though. Suggestions welcome.
# Renders an ItemContainer as a <ul> element and its containing items as <li> elements.
# Prepared to use inside the topbar of Twitter Bootstrap http://twitter.github.com/bootstrap/#navigation
#
# Register the renderer and use following code in your view:
# render_navigation(level: 1..2, renderer: :bootstrap_topbar_list, expand_all: true)
class BootstrapTopbarList < SimpleNavigation::Renderer::Base
def render(item_container)
@jeffutter
jeffutter / github-2.1.1
Created April 8, 2014 18:53
ruby-build file for github/ruby
# Installing on arch needs this patch and ENV
curl -fsSL https://gist.github.com/mislav/a18b9d7f0dc5b9efc162.txt | RUBY_CONFIGURE_OPTS=--with-readline-dir="/usr/lib/libreadline.so" rbenv install --patch ./github-2.1.1
set nocompatible " be iMproved
filetype off " required!
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
" let Vundle manage Vundle
" required!
Bundle 'gmarik/vundle'
@jeffutter
jeffutter / prepare-commit-msg
Created July 15, 2014 13:51
Branch name in commit messages
#!/bin/sh
branch=$(git branch 2>/dev/null | grep -e ^* | tr -d ' *')
trimmed=$(echo $branch | sed -e 's/^[^-]*\/\(.*\)/\1/' -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/' )
echo -n "[$trimmed]"' '|cat - "$1" > /tmp/out && mv /tmp/out "$1"
```...```........,,,,,,..,...,............```````.`.````````````` `````````.``````````````...`..`````.`````.`````.`````````````````` `..,;,,,::,:``..::'#;+,+'';'.,::;;:,,::::,;+:::;''+';:;;;;'+'';;;;;;;##+,,
`````.``````.````````````.``````...,..,.,......,.,.,.,.,.,....................,...,.........................`````.````````````.` `.,:;````::;''+'''+''';;;;::';;:::,:::;;:::::;;:::::,:,:::,:,:;##:,
.,,,,,::,,,,,,,,,.......`.``````...,,.,.,......,.,.,.,.,.,..............,.,.,.,.,.,.,.,......```````````.`````.````````````` ``.```` ` `..`,:;''''''''''''';;;';;;;;;;;;;;;;:::;:;::::,;::::,:,:,##+,
```````..`````.``````.`````.`````..,;'''''';;';;;;:;:;::,:,,.,,.,..`....,.,.,.:.,.,.,.,......`````.`````.`````.`````````` `...` `.` ` ````;::''''+'''';';';;;;;;;:;;;:;:;:::;:;:;::,::;:::::::;;'##;
,,,.......````.``````.````````````......,............,,...,,,....,,,,,,,::::::::::;;;;;;:;::..````.`````.....`....``..`. ``.,.` .` ` `` ,;'+++++#+++++#++++++'';;;:::::;:,,,,
@jeffutter
jeffutter / cleandocker.sh
Created August 7, 2014 04:55
Clean Old Docker Containers/Images
#!/bin/bash
containers=$( (docker ps ; docker ps -a ) | tr -s ' ' | sort | uniq -u |grep -v '_data'|grep -v "CONTAINER" | awk '{print $1}' )
if [[ -n $containers ]]; then
docker rm $containers
fi
images=$(docker images |grep '<none>'| awk '{print $3}')
if [[ -n $images ]]; then
docker rmi $images
fi
# config/bundler-mem.rb
require 'action_view'
module Bundler
class Runtime
include ActionView::Helpers::NumberHelper
REQUIRE_ERRORS = [
/^no such file to load -- (.+)$/i,
/^Missing \w+ (?:file\s*)?([^\s]+.rb)$/i,
source 'https://rubygems.org'
source "https://code.stripe.com"
# Distribute your app as a gem
# gemspec
gem 'redis-rack'
gem 'puma'
# Optional JSON codec (faster performance)
gem 'oj'
@jeffutter
jeffutter / gist:511a372470471fd72d1e
Last active September 4, 2015 09:34
Simulate Magnetic Credit Card Swipe (only works in Firefox)
"%B4000000000000002^CardUser/John^030510100000019301000000877000000?;4000000000000002=0305101193010877?".split('').forEach(function(k){
var e = new KeyboardEvent("keydown", {key: k, char: k, charCode: k.charCodeAt(0), keyCode: k.charCodeAt(0), which: k.charCodeAt(0)});
window.dispatchEvent(e);
});
var ev = document.createEvent('KeyboardEvent');; ev.initKeyEvent(
'keydown', true, true, window, false, false, false, false, 13, 0);
document.body.dispatchEvent(ev);
package main
import (
"bufio"
"encoding/json"
"fmt"
"github.com/fatih/color"
"github.com/nsf/termbox-go"
"os"
"strings"