Skip to content

Instantly share code, notes, and snippets.

View butla's full-sized avatar

Michal Bultrowicz butla

View GitHub Profile
@butla
butla / wait_for_tcp_port.py
Last active December 8, 2022 19:52
Waiting for a TCP port to start accepting connections (Python >=3.6)
"""
MIT License
Copyright (c) 2017 Michał Bultrowicz
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@butla
butla / cf_app_conf.py
Created March 4, 2016 00:17
Notes of how general configuration for Cloud Foundry or other 12-factor apps can be done.
#!/usr/bin/python3
# This is how a configuration setup can look like. The key will form a herarchical key in Config object.
# The values will be taken from environment variables. They should be case insensitive (only the leaf values should be case sensitive). All lists will be flattened.
# If the value is not found then the default value can be found after the semicolon.
import cf_config
config_fields = {
'foo': {
@butla
butla / url_downloader_service.py
Created March 4, 2016 00:13
Falcon service that downloads URL asynchonously.
import concurrent.futures
import falcon
import time
import urllib.request
import json
from urllib.parse import urlsplit
class DownloaderResource:
@butla
butla / check_new_pylint_issues.sh
Created February 3, 2016 18:30
Detect new Pylint issues introduced by your Git changes
#!/bin/bash
# this script must run after Pylint run
REMOTE_MASTER=origin/master
# If there's no difference between the current state and origin/master
# then there's no need to check for new Pylint issues.
if [[ -z $(git diff $REMOTE_MASTER) ]]; then
exit
fi
# to install: pip install networkx
__author__ = 'butla'
import sys
import asyncio
import aiohttp
import networkx
import networkx.algorithms