Skip to content

Instantly share code, notes, and snippets.

Matthew Wetmore wetmore

View GitHub Profile
from django.conf import settings
from django.db import models
# A Batch represents one batch, and may be assigned to multiple
# users.
class Batch(models.Model):
name = models.CharField(max_length=200)
assigned_users = models.ManyToManyField(settings.AUTH_USER_MODEL, blank=True)
def __str__(self):
View lol.hs
{-# LANGUAGE GADTs, RankNTypes, TypeFamilies, DataKinds, DeriveFunctor, TypeOperators #-}
import Data.Type.Equality
import Data.List (intercalate)
import Data.Maybe (catMaybes)
data HasVars = Var | NoVar
data SHasVars a where
SVar :: SHasVars Var
wetmore / stocks.hs
Last active Nov 8, 2015
Find the maximum profit from buying and selling once.
View stocks.hs
data StockState = StockState { hi :: Int, lo :: Int, lowest :: Int }
deriving Show
solve xs = (hi st) - (lo st)
st = solve' xs
solve' [] = StockState 0 0 0
solve' (x:xs) = foldl go (StockState 0 0 x) xs
View gist:0ed545c37f1c0fe3bd29
assignment = __dirname.substr(__dirname.lastIndexOf('/') + 1)
module.exports = (grunt) ->
files: ['!full.tex', '*.tex']
tasks: 'exec:pdf'
event: ['changed']
wetmore / gist:25a968bd4ffbaf67416a
Created Oct 4, 2014
Tex source for a homework assignment with code and math
View gist:25a968bd4ffbaf67416a
%% Use utf-8 encoding for foreign characters
%% Vector based fonts instead of bitmaps
wetmore / gist:2c6286e0873fd2ee4b7e
Created Oct 4, 2014
Tex source for notes on a talk about quantum teleportation
View gist:2c6286e0873fd2ee4b7e
\documentclass[11pt, oneside]{article} % use "amsart" instead of "article" for AMSLaTeX format
\usepackage{geometry} % See geometry.pdf to learn the layout options. There are lots.
\geometry{letterpaper} % ... or a4paper or a5paper or ...
%\geometry{landscape} % Activate for for rotated page geometry
%\usepackage[parfill]{parskip} % Activate to begin paragraphs with an empty line rather than an indent
\usepackage{graphicx} % Use pdf, png, jpg, or eps with pdflatex; use eps in DVI mode
% TeX will automatically convert eps --> pdf in pdflatex
View gist:6ab9a2d5949defc07a11
  1. Give an algorithm to find the longest common subsequence for two given strings using edit distance (the minimal number of additions, deletions and substitutions needed to transform one string into the other).
wetmore / gist:11137017
Last active Aug 29, 2015
Fun math problems
View gist:11137017

Fun problems (rendered at

  1. Find $\displaystyle\sum_{n=1}^\infty \frac{n}{2^n}$

  2. Find $\displaystyle\sum_{n=1}^\infty \frac{n^2}{2^n}$

  3. Let $a(k) = \displaystyle\sum_{n=1}^\infty \frac{n^k}{2^n}$. Find a recurrence relation for $a(k)$.

  4. Let $\mathcal{N}$ be the set of natural numbers that do not contain a 6 in their decimal expansion (so, $\mathcal{N} = { 1, 2, 3, 4, 5, 7, \ldots, 14, 15, 17, \ldots }$). Prove that $$ \sum_{n\in\mathcal{N}} \frac{1}{n} < 80 $$

wetmore /
Last active Dec 29, 2015
Reviewing some parts of javascript I don't know well enough. And also just a dump of some current knowledge.
wetmore / gist:6600824
Last active Dec 23, 2015
hack101 api
View gist:6600824
import requests
import os
twilio_sid = os.environ['TWILIO_SID']
twilio_auth = os.environ['TWILIO_AUTH']
twilio_url = '' % locals()
weather_url = ''
weather_params = {'q': 'montreal'}
r = requests.get(weather_url, params=weather_params)
You can’t perform that action at this time.