Skip to content

Instantly share code, notes, and snippets.

View seanlilmateus's full-sized avatar

Mateus seanlilmateus

View GitHub Profile
@seanlilmateus
seanlilmateus / face_detector.rb
Created December 7, 2011 13:58 — forked from pvinis/face_detector.rb
run with "macruby face_detector.rb" or "macruby face_detector.rb https://fbcdn-sphotos-a.akamaihd.net/hphotos-ak-snc7/304055_10150415385415891_522505890_10347873_1682210515_n.jpg?dl=1" for a photo of me with woody and buzz lightyear :p
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],
@seanlilmateus
seanlilmateus / gist:1448227
Created December 8, 2011 19:43
macruby video face detector
#!/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
@seanlilmateus
seanlilmateus / gist:1461269
Created December 11, 2011 16:00
Macruby isight animated wall; press q to exit and any key to animate the wall
#!/usr/local/bin/macruby
framework 'QuartzCore'
framework 'AVFoundation'
class NSColor
def toCGColor
# approach #2
components = [redComponent, greenComponent, blueComponent, alphaComponent]
color_space = CGColorSpaceCreateWithName(KCGColorSpaceGenericRGB)
@seanlilmateus
seanlilmateus / gist:1472281
Created December 13, 2011 14:21 — forked from alskipp/gist:1469659
Macruby live(ish) moustachification in Mac OS X Lion.
framework 'Cocoa'
framework 'avfoundation'
class FaceDetectionDelegate
attr_accessor :window
def applicationDidFinishLaunching(aNotification)
@tache_array = []
detectorOptions = {CIDetectorAccuracy: CIDetectorAccuracyLow}
@seanlilmateus
seanlilmateus / objc-macruby.m
Created December 18, 2011 08:55 — forked from Watson1978/objc-macruby.m
Objective-C + MacRuby
#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];
@seanlilmateus
seanlilmateus / gist:1492828
Created December 18, 2011 09:24 — forked from masui/gist:1335617
Find large Microsoft Word documents on Mac with Spotlight+MacRuby
#
# List large Microsoft Word files upto 10
#
framework 'Cocoa'
def finish(notification)
max = @query.resultCount
max = 10 if max > 10
(0...max).each { |i|
@seanlilmateus
seanlilmateus / gist:1536136
Created December 29, 2011 20:51
macruby core animation Fireworks, have a nice macruby new year
#!/usr/local/bin/macruby
framework 'Cocoa'
framework 'QuartzCore'
framework 'CoreGraphics' # Mountain Lion Update
class FireworkDelegate
attr_accessor :window
def initWithURL(url)
case url
@seanlilmateus
seanlilmateus / PaddedTextFieldCell.rb
Created January 2, 2012 15:04 — forked from noeticpenguin/PaddedTextFieldCell.rb
Awesome Text Fields in MacRuby
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
@seanlilmateus
seanlilmateus / gist:1669249
Created January 24, 2012 09:30
putting data to a NSComboBox manually in Macruby
#!/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)
@seanlilmateus
seanlilmateus / video_santafy.rb
Created April 23, 2012 10:31 — forked from alskipp/video_santafy.rb
macruby video Santa-fy (with support for multiple Santas)
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")