Skip to content

Instantly share code, notes, and snippets.

View jugyo's full-sized avatar
🏠
Working from home

Kaz jugyo

🏠
Working from home
  • The League
  • New Jersey
View GitHub Profile
require 'readline'
Thread.new do
while true
puts 'hoge'
sleep 1
end
end
while buf = Readline.readline("", true)
module Termtter
class Client
def initialize
@hooks = []
end
def add_hook(&block)
p block_given?
p block
@hooks << block
end
--- 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>
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\]: '
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
require 'rubygems'
require 'highline'
ui = HighLine.new
username = ui.ask('Username: ')
password = ui.ask('Password: ') { |q| q.echo = false }
puts username
puts password
#!/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
'hoge'.instance_eval do |s|
p s #=> 1.8 と 1.9 で結果が違う!
end
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
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