Skip to content

Instantly share code, notes, and snippets.

View jmhobbs's full-sized avatar

John Hobbs jmhobbs

View GitHub Profile
@jmhobbs
jmhobbs / ios5_notify.sh
Created October 12, 2011 16:51 — forked from jerodsanto/ios5_notify.sh
Siri, tell me when iOS 5 is available. Nothing? Fine. Bash, you do it.
#!/bin/bash
:(){ echo "Checking for iOS 5: `date`"; curl -s -L http://phobos.apple.com/version | grep Restore | grep iPhone | grep 5.0 > /dev/null && say "I O S 5 IS NOW AVAILABLE. GO GET YOUR DOWNLOAD ON, KID" || echo "Nothing yet..." && sleep 30 && :; };:
@jmhobbs
jmhobbs / twitter.php
Created October 6, 2011 16:03
Kohana 3 - OAuth & Twitter Example
<?php
class Controller_Twitter extends Controller {
public function action_index () {
// Load a consumer from config file.
$consumer = OAuth_Consumer::factory( Kohana::config( 'oauth.twitter' ) );
@jmhobbs
jmhobbs / screen-cam-cap.sh
Created September 28, 2011 17:04
Capture screen and webcam input with ffmpeg
#! /bin/bash
unlink screen.mpg
unlink camera.mpg
echo "Starting Desktop Grab"
ffmpeg -f x11grab -s `xdpyinfo | grep 'dimensions:'|awk '{print $2}'` -r 25 -i :0.0 -sameq screen.mpg > /dev/null 2>&1 &
echo "Starting Camera Grab"
ffmpeg -f video4linux2 -s 640x480 -i /dev/video0 -sameq camera.mpg > /dev/null 2>&1 &
read -p "Press any key to stop recording."
ps aux | grep ffmpeg | awk '{print $2}' | xargs kill
@jmhobbs
jmhobbs / find_files.php
Created September 15, 2011 14:18
Use PHP to recursively enumerate files in a directory.
<?php
/*
Given a path, this function will enumerate the files on that path.
This tree:
test
├── 1.txt
├── a
@jmhobbs
jmhobbs / chunker.py
Created August 31, 2011 18:48 — forked from squarepegsys/chunker.py
Get Python list in chunks
#!/usr/bin/env python
import unittest
from itertools import cycle
## get a list in chunks
## if we run out of items in the list, start again from the beginning
class Chunker(object):
@jmhobbs
jmhobbs / particles.html
Created August 12, 2011 21:46
Simple JavaScript Particles
<html>
<head>
</head>
<body>
<canvas id="base" width="500" height="500" style="border: 1px solid #444; background: #000;"></canvas>
<script>
var elem = document.getElementById( 'base' );
var context = elem.getContext( '2d' );
var Sprite = function () {
@jmhobbs
jmhobbs / pptpd.sh
Created May 1, 2011 14:33
Ubuntu 11.04 AWS EC2 PPTPD Installer
#!/bin/bash
#
# This script will install and configure a PPTPD server on your Ubuntu box.
# I use this for a micro instance on Amazon EC2 as a quick, cheap (free!) VPN
#
# This script was tested with Natty Narwahl 11.04, ami-06ad526f
#
# Usage:
# wget https://gist.github.com/raw/950539/pptpd.sh
@jmhobbs
jmhobbs / daemon.py
Created April 13, 2011 05:09
Cooked version of Python daemon base script.
#!/usr/bin/env python
# Origin: http://www.jejik.com/articles/2007/02/a_simple_unix_linux_daemon_in_python/
# Cooked up a bit by @jmhobbs
import sys, os, time, errno, atexit
from signal import SIGTERM
class Daemon:
"""
# -*- coding: utf-8 -*-
# Copyright (c) 2010 John Hobbs
#
# http://github.com/jmhobbs/googlecode-irc-bot
#
# 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
# -*- coding: utf-8 -*-
# Copyright (c) 2010 John Hobbs
#
# http://github.com/jmhobbs/googlecode-irc-bot
#
# 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