Skip to content

Instantly share code, notes, and snippets.

View captainpete's full-sized avatar

Peter Hollows captainpete

View GitHub Profile
@captainpete
captainpete / backup.sh
Created November 27, 2024 05:17
Backup Evernote to Tarsnap on MacOS
#!/bin/sh
# initial run instructions:
#
# brew install evernote-backup
# evernote-backup init-db
# sync to latest
evernote-backup sync
@captainpete
captainpete / 2048_sim.js
Created May 14, 2018 07:04
2048 game simulation snippet
// Add the initial tiles
this.grid.insertTile(new Tile({x:3,y:0}, 2**1));
this.grid.insertTile(new Tile({x:2,y:0}, 2**1));
this.grid.insertTile(new Tile({x:1,y:0}, 2**2));
this.grid.insertTile(new Tile({x:0,y:0}, 2**3));
this.grid.insertTile(new Tile({x:0,y:1}, 2**4));
this.grid.insertTile(new Tile({x:1,y:1}, 2**5));
this.grid.insertTile(new Tile({x:2,y:1}, 2**6));
this.grid.insertTile(new Tile({x:3,y:1}, 2**7));
this.grid.insertTile(new Tile({x:3,y:2}, 2**8));
### Keybase proof
I hereby claim:
* I am captainpete on github.
* I am captainpete (https://keybase.io/captainpete) on keybase.
* I have a public key whose fingerprint is 108B 0A12 F415 0AC4 EDD7 17AB 16D5 D511 A1ED DA5B
To claim this, I am signing this object:
@captainpete
captainpete / unlock.rb
Created March 8, 2017 02:40
Ruby script for brute-forcing Apple encrypted volumes
#!/usr/bin/env ruby
require 'pry'
require 'set'
# disk UUID
# find with `diskutil corestorage list`
UUID = "1D1D6CEB-4613-472C-AE71-BD50651D44D1"
SUFFIXES = [ '', '!!', '123' ]
JOINS = [ '', ',', ', ' ]
@captainpete
captainpete / infnoise.conf
Created March 5, 2015 05:41
Infinite Noise Ubuntu Upstart Script (/etc/init/infnoise.conf)
# infnoise
#
# Feed entropy pool using the Infinite Noise TRNG
description "Infinite Noise"
start on filesystem or runlevel [2345]
stop on runlevel [!2345]
respawn
@captainpete
captainpete / infnoise
Last active October 16, 2017 11:22
Infinite Noise Gentoo Init Script (/etc/init.d/infnoise)
#!/sbin/openrc-run
description="infnoise - Feed entropy pool using the Infinite Noise TRNG"
pidfile="/var/run/infnoise.pid"
command="/usr/local/sbin/infnoise"
command_args="--dev-random"
start_stop_daemon_args="--make-pidfile --background"
depend() {
before urandom
anaglyph.plot <- function(x,y,z,left="red",right="cyan",depth="med",style="pop-out",type="p",...) {
if (depth=="low") {
scale <- 0.1
} else if (depth=="med") {
scale <- 0.2
} else if (depth=="high") {
scale <- 0.5
}
@captainpete
captainpete / .zshrc
Created May 6, 2014 07:42
Whiteboard ImageMagick zsh function
# Whiteboard photo cleanup script
# inspired by https://gist.github.com/lelandbatey/8677901
# converts an image to png, extracts strokes, traces etc.
whiteboard() {
convert "$1" "$1.converted.png"
echo "Converted"
convert "$1.converted.png" \
-morphology Convolve DoG:15,100,0 \
-negate -normalize -blur 0x1 -channel RBG \
@captainpete
captainpete / ruby-install-rbx-2.2.6-rl_username_completion_function-fix
Last active February 4, 2022 02:31
ruby-install rbx 2.2.6, Rubinius Mavericks "error: ... rl_username_completion_function" workaround
# If installing Rubinius 2.2.6 fails
# with an error containing 'rl_username_completion_function'
ruby-install rbx 2.2.6 # <= fails
# Remove and re-extract Rubinius
cd ~/src && rm -fr rubinius-2.2.6 && tar -xf rubinius-2.2.6.tar.bz2
# Make sure LLVM is installed
brew install llvm
# Make sure the other libs are present
@captainpete
captainpete / moment-calendar_title.js.coffee
Created August 13, 2012 13:36
Date-based calendar formatter for momentjs
# Adapted from the momentjs calendar function
# Inspired by this answer: http://stackoverflow.com/a/10306813/325676
moment.fn.calendarTitle = ->
calendar =
sameDay : '[Today]',
nextDay : '[Tomorrow]',
nextWeek : 'dddd, Do MMM',
lastDay : '[Yesterday]',
lastWeek : '[Last] dddd',