This file contains 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 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 | |
framework 'QuartzCore' | |
framework 'AVFoundation' | |
class NSTimer | |
def self.scheduledTimerWithTimeInterval interval, repeats: repeat_flag, block: block | |
self.scheduledTimerWithTimeInterval interval, | |
target: self, | |
selector: 'executeBlockFromTimer:', | |
userInfo: block, | |
repeats: repeat_flag |
This file contains 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 | |
framework 'QuartzCore' | |
framework 'AVFoundation' | |
class NSColor | |
def toCGColor | |
# approach #2 | |
components = [redComponent, greenComponent, blueComponent, alphaComponent] | |
color_space = CGColorSpaceCreateWithName(KCGColorSpaceGenericRGB) |
This file contains 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' | |
framework 'avfoundation' | |
class FaceDetectionDelegate | |
attr_accessor :window | |
def applicationDidFinishLaunching(aNotification) | |
@tache_array = [] | |
detectorOptions = {CIDetectorAccuracy: CIDetectorAccuracyLow} |
This file contains 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 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
# | |
# List large Microsoft Word files upto 10 | |
# | |
framework 'Cocoa' | |
def finish(notification) | |
max = @query.resultCount | |
max = 10 if max > 10 | |
(0...max).each { |i| |
This file contains 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 | |
framework 'Cocoa' | |
framework 'QuartzCore' | |
framework 'CoreGraphics' # Mountain Lion Update | |
class FireworkDelegate | |
attr_accessor :window | |
def initWithURL(url) | |
case url |
This file contains 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 PaddedTextFieldCell < NSTextFieldCell | |
def drawingRectForBounds(cellFrame) | |
super | |
result = cellFrame | |
padding_left = (result.size.width / 16).round # to make sure text is clear | |
padding_top = (result.size.height / 4).round | |
result.origin.x += padding_left | |
result.origin.y += padding_top |
This file contains 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 | |
framework 'Cocoa' | |
class TestDelegate | |
attr_accessor :window | |
def applicationDidFinishLaunching(notification) | |
@window.delegate = self | |
# set the content view size and Position | |
combo_box_rect = NSMakeRect(165, 150, 170, 25) |
This file contains 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' | |
framework 'CoreGraphics' # Mountain Lion Update | |
framework 'AVFoundation' | |
class Santa | |
t_url = NSURL.URLWithString("http://dl.dropbox.com/u/349788/mustache.png") | |
t_source = CGImageSourceCreateWithURL t_url, nil | |
@@tache = CGImageSourceCreateImageAtIndex t_source, 0, nil | |
g_url = NSURL.URLWithString("http://dl.dropbox.com/u/349788/glasses.png") |