Skip to content

Instantly share code, notes, and snippets.

View dialtone's full-sized avatar

Valentino Volonghi dialtone

View GitHub Profile
[package]
name = "day7"
version = "0.1.0"
authors = ["Matthew Tran <0e4ef622@gmail.com>"]
edition = "2018"
[dev-dependencies]
criterion = "*"
[[bench]]
@fbrnc
fbrnc / is_leader.sh
Last active March 13, 2017 19:14
"Good enough" leader election script for AWS AutoScalingGroups
#!/usr/bin/env bash
function echoerr { echo "$@" 1>&2; }
function error_exit { echoerr "$1"; exit 1; }
if [ -z "${REGION}" ] ; then error_exit "No REGION set"; fi
command -v jq >/dev/null 2>&1 || error_exit "'jq' not found"
command -v aws >/dev/null 2>&1 || error_exit "'aws' not found"
command -v tee >/dev/null 2>&1 || error_exit "'tee' not found"
command -v ec2metadata >/dev/null 2>&1 || error_exit "'ec2metadata' not found"
@plentz
plentz / nginx.conf
Last active July 22, 2024 11:19
Best nginx configuration for improved security(and performance)
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@dcramer
dcramer / heapqueue.py
Last active December 11, 2015 04:09
Refined Heap Queue for Python (including capped and max heap implementation)
import heapq
from threading import Lock
class HeapQueue(object):
def __init__(self, values=None, maxsize=None, reversed=False):
"""
Create a new heap queue.
- ``maxsize`` will create a capped queue.
-module(erlhmac).
-export([hmac/4]).
hmac(Key, Message, Hash, BlockSize) when byte_size(Key) > BlockSize ->
hmac(Hash(Key), Message, Hash, BlockSize);
hmac(Key, Message, Hash, BlockSize) when byte_size(Key) < BlockSize ->
hmac(<<Key/binary,
(binary:copy(<<0>>, BlockSize - byte_size(Key)))/binary>>,
Message, Hash, BlockSize);