Skip to content

Instantly share code, notes, and snippets.

@cjwebb
cjwebb / pymeals_user_invite.bson
Created September 19, 2012 19:22
Pymeals User Invite
{
"_id" : ObjectId(“505a1614001b9c1a9cb10803"),
"password" : "$2a$12$vCew7zzXqtyRGKQV4xfSZ.KbmmCRMx.pVJD6DesTLrOvuUghB5Oeu",
"expiry_time" : ISODate(“2012-10-21T18:59:31.753Z"),
"invite_code" : "an-invite-code",
"activation_code" : "cbcff14"
}
@cjwebb
cjwebb / pymeals_user.bson
Created September 19, 2012 19:29
Pymeals User
{
"_id" : ObjectId("504ae6e2001b9c0548ab0b64"),
"password" : "$2a$12$vCew7zzXqtyRGKQV4xfSZ.KbmmCRMx.pVJD6DesTLrOvuUghB5Oeu",
"email" : "an_email@address.com",
"created_date" : ISODate(“2012-09-18T18:59:31.753Z")
}
@cjwebb
cjwebb / pymeals_ttl_index.json
Created September 19, 2012 19:35
Pymeals User Invite TTL Index
{
"v" : 1,
"key" : { "expiry_time" : 1 },
"ns" : "pymeals.user_invites",
"name" : "expiry_time_1",
"expireAfterSeconds" : 1
}
@cjwebb
cjwebb / ai-notes-1.markdown
Last active December 6, 2015 15:24
Notes on MIT 6.034 Artificial Intelligence

Lecture videos, programming assignments, and exam papers for [MIT's Artificial Intelligence course][course-url] are available online. These are my notes from "taking" the course.

[Lecture 1: Introduction and Scope][lecture-1]

This course, and every subject at MIT, is based around making models. [Professor Winston][prof-winston] explains that this course will teach:

Algorithms enabled by

Constraints evolved by

@cjwebb
cjwebb / pymeals_create_ttl_index.txt
Created December 17, 2012 21:34
MongoDb: Create TTL index on collection
db.user_invites.ensureIndex( { "expiry_time": 1 }, { expireAfterSeconds: 1 } )
import Color exposing (..)
import Graphics.Collage exposing (..)
import Graphics.Element exposing (..)
main : Element
main =
collage 300 300
[ blueLine
, xAxis
, yAxis
import akka.actor._
import akka.camel.{CamelExtension, CamelMessage, Consumer, Producer, Oneway}
import org.apache.activemq.camel.component.ActiveMQComponent
import org.apache.activemq.ScheduledMessage
case class Message(body: String)
class SimpleConsumer() extends Actor with Consumer {
def endpointUri: String = "activemq:foo.bar"
package io.github.cjwebb
import scala.annotation.tailrec
object Fibonacci extends App {
/** Get the nth fibonacci number */
def fib_iter(n: Int) = {
if (n < 2) n
else {
/**
* Problems from
* http://aperiodic.net/phil/scala/s-99/
*/
object NinetyNine extends App {
// P02
def penultimate[A](l: List[A]): A = l match {
case h :: _ :: Nil => h
case h :: tail => penultimate(tail)
@cjwebb
cjwebb / RomanNumerals.scala
Last active December 29, 2015 15:39
Solutions to the classic roman numerals problem
class RomanNumerals {
def toInt(romanNumerals: String): Int = {
@annotation.tailrec
def recur(l: List[Int], total: Int): Int = {
l match {
case h :: Nil => total + h
case h :: tail if h < tail.head => recur(tail, total - h)
case h :: tail => recur(tail, total + h)
case Nil => total // romans didn't have zero though
}