Skip to content

Instantly share code, notes, and snippets.

Mateus seanlilmateus

Block or report user

Report or block seanlilmateus

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
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
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
def self.new
@pointer = Pointer.new_with_type('@')
self
end
def self.to_pointer
@pointer
end
def self.method_missing(method, *args)
@seanlilmateus
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
// andy@andymatuschak.org
// 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
seanlilmateus / nscoding.rb
Created Aug 25, 2011
how to use NSCoding with MacRuby
View nscoding.rb
#!/usr/local/bin/macruby
framework 'Foundation'
class Note < NSObject
attr_accessor :title, :author, :published
def initialize(title, author, published)
self.conformsToProtocol(Protocol.protocolWithName('NSCoding'))
@title, @author, @published = title, author, published
# protocol NSCoding
end
def initWithCoder aDecoder
View gist:1178900
george = lambda do
puts "george"
end
def fred
puts "fred"
end
def fire
yield
@seanlilmateus
seanlilmateus / filesystem_events.rb
Created Oct 10, 2011
Handling Filesystem Events with GCD and Macruby
View filesystem_events.rb
#!/usr/local/bin/macruby
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
seanlilmateus / gist:1360512
Created Nov 12, 2011
Drawing Fractal with MacRuby concurrently with Grand Central Dispatch
View gist:1360512
#!/usr/local/bin/macruby
framework 'Foundation'
framework 'Cocoa'
class Grid < NSView
attr_accessor :tiles
def initWithFrame frame
super(frame)
@tiles = []
self
@seanlilmateus
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 = Array.new(4){Pointer.new(:double)}
colorRGB.getRed components[0], green:components[1], blue:components[2], alpha:components[3]
@seanlilmateus
seanlilmateus / gist:1427886
Created Dec 3, 2011
Video Recording using Macruby & AVFoundation Framework;
View gist:1427886
#!/usr/local/bin/macruby
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.