Skip to content

Instantly share code, notes, and snippets.

View craigw's full-sized avatar
🦄

Craig R Webster craigw

🦄
View GitHub Profile
@craigw
craigw / irc.sh
Created February 5, 2010 12:44
Connecting to an IRC client running in a remote screen session.
#! /bin/sh
ssh -p 2202 -l craig -t barkingiguana.com $@ screen -xR irc
I love it when I'm looking for something: https://twitter.com/craigwebster/status/8672990615
And stuff like this happens: https://twitter.com/jturnbull/status/8673790759
Why? Well, look at this:
$ dig edinburghmenus.com
; <<>> DiG 9.4.3-P1 <<>> edinburghmenus.com
;; global options: printcmd
# Does the requested file not exist?
RewriteCond %{REQUEST_FILENAME} !-f
# AND is there a file that matches the requested file but with .html at the end?
RewriteCond %{REQUEST_FILENAME}.html -f
# Then rewrite the request under the hood and serve the HTML file.
RewriteRule ^([^.]+)$ $1.html [QSA]
// Library:
Email = {}
Email.Message = function(raw_source) {
var parts = raw_source.split(/\r\n\r\n/);
this.headers = parts[0];
this.body = parts[1];
}
Email.Message.prototype.header(header_name, value) {
if(!value) {
# Quickly setup iptables, ntp, the backup service and snmpd:
# wget http://gist.github.com/raw/282727/1ec21c6628b3cb9a9f6525b4929f7b8675568b4f/first-boot.sh && bash first-boot.sh
# Firewall
apt-get install --yes iptables
iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -p tcp --dport ssh -j ACCEPT
iptables -A INPUT -s 193.219.108.245 -p icmp -m icmp --icmp-type 8 -j ACCEPT
iptables -A INPUT -j DROP
#! /bin/bash
# make sure /etc/mysql.passwd is chmod go-wrx.
# and chmod root:root.
PASSWORD=`cat /etc/mysql.passwd`
NICE='/usr/bin/nice -n 20'
CWD=`/bin/pwd`
UMASK=`umask`
MYSQLDUMP="/usr/bin/mysqldump -u root --password='${PASSWORD}'"
DUMPFILE="/var/backups/mysql.sql"
require('http')
.createServer(function(request, response){
setTimeout(function() {
response.sendHeader(200, {'Content-Type' : 'text/plain'});
response.sendBody("zoom");
response.finish();
}, 2000);
})
.listen(8000);
#! /usr/bin/env ruby
require 'rubygems'
require 'net/http'
require 'cgi'
require 'hpricot'
name = CGI.escape(ARGV[0])
postcode = CGI.escape(ARGV[1])
@craigw
craigw / gist:224927
Created November 3, 2009 10:06
Back up MySQL databases
#! /bin/bash
RETENTION=14
BACKUP_DIRECTORY='/var/backups/mysql'
NICE='/usr/bin/nice -n 20'
MYSQLDUMP='/usr/bin/mysqldump'
BZIP='/bin/bzip2'
RM='/bin/rm'
#! /bin/bash
# This is ~/bin/mc
# chmod +x ~/bin/mc
# Usage: mc foo
# Create a Mochiweb project called "foo" in the current
# directory.
# I keep my clone of http://github.com/toddlipcon/mochiweb at