Skip to content

Instantly share code, notes, and snippets.

View edma2's full-sized avatar

Eugene Ma edma2

  • San Francisco, CA
View GitHub Profile
"""
An efficient scramble/Scramble solver.
Author: Eugene Ma
"""
class Trie(object):
def __init__(self):
self.edges = {}
self.end_state = False
def load(self, path_to_dict):
# beaglenmt diagnostics web server - Vanya Sergeev <vsergeev at gmail.com>
# http://dev.frozeneskimo.com/embedded_projects/beaglebone_network_multitool_server
#
import cherrypy
import os, subprocess, time, shlex, threading, copy
FORTUNE_BIN_PATH = "/home/edma2/minifortune"
FORTUNE_DIR_PATH = "/home/edma2/fortunes"
STATS_UPDATE_INTERVAL = 3
import xml.etree.ElementTree as xml
import sys
import httplib
def usage():
print 'usage: %s <stopId>' % sys.argv[0]
exit(-1)
if len(sys.argv) != 2:
usage()
import itertools
import sys
from bottle import route, run, redirect
ALPHANUM = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
def usage():
print 'usage: %s <hostname> <port>'
exit(-1)
;; zipper.scm
;; A binary tree zipper implementation in Scheme
;; Author: Eugene Ma (edma2)
(define (make-tree datum left right)
(list datum left right))
(define datum car)
(define left-child cadr)
(define right-child caddr)
(define (make-leaf datum)
import copy
import re
class Board(object):
'''
tile
[a-z] placed tile
"_" normal empty square
[2-9] multiplier empty square
'''
@edma2
edma2 / q13.c
Created March 18, 2012 08:15
Project Euler #13
/*
* Project Euler #13
* Eugene Ma
*
* Real Answer: 5537376230
*/
#include <stdio.h>
#include <string.h>
@edma2
edma2 / tsort.go
Created March 15, 2012 00:21
Fun with Go: Topological Sort
package main
import "fmt"
/* Graph representation */
type Dag struct {
outgoing_edges map[int][]int
incoming_edges map[int][]int
}
; tee
; Returns non-zero exit code if an error occured
section .bss
buf: resb 1024
buflen equ $-buf
stdin equ 0
stdout equ 1
O_WRONLY equ 1q
O_CREAT equ 100q
import sys
from random import choice
MAXWORDS = 10000 # Max words to output
NPREF = 2 # Number of prefix words
NONWORD = '\n' # Sentinel word
table = {} # {(p1,p2) : [s1, s2, s3]}
prefix = tuple([NONWORD for i in range(NPREF)])
wordlist = sys.stdin.read().split()