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
warvariuc / del_old_branches.py
Created Dec 24, 2015
Delete merged branches
View del_old_branches.py
#!/usr/bin/env python3
import subprocess
print('Fetching remote branches...')
subprocess.call('git fetch -p --all', shell=True)
print('Processing remote branches...')
remote_branches = subprocess.check_output(
@warvariuc
warvariuc / gist:23b991fced05344c7f3d
Created Nov 13, 2014
requirements.txt github dependency
View gist:23b991fced05344c7f3d
git+git://github.com/warvariuc/pyaiml@v0.8.7
View profile.py
# http://stackoverflow.com/questions/9533179/which-is-the-relationship-between-cpu-time-measured-by-python-profiler-and-real/18012858#18012858
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
View ping.py
#!/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: https://gist.github.com/pklaus/856268
I've rewritten nearly everything for enhanced performance and readability,
and removed unnecessary functions (assynchroneous PingQuery and related).
View python-closures.py
# "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
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
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):
self.name = name # migration name
self.start_time = time.time()
self._count = 0
self.total_count = 0
self.interval = interval # progress printing interval
logger.info('%s: migration started', name)
@warvariuc
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
# https://help.ubuntu.com/community/RaringUpgrades/Kubuntu
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.