This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import os, os.path | |
sys.path.insert(0, os.getcwd()) | |
import zmq | |
addr = 'inproc://tmp1' | |
msg = '0' | |
copy = True | |
sw = zmq.Stopwatch() | |
cycles = int(sys.argv[1]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os, sys, socket, passfd | |
import tornado.httpserver | |
import tornado.ioloop | |
import tornado.web | |
import time | |
class HelloHandler(tornado.web.RequestHandler): | |
def get(self): | |
self.write('hello from pid: %s' % os.getpid()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class What(object): | |
def __init__(self, arg={}): | |
self.arg = arg | |
assert not len(self.arg) | |
arg[1] = 2 | |
What() | |
# Whoops... arg is a mutable object |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def parse(data): | |
char = data.pop(0) | |
if char == '[': | |
return parse_list(data) | |
elif char == '{': | |
return parse_object(data) | |
elif '0' <= char <= '9': | |
return parse_int(char, data) | |
elif char in 'tfn': |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Data.List (partition) | |
sortByOther :: String -> String -> String | |
sortByOther [] _ = [] | |
sortByOther (x:xs) ins = matches ++ sortByOther xs rejects | |
where (matches, rejects) = partition (==x) ins | |
main = putStrLn $ sortByOther "abcd" "ccbbaae" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a = "ccbbaa" | |
a = sorted(a) | |
f = {} | |
n = 0 | |
cc = a[0] | |
for c in a: | |
if c != cc: | |
f[cc] = n | |
n = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Test: | |
Given two strings, `a` and `b`. Sort the letters in `a` by the order of letters in `b`. | |
For example: | |
a = "ssttexeste" | |
b = "test" | |
result = "ttteeesssx" | |
""" | |
def a_by_b(a, b): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
// I would like to export a class from Purescript like below. | |
class MyObjectFromPurescript { | |
constructor(n) { | |
this.n = n | |
} | |
getN() { | |
return this.n; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
main = lambda view, port, host='0.0.0.0', recvlen=4096, recvtimeout=0.0: ( | |
(lambda sys, socket, itertools, urllib, re, cStringIO, pprint, datetime, types, select, traceback, BaseHTTPServer: | |
(lambda _try, recursive: | |
(lambda HttpRequest, HttpResponse: | |
(lambda conn2buf, serverloop, log_hit, errorview: | |
(lambda sock, handler: | |
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) or |
This file has been truncated, but you can view the full file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var h$currentThread = null; | |
var h$stack = null; | |
var h$sp = 0; | |
var h$initStatic = []; | |
var h$staticThunks = {}; | |
var h$staticThunksArr = []; | |
var h$regs = []; | |
var h$r1 = 0; | |
var h$r2 = 0; | |
var h$r3 = 0; |