Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/python3
# program '.....' unused_letters exclusions
# board='..i..' guess=['roate','spunk','climb'] 3:a 1:s 4:m
# program '..i..' rotepunkclb 3:a 1:s 4:m
import sys
def main() -> int:
pattern = sys.argv[1]
@nrh
nrh / foo.bas
Created September 10, 2018 02:50
#picaxe 14m2
; constants
symbol COUNTPERIOD = 548 ; number of ms to count vss_in pulses
; 548 gives means vss_in ~= actual mph
symbol NUM_HINTS_UP = 5 ; number of times vss_in must be reported as fast/slow for the
symbol NUM_HINTS_DN = 5 ; tail to be triggered up/down
; 1 unit = .56sec
; 5 = 2.8sec
symbol MPH_RAISETAIL = 65
@nrh
nrh / virtualenv_functions.bash
Last active November 27, 2016 17:33
bash function for python virtualenv thingies.
function venv-activate {
if [ ! -z "$1" ]; then
. $PWD/$1/bin/activate
else
_matches=($(compgen -G "*/bin/activate") $(compgen -G ".??*/bin/activate"))
if [ ${#_matches[@]} -eq 0 ]; then
echo "Environment not found."
elif [ ${#_matches[@]} -eq 1 ]; then
_env=${_matches[0]}
echo "Found $_env"
[Wed May 4 21:27:17 2016] Processing genuino101 (platform: intel_arc32, board: genuino101, framework: arduino)
------------------------------------------------------------------------------------------------------------------------
arc-elf32-ar rcs .pioenvs/genuino101/libFrameworkArduino.a .pioenvs/genuino101/FrameworkArduino/CDCSerialClass.o .pioenvs/genuino101/FrameworkArduino/IPAddress.o .pioenvs/genuino101/FrameworkArduino/Print.o .pioenvs/genuino101/FrameworkArduino/RingBuffer.o .pioenvs/genuino101/FrameworkArduino/Stream.o .pioenvs/genuino101/FrameworkArduino/Tone.o .pioenvs/genuino101/FrameworkArduino/UARTClass.o .pioenvs/genuino101/FrameworkArduino/WInterrupts.o .pioenvs/genuino101/FrameworkArduino/WMath.o .pioenvs/genuino101/FrameworkArduino/WString.o .pioenvs/genuino101/FrameworkArduino/abi.o .pioenvs/genuino101/FrameworkArduino/hooks.o .pioenvs/genuino101/FrameworkArduino/i2c.o .pioenvs/genuino101/FrameworkArduino/main.o .pioenvs/genuino101/FrameworkArduino/new.o .pioenvs/genuino101/FrameworkArdui
@nrh
nrh / osx-for-hackers.sh
Last active September 14, 2015 17:51 — forked from brandonb927/osx-for-hackers.sh
OSX for Hackers: Yosemite Edition. This script tries not to be *too* opinionated and any major changes to your system require a prompt. You've been warned. Also, please don't email me about this script, my poor inbox...
#!/bin/sh
# Alot of these configs have been taken from the various places
# on the web, most from here
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# Set the colours you can use
black='\033[0;30m'
white='\033[0;37m'
red='\033[0;31m'
@nrh
nrh / gist:789dab11017c53f116ea
Last active August 29, 2015 14:12
Notes on Google Cloud Platform

Notes on Google Cloud Platform

Jan 7 2015

  • Recovering a root disk is a bit of a pain, surprising that there isn't a way to stop a vm/detach a disk and edit it elsewhere. the general pattern is:
    1. snapshot running? instance
    2. create new disk from snapshot
    3. attach disk to working VM
    4. modify disk
    5. clone old VM with new disk
    6. move over any stuff (IP, ..?)
@nrh
nrh / keybase.md
Created September 22, 2014 17:44

Keybase proof

I hereby claim:

  • I am nrh on github.
  • I am nrh (https://keybase.io/nrh) on keybase.
  • I have a public key whose fingerprint is C3D6 558D DB19 338F B722 3F6E 1267 D59D 266A 375D

To claim this, I am signing this object:

#!/bin/bash
[ "`whoami`" != "root" ] && echo "Should be run by root!" && exit 1
[ -e *.vmdk ] || ( echo Extracting VMDK image from *.ova ... ; tar xf *.ova )
[ -e github.img ] || ( echo Converting *.vmdk to raw image ... ; qemu-img convert *.vmdk github.img )
echo Preparing mounts ...
losetup -f github.img -P
vgchange -ay enterprise-11
[nrh@tinydancer ~/projects/pyrange (master)] nosetests -vxs
ok_expando_0 '[1-10]' ...
<Expando begin="1" end="10"/>
ok
ok_expando_1 '[10-1]' ...
<Expando begin="10" end="1"/>
ok
ok_expando_2 '[9999-10000]' ...
#!/bin/bash -x
# describe symlink destination as ["#]file: .foo, assume $HOME
for file in dot.*; do
dest=`grep '^[\"\#\/].*.file:' "$file"|gawk -F'[:[:space:]]' '{print \$3}'`
dest=$(eval echo $dest)
destdir=${dest%/*}
if [ "$destdir" != "$dest" -a ! -d "${HOME}/${destdir}" ]; then