Skip to content

Instantly share code, notes, and snippets.

View joshes's full-sized avatar

Joshua Hansen joshes

View GitHub Profile
@joshes
joshes / springer-free-maths-books.md
Created December 29, 2015 00:22 — forked from bishboria/springer-free-maths-books.md
Springer have made a bunch of maths books available for free, here are the direct links
@joshes
joshes / distance.sql
Created March 21, 2017 20:53 — forked from aramonc/distance.sql
MySQL function to calculate the distance between two coordinates using the Haversine formula. Leaving it here for future reference.
DELIMITER $$
CREATE FUNCTION `haversine` (lat1 DECIMAL(8,6), lng1 DECIMAL(8,6), lat2 DECIMAL(8,6), lng2 DECIMAL(8,6)) RETURNS DECIMAL(8,6)
BEGIN
DECLARE R INT;
DECLARE dLat DECIMAL(30,15);
DECLARE dLng DECIMAL(30,15);
DECLARE a1 DECIMAL(30,15);
DECLARE a2 DECIMAL(30,15);
DECLARE a DECIMAL(30,15);
DECLARE c DECIMAL(30,15);
@joshes
joshes / command.yaml
Created March 27, 2018 22:11
Command to make container wait
command: ['/bin/bash', '-c', 'trap : TERM INT; sleep infinity & wait']
@joshes
joshes / download-alexa-audio.sh
Created January 19, 2019 17:51
Downloads all of your Amazon Alexa audio files to disk
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Downloads all of your alexa audio files to `output_dir` with the filenames
# flattened (vs storing as sub-directories as implied by the file name).
#
# For example, the following id:
# - A3S5CH1HU6KAYF:1.0/2019/01/18/17/G090LF1174270LM2/39:31::TNIH_2V.6c04473c-3160-4012-9719-63ca63396288ZXK
# Will be saved to:
# - ${output_dir}/A3S5CH1HU6KAYF_1_0_2019_01_18_17_G090LF1174270LM2_39_31__TNIH_2V_6c04473c-3160-4012-9719-63ca63396288ZXK.wav
#
# Example of using etcdctl w/TLS
kubectl exec -it -n kube-system $(kubectl get pods -n kube-system | grep etcd-manager-main | awk '{print $1}') bash
CLUSTER=my-cluster.k8s.local
cd /opt/etcd-v3.2.18-linux-amd64
ETCDCTL_API=3 ./etcdctl \
--key /rootfs/etc/kubernetes/pki/kube-apiserver/etcd-client.key \
--cert /rootfs/etc/kubernetes/pki/kube-apiserver/etcd-client.crt \
sudo SKIP_PACKAGE_UPDATE=1 /var/cache/kubernetes-install/nodeup --conf=/var/cache/kubernetes-install/kube_env.yaml --v=10
# Show stats
sudo du -d1 -h /var/lib/docker | sort -h
# Cleanup images
sudo docker rmi $(sudo docker images --filter "dangling=true" -q --no-trunc)
# Cleanup volumes
sudo docker ps -a | awk 'NR>1 {print $1}' | xargs sudo docker rm
sudo docker volume rm $(sudo docker volume ls -qf dangling=true)
@joshes
joshes / gist:0a7c05c5b600347575e0422641c9d3bc
Last active August 18, 2019 17:52 — forked from amccarty/gist:efb8b8cfd2a42363cf060ff7778a10f9
Elastic Beanstalk memory monitor cron
# https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/mon-scripts.html
#.ebextensions/01-memorymon.config
packages:
yum:
perl-Switch: []
perl-DateTime: []
perl-Sys-Syslog: []
perl-LWP-Protocol-https: []
perl-Digest-SHA.x86_64: []
#!/bin/bash
###
### my-script — does one thing well
###
### Usage:
### my-script <input> <output>
###
### Options:
### <input> Input file to read.
### <output> Output file to write. Use '-' for stdout.