Skip to content

Instantly share code, notes, and snippets.

View drdaeman's full-sized avatar
😺
I love cats

Aleksei Zhukov drdaeman

😺
I love cats
View GitHub Profile
"""
A drop-in replacement to make PyBrowserID[1]
use cryptography.io instead of M2Crypto.
Replace browserid/crypto/fallback.py 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.

Keybase proof

I hereby claim:

  • I am drdaeman on github.
  • I am drdaeman (https://keybase.io/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:

@drdaeman
drdaeman / fields.py
Last active May 12, 2016 20:34
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
@drdaeman
drdaeman / rcompare.js
Last active January 8, 2017 22:50
RethinkDB-resembling type-aware value comparison (experiment)
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
drdaeman / rkt-fly-on-wsl.md
Last active January 19, 2022 10:28
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.

Nuances:

  • 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
drdaeman / utils.py
Created May 10, 2017 15:40
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
drdaeman / Dockerfile
Created January 9, 2018 16:06
Dockerfile to build oklog/oklog
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
# ============================================================================
{ 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.