Skip to content

Instantly share code, notes, and snippets.

View jrk's full-sized avatar

Jonathan Ragan-Kelley jrk

View GitHub Profile
@jrk
jrk / gist:70797
Created February 26, 2009 11:04
foreach in bash
# foreach in bash
for file in `echo *`
do
do_stuff_to $file
done
# A tiny DSL implementation for a minimal subset of BASIC in Scala
# Via http://www.nabble.com/-scala--ease-of-making-DSLs-in-Scala---nobody-cares-to22450638.html
class BasicClass {
abstract sealed class BasicLine
case class PrintLine(num: Int, s: String) extends BasicLine
case class GotoLine(num: Int, to: Int) extends BasicLine
val lines = new scala.collection.mutable.HashMap[Int, BasicLine]
case class linebuilder(num: Int) {
def GOTO(to: Int) = lines(num) = GotoLine(num, to)
#
# this script will go through all pools and scrub them one at a time
# Via http://aspiringsysadmin.com/blog/2007/06/07/scrub-your-zfs-file-systems-regularly/
#
[email protected]
ZPOOL=/usr/sbin/zpool
TMPFILE=/tmp/scrub.sh.$$.$RANDOM
scrub_in_progress() {
@jrk
jrk / pdf_slide_share.sh
Created April 1, 2009 19:34
Quick and dirty PDF slide sharing: converts a PDF to PNGs and spits out HTML+JS to browse them.
#!/bin/sh
# Quick and Dirty PDF Sharing
# Converts a PDF to PNGs (using Image Magick)
# and spits out HTML+JS to browse them.
# By John Resig (ejohn.org)
# Distributed under the MIT License
# Home: http://ejohn.org/projects/easy-pdf-sharing/
# Input:
@jrk
jrk / camper.rb
Created May 2, 2009 18:53
Simple Campfire-Jabber relay daemon in Ruby
# The MIT License
#
# Copyright (c) 2008 Jared Kuolt
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
@jrk
jrk / newpost.rb
Created May 5, 2009 06:48 — forked from al3x/newpost.rb
Creates a new Jekyll post, opens it in TextMate, and adds to the git index
#!/usr/bin/env ruby
require Dir
unless ARGV[0]
puts 'Usage: newpost "the post title"'
exit(-1)
end
blog_root = "/Users/jrk/proj/blog"
function gr {
## If the current working directory is inside of
## a git repository, this function will change
## it to the git root (ie, the directory that
## contains the .git/ directory), and then print
## the new directory.
git branch > /dev/null 2>&1 || return 1
cd "$(git rev-parse --show-cdup)".
pwd
#!/bin/bash
# The CommandLineFu.com is a great web site to exchange knowledge about shell usage and command line
# magics. But if that is about command line will be to have a command line interface to access this
# knowledge.
# The clfu-seach is the usable proof of concept to think seriously on this idea.
# via http://www.colivre.coop.br/Aurium/CLFUSearch
# This is a Free (as in freedom) Software licenced under the last GPL.
@jrk
jrk / front_finder_window_shell_utilities.sh
Created June 3, 2009 01:25
Shell aliases for quickly acting on the frontmost Finder window.
# Define front_finder_window_path to return the POSIX path string to the frontmost Finder window
alias front_finder_window_path="osascript -e 'tell application \"Finder\" to get URL of target of front Finder window' | sed 's/file:\\/\\/localhost//g'"
# cd to the front Finder window path
alias cdf='cd `front_finder_window_path`'
# pushd to the front Finder window path
alias pushdf='pushd `front_finder_window_path`'
alias pushf=pushdf
alias pdf=pushdf
@jrk
jrk / draggable.html
Created June 13, 2009 22:48
A bookmarklet to redirect your current browser page through MIT's Proxy, useful for browsing ACM Portal, etc. Drag it to your bookmarks toolbar, and click it on any page to view that page through the MIT proxy.
<a href="javascript:location.href='https://libproxy.mit.edu/cgi-bin/ezpauth?url='+location.href">MIT proxy</a>