Skip to content

Instantly share code, notes, and snippets.

View jboynyc's full-sized avatar
🍜

John Boy jboynyc

🍜
View GitHub Profile
@jboynyc
jboynyc / get-in.rkt
Created August 12, 2018 18:08
`get-in` for racket
#lang racket
(define (get-in h . path)
(foldl (λ (p h) (hash-ref h p)) h path))
(define nested-dict #hash((foo .
#hash((bar .
#hash((spam .
#hash((eggs . 1)))))))))
one_obvious = 'more than one'
print(f'There should be {one_obvious} way to do it.')
@jboynyc
jboynyc / trumptown_networks.ipynb
Created April 13, 2018 09:07
Networks of Trump Town
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jboynyc
jboynyc / soundbots.rkt
Created April 4, 2018 22:51
robots making sounds
#lang racket
(require rsound)
(define *midi-notes* (range 38 85))
(define (choice lst)
(list-ref lst (random (length lst))))
(define (sublist lst midpoint width)
@jboynyc
jboynyc / playing-with-macros.rkt
Created March 27, 2018 23:17
racket macro experimentation
#lang racket
(define-syntax define-html-tag
(syntax-rules ()
[(_ element)
(define element
(let ([es (symbol->string 'element)])
(make-keyword-procedure
(lambda [keys vals . contents]
(let ([properties (string-join
@jboynyc
jboynyc / new_key_announcement.txt
Created February 14, 2018 22:39
I have a new pgp key
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
I am transitioning to using a new pgp key with fingerprint 272B9BDD29CFE9509A3DC60629A105A586DEB641.
You can get it from keyservers or keybase.io/jboy now.
This message is signed with my current key (74A7A4B33DE1D395), which expires in a few days.
-----BEGIN PGP SIGNATURE-----
iQIzBAEBCgAdFiEEsQFdpc0ErrdEdt31mR24sJ2K5NgFAlqEujsACgkQmR24sJ2K
@jboynyc
jboynyc / give_me_text.py
Created July 21, 2017 08:54
Give Me Text
import requests
def pdf_to_text(pdf_file):
'''
See http://givemetext.okfnlabs.org/#api for a description of the API.
'''
r = requests.put('http://beta.offenedaten.de:9998/tika', open(pdf_file, 'rb'))
r.raise_for_status()
r.encoding = 'utf-8'
@jboynyc
jboynyc / rolx.py
Created February 7, 2017 17:19
Run SNAP RolX role extraction on an IGraph network graph.
import subprocess
from collections import defaultdict
from tempfile import NamedTemporaryFile
import igraph as ig
ROLX_BIN = 'Snap-3.0/examples/rolx/testrolx'
def extract_roles(input_graph, min_roles=2, max_roles=3):
@jboynyc
jboynyc / setup-snappy.sh
Created February 7, 2017 17:05
Set up SNAP Python package in a virual environment
set -e
snap_env=snap_env
snap_pkg=snap-3.0.2-3.0-centos6.5-x64-py2.6
virtualenv -p python2.7 ${snap_env}
source snap_env/bin/activate
if [-d $snap_pkg ]
then wget http://snap.stanford.edu/snappy/release/${snap_pkg}.tar.gz && tar xzf ${snap_pkg}.tar.gz
fi
@jboynyc
jboynyc / Flying_Circus.ipynb
Last active January 26, 2017 12:16
Flying Circus Python course notebook
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.