Skip to content

Instantly share code, notes, and snippets.

View pnathan's full-sized avatar
⚒️
worker

Paul Nathan pnathan

⚒️
worker
View GitHub Profile
@pnathan
pnathan / notes-on-docker-error.md
Last active May 25, 2016 05:34
Notes on docker error May 13 2016

Likely immediate culprit was a typical gentoo upgrade a week or so ago. I don't use docker on this machine much, and it's been stable for the past few versions. I've had an unpleasant time before with upgrades.

Versions:

 $ docker --version
Docker version 1.11.0, build 4dc5990
@pnathan
pnathan / supershell.elisp
Created January 15, 2016 17:51
supah-shell
(defvar shell-count 0)
(defun supershell ()
(interactive)
(shell (concat "*shell" (number-to-string shell-count) "*"))
(setq shell-count (+ shell-count 1)))
@pnathan
pnathan / keep-containers-running.sh
Created October 16, 2015 03:29
keep-those-containers-running
#!/bin/bash
# downloads docker container.
running_id=$(docker ps | grep "$1" | cut -f1 -d' ')
docker pull "$1" | grep 'up to date'
if [[ "$?" -eq "1" ]]; then
docker kill $running_id
fi
@pnathan
pnathan / action-lib.rs
Created October 11, 2015 17:53
A pre-1.0 command runner in Rust
/*
action module.
The action module is a simplification of running processes. In
particular, it takes a bash-executable string and runs it under -xe
context.
*/
use std::io::File;
use std::io::process::Command;
use std::str::from_utf8_lossy;
#!/bin/bash -e
# code to cook a insecure raspbian apache server.
echo -e "\e[1;32m"
# Ridiculous leet script text. Probably mandatory for this kind of
# thing. I summon arbitrary memories of being a teenage geek to
# bolster and approve this message.
cat <<'EOF'

Howto build a rust compiler for the Raspberry Pi on Debian 7.1 (wheezy)

# additional information: http://stackoverflow.com/questions/19162072/installing-raspberry-pi-cross-compiler/19269715#19269715
sudo apt-get install git build-essential
test `uname -m` = x86_64 && sudo apt-get install ia32-libs
git clone https://github.com/raspberrypi/tools.git
export PATH=$PWD/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin:$PATH
git clone http://github.com/mozilla/rust.git
cd rust

./configure --target=arm-unknown-linux-gnueabihf

(require 'sb-introspect)
(defun curry-helper (paramlist args function-name)
(if (= (length paramlist) (length args))
(apply function-name args)
(lambda (&rest more-args)
(let ((args (append args more-args)))
(assert (>= (length paramlist) (length args)))
(curry-helper paramlist args function-name)))))
@pnathan
pnathan / gist:7649433
Created November 25, 2013 21:44
cl-postgres integration with local-time
(defmethod cl-postgres:to-sql-string ((arg local-time:timestamp))
(values
(format nil "~a" arg)
"timestamp"))
@pnathan
pnathan / scheduler.pro
Created November 25, 2013 08:35
Schedule suggester
% given constraints on a schedule with multiple people, find out what slots work.
available(monday, morning, jim).
available(tuesday, afternoon, jim).
available(wednesday, morning, jim).
available(wednesday, morning, julia).
available(tuesday, afternoon, james).
available(friday, afternoon, james).
@pnathan
pnathan / keyspace.lisp
Created November 23, 2013 09:51
Calculate the keyspace of a password.
(defun keyspace (string)
"Calculates the keyspace of an ASCII string; this can be used to
deny certain passwords from being used."
;; Hopefully the implementation is a smart string and knows how long
;; it is automatically.
(let ((length (length string))
(capabilities (make-hash-table :test #'eq)))
;; O(n)
(loop for ele across string