This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from mongoengine import Document, StringField, ListField, EmbeddedDocument, EmbeddedDocumentField | |
# ******** before remodel: ********** | |
class FailedChargeAttempt_Old(EmbeddedDocument): | |
id = StringField() | |
failed_reason = StringField() | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Foo(): | |
message = 'foo' | |
def bar(self): | |
print('bar') | |
from unittest.mock import patch | |
def baz(self): | |
print(self.message) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@import Foundation; | |
#include <gst/gst.h> | |
@interface NSData (GStreamer) | |
- (GstBuffer *)gstBuffer; | |
@end | |
@interface NSMutableData (GStreamer) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |