Skip to content

Instantly share code, notes, and snippets.

View aerickson's full-sized avatar

Andrew Erickson aerickson

View GitHub Profile
@aerickson
aerickson / rsync_with_progress.py
Created October 13, 2011 05:09
Get total rsync progress using Python
# from https://libbits.wordpress.com/2011/04/09/get-total-rsync-progress-using-python/
import subprocess
import re
import sys
print('Dry run:')
cmd = 'rsync -az --stats --dry-run ' + sys.argv[1] + ' ' + sys.argv[2]
proc = subprocess.Popen(cmd,
shell=True,
@aerickson
aerickson / mirror.sh
Created May 7, 2020 07:00
mirror squarespace site with wget
#!/usr/bin/env bash
set -e
wget --recursive -c --level=inf --page-requisites --convert-links --adjust-extension --span-hosts --domains=mywebsite.com,squarespace-cdn.com http://www.mywebsite.com
@aerickson
aerickson / build_with_proxy.sh
Last active March 2, 2022 19:36
docker_build_package_caching
#!/usr/bin/env bash
#
# script to build docker images and use a polipo proxy if present
# - works well for caching package fetches during apt install, etc
#
set -e
# set -x
@aerickson
aerickson / # llvm - 2020-04-02_11-35-20.txt
Created April 2, 2020 20:44
llvm on macOS 10.15.3 - Homebrew build logs
Homebrew build logs for llvm on macOS 10.15.3
Build date: 2020-04-02 11:35:20
@aerickson
aerickson / README.md
Created August 28, 2019 19:50 — forked from robbiet480/README.md
A consul-template plugin to get EC2 metadata

ec2-consul-template-plugin

About

This is a simple little Python script to let you query EC2 metadata from consul-template. It's only requirement is boto. It uses the EC2 internal metadata service so it does not require any API keys or even a region. The only caveat is that this can only be run on a machine on EC2.

Usage

You can give no arguments for full dictionary output or one or more arguments to get specific key(s). Put it somewhere on your machine, chmod +x it and give the full path to consul-template.

Examples

@aerickson
aerickson / README.md
Created August 28, 2019 19:50 — forked from marceloalmeida/README.md
A consul-template plugin to get EC2 metadata

ec2-consul-template-plugin

About

This is a simple little Python script to let you query EC2 metadata from consul-template. It's only requirement is boto. It uses the EC2 internal metadata service so it does not require any API keys or even a region. The only caveat is that this can only be run on a machine on EC2.

Usage

You can give no arguments for full dictionary output or one or more arguments to get specific key(s). Put it somewhere on your machine, chmod +x it and give the full path to consul-template.

Examples

@aerickson
aerickson / PyCurlSSLFixOnUbuntu
Last active December 16, 2018 11:34
how to rebuild PyCurl against OpenSSL on Ubuntu (12-13+)
XBMC uses pycurl/libcurl to fetch stuff. YouTube requires the RC4
cipher that GnuTLS has removed for security reasons (or doesn't allow
it to be selected, or XBMC doesn't allow to specify the cipher...).
PyCurl linked against OpenSSL can take the RC4 argument and make the
Youtube plugin work (Ubuntu ships it linked against GnuTLS), so we
need to rebuild to make it work.
///
from: https://code.google.com/p/wfuzz/wiki/PyCurlSSLBug
def humanize secs
[[60, :seconds], [60, :minutes], [24, :hours], [1000, :days]].map{ |count, name|
if secs > 0
secs, n = secs.divmod(count)
"#{n.to_i} #{name}"
end
}.compact.reverse.join(' ')
end
@aerickson
aerickson / Screen Cheat Sheet.txt
Created October 7, 2016 23:41
gnu-screen tips
Screen Cheat Sheet
===========================
terminal usage:
new session:
screen
new named session:
screen -S <NAME>
view sessions:
screen -list
@aerickson
aerickson / find_external_ip.rb
Created September 16, 2013 18:20
Get your IP address on unix-y system without a fork in Ruby. http://coderrr.wordpress.com/2008/05/28/get-your-local-ip-address/
require 'socket'
def local_ip
orig, Socket.do_not_reverse_lookup = Socket.do_not_reverse_lookup, true # turn off reverse DNS resolution temporarily
UDPSocket.open do |s|
s.connect '64.233.187.99', 1
s.addr.last
end
ensure