Skip to content

Instantly share code, notes, and snippets.

View rgov's full-sized avatar
🤿

Ryan Govostes rgov

🤿
View GitHub Profile
@rgov
rgov / debruijn.py
Last active November 14, 2023 07:37
de Bruijn sequence generator
def deBruijn(n, k):
'''
An implementation of the FKM algorithm for generating the de Bruijn
sequence containing all k-ary strings of length n, as described in
"Combinatorial Generation" by Frank Ruskey.
'''
a = [ 0 ] * (n + 1)
def gen(t, p):
@rgov
rgov / gist:893792
Created March 30, 2011 03:11
startup script for Python to enable tab completion
from sys import stdout, stderr
# Enable tab completion if readline is available. Rather than using the
# default completer, though, we allow tabs at the beginning of the line.
try:
import readline
readline.is_libedit = 'libedit' in readline.__doc__
except ImportError:
pass
else:
AAABAACAADAAEAAFAAGAAHAAIAAJAAKAALAAMAANAAOAAPAAQAARAASAATAAUAAVAAWAAXAAYAAZABABBABCABDABEABFABGABHABIABJABKABLABMABNABOABPABQABRABSABTABUABVABWABXABYABZACACBACCACDACEACFACGACHACIACJACKACLACMACNACOACPACQACRACSACTACUACVACWACXACYACZADADBADCADDADEADFADGADHADIADJADKADLADMADNADOADPADQADRADSADTADUADVADWADXADYADZAEAEBAECAEDAEEAEFAEGAEHAEIAEJAEKAELAEMAENAEOAEPAEQAERAESAETAEUAEVAEWAEXAEYAEZAFAFBAFCAFDAFEAFFAFGAFHAFIAFJAFKAFLAFMAFNAFOAFPAFQAFRAFSAFTAFUAFVAFWAFXAFYAFZAGAGBAGCAGDAGEAGFAGGAGHAGIAGJAGKAGLAGMAGNAGOAGPAGQAGRAGSAGTAGUAGVAGWAGXAGYAGZAHAHBAHCAHDAHEAHFAHGAHHAHIAHJAHKAHLAHMAHNAHOAHPAHQAHRAHSAHTAHUAHVAHWAHXAHYAHZAIAIBAICAIDAIEAIFAIGAIHAIIAIJAIKAILAIMAINAIOAIPAIQAIRAISAITAIUAIVAIWAIXAIYAIZAJAJBAJCAJDAJEAJFAJGAJHAJIAJJAJKAJLAJMAJNAJOAJPAJQAJRAJSAJTAJUAJVAJWAJXAJYAJZAKAKBAKCAKDAKEAKFAKGAKHAKIAKJAKKAKLAKMAKNAKOAKPAKQAKRAKSAKTAKUAKVAKWAKXAKYAKZALALBALCALDALEALFALGALHALIALJALKALLALMALNALOALPALQALRALSALTALUALVALWALXALYALZAMAMBAMCAMDAMEAMFAMGAMHAMIAMJAMKAMLAMMAMNAMOAMPAMQAMRAMSAMTAMUAMVAMWAMXAMYAMZANANBANCANDANEANFANGANHA
#!/bin/bash -e
RIN="6601234567"
PIN="12180"
SIS="sis.rpi.edu"
# Options for curl(1), e.g., -vvv for verbose and -s for silent.
CURLOPTS="-s"
# Use HTTPS if it's available.
#!/bin/bash -e
if [ "$1" = "store" ]; then
echo -n "Archiving Subversion metadata... "
find . -name '.svn' -type d -print0 > .svn.tmp
xargs -0 tar cf .svn.tar < .svn.tmp
xargs -0 rm -Rf < .svn.tmp
rm -f .svn.tmp
echo "done."
elif [ "$1" = "restore" ]; then
@rgov
rgov / Pages - Actual Size.scpt
Created October 13, 2011 00:31
Zoom Pages document to actual size.
(* Converts hex digits in big endian to an integer. *)
on fromHex(theDigits)
set theValue to 0
repeat with theDigit in theDigits
set theValue to (theValue * 16) + (offset of theDigit in "0123456789ABCDEF") - 1
end repeat
return theValue
end fromHex
(* Does a record have a certain key? (Hack.) *)
@rgov
rgov / gist:1297132
Created October 19, 2011 00:11
call functions in target process with lldb Python script
import lldb
class Executioner(object):
typemap = {
None: 'void',
int: 'int',
float: 'float',
str: 'char *',
}
@rgov
rgov / ciphcrack.py
Created October 21, 2011 03:22
Ciphode cracker
# Cracker for David Lougheed's Ciphode 0.06, by rgov.
# See www.davidlougheed.com/ciphode for details.
'''
printable is a set of all of the characters that can be easily typed. We can
use it to test whether a numkey decrypts the message into gibberish or not.
'''
from string import printable
def isprintable(string):
@rgov
rgov / gist:1499136
Created December 19, 2011 22:10
Row reduced echelon form with modular arithmetic
import numpy as np
def modinv(n, mod):
'''
Lazily finds the multiplicative inverse of n modulo mod.
'''
for x in xrange(1, mod):
if (n * x) % mod == 1: return x
else:
raise ArithmeticError('%i has no multiplicative inverse modulo %i.' % (n, mod))
#!/bin/bash
ps -Ac -o pid=,command= | grep -v 'launchd' | while read line; do
PID=$(echo $line | cut -f 1 -d ' ')
CMD=$(echo $line | cut -f 2- -d ' ')
cat <<EOF > /tmp/gdbscript
attach $PID
sharedlibrary update
info sharedlibrary