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 sys | |
from importlib._bootstrap import _find_and_load | |
from resource import getrusage, RUSAGE_SELF | |
from contextlib import contextmanager | |
IMPORT_ENTRY = _find_and_load.__code__ | |
def get_mem(): |
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
@contextmanager | |
def lock(file_name, block=False): | |
fp = open(file_name, 'w') | |
opts = fcntl.LOCK_EX | |
if not block: | |
opts |= fcntl.LOCK_NB | |
try: | |
fcntl.lockf(fp, opts) |
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
#!/usr/bin/env python | |
import time | |
import sys | |
import socket | |
import ssl | |
import math | |
def percentile(N, percent, key=lambda x:x): |
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
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', |
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
#!/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): |
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 os | |
from btasks import add | |
COUNT = 10000 | |
if os.environ['QUEUE'] == 'rq': | |
from rq import Queue | |
from redis import Redis |
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
#!/usr/bin/env python | |
from __future__ import print_function | |
import os.path | |
import glob | |
import json | |
import argparse | |
import sqlite3 | |
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
#!/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 |
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
# 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 = [] |
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
#!/usr/bin/env python2 | |
import sys | |
COLORS = [ | |
('16', '000000'), | |
('17', '00005f'), | |
('18', '000087'), | |
('19', '0000af'), | |
('20', '0000d7'), | |
('21', '0000ff'), |
NewerOlder