Skip to content

Instantly share code, notes, and snippets.

View troystribling's full-sized avatar

Troy Stribling troystribling

  • San Francisco, CA
View GitHub Profile
@troystribling
troystribling / gist:2603108
Created May 5, 2012 15:01
Objective C Class Name as String
#import <objc/runtime.h>
@interface NSObject (Extensions)
- (NSString*)className;
@end
@implementation NSObject (Extensions)
@troystribling
troystribling / gist:2491439
Created April 25, 2012 17:18
Objective C Array Map
@interface NSArray (Extensions)
- (NSArray *)mapObjectsUsingBlock:(id (^)(id obj, NSUInteger idx))block;
@end
@implementation NSArray (Extensions)
- (NSArray *)mapObjectsUsingBlock:(id (^)(id obj, NSUInteger idx))block {
NSMutableArray *result = [NSMutableArray arrayWithCapacity:[self count]];
@troystribling
troystribling / symbolize_keys.rb
Created January 11, 2012 20:43
Recursive symbolize_keys
def symbolize_keys!(thing)
case thing
when Array
thing.each{|v| symbolize_keys!(v)}
when Hash
thing.symbolize_keys!
thing.values.each{|v| symbolize_keys!(v)}
end
end
@troystribling
troystribling / ebs_snap.rb
Created December 30, 2011 16:57
Take snaps of EBS volumes with Fog
#!/usr/bin/env ruby
require 'rubygems'
require 'fog'
config = YAML.load(File.read(ARGV[0]))
volumes_to_snap = YAML.load(File.read(ARGV[1]))
time = Time.now
puts "\nCreating snaps #{time.to_s}"
xmpp_pubsub_messages.xml
*** get user disc#info
<iq to='noone@somewhere.com' id='disco1' type='get'>
<query xmlns='http://jabber.org/protocol/disco#info'/>
</iq>
*** create user@somewhere.com pubsub root node (sent from account user@somewhere.com)
<iq id='29293' to='pubsub.somewhere.com' type='set' xmlns='jabber:client'>
@troystribling
troystribling / agent_xmpp_examples.rb
Created August 3, 2009 02:42
Agent XMPP Example Application
##########################################################################################################
require 'rubygems'
require "#{File.dirname(__FILE__)}/../../lib/agent_xmpp"
##########################################################################################################
# before filters
#.........................................................................................................
# only online contacts can send command messages
before :command => :all do
jid = params[:from]