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 / 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
@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
#!/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).
@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(
# Make test method names str more friendly for feeding them to ./manage.py test
unittest.case.TestCase.__str__ = lambda self: \
f'{self.__class__.__module__}.{self.__class__.__qualname__}.{self._testMethodName}'
import time
import math
import pygame
WIDTH = 320 # width of screen
HEIGHT = 240 # height of screen
FPS = 30 # frames per second setting
@warvariuc
warvariuc / gist:470f71d121134d1d36d7ca0ac116f244
Last active March 15, 2022 08:33
Check environment variables passed to a docker container in cloud
root@4f2af8100e1f:# strings /proc/1/environ
PATH=/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
HOSTNAME=4f2af8100e1f
COMPUTERNAME=10-30-0-24
PLATFORM_VERSION=97.0.7.610
APPSVC_RUN_ZIP=FALSE
WEBSITE_SKU=LinuxFree
...
-------------------------------------------------------------------------------
import functools
import logging.config
import mongoengine
import pydantic as p
logging.basicConfig()
@warvariuc
warvariuc / crown_molding_king.py
Created March 19, 2022 06:20
This script will calculate the chop saw miter and bevel settings for any angle crown molding.
"""
This application will calculate the chop saw miter and bevel settings for any angle crown molding.
https://play.google.com/store/apps/details?id=com.crownking
"""
import math
wall_angle = 90 # Wall angle
sping_angle = 38 # Miter spring angle
sa2 = math.radians(sping_angle)