Skip to content

Instantly share code, notes, and snippets.

View kachick's full-sized avatar
😋
😪

Kenichi Kamiya kachick

😋
😪
View GitHub Profile
@kachick
kachick / tips_atom.md
Created October 5, 2016 10:58
しょぼい Atom 周りの tips

Atom

  • cmd + k の後にキーを離して上下左右で、そちらへのペイン分割。移動はcmd + k の後にキーを離して cmd + n/p。とじはcmd + k の後にキーを離してcmd + w
  • ctrl + cmd + m で現在の カッコ内を全選択。 大カッコとかも含むんで、配列の中ぜん選択とかもできて便利!
  • alt + cmd + . で 直近のタグを閉じる
@kachick
kachick / tips_mac_os_x.md
Created October 5, 2016 10:57
しょぼい Mac OS X 周りの tips

Mac OS X

  • http://qiita.com/ogomr/items/71e4d2024794ea08d978 でまずはキーの読み方覚えないとイカン。
  • cmd + ctrl + d: Mac標準搭載の辞書で選択箇所の訳が出る。イイ
  • command + option + D で dock の on/off
  • ⁠⁠⁠⁠sudo nvram boot-args=niog=1 で、閉じず(クラムシェルモード)に外部ディスプレイへ出せる?
  • open . で、カレントディレクトリを finder で開ける
@kachick
kachick / building_ruby_trunk_for_chruby.md
Created July 29, 2016 19:14
rubyのtrunkをさっくりbuildしてchrubyから使えるようにする時の僕のやり方

推奨できる物かは知らないけど個人的に楽

Mac OS X + zsh + chruby

ruby_version=$(grep '#define RUBY_VERSION' version.h | grep -o -E '[0-9.]+')
ruby_bin=ruby-${ruby_version}dev.$(git rev-parse --short trunk)
./configure --prefix="$HOME/.rubies/$ruby_bin" --disable-install-doc
make install
source /usr/local/share/chruby/chruby.sh
@kachick
kachick / rubinius.SIGSEGV.20160723.txt
Created July 22, 2016 19:09
`Array.new` with huge value makes SIGSEGV
☻ ./tmp/bin/rbx -e 'Array.new(2 ** 29)' ruby-2.3.0p0 spec-public-send-with-protected-method 3c32123
The Rubinius process is aborting with signal: SIGSEGV
--- begin system info ---
node info: MacBook-Pro-2.local Darwin Kernel Version 15.5.0: Tue Apr 19 18:36:36 PDT 2016; root:xnu-3248.50.21~8/RELEASE_X86_64
--- end system info ---
--- begin rubinius info ---
process info: kachick rbx 6414 3.3.c713 2.3.1 2016-07-21 f0373ac0 3.6.2 JIT disabled
--- end rubinius info ---
--- begin system backtrace ---
0 rbx 0x000000010b9eda53 _ZN8rubiniusL20abandon_ship_handlerEi + 259
@kachick
kachick / hash-p_diff.rb
Created December 5, 2015 08:38
Hash#p_diff
class Hash
def p_diff(b)
merged_keys = keys | b.keys
merged_keys.each do |k|
case
when key?(k) && b.key?(k)
value = self[k]
if value == b[k]
puts "a,b: #{k.inspect} => #{value.inspect} == #{b[k].inspect}"
else
@kachick
kachick / utc_from_jst.rb
Last active December 5, 2015 08:39
頭の中では日本時間で考えたいが、実際にはUTCで扱わなきゃいけないというツラさを解消したい
def utc_from_jst(*args)
ActiveSupport::TimeZone.new('Asia/Tokyo').utc_offset.seconds.ago Time.zone.local(*args)
end
@kachick
kachick / arel_table_is_private-API_and_rails-5_AR-or.md
Created November 11, 2015 03:08
arel_table は private な APIだよ & Rails 5 から ActiveRecord::Relation#or が用意された
@kachick
kachick / rescue_with_module.md
Created November 4, 2015 12:03
例外のrescueにmoduleを使う

Ruby の beginrescueend 構文では例外クラスを指定しろという説明が多い気するけど、includeしているmoduleとかでも拾えるんでもっと柔軟だよねというアレ

module Role end

class Foo < Exception
  include Role
end

begin
@kachick
kachick / rubinius_build_maxosx_2015-09.md
Last active May 18, 2016 17:32
Rubinius build on Max OS X 2015-09 ~ 2016

久しぶりに Mac OS X で rubinius build しようとしたら躓いた。 ぐぐってさっくり解決したとこをすっ飛ばすと、時間かかったのがここ

$ ./configure
Checking clang: found
Checking clang++: found
  Checking for 'llvm-config': only LLVM 3.0-3.5 is supported
ABORT: unable to set up LLVM
@kachick
kachick / key-change.md
Created August 9, 2015 22:35
壊れたキーボードの凌ぎ方 in Linux

キーボードの調子おかしくなってきて掃除した時、UpAllow↑キーの中のふにゃふにゃとキーカバーが上手くはまらないままどっかいっちゃった ベテランは使わないキーな気もするけど自分にとっては慣れ親しんだキーなので結構困る。 幸い?すぐそばの右シフトは使わなかったんでこれを差し替えて凌いでる。

# まずはxenvで
xenv
# 差し替え対象と差し替え先のキーを叩いてキーコード確認する。それさえ出来ない時も「xmodmap -pke」でなんとなく読める一覧は得られる
# 変更コマンドファイル作ってxmodmapに読み込ませる