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 / robot.py
Last active August 27, 2015 15:58
Playing with OpenCV; making myself into a robot
import cv2
# See https://www.youtube.com/watch?v=FH5oDFgLSs4 for example output
cap = cv2.VideoCapture(0)
face_cascade = cv2.CascadeClassifier("/usr/share/opencv/haarcascades/haarcascade_frontalface_default.xml")
eye_cascade = cv2.CascadeClassifier("/usr/share/opencv/haarcascades/haarcascade_eye.xml")
fourcc = cv2.cv.CV_FOURCC(*'XVID')
out = cv2.VideoWriter('output.avi',fourcc, 15, (640,480))
@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 / rsync-link-dest.sh
Last active August 29, 2015 13:56
Rsync with --link-dest wrapper
alert(1);

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:

@tomnomnom
tomnomnom / lolstore.go
Created January 21, 2015 14:20
lolstore
package main
import (
"fmt"
"io"
"log"
"net/http"
"os"
)
@tomnomnom
tomnomnom / virev.sh
Created September 28, 2011 09:36
bash function to open files modified in a git commit in vim tabs
# Open files modified in a git commit in vim tabs; defaults to HEAD. Pop it in your .bashrc
# Examples:
# virev 49808d5
# virev HEAD~3
function virev {
commit=$1
if [ -z "${commit}" ]; then
commit="HEAD"
fi
rootdir=$(git rev-parse --show-toplevel)
@tomnomnom
tomnomnom / mungeable.php
Created November 12, 2011 03:41
Mungeable PHP objects - playing with PHP 5.4 RC1
<?php
/**
* Playing with some of PHP 5.4 RC1's features
*
* A trait to make an object "mungeable"; i.e. so you can "munge"
* methods (closures/lambdas) and properties into it.
*
* All methods and properties will be public.
*
* This is pure experimentation. Please do not attempt to derive any
@tomnomnom
tomnomnom / vim-in-ambient-exercise.html
Created May 7, 2012 12:06
Vim "in" and "ambient" motions exercise
<!doctype html>
<html lang="en">
<head>
<title>My awesome homepage</title>
<script type="text/javascript">
(function(){
// Press ci" (Change In quotes) with the cursor between
@tomnomnom
tomnomnom / xdebug-trigger.patch
Created May 15, 2012 21:59
XDEBUG_PROFILE trigger from CLI patch
From a7209454d1817f0e79b62d78b370cd8390fb1069 Mon Sep 17 00:00:00 2001
From: Tom Hudson <mail@tomnomnom.com>
Date: Tue, 15 May 2012 22:55:24 +0100
Subject: [PATCH] Enabled use of XDEBUG_PROFILE trigger from CLI via _ENV
globals
---
xdebug.c | 3 +++
1 file changed, 3 insertions(+)