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 Promise | |
def initialize(_type, &block) | |
@type = _type | |
@converter = block_given? ? block : proc {|value| @type.new(value) } | |
end | |
def validate(val) | |
@type === val or raise ArgumentError | |
end |
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/bin/env ruby | |
require 'rubygems' | |
require 'pit' | |
require 'xmpp4r-simple' | |
def notify(title, msg='') | |
system("growlnotify '#{title}' -m '#{msg}'") | |
end |
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/bin/env ruby | |
# vim:set ft=ruby: | |
require "optparse" | |
require "tmpdir" | |
OPTS = {} | |
OptionParser.new.instance_eval do | |
on('-d', '--dry') { OPTS[:dry] = true } |
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
require "sinatra" | |
get "/:message" do | |
system "growlnotify -a 'Growl Remote Notification' -m '#{params[:message]' '#{request.host}'" | |
"OK\n" | |
end |
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 Hoge | |
attr_accessor :hoge, :fuga | |
end | |
a = Hoge.new; b = Hoge.new | |
a.foo = :bar; b.foo = :bar | |
p a == b # -> false | |
require 'ostruct' |
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
// vim:set noet sw=3 ts=3 sts=3 | |
import scala.util.parsing.combinator._ | |
import java.io.FileReader | |
class XselfParser extends RegexParsers { | |
def expression: Parser[Any] = opt("(")~rep(identifier)~opt(")") | |
def identifier: Parser[Any] = rep("""[a-zA-Z0-9]""".r | symbol) | |
def symbol: Parser[Any] = "~" | "!" | "@" | "$" | "%" | "^" | "&" | "*" | "-" | "_" | "=" | "+" | "|" | ":" | "<" | ">" | "/" | "?" | |
} |
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
diff --git a/access_hatena.js b/access_hatena.js | |
index 2f82fa1..b291b02 100644 | |
--- a/access_hatena.js | |
+++ b/access_hatena.js | |
@@ -218,7 +218,8 @@ map ; :accesshatena | |
} else if (args.length == 2) { | |
var host = args[0].toString(); | |
context.title = ["ID", "Page"]; | |
- context.completions = [[ids[i], title.get(host, ids[i])] for (i in ids) if (ids.hasOwnProperty(i))]; | |
+ var _completions = [[ids[i], title.get(host, ids[i])] for (i in ids) if (ids.hasOwnProperty(i))]; |
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 ::Object | |
def func(name, &block) | |
self.class.send(:define_method, name, &block) | |
end | |
end | |
func :unko do |len| "unko".each_char.map {|ch| ch * len.to_i }.join end | |
unko 5 # -> "uuuuunnnnnkkkkkooooo" |
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 Foo | |
@x = :class_local_var | |
class << self | |
attr_accessor :x | |
end | |
end | |
Foo.x # -> :class_local_var | |
Foo.x = 1 |
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
require 'formula' | |
class ApacheCassandra < Formula | |
url 'http://www.apache.org/dyn/closer.cgi?path=/cassandra/0.7.9/apache-cassandra-0.7.9-bin.tar.gz' | |
homepage 'http://cassandra.apache.org' | |
md5 '6c7ae6a2c2e58e72261fa1f7321696fb' | |
def install | |
(var+'lib/cassandra-0.7').mkpath | |
(var+'log/cassandra-0.7').mkpath |