Skip to content

Instantly share code, notes, and snippets.

View igrep's full-sized avatar
:shipit:
Programming in TypeScript, Python, or Haskell.

YAMAMOTO Yuji igrep

:shipit:
Programming in TypeScript, Python, or Haskell.
View GitHub Profile
@igrep
igrep / evalex.rb
Last active August 29, 2015 14:13
神奈川Ruby会議01のペアプロ問題から。 http://nabetani.sakura.ne.jp/kanagawa.rb/evalex/
require 'strscan'
=begin
神奈川Ruby会議01のペアプロ問題から。 http://nabetani.sakura.ne.jp/kanagawa.rb/evalex/
ちょうど今読んでいる http://www.amazon.co.jp/Programming-Principles-Practice-Using-Edition/dp/0321992784
に電卓を作る例があったので、ほとんど写経するような形で書いてみた。
書いておきながら細かいところをちゃんと説明できないので途中まで書いていてすごく不安だった...
=end
Token = Struct.new(:kind, :string)
@igrep
igrep / file0.txt
Last active August 29, 2015 14:16
間違えてmasterやdevelopにpushしてしまうあなたは今すぐこれを.git/hooks/pre-commitにコピペしなさい ref: http://qiita.com/igrep/items/b0eabaeb7b301cdc2045
#!/bin/bash
current_branch=$(git rev-parse --abbrev-ref HEAD)
warn_branch() {
echo "You can't commit on '$current_branch'!"
}
case $current_branch in
master) warn_branch; exit 1 ;; # Of cource you can add any other important branches as you need.
@igrep
igrep / file0.html
Last active October 7, 2015 06:13
閉じるボタンを押したら確認してくれるメモ帳を作るワンライナー ref: http://qiita.com/igrep/items/7b550bb9b19f44637990
data:text/html,<html contenteditable><script>window.onbeforeunload = function(){ return 'Close window?'; }</script>
$ npm install
npm WARN engine xmlbuilder@2.2.1: wanted: {"node":"0.8.x || 0.10.x"} (current: {"node":"0.12.4","npm":"2.10.1"})
node-webkit-winstate@1.1.1 node_modules\node-webkit-winstate
intelli-espower-loader@0.6.0 node_modules\intelli-espower-loader
parse-github-event@0.2.0 node_modules\parse-github-event
bluebird@2.9.27 node_modules\bluebird
@igrep
igrep / file0.vim
Last active August 29, 2015 14:22
全角アルファベットやひらがな・カタカナを入力しても(ちょっと)いい感じに解釈してくれるvimrc ref: http://qiita.com/igrep/items/2c0dae6242eed5baf172
"ひらがな・カタカナ・全角アルファベットによるコマンド入力を有効にする
noremap あ a
noremap い i
noremap う u
noremap え e
noremap お o
noremap ア a
noremap イ i
noremap ウ u
noremap エ e
@igrep
igrep / file0.rb
Created June 13, 2015 10:19
#yokohamarb 「Rubyレシピブック」recipe 194「ファイルに1行挿入する」の修正 ref: http://qiita.com/igrep/items/6e123a3e6681b9a62352
require 'tempfile'
require 'fileutils'
def insert path, start_line, data
pid = Process.pid.to_s
Tempfile.create pid, File.dirname(path) do|temp|
File.open(path) do|input|
start_line.times do
if line = input.gets
temp.write line
@igrep
igrep / file0.rb
Last active October 16, 2017 08:22
RSpec 3.0から3.3まで一気に上げたので独断と偏見で選んだ注目すべき新機能を紹介する ref: http://qiita.com/igrep/items/cd1d2ba8ce5ccb6f5f44
RSpec.configure do |c|
c.example_status_persistence_file_path = "./tmp/rspec-example-status.txt"
end
@igrep
igrep / commit-msg
Last active September 25, 2015 01:46
branch名にuser storyのidを入れてコミットメッセージにuser storyのURLを自動で貼る ref: http://qiita.com/igrep/items/17df4627192d7d9d3188
#!/bin/sh
story_id=$(git rev-parse --abbrev-ref HEAD | sed -n 's#.*stories/\([0-9]\+\).*#\1#p')
if [ -n "$story_id" ]; then
echo user story: https://www.pivotaltracker.com/story/show/$story_id >> $1
fi
@igrep
igrep / .vimrc
Last active November 11, 2020 20:49
vim-watchdogsでエラーをquickfix listに出した後、カーソルをquickfix listのウィンドウに移動させない ref: http://qiita.com/igrep/items/e5d288f42d9abb23e4c1
function! GoToPreviousWindowWhenQf() abort
if &filetype == 'qf'
wincmd p
endif
endfunction
let g:quickrun_config = {
\ "_": {
\ "outputter/quickfix/open_cmd" : "cwindow | call GoToPreviousWindowWhenQf()"
\ },
\ }
@igrep
igrep / auto-save-opening-files-bat.vim
Last active January 17, 2016 01:29
Save file names your vim opened, on a bat file to restore. Alternative to http://vim.wikia.com/wiki/Automatic_session_restore_in_git_directories
" Alternative to http://vim.wikia.com/wiki/Automatic_session_restore_in_git_directories for Windows.
" I created this because automatic session restore didn't work On my windows environment.
"
" Save a bat file to reopen the last opened files on exit.
" I consulted unite.vim\plugin\unite\buffer.vim for which events to autocmd and how to handle them.
if !( has('win32') || has('win64') )
finish
end