Skip to content

Instantly share code, notes, and snippets.

View tomnomnom's full-sized avatar
☺️
Taking it easy

Tom Hudson tomnomnom

☺️
Taking it easy
View GitHub Profile
@tomnomnom
tomnomnom / simple-vm.go
Created October 29, 2014 11:10
Simple VM in Go
package main
import (
"fmt"
"log"
"strings"
)
// Ops
const (

Keybase proof

I hereby claim:

  • I am TomNomNom on github.
  • I am tomnomnom (https://keybase.io/tomnomnom) on keybase.
  • I have a public key whose fingerprint is 52D9 4FE1 8D6A A5EF 0FE3 3ECE CE03 0B9A DABB DC9E

To claim this, I am signing this object:

alert(1);
@tomnomnom
tomnomnom / node-hello.js
Created March 5, 2014 09:06
Node.js Hello World Server
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}).listen(1337, '0.0.0.0');
console.log('Server running at http://0.0.0.0:1337/');
@tomnomnom
tomnomnom / rsync-link-dest.sh
Last active August 29, 2015 13:56
Rsync with --link-dest wrapper
@tomnomnom
tomnomnom / extract.php
Created February 5, 2014 13:35
PHP Extract Function
<?php
function array_extract(array $input, array $keys){
$output = [];
foreach ($keys as $key){
if (!array_key_exists($key, $input)) continue;
$output[$key] = $input[$key];
}
return $output;
}
@tomnomnom
tomnomnom / find-bt-address-id.php
Created December 9, 2013 17:03
Hacky script for finding BT Address IDs
<?php
const HOUSE_NUMBER = 2;
const POSTCODE = 'LS1 4AP';
const SERVICE_URL = 'http://www.productsandservices.bt.com/consumerProducts/v1/addressSearch.do';
$query = http_build_query(array(
'postcode' => POSTCODE,
@tomnomnom
tomnomnom / fttc-check.php
Last active December 30, 2015 19:29
Hacky FTTC Check Script
<?php
// Change me
const ADDRESS_ID = 'Gold|StringOfAlphas|MY|HouseNumber'; // You can find your Address ID using this: https://gist.github.com/TomNomNom/7875919
const TO_EMAIL = 'me@example.com';
const FROM_EMAIL = 'server@example.com';
// Don't change me
const SERVICE_URL = 'http://www.productsandservices.bt.com/consumerProducts/v1/productAvailability.do';
@tomnomnom
tomnomnom / json-parsing.go
Created October 27, 2013 10:49
Parsing arbitrary JSON with go
package main
import (
"log"
"fmt"
"encoding/json"
)
func main() {
b := []byte(`{"name": "tom", "favNum": 6, "interests": ["knives", "computers"], "usernames": {"github": "TomNomNom", "twitter": "@TomNomNom"}}`)
<?php
class SayDate extends DateTime {
public function say(){
$now = new DateTime();
$now->setTime(0, 0, 0);
$interval = (int) $now->diff($this)->format('%r%a');
if ($interval < 0){
return $this->format('Y-m-d');