Skip to content

Instantly share code, notes, and snippets.

View warvariuc's full-sized avatar

Victor Varvaryuk warvariuc

  • Moldova, Chisinau
View GitHub Profile
@warvariuc
warvariuc / prepare-commit-msg
Last active January 25, 2016 16:38
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).
#!/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()
# "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 / del_old_branches.py
Created December 24, 2015 08:38
Delete merged branches
#!/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:5459407
Created April 25, 2013 12:41
Threads SIGINT
#!/usr/bin/env python
import threading
def handleSigint(*args):
print 'Received SIGINT. Notifying worker threads to stop.', args
global shutdown
shutdown = True
shutdown = False