Skip to content

Instantly share code, notes, and snippets.

@darius
darius / heh.py
Last active December 10, 2020 02:28
"""
Try to sclambre wrods itno the msot porbable wrooddis *not* in the
lexcion. We optimize the priblitaboy unsig hlil-cimbling wtih random
restrat. The ruselt: pettry asuming. The pragrom: pettry solw.
"""
import collections
import operator
import random
import re
@mouse-reeve
mouse-reeve / fizzbuzz.py
Last active April 22, 2022 06:33
Fizzbuzz via answers.com
''' we're solving fizzbuzz with a little help from the web '''
from html.parser import HTMLParser
from urllib.request import Request, urlopen
import re
import time
base_url = 'https://www.answers.com/Q/'
tag_name = 'div'
class_name = 'answer-body'
delimiter = '_'
;; manual
(def fuel (atom 10))
(loop []
(when (zero? (swap! fuel dec))
(fail "out of fuel!"))
(recur))
anonymous
anonymous / gist:bda6c8f3388f95df8b59860b4090e88c
Created September 19, 2017 03:31
Create screencaptures of HTML-made playing cards
console.log("doing puppeteer things!")
const puppeteer = require('puppeteer');
const dim = {
x: 823,
y: 597
};
const tileCount = 1;
@aparrish
aparrish / understanding-word-vectors.ipynb
Last active July 9, 2024 15:59
Understanding word vectors: A tutorial for "Reading and Writing Electronic Text," a class I teach at ITP. (Python 2.7) Code examples released under CC0 https://creativecommons.org/choose/zero/, other text released under CC BY 4.0 https://creativecommons.org/licenses/by/4.0/
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@andymatuschak
andymatuschak / States-v3.md
Last active June 12, 2024 04:17
A composable pattern for pure state machines with effects (draft v3)

A composable pattern for pure state machines with effects

State machines are everywhere in interactive systems, but they're rarely defined clearly and explicitly. Given some big blob of code including implicit state machines, which transitions are possible and under what conditions? What effects take place on what transitions?

There are existing design patterns for state machines, but all the patterns I've seen complect side effects with the structure of the state machine itself. Instances of these patterns are difficult to test without mocking, and they end up with more dependencies. Worse, the classic patterns compose poorly: hierarchical state machines are typically not straightforward extensions. The functional programming world has solutions, but they don't transpose neatly enough to be broadly usable in mainstream languages.

Here I present a composable pattern for pure state machiness with effects,

Interactive Machine Learning

Taught by Brad Knox at the MIT Media Lab in 2014. Course website. Lecture and visiting speaker notes.

@marick
marick / gist:9975e6cb76b11350f55b
Last active November 30, 2015 20:34
Alternate history

Consider the relational database. Queries to it return vectors of maps of (eventually) primitives. Databases as varied as Mongo and Redis do the same.

Consider communication to a Javascript or native app front end. It is via (JSON or XML) vectors and maps of (eventually) primitives.

The same applies in the reverse direction: maps and vectors come from the front end, are munged, and are inserted as maps and vectors of (eventually) primitives.

Are all apps 3-tier web apps? No. But I would claim they are the dominant kind of app today, in terms of mindshare and sheer amount of effort devoted to easing their development.

So, interesting: an enormous amount of effort is spent on apps that convert map/vector-structured data into map/vector-structured data.

@queertypes
queertypes / Filter.hs
Created April 14, 2015 07:53
A Filter algebra based on semirings with a pure evaluator
module Filter where
-- | F(ilter) a, the Filter algebra
-- Literal := in | eq | lt | gt | false | true
-- Term t := Literal | And t t | Or t t | Not t
data F a
-- Expression literals
= InF [a]
| EqF a
| GtF a
@bhauman
bhauman / README.md
Last active December 3, 2019 16:43
ClojureScript minimal dev and prod setup.

Recent improvements to the ClojureScript compiler have greatly simplified setting up development versus production outputs.

This example uses Figwheel as something that you want to exclude for production, but the pattern is general.

With this simple setup you only need one html file/view and it will work for developement and production.