Skip to content

Instantly share code, notes, and snippets.

View MostAwesomeDude's full-sized avatar

Corbin Simpson MostAwesomeDude

View GitHub Profile
import math
BASE = 4
def XPForLevel(level):
"The amount of XP to reward for a given power level."
return int(BASE ** level)
print "Level 2.7 enemy is worth", XPForLevel(2.7)
from collections import defaultdict
import string
words = open("wordsEn.txt", "rb").read().split("\r\n")
words.sort(key=lambda k: (-len(k), k))
def longestWordsByLetter(k):
remaining = dict((c, k) for c in string.lowercase)
rv = defaultdict(list)
for word in words:
import "lib/streams" =~ [=> flow :DeepFrozen]
exports (main)
def main(argv, => makeTCP4ServerEndpoint) as DeepFrozen:
def ep := makeTCP4ServerEndpoint(7777)
ep.listenStream(flow)
return 0
exports (main)
object nullStream as DeepFrozen:
to _printOn(out):
out.print("null")
to map(_):
return nullStream
to fold(_, x):
@MostAwesomeDude
MostAwesomeDude / puyo.fall
Last active December 18, 2015 11:39
Hmmm.....
blocks = {
|&*,
}
colors = {red, green, blue, yellow, white}
discrete
stick immediately
Powers of Two
Assume: http://en.wikipedia.org/wiki/Fundamental_theorem_of_arithmetic
Assume: No power of two is divisible by three.
Assume: In any three sequential integers, exactly one is divisible by three.
Even powers of two are congruent to 3 mod 1. Proof:

Consider one single vat. There are objects in this vat. With the exception of some types, listed below, all objects are made of pure S code. The difference between a builtin type and an object made from S code is not visible from within the object space; for all objects, only message passing can be used to communicate and no object introspection is possible.

Note that "type" simply means "a template for an object." There is no visible difference between a function which returns an object and a type, nor is there any typechecking per se.

Here are some builtin types. This list is not yet exhaustive, but it won't get much longer. Types without literal syntax have a + next to them, and have quasiliteral syntax instead.

  • int
  • float
  • str: Unicode strings.
  • bytes+: Bytestrings. bytes is important because it is the type of objects which are used as identifiers and message names.
data Protocol s a = Protocol { state :: s
, connected :: Bool
, transport :: Maybe Transport
, makeConnection :: Transport -> Protocol s a
, connectionMade :: Protocol s a
, dataReceived :: [a] -> Protocol s a -> ([a], Protocol s a)
, connectionLost :: Maybe Reason -> Protocol s a }
def mk_nested_defaultdict(levels, factory):
base = lambda: defaultdict(factory)
while levels:
levels -= 1
base = lambda: defaultdict(base)
return defaultdict(base)
from twisted.python import log
from sys import stdout
log.startLogging(stdout)
from twisted.internet.protocol import Protocol, Factory
class EchoProtocol(Protocol):
def dataReceived(self, data):
self.transport.write(data)
class EchoFactory(Factory):