Skip to content

Instantly share code, notes, and snippets.

View grantc's full-sized avatar

Grant Croker grantc

View GitHub Profile

### Keybase proof

I hereby claim:

  • I am grantc on github.
  • I am grantcroker (https://keybase.io/grantcroker) on keybase.
  • I have a public key ASC-hVjfQJKBEYBoEfMEve1Jis0RoyEZhYlkazYXQL1qwgo

To claim this, I am signing this object:

@grantc
grantc / .gitconfig
Last active October 3, 2019 08:49
.gitconfig
[user]
name =
email =
signingkey =
[core]
excludesfile = /Users/me/.gitignore_global
editor = vim
pager = less
[difftool "sourcetree"]
cmd = opendiff \"$LOCAL\" \"$REMOTE\"
@grantc
grantc / function.js
Created May 9, 2018 06:56 — forked from vgeshel/function.js
AWS Lambda function for forwarding SNS notifications to Slack
console.log('Loading function');
const https = require('https');
const url = require('url');
// to get the slack hook url, go into slack admin and create a new "Incoming Webhook" integration
const slack_url = 'https://hooks.slack.com/services/...';
const slack_req_opts = url.parse(slack_url);
slack_req_opts.method = 'POST';
slack_req_opts.headers = {'Content-Type': 'application/json'};
@grantc
grantc / haproxy.cfg
Created November 13, 2017 15:44 — forked from thisismitch/haproxy.cfg
Let's Encrypt Auto-Renewal script for HAProxy
global
log /dev/log local0
log /dev/log local1 notice
chroot /var/lib/haproxy
stats socket /run/haproxy/admin.sock mode 660 level admin
stats timeout 30s
user haproxy
group haproxy
daemon
maxconn 2048
@grantc
grantc / renice-audio.sh
Last active April 18, 2017 11:04 — forked from redolent/renice-audio.sh
Fix Bluetooth Audio on Mac
#!/bin/bash
list="$(
sudo ps -A \
| grep -iE '([h]ear|[f]irefox|[c]hrome|[b]lue|[c]oreaudiod)' \
| cut -c 1-90
)"
pids=$( cut -c 1-6 <<< "$list" )
#!/bin/bash
hostname=$0
echo "Setting hostname to ${hostname}"
sed -i "s/^127.0.0.1.*/127.0.0.1\t${hostname} localhost localhost.localdomain localhost4 localhost4.localdomain4/" /etc/hosts
sed -i "s/^::1.*/::1\t${hostname} ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6/" /etc/hosts
sed -i "s/HOSTNAME=.*/HOSTNAME=${hostname}/" /etc/sysconfig/network
hostname ${hostname}
echo "The hostname is now $(hostname)"
@grantc
grantc / processes.py
Created November 5, 2015 12:49
list top 20 proceses by memory usage
import psutil
import json
import datetime
procs = []
timestamp = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
for proc in psutil.process_iter():
try:
pinfo = proc.as_dict(attrs=['pid', 'name', 'cmdline'])
@grantc
grantc / stunnel-5.22.xforwardedfor.patch
Last active December 28, 2018 14:44
X-Forwarded-For patch for Stunnel 5.22
diff -rupN stunnel-5.22.orig/doc/stunnel.8.in stunnel-5.22/doc/stunnel.8.in
--- stunnel-5.22.orig/doc/stunnel.8.in 2015-07-27 09:54:55.000000000 +0000
+++ stunnel-5.22/doc/stunnel.8.in 2015-08-18 09:25:06.868928121 +0000
@@ -964,6 +964,10 @@ This option has been renamed to \fInone\
.RE
.RS 4
.RE
+.IP "\fBxforwardedfor\fR = yes | no" 4
+.IX Item "xforwardedfor = yes | no"
+append an 'X-Forwarded-For:' HTTP request header providing the
@grantc
grantc / install_puppet.bash
Created July 1, 2014 06:54
Install Puppet on Ubuntu/Debian
wget https://apt.puppetlabs.com/puppetlabs-release-$(lsb_release -cs).deb
dpkg -i puppetlabs-release-$(lsb_release -cs).deb
apt-get update
apt-get install puppet
@grantc
grantc / README.md
Created June 5, 2014 13:53
Embedded Perl

Compilation etc..

yum install perl-devel
gcc ep.c -o ep -I /usr/lib64/perl5/CORE -lperl -L /usr/lib64/perl5/CORE/
cat > hw.pl <<EOP
print "Hello World\n";
EOP
export LD_LIBRARY_PATH=/usr/lib64/perl5/CORE/

./ep hw.pl