Skip to content

Instantly share code, notes, and snippets.

View tumregels's full-sized avatar
🎯
Focusing

Lev tumregels

🎯
Focusing
View GitHub Profile
If you find yourself regularly logging into the server then it will be useful to load your ssh key automatically.
Add the following snippet to the bottom of ~/.bash_profile to add it to your shell environment permanently:
ssh-add ~/.ssh/your_ssh_key > /dev/null 2>&1
@tumregels
tumregels / wait.sh
Last active July 2, 2021 18:58
wait for status code or fail
# from https://gist.github.com/rgl/f90ff293d56dbb0a1e0f7e7e89a81f42
timeout 300 bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:9000)" != "200" ]]; do sleep 5; done' || false
@tumregels
tumregels / Makefile
Created June 24, 2021 13:28
example of a well documented Makefile
# Makefile for Sphinx documentation
# https://github.com/graphql-python/graphene/blob/master/docs/Makefile
# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
PAPER =
BUILDDIR = _build
# Internal variables.
@tumregels
tumregels / table.py
Created August 28, 2020 22:00
create table images with matplotlib
import matplotlib.pyplot as plt
import numpy as np
data = [
['Freeze', 'Wind', 'Flood', 'Quake', 'Hail'],
['5 year', 66386, 174296, 75131, 577908, 32015],
['10 year', 58230, 381139, 78045, 99308, 160454],
['20 year', 89135, 80552, 152558, 497981, 603535],
['30 year', 78415, 81858, 150656, 193263, 69638],
['40 year', 139361, 331509, 343164, 781380, 52269],
@tumregels
tumregels / s3_files_to_memory.py
Last active April 19, 2020 21:19
download s3 files into in-memory binary stream
import io
import os
import zipfile
import boto3
def download_s3_dir_into_binary_stream(bucket_name, remote_dir_name):
s3_resource = boto3.resource('s3')
bucket = s3_resource.Bucket(bucket_name)

view port

$ ps aux | grep 6805

cleanup system

$ docker system prune

export journalctl

@tumregels
tumregels / venv_wrapper
Created December 25, 2019 22:37 — forked from dbtek/venv_wrapper
Python 3 venv wrapper. Manages all virtual environments under ~/.venv/ .
# include following in .bashrc / .bash_profile / .zshrc
# usage
# $ mkvenv myvirtualenv # creates venv under ~/.venv/
# $ venv myvirtualenv # activates venv
# $ deactivate # deactivates venv
# $ rmvenv myvirtualenv # removes venv
export VENV_HOME="$HOME/.venv"
[[ -d $VENV_HOME ]] || mkdir $VENV_HOME

install sshuttle

sudo apt-get update -y
sudo apt-get install -y sshuttle

open ~/.bashrc and add these lines at the end

@tumregels
tumregels / ansible_local_playbooks.md
Created September 9, 2019 22:19 — forked from alces/ansible_local_playbooks.md
How to run an Ansible playbook locally
  • using Ansible command line:
ansible-playbook --connection=local 127.0.0.1 playbook.yml
  • using inventory:
127.0.0.1 ansible_connection=local
@tumregels
tumregels / socks-create.sh
Created September 9, 2019 13:15 — forked from AfroThundr3007730/socks-create.sh
Create an on-demand SSH-based SOCKS5 proxy via systemd socket activation
#!/bin/bash
# These steps will allow the setup of an on-demand SSH proxy
# Three unit files will be created to serve this purpose:
# ssh-socks-helper.socket - The listening socket providing activation
# ssh-socks-helper.service - A systemd proxy to pass the socket fd
# ssh-socks.service - The actual SSH service providing the tunnel
cat <<'EOF' > ~/.config/systemd/user/ssh-socks-helper.socket
[Unit]
Description=Proxy Helper Socket for Bastion SOCKS5 Proxy