Skip to content

Instantly share code, notes, and snippets.

@colby
colby / bump
Last active March 6, 2019 16:56
Bumps a git tag and metadata.rb version for a given Chef cookbook, follows SemVer standards.
#!/bin/bash
set -eo pipefail
semver_regex="^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(\-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?(\+[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$"
usage="\
Usage:
$0
$0 show
@colby
colby / remove_php.sh
Last active October 27, 2016 18:41
Remove all traces of PHP
sudo aptitude purge $(dpkg -l | grep php | awk '{print $2}' | tr "\n" " ")
@colby
colby / gist:1985164959593763280c8eb3d91b4feb
Created May 19, 2016 19:59 — forked from wkrsz/gist:3d5ff7f908a180b87498
Stop Safari hanging when selecting the address bar or opening a new tab
This shit has been bugging me for too long, so I went on a hunt and found a workaround.
The Symptoms are as follows:
* Clicking the address bar results in a 1-4 second delay
* Opening links in new tabs results in a 1-4 second delay
* +T results in a 1-4 second delay
* `PressAndHold[<pid>]: IMKServer Stall detected` is present in `/var/log/system.log` at the time of the hang.
It appears to be to do with the PressAndHold helper - the thing that shows an IOS style selection of accents when you hold a key down.
The fix may have some unwanted effects, I haven't really noticed any.
@colby
colby / package_check.sh
Created April 28, 2016 19:17
A package upgrade checking script.
#!/bin/bash
file=/tmp/packages
/usr/lib/update-notifier/apt-check --human-readable
[ -f /var/run/reboot-required ] && echo -e "\nA reboot is required!"
apt list --upgradable > $file 2>/dev/null
@colby
colby / opera-vpn.md
Created April 24, 2016 06:25 — forked from spaze/opera-vpn.md
Opera VPN behind the curtains is just a proxy, here's how it works

When setting up (that's immediately when user enables it in settings) Opera VPN sends few API requests to https://api.surfeasy.com to obtain credentials and proxy IPs, see below.

The browser then talks to a proxy de0.opera-proxy.net (when VPN location is set to Germany), it's IP address can only be resolved from within Opera when VPN is on, it's 185.108.219.42 (or similar, see below). It's an HTTP/S proxy which requires auth.

When loading a page with Opera VPN enabled, the browser sends a lot of requests to de0.opera-proxy.net with Proxy-Authorization request header.

The Proxy-Authorization header decoded: CC68FE24C34B5B2414FB1DC116342EADA7D5C46B:9B9BE3FAE674A33D1820315F4CC94372926C8210B6AEC0B662EC7CAD611D86A3 (that's sha1(device_id):device_password, where device_id and device_password come from the POST /v2/register_device API call, please note that this decoded header is from another Opera installation and thus contains different device_id and device_password than what is shown be

@colby
colby / git.sh
Created April 5, 2016 17:33
Display git information in PS1.
export PS1="\n\w\$(stopped_jobs)\$(git_prefix)\$(git_prompt_info)\n\$(last_status)\$ "
# only show status when non zero
function last_status() {
last_status="${STATUS}"
if [ ${last_status} -gt 0 ]; then
echo "${last_status}"
fi
}
@colby
colby / sandman.sh
Last active January 14, 2016 07:09
A tool to put all known Vagrant VMs to sleep.
#!/usr/bin/env sh
# functions
errcho() {
>&2 echo "$*"
exit 1
}
check() {
which "$1" || errcho "Missing dependency: $1"
@colby
colby / aliases.sh
Last active September 19, 2016 23:15
Useful IP related aliases and tools.
alias speed="wget --output-document=/dev/null http://speedtest.wdc01.softlayer.com/downloads/test500.zip"
alias wanip="curl http://ifconfig.co"
function ipinfo() { curl "http://ipinfo.io/$1"; }
@colby
colby / imgur.sh
Created October 15, 2015 23:09
UPLOADS TO IMGUR, GOT IT?
#!/usr/bin/env bash
# variables
img="$1"
tmp=/tmp/imgur
id='3e7a4deb7ac67da'
link='https://api.imgur.com/3/upload'
# functions
errcho() {
@colby
colby / wrap
Last active September 25, 2015 00:25
Cron wrapper for logging job duration.
#!/bin/bash
LOG='/tmp/joblog'
JOB="$*"
NOW=$SECONDS
eval $JOB
END=$SECONDS