Skip to content

Instantly share code, notes, and snippets.

View jayrbolton's full-sized avatar
🍕

Jay R Bolton jayrbolton

🍕
View GitHub Profile
# Right turn directions
TURN_DIR = {
'u': 'r',
'r': 'd',
'd': 'l',
'l': 'u',
}
# Right turn coordinate math
TURN_FN = {
@jayrbolton
jayrbolton / drum-lang.md
Created April 10, 2020 20:53
Esoteric drumming and programming
  • Like a drum machine, you have a memory bank of patterns, where each pattern is a function definition
  • You invent a rhythm to signify a function name
    • While your functions's rhythm is playing in a loop, you can edit the function body
    • Add certain sounds and/or rhythms in a sequence to add commands, such as variable assignment or function application
    • To add a nested lexical scope, such as a while loop or a conditional, you loop a "keyword rhythm"
      • For example, there may be a special "if-condition" rhythm. While the if-condition rhythm is playing, you are editing the inside of its block. At this point, both the function body and if-condition rhythms will be looping in the background
  • When you execute a function, all the sounds and rhythms are played back in execution order at any speed you wanta
  • Keywords, commands, and functions are differentiated by rhythm, sound, and/or tone
@jayrbolton
jayrbolton / gfu-diff.diff
Created February 12, 2020 18:16
GenomeFileUtil prod vs current diff
diff --git a/GenomeFileUtil.spec b/GenomeFileUtil.spec
index 9c8c209..d2cb40c 100644
--- a/GenomeFileUtil.spec
+++ b/GenomeFileUtil.spec
@@ -19,18 +19,18 @@ module GenomeFileUtil {
typedef mapping<string, string> usermeta;
- /*
+ /*
@jayrbolton
jayrbolton / word_count.omi
Last active August 14, 2019 01:31
Asynchronously count words from from stdin and print formatted results to stdout
import @/table
export word_count
main
# Channel of words
| words <- !split_to_channel /\s/ stdin
# Hash table of word mapped to count
| word_counts <- !word_count words
$ iterate line <- !format word_counts
group :num
:int :float
type :bintree:leaf a
@val a
type :bintree:branch a
@left :bintree a
@right :bintree a
# Sum of multiples of `n` up to `limit
# eg: 18 is the sum of multiples of 3 up to 10 (3, 6, 9)
fun mul_sum n:int lim:int -> int
| sum <- 0
| counter <- 1
| mul <- n
$ loop while !lt mul lim
| counter <- !inc counter
| mul <- !add mul n
| sum <- !add sum mul
# Register-based -- all varaibles are stored in registers. Sub-function calls are templated and expanded inline
# Compute the nth factorial
fun factorial n:int -> int
| count <- n
$ loop while (gt count 1)
| count <- dec count
| n <- mul count n
$ repeat
$ return n
@jayrbolton
jayrbolton / push_pull_threads_zmq.py
Created June 24, 2019 17:43
Example of push pull workers with zmq thread queue vs builtin thread queue
import time
import zmq
import zmq.devices
from threading import Thread
# Advantages:
# - Easier to change the architecture around
# - Easier to add other processes, workers, remote workers, etc
# Disadvantages:
# - Need a little knowledge of zmq
@jayrbolton
jayrbolton / push_pull_threads_queue.py
Created June 24, 2019 17:43
Example of push pull workers with builtin thread queue vs zmq thread queue
import time
from threading import Thread
from queue import Queue
# Advantages:
# - a little simpler, uses only builtins
# - doesn't require another lib
# Disadvantages:
# - harder to migrate to other architectures (eg. request/reply, processes, fair share)
import time
import zmq
import atexit
import logging
from zmq.devices import ProcessDevice
from zmq.log.handlers import PUBHandler
from multiprocessing import Process
# All child processes we create
procs = [] # type: list