Skip to content

Instantly share code, notes, and snippets.

View bradfordcp's full-sized avatar

Christopher Bradford bradfordcp

View GitHub Profile
@bradfordcp
bradfordcp / tunneler.rb
Created August 24, 2011 07:58
Setting up an SSH tunnel with Net::SSH::Gateway then working through that tunnel
require 'net/ssh'
require 'net/ssh/gateway'
# Connect to the gateway machine
gateway = Net::SSH::Gateway.new('host.to.tunnel.from', 'user.name')
# Open the tunnel (in this example we are using port 5900 locally)
gateway.open('host.to.tunnel.to', 22, 5900)
# SSH through our tunnel and grab the list of vault contents
@bradfordcp
bradfordcp / .gitignore
Created August 7, 2011 02:54
Scratch work on a neat idea
.DS_Store
@bradfordcp
bradfordcp / RemoteEntity.h
Created August 3, 2011 01:32
RemoteEntity Example - Assumes the AppDelegate has a connection to the ManagedObjectContext.
//
// RemoteEntity.h
//
// Created by Christopher Bradford on 5/6/10.
// Copyright 2010 INM United. All rights reserved.
//
@interface RemoteEntity : NSManagedObject
{
@bradfordcp
bradfordcp / blog_pusher.rb
Created July 13, 2011 22:40
Retrieve nodes from a D6 installation and push them to the services module on D7
#! /usr/bin/env ruby
require 'rubygems'
require 'uri'
require 'net/http'
require 'json'
require 'pp'
require 'mysql'
SERVER = "http://drupal.example.com/api/blog"
@bradfordcp
bradfordcp / gist:1068665
Created July 7, 2011 00:30
iPhone: Retrieve a list of all available fonts
for (NSString *family in [UIFont familyNames]) {
NSLog(@"Family: %@", family);
for (NSString *font in [UIFont fontNamesForFamilyName:family]) {
NSLog(@" - %@", font);
}
NSLog(@"");
}
@bradfordcp
bradfordcp / ruby-enterprise.spec
Created June 9, 2011 21:26 — forked from axisofentropy/ruby-enterprise.spec
Ruby Enterprise Edition RPM SPEC file. Does not include fast threading or libtcmalloc.
# Package Maintainer: Increment phusion_release to match latest release available
%define phusion_release 2011.03
%define _prefix /opt/ruby-enterprise
Summary: Ruby Enterprise Edition (Release %{phusion_release})
Name: ruby-enterprise
Vendor: Phusion.nl <info@phusion.nl>
Packager: Christopher Bradford <bradfordcp@gmail.com>
Version: 1.8.7
Release: 7%{?dist}
@bradfordcp
bradfordcp / proxy.php
Created May 25, 2011 22:30
PHP Proxy to a specified domain, used for retrieving .atom feeds from shopify and avoid cross-domain issues.
<?php
// Location where we are storing the cache
$CACHE_DIRECTORY = dirname(dirname(__FILE__)) ."/statics";
// Set the lifetime of cached pages
$CACHE_LIFETIME = (24 * 60 * 60); // 24 Hours * 60 Minutes (per hour) * 60 Seconds (per minute)
// Grab the URL to proxy, strip out the host as a security measure
$url = null;
@bradfordcp
bradfordcp / pre-commit
Created May 24, 2011 18:21
Pre-commit git hook to regenerate documentation and add it to the commit
inm-bradfordcp-mbp:some_folder bradfordcp$ cat .git/hooks/pre-commit
#!/bin/sh
#
# Regenerates documentation and adds it to the commit
#
echo
echo "Regenerating Documentation"
echo
rake doc:generate
echo
@bradfordcp
bradfordcp / parser.js
Created May 10, 2011 13:38
Converts the json version of the olson timezone database into MySQL tables. Here we have scoped the directories we are searching to certain continents, that logic may be removed in favor of just passing the root directory into process_dir().
#! /usr/bin/env node
// Require the filesystem library
var fs = require('fs');
// Connect to MySQL
var Client = require('mysql').Client, client = new Client();
client.user = 'rails';
client.connect();
client.query('USE scratch');
@bradfordcp
bradfordcp / pre-commit
Created February 10, 2011 15:17
Git pre-commit hook to generate documentation and add it to the commit, may be places within .git/hooks
#!/bin/sh
#
# Regenerates documentaion and adds it to the commite
#
# To enable this hook, rename this file to "pre-commit".
echo
echo "Regenerating Documentation"
echo
rake doc:generate
echo