Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
wrk=$(mktemp)
CGROOT=/sys/fs/cgroup
SUBGROUP=subgroup
IFS=:
cp /proc/self/cgroup $wrk
while read id ctrl path ; do
[ "$path" = "/" ] && continue
Public source:
https://raw.githubusercontent.com/Werkov/Werkov.github.io/874101fed2664468ef3b02c2486c1dc7069d5799/_posts/2019-01-09-predictions.md
Checksums:
8bc09fc868f1cc54253e865a092d15a59af0a6aa _posts/2019-01-09-predictions.md
3db759e1ec1f1a81a27889080eb7992b _posts/2019-01-09-predictions.md
Public source:
https://raw.githubusercontent.com/Werkov/Werkov.github.io/72c52850c39a102499a048e59772a4d9147ba796/_posts/2018-01-13-predictions.md
Checksums:
a9f7d7e5ddf4def05310db2196185b67dda283f2 _posts/2018-01-13-predictions.md
e166a2a36a399a000fda91c7e71df1a8 _posts/2018-01-13-predictions.md
@Werkov
Werkov / git-time-stats.py
Created September 4, 2013 13:27
Estimates time spent on a project from Git commit timestamps
#!/usr/bin/python3
# Estimates time spent on a project from commit timestamps
#
# If two commits are less than INERTIA time apart, the time
# between them is considered spent, otherwise SINGLE_COMMIT
# time is taken.
import os
@Werkov
Werkov / ngram-entropy.py
Created June 17, 2012 21:09
Random variable entropy meter
#!/usr/bin/python3
from collections import defaultdict
from math import log
def entropy(n, sequence):
"""
Estimates entropy of random sequence of elements
based on ngram distribution.
@Werkov
Werkov / Bedna2012.Kostky.Bazinga.py
Created May 13, 2012 16:42
Bedna2012.Kostky.Bazinga
#!/usr/bin/python3
_cache = {}
def sums(addends, sum):
"""Return list of tuples of @addends addends that sums up to @sum."""
global _cache
if addends < 1 or sum < addends:
return []
if (addends, sum) not in _cache:
result = [] if addends > 1 else [(sum,)]
@Werkov
Werkov / weasel.py
Created January 14, 2012 16:49
Cumulative selection demo (inspired by Richard Dawkins)
#!/usr/bin/env python3
#
# WEASEL
# Inspired by Richard Dawkins.
#
from random import random, choice
genoverse = 'ABCDEFGHIJKLKMNOPQRSTUVWXYZ '
@Werkov
Werkov / tac.py
Created November 12, 2011 22:05
Interlos.P1.Bazinga
def play(desk, who):
bestResult = -2
for row in range(0, 3):
for col in range(0, 3):
if desk[row][col] != 0:
continue
desk[row][col] = who
if testLoser(desk, row, col, who):
bestResult = max(bestResult, -1)
else: