Skip to content

Instantly share code, notes, and snippets.

View takai's full-sized avatar

Naoto Takai takai

View GitHub Profile
require 'rubygems'
require 'active_record'
ActiveRecord::Base.establish_connection('host' => 'localhost',
'user' => 'root',
'adapter' => 'mysql2',
'read_timeout' => 1)
begin
result = ActiveRecord::Base.connection.execute('select sleep(2)')
result.each { |r| p r }
development:
adapter: mysql2
encoding: utf8
reconnect: false
database: mysql_read_timeout_development
pool: 5
username: root
password:
socket: /tmp/mysql.sock
@takai
takai / init.el
Created January 6, 2012 02:27
Emacs settings at office
;; GNU Emacs 23.3.1 (x86_64-apple-darwin11.1.0, NS apple-appkit-1138.00) of 2011-10-03
;; load-path
(setq load-path
(append '("/usr/local/Cellar/emacs/23.3a/share/emacs/site-lisp/apel"
"/usr/local/Cellar/emacs/23.3a/share/emacs/site-lisp/skk"
"/Users/takai/Src/elisp/rinari"
"/Users/takai/Src/elisp/rhtml"
"/Users/takai/Src/elisp/haml-mode"
"/Users/takai/Src/elisp/sass-mode"
"/Users/takai/Src/elisp/coffee-mode"
<!-- =========================================================== -->
<!-- Configure Request Log -->
<!-- Request logs may be configured for the entire server here, -->
<!-- or they can be configured for a specific web app in a -->
<!-- contexts configuration (see $(jetty.home)/contexts/test.xml -->
<!-- for an example). -->
<!-- =========================================================== -->
<Ref id="RequestLog">
<Set name="requestLog">
<New id="RequestLogImpl" class="org.mortbay.jetty.NCSARequestLog">
バイナリログの表示
$ sudo mysqlbinlog --no-defaults --character-set=utf8 /var/lib/mysql/log-bin.000001
バイナリログのローテート
mysql> flush logs
もしくは
$ sudo pkill -HUP mysqld
describe 'テスト対象' do
context '状態' do
describe 'テスト対象メソッド' do
context '与える入力' do
it '期待する出力'
end
end
end
end
describe SymbolStack do
context 'when stack is empty' do
its (:size) { should eq 0 }
describe 'SymbolStack#push' do
context 'with symbol' do
it 'increments stack size' do
expect { subject.push(:data) }.
to change { subject.size }.from(0).to(1)
end
class StackEmptyError < StandardError
end
class StackOverflowError < StandardError
end
class SymbolStack
def initialize
@stack = []
end
require 'benchmark'
require 'set'
source = 100000.times.map { rand(100) }
n = 100
Benchmark.bm(5) do |x|
x.report('uniq') do n.times { source.uniq } end
x.report('uniq!') do n.times { source.uniq! } end
x.report('set') do n.times { Set.new(source) } end
module Amida
class App
START_CHAR = 65
def header(column)
chars = (START_CHAR...(START_CHAR + column)).map(&:chr)
chars.join(' ') + "\n" +
bar_row_string(column)
end