Skip to content

Instantly share code, notes, and snippets.

View diiq's full-sized avatar

Sam Bleckley diiq

View GitHub Profile
@diiq
diiq / sicp-216.rkt
Last active April 11, 2019 15:50
SICP Exercise 2.16 notes
#lang sicp
#|
SICP's exercise 2.16 is marked with a warning that it's very difficult. There
are a handful of one-paragraph or even one-sentence attempts at answering it
floating around the internet, but nothing that satisfied me, so I'm trying to
build on what I found, and what I determined for myself, and write something a
little more complete.
@diiq
diiq / canonize.py
Last active July 15, 2018 22:58
Location canonization for Michigan elections (doesn't function for the "Village of Grosse Pointe Shores, A Michigan City", yet)
import csv
import re
from collections import Iterable
def flatten(items):
# Why in gods name am I forced to write this, python?
for x in items:
if isinstance(x, Iterable) and not isinstance(x, (str, bytes)):
for sub_x in flatten(x):
@diiq
diiq / select.tsx
Created July 13, 2018 19:15
Portals for ReactSelect
import * as React from 'react'
import * as ReactDOM from 'react-dom'
import ReactSelect from 'react-select'
import { TouchEvent } from 'react';
export class Select extends (ReactSelect) {
wrapper: any
menuContainer: HTMLDivElement
handleMenuScroll: () => void
handleMouseDownOnMenu: () => void
@diiq
diiq / scores.md
Last active March 7, 2018 21:17
Neural Fluxus

Fluxus Scores Generated by Tensorflow

What are these supposed to be?

They are fluxus event scores; brief instructions for performance art. See https://en.wikipedia.org/wiki/Fluxus#Event_score

These particular event scores were created by training a predictive recurrent neural network on the Fluxus Performance Workbook. ~5000 lines of output were then generated (about the length of the workbook itself), most of which was gibberish. These scores were selected as the most performable examples from out of that gibberish, and many were lightly edited to correct spelling or grammar. The titles remain unaltered. The first score, Solo, is my favorite, and required no editing at all.

Solo
Performer peas on the stage.

Symphony

@diiq
diiq / index.js
Created December 4, 2017 21:00
Scraping the Michigan SOS voter registration page for 1 person, as a AWS lambda function
'use strict';
const https = require("https");
const querystring = require('querystring');
/*
APOLOGY:
50% of this mess is because I'm lazy and don't want to package a
requests library up to Amazon, That should probably be fixed.
@diiq
diiq / dice.py
Last active September 9, 2017 06:17
import random
from collections import defaultdict
def raw_roll(num):
dice = [random.randint(1, 10) for _ in range(num)]
# Extra dice for 10s
dice += [random.randint(1, 10) for _ in range(dice.count(10))]
# Drop the lowest
@diiq
diiq / InubatorCtrl.coffee
Created June 10, 2017 02:16
Intubator (an old haxxy Angular 1 snippet)
class Player
constructor: (@gplayer, @nextId) ->
@top = true
@vol = 30
load: (id) =>
@top = false
@gplayer.loadVideoById
videoId: @nextId()
@gplayer.mute()
require "rsec"
module Parsing
extend Rsec::Helpers
# build the parser
def self.query_lang
# Predicate should be constructed with loop over keywords
predicate = /.*?(?=STATUS IS|TYPE IS|AND|OR|\(|\)|$)/.r.map { |s| s.strip }
@diiq
diiq / pull_request.md
Last active October 23, 2015 15:06
Pull Request Template

Link to story: http://something.somwhere.schmoo

What this PR does:

Explain in a few sentences what functionality changed, and how. Can your changes be seen by a user? Then add a screenshot. Is it an interaction? Perhaps a recording.

Notes

Are there any surprises? Anything that was particularly difficult, or clever, or made you nervous, and should get particular attention during review? Call it out.

@diiq
diiq / code.js
Last active August 29, 2015 14:20
/** Load 'er up! **/
$.ajax({url:url, dataType:"json", async:false, success:grid.mport});
grid.specials = {
//3:[{src:"baobad.png", x:66, y:2, offset:[-95, -287]}],
//3:[{src:"baobab.png", x:66, y:2, offset:[-110, -370]}]
//3:[{src:"clockwork.png", x:66, y:2, offset:[-50, -235]}]
};