Skip to content

Instantly share code, notes, and snippets.

View drhodes's full-sized avatar

Derek Rhodes drhodes

View GitHub Profile
@drhodes
drhodes / gist:8b93ccb3d00ad44c286b
Created November 3, 2015 05:12
embedding a github gist on the edx forum
Hello
#!/usr/bin/env bash
# thanks for the helpful blog post @
# https://paulbradley.org/video-to-animated-gif/
avconv -i $1 -r 10 -pix_fmt rgb24 -f gif - | gifsicle --optimize=9 --delay=10 --loopcount > $1.gif
@drhodes
drhodes / word_show.asm
Last active December 21, 2015 16:19
uasm assembly for printing a word in memory to the console
.include "beta.uasm"
.options tty
ADDC(SP, 0x800, SP) // allocating
BEQ(R31, main, R31) // goto main
. = . + 0x800
main:
ADDC(R31, 0x100, SP) // Set stack pointer
waddr = R1
ADDC(R31, 0x1000, waddr) // point waddr to array
PUSH(waddr) // pushing argument reverse order
@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')
@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 )
# -*- 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
#!/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
#-----------------------------------------------------------------------------
@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))
;;
)
@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 / 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.