Skip to content

Instantly share code, notes, and snippets.

View drhodes's full-sized avatar

Derek Rhodes drhodes

View GitHub Profile
import Mathlib.Tactic
open Nat
theorem induction0 {P : ℕ → Prop}
(base : P 0) (step : ∀m, P m → P (succ m)) : (∀n, P n) := by
intro k
cases k with
| zero => exact base
| succ m =>
import math
from PIL import Image
from PIL import ImageDraw
'''
to run, need python3
$ python3 -m venv venv
$ source ./venv/bin/activate
$ pip install pillow
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;; Firefox-like font resizing ;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define fonts
(list->vector
(list "5x7" "5x8" "6x9" "6x10" "6x12" "6x13" "7x13" "7x14" "8x13"
"8x16" "9x15" "10x20" "11x22" "14x28" "16x32"
"-xos4-terminus-medium-r-normal--22-220-72-72-c-110-microsoft-cp1251"
@drhodes
drhodes / alu_rom.py
Last active February 4, 2020 21:44
generate rom table
class Line(object):
def __init__(self, addr_pattern):
self.ins = addr_pattern.split(" ")[0].strip()
self.out = addr_pattern.split(" ")[1].strip()
def out_format(self):
return self.out.replace("x", "0")
def matches(self, addr):
# addr is a string of 0 and 1 chars.
@drhodes
drhodes / gcd.test
Last active February 5, 2020 01:50
.power Vdd=1
.thresholds Vol=0 Vil=0.1 Vih=0.9 Voh=1
.group inputs RESET START A[31:0] B[31:0]
.group outputs S[31:0]
.mode gate
.cycle CLK=1 tran 5n assert inputs tran 45n CLK=0 tran 49n sample outputs tran 1n
@drhodes
drhodes / sub-scheme.el
Created January 7, 2020 16:30
a scheme config
(defun xscheme ()
"Loads xscheme and runs a scheme process in the current buffer."
(interactive)
(load-library "xscheme")
(xscheme-start "scheme -emacs"
(buffer-name)
(buffer-name))
;;
)
#!/usr/bin/env python3
# simulate the field inside a hollow conductor with N number of
# equally space thin wire at a distance R from the center.
from PIL import Image
from numpy import arange
import math
#-----------------------------------------------------------------------------
# -*- sh -*-
#!/usr/bin/env bash
TMPFILE=/tmp/selfcontrol.temp
# remove self control from hosts
cat /etc/hosts | grep -v self-control > $TMPFILE
echo "# self-control" >> $TMPFILE
@drhodes
drhodes / lumoto.py
Last active January 14, 2018 15:56
# translating pseudocode from wikipedia's quicksort to python.
# https://en.wikipedia.org/wiki/Quicksort#Lomuto_partition_scheme
# algorithm quicksort(A, lo, hi) is
def quicksort(A, lo, hi):
# if lo < hi then
if lo < hi:
# p := partition(A, lo, hi)
p = partition(A, lo, hi)
# quicksort(A, lo, p - 1 )
@drhodes
drhodes / jade2json-firefox.py
Last active May 8, 2017 13:38
extract JADE modules from firefox localstorage and output to a specified JSON file
#!/usr/bin/env python
import sqlite3
import json
import argparse
parser = argparse.ArgumentParser(description='extract JADE modules from firefox localstorage')
parser.add_argument('infile', metavar='infile',
type=str, help='the infile, something like: ./some/path/to/webappsstore.sqlite')
parser.add_argument('outfile', metavar='outfile',
type=str, help='the output, for example myModules.json')