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
module Enumerable | |
def parallel_map(&block) | |
threads = [] | |
result = {} | |
self.each_with_index do |a, i| | |
threads << Thread.new do | |
result[i] = [a].map(&block).first | |
end | |
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
$ time bundle exec rspec spec/fb_graph/rails/authentication_spec.rb ~/fb_graph-rails | |
........................ | |
Finished in 0.49638 seconds | |
24 examples, 0 failures | |
bundle exec rspec spec/fb_graph/rails/authentication_spec.rb 3.85s user 0.86s system 98% cpu 4.775 total | |
$ time rspec spec/fb_graph/rails/authentication_spec.rb ~/fb_graph-rails | |
........................ |
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/local/Library/Formula/vim.rb | |
# | |
# Vim formula for HomeBrew | |
# | |
# Written by Joseph Ku <[email protected]> | |
# All right reserved. | |
require 'formula' | |
class Vim < Formula |
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/local/Library/Formula/vim.rb | |
# | |
# Vim formula for HomeBrew | |
# | |
# Written by Joseph Ku <[email protected]> | |
# All right reserved. | |
require 'formula' | |
class Vim < Formula |
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
# -*- encoding: utf-8 -*- | |
require 'tempfile' | |
module Editable | |
# Edit self by $EDITOR | |
# | |
def edit! | |
temp = Tempfile.new(self.object_id.to_s) |
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
# From http://d.hatena.ne.jp/mollifier/20090814/p1 | |
zstyle ':vcs_info:*' formats '%b' | |
zstyle ':vcs_info:*' actionformats '%b|%a' | |
ZSHFG=`expr $RANDOM / 128` | |
precmd () { | |
psvar=() | |
LANG=en_US.UTF-8 vcs_info | |
[[ -n "$vcs_info_msg_0_" ]] && psvar[1]="$vcs_info_msg_0_" | |
if [ $ZSHFG -ge 250 ] |
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
ruby-1.9.2-p290 :037 > value['warden.user.default.key'].first => User(id: integer, email: string, password_digest: string, read_tos_at: datetime, deleted_at: datetime, created_at: datetime, updated_at: datetime) | |
ruby-1.9.2-p290 :038 > User => User(id: integer, email: string, password_digest: string, read_tos_at: datetime, deleted_at: datetime, created_at: datetime, updated_at: datetime) | |
ruby-1.9.2-p290 :039 > value['warden.user.default.key'].first == User | |
=> false ruby-1.9.2-p290 :040 > |
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
# From http://d.hatena.ne.jp/mollifier/20090814/p1 | |
autoload -Uz vcs_info | |
zstyle ':vcs_info:*' formats '%b' | |
zstyle ':vcs_info:*' actionformats '%b|%a' | |
# Set initial color | |
ZSHFG=`expr $RANDOM / 128` | |
precmd () { | |
# Set git info into 1v |
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
# encoding: utf-8 | |
count = 0 | |
# getsでターミナルで打った文字が取れます | |
while number = gets | |
# getsは文字で受け取るので、to_iで数字に変換 | |
count = count + number.to_i | |
if count >= 1000 | |
puts '1000 over' |
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
# -*- encoding: utf-8 -*- | |
name = "My name is Fujimura, I was born in Kawasaki city" | |
# ここで名前を変更して、name変数を上書き | |
name = name.sub("Fujimura", "Chikuwa") | |
# ここで街を変更、name変数を上書き | |
name = name.sub("Kawasaki", "Kyoto") |