Skip to content

Instantly share code, notes, and snippets.

@mattsgarrison
mattsgarrison / ST7565_Image_Previewer.rb
Created February 9, 2011 22:00
Quick way to previewing what a given image will look like on the ST7565 LCD display.
require 'mini_magick'
image = MiniMagick::Image.open("big_color.jpg")
image.resize"128x64^" #resize but retain aspect ratio
image.depth 1
image.format 'bmp'
image.colorspace 'gray'
image.write "grayscale.bmp"
@mattsgarrison
mattsgarrison / vim_movement_training.vimrc
Created April 21, 2011 13:33
Unbind the cursor keys in insert, normal and visual modes.
for prefix in ['i', 'n', 'v']
for key in ['<Up>', '<Down>', '<Left>', '<Right>']
exe prefix . "noremap " . key . " <Nop>"
endfor
endfor
@mattsgarrison
mattsgarrison / autodj.bookmarklet.js
Created August 23, 2011 20:02 — forked from azoff/autodj.bookmarklet.js
Turntable.fm DJ Script
javascript:(function(g,d,f){if(f)d.info("Session found:",f);else return d.warn("No session found!");var h={check:10,wait:500},b=g.autodj={api:g[f],available:function(a){return b.api.taken_dj_map[a]<0},spot:function(){return b.api.become_dj.data("spot")},become:function(a){b.api.callback("become_dj",a)},waiter:function(a){return function(){return b.available(a)?(b.become(a),a):(d.info("Waiting..."),-1)}},seated:function(a){return b.api.djs[a]&&b.api.djs[a][0]===b.api.myuserid},wait:function(a,c){var e=c!==void 0,
a=a||h.check,c=c||b.spot();b.seated(c)?d.warn("Spot",c,"taken!"):(e&&d.error("Spot",c,"missed. Restarting..."),d.info("Polling @",a,"ms"),b.check(a,b.waiter(c)))},check:function(a,c){setTimeout(function(){var e=c.call(b);e>0?(d.warn("Spot",e,"open..."),setTimeout(function(){b.wait(a,e)},h.wait)):b.check(a,c)},a)}}})(window,console,function(g,d,f,h,b,a,c,e,i,j,k){try{return g(d)[f](h)[b][a][c][e]()[i](j)[k]}catch(l){return null}}(jQuery,".invite_dj","data","events","click",0,"handler","toString","match
@mattsgarrison
mattsgarrison / vim setup
Created August 30, 2011 19:40
vim setup instructions
sudo apt-get install git vim-nox
cd
git clone [email protected]:mattsgarrison/Dotfiles.git
ln -s ~/Dotfiles/vimrc ~/.vimrc
vim
@mattsgarrison
mattsgarrison / merge_pdfbox.py
Created August 31, 2011 15:35
Jython script to use Apache PDFBox to merge PDFs into a single file.
import sys
from java.io import *
import java.io.InputStream
import java.io.FileInputStream
import java.lang.String # blah....converting String types between Java/Python is tedious
sys.path.append("pdfbox-1.0.0.jar") # or wherever you stashed it
import org.apache.pdfbox
"""
This method merges the FileInputStreams that the streamList points to, into the
@mattsgarrison
mattsgarrison / date_time.coffee
Created December 28, 2011 16:07 — forked from markbates/date_time.coffee
Example: Rails-style date/time helpers in CoffeeScript (added days)
Number::seconds = ->
@ * 1000
Number::minutes = ->
@seconds() * 60
Number::minute = Number::minutes
Number::hours = ->
@minutes() * 60
@mattsgarrison
mattsgarrison / find_large_files.sh
Created January 5, 2012 05:01
Finding the largest files on your *nix system
find . -size +20000k -exec du -h {} \;
@mattsgarrison
mattsgarrison / hubot_service.sh
Created January 6, 2012 16:51
Start/Stop script to manage Hubot with Monit
#!/bin/zsh
### BEGIN INIT INFO
# Provides: hubot
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the hubot service
# Description: starts the Hubot bot for the Campfire rooms
@mattsgarrison
mattsgarrison / bootstrap-paged-navar.js
Created January 12, 2012 14:46
CoffeeScript and JavaScript results to enhance Twitter Bootstrap navbar's "active" tab for multiple pages (essentially supplanting scrollspy).
// Generated Output from CoffeeScript
jQuery(function() {
var a, b, c, d, e;
d = $(".topbar .nav a"), e = [];
for (b = 0, c = d.length; b < c; b++)
a = d[b], e.push(function(a) {
if (window.location.pathname === a.pathname)
return $(a).parent().toggleClass("active")
}(a));
return e
@mattsgarrison
mattsgarrison / Rakefile
Created April 9, 2012 13:57
Rake task to link up my Dotfiles repo.
require 'pathname'
require 'fileutils'
#This assumes this script is your home directory level Rakefile
namespace :dotfiles do
desc "Link ALL the dotfiles!"
task :link do
path = Pathname.new("#{__FILE__}").dirname
Dir.glob "#{path}/Dotfiles/*" do |f|