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 / 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 / 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.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
$ npm install
npm WARN engine [email protected]: wanted: {"node":"0.8.x || 0.10.x"} (current: {"node":"0.12.4","npm":"2.10.1"})
[email protected] node_modules\node-webkit-winstate
[email protected] node_modules\intelli-espower-loader
[email protected] node_modules\parse-github-event
[email protected] node_modules\bluebird
@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>
@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 / 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 / 0_reuse_code.js
Last active August 29, 2015 14:13
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@igrep
igrep / git_menu.vim
Last active August 29, 2015 13:55 — forked from scrooloose/git_menu.vim
Adds git command menu items.
" Put this in ~/.vim/after/nerdtree_plugin/git_menu.vim
" NOTE: I fixed a bug of NERDTree to get this plugin work.
" You may have to cherry-pick or fork the pull request to use this plugin.
" https://github.com/scrooloose/nerdtree/pull/308
"
" Adds git command menu items
"
" TODO: Behave like nerdtree_plugin/fs_menu.vim
" Extend nerdtree_plugin/fs_menu.vim without deleting any defalut menu items.
"
#!/usr/bin/ruby
# -*- coding: utf-8 -*-
# GistID: 6203578
=begin
Rubyのリファレンスマニュアル( http://doc.ruby-lang.org/ja/2.0.0/doc/spec=2fdef.html#alias )
「別名を付けられたメソッドは、その時点でのメソッド定義を引き継ぎ、元のメソッドが再定義されても、
再定義前の古いメソッドと同じ働きをします。あるメソッドの動作を変え、
再定義するメソッドで元のメソッドの結果を利用したいときなどに利用されます。」
の通り、