Skip to content

Instantly share code, notes, and snippets.

View mrkschan's full-sized avatar
😀

KS Chan mrkschan

😀
View GitHub Profile
@mrkschan
mrkschan / fcgi.py
Last active February 5, 2021 04:27
fastcgi client in python
'''
Modified from https://github.com/wuyunfeng/Python-FastCGI-Client
'''
from urlparse import urlparse as parse_url
import random
import socket
import sys
docker run -e HOME -e AWS_ACCESS_KEY_ID -e AWS_SECRET_ACCESS_KEY -e SSH_AUTH_SOCK -v /tmp:/tmp -v "/run/user/$UID":"/run/user/$UID" -v "$HOME":"$HOME" -w "$(pwd)" --rm -i -t <image> <command>
python3 -c 'import math; yr=3; rate=1.75; print(math.exp(math.log(rate)/yr))'
# The schema is versioned so that we can establish code paths differently in the future if we need to change this.
version: 1
# Templates are a small amount of information supporting a template URL. Each template is selectable at the project-creation step.
info:
# Unique machine name, prefaced by a vendor or organization identifier
id: Bearer/Pizzly
# The human-readable name of the template.
name: Pizzly
# Human-readable descriptive text for the template. Supports limited HTML.
@mrkschan
mrkschan / collision.py
Last active February 2, 2022 12:38 — forked from zadam/collision.py
Calculate birthday paradox (chance of collision) for very large numbers
#!/usr/bin/python3
# This is used for calculating of birthday paradox for large values
# We're using approximation explained here: http://preshing.com/20110504/hash-collision-probabilities/
# Beware that approximation isn't very precise at smaller params N and K, but gets more precise with large numbers
# see https://docs.python.org/3/library/decimal.html#module-decimal
from decimal import *
# setting decimal precision