A simple channel implementation for python for prototyping and debugging. It is thread-safe.
Args:
- ``: The IP address to listen on.
-- 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 |
def msqrt(n): | |
x = 1 | |
for i in xrange(100): | |
x = 1 + (float(n - 1) / (x + 1)) | |
return x |
import math | |
def memoize(f): | |
memo = {} | |
def wrapper(val): | |
if val not in memo: | |
memo[val] = f(val) | |
return memo[val] | |
return wrapper |
package main; | |
import "fmt" | |
import "runtime" | |
func main() { | |
runtime.GOMAXPROCS(1) | |
a := make(chan bool) | |
b := make(chan bool) |
# 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(): |
var elems = document.querySelectorAll("li.retableRow"); for (i = 0; i < elems.length; i++) { var item = elems[i]; var mid = item.getAttribute("data-movieid"); var date = item.querySelector(".col.date").textContent; var title = item.querySelector(".col.title a").textContent; var rating = item.querySelector(".col.rating div").getAttribute("data-your-rating"); console.log(mid + "," + date + "," + "\"" + title + "\"" + "," + rating); } |
#!/bin/bash | |
# Where the cookies are stored | |
COOKIES='cookies.tmp' | |
# Where the pages are temporarily stored | |
PAGE='page.tmp' | |
# value matching regex constant | |
VALUE_MATCHER='^ value="([^"]*)"' |
@classmethod | |
def resolve(cls, request, caching_client): | |
"""If this request isn't yet cached, cache it, otherwise return | |
a file containing the cached contents""" | |
hash = cls.hash(request) | |
is_caching = False | |
active_thread = None | |
# If there is no cached file | |
if not cls.hit(hash): | |
# obtain a lock for the active caches |
from itertools import product | |
import string | |
id_combos = product("".join((string.ascii_lowercase, string.digits[2:])), repeat=3) | |
ids = map("".join, id_combos) | |
print len(ids), "ids found." |