Skip to content

Instantly share code, notes, and snippets.

@phillbaker
phillbaker / Gemfile
Last active December 11, 2015 07:18
Rails Gemfile
source 'https://rubygems.org'
RAILS_VERSION = '~> 3.2.8'
gem 'activesupport', RAILS_VERSION, :require => 'active_support'
gem 'actionpack', RAILS_VERSION, :require => 'action_pack'
gem 'actionmailer', RAILS_VERSION, :require => 'action_mailer'
gem 'activeresource', RAILS_VERSION, :require => 'active_resource'
gem 'railties', RAILS_VERSION, :require => 'rails'
gem 'tzinfo', '~> 0.3.32'
@phillbaker
phillbaker / lmu.m
Created November 17, 2012 20:23
Macbook ambient light sensor data
// Compile with $ gcc -o lmutracker lmu.m -framework IOKit -framework CoreFoundation -framework Foundation
// Usage: ./lmu [now]
// Prints out the value from the ambient light sensor and the back light LED every 1/10 of a second. Optionally print just one value.
// Inspired by the code found at
// http://google-mac-qtz-patches.googlecode.com/svn-history/r5/trunk/AmbientLightSensor
// and http://osxbook.com/book/bonus/chapter10/light/
// and http://en.wikipedia.org/wiki/Wikipedia:Reference_desk/Archives/Computing/2010_February_10#Mac_OS_X_keyboard_backlight_drivers
// http://forums.macrumors.com/showthread.php?t=1133446
#include <stdio.h>
@phillbaker
phillbaker / index.html
Last active October 12, 2015 02:57
HTML5 starter with boostrap cdn + jquery cdn
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title></title>
<link href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.2.2/css/bootstrap-combined.min.css" rel="stylesheet">
<style>
/*Styles*/
</style>
@phillbaker
phillbaker / gist:3918047
Created October 19, 2012 12:39
DataMapper semi-equivalent of ActiveRecord's reflect_on_all_associations method
# Originally http://pastie.org/pastes/233178
def reflect_on_all_associations
# Datamapper, you're crazy...
relationships.map { |name, relationship|
#TODO :has_and_belongs_to_many
if relationship.options[:min].nil?
macro = :belongs_to
if relationship.options[:class_name]
# In a belongs_to, the side with the class name uses
# the parent model, but child key for the foreign key...
@phillbaker
phillbaker / DataManager.h
Created August 7, 2012 15:43 — forked from rojotek/DataManager.h
Core Data singleton manager class capable of being run from a static library - updated for ARC.
// DataManager.h
#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>
extern NSString * const DataManagerDidSaveNotification;
extern NSString * const DataManagerDidSaveFailedNotification;
@interface DataManager : NSObject {
}
@phillbaker
phillbaker / eventmachine.cheat
Created August 5, 2012 20:15
EventMachine Cheat Sheet
EventMachine
============
Installation:
$ gem install eventmachine
Synchronous Ruby code (Not EM appropriate):
ret = operation(); do_something_with(ret)
Evented, asynchronous code (EM appropriate):
@phillbaker
phillbaker / LLRoundSwitch.podspec
Created July 31, 2012 16:10
LLRoundSwitch v1.0.1
Pod::Spec.new do |s|
s.name = 'LLRoundSwitch'
s.version = '1.0.1'
s.license = 'MIT'
s.summary = 'Customizable replacement for UISwitch with ARC support'
s.homepage = 'http://github.com/LordLobo/LLRoundSwitch'
s.author = { 'LordLobo' => 'dan.giralte@gmail.com' }
s.source = { :git => 'http://github.com/LordLobo/LLRoundSwitch.git', :commit => 'ae2fdb6d7bc7b6b0f1e96f4aadd69f7246477422' }
s.description = 'Customize the on/off text, the color of the background, supports event delegation, all with ARC in-mind.'
s.platform = :ios
@phillbaker
phillbaker / MJPopupViewController.podspec
Created July 26, 2012 21:53
MJPopupViewController v0.0.0
Pod::Spec.new do |s|
s.name = 'MJPopupViewController'
s.version = '0.0.0'
s.platform = :ios
s.summary = 'A UIViewController Category to display a ViewController as a popup with different transition effects.'
s.homepage = 'https://github.com/martinjuhasz/MJPopupViewController'
s.author = { 'Martin Juhasz' => 'martin@martinjuhasz.de' }
s.source = { :git => 'https://github.com/martinjuhasz/MJPopupViewController.git', :commit => '45ac970c38ed5240a111b9047cc39b5413d42f6e' }
s.source_files = 'Source'
s.frameworks = 'QuartzCore', 'CoreGraphics'
@phillbaker
phillbaker / Facebook-iOS-SDK.podspec
Created July 26, 2012 21:37
Facebook-iOS-SDK v3.0.6.b
Pod::Spec.new do |s|
s.name = 'Facebook-iOS-SDK'
s.version = '3.0.6.b'
s.platform = :ios
s.license = 'Apache License, Version 2.0'
s.summary = 'The iOS SDK provides Facebook Platform support for iOS apps.'
s.description = 'The Facebook iOS SDK enables you to access the Facebook Platform APIs including the Graph API, FQL, and Dialogs.'
s.homepage = 'http://developers.facebook.com/docs/reference/iossdk'
s.author = 'Facebook'
s.source = { :git => 'https://github.com/facebook/facebook-ios-sdk.git', :tag => 'sdk-version-3.0.6.b' }
@phillbaker
phillbaker / gist:3041093
Created July 3, 2012 17:08
Auto-incrementing build numbers in Xcode 4.3 (based on http://davedelong.com/node/37)
#!/bin/bash
# Set the marketing version of the project.
# Take the number from git and apply it to the project.
# Any "v" prepended to the git tag will be removed.
# Get the current release description from git.
git_version=`git describe --tags`
# Check to see if the tag starts with with "v", and remove if so.