Skip to content

Instantly share code, notes, and snippets.

View blinks's full-sized avatar

Adam Blinkinsop blinks

View GitHub Profile
@blinks
blinks / smtpcheck.py
Created January 16, 2009 16:35
Check if an email address exists without sending an email. Technique from: http://www.webdigi.co.uk/blog/2009/how-to-check-if-an-email-address-exists-without-sending-an-email/
#!/usr/bin/env python
"""
Check that a particular email address exists.
Adam Blinkinsop <blinks@acm.org>
WARNING:
Checking email addresses in this way is not recommended, and will lead to
your site being listed in RBLs as a source of abusive traffic. Mail server
admins do like it when they get connections that don't result in email being
sent, because spammers often use this technique to verify email addresses.
@blinks
blinks / scanner.py
Created January 16, 2009 16:43
A simple Python token scanner.
"""
Scanner: match text to generate tokens.
Adam Blinkinsop <blinks@acm.org>
First, construct a scanner with the tokens you'd like to match described as
keyword arguments, using Python-syntax regular expressions.
WARNING: Group syntax in these expressions has an undefined effect.
>>> simple = Scan(ID=r'\w+')
@blinks
blinks / roll.py
Created January 16, 2009 16:43
A dice roller.
#!/usr/bin/env python
import logging
import random
import re
import sys
ROLL = re.compile(r'(\d*)d(\d+)')
def roll(dice):
"""Randomly generate the result of a dice roll.
@blinks
blinks / gist:47991
Created January 16, 2009 16:44
A Mastermind Solver in Haskell.
-- Master: Mastermind Solver
-- Adam Blinkinsop <blinks@google.com>
import Data.Ord
import Data.List
-- Types for pegs and codes, mainly for display.
data Peg = Red | Green | Blue | White | Yellow | Orange
deriving (Eq, Ord, Show)
data Code = Code [Peg] deriving Show
data Response = Respond (Int, Int) deriving Eq
@blinks
blinks / randgame.py
Created February 10, 2010 20:11
Choose a random game from your BGG collection.
#!/usr/bin/env python2.6
"""
Choose a random game from your BGG collection. For example:
$ ./randgame.py blinks
Downloading collection for blinks...
Filtering collection of 66 for 2 players...
Filtering remaining 53 for 90 minutes...
Filtering remaining 39 for rating 6.0...
Choosing from 29 games... -> Fluxx <-
@blinks
blinks / otomata.ck
Created October 28, 2011 18:27
ChucK script to simulate Otomata
/**
* MIDI Helper Methods
*/
class MIDIConnection {
MidiOut mout;
fun void connect(int port) {
if (!mout.open(0)) { me.exit(); }
}
@blinks
blinks / core.clj
Created July 11, 2013 21:47
Four-part chorale algorithmic composer. Caveat emptor; this needs some major work, which is coming.
(ns bgm.core
(:use [overtone.inst sampled-piano])
(:require [clojure.set]
[overtone.core :as overtone])
(:gen-class))
(def golden-ratio 1.61803398875)
(def golden-ratio-conjugate (/ 1.61803398875))
;;; COMPOSITION
@blinks
blinks / gather.py
Created September 30, 2014 04:51
gather.py
#!/usr/bin/env python
# Gather cards from wizards.com into local Elasticsearch.
# Adam Blinkinsop <http://plus.google.com/+AdamBlinkinsop>
from elasticsearch import Elasticsearch
import bs4
import re
import urllib
def main(args):
sets = args.sets
@blinks
blinks / napoleon.markdown
Created September 6, 2018 21:51
A card-driven strategy game about the Napoleonic Wars.

A strategic card game about the Napoleonic Wars (c. 1797 to 1815), based on mechanisms from Glory to Rome.

Components

  • Decks of event cards, each with action, reaction, unit, and 2d6 roll.
  • A bunch of morale cubes.
  • A map of Europe and surrounding areas.
  • Standees for the various leaders involved.

Play

@blinks
blinks / harperpool.py
Created July 9, 2019 22:23
A monte carlo simulation of a very particular kind of dice pool.
#!/usr/bin/env python
# A simple monte carlo simulation for a specific kind of die pool.
#
# Usage: ./pool.py --trials=1000 4d6+3d8
import collections
import random
def main(args):
result = collections.defaultdict(lambda: 0)