Skip to content

Instantly share code, notes, and snippets.

@justinfay
justinfay / sockpile.py
Last active August 29, 2015 14:03
Python program resembling how I pile my socks.
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 = []
def private():
"""
Factory function for creating Private instances.
"""
def _():
_.attr = 0
class Private(object):
"""
func! DeleteTrailingWS()
exe "normal mz"
%s/\s\+$//ge
exe "normal `z"
endfunc
autocmd BufWrite * :call DeleteTrailingWS()
<!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">
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
func! DeleteTrailingWS()
exe "normal mz"
%s/\s\+$//ge
exe "normal `z"
endfunc
autocmd BufWrite * :call DeleteTrailingWS()
@justinfay
justinfay / permutations.js
Last active October 16, 2022 16:15
Python `itertools.permutations` javascript equivalent.
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 = [];
SQL_CREATE_POST = ''
SQL_RETRIEVE_POST = ''
SQL_UPDATE_POST = ''
SQL_DELETE_POST = ''
class Persistent(object):
# Implements persistence logic using dbkit.
pass
import re
@app.template_filter('linkify')
def linkify_filter(text):
return re.sub(r'(https?://[^\s\\]+)', r'<a href="\1">\1</a>', text)
# 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]