Skip to content

Instantly share code, notes, and snippets.

View akm's full-sized avatar

Takeshi Akima akm

View GitHub Profile
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'))
#! /usr/bin/env ruby
require 'fileutils'
require "optparse"
OPTIONS = {
:default => 'n',
:confirmation => :once,
:sort => :path,
:display_format => '"mtime size path"',
:verbose => false
@akm
akm / .irbrc
Created February 25, 2010 01:38
# http://doc.loveruby.net/refm/api/view/library/irb
# プロンプトモードは :DEFAULT の他に :NULL, :CLASSIC, :SIMPLE, :XMP が定義されています。
# 実行時には
# IRB.conf[:PROMPT].keys
# で確認できます。
# irb中で、
# conf.prompt_mode = :CODE
# とかすれば、モードの変更ができます。
# 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
# 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
#! /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")
#!/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日がマイルストーン
# 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,
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
@akm
akm / .emacs
Created July 7, 2010 05:18
.emacs
;; 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))