Table of contents
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): |
{-# 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 |
import requests | |
import os | |
twilio_sid = os.environ['TWILIO_SID'] | |
twilio_auth = os.environ['TWILIO_AUTH'] | |
twilio_url = 'https://api.twilio.com/2010-04-01/Accounts/%(twilio_sid)s/SMS/Messages.json' % locals() | |
weather_url = 'http://api.openweathermap.org/data/2.5/weather' | |
weather_params = {'q': 'montreal'} | |
r = requests.get(weather_url, params=weather_params) |
from random import randint | |
def run(goal, runs): | |
total = 0 | |
for x in xrange(runs): | |
sequence = [] | |
for i in xrange(3): | |
sequence.append(randint(0,1)) | |
while sequence[-3:] != goal: | |
sequence.append(randint(0,1)) |
var quote = String.fromCharCode(39); | |
var source = [ | |
'var quote = String.fromCharCode(39);', | |
'var source = [', | |
' ', | |
'];', | |
'console.log(source[0]);', | |
'console.log(source[1]);', | |
'source.forEach(function(line) {', | |
' console.log(source[2] + quote + line + quote + ",");', |
Proposition: If
If we want to show that the product of two continuous functions is continuous, we need the following lemma:
Lemma: If
data StockState = StockState { hi :: Int, lo :: Int, lowest :: Int } | |
deriving Show | |
solve xs = (hi st) - (lo st) | |
where | |
st = solve' xs | |
solve' [] = StockState 0 0 0 | |
solve' (x:xs) = foldl go (StockState 0 0 x) xs | |
where |
var _ = require('underscore'); | |
var freqVector = function(word, letters) { | |
var freq = _.groupBy(word.split(''), function(l) {return l;}); | |
return _.map(letters, function(l) { | |
return freq[l] ? freq[l].length : 0; | |
}); | |
}; | |
var dot = function(v1, v2) { |
function counter(times, callback) { | |
var ct = 0; | |
return function() { | |
ct++; | |
if (ct === times) | |
callback(); | |
}; | |
}; | |
// register a counter function |