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 RemoveMethodHook < Exception; end | |
class Module | |
def before_method(name, &new_method) | |
raise ArgumentError unless block_given? | |
old_method = instance_method(name) rescue nil | |
# new_method = Proc.new | |
unless old_method.nil? | |
define_method(name) do |*args| |
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 NSObject (RegisterObserverAdditions) | |
-(void) registerObserver:(NSObject *)observer | |
forKeyPath:(NSString *)keyPath | |
options:(NSKeyValueObservingOptions)options | |
context:(void *)context; |
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
// | |
// TransitionController.h | |
// | |
// Created by XJones on 11/25/11. | |
// | |
#import <UIKit/UIKit.h> | |
@interface TransitionController : UIViewController |
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
framework 'Cocoa' | |
class NSColor | |
def toCGColor | |
color_RGB = colorUsingColorSpaceName(NSCalibratedRGBColorSpace) | |
## approach #1 | |
# components = Array.new(4){Pointer.new(:double)} | |
# color_RGB.getRed(components[0], | |
# green: components[1], | |
# blue: components[2], |
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 <MacRuby/MacRuby.h> | |
int main(void) | |
{ | |
id ruby; | |
id foo; | |
ruby = [[MacRuby sharedRuntime] evaluateFileAtPath:@"test.rb"]; | |
foo = [ruby performRubySelector:@selector(main:) withArguments:@"from Objc", NULL]; |
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
# | |
# Datastore.rb | |
# A singleton class to manage a MacRuby application's data storage requirements. | |
# | |
# Chris Powell, [email protected], http://cbpowell.wordpress.com | |
# | |
# This work is licensed under a Creative Commons Attribution 3.0 Unported License. | |
# http://creativecommons.org/licenses/by/3.0/ | |
# | |
# For usage and discussion, see http://cbpowell.wordpress.com/category/macruby/ |
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
Open "/Users/<UserName>/Library/Application Support/CodeRunner/Languages/5/compile.sh" | |
Change this line: | |
gcc "$1" -o "$compname" -finput-charset=${enc[$2]} -ObjC $3 | |
to | |
clang "$1" -o "$compname" -finput-charset=${enc[$2]} -ObjC $3 |
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 FolderListCell : CPView | |
{ | |
CPString folderNameText; | |
CPImage icon; | |
CPImageView iconView; | |
CPTextField label; | |
BOOL isSelected; | |
JSObject folderObject; | |
} |
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
# Helper function that returns a number with its correct indefinite article | |
# e.g. number_with_indefinite_article(10) #=> "a 10" | |
# e.g. number_with_indefinite_article(80, "$") #=> "an $80" | |
def number_with_indefinite_article(number, prefix=nil) | |
[indefinite_article_for_number(number), " ", prefix, number].compact.join | |
end | |
# Helper function that returns the correct indefinite article for a number | |
# e.g. indefinite_article_for_number(10) #=> "a" | |
# e.g. indefinite_article_for_number(80) #=> "an" |