Skip to content

Instantly share code, notes, and snippets.

@thomseddon
thomseddon / install
Last active December 27, 2015 18:19
Install node.js on linux
#!/bin/bash
# Get the latest version no.
version=$(wget --quiet --output-document - \
http://nodejs.org/dist/latest/SHASUMS.txt |
head --lines 1 |
cut --fields 3 --delimiter " " |
cut --fields 2 --delimiter "-")
name=node-$version-linux-x64
@thomseddon
thomseddon / git_deploy.sh
Last active December 29, 2015 10:09
Create a git deployment folder on a remote machine
#!/bin/bash
# Read vars
if [ "$1" == "" ]; then
echo "Usage: ./git_deploy <folder> <user?> <post-receive?>"
exit 1
fi
folder=$1
if [ -d "$folder" ]; then
@thomseddon
thomseddon / mkcrt.sh
Created December 18, 2013 20:21
SSL walkthrough for nginx
#!/bin/bash
# Copyright 2013-present Thom Seddon
if [ "$1" == "" ]; then
echo "Usage: sudo ./mkcrt <hostname>"
exit 1
fi
if [ "$(id -u)" != "0" ]; then
echo "Must run with sudo"
@thomseddon
thomseddon / bootstrap_cake_pagination.php
Last active November 6, 2020 11:08
Bootstrap style CakePHP pagination
<p>
<?php
echo $this->Paginator->counter(array(
'format' => __('Page {:page} of {:pages}, showing {:current} records out of {:count} total, starting on record {:start}, ending on {:end}')
));
?>
</p>
<ul class="pagination">
<?php
echo $this->Paginator->prev('&laquo;', array('tag' => 'li', 'escape' => false), '<a href="#">&laquo;</a>', array('class' => 'prev disabled', 'tag' => 'li', 'escape' => false));
@thomseddon
thomseddon / forward.js
Created September 15, 2014 18:23
SupportBee <3 PagerDuty
function doPost(req) {
var date = new Date();
var hour = date.getHours();
var day = date.getDay();
// Normal support
if (hour >= 9 && hour <= 17 && day >= 1 && day <= 5)
return ContentService.createTextOutput('Normal support');
// Parse body

Keybase proof

I hereby claim:

  • I am thomseddon on github.
  • I am thomseddon (https://keybase.io/thomseddon) on keybase.
  • I have a public key whose fingerprint is F5A5 8053 B6B2 9FE9 C90D 4459 A531 B220 A925 2B68

To claim this, I am signing this object:

@thomseddon
thomseddon / gist:f58d57b85ce4c1a570b4
Created January 20, 2015 14:30
Recursively convert tabs to 2 spaces
find . -name '*' ! -type d -exec bash -c 'expand -t 2 "$0" > /tmp/e && mv /tmp/e "$0"' {} \;
@thomseddon
thomseddon / proxy
Created February 25, 2015 20:31
Create proxies in iptables
#!/bin/bash
#
# Copyright Thom Seddon 2015
# MIT
#
if [ "$1" == "" ] || [ "$1" == "help" ]; then
echo "Usage: ~/.proxy <option>"
echo
echo " Options: "
# Test:
$ curl http://127.0.0.1:3000
# With debug set to true
$ node test.js
OAuth2Error: The access token was not found
at OAuth2Error (/home/thom/Dev/node/t/node_modules/oauth2-server/lib/error.js:30:12)
at Authorise.getBearerToken (/home/thom/Dev/node/t/node_modules/oauth2-server/lib/authorise.js:70:17)
at run (/home/thom/Dev/node/t/node_modules/oauth2-server/lib/runner.js:15:14)
at runner (/home/thom/Dev/node/t/node_modules/oauth2-server/lib/runner.js:19:5)
#!/bin/sh
#===================================================================================
#
# FILE: dump.sh
# USAGE: dump.sh [-i interface] [tcpdump-parameters]
# DESCRIPTION: tcpdump on any interface and add the prefix [Interace:xy] in front of the dump data.
# OPTIONS: same as tcpdump
# REQUIREMENTS: tcpdump, sed, ifconfig, kill, awk, grep, posix regex matching
# BUGS: ---
# FIXED: - In 1.0 The parameter -w would not work without -i parameter as multiple tcpdumps are started.