Skip to content

Instantly share code, notes, and snippets.

View fingertree_simple.erl
%%%-------------------------------------------------------------------
%%% @author Alex S
%%% @copyright (C) 2016, Alex S
%%% @doc
%%% Homegrown Hinze/Paterson FingerTree implementation optimized for speed and
%%% occasionally size.
%%% Note that despite Erlang being an eager language, we do not use
%%% Kaplan-Tarjan implementation because I didn't want to descend into
%%% madness of stacks of stacks upon stacks; thus, this implementation
%%% gives no real-time guarantees but good amortized guarantees.
@ElectronicRU
ElectronicRU / snake.py
Last active Sep 30, 2015
A simple snake game
View snake.py
# snake
from collections import deque
import functools
import operator
import time
import tkinter
from tkinter.constants import *
import random
class point(tuple):
@ElectronicRU
ElectronicRU / dmenu_history.sh
Last active Dec 14, 2015
dmenu script for providing unlimited history sorted by number of uses/most recent use.
View dmenu_history.sh
#!/bin/sh
if [ $# -lt 1 ] ; then
echo 1>&2 "usage: dmenu_history hist_file dmenu_opts..."
exit 1
fi
f="$1"
tf=`mktemp`
if ! [ -e "$f" ]; then touch "$f"; fi
shift
( sort -r -k 1,1 -n -s "$f" | cut -d' ' -f2- ; cat - ) | dmenu "$@" |
View scarmble.py
import random
def recase(w):
return ''.join(x.upper() if random.randint(0, 1) else x.lower() for x in w)
import sys
n = int(sys.argv[2])
for i in range(n):
print(recase(sys.argv[1]), end=' ')
print()