Skip to content

Instantly share code, notes, and snippets.

Victor Varvaryuk warvariuc

Block or report user

Report or block warvariuc

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
warvariuc /
Created Dec 24, 2015
Delete merged branches
#!/usr/bin/env python3
import subprocess
print('Fetching remote branches...')'git fetch -p --all', shell=True)
print('Processing remote branches...')
remote_branches = subprocess.check_output(
warvariuc / gist:23b991fced05344c7f3d
Created Nov 13, 2014
requirements.txt github dependency
View gist:23b991fced05344c7f3d
import cProfile
import pstats
import time
skus = ["FI003BWCOB89", "FR948EMCCC73", "MC002EMBUM82", "ME001EMAUL93", "MO151AWBW352", "MO714AMCBJ80", "MO714AMCBJ84", "CA011AMBBB11", "ME001EMAUL96", "MA002EWCOF12", "LA004EWCIX95", "BA007EWCBE17", "MC001EMAUI28", "MC001EMCJO63", "NI464EWCAD19", "AS455AMBWK25", "BA007EWCBE19", "BA007EWCBE21", "ME146EWBWZ65", "ME486EWGP987", "MO151AWCMP81", "NE008AMCPB12", "NE008AMCPB13", "VI003EWID917", "AS455AMCCI00", "MI033EWBOT99", "NI464EMAOW02", "NI464EMCC737", "NI464EWCIJ72", "AB003BWAQM71", "GU643EWBWI74", "NA020EGCLS87", "IC461CMCFV24", "NI464AMBXC34", "AN010EWBHT51", "NI464AMBXC35", "NE009EWBNP05", "NE007AUATU52", "NI464EWADA27", "NE007AUATU53", "NE007AUATU54", "FO001EWBQL57", "NI464AMBXB75", "NI464AMBXD84", "NI464AWAHG80", "NI464AWBNM78", "NI464EWCIL38", "NI464EWCIL44", "NI464EWCIL55", "NI464EMACJ97", "NI464EMBLN99", "NI464EMII77
#!/usr/bin/env python3
A pure Python "ping" implementation, based on a rewrite by Johannes Meyer,
of a script originally by Matthew Dixon Cowles. Which in turn was derived
from "ping.c", distributed in Linux's netkit. The version this was forked
out of can be found here:
I've rewritten nearly everything for enhanced performance and readability,
and removed unnecessary functions (assynchroneous PingQuery and related).
# "Understanding Python's closures".
# Tested in Python 3.1.2
# General points:
# 1. Closured lexical environments are stored
# in the property __closure__ of a function
# 2. If a function does not use free variables
warvariuc / gist:6319180
Last active Dec 21, 2015
Export some PosgreSql table columns and import them into another databse
View gist:6319180
sudo -u postgres psql leos -c "COPY product (sku, attributes) TO STDOUT" > attributes
sudo -u postgres psql leos -c "COPY (SELECT sku, heel_height FROM product WHERE heel_height > 0) TO STDOUT" > heel_height
Then in another db do something like:
CREATE TABLE product_(...);
COPY product_ (sku, attrributes) FROM ~/attributes;
UPDATE product
SET attributes = product_.attributes
warvariuc / gist:6230795
Last active Dec 21, 2015
Migration process
View gist:6230795
class MigrationProgress(object):
"""Context manager to track migration progress.
def __init__(self, name, interval=100): = name # migration name
self.start_time = time.time()
self._count = 0
self.total_count = 0
self.interval = interval # progress printing interval'%s: migration started', name)
warvariuc / prepare-commit-msg
Last active Jan 25, 2016
A hook for git that inserts at the beginning of the commit message name of the current branch, if the message is empty (contains empty or comment lines).
View prepare-commit-msg
#!/usr/bin/env python3
import sys
import subprocess
with open(sys.argv[1], 'r+') as commit_message_file:
commit_message = list(commit_message_file)
for line in commit_message:
line = line.strip()
View gist:5493655
# How to upgrade Kubuntu to the next release
do-release-upgrade -d
View gist:5459407
#!/usr/bin/env python
import threading
def handleSigint(*args):
print 'Received SIGINT. Notifying worker threads to stop.', args
global shutdown
shutdown = True
shutdown = False
You can’t perform that action at this time.