Skip to content

Instantly share code, notes, and snippets.

View Watson1978's full-sized avatar

Shizuo Fujita Watson1978

View GitHub Profile
@Watson1978
Watson1978 / AppDelegate.rb
Created July 27, 2012 02:47
MacRuby : NSSharingService
#
# AppDelegate.rb
# tweet
#
# Created by watson on 2012/07/27.
#
class AppDelegate
attr_accessor :window
def applicationDidFinishLaunching(a_notification)
@Watson1978
Watson1978 / AppDelegate.rb
Created July 26, 2012 01:35
MacRuby : Mountain Lion + Notification
#
# AppDelegate.rb
# notify
#
# Created by watson on 2012/07/26.
#
module Notification
module_function
def send(title, text)
# -*- 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
class Foo
attr_accessor :name
def initialize
@name = UILabel.alloc.initWithFrame([[0, 0], [10, 10]])
end
end
class Bar < UITableViewCell
attr_accessor :name
@Watson1978
Watson1978 / gist:3029741
Created July 1, 2012 21:48 — forked from seanlilmateus/gist:3029710
macruby reject bugs tweets
#!/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
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
@Watson1978
Watson1978 / gist:2898787
Created June 9, 2012 00:18
MacRuby 0.12 release note
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
# -*- 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
#!/usr/local/bin/macruby
framework "Cocoa"
require 'pp'
class RSS
def parse(url,
delegate: delegate,
selector: callback)
@delegate = delegate
@callback = callback
# -*- coding: utf-8 -*-
require 'rubygems'
require 'ruby-growl'
g = Growl::GNTP.new "localhost", "test"
g.add_notification "test"
g.register
g.notify "test", "test"