Skip to content

Instantly share code, notes, and snippets.

View cddr's full-sized avatar

Andy Chambers cddr

View GitHub Profile
(defun rangecheck (rc)
(lambda (actual)
(let* ((comparator (intern (property rc "Comparator") #.*package*))
(unit (find-def (kid-like 'measurementunitref :in rc)))
(test (case comparator
(LT '<)
(LE '<=)
(GT '>)
(GE '>=)
(EQ '=)
@cddr
cddr / gist:2977107
Created June 23, 2012 06:16
edit file that asdf failed to load
(defmethod asdf:perform :around ((op asdf:compile-op) (component asdf:cl-source-file))
(restart-case (call-next-method)
(slime-edit ()
:report "Edit file which failed to compile."
(progn
(ed-in-emacs (asdf::component-pathname component))
(abort)))))
./long-running-proc
#Ctrl-Z # stops the job
bg # starts it running in the background
disown %1 # detaches this process from the current shell
ps -ef |grep long-running-proc
502 6536 5782 0 21:02 pts/8 00:00:07 long-running-proc
kill -s SIGCONT 6536
@cddr
cddr / code-review.sh
Created January 30, 2013 22:51
Simple script to help reviewing large pull requests
# Helper script for anyone that has to review Ken's massive pull requests
#
# Usage:
# 0. Save this file as ~/bin/code-review, make it executable and put it in your $PATH
# 1. Use https://gist.github.com/3342247 to get a local copy of the PR
# 2. Save this as ~/bin/code-review
# 3. $ git checkout pr/foo
# 4. $ git diff develop.. --oneline |code-review
#
# Script to review code in the order specified by Dougo on where_web. If you
# prefer a different order just rearrange the order of "git diffs", and maybe
# alter the definition of "ordered_files" if you actually add or remove a step
#
# It assumes you've checked out a local copy of the pull request and are
# comparing that with develop.
#
BASE=develop
HEAD=HEAD
@cddr
cddr / stuey.rb
Created February 25, 2013 23:15
Testing daemons.....
MUM=["mom", "mommy", "mother", "mama"]
loop do
puts MUM.sample
sleep(1)
end
@cddr
cddr / gist:5228055
Created March 23, 2013 15:15
Common Lisp validation syntax
(defclass venue (validatable)
((zip :col-type string :initarg :zip :accessor zip)
(phone :col-type string :initarg :phone :accessor phone)
(website :col-type (or db-null string) :initarg :website :accessor website))
(:metaclass pomo:dao-class)
(:keys id))
(defvalidators venue ()
(website (start-with "https://"))
(phone (match "(\\d\\d\\d)-\\d\\d\\d-\\d\\d\\d"))
@cddr
cddr / yolo
Last active December 16, 2015 17:29
Finding a memory leak in ruby2/rails4
#You Only Leak Once
# Install valgrind using one of the following
brew install valgrind
sudo apt-get install vagrind
# make sure valgrind is enabled in your ruby build
CONFIGURE_OPTS="--with-valgrind" rbenv install 2.0.0-p0
# control test (should not show any memory leaks)
@cddr
cddr / annotate.js
Created July 11, 2013 15:19
Annotate a page with a formtastic form
javascript: (function () {
$("label").prepend(function () {
if ($("abbr sup", this).length === 0) {
var annotation = $("<sup>", { "text": $(this).attr("for"),
"style": "color: red" });
return $("<abbr>").append(annotation);
}
})
})();