Skip to content

Instantly share code, notes, and snippets.


Alan Berezin aberezin

View GitHub Profile
aberezin / argparse.bash
Last active Aug 18, 2020
View argparse.bash
#!/usr/bin/env bash
# Use python's argparse module in shell scripts
# The function `argparse` parses its arguments using
# argparse.ArgumentParser; the parser is defined in the function's
# stdin.
# Executing ``argparse.bash`` (as opposed to sourcing it) prints a
# script template.

Installing python on MacOS The Right Way

To completely avoid the MacOS python, start with brew or macport. If you start with macports, you will not be using that python version for much (ideally). But we need some, somewhat isolated python to start with.

sudo port install python38
sudo port install py38-pip
aberezin /
Last active Jul 16, 2020
certified crazy -- Where all the certs are hidden

Certificates in Python

You can see what path openssl lib uses for certs openssl version -a

Python packages often use the default cafile $ python -c "import ssl; print(ssl.get_default_verify_paths())" But note that there are other places packages could look even just based on the above. SSL_CERT_DIR SSL_CERT_FILE

View git-global-pre-commit
# from
# To prevent debug code from being accidentally committed, simply add a comment near your
# debug code containing the keyword NO_GITCOMMIT (with underscore gone) and this script will abort the commit.
# I also made this available here
if git commit -av --dry-run | grep $(echo NO_GITCOMMIT | tr -d _) >/dev/null 2>&1
aberezin / Dockerfile
Created Mar 24, 2020
Alpine linux with rcinit and ssh
View Dockerfile
FROM alpine:edge
# use the CDN mirror from gilderlabs since its much faster
RUN mkdir -p /etc/apk && echo "" > /etc/apk/repositories &&\
# Install openrc
apk update && apk add openrc &&\
# Tell openrc its running inside a container, till now that has meant LXC
sed -i 's/#rc_sys=""/rc_sys="lxc"/g' /etc/rc.conf &&\
# Tell openrc loopback and net are already there, since docker handles the networking
echo 'rc_provide="loopback net"' >> /etc/rc.conf &&\
aberezin /
Created Jan 1, 2020 — forked from Natim/
Convert an ini configuration file into a json file
# -*- coding: utf-8 -*-
import json
import sys
from ConfigParser import (ConfigParser, MissingSectionHeaderError,
ParsingError, DEFAULTSECT)
class StrictConfigParser(ConfigParser):
def _read(self, fp, fpname):
aberezin /
Created May 24, 2019
One-liner to force dropbox to synch every file
find . -type f -exec sh -c 'cat "$1" > /dev/null; printf "$1"' -- '{}' \;
View psjson
#! /usr/bin/env bash
# Use at own risk. License CC0 see
OPTIND=1 # Reset in case getopts has been used previously in the shell.
while getopts ":hc" opt; do
case "$1" in
-h | --help )
cat <<-EOF
aberezin / iterm
Created Jun 22, 2018 — forked from vyder/iterm
iterm.bash - Launch iTerm from command line
View iterm
#!/usr/bin/env bash
# Open new iTerm window from the command line using v3 syntax for applescript as needed in iTerm2 Version 3+
# This script blocks until the cmd is executed in the new iTerm2 window. It then leaves the window open.
# TODO Add option to close iTerm2 after cmd execs
# See also
# Usage:
View gist:0ee9c5e6354996849d3b0bcb50c6e29c
" Canonical is at"
" This didnt work for me so lets just manually synch with the gist above
" let configpath = '/Users/aberezin/.cvimrc'
" set localconfig
" ccim_server in ~/bin needs to be run mannually for now. Maybe make a
" service
set noautofocus
set autoupdategist