Skip to content

Instantly share code, notes, and snippets.


Mateus seanlilmateus

View GitHub Profile
View status_bar_view.rb
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
seanlilmateus / gist:974340
Created May 16, 2011
Using Obj-C Blocks from MacRuby with Ruby 1.9.2 Syntax
View gist:974340
# 1 # Processing enumerated arrays using two blocks
area = "Europe"
timeZoneNames = NSTimeZone.knownTimeZoneNames
areaArray = NSMutableArray.arrayWithCapacity 1
areaIndexes = timeZoneNames.indexesOfObjectsWithOptions NSEnumerationConcurrent,
passingTest: -> (obj, idx, stop) {
tmpStr = obj
tmpStr.hasPrefix area
tmpArray = timeZoneNames.objectsAtIndexes areaIndexes
View gist:1033832
class ForwardError
attr_accessor :pointer
@pointer = Pointer.new_with_type('@')
def self.to_pointer
def self.method_missing(method, *args)
seanlilmateus / NSObject+ProcObservation.h
Created Jul 3, 2011 — forked from nolanw/NSObject+ProcObservation.h
Slight alteration of Any Matuschak's BlockObservation for MacRuby.
View NSObject+ProcObservation.h
// NSObject+ProcObservation.h
// Version 1.0
// Andy Matuschak
// Public domain because I love you. Let me know how you use it.
// NTW 2009-Oct-21: Added selectors with an options argument.
// NTW 2009-Oct-30: Transplanted new observation key from MYUtilities's KVUtils.
seanlilmateus / nscoding.rb
Created Aug 25, 2011
how to use NSCoding with MacRuby
View nscoding.rb
framework 'Foundation'
class Note < NSObject
attr_accessor :title, :author, :published
def initialize(title, author, published)
@title, @author, @published = title, author, published
# protocol NSCoding
def initWithCoder aDecoder
View gist:1178900
george = lambda do
puts "george"
def fred
puts "fred"
def fire
seanlilmateus / filesystem_events.rb
Created Oct 10, 2011
Handling Filesystem Events with GCD and Macruby
View filesystem_events.rb
framework 'Foundation'
include Dispatch
#``O_EVTONLY`` is defined as ``0x8000`` in the OS X header files.
# instead of RDONLY flag I use the O_EVTONLY flag to open() the file, otherwise we'll prevent the
# volume that the file is on from being unmounted.
O_EVTONLY = 0x8000
seanlilmateus / gist:1360512
Created Nov 12, 2011
Drawing Fractal with MacRuby concurrently with Grand Central Dispatch
View gist:1360512
framework 'Foundation'
framework 'Cocoa'
class Grid < NSView
attr_accessor :tiles
def initWithFrame frame
@tiles = []
seanlilmateus / gist:1386468
Created Nov 22, 2011
Macruby Face Detection in Mac OS X Lion
View gist:1386468
framework 'Cocoa'
framework 'QuartzCore'
class NSColor
def toCGColor
colorRGB = self.colorUsingColorSpaceName NSCalibratedRGBColorSpace
components ={}
colorRGB.getRed components[0], green:components[1], blue:components[2], alpha:components[3]
seanlilmateus / gist:1427886
Created Dec 3, 2011
Video Recording using Macruby & AVFoundation Framework;
View gist:1427886
framework 'Cocoa'
framework 'AVFoundation'
# because we love blocks, we make NSTimer blocks :-)
class NSTimer
def self.scheduledTimerWithTimeInterval interval, repeats: repeat_flag, block: block
self.scheduledTimerWithTimeInterval interval,
target: self,
selector: 'executeBlockFromTimer:',
You can’t perform that action at this time.