This file contains hidden or 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
// Moved to https://github.com/temoto/meetup |
This file contains hidden or 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
#!/usr/bin/env python | |
from __future__ import print_function | |
import argparse | |
import collections | |
import re | |
import subprocess | |
import sys | |
KNOWN_IMPORT_PACKAGE_MAP = { |
This file contains hidden or 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/bash | |
set -e | |
onto=origin/master | |
git fetch --prune | |
git branch --remotes --list 'origin/*' |grep -vE 'HEAD|master|gh-pages' |cut -d/ -f2 |while read -r b; do | |
printf "\nRebasing $b\n\n" | |
git checkout -B $b origin/$b | |
git rebase $onto && continue |
This file contains hidden or 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
#!/usr/bin/env python3 | |
'''Fix PEP-8 E128. | |
function(argument1, argument2, | |
argument3, argument4) | |
-> | |
function( | |
argument1, argument2, |
This file contains hidden or 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
try: | |
# DB profiling. | |
# TODO: extract this to separate module. | |
TERMINAL_WIDTH = 124 # fine for 15" in 12px mono font. | |
SHOW_TOP_N_QUERIES = 5 | |
import itertools | |
import textwrap | |
queries = django.db.connection.queries | |
if queries: |
This file contains hidden or 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 django.db.models.sql import Query | |
from functools import wraps | |
import inspect | |
TRACE_THIS_QUERY = u'SELECT "blog_group"."id", "blog_group"."name", "blog_group"."arg" FROM "blog_group" INNER JOIN "blog_group_members" ON ("blog_group"."id" = "blog_group_members"."group_id") WHERE "blog_group_members"."user_id" = %s ' | |
def trace_get_compiler(fun): | |
@wraps(fun) |
This file contains hidden or 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
#!/usr/bin/env python3 | |
''' | |
каждый день{tab}13:45{tab}игнорируется{tab}http://ping.url/ | |
-> | |
45 13 * * *{tab}/usr/bin/curl -fsS 'http://ping.url/' | |
''' | |
import re | |
import sys |
This file contains hidden or 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
def shinglize(s): | |
return frozenset(s[i:i + 3] for i in xrange(len(s) - 2)) | |
def shingle_compare(sh1, string): | |
'''set(shingle), 'string' -> float 0..1 | |
''' | |
sh2 = shinglize(string) | |
if not sh1 or not sh2: | |
return 0 |
This file contains hidden or 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
# I will eat you family and your dog if you use FROM ubuntu for container that runs a service in production | |
# Reading: http://phusion.github.io/baseimage-docker/ | |
FROM phusion/baseimage:0.9.15 | |
# inspired by https://github.com/progrium/buildstep | |
RUN mkdir /build | |
ADD ./files-build/ /build/ | |
RUN chmod --recursive go-rwx /build | |
RUN LC_ALL=C DEBIAN_FRONTEND=noninteractive /bin/bash /build/prepare | |
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* |
This file contains hidden or 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 multiprocessing as mp | |
import sys | |
import resource | |
def memory(): | |
self = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss | |
children = resource.getrusage(resource.RUSAGE_CHILDREN).ru_maxrss | |
return self + children |