Skip to content

Instantly share code, notes, and snippets.

View ikonst's full-sized avatar

Ilya Priven ikonst

  • New York, NY
  • 02:16 (UTC -04:00)
View GitHub Profile
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
ikonst / private.xml
Created March 18, 2016 21:34
Microsoft L5V-00001 Sculpt Ergonomic Desktop Keyboard and Mouse — private.xml for Karabiner
<?xml version="1.0"?>
<root>
<!--
Based on:
https://blog.yorkxin.org/posts/2014/04/12/microsoft-sculpt-mobile-mouse-and-mac/
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
@ikonst
ikonst / NSData+GStreamer.h
Created July 1, 2015 13:12
NSData+GStreamer
@import Foundation;
#include <gst/gst.h>
@interface NSData (GStreamer)
- (GstBuffer *)gstBuffer;
@end
@interface NSMutableData (GStreamer)
class Foo():
message = 'foo'
def bar(self):
print('bar')
from unittest.mock import patch
def baz(self):
print(self.message)
from datetime import datetime
import pytz
import dateutil.tz
from pynamodb.models import Model
from pynamodb.attributes import NumberAttribute, UTCDateTimeAttribute
class MyModel(Model):
class Meta:
table_name = 'my_model'
<?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) {
#!/bin/sh
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.
FPS=10
PALETTE=$(mktemp).png
@ikonst
ikonst / mongoengine_allow_inheritance_be_careful.py
Created December 19, 2017 20:09
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 https://github.com/settings/tokens
TOKEN = '<REDACTED>'
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):
continue
fields = [field for field in get_reference_fields_of_model(model)