Skip to content

Instantly share code, notes, and snippets.

View takkanm's full-sized avatar

Mitsutaka Mimura takkanm

  • Tokyo, Japan
View GitHub Profile
@takkanm
takkanm / gist:9263886
Created February 28, 2014 02:16
and_return に関する考察
koic Feb 27 19:10
and_return とブロックのいずれが良いか :sushi: と話しております
koic Feb 27 19:18
:sushi: 逃げました
moro 10:36
95%くらいはand_return じゃなくてブロックがいいと思います
moro 10:36
('ぁ'..'ん').to_a.zip(
%w(xa a xi i u xu u xe e xo o ka ga ki gi ku
gu ke ge ko go sa za si zi su zu se ze so zo
ta da ti di xtu du te de to do na ni nu ne no
ha ba pa hi bi pi fu bu pu he be pe ho bo po
ma mi mu me mo xya ya xyu yu xyo yo
ra ri ru re ro xwa wa wi we wo n)
).inject({}){|hash, (hiragana, roma)|
hash[hiragana] = roma
hash
irb(main):001:0> a = []
=> []
irb(main):002:0> h = a.hash
=> 4042432731835813366
irb(main):003:0> a.push 1
=> [1]
irb(main):004:0> h == a.hash
=> false
@takkanm
takkanm / file0.txt
Created May 6, 2014 05:57
Mac アプリケーションの Window を閉じる前のサイズと位置で開きなおしたい ref: http://qiita.com/takkanm/items/1ca0b384c9af64a48a42
autosave_name = windowFrameAutosaveName
make() {
if [ -e ./Makefile ]; then
make $*
else
rake $*
fi
}
Parsing documentation for rails-4.1.5
Installing ri documentation for rails-4.1.5
Installing darkfish documentation for rails-4.1.5
ruby(70285,0x7fff760c5310) malloc: *** error for object 0x7ff10c3b4fa8: incorrect checksum for freed object - object was probably modified after being freed.
*** set a breakpoint in malloc_error_break to debug
irb(main):001:0> a
NameError: undefined local variable or method `a' for main:Object
from (irb):1
from /Users/takkanm/.rbenv/versions/2.2.0/bin/irb:11:in `<main>'
irb(main):002:0> if false
irb(main):003:1> a = 1
irb(main):004:1> end
=> nil
irb(main):005:0> a
=> nil
irb(main):001:0> p ["hello", "world"].map(&:capitalize).join(' ')
"Hello World"
=> "Hello World"
irb(main):002:0> puts ["hello", "world"].map(&:capitalize).join(' ')
Hello World
=> nil
source "https://rubygems.org"
gem 'rspec'
require 'timeout'
pid = Process.spawn('sleep', '10')
puts Time.now
begin
Timeout.timeout(1) {
Process.waitpid(pid)
}
rescue => e
p e