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 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 |
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
# 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 |
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 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) |
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
// | |
// NSObject+ProcObservation.h | |
// Version 1.0 | |
// | |
// Andy Matuschak | |
// [email protected] | |
// 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. |
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 '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 |
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
george = lambda do | |
puts "george" | |
end | |
def fred | |
puts "fred" | |
end | |
def fire | |
yield |
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 '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 |
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 'Foundation' | |
framework 'Cocoa' | |
class Grid < NSView | |
attr_accessor :tiles | |
def initWithFrame frame | |
super(frame) | |
@tiles = [] | |
self |
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 '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] |
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 '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:', |
OlderNewer