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 / 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]
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 / 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}"
@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 / 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 / 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:2603949
Created May 5, 2012 16:47
Load UIView from NIB
#import "NSObject+Extensions.h"
@interface UIView (Extensions)
+ (UIView*)loadView:(Class)_viewClass;
@end
@implementation UIView (Extensions)
@troystribling
troystribling / ParameterSliderView.h
Created May 26, 2012 22:11
UIPanGesture Slider Control
#import <UIKit/UIKit.h>
@protocol ParameterSliderViewDelegate;
@interface ParameterSliderView : UIView
@property(nonatomic, weak) id<ParameterSliderViewDelegate> delegate;
@property(nonatomic, strong) UIView* parameterView;
@property(nonatomic, strong) UIView* parameterViewBorder;
@property(nonatomic, strong) UIPanGestureRecognizer* panGesture;
@troystribling
troystribling / UIImage+Extensions.h
Created May 28, 2012 00:18
Blank UIImage with Specified Color
#import <Foundation/Foundation.h>
@interface UIImage (Extensions)
+ (UIImage*)blankImage:(CGSize)_size;
+ (UIImage*)blankImage:(CGSize)_size withColor:(UIColor*)_color;
@end
@troystribling
troystribling / gist:2936763
Created June 15, 2012 14:33
Set Title of Terminal Window
function settitle() { echo -ne "\e]2;$@\a\e]1;$@\a"; }