Skip to content

Instantly share code, notes, and snippets.

View jboynyc's full-sized avatar
🍜

John Boy jboynyc

🍜
View GitHub Profile
@jboynyc
jboynyc / mapillary.py
Last active November 18, 2016 10:52
simple Mapillary API wrapper (for Python 3.4+)
# coding=utf-8
import requests
from yaml import load as yaml_load
from functools import partialmethod
from urllib.parse import urlencode, quote
class Mapillary(object):
def __init__(self, token='token.yaml'):
self._base_url = 'https://a.mapillary.com/v2'
@jboynyc
jboynyc / quicksort.scm
Created November 23, 2016 15:57
quicksort in Chicken Scheme
(use srfi-1) ; provides filter
(define (quicksort elems)
(if (null? elems) (list)
(let [[middle (car elems)]
[others (cdr elems)]]
(let [[left (filter (lambda (x) (<= x middle)) others)]
[right (filter (lambda (x) (> x middle)) others)]]
(append (quicksort left) (cons middle (quicksort right)))))))
@jboynyc
jboynyc / Flying_Circus.ipynb
Last active January 26, 2017 12:16
Flying Circus Python course notebook
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@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 / 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 / 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 / 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 / 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 / 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 / trumptown_networks.ipynb
Created April 13, 2018 09:07
Networks of Trump Town
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.