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
expand (Plus a) = foldr interleave [] $ do | |
match <- expand a | |
return $ match:(map (match++) (expand (Plus a))) | |
expand (Plus a) = (concat . ap (iterate . liftM2 (++) . expand) expand) a |
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
(define (zip-cons a b) | |
(if (null? a) | |
'() | |
(cons (cons (car a) (car b)) | |
(zip-cons (cdr a) (cdr b))))) | |
(define (p c r) | |
(cond | |
((null? c) (map (lambda (x) '()) r)) | |
((eq? (car c) (caar r)) |
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 | |
# Verhoeff implementation from Hermann Himmelbauer, | |
# http://en.wikibooks.org/wiki/Algorithm_Implementation/Checksums/Verhoeff_Algorithm#Python | |
verhoeff_table_d = ( | |
(0,1,2,3,4,5,6,7,8,9), | |
(1,2,3,4,0,6,7,8,9,5), | |
(2,3,4,0,1,7,8,9,5,6), | |
(3,4,0,1,2,8,9,5,6,7), |
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 ast | |
import operator | |
ops = { | |
ast.Add: operator.add, | |
ast.Mult: operator.mul, | |
ast.Sub: operator.sub, | |
ast.Div: operator.truediv, | |
ast.FloorDiv: operator.floordiv, |
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
<html> | |
<body> | |
<div> | |
<input type=file id="the_file"> | |
<button id="prev" onclick="goPrevious()">Previous</button> | |
<button id="next" onclick="goNext()">Next</button> | |
| |
<span>Page: <span id="page_num"></span> / <span id="page_count"></span></span> | |
</div> |
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
snippet sup | |
super(`GetCurrentPythonClass()`, `GetFirstPythonArg()`).`GetCurrentPythonMethod()`(${1:`GetCurrentPythonArgs()`})${2} |
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 Resource(object): | |
class Base(object): | |
pass | |
class List(generics.ListCreateAPIView): | |
pass | |
class Detail(generics.RetrieveUpdateDestroyAPIView): | |
pass |
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 DecoratorMixin(decorator): | |
""" | |
Converts a decorator written for a function view into a mixin for a | |
class-based view. | |
:: | |
LoginRequiredMixin = DecoratorMixin(login_required) | |
class MyView(LoginRequiredMixin): |
OlderNewer