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 'readline' | |
Thread.new do | |
while true | |
puts 'hoge' | |
sleep 1 | |
end | |
end | |
while buf = Readline.readline("", 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
module Termtter | |
class Client | |
def initialize | |
@hooks = [] | |
end | |
def add_hook(&block) | |
p block_given? | |
p block | |
@hooks << block | |
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
--- a/files/prefpane/checkbox.xml Wed Oct 08 19:42:28 2008 +0900 | |
+++ b/files/prefpane/checkbox.xml Sat Jan 10 12:06:03 2009 +0900 | |
@@ -1808,6 +1808,18 @@ | |
<only>TERMINAL</only> | |
<autogen>--KeyToKey-- KeyCode::COMMAND_L, KeyCode::OPTION_L</autogen> | |
</item> | |
+ <item> | |
+ <name>Remap Command_L to Control_L</name> | |
+ <sysctl>remap.app_term_commandL2controlL</sysctl> | |
+ <only>TERMINAL</only> |
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
parse_git_branch() { | |
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/' | |
} | |
export PS1='\[\033\e[34m\]\w \[\033\e[33m\]$(parse_git_branch)\[\033\e[0m\]: ' |
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 'rubygems' | |
require 'highline' | |
if $stdin.respond_to?(:getbyte) # for ruby1.9 | |
require 'delegate' | |
stdin_for_highline = SimpleDelegator.new($stdin) | |
def stdin_for_highline.getc | |
getbyte | |
end | |
else |
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 'rubygems' | |
require 'highline' | |
ui = HighLine.new | |
username = ui.ask('Username: ') | |
password = ui.ask('Password: ') { |q| q.echo = false } | |
puts username | |
puts password |
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 | |
`svn diff #{ARGV.join(' ')}`.each do |line| | |
puts( if line =~ /^\+(.*)$/ | |
"\e[32m#{$&}\e[0m" | |
elsif line =~ /^-(.*)$/ | |
"\e[31m#{$&}\e[0m" | |
else | |
line | |
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
'hoge'.instance_eval do |s| | |
p s #=> 1.8 と 1.9 で結果が違う! | |
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 Foo | |
def define_singleton_method(name, &block) | |
extend Module.new{define_method name, &block} | |
end | |
end | |
f = Foo.new | |
f.define_singleton_method(:hoge) do |arg| | |
puts arg | |
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
module Delegatable | |
def delegate(from_obj, from_method, to_obj, to_method) | |
from_obj.extend Module.new{ | |
define_method(from_method) do |*arg| | |
to_obj.__send__(to_method, *arg) | |
end | |
} | |
end | |
end | |