Skip to content

Instantly share code, notes, and snippets.

View samgiles's full-sized avatar
🗺️

Sam Giles samgiles

🗺️
  • Citymapper
  • London
View GitHub Profile
@samgiles
samgiles / gist:b3fa9da8f6b8d71ca6b2
Created March 13, 2015 14:12
php56w configure flags
--build=x86_64-redhat-linux-gnu --host=x86_64-redhat-linux-gnu --target=x86_64-redhat-linux-gnu --program-prefix= --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc --datadir=/usr/share --includedir=/usr/include --libdir=/usr/lib64 --libexecdir=/usr/libexec --localstatedir=/var --sharedstatedir=/var/lib --mandir=/usr/share/man --infodir=/usr/share/info --cache-file=../config.cache --with-libdir=lib64 --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --disable-debug --with-pic --disable-rpath --without-pear --with-exec-dir=/usr/bin --with-freetype-dir=/usr --with-png-dir=/usr --with-xpm-dir=/usr --enable-gd-native-ttf --with-t1lib=/usr --without-gdbm --with-jpeg-dir=/usr --with-openssl --with-pcre-regex --with-zlib --with-layout=GNU --with-kerberos --with-libxml-dir=/usr --with-system-tzdata --with-mhash --enable-dtrace --enable-force-cgi-redirect --disable-phpdbg --libdir=/usr/lib64/php --enable-pcntl --enable-fastcgi --without-readline --with-libedit --
@samgiles
samgiles / promisetimeout.js
Last active August 29, 2015 14:16
Tiny Promise timeout implementation
// License MIT;
// Simple Promise timeout implementation, always assume IO is being done by carrier pigeon. Timeout.
function promiseTimeout(promise, timeInMs) {
function promiseTimer(resolve, reject) {
setTimeout(function() { reject(new Error("Promise timed out")); }, timeInMs);
}
return Promise.race([promise, new Promise(promiseTimer)]);
}
// Usage:
@samgiles
samgiles / tcp-proxy.sh
Created January 29, 2015 16:28
Simple TCP proxy src-port -> dest-host:port.
#!/bin/sh -e
if [ $# != 3 ]
then
echo "usage: $0 <src-port> <dst-host> <dst-port>"
exit 1
fi
TMP=`mktemp -d`
BACK=$TMP/pipe.back
@samgiles
samgiles / tcp-proxy.sh
Created December 9, 2014 12:01
Simple TCP proxy
#!/bin/sh -e
if [ $# != 3 ]
then
echo "usage: $0 <src-port> <dst-host> <dst-port>"
exit 0
fi
TMP=`mktemp -d`
BACK=$TMP/pipe.back

Called done { '0': undefined } is logged if the x method does not throw an error.

Nothing is logged if x throws an error.

...
this.y = Q.Promise.resolve(this.y).then(this.x.bind(this)).done(function() {
  console.log("Called done", arguments);
});
@samgiles
samgiles / gist:735178b552c56e9d87ef
Created September 24, 2014 10:09
All GISTS by samgiles are licensed using the MIT license unless otherwise stated.
The MIT License (MIT)
Copyright (c) 2014 Samuel Giles
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@samgiles
samgiles / check_health
Last active August 29, 2015 14:06
Simple __health endpoint NRPE check
#!/usr/bin/env python
import argparse
import urllib2
import json
import sys
NAGIOS_OK = 0
NAGIOS_WARN = 1
NAGIOS_CRIT = 2
@samgiles
samgiles / gist:36ebe62656ab1177c654
Last active August 29, 2015 14:06
AWS Instance Type Information
{
"families": [{
"description": "Micro instances are a low-cost instance option, providing a small amount of CPU resources. They are suited for lower throughput applications, and websites that require additional compute cycles periodically, but are not appropriate for applications that require sustained CPU performance. Popular uses for micro instances include low traffic websites or blogs, small administrative applications, bastion hosts, and free trials to explore EC2 functionality.",
"name": "Micro instances",
"types": [{
"architectures": ["x86_64", "i386"],
"cpu": {
"cores": 1,
"units": "Variable"
},
Set up key for github
make sure brew is installed
make sure git is installed with brew
(Sourcetree issues..) Use HTTPS (Auth issues are just too much) Github for Mac
git clone at the command line?
try `sudo gem install ruby` if failed:
rvm install ruby
@samgiles
samgiles / npmcleaner
Created August 1, 2014 13:30
Remove all Node modules safely
# Not global:
npm ls -p --depth=0 | awk -F/node_modules/ '{print $2}' | grep -vE '^(npm)$' | xargs npm rm
# Global:
npm ls -gp --depth=0 | awk -F/node_modules/ '{print $2}' | grep -vE '^(npm)$' | xargs npm -g rm