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
# -*- coding: utf-8 -*- | |
top_level_domains=[ | |
u'ac', | |
u'com.ac', | |
u'edu.ac', | |
u'gov.ac', | |
u'net.ac', | |
u'mil.ac', | |
u'org.ac', | |
u'ad', |
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
#include <iostream> | |
using namespace std; | |
class memoize{ | |
public: | |
memoize(int); | |
double fib(int); | |
private: | |
double *memo; | |
int 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
class Memoize: | |
def __init__(self, function): | |
self.function=function | |
self.memoized={} | |
def __call__(self, *args): | |
try: | |
return self.memoized[args] | |
except KeyError: | |
self.memoized[args]=self.function(*args) | |
return self.memoized[args] |
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 functools, json | |
from siteparse import IndividualPage | |
GRAPH={'a':['b','c'], 'b': ['d'], 'c': ['d', 'a'], 'd': ['b', 'c']} | |
import urllib2, BeautifulSoup, urlparse | |
class IndividualPage(object): | |
def __init__(self, url): | |
self.source=urllib2.urlopen(url) |
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 permute(queue, final = []): | |
for item in queue: | |
remaining_queue, pending = [e for e in queue if e is not item], final + [item] | |
if remaining_queue: | |
for more in permute(remaining_queue, pending): | |
yield more | |
else: | |
yield pending |
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 datetime | |
from functools import wraps | |
def total_seconds(td): | |
return (td.microseconds + (td.seconds + td.days * 24 * 3600) * 10**6) / 10.0**6 | |
def throttle(time): | |
def _throttle(f): | |
f.time = time | |
f.time_since_last = datetime.datetime.now() - datetime.timedelta(seconds = time) |
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
(load "~~/lib/syntax-case") | |
(define-syntax let-values | |
(syntax-rules | |
() | |
((_ (mvbinding ...) . body) | |
(let-values foo (mvbinding ...) . body)) | |
((_ name () . body) | |
(let name () . body)) | |
((_ name ((vars mv) . mvbindings) . body) |
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
(load "~~/lib/syntax-case") | |
(define-syntax case-cond | |
(syntax-rules | |
(else) | |
((_ e (c r) ... (else d)) | |
(cond ((c e) r) ... (else d))))) | |
(define (curry f . c) (lambda x (apply f (append c x)))) |
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
; Scheme implementation of 'expression threading'. | |
; chains the given argument through each expression; such as | |
; (->> 5 | |
; (+ 3) | |
; (* 2)) === 16 | |
; | |
; or even better: | |
; | |
; (->> | |
; "lets find some even chars!" |
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
package main | |
import "fmt" | |
type IntegerReduce func(...int) int | |
func main() { | |
sum := func(n ...int) int { | |
sum := 0 | |
for _, v := range n { | |
sum += v |
OlderNewer