Skip to content

Instantly share code, notes, and snippets.

View odaillyjp's full-sized avatar

Suguru Odai odaillyjp

View GitHub Profile
class Controller
def create
word = Word.new(name: params[:name])
vowel = word.get_vowel #=> 母音の string が取れる
words = RhymeMaker.get_words(vowel, Word.all)
RhymeMaker.get_words(params[:name]) #=> 単語一覧
end
end
class Controller
def create
word = Word.new(name: params[:name])
vowel = word.get_vowel #=> 母音の string が取れる
words = RhymeMaker.get_words(vowel, Word.all)
RhymeMaker.get_words(params[:name]) #=> 単語一覧
end
end
@odaillyjp
odaillyjp / thread_null.rb
Last active January 1, 2016 17:03
Thread をインスタンス変数などに格納していた場合、その Thread が終了したタイミングで参照を無くすには、ensure節でこうやるしかないのかな...
@th = Thread.start do
begin
sleep 1
Thread.exit
ensure
@th = nil
end
end
@th.join
@odaillyjp
odaillyjp / thread_exit.rb
Last active December 30, 2015 03:31
メインスレッドで定義した Proc オブジェクト内の Thread.exit をサブスレッドで呼び出しても、メインスレッドは終了されず、サブスレッドが終了される。http://docs.ruby-lang.org/ja/2.2.0/class/Thread.html#S_EXIT
# ruby 2.2.3
proc = -> { Thread.exit }
th = Thread.start do
sleep 5
proc.call #=> スレッドthが終了される。メインスレッドは終了されない。
end
th.join
@odaillyjp
odaillyjp / yochiyochi.md
Last active August 29, 2015 14:25
よち合宿

2015/09/04(金)〜2015/09/06(日)の期間でよちよち.rb開発合宿を開催します。 普段は忙しくてなかなか取り込むことができなかったことを各自持ち寄って、いつもとは違う環境でもくもくと取り組みに行きませんか?

よちよち.rbとは

詳細

2015/09/04(金)〜 2015/09/06(日)

集合場所: 20:30 JR品川駅

@odaillyjp
odaillyjp / nginx.rb
Last active August 29, 2015 14:04
CentOS に Nginx の最新安定版を入れるレシピ
include_recipe 'yum'
# リポジトリは http://wiki.nginx.org/Install#Official_Red_Hat.2FCentOS_packages を参考
yum_repository 'nginx' do
baseurl "http://nginx.org/packages/centos/#{node[:platform_version].to_i}/#{node[:kernel][:machine]}/"
gpgcheck false
enabled false
action :create
end
@odaillyjp
odaillyjp / remi.rb
Last active August 29, 2015 14:04
remi リポジトリを入れるレシピ
include_recipe 'yum'
yum_repository 'remi' do
baseurl "http://rpms.famillecollet.com/enterprise/#{node[:platform_version].to_i}/remi/#{node[:kernel][:machine]}/"
enabled false
gpgkey 'http://rpms.famillecollet.com/RPM-GPG-KEY-remi'
action :create
end
require 'minitest'
require 'minitest/autorun'
require 'pry'
MAX_WIDTH = 5
MAX_HEIGHT = 5
SENTINEL_CHER = -1
def solve(str)
init_numbers_field(str)
@odaillyjp
odaillyjp / odai.md
Created June 14, 2014 12:01
よちよち.rb 過去の宿題

思い入れのある Git コマンド

  • git diff
  • git grep

定番!

宿題のおまけ

よく使っているコマンドを調べてみました。(とりあえず トップ20 だけ抜き出し)

$ egrep -o ';g(?:it)?\s\w*' ~/.zsh_history | cut -f 2 -d ' ' | sed -e "s/^co$/checkout/" -e "s/^st$/status/" -e "s/^lg/log/" | sort | uniq -c | sort -r
<!doctype html>
<html lang="ja">
<head>
<meta charset="utf-8">
<title>カレーのレシピ</title>
<meta name="description" content="誰でもできる、美味しいカレーの作り方です。旦那も息子もこのカレーが大好物。">
</head>
<body>
<header>
<h1>カレーのレシピ</h1>