Skip to content

Instantly share code, notes, and snippets.

書籍

1. 入門「Ruby on Rails 4 アプリケーションプログラミング」

Railsは最初は「パーフェクトRuby on Rails」より「Ruby on Rails 4 アプリケーションプログラミング」の方がよい。パーフェクトは初心者には内容が飛躍してる場所が多い印象。 Railsアプリケーションプログラミングは長いことRailsの基礎部分のリファレンスとして使える。

2. 初級~中級「パーフェクトRuby on Rails」「RSpecによるRailsテスト入門」

パーフェクトは、チュートリアルと、Railsの一歩先(gemとかドキュメントとか)の部分が優秀。 RSpecを使うなら「RSpecによるRailsテスト入門」は必読。

1. 入門「たのしいRuby」

バーって読み通して、Rubyがどんなもんなのか、体系的に広く大体の雰囲気を知る。内容はそんなに深くなくて基本の文法が主なので、まず読み通してRubyの大体の雰囲気を知るみたいなイメージ。コラムは普段だと知れないこともあって面白い。

2. 初級〜中級 「パーフェクトRuby」

この本は網羅的にしかも割と深く書かれてるのでむっちゃオススメ。中身も、初心者のためのブラックボックスな説明みたいのがなくて誠実な印象でよい。1度読み通した後はリファレンス的にこの本を使っていく。

3. 中級〜上級「メタプログラミングRuby」

ここまで来たらこの本はRubyist的に必読。よりRubyの概念・哲学・仕組みを知れる。ひたすら良本。

4. 上級「Rubyのしくみ」

@totzyuta
totzyuta / rm-git.sh
Created August 30, 2016 06:38
gitで、stagingされてないファイル・ディレクトリを全て削除するコマンド
rm -r `g st | tail -n +2 | awk '{ print $2 }'`
require "rubygems"
require 'timers'
timers = Timers::Group.new
five_second_timer = timers.every(120) do
system(`osascript -e 'display notification "🍻" with title "2 mins!"'`)
end
loop do
begin
File.open("converted-prices.txt","w") do |file|
File.open('prices.txt') do |price_file|
price_file.each_line do |price|
if price != "\n"
price.delete!(",")
file.puts("#{(price.to_i * (2.0/3.0)).floor}")
else
file.puts ""
end
@totzyuta
totzyuta / virtualhost.conf
Created May 1, 2016 06:40
PHP by nginx + php-fpm in EC2
# /etc/nginx/conf.d/www.conf
server {
listen 80;
root /var/www/lp;
index index.php index.html index.htm;
# server_name dog-trimming.com;
server_name 52.69.232.100;
require 'twilio-ruby'
class ShortMessageService
ACCOUNT_SID = 'xxxxxxxxxxxxxxxxxxxxxxxxx'
AUTH_TOKEN = 'xxxxxxxxxxxxxx'
FROM = '+xxxxxxxxx'
def self.send_short_message(to, body)
client = Twilio::REST::Client.new ACCOUNT_SID, AUTH_TOKEN
client.account.messages.create({
@totzyuta
totzyuta / calc.rb
Last active February 15, 2016 02:19
require 'nokogiri'
require 'open-uri'
html = Nokogiri::HTML(File.open(File::expand_path('./source.txt')))
prices = html.css('#kagKinDisp').map {|price| price.content.delete(",").to_i }
times = html.css('#hesKaisuDisp').map(&:content)
result = Array.new
upstream unicorn_server {
server unix:/tmp/unicorn.sock
fail_timeout=0;
}
server {
listen 80;
server_name 1-box.jp;
access_log /var/log/nginx/access.log;
#!/usr/local/bin/ruby
# rain for a curses test
# it does not work by Ruby 2.2.0
require "curses"
include Curses
def onsig(sig)
close_screen
exit sig