Skip to content

Instantly share code, notes, and snippets.


Ilya Konstantinov ikonst

  • San Francisco, CA
Block or report user

Report or block ikonst

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
class Foo():
message = 'foo'
def bar(self):
from unittest.mock import patch
def baz(self):
from datetime import datetime
import pytz
from pynamodb.models import Model
from pynamodb.attributes import NumberAttribute, UTCDateTimeAttribute
class MyModel(Model):
class Meta:
table_name = 'my_model'
View PhpArrayModernCodec.php
use DateTime;
use DrSlump\Protobuf;
use google\protobuf\Timestamp;
class PhpArrayModernCodec extends \DrSlump\Protobuf\Codec\PhpArray {
protected function encodeMessage(Protobuf\Message $message)
if ($message instanceof Timestamp) {
from contextlib import contextmanager
from functools import wraps
from socket import socket as socket_type, MSG_PEEK
from typing import Set
import flask
import gevent
def _abort_on_eof_watchdog(socket: socket_type, greenlets: Set[gevent.Greenlet]) -> bool:
ikonst /
Last active May 14, 2019
Example of a gevent-based Flask server that aborts when downstream disconnects
Implements a behavior similar to:
- Go srv's cancelation of context on downstream disconnect
- PHP (unless `ignore_user_abort` is true)
import gevent.monkey
from contextlib import contextmanager
from flask import Flask
ikonst /
Created Dec 19, 2017
One doesn't just add "allow_inheritance=True"
from mongoengine import Document, StringField, ListField, EmbeddedDocument, EmbeddedDocumentField
# ******** before remodel: **********
class FailedChargeAttempt_Old(EmbeddedDocument):
id = StringField()
failed_reason = StringField()
from github import Github
from csv import DictWriter
# Generate on
ORG = 'lyft'
AUTHOR = '<github username here>'
g = Github(login_or_token=TOKEN)
org = g.get_organization(ORG)
from mongoengine import Document, EmbeddedDocument, Q, ReferenceField
from pymongo.read_preferences import ReadPreference
all_models = Document.__subclasses__()
def referencing_models(document):
for model in all_models:
if issubclass(model, EmbeddedDocument):
fields = [field for field in get_reference_fields_of_model(model)
set -e
# Converts a Quicktime movie to a GIF aniamtion.
# Useful for screen recordings.
# Preliminary step with palette required to make it look good
# without dithering artifacts.
ikonst / private.xml
Created Mar 18, 2016
Microsoft L5V-00001 Sculpt Ergonomic Desktop Keyboard and Mouse — private.xml for Karabiner
View private.xml
<?xml version="1.0"?>
Based on:
Button 4 is the side button (located by the blue Windows button).
This allows you to map the Windows button as Button 5.
1. brew cask install karabiner
You can’t perform that action at this time.