Skip to content

Instantly share code, notes, and snippets.

I love cats

Aleksei Zhukov drdaeman

I love cats
View GitHub Profile
View kubernetes.nix
{ config, pkgs, ... }:
# Kubernetes configuration
# Insecure, for local development only, totally unsuitable for production
services.kubernetes = {
roles = ["master" "node"];
# Without explicitly defined keys things will break after reboot,
# as by default keys will be generated in /var/run/kubernetes.
drdaeman / Dockerfile
Created Jan 9, 2018
Dockerfile to build oklog/oklog
View Dockerfile
FROM node:9 AS build-ui
RUN npm install -g elm --unsafe-perm=true --allow-root
COPY ./ui /app/ui
RUN cd /app/ui \
&& ([ ! -e elm-stuff ] || rm -rf elm-stuff) \
&& elm-make --yes src/Main.elm --output=scripts/oklog.js
# ============================================================================
drdaeman /
Created May 10, 2017
Helpers for django-elasticsearch-dsl
import collections
import itertools
def get_result_models_lazy(results):
Given a ``Response`` instance or any iterable with documents,
provides an iterable (a generator, to be exact) with matching
database model instances.
drdaeman /
Last active Feb 21, 2018
Running Docker containers on Windows, natively, using rkt (WSL aka Bash on Windows)

Just a heads up for those who are looking into running Docker containers natively on WSL. While it's not usable for anything serious (even your toy project development), there is a way.


  • We'll be using rkt and not Docker. So, no docker-compose for you.
  • There will be some source code patching. Nothing serious, just a few lines.
  • Very limited isolation and networking capabilities. Think of always --privileged, --net-host and no DNS.

WSL doesn't have cgroups at the moment, and probably won't have them anytime soon, so no way Docker would work.

drdaeman / rcompare.js
Last active Jan 8, 2017
RethinkDB-resembling type-aware value comparison (experiment)
View rcompare.js
const _ = require("lodash");
function inferTypeOf(value) {
// Given a value from RethinkDB, tries to infer its ReQL type.
// Returns a string value, similar to r.typeOf result, or an empty
// string if the type is not recognized or unsupported.
switch (typeof value) {
case "string":
return "STRING";
case "number":
drdaeman /
Last active May 12, 2016
Experiment with django-money to have multiple money fields that share the single currency. May contain bugs, use with extreme caution.
from __future__ import absolute_import, unicode_literals
from djmoney.models.fields import MoneyField, MoneyFieldProxy
class CurrencyLockedMoneyFieldProxy(MoneyFieldProxy):
def __init__(self, field, currency_field_name=None):
super(CurrencyLockedMoneyFieldProxy, self).__init__(field)
if currency_field_name is not None:
self.currency_field_name = currency_field_name

Keybase proof

I hereby claim:

  • I am drdaeman on github.
  • I am drdaeman ( on keybase.
  • I have a public key whose fingerprint is FE74 8B15 6F78 F2B3 360E 9C85 E1C3 A285 7EFC 7C66

To claim this, I am signing this object:

A drop-in replacement to make PyBrowserID[1]
use instead of M2Crypto.
Replace browserid/crypto/ with this file,
or monkey-patch browserid.crypto.{Key,RSKey,DSKey},
or whatever. The choice of dirtiness is up to you.
Use with caution. I'm no cryptographer.
drdaeman / ppp_generic.patch
Last active Aug 29, 2015
An somewhat ugly hack to make packets to certain IPv4 addresses not increment interface counters. Original patch's not mine.
View ppp_generic.patch
--- drivers/net/ppp/ppp_generic.c 2014-01-20 06:40:07.000000000 +0400
+++ drivers/net/ppp/ppp_generic.c 2014-06-09 14:48:48.000000000 +0400
@@ -54,6 +54,13 @@
#include <net/net_namespace.h>
#include <net/netns/generic.h>
+#include <linux/proc_fs.h>
drdaeman /
Last active Mar 10, 2016
Quick-and-dirty fix for forms using ModelChoiceField with to_field_name set.
# Quick-and-dirty fix for forms using ModelChoiceField with to_field_name set.
# See for details.
# Example usage:
# >>> import form_fixes
# >>> form_fixes.fix_to_field_name()
from django import forms
from django.db import models