Skip to content

Instantly share code, notes, and snippets.

View mheap's full-sized avatar
:octocat:
Follow me on Twitter @mheap

Michael Heap mheap

:octocat:
Follow me on Twitter @mheap
View GitHub Profile
<?php
## PHP Version of osfameron's fixed width table parser
## http://github.com/osfameron/misc-opensource/tree/7317cbb59edb0ec9a5e023049d7c6b423d453d7f/parse-table
class row{
private $_cols = array();
private $_parsed = array();
private $_params = array();
svn export http://svn.ellislab.com/CodeIgniter/trunk/ && mv trunk html && mv html/system . && mv system/application/ . && NEWHOST=`echo $PWD | awk -F"/" '{ print $4 }'` && sed -i s/example\.com/$NEWHOST/ application/config/config.php
@mheap
mheap / oauth.php
Last active August 30, 2021 09:24
Example of using PECL's OAuth for PHP
<?php session_start();
define('OAUTH_CONSUMER_KEY', '');
define('OAUTH_CONSUMER_SECRET', '');
define('OAUTH_REQUEST_URL', 'https://api.twitter.com/oauth/request_token');
define('OAUTH_ACCESS_URL', 'https://api.twitter.com/oauth/access_token');
define('OAUTH_AUTHORISE_URL', 'https://api.twitter.com/oauth/authorize');
define('API_URL','http://api.twitter.com/1/');
@mheap
mheap / newmac.sh
Created October 11, 2011 18:43
Change MAC Address OSX
NEWMAC=$1
echo $NEWMAC
INTERFACE='en0'
echo "Before:"
ifconfig $INTERFACE | grep ether
/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -z
ifconfig $INTERFACE ether $NEWMAC
echo "After:"
ifconfig $INTERFACE | grep ether
@mheap
mheap / gist:1362663
Created November 13, 2011 20:45
Connect to a remote mySQL Server over SSH
ssh -fNg -L3310:127.0.0.1:3306 user@server.domain.ext
mysql -h127.0.0.1 -P 3310 -u user -p db_name
@mheap
mheap / FileDupe.py
Created April 17, 2012 10:48
Find duplicate files in a given directory
#!/usr/bin/python
"""
Find duplicate files from a given root in the directory hierarchy of a given size
"""
import os
import glob
import sys
import hashlib
import optparse
import timeit
@mheap
mheap / README.md
Created May 20, 2012 20:52
JST Handlebars templates

I really struggled to get this working. I initially found https://gist.github.com/1990736 but it wasn't working for me, so I decided to throw it out, copy the original JST task and adapt it.

The jsthb helper has been lifted entirely from https://gist.github.com/1990736, the rest I've hacked at myself. This has been tested with both ajax loading and a release build.

@mheap
mheap / filter-branch.sh
Created September 9, 2012 19:50
Remove a file from a repo and delete all it's history
#!/bin/bash
set -o errexit
# Author: David Underhill
# Script to permanently delete files/folders from your git repository. To use
# it, cd to your repository's root and then run the script with a list of paths
# you want to delete, e.g., git-delete-history path1 path2
if [ $# -eq 0 ]; then
exit 0
@mheap
mheap / pr.md
Created November 27, 2012 11:48 — forked from piscisaureus/pr.md
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@mheap
mheap / gist:4985392
Created February 19, 2013 12:22
Convert multidimensional array to 2D array with dot notation keys (via http://stackoverflow.com/a/10424516)
<?php
$ritit = new RecursiveIteratorIterator(new RecursiveArrayIterator($myArray));
$result = array();
foreach ($ritit as $leafValue) {
$keys = array();
foreach (range(0, $ritit->getDepth()) as $depth) {
$keys[] = $ritit->getSubIterator($depth)->key();
}
$result[ join('.', $keys) ] = $leafValue;
}