Skip to content

Instantly share code, notes, and snippets.

View kurotaky's full-sized avatar
🍚
Focusing

Yuta Kurotaki kurotaky

🍚
Focusing
View GitHub Profile
@kurotaky
kurotaky / clean_ruby.rb
Created March 6, 2013 01:57
CleanRuby 0.6 p.35, example code
class TransfersControllerTest < ActionController::TestCase
test "POST#create" do
source = Account.new(:balance => 900)
destination = Account.new(:balance => 900)
Account.expects(:find).with('1').returns(source)
Account.expects(:find).with('2').returns(destination)
post :create, :account_id => '1',
:destination_id => '2',
:amount => '500'
assert_equal 400, source.balance

sublime-text2を入れて初めにやったこと

特徴

  • マルチプラットフォーム
  • 最初から良い感じに使える
  • 設定ファイルがJSON
  • 拡張がPythonで書ける
  • プロプライエタリ

インストール方法

@kurotaky
kurotaky / Gemfile
Last active December 11, 2015 03:19
Web-driverを使ってリモートホストのテストをするサンプル
source :rubygems
gem 'rspec'
gem 'capybara'
gem 'rake'
@kurotaky
kurotaky / .vimrc
Created January 15, 2013 00:48
!!! vim !!!
set encoding=utf-8
set fileencodings=utf-8,euc-jp
set expandtab "タブ入力を複数の空白入力に置き換える
set tabstop=4 "画面上でタブ文字が占める幅
set shiftwidth=4 "自動インデントでずれる幅
set softtabstop=4 "連続した空白に対してタブキーやバックスペースキーでカーソルが動く幅
set autoindent "改行時に前の行のインデントを継続する
set smartindent "改行時に入力された行の末尾に合わせて次の行のインデントを増減する
filetype plugin indent on
@kurotaky
kurotaky / build error
Created December 3, 2012 16:41
php-build
/Users/yuta% sudo php-build 5.3.9 ~/.phpenv/versions/5.3.9
Password:
[Info]: Loaded pyrus Plugin.
[Info]: Loaded xdebug Plugin.
[Info]: php.ini-production gets used as php.ini
[Info]: Building 5.3.9 into /Users/yuta/.phpenv/versions/5.3.9
[Skipping]: Already downloaded and extracted http://www.php.net/distributions/php-5.3.9.tar.bz2
[Preparing]: /var/tmp/php-build/source/5.3.9
[Compiling]: /var/tmp/php-build/source/5.3.9
[Pyrus]: Downloading from http://pear2.php.net/pyrus.phar
@kurotaky
kurotaky / expect_to.rb
Created November 23, 2012 20:37
rspec-rails: route_to matcher のなぞ
# expect to の書き方が推奨されているので書きなおす
# https://github.com/rspec/rspec-rails
# ↓ 落ちる
it "routes to #show" do
expect(get: "/entries/1").to route_to(controller: "entries", action: "show", id: "1")
end
Failures:
# http://blog.uu59.org/2011-10-03-sinatra-stream.html
require "rubygems"
require "sinatra"
set :server, :thin # 注: :keep_openが使えるのはイベントベースのサーバだけなのでthinを明示的に指定してる
connections = []
get '/' do
# keep stream open
@kurotaky
kurotaky / lightning_talk_order.rb
Created November 16, 2012 00:57
lightning_talk_order
# -*- coding: utf-8 -*-
presenters = %w(mizzyさん fuchinoさん demiさん kulopさん わじさん ライティさん まよとさん あんちぽさん あよはたさん \
うーたんさん うまづらさん テリーさん けんごさん tnmtさん)
presenters.shuffle!
presenters.each_with_index do |presenter, index|
puts "#{index+1}. #{presenter}"
end
@kurotaky
kurotaky / gist:4042351
Created November 8, 2012 22:45
Formatter
class Formatter
def output_report(title, text)
raise 'Abstruct method called'
end
end
class HTMLFormatter < Formatter
def output_report(title, text)
puts '<html>'
puts '<head>'
@kurotaky
kurotaky / kana_lookup.rb
Created October 21, 2012 05:57 — forked from randym/kana_lookup.rb
crap code for finding index of kanna phonetics
# encoding: UTF-8
#
require 'nkf'
class PhoneticMap
def data
@data ||= build_data
end
def index_of(string)