Skip to content

Instantly share code, notes, and snippets.

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mhlr
mhlr / proto-demo.py
Last active December 26, 2020 06:30
Enabling delegation / prototypal inheritance / instance based programming in Python
from proto import Proto, ProtoMeta
__metaclass__ = ProtoMeta
class A:
x = "This is X"
def getY(self):
return self._y
class B:
_y = "This is Y"
from pylab import *
import scipy
from scipy import stats
from numba import vectorize, guvectorize, float64, jit, njit
@guvectorize(['void(float64[:], float64[:], float64[:])'],
'(i),(i)->()',
nopython=True
)
@mhlr
mhlr / zipf.R
Last active January 10, 2017 05:49
generate Zipf distributed data as described in http://arxiv.org/abs/1407.7135
# gnerate Zipf distributed data as described in
# http://arxiv.org/abs/1407.7135
# Zipf's law arises naturally in structured, high-dimensional data
# Laurence Aitchison, Nicola Corradi, Peter E. Latham
n <- 2**22
k <- 20
b <- rnorm(k, 1, 0.2)
data <- replicate(n, {z <- runif(1)
p <- (z^b) / (z^b + (1-z)^b)
@mhlr
mhlr / init.el
Created February 14, 2016 08:16 — forked from lispnik/init.el
~/.emacs.d/init.el
(if window-system
(tool-bar-mode -1)
(menu-bar-mode -1))
(when (eq window-system 'ns)
(add-to-list 'default-frame-alist '(height . 80))
(add-to-list 'default-frame-alist '(width . 132)))
(require 'package)
(setq package-enable-at-startup nil)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))