Skip to content

Instantly share code, notes, and snippets.

@aerickson
aerickson / rsync_with_progress.py
Created Oct 13, 2011
Get total rsync progress using Python
View rsync_with_progress.py
# 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
mirror squarespace site with wget
View mirror.sh
#!/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 / # llvm - 2020-04-02_11-35-20.txt
Created Apr 2, 2020
llvm on macOS 10.15.3 - Homebrew build logs
View # llvm - 2020-04-02_11-35-20.txt
Homebrew build logs for llvm on macOS 10.15.3
Build date: 2020-04-02 11:35:20
@aerickson
aerickson / README.md
Created Aug 28, 2019 — forked from robbiet480/README.md
A consul-template plugin to get EC2 metadata
View README.md

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 Aug 28, 2019 — forked from marceloalmeida/README.md
A consul-template plugin to get EC2 metadata
View README.md

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 Dec 16, 2018
how to rebuild PyCurl against OpenSSL on Ubuntu (12-13+)
View PyCurlSSLFixOnUbuntu
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
View ruby seconds to human readable
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
View Screen Cheat Sheet.txt
Screen Cheat Sheet
===========================
terminal usage:
new session:
screen
new named session:
screen -S <NAME>
view sessions:
screen -list
View find_external_ip.rb
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
View urbanspoon_reservations.rb
require 'rubygems'
require 'mechanize'
FIRST_NAME = 'FIRST_NAME'
LAST_NAME = 'LAST_NAME'
PHONE = 'PHONE'
EMAIL = 'EMAIL@provider.com'
PARTY_SIZE = 2
SCHEDULE_RANGE = { :start_time => '19:00', :end_time => '20:30' }