This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/bin/macruby | |
# This example is done with MacRuby and the UIKit framework for Mac OS X | |
# http://chameleonproject.org/ | |
# https://github.com/BigZaphod/Chameleon/ | |
framework 'Cocoa' | |
framework "UIKit" # garbage collected version, the current version of Chameleon ist not known to be GC-safe | |
################### |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class StatusBarView < NSView | |
attr_reader :progressIndicator, :statusBarItem | |
def initWithStatusBarItem(item) | |
bar = item.statusBar | |
if initWithFrame([[0,0], [bar.thickness, bar.thickness]]) | |
@statusBarItem = item | |
@highlight = false | |
origin, size = frame.origin, frame.size |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env macruby | |
framework 'Foundation' | |
framework 'AppKit' | |
class Person | |
def initWithCoder(decoder) | |
# empty implementation needed for ancient iChat conversations | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Foundation/Foundation.h> | |
@interface NSDictionary (QueryStringBuilder) | |
- (NSString *)queryString; | |
@end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# From https://gist.github.com/778535 | |
# In turn based on http://www.natontesting.com/2010/01/11/updated-script-to-list-all-cucumber-step-definitions/ | |
desc "List all available steps" | |
task :steps do | |
require 'hirb' | |
extend Hirb::Console | |
features_dir = "features" | |
step_candidates = Dir.glob(File.join(features_dir,'**/*.rb')) | |
# Follow all the gem requires, and identify which files have steps in them |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@implementation MySharedThing | |
+ (id)sharedInstance | |
{ | |
DEFINE_SHARED_INSTANCE_USING_BLOCK(^{ | |
return [[self alloc] init]; | |
}); | |
} | |
@end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Foundation/Foundation.h> | |
#import <dispatch/dispatch.h> | |
#import "MAZeroingWeakRef.h" | |
@interface KBMultiDispatchSource : NSObject | |
{ | |
dispatch_source_t _dispatch; | |
dispatch_queue_t _queue; | |
dispatch_source_type_t _type; | |
CFMutableDictionaryRef _eventObservers; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'benchmark' | |
Benchmark.bm(5) do |x| | |
str = "MacRuby is an implementation of Ruby 1.9" | |
x.report "Ruby" { | |
str.match(/([^ ]+)/) | |
#p $1 | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% DYLD_LIBRARY_PATH=~/src/macruby-master sudo ./methods.d -c "/Users/watson/src/macruby-master/macruby /Users/watson/tmp/t.rb" | |
"a" | |
-> _GLOBAL__I__ZN12_GLOBAL__N_115ForceJITLinkingE | |
<- _GLOBAL__I__ZN12_GLOBAL__N_115ForceJITLinkingE = 0x1 | |
-> __static_initialization_and_destruction_0(int, int) | |
<- __static_initialization_and_destruction_0(int, int) = 0x1 | |
-> start | |
-> main | |
-> ruby_sysinit | |
<- ruby_sysinit = 0x3f |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Foundation/Foundation.h> | |
#import <objc/runtime.h> | |
#import <MacRuby/MacRuby.h> | |
@interface NSObject (MRAssociatedObjects) | |
- (id)associatedObjectForSymbol:(NSString *)rubySymbolName; | |
- (void)setAssociatedObject:(id)value forSymbol:(NSString *)rubySymbolName; | |
@end | |
@implementation NSObject (MRAssociatedObjects) |