This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # -*- coding: utf-8 -*- | |
| # GistID: 5023809 | |
| # Tried by: Rails 3.2.12 | |
| # 控えめで (Unobtrusive) 自己中な (Selfish) Controller | |
| class UnobtrusiveJikochusController < ApplicationController | |
| def index | |
| @unobtrusive_jikochus = UnobtrusiveJikochu.all |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {-# 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/env ruby | |
| # GistID: 5428360 | |
| require 'termcolor' | |
| $KCODE = 'u' if RUBY_VERSION < '1.9' | |
| $VERBOSE = true | |
| unless Array.method_defined? :sample | |
| class Array # reopen |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class IrrescuableException < StandardError | |
| # But actually, rescued! | |
| def is_a? _klass | |
| false | |
| end | |
| end | |
| begin | |
| raise IrrescuableException | |
| rescue Exception => e |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class DefinitelyRescuedException < Exception | |
| def is_a? _klass | |
| true | |
| end | |
| def < _klass | |
| true | |
| end | |
| def > _klass | |
| false | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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% |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/ruby | |
| # -*- coding: utf-8 -*- | |
| # GistID: 6203578 | |
| =begin | |
| Rubyのリファレンスマニュアル( http://doc.ruby-lang.org/ja/2.0.0/doc/spec=2fdef.html#alias ) | |
| 「別名を付けられたメソッドは、その時点でのメソッド定義を引き継ぎ、元のメソッドが再定義されても、 | |
| 再定義前の古いメソッドと同じ働きをします。あるメソッドの動作を変え、 | |
| 再定義するメソッドで元のメソッドの結果を利用したいときなどに利用されます。」 | |
| の通り、 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Use Gists to store code you would like to remember later on | |
| console.log(window); // log the "window" object to the console |