This file contains hidden or 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 FormatterWithThread < Logger::Formatter | |
Format = "%s %s, [%s#%d] %5s -- %s: %s\n" | |
def call(severity, time, progname, msg) | |
Format % [(Thread.current[:name] || Thread.current.object_id).to_s, | |
severity[0..0], format_datetime(time), $$, severity, progname, | |
msg2str(msg)] | |
end | |
end | |
ActiveRecord::Base.logger = Logger.new(File.join(File.dirname(__FILE__), 'debug.log')) |
This file contains hidden or 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 'fileutils' | |
require "optparse" | |
OPTIONS = { | |
:default => 'n', | |
:confirmation => :once, | |
:sort => :path, | |
:display_format => '"mtime size path"', | |
:verbose => false |
This file contains hidden or 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
# http://doc.loveruby.net/refm/api/view/library/irb | |
# プロンプトモードは :DEFAULT の他に :NULL, :CLASSIC, :SIMPLE, :XMP が定義されています。 | |
# 実行時には | |
# IRB.conf[:PROMPT].keys | |
# で確認できます。 | |
# irb中で、 | |
# conf.prompt_mode = :CODE | |
# とかすれば、モードの変更ができます。 |
This file contains hidden or 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
# http://doc.loveruby.net/refm/api/view/library/irb | |
# プロンプトモードは :DEFAULT の他に :NULL, :CLASSIC, :SIMPLE, :XMP が定義されています。 | |
# 実行時には | |
# IRB.conf[:PROMPT].keys | |
# で確認できます。 | |
# irb中で、 | |
# conf.prompt_mode = :CODE | |
# とかすれば、モードの変更ができます。 | |
IRB.conf[:PROMPT_MODE] = :SIMPLE |
This file contains hidden or 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
# HashKeyOrderable | |
# sort key and values for your order. MIT LICENCE. copyright Takeshi AKIMA 2010. | |
# http://gist.github.com/358709 | |
module HashKeyOrderable | |
attr_accessor :key_order | |
def each_with_key_order(&block) | |
if @key_order.nil? || @key_order.empty? | |
each_without_key_order(&block) | |
return self |
This file contains hidden or 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 'date' | |
STARTED_AT = DateTime.parse("Mon Apr 19 09:30:00 +0900 2010") | |
len = DateTime.now - STARTED_AT | |
t = Time.at((len * 24 * 60 * 60).to_i) | |
puts t.utc.strftime("#{len.to_i} days and %H:%M") |
This file contains hidden or 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 | |
# -*- coding: utf-8 -*- | |
require 'rubygems' | |
require 'gcalapi' | |
service = GoogleCalendar::Service.new("[email protected]", "*****") | |
calendar = GoogleCalendar::Calendar::new(service, | |
"http://www.google.com/calendar/feeds/[email protected]/private/full") | |
# 毎月18日がマイルストーン |
This file contains hidden or 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
# simply_stored | |
# gem install simply_stored right_aws uuidtools | |
require 'active_support' | |
require 'simply_stored/simpledb' | |
SimplyStored::Simple.aws_access_key = 'test1' | |
SimplyStored::Simple.aws_secret_access_key = 'test1' | |
conn = RightAws::ActiveSdb.establish_connection( | |
SimplyStored::Simple.aws_access_key, |
This file contains hidden or 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
obj = Object.new | |
def obj.foo(*args) | |
options = args.last.is_a?(Hash) ? args.pop : {} | |
options = {:name=>"A", :no=>1}.update(options) | |
"#{args.inspect} #{options.inspect}" | |
end |
This file contains hidden or 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
;; add load-path | |
(let ((dir (expand-file-name "~/.emacs.d/lisp"))) | |
(if (member dir load-path) nil | |
(setq load-path (cons dir load-path)) | |
(let ((default-directory dir)) | |
(load (expand-file-name "subdirs.el") t t t)))) | |
;; デフォルトの透明度を設定する (85%) | |
(add-to-list 'default-frame-alist '(alpha . 92)) |