Skip to content

Instantly share code, notes, and snippets.

View njt1982's full-sized avatar
Converting Coffee into Code

Nicholas Thompson njt1982

Converting Coffee into Code
View GitHub Profile
@njt1982
njt1982 / gist:8705893
Created January 30, 2014 10:22
TamperMonkey script to detect Varnish hits
// ==UserScript==
// @name Varnish Header Checker
// @namespace http://www.thingy-ma-jig.co.uk/
// @version 0.1
// @description Check for the presence of a Varnish Header and put an alert DIV on the page.
// @match http://*/*
// @copyright 2014+, You
// ==/UserScript==
var req = new XMLHttpRequest();
@njt1982
njt1982 / jenkins-build-count.sh
Last active August 29, 2015 13:55
List Jenkins job build count from command line
#!/bin/sh
cd /var/lib/jenkins/jobs
find . -mindepth 1 -maxdepth 1 -type d -print0 | while read -d $'\0' f; do C=`find "$f/builds/" -maxdepth 1 -type d | wc -l`; echo "${C} ${f}"; done | sort -n
@njt1982
njt1982 / ipwatcher.sh
Created March 18, 2014 15:03
Domain IP Watcher
#!/bin/sh
if [ $# -lt 1 ]; then
echo "USAGE: $0 [domain.com]"
exit 1
fi
DOMAIN=$1
INITIAL=$(dig $DOMAIN | grep -E 'IN.+A.+.+' | awk '{print $5}')
echo "Initial IP = $INITIAL"
@njt1982
njt1982 / keybase.md
Created October 20, 2014 15:34
KeyBase.io proof

Keybase proof

I hereby claim:

  • I am njt1982 on github.
  • I am njt1982 (https://keybase.io/njt1982) on keybase.
  • I have a public key whose fingerprint is 907A 2485 7EF0 D11C F390 FF7E 4C6F CE31 94FB E84B

To claim this, I am signing this object:

@njt1982
njt1982 / Borked Internet
Created October 26, 2014 21:07
Pings aren't great...
$ ping google.co.uk
PING google.co.uk (74.125.230.127): 56 data bytes
Request timeout for icmp_seq 0
Request timeout for icmp_seq 1
Request timeout for icmp_seq 2
Request timeout for icmp_seq 3
Request timeout for icmp_seq 4
64 bytes from 74.125.230.127: icmp_seq=1 ttl=54 time=4025.251 ms
64 bytes from 74.125.230.127: icmp_seq=2 ttl=54 time=3040.001 ms
64 bytes from 74.125.230.127: icmp_seq=3 ttl=54 time=2103.742 ms
@njt1982
njt1982 / clean-settings.sh
Created January 7, 2015 12:38
Drupal - Make Clean Settings.php file
#!/bin/sh
grep -vE '^(#|\/| \*)' default.settings.php | sed '/^\s*$/d' > settings.php
@njt1982
njt1982 / gist:dd1c533142639aed7d25
Created March 18, 2015 12:47
VarnishADM Reload helper

Basically:

  • Switch to a different conf (you cannot discard / reload an active conf)
  • Discard it
  • Reload it into a name
  • Use that name
vcl.use boot
vcl.discard reload01
@njt1982
njt1982 / nginx configure
Created September 11, 2013 09:03
My nginx configuration
./configure --user=nginx --group=nginx --prefix=/usr/share/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/lib/nginx/tmp/client_body --http-proxy-temp-path=/var/lib/nginx/tmp/proxy --http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi --http-uwsgi-temp-path=/var/lib/nginx/tmp/uwsgi --http-scgi-temp-path=/var/lib/nginx/tmp/scgi --pid-path=/var/run/nginx.pid --lock-path=/var/lock/subsys/nginx --with-openssl=/usr/local/src/openssl-0.9.8l/ --with-openssl-opt="enable-tlsext" --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_geoip_module --with-http_sub_module --with-http_gzip_static_module --with-http_stub_status_module --with-http_perl_module --with-file-aio --with-cc-opt='-O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic' --with-ld-opt=-Wl,-E
// Feel free to use. MIT License
#import "cocos2d.h"
// Layer that will just capture any touch events on it
@interface OpaqueLayer : CCLayerColor
@end
@njt1982
njt1982 / gist:8659208
Created January 27, 2014 23:08
Make iOS Default Project Images
#!/usr/bin/env bash
# Usage: ./resize-default.sh /path/to/folder
#
# Expects there to be a Source.png which is the iPad@2x.png resolution (1536x2048)
# It then generates versions for iPad/iPad Mini and 3 iPhones (5/5S, 4/4S/3GS and 3G/2G)
#
if [ -z "$1" ]; then