Skip to content

Instantly share code, notes, and snippets.

View jrk's full-sized avatar

Jonathan Ragan-Kelley jrk

View GitHub Profile
@jrk
jrk / flac2mp3
Created November 10, 2009 01:21 — forked from mxcl/flac2mp3.md
Simple flac2mp3 conversion script, supporting essential tags and batch processing with globs.
#!/usr/bin/ruby
# http://gist.github.com/230533
# forked from http://gist.github.com/124242
# TODO: add iteration over arguments
filename=ARGV[0]
abort "Usage: flac2mp3 FLACFILE" if filename.nil?
`metaflac --export-tags-to=- "#{filename}"`.each_line do |s|
v=s.strip.split '=', 2
@jrk
jrk / chm2lrf.py
Created November 8, 2009 20:59
Convert CHM files to the LFM ebook format.
from __future__ import with_statement
''' CHM File decoding support '''
__license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>,' \
' and Alex Bramley <a.bramley at gmail.com>.'
import sys, os, re, shutil
from tempfile import mkdtemp
from mimetypes import guess_type as guess_mimetype
from htmlentitydefs import name2codepoint
@jrk
jrk / llvmlisp.cpp
Created November 5, 2009 08:26
Toy LLVM Lisp, originally from http://paste.lisp.org/display/74068
/* A Trivial LLVM LISP
* Copyright (C) 2008-2009 David Robillard <[email protected]>
*
* Parts from the Kaleidoscope tutorial <http://llvm.org/docs/tutorial/>
* by Chris Lattner and Erick Tryzelaar
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
@jrk
jrk / gist:226604
Created November 5, 2009 01:35
Minimalist painting in HTML5 canvas + Javascript.
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
function draw() {
var canvas = document.getElementById("canvas");
var ctx = canvas.getContext("2d");
ctx.fillStyle = "black";
ctx.beginPath();
[github]
token = !security 2>&1 >/dev/null find-generic-password -gs "github.token" | ruby -e 'print $1 if STDIN.gets =~ /^password: \\\"(.*)\\\"$/'
@jrk
jrk / gist:214476
Created October 20, 2009 18:16
Convert a p12 certificate export to raw OpenSSL pem format, including private key and certificate.
function p12topem {
# Convert a p12 certificate export to raw OpenSSL pem format, including
# private key and certificate.
# via http://www.gridsite.org/wiki/Convert_p12
openssl pkcs12 -in "$1" -nodes -out "$2"
# Make it readable only by you:
chmod 0400 "$2"
}
@jrk
jrk / .profile.functions
Created October 7, 2009 18:13
Tools for easily and automatically initializing/renewing Kerberos tickets with launchd and from command-line scripts on Snow Leopard.
# Initialize or renew Kerberos tickets. Assumes password for the requested principal is stored in the
# keychain, which is now automatically used by Snow Leopard kinit.
# This is useful to define globally in your shell profile, for easy use within other scripts and
# from the command-line.
function ker {
kinit -R 2> /dev/null
if [[ $? = '0' ]]; then
echo "renewed..."
klist
else
@jrk
jrk / httpd.conf
Created September 25, 2009 20:27 — forked from al3x/gist:187147
Alex Payne web productivity hack: redirect distracting domains to a local page which pops up Things.
#
# This is the main Apache HTTP server configuration file. It contains the
# configuration directives that give the server its instructions.
# See <URL:http://httpd.apache.org/docs/2.2> for detailed information.
# In particular, see
# <URL:http://httpd.apache.org/docs/2.2/mod/directives.html>
# for a discussion of each configuration directive.
#
# Do NOT simply read the instructions in here without understanding
# what they do. They're here only as hints or reminders. If you are unsure
#!/bin/bash
#
# gitwait - watch file and git commit all changes as they happen
# via http://stackoverflow.com/questions/420143/making-git-auto-commit/965274#965274
#
while true; do
inotifywait -qq -e CLOSE_WRITE ~/.calendar/calendar
#include <CoreServices/CoreServices.h>
static void callback(ConstFSEventStreamRef streamRef,
void *clientCallBackInfo,
size_t numEvents,
void *eventPaths,
const FSEventStreamEventFlags eventFlags[],
const FSEventStreamEventId eventIds[]) {
exit(0);
}