Skip to content

Instantly share code, notes, and snippets.

View oshinko's full-sized avatar

Oshinko oshinko

View GitHub Profile
@oshinko
oshinko / hmac_web_token_example.py
Last active January 30, 2018 02:43
HMAC Web Token Example
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:
# -*- coding: utf-8 -*-
import multiprocessing
import subprocess
import sys
import time
class Job:
done = False
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())
@oshinko
oshinko / verify_moritomodoc.py
Created March 19, 2018 04:53
森友文書の改ざんを検証します。
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())
@oshinko
oshinko / install-git.sh
Created June 15, 2018 10:34
Installing Git
cd git
make configure
./configure --prefix=/usr/local/git
sudo make install
x = range(5)
assert list(zip(x[::2], x[1::2])), [(0, 1), (2, 3)]
#!/bin/sh
PWD=`pwd`
PROJECT=`basename $PWD`
if [ ! -f $HOME/.venv/$PROJECT ]; then
mkdir -p $HOME/.venv
python3 -m venv $HOME/.venv/$PROJECT
fi
@oshinko
oshinko / loop.sh
Created May 23, 2019 07:28
Syntax for a single-line Bash infinite while loop
while true; do foo; sleep 2; done
@oshinko
oshinko / install-pgsql-11-from-source-code-on-amazon-linux-2.sh
Last active January 19, 2024 16:26
Install PostgreSQL 11 from Source Code on Amazon Linux 2
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
@oshinko
oshinko / install-nginx-on-amazon-linux-2.sh
Created August 27, 2019 01:47
Install Nginx on Amazon Linux 2
# 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