Skip to content

Instantly share code, notes, and snippets.

View dannycroft's full-sized avatar

Danny Croft dannycroft

View GitHub Profile
@dannycroft
dannycroft / templates.json
Created December 1, 2017 14:52
Stack Templates
[{
"type": "container",
"title": "Registry",
"description": "Docker image registry",
"categories": ["docker"],
"platform": "linux",
"logo": "https://cloudinovasi.id/assets/img/logos/registry.png",
"image": "registry:latest",
"ports": [
"5000/tcp"
### Keybase proof
I hereby claim:
* I am dannycroft on github.
* I am dannycroft (https://keybase.io/dannycroft) on keybase.
* I have a public key ASCOJTYfcKRcaND9PnQqyF-0XeDeh7q8zaU5CgHPWeqYhAo
To claim this, I am signing this object:
@dannycroft
dannycroft / bloom.py
Created September 28, 2017 16:06
A basic bloom filter implementation
#!/usr/bin/env python3
''' A basic bloom filter implementation'''
from bitarray import bitarray
from hashlib import sha256
import math
def h_i(i, m, s):
'''
Our "uniformly distributed" hash function: h_i(s) = sha256(s + i) % m
@dannycroft
dannycroft / main.go
Created September 22, 2017 17:09
Fibonacci in GO
package main
import "fmt"
func fibonacci() func() int {
first, second := 0, 1
return func() int {
ret := first
first, second = second, first+second
return ret
@dannycroft
dannycroft / tti.js
Created June 16, 2017 06:06
TTI - console measurement
var t = window.performance.timing;
var interactive = t.domInteractive - t.domLoading;
var dcl = t.domContentLoadedEventStart - t.domLoading;
var complete = t.domComplete - t.domLoading;
console.log('interactive: ' + interactive + 'ms, ' + 'dcl: ' + dcl + 'ms, complete: ' + complete + 'ms');
#!/bin/bash
# ./ttfb https://www.google.com ~/your-log-file.txt
function ttfb() {
curl -o /dev/null \
-H 'Cache-Control: no-cache' \
-s \
-w "%{time_connect} %{time_starttransfer} %{time_total}" \
$1
}
curl -o /dev/null -w "Connect: %{time_connect} TTFB: %{time_starttransfer} Total time: %{time_total} \n" https://google.com
fetch('//freegeoip.net/json/').then(r => r.json()).then(r => console.log(r));
#!/bin/sh
fancy_echo() {
local fmt="$1"; shift
# shellcheck disable=SC2059
printf "\n$fmt\n" "$@"
}
append_to_zshrc() {
S3KEY="my aws key"
S3SECRET="my aws secret" # pass these in
function putS3
{
path=$1
file=$2
aws_path=$3
bucket='my-aws-bucket'
date=$(date +"%a, %d %b %Y %T %z")