Skip to content

Instantly share code, notes, and snippets.

View kyuden's full-sized avatar

Masahiro Kyuden kyuden

View GitHub Profile
@kyuden
kyuden / gist:7487526
Created November 15, 2013 16:48
preferences.sublime-settings
{
"color_scheme": "Packages/Theme - Flatland/Flatland Monokai.tmTheme",
"draw_white_space": "all",
"flatland_sidebar_tree_xsmall": true,
"flatland_square_tabs": true,
"highlight_line": true,
"highlight_modified_tabs": true,
"highlight_trailing_spaces_color_name": "invalid",
"ignored_packages":
[
@kyuden
kyuden / gist:7487584
Created November 15, 2013 16:51
Package Conrol.sublime-settings
{
"installed_packages":
[
"Abacus",
"BracketHighlighter",
"Creation Platform - KL Language Support",
"Gist",
"GitGutter",
"Package Control",
"rbenv",
@kyuden
kyuden / gist:8888098
Created February 8, 2014 18:40
how to clone remote_branch on local
# display remote_branch
gir branch -r
# clone remote_branch on local
git checkout 'branch_name' origin/'branch_name'
@kyuden
kyuden / describe vs. context in rspec
Created February 8, 2014 20:27
describe vs. context in rspec
describe vs. context in rspec
http://lmws.net/describe-vs-context-in-rspec
In Rspec world, you often see people using both “describe” blocks and “context” blocks together, like this
describe "launch the rocket" do
context "all ready" do
end
context "not ready" do
@kyuden
kyuden / file0.txt
Created February 27, 2014 16:39
guard-rspecでRSpecのバージョン不一致によるエラー対処法 ref: http://qiita.com/Kyuden@github/items/ef597250d673a2608e49
bundle exec guard
01:12:33 - INFO - Guard is using TerminalTitle to send notifications.
01:12:33 - INFO - Guard::RSpec is running
01:12:33 - INFO - Guard is now watching at '/Users/kyuden/Test'
[1] guard(main)>
01:12:34 - INFO - Run all
01:12:34 - INFO - Running all specs
WARN: Unresolved specs during Gem::Specification.reset:
rspec-expectations (~> 2.14.0)
rspec-mocks (~> 2.14.0)
@kyuden
kyuden / gist:9327279
Created March 3, 2014 15:25
Guardfile
# A sample Guardfile
# More info at https://github.com/guard/guard#readme
guard 'livereload' do
watch(%r{app/views/.+\.(erb|haml|slim)$})
watch(%r{app/helpers/.+\.rb})
watch(%r{public/.+\.(css|js|html)})
watch(%r{config/locales/.+\.yml})
# Rails Assets Pipeline
watch(%r{(app|vendor)(/assets/\w+/(.+\.(css|js|html|png|jpg))).*}) { |m| "/assets/#{m[3]}" }
@kyuden
kyuden / collection
Last active August 29, 2015 14:02
collection
numbers = [1, 2, 3, 4, 5, 6]
result1 = []
numbers.each do |num|
result1 << num * 2 if num % 2 == 0
end
p result1 # => [4, 8, 12]
# 02
message = "hello"
if message.length > 1
alert message
# 03
s = "hello
safdaf
asdf
asfdfda"
# []があるから範囲指定の文字列抽出用途では価値ない
"2012-08-01".slice(0..2)
"2012-08-01"[0..2]
# 正規表現で抽出文字列を絞り込めるはおおきな利点
"2012-08-01".slice(/-(.+)-/) # => "-08-"
# ちなみにdeleteは削除後の文字列を返却するのが違い
"2012-08-01".delete(/-(.+)-/) # => "201201"
@kyuden
kyuden / enumberalbe
Last active August 29, 2015 14:04
map vs inject vs each_with_object
# map(collect)
### 特徴
レシーバの配列の要素、1つずつに対して処理を行う
一つずつというのが重要で、処理前と処理後の配列のsizeは結局同じ
### 使い所
配列→配列の場合に使う
配列内容の要素すべてを1つずつ同様の処理を行うのに便利
例えば