Skip to content

Instantly share code, notes, and snippets.

View trevorsheridan's full-sized avatar

Trevor Sheridan trevorsheridan

View GitHub Profile
@trevorsheridan
trevorsheridan / gist:1528988
Created December 28, 2011 18:18
Iterator that takes a single dimensional array as input and produces a multidimensional array of groups of three
<?php
$lc = sizeof($list);
for ($i = 0; $i < ( ($lc % 3 == 0) ? $lc : ($lc - ($lc % 3) + 3) ); $i = $i + 3) { // This loop defines the group you're in, $i will always be divisible by 3.
for ($si = 0; $si < ( ($i + 3 < $lc) ? 3 : ($lc - $i) ); $si++) // Determine which item is next in this group.
$a[] = list[$i + $si];
$groups[] = $a;
}
@trevorsheridan
trevorsheridan / org.postgresql.postgresqld.plist
Created February 29, 2012 19:17
PostgreSQL launchd configuration
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Disabled</key>
<false/>
<key>Label</key>
<string>org.postgresql.postgresqld.plist</string>
<key>ProgramArguments</key>
<array>
@trevorsheridan
trevorsheridan / Installing PostgreSQL on Mac OS X Lion
Created February 29, 2012 19:28
Installing PostgreSQL on Mac OS X Lion
Postgres manual located here: http://www.postgresql.org/docs/8.4/interactive/index.html
These instructions should work for Postgres 8 and 9
1. INSTALL
$ cd ~/source
$ ftp http://ftp.postgresql.org/pub/source/v8.4.11/postgresql-8.4.11.tar.gz
$ tar -zxvf postgresql-8.4.11.tar.gz
$ rm -r postgresql-8.4.11.tar.gz
$ cd postgresql-8.4.11
$ ./configure
@trevorsheridan
trevorsheridan / Installing GNU Wget on Mac OSX Lion
Created February 29, 2012 20:22
Installing GNU Wget 1.13.4 on Mac OSX Lion
$ cd ~/source
$ ftp http://ftp.gnu.org/gnu/wget/wget-1.13.4.tar.gz
$ tar -zxvf wget-1.13.4.tar.gz
$ rm -r wget-1.13.4.tar.gz
$ cd wget-1.13.4/
$ ./configure --prefix=/usr/local --with-ssl=openssl
$ make
$ sudo make install
@trevorsheridan
trevorsheridan / Installing CMake on Mac OSX Lion
Created March 1, 2012 08:17
Installing CMake 2.8.7 on Mac OSX Lion
$ cd ~/source
$ ftp http://www.cmake.org/files/v2.8/cmake-2.8.7.tar.gz
$ tar -zxvf cmake-2.8.7.tar.gz
$ rm -r cmake-2.8.7.tar.gz
$ cd cmake-2.8.7
$ ./bootstrap
$ make
$ sudo make install
@trevorsheridan
trevorsheridan / Installing TagLib on Mac OSX Lion
Created March 1, 2012 08:24
Installing TagLib 1.7.1 on Mac OSX Lion
$ cd ~/source
$ ftp http://developer.kde.org/~wheeler/files/src/taglib-1.7.1.tar.gz
$ tar -zxvf taglib-1.7.1.tar.gz
$ rm -r taglib-1.7.1.tar.gz
$ cd taglib-1.7.1
$ cmake -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_OSX_DEPLOYMENT_TARGET=10.6 \
-DCMAKE_OSX_ARCHITECTURES="i386;x86_64" \
-DENABLE_STATIC=ON \
@trevorsheridan
trevorsheridan / Installing LAME on Mac OSX Lion
Created March 1, 2012 09:00
Installing LAME on Mac OSX Lion
Getting the Source
$ cd ~/source
$ curl -L -O http://downloads.sourceforge.net/project/lame/lame/3.99/lame-3.99.5.tar.gz
$ tar -zxvf lame-3.99.5.tar.gz
$ rm -r lame-3.99.5.tar.gz
$ cd lame-3.99.5
Installing
$ ./configure
$ make
(function() {
var Detective = window.Detective = Backbone.Base.extend({
initialize: function() {
snack.publisher(this);
this.ua = window.navigator.userAgent;
return this;
},
@trevorsheridan
trevorsheridan / http-vhosts.conf
Created July 12, 2012 02:33
Apache virtual host file for mobile development on a LAN. Supports named based hosting and access through port 8000 (10.0.1.3:8000).
#
# Virtual Hosts
#
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:http://httpd.apache.org/docs/2.2/vhosts/>
@trevorsheridan
trevorsheridan / size.sh
Created August 1, 2012 09:46
Calculate the dimensions of a bitmap given a rotation and rotation width.
#!/bin/bash
temp="/tmp/size-"$(date +"%s")"-tmp.png"
em=10
convert $1 -rotate $2 $temp
convert $temp -scale $3 -rotate $(echo "$2 * -1" | bc) -trim -shave 2x2 $temp
identify -format "dimensions: %w x %h pixels\nwidth: %[fx:w/$em]em;\nheight: %[fx:h/$em]em;" $temp
rm -rf $temp