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 'dm-core' | |
DataMapper.setup(:default, "sqlite3:///#{File.expand_path(File.dirname(__FILE__))}/test.db") | |
class User | |
include DataMapper::Resource | |
property :id, Integer, :serial => true | |
property :name, String, :nullable => false | |
has n, :items |
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 python | |
# -*- coding: utf-8 -*- | |
import gdata.photos.service | |
gd_client = gdata.photos.service.PhotosService() | |
user = '<ユーザーID>' | |
# アルバムの情報を取得 |
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 'readline' | |
require 'open-uri' | |
Thread.new do | |
puts open('http://example.com/').read | |
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
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 |