Skip to content

Instantly share code, notes, and snippets.

View taea's full-sized avatar
🏠
Working from home

ken_c_lo / TAEKO AKATSUKA taea

🏠
Working from home
View GitHub Profile
@taea
taea / gist:5335239
Created April 8, 2013 08:44
データ入れる
$ rails db<[SQLfilePath]
@taea
taea / gist:5344368
Created April 9, 2013 09:32
なんとかpathの書き方を知るにはどこを見ればいいのか
わりとdecoratorに書いてある。
っていうかなんとかpathでgit grepするといいのか
@taea
taea / rake-routes.md
Last active December 15, 2015 23:59
rake routes
$ bundle exec rake routes CONTROLLER=companies/offices

とかなんとか

@taea
taea / try.haml
Last active December 16, 2015 06:49
Haml: 値が存在する場合だけ表示 をワンライナーで → try
= "#{@person.try(:name)}"
-# もしくは
= "#{"#{@person.name}" if @person.name.present?}"
@taea
taea / join.haml
Last active December 16, 2015 07:19
配列を一定数とりだしてコンマでつなげて表示したい
-# @usersからnameを5ことりだして,でつなげる
= @users[0..4].map(&:name).join(', ')
-#これらでもよい(というかこっちの方が実行効率がわずかによいらしい)
= @users[0, 5].map(&:name).join(', ')
= @users.take(5).map(&:name).join(', ')
= @users.first(5).map(&:name).join(', ')
@taea
taea / github.com.js
Last active December 16, 2015 07:19
dotjsでOctocatを荒ぶるkomagataアイコンに差し替える
// ~/.js/github.com.js
$('a.header-logo-invertocat').css({'padding-top': '2px', 'padding-bottom': '0'}).html(
$('<img>')
.attr('src', 'http://docs.komagata.org/theme/p0t/images/movable_face.gif')
.css({'width': 'auto', 'height': '34px'})
);
@taea
taea / rails_cycle.haml
Last active December 16, 2015 20:59
rails の cycle
- @users.each do |user|
%p.user{class: cycle('', '', 'nth-child-3')}
%span.name= user.name
@taea
taea / capitalize.haml
Created May 8, 2013 10:23
capitalize
= @user.name.capitalize
@taea
taea / rails-c.md
Last active December 17, 2015 07:49
rails c でデータを入れる
$ rails c

User モデルの一個目のデータを"u" に代入(モデルは大文字はじまり・単数)

irb(main):000:0> u = User.first

↓ 一個目出る

@taea
taea / gist:5576154
Last active December 17, 2015 07:58
Vimはじめるときに入れとくと良いやつ