A simple channel implementation for python for prototyping and debugging. It is thread-safe.
Args:
- ``: The IP address to listen on.
# Returns two classes, a "Sealer", and an "Unsealer". | |
# Lets call the Sealer "s" and the Unsealer "u". | |
# For any pair of s and u returned from makeBrandPair, s.seal(value) | |
# (where "value" can be any python object) returns a boxed version of | |
# value that cannot be extracted unless you have a reference to the | |
# unsealer u (not 100% sure on this, but it seems to be true). | |
# When you call u.unseal(box), the value originally sealed into the | |
# box is returned. A separate call to makeBrandPair will return | |
# a different sealer/unsealer pair that only work with eachother. | |
def makeBrandPair(): |
package main; | |
import "fmt" | |
import "runtime" | |
func main() { | |
runtime.GOMAXPROCS(1) | |
a := make(chan bool) | |
b := make(chan bool) |
type thing struct { | |
a, b int | |
c string | |
d uint | |
} | |
// this is valid go (in a function context) | |
v := thing{ a: 0, | |
b: 0, |
import math | |
def memoize(f): | |
memo = {} | |
def wrapper(val): | |
if val not in memo: | |
memo[val] = f(val) | |
return memo[val] | |
return wrapper |
def msqrt(n): | |
x = 1 | |
for i in xrange(100): | |
x = 1 + (float(n - 1) / (x + 1)) | |
return x |
function split(s, on) | |
local elems = {} | |
local buffer = "" | |
local i, c | |
for i = 1, #s do | |
c = string.sub(s, i,i) | |
if c == on then | |
table.insert(elems, buffer) | |
buffer = "" | |
else |
-- bencode.lua: A lua bencoding serializer and de-serializer | |
-- | |
-- The MIT License (MIT) | |
-- | |
-- Copyright (c) 2015 Josh Kunz | |
-- | |
-- Permission is hereby granted, free of charge, to any person obtaining a copy | |
-- of this software and associated documentation files (the "Software"), to deal | |
-- in the Software without restriction, including without limitation the rights | |
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
find . -name '.git' -type d -prune \ | |
| rev | cut -d '/' -f2- | rev | tr '\n' '\0' \ | |
| xargs -0 -n1 -I% bash -c 'echo -n "%..."; cd "%"; git fsck 2>/dev/null 1>&2; if [ $? -eq "0" ]; then printf "\e[32mPASS\e[39m\n"; else printf "\e[31mFAIL\e[39m\n"; fi' |
class foo: | |
__local = 10 | |
def local(self): return self.__local | |
def test(self, bar): return self.__local, bar.__local | |
class empty: | |
pass | |
ei= empty() | |
ei.__local = "hello from empty" | |
f = foo() |