Skip to content

Instantly share code, notes, and snippets.

View altaurog's full-sized avatar

Aryeh Leib Taurog altaurog

View GitHub Profile
@altaurog
altaurog / vew-bootstrap.sh
Created July 19, 2020 19:09
virtualenvwrapper bootstrap script
#!/bin/bash
mkdir ~/.venv
python3 -m venv ~/.virtualenvs/venv
~/.virtualenvs/venv/bin/pip install virtualenvwrapper
if [ -n "`$SHELL -c 'echo $ZSH_VERSION'`" ]; then
config=~/.zshrc
elif [ -n "`$SHELL -c 'echo $BASH_VERSION'`" ]; then
config=~/.bashrc
@altaurog
altaurog / Dockerfile
Last active June 22, 2020 17:43
starlette on docker x-forwarded-proto
FROM debian:10-slim
RUN apt-get update && \
apt-get install -y --no-install-recommends \
gcc make python3 python3-dev python3-pip
RUN pip3 install setuptools wheel
RUN pip3 install uvicorn starlette
COPY app.py app.py
@altaurog
altaurog / Dockerfile
Last active February 3, 2020 22:51
Error using SQLProvider
FROM mcr.microsoft.com/dotnet/core/sdk:3.1
RUN apt-get update && apt-get install -y netcat
COPY Test.fsproj Program.fs /Test/
WORKDIR /Test
RUN dotnet restore # --verbosity detailed
@altaurog
altaurog / docker_descendants.py
Last active May 29, 2023 04:11
Python3 script to find descendants of one or more docker images
#!/usr/bin/python3
#
# usage: python3 docker_descendants.py <image_id> ...
import sys
from subprocess import check_output
def main(images):
image_ids = set(images)
@altaurog
altaurog / insertmany.py
Last active February 1, 2017 13:27 — forked from dvarrazzo/exmany.py
Test for a different implementation of psycopg executemany
import contextlib
import itertools
import operator
import os
import sys
import time
import psycopg2
import pgcopy
@altaurog
altaurog / ct_pd.py
Last active January 29, 2016 11:29
"""
Performance benchmark: pandas DataFrame.pivot against crosstab
"""
from datetime import datetime, timedelta
import io
import random
import sys
import time
import pandas as pd
@altaurog
altaurog / ip.py
Created August 12, 2015 20:44
Python classes for working with ipv4 addresses
tohex = lambda a:'.'.join('%02X' % p for p in a)
fromhex = lambda h:[int(p,16) for p in h.split('.')]
tobin = lambda a:'.'.join('{0:08b}'.format(p) for p in a)
frombin = lambda h:[int(p,2) for p in h.split('.')]
class IPAddr(object):
def __init__(self, address):
if isinstance(address, (int,long)):
self.long = address
else:
@altaurog
altaurog / partition.py
Created August 12, 2015 20:42
Linux partitioning tools
sec = 512
k = 1024
m = k * k
g = m * k
bs = 4 * m /sec
# Generate a partition table for consumption by sfdisk
# (partition plan is hardcoded below)
partplan = (
@altaurog
altaurog / death_row.py
Last active August 29, 2015 14:27
Demonstrate solution to death row problem
import operator
import random
import sys
# https://en.wikipedia.org/wiki/Prisoners_and_hats_puzzle#Countably_Infinite_Hat_Problem_with_Hearing
def answer(death_row, answers):
return reduce(operator.xor, death_row + answers)
def main(death_row):
@altaurog
altaurog / numbersets.py
Last active August 29, 2015 14:27
Find set S of 7 numbers such that the set of all sums s1, s1 + s2, s1 + s2 + s3 for s1, s2, and s3 in S contains the set of positive integers [1, 70]
import multiprocessing
import sys
def rsetgen(count, floor, ceiling):
"""
Recursively generate all possible sets of
count unique numbers between floor and ceiling
"""
if 1 == count:
for i in xrange(floor, ceiling):