This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from typing import List | |
import typer # pip install typer==0.6.1 | |
import termios | |
import fcntl | |
import os | |
import struct | |
import sys | |
import re |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This script prints the "version" of the repository. | |
# The defenition of version is: | |
# If there is a tag points to the current commit - the prefix will be the tag. If not, it will be the current commit. | |
# If the repository is dirty, it will add "-dirty" as suffix. | |
# Examples: | |
# Tag and not dirty: v1.2.3 | |
# Tag and dirty: v1.2.3-dirty | |
# Not a tag and not dirty: 3cccdf4a163d0b9fea760d5de83ad2ed23dc938d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function md() { | |
if ! command -v pandoc >/dev/null 2>&1 ; then | |
echo "pandoc is requiered, but it's not installed. Aborting."; | |
return; | |
fi | |
if ! command -v lynx >/dev/null 2>&1 ; then | |
echo "lynx is requiered, but it's not installed. Aborting."; | |
return; | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def to_type(o, new_type): | |
''' | |
Helper funciton that receives an object or a dict and convert it to a new given type. | |
:param object|dict o: The object to convert | |
:param Type new_type: The type to convert to. | |
''' | |
if new_type == type(o): | |
return o | |
else: | |
return new_type(**o |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import docker | |
import time | |
import typing | |
class ContainerWrapper: | |
''' | |
A class that wraps a docker image for easier work. Used manily for tests. | |
''' | |
def __init__(self, image, environment, ports, is_continaer_up: typing.Callable[[], bool]): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dependencies = $(foreach dependency, $(1), build-module-$(dependency)) | |
module1_dependencies = | |
module2_dependencies = $(call dependencies, module1) | |
module3_dependencies = $(call dependencies, module2) | |
module4_dependencies = $(call dependencies, module1) | |
all_modules = $(call dependencies, module1 module2 module3 module4) | |
docker1_dependencies = $(call dependencies, module1) | |
docker2_dependencies = $(call dependencies, module2, module4) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Check for currently running queries | |
SELECT * FROM pg_stat_activity WHERE state = 'active'; | |
-- Kill an active query | |
SELECT pg_cancel_backend(12345); | |
-- Kill an active query | |
SELECT pg_terminate_backend(12345); | |
-- Get locking and locked queries |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
class SafeLog: | |
def __init__(self, log: logging.Logger): | |
self.log = log | |
self.safe = False | |
def __enter__(self): | |
self.safe = True | |
return self |