Skip to content

Instantly share code, notes, and snippets.

View rjungemann's full-sized avatar

Roger Jungemann rjungemann

View GitHub Profile
#! /bin/sh
### BEGIN INIT INFO
# Provides: redis-server
# Required-Start: $syslog
# Required-Stop: $syslog
# Should-Start: $local_fs
# Should-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: redis-server - Persistent key-value db
@rjungemann
rjungemann / install.sh
Created September 24, 2012 22:54 — forked from cloud8421/install.sh
Install tmux 1.6 on Ubuntu 10.04
wget -q -O - https://raw.github.com/gist/2204072/install_tmux_1.6_on_ubuntu_10.04.sh | sudo bash
@rjungemann
rjungemann / tmux-clipboard.applescript
Created September 17, 2012 01:47
Text to and from system clipboard to tmux using AppleScript
-- putting current selection in clipboard
-- set tmux path
set tmux_path to "/usr/local/bin/tmux"
-- copy selected text to clipboard
tell application "System Events" to keystroke "c" using {command down}
delay 0.1 -- so copy can take place
set selected_text to (the clipboard as text)
@rjungemann
rjungemann / reverse_evaluate.rb
Created June 16, 2012 18:38
Defines `reverse_evaluate`, which takes a block and evaluates its contents in reverse order.
# Defines a macro in Ruby which takes a block, and evaluates the
# block's statements in reverse order.
#
# Requires the 'live_ast' and 'ruby2ruby' gems. Install via:
#
# gem install live_ast ruby2ruby
#
# Should work in 1.8 as well as 1.9.
require 'rubygems'
@rjungemann
rjungemann / euclid.ino
Created May 16, 2012 07:58
Euclidian sequencer proof-of-concept for Ardcore
/*
A simple two-channel euclidian sequencer (work-in-progress).
Currently supports one channel. Caveat: there may be bugs. I just got my Ardcore
and I started developing this before it arrived.
Given an input like (A), it should send out something like (B) in a loop:
(A) * * * * * * * *
(B) * * *
@rjungemann
rjungemann / gist:1257796
Created October 2, 2011 19:14
TinyVM example
// R08 stores a pointer to top of the heap
// a function with two parameters (lists of pointers)
// R09 stores the flag
// R10 stores a pointer to the current node in the heap
// R11 stores:
// * a pointer to the list of parameters
// * the return value
f:
@rjungemann
rjungemann / gist:1251440
Created September 29, 2011 18:02
Make sure an image has loaded using JQuery
$.imageComplete = (callback) ->
$(this).one('load', callback).each -> if this.complete then $(this).load()
@rjungemann
rjungemann / gist:1239798
Created September 24, 2011 20:11
Math in Bash
expr '1 + 1'
echo $[1 + 1]
let variable=1+1 # spaces are illegal
echo '6 ^ 10' | bc
bc <<< '13 / 5' # use heredoc notation to pass parameters to bc
@rjungemann
rjungemann / flash_player.rb
Created September 23, 2011 04:59
FlexSDK Homebrew formula. Installs mxmlc and other tools.
require 'formula'
class FlashPlayer < Formula
url 'http://fpdownload.macromedia.com/pub/flashplayer/updaters/11/flashplayer_11_sa_debug.app.zip'
md5 '2770acd6997bfd5016dd51acfb20c025'
homepage 'http://adobe.com'
version '11.1'
def install
name = 'Flash Player Debugger.app'
@rjungemann
rjungemann / sample.coffee
Created September 12, 2011 02:30
Generate WebSocket frames in CoffeeScript
hexToBuffer = (hex, padding) ->
n = lpad hex.toString(16), '0', padding
list = []
while n.length > 0
head = n.substr 0, n.length - 2
tail = n.substr n.length - 2
list.unshift parseInt tail, 16