Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / sandman.sh
Created November 17, 2016 05:49
Put all of your Vagrant VMs to sleep.
#!/usr/bin/env sh
vagrant=$(which vagrant)
awk=$(which awk)
printf "Gathering a list of machines. "
machines=$(vagrant global-status --prune 2>/dev/null | $awk '/running/ {print $5}')
if [ ! -z "${machines[@]}" ]
then
@colby
colby / -
Created December 6, 2016 01:59
[vagrant@web ~]$ # sudo yum install policycoreutils-python
[vagrant@web ~]$ # sudo audit2allow -a -M httpd_copious
[vagrant@web ~]$ # sudo semodule -i httpd_copious.pp
@colby
colby / -
Created December 6, 2016 02:17
[vagrant@web ~]$ cat httpd_copious.te
module httpd_copious 1.0;
require {
type httpd_t;
type default_t;
type hugetlbfs_t;
class file { write getattr };
class capability2 block_suspend;
wget https://gist.githubusercontent.com/colby/20fb4fc48f5ebf9a062da5fdf1f59f88/raw/c154e38fb44f9aaf1e6d8329cc5546bef41b57ea/dank-tags.csv
function dank() {
local tags=~/Desktop/dank-tags.csv
if [[ $# -gt 0 ]]
then
grep "$@" $tags | gsort --random-sort | head -n 1 | say
else
gsort --random-sort $tags | head -n 1 | say
fi
@colby
colby / bump
Created January 16, 2017 19:18
#!/bin/bash
set -e
platform=$(uname)
if [ "$platform" == 'Darwin' ]
then
sed=$(which gsed || errcho "install gnu-sed")
else
sed=$(which sed)
#!/usr/bin/env sh
vagrant=$(which vagrant)
awk=$(which awk)
printf "Gathering a list of machines. "
machines=$(vagrant global-status --prune 2>/dev/null | vagrant global-status | $awk '/running/ {print $5}')
if [ ! -z "${machines[@]}" ]
then
@colby
colby / -
Created August 9, 2017 22:35
awk 'NF {sub(/\r/, ""); printf "%s\\n",$0;}' cert-name.pem