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 typing | |
from abc import ABCMeta | |
INSTANCE_ATTR = 'instance_attr' | |
class UndefinedType: | |
def __repr__(self): | |
return 'UndefinedType' |
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 typing | |
from collections import OrderedDict | |
from django.db import models | |
from django.db.models.fields import related_descriptors | |
from rest_framework import serializers | |
from rest_framework.fields import SkipField | |
from rest_framework.relations import PKOnlyObject | |
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
// Go Websocket binary proxy noVnc | |
package main | |
import ( | |
"flag" | |
"golang.org/x/net/websocket" | |
"io" | |
"log" | |
"net" | |
"net/http" |
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 time | |
def consumer(): | |
r = '' | |
while True: | |
n = yield r | |
if not n: | |
return |
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 random | |
import bicsect | |
import itertools | |
class WeightedRandomGenerator(object): | |
def __init__(self, weights): | |
self.totals = [] | |
running_total = 0 | |
# py2 |
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 tornado.web import RequestHandler, HTTPError | |
from tornado.escape import json_encode, json_decode | |
class MethodDispatcher(RequestHandler): | |
allow_methods = () | |
def set_default_headers(self): | |
origin = None | |
if self.request.headers.get('Origin'): |