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 / 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%
class DefinitelyRescuedException < Exception
def is_a? _klass
true
end
def < _klass
true
end
def > _klass
false
end
class IrrescuableException < StandardError
# But actually, rescued!
def is_a? _klass
false
end
end
begin
raise IrrescuableException
rescue Exception => e
@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
{-# 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 / 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.
# -*- coding: utf-8 -*-
# GistID: 5023809
# Tried by: Rails 3.2.12
# 控えめで (Unobtrusive) 自己中な (Selfish) Controller
class UnobtrusiveJikochusController < ApplicationController
def index
@unobtrusive_jikochus = UnobtrusiveJikochu.all
# -*- coding: utf-8 -*-
# GistID: 5023699
# Tried by: Rails 3.2.12
# 自己中な (Selfish) Controller
class JikochusController < ApplicationController
def index
@jikochus = Jikochu.all
@igrep
igrep / 2013-02-17-reproduce-git.sh
Created February 17, 2013 12:15
A literate bash script.
#!/usr/bin/bashdb
# GistID: 4971264
######################################################
# NOTES:
# This is not just an executable shell script.
# You can read this as a blog post also.
# And by excuting, you'll find what I experienced.
# I recommend you to execute this script step by step
@igrep
igrep / install-only-changed.sh
Last active December 11, 2015 22:58
maybe useful when you want to try your committed vimscript on your vim
#!/bin/bash
# maybe useful when you want to try your committed vimscript on your vim
# WARNING: as written, this script doesn't backup the destination directory
GIT_PAGER=cat
PAGER=cat
updated_files=$(git diff --name-only master)
dest_dir=$1