Skip to content

Instantly share code, notes, and snippets.

View jboynyc's full-sized avatar
🍜

John Boy jboynyc

🍜
View GitHub Profile
@jboynyc
jboynyc / kv_store.py
Created June 18, 2014 17:16
simple persistent key-value store backed by... shelve
import shelve
from contextlib import closing
class Store:
'''Simple persistent key-value store.'''
def __init__(self, shelf='data.shelf'):
self.shelf = shelf
def store(self, key, value):
with closing(shelve.open(self.shelf)) as db:
db[key] = value

Keybase proof

I hereby claim:

  • I am jboynyc on github.
  • I am jboy (https://keybase.io/jboy) on keybase.
  • I have a public key whose fingerprint is C481 C66B 553D 9DC4 3A38 0164 74A7 A4B3 3DE1 D395

To claim this, I am signing this object:

@jboynyc
jboynyc / gradcenter_email_transition.md
Last active August 29, 2015 14:10
What I found out about the Graduate Center email transition

What I found out about the Graduate Center email transition

Following the announcement about the migration of Graduate Center email to the hosted Microsoft Office365 service (and thus the gradcenter.cuny.edu domain), I inquired with GC IT about when our old gc.cuny.edu addresses will expire, since the announcement sent out by IT was unclear on this point.

According to the help desk, our old addresses will not be phased out so much as killed:

Once June 1st comes around, the @gc.cuny.edu accounts will be removed from our

@jboynyc
jboynyc / ZwartePiet_Analysis.ipynb
Last active August 29, 2015 14:10
A look at 2½ weeks' worth of #zwartepiet tweets
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jboynyc
jboynyc / cheryls-birthday.hy
Created April 25, 2015 15:27
What is Cheryl's birthday?
(def *possible-dates*
["May 15" "May 16" "May 19" "June 17" "June 18" "July 14" "July 16"
"August 14" "August 15" "August 17"])
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defn cheryls-birthday [possible-dates]
(filter all-statements possible-dates))
(defn month [date]
@jboynyc
jboynyc / UniqueQueue.py
Created May 19, 2015 09:07
Wrap Beanstalkc to create unique (deduplicated) queues.
import beanstalkc
from redis import Redis
class UniqueQueue(object):
'''Stores a persistent set of added jobs in Redis to keep jobs from being
added to the Beanstalkd queue more than once.'''
def __init__(self, tube_name='default', host='localhost'):
self.beanstalk = beanstalkc.Connection(host=host)
self.beanstalk.use(tube_name)
self.tube = self.beanstalk.using()
@jboynyc
jboynyc / demo.css
Last active December 14, 2015 14:29
/* if you want images to drop a shadow */
img {
box-shadow: 10px 10px 5px #888;
}
/* if you want "fleurons" instead of bullets in unordered lists */
ul {
padding-left:1em;
list-style:none;
margin-left:0;
@jboynyc
jboynyc / LIESMICH.md
Last active December 16, 2015 18:39
Project Euler solutions

I moved my solutions to a full-fledged repo, so that's where you should go looking for my latest kludges.

@jboynyc
jboynyc / nth-prime.scm
Last active December 21, 2015 02:08
Chicken Scheme program to compute the *n*th prime number (where *n* can be passed as an argument from the command line). Should be compiled using `csc` for optimal performance. Written to brute force the result of a Project Euler problem.
#!/usr/bin/env csi -ss
(use srfi-42)
(define (range from upto)
(list-ec (:range n from upto) n))
(define (zero-length? l)
(= (length l) 0))
@jboynyc
jboynyc / sum-of-primes.scm
Last active December 21, 2015 04:09
Chicken Scheme program to compute the sum of all primes below the number passed via the command line. Used to brute force a Project Euler problem. Compile using `csc` for better performance.
(use srfi-42)
(define (range from upto)
(list-ec (:range n from upto) n))
(define (zero-length? l)
(= (length l) 0))
(define (no-remainder? n d)
(= (remainder n d) 0))
(define (rounded-sqrt n)
(inexact->exact (round (sqrt n))))