Skip to content

Instantly share code, notes, and snippets.

View arogozhnikov's full-sized avatar

Alex Rogozhnikov arogozhnikov

View GitHub Profile
@arogozhnikov
arogozhnikov / edgedb_feedback.markdown
Last active August 23, 2023 19:08
Edgedb feedback, comparison of edgedb vs sqlmodel/sqlalchemy

Notes on edgedb

I’ve made a test evaluation of edgedb for the purposes of a small company.

My order of priorities (starting from most important):

  1. correctness of results (data and code)
  2. developer convenience
  3. minimal maintenance
  4. efficiency/scalability
@arogozhnikov
arogozhnikov / IsotonicRegression.py
Created September 8, 2015 20:12
Shortest isotonic transform function in the world. Generates increasing formula.
def isotonic_transform(x, y, alpha=0.001):
target = y + 0.
output = numpy.zeros(len(x))
steps = 2 ** numpy.arange(int(numpy.log2(len(x)) - 1))[::-1]
print steps
for i in range(100):
for step in steps:
penalty = 2 * (target - output)
diffs = - (output[step:] - output[:-step])
diffs = diffs.clip(0)
@arogozhnikov
arogozhnikov / grbm.py
Created August 3, 2015 01:49
Very minimal Gaussian Bernoulli RBM using batch learning
import numpy
from scipy.special import expit
class GRBM(object):
def __init__(self, n_vis, n_hid, std=0.1):
self.std = std
self.W = numpy.random.normal(loc=-1./n_hid, scale=0.1, size=[n_vis + 1, n_hid + 1])
def hidden_p(self, data):
result = expit(data.dot(self.W))
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.
@arogozhnikov
arogozhnikov / fortran_compiler.py
Created November 17, 2015 15:56
FORTRAN 90 compiling from python with numpy.f2py
def compile_fortran(source, modulename, extra_args=''):
import tempfile
import sys
import numpy.f2py
from numpy.distutils.exec_command import exec_command
try:
f = tempfile.NamedTemporaryFile(suffix='.f90')
f.write(source)
f.flush()
@arogozhnikov
arogozhnikov / docker-run-user.sh
Created January 28, 2018 17:56 — forked from marten-cz/docker-run-user.sh
Run docker with current user
# Run command with the same user ID as current user
# -v $(pwd):/tmp/mount - mount current directory to /tmp/mount/
# --env HOME="/tmp/" - some commands may need to be able to write to your home, se it to temporary folder
docker run -ti --rm -v $(pwd):/tmp/mount —user=$(id -u) --env HOME="/tmp/" debian:jessie
# Mount current users and group and be able to use them
# mount /etc/group and /etc/passwd read only
# set user from $USER
docker run -ti --rm -v $(pwd):/tmp/mount -w /tmp/hx -v /etc/group:/etc/group:ro -v /etc/passwd:/etc/passwd:ro —user=$USER debian:jessie
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
----> call function __getitem__
------> call function __contains__
<------ exit function __contains__
------> call function _getitem_column
--------> call function _get_item_cache
----------> call function get
------------> call function _get_items
<------------ exit function _get_items
------------> call function isnull
--------------> call function _isnull_new
@arogozhnikov
arogozhnikov / gist:f85abc941754ce12988d3566f8044e11
Last active February 14, 2017 13:35
Check reproducibility of an ipython notebook
# to be executed from different notebook!
def check_notebook_reproducibility(filename):
md5s = []
for attempt in [1, 2]:
!jupyter nbconvert --to notebook --inplace --execute $filename --ExecutePreprocessor.timeout=86400
result = !md5sum $filename
md5s.append(result)
print result
a, b = md5s
assert a == b, 'hashes are different'