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 hmac | |
from datetime import datetime, timedelta | |
from hashlib import sha256 | |
class Session: | |
secret = b'Please enter your desired passphrase' | |
def __init__(self, *, user=None, token=None): | |
if user: |
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
# -*- coding: utf-8 -*- | |
import multiprocessing | |
import subprocess | |
import sys | |
import time | |
class Job: | |
done = False |
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 md5 | |
import os | |
import sys | |
import zipfile | |
def zipfiles(path): | |
with zipfile.ZipFile(path, 'r') as f: | |
return tuple((x.file_size, x.filename) for x in f.infolist()) |
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 binascii | |
import ecdsa | |
import os | |
curve = ecdsa.SECP256k1 | |
def get_public_key_from_private_key(private_key): | |
point = int.from_bytes(my_private_key, 'big') * curve.generator | |
h = '04{0:064x}{1:064x}'.format(point.x(), point.y()) |
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
cd git | |
make configure | |
./configure --prefix=/usr/local/git | |
sudo make install |
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
x = range(5) | |
assert list(zip(x[::2], x[1::2])), [(0, 1), (2, 3)] |
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/sh | |
PWD=`pwd` | |
PROJECT=`basename $PWD` | |
if [ ! -f $HOME/.venv/$PROJECT ]; then | |
mkdir -p $HOME/.venv | |
python3 -m venv $HOME/.venv/$PROJECT | |
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
while true; do foo; sleep 2; done |
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
sudo yum groupinstall "Development Tools" -y | |
sudo yum install readline readline-devel systemd-devel -y | |
wget -O - https://ftp.postgresql.org/pub/source/v11.4/postgresql-11.4.tar.bz2 | tar jxf - | |
cd postgresql-11.4 | |
# ref: https://www.postgresql.org/docs/11/install-short.html | |
./configure --with-systemd | |
make | |
sudo make install | |
sudo adduser postgres |
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
# Nginx | |
sudo amazon-linux-extras install nginx1.12 -y | |
sudo bash -c "cat << 'EOF' > /etc/nginx/nginx.conf | |
# ref: https://github.com/benoitc/gunicorn/blob/master/examples/nginx.conf | |
worker_processes 1; | |
user nginx nginx; | |
error_log /var/log/nginx/error.log warn; | |
pid /var/run/nginx.pid; | |
events { | |
worker_connections 1024; # increase if you have lots of clients |