Skip to content

Instantly share code, notes, and snippets.

View jrk's full-sized avatar

Jonathan Ragan-Kelley jrk

View GitHub Profile
@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 / 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 / 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 / redis-server-for-init.d-startup
Created January 25, 2010 17:00 — forked from mtodd/redis-server-for-init.d-startup
init.d script for redis server
#! /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
@jrk
jrk / gist:295178
Created February 4, 2010 22:09
Open a new OS X Terminal window at an arbitrary path from Bash.
function openterm {
## Open a new Terminal window at $1
path=`cd $1; pwd`
osascript -e "tell application \"Terminal\" to do script \"cd ${path}\""
}
@jrk
jrk / gist:316073
Created February 26, 2010 19:44
Wrapper to run R scripts like Python/Perl/Ruby/Bash/anything else sane
#!/bin/sh
# Wrapper to easily run an R script at the command line, with arguments,
# like you're used to with Python/Perl/Ruby/Bash/anything else remotely sane.
#
# Usage:
# runR <script.R> [argument list]
# you can also optionally route output to /dev/null, depending on your desires
R --vanilla "--args ${@:2}" < $1 #>/dev/null
<a href="javascript:var%20http%20=%20new%20XMLHttpRequest();var%20url%20=%20%22https://prowl.weks.net/publicapi/add%22;var%20apikey%20=%20%qqqqqq%22;var%20application%20=%20%22the%20web%22;var%20evt%20=%20%22Browser!%22;var%20description%20=%20encodeURIComponent(document.title.replace(/^\s*|\s*$/g,%27%27))+%20escape(%22\n%22)%20+%20encodeURIComponent(location.href);var%20params%20=%20%22apikey=%22+apikey+%22&application=%22+escape(application)+%22&event=%22+escape(evt)+%22&description=%22+description;http.open(%22POST%22,%20url,%20true);http.setRequestHeader(%22Content-type%22,%20%22application/x-www-form-urlencoded%22);http.send(params);">Prowl!</a>
(Replace "qqqqqq" in the bookmarklet string with your Prowl <a href="https://prowl.weks.net/settings.php">API key</a> before using.)

To reproduce

  • Create or link a large (10s of MB) binary file to /tmp/big.zip.

  • Run

  • Fetch the data with curl:

    curl -O http://localhost:8080

==> fails in chunky parser at random points during download

@jrk
jrk / gist:819409
Created February 9, 2011 22:05
Install matlab-ruby against Mac MATLAB.app install
# http://www.macresearch.org/matlab-ruby-snow-leopard
# Build/install
sudo env ARCHFLAGS="-arch x86_64" gem install matlab-ruby -- --with-matlab-include=/Applications/MATLAB_R2010b.app/extern/include --with-matlab-lib=/Applications/MATLAB_R2010b.app/bin/maci64 --with-swig
# Run irb
PATH=/Applications/MATLAB_R2010b.app/bin:$PATH DYLD_LIBRARY_PATH=/Applications/MATLAB_R2010.app/sys/os/maci64:/Applications/MATLAB_R2010b.app/bin/maci64/MATLAB.app/Contents/MacOS:/Applications/MATLAB_R2010b.app/bin/maci64:/Applications/MATLAB_R2010b.app/extern/lib/maci64:/Applications/MATLAB_R2010b.app/runtime/maci64 irb