Skip to content

Instantly share code, notes, and snippets.

@rcastill
rcastill / set_interval.py
Created September 19, 2017 02:53
setInterval for Python
from threading import Timer
class Interval:
def __init__(self, func, secs):
# Fuction to be called back
self.func = func
# Interval
self.secs = secs
# Timer thread object
@rcastill
rcastill / setup_logger.py
Created July 29, 2019 14:43
Logger setup
# call once per file then retrieve with logging.getLogger(__file__)
import logging
def setup_logger(level):
log = logging.getLogger(__file__)
handler = logging.StreamHandler()
formatter = logging.Formatter(f'%(asctime)-15s {__file__} %(message)s')
handler.setFormatter(formatter)
log.addHandler(handler)
@rcastill
rcastill / lock2req.py
Created November 26, 2019 16:11
Convert Pipfile.lock into requirements.txt
#!/usr/bin/env python
"""
Convert Pipfile.lock into requirements.txt
It generates an output similar to `pipenv lock -r`
without the need to actually locking the file.
See https://github.com/pypa/pipenv/issues/3493
This script was created to include the definition of sources
@rcastill
rcastill / bumpversion.sh
Created December 14, 2021 14:36
Bump version helper script
#!/bin/bash
# Thanks goes to @pete-otaqui for the initial gist:
# https://gist.github.com/pete-otaqui/4188238
#
# Original version modified by Marek Suscak
#
# works with a file called VERSION in the current directory,
# the contents of which should be a semantic version number
# such as "1.2.3" or even "1.2.3-beta+001.ab"