Skip to content

Instantly share code, notes, and snippets.

View superbobry's full-sized avatar

Sergei Lebedev superbobry

View GitHub Profile
@superbobry
superbobry / with-arguments.md
Last active January 30, 2020 11:50
Пояснение к лекции про декораторы в CS Центре

Хочу ещё раз на примере декоратора trace пояснить, какие типы декораторов используются на практике и как они работают.

Декораторы без аргументов

Общая структура декоратора и пример использования:

def trace(func):
 def inner(*args, **kwargs):
@superbobry
superbobry / gist:8228050
Last active June 14, 2022 11:30 — forked from debasishg/gist:8172796
Sketching References
  1. General Background and Overview
@superbobry
superbobry / okasaki.ml
Created December 9, 2011 19:52
okasaki exercises
(* Chapter 2: BST *)
type 'a tree = Empty | Node of 'a tree * 'a * 'a tree
module Set : sig
val empty : 'a tree
val member : 'a tree -> 'a -> bool
val insert : 'a tree -> 'a -> 'a tree
end = struct
@superbobry
superbobry / tdf.rst
Last active April 23, 2023 05:22
TDF format spec

TDF

TDF is a binary format developed by the IGV team at Broad Institute.

Overview

Concepts

@superbobry
superbobry / example.py
Created December 22, 2014 16:37
Python 2/3 buffer protocol inconsistency
# Python 2
>>> b = bytearray(8)
>>> v = memoryview(b)
>>> v[0] = 42
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'int' does not have the buffer interface
>>> b
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00')
@superbobry
superbobry / timing.py
Created September 23, 2015 14:10
Вспомогательный модуль для курса "Алгоритмы: теория и практика. Методы"
import time
from matplotlib import pyplot as plt
def timed(f, args, *, n_iter=100):
acc = float("inf")
for i in range(n_iter):
t0 = time.perf_counter()
f(*args)
@superbobry
superbobry / rose.ml
Created February 15, 2012 20:08
Basic Rose Trees in OCaml
open StdLabels
type 'a tree = Node of ('a * 'a tree list)
let rec make ~f init =
let (label, forest) = f init in
Node (label, (List.map ~f:(make ~f) forest))
and draw ~f (Node (label, forest)) =
let rec inner = function