This file contains hidden or 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
| # | |
| # AppDelegate.rb | |
| # tweet | |
| # | |
| # Created by watson on 2012/07/27. | |
| # | |
| class AppDelegate | |
| attr_accessor :window | |
| def applicationDidFinishLaunching(a_notification) |
This file contains hidden or 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
| # | |
| # AppDelegate.rb | |
| # notify | |
| # | |
| # Created by watson on 2012/07/26. | |
| # | |
| module Notification | |
| module_function | |
| def send(title, text) |
This file contains hidden or 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
| # -*- coding: utf-8 -*- | |
| # MacRuby - Dispatch::Source のサンプル | |
| # 変更を監視するファイル | |
| path = File.expand_path "~/test.txt" | |
| gcdque = Dispatch::Queue.new('sample') | |
| gcdsem = Dispatch::Semaphore.new(0) | |
| fmask = Dispatch::Source::VNODE_DELETE | Dispatch::Source::VNODE_WRITE |
This file contains hidden or 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 Foo | |
| attr_accessor :name | |
| def initialize | |
| @name = UILabel.alloc.initWithFrame([[0, 0], [10, 10]]) | |
| end | |
| end | |
| class Bar < UITableViewCell | |
| attr_accessor :name |
This file contains hidden or 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/bin/env macruby -wKU | |
| framework 'Foundation' | |
| ## first example reject works great | |
| new_array = ["test", "test 1", "Test 2", "Test 3", 10].reject {|test| test.is_a?(Fixnum) } | |
| p new_array | |
| ## second example it still showing tweets with iso_language_code == en |
This file contains hidden or 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 RSS | |
| def parse(url) | |
| @url = url | |
| @self = self | |
| Thread.start do | |
| #Dispatch::Queue.concurrent.async do | |
| @xml = NSXMLParser.alloc.initWithContentsOfURL(@url) | |
| @xml.delegate = @self | |
| @xml.parse | |
| end |
This file contains hidden or 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
| MacRuby 0.12 is now available. | |
| What's new in this release (since 0.10): | |
| - Improve stability and compatibility by total 1168 commits | |
| - Changed RUBY_AUTHOR to "The MacRuby Team" | |
| - Add support for XCode 4.3 | |
| - Drop support for XCode 4.2 and earlier | |
| - Upgrade to RubyGems 1.8.20 | |
| - Upgrade to Rake 0.9.2.2 | |
| - Add the --codesign option to macruby_deploy |
This file contains hidden or 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
| # -*- coding: utf-8 -*- | |
| require 'benchmark' | |
| str_ascii = "abcdefghij" * 100000 | |
| str_utf8 = "あいうえお" * 100000 | |
| Benchmark.bm(10) do |x| | |
| x.report "ascii" do | |
| 1000.times do | |
| str_ascii.length | |
| end |
This file contains hidden or 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" | |
| require 'pp' | |
| class RSS | |
| def parse(url, | |
| delegate: delegate, | |
| selector: callback) | |
| @delegate = delegate | |
| @callback = callback |
This file contains hidden or 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
| # -*- coding: utf-8 -*- | |
| require 'rubygems' | |
| require 'ruby-growl' | |
| g = Growl::GNTP.new "localhost", "test" | |
| g.add_notification "test" | |
| g.register | |
| g.notify "test", "test" |