Skip to content

Instantly share code, notes, and snippets.

View captainpete's full-sized avatar

Peter Hollows captainpete

View GitHub Profile
@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 / 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));
@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
### 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 / 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',
@captainpete
captainpete / yahoo-finance-csv-curl.rb
Last active September 29, 2015 17:38
Yahoo Finance currency conversion method in Ruby (for prototyping use, budget but works)
require 'csv'
# Cheers to Greg on StackOverflow
# http://stackoverflow.com/questions/181990/programmatically-access-currency-exchange-rates
class Yahoo
def self.fetch(code = 'AUDUSD')
csv = `curl -q "http://download.finance.yahoo.com/d/quotes.csv?s=#{code}=X&f=sl1d1t1ba&e=.csv"`
values = CSV.parse(csv)
values[0][1]
@captainpete
captainpete / pyrit-benchmark-output
Created January 16, 2012 10:58
dojo7-cracking-station-upgrade
Running benchmark (20114.1 PMKs/s)... -
Computed 20114.07 PMKs/s total.
#1: 'OpenCL-Device 'Juniper'': 22367.4 PMKs/s (RTT 2.8)
#2: 'CPU-Core (SSE2)': 401.4 PMKs/s (RTT 3.3)
@captainpete
captainpete / currency-formatter.coffee
Created January 14, 2012 22:09
dojo7-formatting-currency-in-javascript
Number.prototype.toCurrency = ->
match = (this / 100).toString().match(/^-?(\d+)(\.\d+)?$/)
return unless match
cents = if match[2] then (match[2] + '00').substr(1, 2) else '00'
dollars = match[1].replace(/(\d)(?=(\d\d\d)+(?!\d))/g, '$1,')
result = "$#{dollars}.#{cents}"
result = '-' + result if this < 0
@captainpete
captainpete / gist:1449044
Created December 8, 2011 22:44
Pyrit benchmark: MacBook Pro 6,2 (15" mid-2010), 2.4GHz Intel Core i5, NVIDIA GeForce GT 330M 256MB
Pyrit 0.4.0 (C) 2008-2011 Lukas Lueg http://pyrit.googlecode.com
This code is distributed under the GNU General Public License v3+
Running benchmark (2747.2 PMKs/s)... \
Computed 2747.16 PMKs/s total.
#1: 'OpenCL-Device 'GeForce GT 330M'': 1630.3 PMKs/s (RTT 2.6)
#2: 'CPU-Core (SSE2)': 458.1 PMKs/s (RTT 3.1)
#3: 'CPU-Core (SSE2)': 477.6 PMKs/s (RTT 3.1)
#4: 'CPU-Core (SSE2)': 471.0 PMKs/s (RTT 3.1)