Skip to content

Instantly share code, notes, and snippets.

Anton Bobrov baverman

Block or report user

Report or block baverman

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@baverman
baverman / nya.py
Created Oct 29, 2012
Next episodes downloader from http://www.nyaa.eu/
View nya.py
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
import re
import sys
import os.path
from urllib2 import build_opener
from urllib import urlencode
from lxml import html
@baverman
baverman / tcolor.py
Last active Jan 4, 2016
xterm 256 color palette translation
View tcolor.py
#!/usr/bin/env python2
import sys
COLORS = [
('16', '000000'),
('17', '00005f'),
('18', '000087'),
('19', '0000af'),
('20', '0000d7'),
('21', '0000ff'),
View xml2dict.py
# Simple xml to dict parser
#
# It's usable only for small documents due low performance
# comparing with lxml
from xml.etree import cElementTree as etree
from cStringIO import StringIO
def builder(ptag, attrib, pchild):
child = []
@baverman
baverman / colorpicker
Last active Jan 4, 2016
Simple color picker using gobject introspection
View colorpicker
#!/usr/bin/env python2
import sys
from gi.repository import Gtk, Gdk
if len(sys.argv) > 1:
incolor = sys.argv[1]
use_hash = incolor.startswith('#')
incolor = incolor.strip('#')
else:
use_hash = True
View bench.py
import os
from btasks import add
COUNT = 10000
if os.environ['QUEUE'] == 'rq':
from rq import Queue
from redis import Redis
View throng
#!/usr/bin/env python
import os
import time
import argparse
import signal
from subprocess import Popen
class Pool(object):
def __init__(self, process_count, args):
View JIRA archive old releases
function archiveOldReleases(dt) {
$('tr.project-config-version-released').each((idx, obj) => {
$obj = $(obj);
if (!$obj.hasClass('project-config-version-archived')) {
var rdate = $obj.attr('data-releasedate');
if (rdate && rdate < dt) {
$.ajax({
type: 'PUT',
url: '/rest/api/2/version/' + $obj.attr('data-id'),
contentType: 'application/json',
@baverman
baverman / ssl-perf
Last active Oct 12, 2017
Shows histogram of TLS connect times
View ssl-perf
#!/usr/bin/env python
import time
import sys
import socket
import ssl
import math
def percentile(N, percent, key=lambda x:x):
@baverman
baverman / asyncio_statsd.py
Created Nov 6, 2017
asyncio statsd client
View asyncio_statsd.py
import asyncio
import statsd
class AsyncStatsClient(statsd.StatsClient):
class DummyProto(asyncio.DatagramProtocol):
pass
def __init__(self, host='localhost', port=8125, prefix=None, maxudpsize=512):
self._addr = host, port
You can’t perform that action at this time.