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
# -*- coding: utf-8 -*-
# GistID: 5023809
# Tried by: Rails 3.2.12
# 控えめで (Unobtrusive) 自己中な (Selfish) Controller
class UnobtrusiveJikochusController < ApplicationController
def index
@unobtrusive_jikochus = UnobtrusiveJikochu.all
@igrep
igrep / pre-commit.bash
Created March 14, 2013 01:23
Prevent you from committing on important branches.
#!/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.
{-# LANGUAGE OverloadedStrings #-}
module Main where
import System.Environment (getArgs)
import Data.String.Utils (split)
import Data.Char (digitToInt, intToDigit, isDigit)
import Data.List (sort, permutations)
import Data.Maybe (listToMaybe)
@igrep
igrep / sl
Last active December 16, 2015 11:38
#!/bin/env ruby
# GistID: 5428360
require 'termcolor'
$KCODE = 'u' if RUBY_VERSION < '1.9'
$VERBOSE = true
unless Array.method_defined? :sample
class Array # reopen
class IrrescuableException < StandardError
# But actually, rescued!
def is_a? _klass
false
end
end
begin
raise IrrescuableException
rescue Exception => e
class DefinitelyRescuedException < Exception
def is_a? _klass
true
end
def < _klass
true
end
def > _klass
false
end
@igrep
igrep / snapshot-vbox-ubuntu.bat
Created June 2, 2013 09:46
take a snapshot of my VM 自分用VMのスナップショットを日付付きで。 参考: http://d.hatena.ne.jp/machua/20100502/1272780972 http://d.hatena.ne.jp/ymaru/20071123/p1
set date_tmp=%date:/=%
set time_tmp=%time: =0%
set yyyy=%date_tmp:~0,4%
set mm=%date_tmp:~4,2%
set dd=%date_tmp:~6,2%
set hh=%time_tmp:~0,2%
set mi=%time_tmp:~3,2%
set datetime=%yyyy%-%mm%-%dd%-%hh%-%mi%
#!/usr/bin/ruby
# -*- coding: utf-8 -*-
# GistID: 6203578
=begin
Rubyのリファレンスマニュアル( http://doc.ruby-lang.org/ja/2.0.0/doc/spec=2fdef.html#alias )
「別名を付けられたメソッドは、その時点でのメソッド定義を引き継ぎ、元のメソッドが再定義されても、
再定義前の古いメソッドと同じ働きをします。あるメソッドの動作を変え、
再定義するメソッドで元のメソッドの結果を利用したいときなどに利用されます。」
の通り、
@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.
"
@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