Skip to content

Instantly share code, notes, and snippets.

View gertig's full-sized avatar

Andrew Gertig gertig

View GitHub Profile
@gertig
gertig / avatar_uploader.rb
Created July 11, 2012 21:25
Cloudinary and CarrierWave
class AvatarUploader < CarrierWave::Uploader::Base
# include CarrierWave::RMagick
# configure do |config|
# config.remove_previously_stored_files_after_update = false
# end
include Cloudinary::CarrierWave
process :convert => 'jpg' #converts all images to pngs
@gertig
gertig / appcrush.rb
Created June 30, 2012 03:37
Extract all assets (png, jpg, pdf) from an iPhone ap
#!/usr/bin/ruby -rubygems
#
# Point appcrush at an .ipa file from the iTunes AppStore and it
# - expands the zip file
# - finds all the images
# - runs pngcrush with the revert-iphone-optimizations option on each image
#
# Requirements Xcode with iOS SDK 3.2 or higher
#
# Usage: appcrush '/Users/boctor/Music/iTunes/Mobile Applications/iBooks.ipa'
@gertig
gertig / juggernaut_channels.rb
Created June 26, 2012 11:55 — forked from maccman/juggernaut_channels.rb
Sinatra Server Side Event streaming with private channels.
# Usage: redis-cli publish message.achannel hello
require 'sinatra'
require 'redis'
conns = Hash.new {|h, k| h[k] = [] }
Thread.abort_on_exception = true
get '/' do
@gertig
gertig / juggernaut.rb
Created June 26, 2012 11:51 — forked from maccman/juggernaut.rb
Sinatra Server Side Event streaming.
# Usage: redis-cli publish message hello
require 'sinatra'
require 'redis'
conns = []
get '/' do
erb :index
end
@gertig
gertig / ExampleClass.m
Created June 26, 2012 03:08 — forked from lukeredpath/ExampleClass.m
Macro for creating your "shared instance" using GCD
@implementation MySharedThing
+ (id)sharedInstance
{
DEFINE_SHARED_INSTANCE_USING_BLOCK(^{
return [[self alloc] init];
});
}
@end
@gertig
gertig / logToServer.m
Created June 6, 2012 15:12
Send some data to the server for logging purposes
#pragma mark - Logging User Session Info
- (void)logToServer:(NSString *)reason thisInfo:(NSDictionary *)data
{
UIDevice *device = [UIDevice currentDevice];
NSString *deviceName = [device model];
NSString *appVersion = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"];
NSString *userId = [NSString stringWithFormat:@"%d", self.getMyUserId];
NSString *liveEventId = [NSString stringWithFormat:@"%d", self.getEventId];
@gertig
gertig / user_agent.m
Created June 6, 2012 03:42
iOS Default User Agent
#pragma mark get user agent
+ (NSString *)defaultUserAgentString
{
@synchronized (self) {
if (!defaultUserAgent) {
NSBundle *bundle = [NSBundle bundleForClass:[self class]];
@gertig
gertig / XBeeRGBColor
Created April 5, 2012 02:12
XBee RGB Color picker
/*
XBeeCableReplacement.pde
Control the color of an RGB LED wirelessly via XBee.
Required (in addition to your Arduino):
(These items are found in the SparkFun XBee Wireless Kit Retail product
@gertig
gertig / XBeeSerialEcho.pde
Created April 5, 2012 02:11
XBeeSerialEcho Tutorial
/*
XBeeSerialEcho -- Simple sketch for demonstrating two-way XBee communication
Requires:
(These items are found in the SparkFun XBee Wireless Kit Retail product
or can be obtained individually.)
* 1 x SparkFun XBee Explorer USB
@gertig
gertig / 0_steps
Created March 31, 2012 20:26
VPS Setup and Deployment (Railscasts.com #335)
When building a new instance of Amazon EC2 choose quick-start-1 as the security group not default
#LOCALLY
$ capify .
$ chmod +x config/unicorn_init.sh
$ git add .
$ git commit -m "deployment configs"
If rebuilding an instance don't forget to remove the ssh keys