Skip to content

Instantly share code, notes, and snippets.

View teddyknox's full-sized avatar

Teddy Knox teddyknox

  • eigenlayer.xyz
  • New York, NY
  • 07:50 (UTC -04:00)
View GitHub Profile
@teddyknox
teddyknox / pats_ast.swift
Last active February 28, 2017 08:39
Using Swift's Protocols with Associated Types to compile-time check an Abstract Syntax Tree DSL
//
// feb25.swift
// AbstractSyntaxTree
//
// Created by Edward Knox on 2/25/17.
// Copyright © 2017 Edward Knox. All rights reserved.
//
import Foundation
@teddyknox
teddyknox / product.scala
Created October 29, 2015 15:53
Scala product function to generate combinations across sets.
def product[T](seqs: Seq[Seq[T]]): Seq[Seq[T]] = {
var combos = Seq[Seq[T]](Seq[T]())
for (seq <- seqs) {
combos = for {
combo <- combos
id <- seq
} yield combo :+ id
}
combos
}
@teddyknox
teddyknox / 0_reuse_code.js
Created October 29, 2015 15:52
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console

Keybase proof

I hereby claim:

  • I am teddyknox on github.
  • I am teddy (https://keybase.io/teddy) on keybase.
  • I have a public key whose fingerprint is 0100 E5E7 720B 4DC3 5481 D5AD 9B22 16C4 7740 CE8D

To claim this, I am signing this object:

TwitterPrep ➤ python boggle.py
building dictionary tree... done.
5x5 board
----------
T Y G L B
T C C N D
H Y Y O T
E N C U M
M N U D E
----------
#!/usr/bin/env python
from functools import partial
from random import randint, uniform
from pprint import pprint
from operator import truth, add
def build_dict_tree(filename):
f = open(filename)
D = {}
@teddyknox
teddyknox / session.js
Created June 23, 2013 23:02
Socket.io Express 3.0 session retrieval function
io.set('authorization', function(handshake, callback) {
if (handshake && handshake.headers && handshake.headers.cookie) {
cookieParser(handshake, {}, function(err) {
if(err) {
return callback('COOKIE_PARSE_ERROR', false);
}
var sessionId = handshake.signedCookies[config.cookie];
sessionStore.load(sessionId, function(err, session) {
if(err || !session) {//|| !session.auth || !session.auth.loggedIn) {
callback('NOT_LOGGED_IN', false);