Skip to content

Instantly share code, notes, and snippets.

@paveltyavin
paveltyavin / command.py
Created June 7, 2016 16:37
update bunch of django models using naive implemetation, multiprocessing, multithreading in postgres and sqlite
# coding: utf-8
import threading
import time
import random
import string
from django.db import connection
from multiprocessing import Pool
from django.core.management.base import BaseCommand
@paveltyavin
paveltyavin / benchmark.md
Last active June 7, 2016 20:05
typedict vs schematics benchmark
typeddict_test       1.759s        372 Kb
schematics_test 2.0  3.188s        152 Kb
schematics_test 1.1  3.339s         96 Kb
// go test -run none -bench .
package b
import (
"math/rand"
"sort"
"testing"
)
const M = 8192
from PIL import Image
from PIL import ImageDraw
from math import tanh
import random
Size = 512
im = Image.new("RGB", (Size, Size), "#fff")
draw = ImageDraw.Draw(im)
@paveltyavin
paveltyavin / geohash_list.py
Last active August 16, 2017 13:00
converts polygon to list of geohashes. You can specify precision and tile policy. Different interpretations of geohashes in output.
"""find geohashes inside polygon"""
from __future__ import division
__base32 = '0123456789bcdefghjkmnpqrstuvwxyz'
precision = 8
geohash_corners_inside_polygon_policy = any # or all
def geohash(lon, lat):
result_str = []