Skip to content

Instantly share code, notes, and snippets.

View jdewind's full-sized avatar

Justin DeWind jdewind

  • LifeWorks
  • Grand Rapids
View GitHub Profile
@interface SomeClass
{
...
}
// Use 'assign' because a meta class is not subject to the normal retain/release lifecycle.
// It will exist until the application is terminated (Class Initialization -> Application Termination)
// regardless of the number of objects in the runtime that reference it.
@property (nonatomic, assign) id<ExternalUtility> externalUtility
@end
slow_connection () {
if [ -z $1 ]; then
echo "Bandwidth must be provided"
return
fi
default_port="80"
sudo ipfw pipe 1 config bw $1KByte/s
sudo ipfw add 1 pipe 1 src-port ${2:-$default_port}
@implementation MyController
@synthesize applicationModel = _applicationModel;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
self.applicationModel = [[Objection globalInjector] getObject:[WCMyControllerApplicationModel class]];
self.applicationModel.controller = self;
self.title = NSLocalizedString(@"My Title", @"");
@interface ObjectionProvider : NSObject {
}
- (id)getObject:(Class)theClass;
@end
@implementation ObjectionProvider
objection_register_singleton(ObjectionProvider)
// Example Discussion APN Payload
{
"device_tokens": ["<Tokens of Users in Group>"],
"aps": {"alert": "<Person> posted a message on <Group>"},
"type": 0 // 0 = Discussion, 1 = Comment
"DiscussionAlert": {
"groupID": 122,
"groupName": "The Name"
}
}
require 'real_growl'
=> true
>> rg("Check out", ["Real", "Growl"], :icon => "/path/to/a/picture.jpg")
>> rg("Google", ["Real", "Growl"], :icon => "http://www.google.com/logos/stpatricks_d4gwinner_eo09.gif")
=> nil
>> Kernel.rg_sticky = false
=> false
>> Kernel.rg_priority = 3
=> 3
>> require 'real_growl'
>> my_own_application = RealGrowl::Application.new("AppName")
=> #<RealGrowl::Application:0x1018eb6b8>
>> my_own_application.notify(:title => "Title", :description => "Desc", :priority => 0, :sticky => true, :icon => "/path/to/image.png")
require 'real_growl_api'
require 'pp'
module RG
module ClassMethods
attr_accessor :rg_sticky, :rg_priority, :rg_icon
end
module InstanceMethods
static void *kBindingContext = &kBindingContext;
@implementation MySlider
@synthesize requestModel;
@synthesize percent;
- (id)init {
if((self = [super init])) {
[requestModel addObserver:self forKeyPath:@"percentUploaded" options:0 context:kBindingContext];
@implementation MySlider
@synthesize requestModel;
@synthesize percent;
- (id)init {
if((self = [super init])) {
[requestModel bindProperty:@"percent" onTarget:self toKeyPath:@"percentUploaded"];
}
return self;
}