Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@tonyg
tonyg / refresh-backup.sh
Created May 25, 2009 21:43
Keep a set of clones of your github repos up-to-date.
#!/bin/bash
# Keep a set of clones of your github repos up-to-date. Run this in a
# directory of its own. It will clone (or update) your github repos into
# subdirectories, one per repo. Written on OS X Leopard.
# Depends on /usr/bin/xpath.
# Make sure you set githubuser, below, to the correct value :-)
githubuser=tonyg
for repo in $(curl http://github.com/api/v1/xml/$githubuser | xpath '//repository/name' 2>/dev/null | sed -e 's:><:> <:g')
@tonyg
tonyg / maybebug.cm
Created January 1, 2010 18:05
Q: Why does the whole program crash when the remote client closes its socket before the server is done? A: Because SIGPIPE is not blocked. Use UnixSignals.setHandler.
Group is
$cml/basis.cm
$cml/cml.cm
$cml-lib/smlnj-lib.cm
maybebug.sml
;; Relevant parts of my .emacs for setting up org-mode
;; - I like the main file to be loaded at startup
;; - I'm experimenting with having the agenda shown at startup, too
;; - comment out the lines marked with "%%%" below if you don't like this
;; - I'm using flashbake for checking in my main org-file using cron,
;; http://bitbucketlabs.net/flashbake/
; Don't make pesky backup files.
(setq make-backup-files nil)
@tonyg
tonyg / SinCosTanMorph.st
Created April 19, 2010 04:20
Squeak Smalltalk source code for a Morph displaying sin/cos/tan as an animation. Here's an example captured animation: http://www.eighty-twenty.org/images/sct_anim.gif
Morph subclass: #SinCosTanMorph
instanceVariableNames: 'radius theta sinHistory cosHistory tanHistory stretch'
classVariableNames: ''
poolDictionaries: ''
category: 'SinCosTan'!
!SinCosTanMorph methodsFor: 'as yet unclassified' stamp: 'tonyg 4/19/2010 15:31'!
drawHistory: aHistory on: aCanvas from: aPoint withBasis: aBasis
| xAxis yAxis b p q n |
xAxis := aBasis first * stretch.
@tonyg
tonyg / flow_control_patch.patch
Created May 12, 2010 23:41
Patch to py-amqplib for experimental support for flow-control blocking of publications
diff -r aa7a2b480166 amqplib/client_0_8/channel.py
--- a/amqplib/client_0_8/channel.py Thu Dec 10 23:40:05 2009 -0600
+++ b/amqplib/client_0_8/channel.py Thu Jan 07 17:43:42 2010 +0000
@@ -74,6 +74,7 @@
self.default_ticket = 0
self.is_open = False
self.active = True # Flow control
+ self.flow_callback = None
self.alerts = Queue()
self.returned_messages = Queue()
@tonyg
tonyg / setup.sh
Last active September 5, 2015 00:54
Script I use to setup and uninstall my git-managed dotfile collection
#!/bin/sh
cd $(dirname "$0")
SETUPHOST="$(hostname -s)"
SETUPDOMAIN="$(hostname -f | sed -e "s:$(hostname -s):any:")"
echo "Setting up home directory from $(pwd) for host $SETUPHOST and domain $SETUPDOMAIN."
git submodule update --init
uninstall="no"
while getopts "u" opt; do
@tonyg
tonyg / gist:861726
Created March 9, 2011 05:08
Erlang, If You See What I Mean
(define-language model-erlang
(world ((module ...) (actor ...)))
(module-dictionary (module ...))
(module (atom ;; module name
(atom value) ...)) ;; (constant-name constant-definition) - incl functions
(atom string)
#lang racket
(require racket/private/class-internal)
;; An ordinary Racket class.
(define a%
(class* object% ()
(super-new)
(define/public (op x) (+ x 1))))
;; Representation of a trivial vtable.
@tonyg
tonyg / gist:1014851
Created June 8, 2011 17:14
Compile-time loading of constant JSON data
#lang racket
(require (for-syntax "json-parsing.ss"))
(define-syntax loaded-uci-descriptions
(lambda (stx)
(syntax-case stx ()
((_) #`(quote #,(call-with-input-file "uci-descriptions.js"
(lambda (f) (json->sjson f))))))))
@tonyg
tonyg / gist:1033686
Created June 19, 2011 02:39
Pattern-matching over objects using views and coviews
(define-language <list>
(Nil)
(Cons first rest))
(define-language <maybe>
(Nothing)
(Just value))
(define-language <tsil>
(Snoc butlast last))