Skip to content

Instantly share code, notes, and snippets.

(defvar *variable-memory* (make-hash-table :test #'equal))
(fare-memoization:define-memo-function (intern-variable :table *variable-memory*) (name variable-specs)
(flet ((field? (n)
(cdr (assoc n variable-specs))))
(make-instance 'variable
:name (json:lisp-to-camel-case (symbol-name name))
:concept? (field? :concept)
:label (field? :label))))
@bhyde
bhyde / google-search.el
Last active August 29, 2015 13:56
Emacs command to google something.
(defvar google-query-history nil)
(defun google (query)
"Search google in the regular web browser, prefix arg for luck."
;; Mac only, due to the use of the unix open command.
(interactive
(list
(read-string "Query: "
(if (use-region-p)
(buffer-substring (region-beginning) (region-end))
[[ $# -gt 0 ]] || error 'Missing Argument(s)'
case $1 in
-h) check_args -h ; do_help ;;
--help) check_args --help ; do_help ;;
help) check_args help ; do_help ;;
add-key) check_args add-key url ; do_add_key $2 ;;
list-keys) check_args list-keys ; do_list_keys ;;
sign) check_args sign key_id file file ; do_sign $2 $3 $4 ;;
get) check_args get url ; do_get $2 ;;
*) check_args url ; do_get $1 ;;
@bhyde
bhyde / bad_ssh_agent_signer.py
Last active August 29, 2015 13:57
Sign some data using ssh_agent's first key. Doesn't work. Angels weep.
#!/usr/bin/python
# Doesnt work ... the can_verify result is probably the hint why not.
# based loosely on http://blog.oddbit.com/2011/05/09/signing-data-with-ssh-agent/
# Script to generate a cryptographic signature over a bit of data
# The signing is done by the current ssh-agent, using the first key stored
# in that agent. Usually that is the current user.
@bhyde
bhyde / gist:9515331
Last active August 29, 2015 13:57
cl-launch doesn't read it's init file until you beg?
bash-3.2$ cl-launch --version
cl-launch 3.22.1
Supported implementations:
sbcl, cmucl (lisp), clisp, ecl, ccl (openmcl), abcl,
xcl, gcl (gclcvs), allegro (alisp), lispworks, scl
Local defaults for generated scripts:
will search in this order these supported implementations:
sbcl clisp ccl ecl cmucl gclcvs lispworks allegro gcl abcl scl
@bhyde
bhyde / Readme.org
Last active August 29, 2015 13:57
asparagus

P is a peer 2 peer scheme based on WebRTC.

The fun thing here is a network status widget defined in mon.js. It displays the list of peers and their isOpen status.

drc.html and drc.js attempt to be the simplest peers possible.

I don’t understand:

  1. Why I get to connect message for each peer I fire up.
@bhyde
bhyde / gist:52647332e89074bb9977
Created June 27, 2014 15:55
Teach emacs to indent cl-flet and cl-macrolet.
;;; gosh.el --- control our enthusiasm
;; -*- mode: emacs-lisp; lexical-binding: t; -*-
;; Local Variables:
;; lisp-indent-function: common-lisp-indent-function
;; eval: (put 'cl-flet 'common-lisp-indent-function (get 'flet 'common-lisp-indent-function))
;; eval: (put 'cl-macrolet 'common-lisp-indent-function (get 'flet 'common-lisp-indent-function))
;; End:
@bhyde
bhyde / quickload_system_test
Created July 8, 2014 17:18
Assuming you have a working docker setup 'quickload_system_test foo' will (ql:load "foo") in a container and leave a of that in runs/foo/foo.log
#!/bin/bash
cd $(dirname $0)
set -o nounset -o errexit
function LOG(){ echo "LOG: $*" ; }
function ERROR(){ echo "ERROR: $*" ; }
function cleanup(){ echo '' ; }
trap "cleanup; ERROR in $0; exit 1" ERR
if [[ 0 == $# ]] ; then ERROR "missing system name arg."; exit 1; fi
QL_SYSTEM="$1"
DIR="runs/$QL_SYSTEM"
@bhyde
bhyde / start-droplet-setup-ssh
Created July 30, 2014 21:44
Create droplet using tugboat, and wait for it. Wait till we can ssh_keyscan can get it's host key. Update my known_hosts. Plus, a paranoid check that ssh is working reliability.
#!/bin/bash
# Usage: start-droplet-setup-ssh <name> london docker
NAME="$1"
REGION="$2"
IMAGE="$3"
function LOG() { echo "LOG: $*" ; }
function ERROR() { echo "ERROR: $*" ; exit 1 ;}
@bhyde
bhyde / bad_indent.sh
Created November 18, 2014 18:31
A clever scheme to indent shell output, which doesn't work :(
#!/bin/bash
function indent(){
exec 6>&1
exec > >(sed 's/^/ /')
}
function end_indent(){
exec 1>&6 6>&-
}