Skip to content

Instantly share code, notes, and snippets.

@bhyde
bhyde / establish-routing-to-boot2docker-container-network
Last active November 2, 2019 18:59
Boot2docker - teach the mac how to connect to the containers by adjusting it's routing.
#!/bin/bash
# Script to instruct the Mac how to route packets to the
# software defined network where containers created via boot2docker
# reside. This lets you casually directly to ports (ssh, http, etc. etc.)
# on those containers.
function ERROR(){ echo "ERROR: $*" ; }
function FAIL(){ echo "FAILING: $*" ; exit 1; }
if [[ 'running' != $(boot2docker status) ]]
then FAIL "boot2docker's VM not running" ; fi
IP_OF_DOCKER_HOST=$(boot2docker ip 2> /dev/null)
@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 / 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: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 / 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.
[[ $# -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 / 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))
(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 / foo-nov23.lisp
Created November 23, 2013 16:37
Some one liners in service of making a list of etherpad-lite plugins. See: https://github.com/ether/etherpad-lite/wiki/Plugin,-a-list
(in-package #:cl-user)
;;; run each form in here one at a time by hand.
(ql:quickload '("cl-json" "drakma"))
(defparameter *all* ;; This takes quite a while.
(cl-json:decode-json-from-source
(drakma:http-request "https://registry.npmjs.org/-/all" :want-stream t)))
@bhyde
bhyde / access.log of attack
Last active December 28, 2015 20:19
Two files, the access.log during the attack (only the one IP included). Note that my wp-login.php requires two factor auth. Then the file that was hacked in the install.
211.110.140.155 - - [19/Nov/2013:17:30:37 -0800] "GET /wp-login.php HTTP/1.1" 200 3163 "http://enthusiasm.cozy.org/wp-login.php" "Mozilla/4.0 (compatible; MSIE 9.0; Windows NT 6.1; 125LA; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022)"
211.110.140.155 - - [19/Nov/2013:17:30:38 -0800] "GET /wp-login.php HTTP/1.1" 200 3163 "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"
211.110.140.155 - - [19/Nov/2013:17:30:39 -0800] "GET /wp-login.php HTTP/1.1" 200 3163 "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"
211.110.140.155 - - [19/Nov/2013:17:30:40 -0800] "GET /?author=1 HTTP/1.1" 301 353 "http://enthusiasm.cozy.org/?author=1" "Mozilla/4.0 (compatible; MSIE 9.0; Windows NT 6.1; 125LA; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022)"
211.110.140.155 - - [19/Nov/2013:17:30:41 -0800] "GET /?author=1 HTTP/1.1" 301 353 "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"
211.110.140.155 - - [19/Nov/2013:17:30:43 -0800] "GET /archives/author/admin HTTP/1.1" 200 4