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 random | |
# Each colour of sock represented by an integer. | |
socks = 2 * range(20) | |
# Randomize the order of our socks. | |
random.shuffle(socks) | |
# Container variable for our sorted socks and working stack. | |
sorted = [] | |
stack = [] |
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 private(): | |
""" | |
Factory function for creating Private instances. | |
""" | |
def _(): | |
_.attr = 0 | |
class Private(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
func! DeleteTrailingWS() | |
exe "normal mz" | |
%s/\s\+$//ge | |
exe "normal `z" | |
endfunc | |
autocmd BufWrite * :call DeleteTrailingWS() |
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
<!DOCTYPE html> | |
<html> | |
</h1>{{ config['COIN_NAME'] }} Faucet</h1> | |
{% if sent %} | |
<h2>your coins have been queued for sending</h2> | |
{% endif %} | |
{% if error %} | |
<h3>{{ error }}</h3> | |
{% endif %} | |
<form action="{{ url_for('index') }}" method="post"> |
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 itertools import chain, izip_longest | |
__all__ = ('detect_cycle',) | |
def detect_cycle(graph): | |
""" | |
Detect a cycle in a directed graph by removing | |
nodes with no leaf nodes. If there are nodes |
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
func! DeleteTrailingWS() | |
exe "normal mz" | |
%s/\s\+$//ge | |
exe "normal `z" | |
endfunc | |
autocmd BufWrite * :call DeleteTrailingWS() |
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 permutations(array, r) { | |
// Algorythm copied from Python `itertools.permutations`. | |
var n = array.length; | |
if (r === undefined) { | |
r = n; | |
} | |
if (r > n) { | |
return; | |
} | |
var indices = []; |
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
SQL_CREATE_POST = '' | |
SQL_RETRIEVE_POST = '' | |
SQL_UPDATE_POST = '' | |
SQL_DELETE_POST = '' | |
class Persistent(object): | |
# Implements persistence logic using dbkit. | |
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
import re | |
@app.template_filter('linkify') | |
def linkify_filter(text): | |
return re.sub(r'(https?://[^\s\\]+)', r'<a href="\1">\1</a>', text) |
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
# Expose a local service running on port 5000 | |
# on host host.com on port 9999. | |
ssh -R0.0.0.0:9999:localhost:5000 [email protected] |