Skip to content

Instantly share code, notes, and snippets.

View mmalone's full-sized avatar

Michael Malone mmalone

View GitHub Profile
ARG FUNCTION_RUNTIME
FROM mikesir87/aws-cli as code
ARG FUNCTION_NAME
ARG AWS_DEFAULT_REGION
ARG AWS_ACCESS_KEY_ID
ARG AWS_SECRET_ACCESS_KEY
RUN wget -O function.zip `aws lambda get-function --function-name $FUNCTION_NAME --query 'Code.Location' --output text`
@mmalone
mmalone / example.sh
Created February 12, 2019 22:14
Using `step certificate` without the online step CA
# Create a root certificate and signing key.
$ step certificate create "Root CA" root.crt root.key --profile root-ca
Please enter the password to encrypt the private key:
Your certificate has been saved in root.crt.
Your private key has been saved in root.key.
# Create an intermediate certificate & signing key. This isn't
# required; we could use the root to sign directly which is
# probably fine for local dev and removes the need to bundle later.
$ step certificate create "Intermediate CA" int.crt int.key --profile intermediate-ca --ca root.crt --ca-key root.key
@mmalone
mmalone / README.md
Created November 5, 2015 04:10 — forked from mbostock/.block
Line Chart
@mmalone
mmalone / diskstats.py
Created July 14, 2011 00:10
python diskstats parser
def diskstats():
file_path = '/proc/diskstats'
# http://lxr.osuosl.org/source/Documentation/iostats.txt
columns_disk = ['major_dev_num', 'minor_dev_num', 'device', 'reads', 'reads_merged', 'sectors_read', 'ms_reading', 'writes', 'writes_merged', 'sectors_written', 'ms_writing', 'current_ios', 'ms_doing_io', 'weighted_ms_doing_io']
columns_partition = ['major_dev_num', 'minor_dev_num', 'device', 'reads', 'sectors_read', 'writes', 'sectors_written']
result = {}
for line in (l for l in open(file_path, 'r').xreadlines() if l != ''):
parts = line.split()
>>> x = 'abcdefghijklmnopqrstuvwyz1234567890'
>>> for i in xrange(len(x) + 1):
... y = (x[:i] + 'x' * len(x))[:len(x)]
... print timeit.Timer('x == y', 'from __main__ import x, y').timeit()
...
0.0604889392853
0.0732460021973
0.069344997406
0.0671350955963
0.0664479732513
# Requires apachelog from http://code.google.com/p/apachelog/source/browse/trunk/apachelog.py
import sys, time, re
from collections import defaultdict
from threading import Timer
import apachelog
class Parser(apachelog.parser):
import math
import random
class Statistic(object):
"""
Hookin' it up with the seven descriptive statistics.
"""
def __init__(self, sample):
1568020383607837124674242424233936224366074619938054295149435080651133347159866539515828916334423825699216287430613550119009746682495526220087196369932993220993947068398348139078036223234189886410582032934294689156382470618963836853600005504402303219553800308328245464091978334255365120288597797327665191066332303969094527875543599893710346844574971075921041496871881080512503217260769624804065596751534343662438394009356717682549849813579683807411836806956417224771432950855424795916847683629888419235012414123218681592018347300549566480645820788828884670170227348048694510744364877265930061422199605236539854481131874246370399956781377830722015722886884059955236617197194789439998472191229648923258247262131755689255146886795535534537354318015385271178803608088214700126029621133594790006436889852250107606783683417339851548995227133141803484257221095744914814397064115308252464652873341285802340753454548916615332528616057502990290828900499685424871335209817720727253000270548565157264252790009718525020443966599344478805
class Outer {
public Outer() {
}
public class Inner {
public Inner() {
}
public void doit() {
System.out.println("Sup.");
import random
import itertools
def find_collision(rng):
d = {}
for iteration in itertools.count():
nonce = rng()
if nonce in d:
return iteration