Skip to content

Instantly share code, notes, and snippets.

View shishi's full-sized avatar
🏠
Working from home

Shigenobu Nishikawa shishi

🏠
Working from home
View GitHub Profile
@rosylilly
rosylilly / gist:3401612
Created August 20, 2012 06:40
先輩と覚える HTTP ステータスコード

先輩に学ぶ HTTP Status Code

超雑にまとめました。修正してください。

登場人物

  • アプリケーション先輩: いつも忙しい。横に広がるのが得意(デブじゃない)。
  • 後輩: 頼んでばっかしで役に立たない。
  • サーバー先輩: アプリケーション先輩と仲がいい。Unix Socket でつながるくらい仲良し。
  • プロクシ先輩: アプリケーション先輩とかサーバー先輩と後輩の間を取り持って代わりに伝えたりしてくれる。たまに勝手にレスポンスを書き換える。
@fujimura
fujimura / delete_remote_branch.sh
Created June 25, 2012 12:05
Delete remote branches except master
git branch -a | grep origin | cut -d / -f 3 | grep -v master | \
ruby -e "STDIN.to_a.tap(&:shift).map(&:chomp).each {|s| p %|git push origin :#{s}| }"
# replace `p` with `system` to run actual command
@tancnle
tancnle / gist:2969692
Created June 22, 2012 01:32
Fix incorrect Nokogiri loaded libraries

Every time I upgrade libxml2 via Homebrew, running cucumber test will post an annoying warning message

WARNING: Nokogiri was built against LibXML version 2.7.3, but has dynamically loaded 2.8.0

To fix it:

$ gem uninstall nokogiri
$ brew link libxml2

$ gem install nokogiri -- --with-xml2-include=/usr/local/Cellar/libxml2/2.8.0/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.8.0/lib --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.26

phpbrew install php-5.4.2 +mysql +pdo +apxs2=/opt/local/apache2/bin/apxs +ftp +pgsql=/opt/local/lib/postgresql91 +sqlite+imap+ipc+pcntl+calendar
import Data.List
data Suit = Spade | Diamond | Club | Heart
deriving (Eq, Show, Ord)
data Card = Card Suit Int
deriving (Eq, Show, Ord)
suit (Card s _) = s
rank (Card _ r) = r
@ppworks
ppworks / roman.rb
Created April 26, 2012 03:49
Convert a Number into Roman Numerals.
module Roman
CHAR = "IVXLCDM"
def self.to_num n
return "" if n <= 0 || 5000 <= n
str = sprintf("%04d", n).reverse!
res = ''
4.times do|i|
res = "#{roman_char(str[i], i*2)}#{res}"
end
res
@joker1007
joker1007 / roman_number.rb
Created April 25, 2012 15:09
Fixnum convert to Roman Number String
class Fixnum
def to_roman
return "" unless (1..3999).include?(self)
digit_count = Math.log(self, 10).to_i
case digit_count
when 0
minor = "I"
major = "V"
@kei-q
kei-q / roman.rb
Created April 25, 2012 14:44
shinjuku.rbでもくもくと書いてたコード 負の数を入れたら挙動おかしいね
# digit : 一桁の数字
# roman : その桁の1, 5, 10を表す文字三文字 (ex: 'IVX')
def digit2roman(digit, roman)
a, b, c = roman.split(//)
case digit
when 0 then ''
when 1..3 then a * digit
when 4 then a + b
when 5 then b
;;; anything
(setq anything-command-map-prefix-key "C-x C-a")
(require 'anything)
;; C-z は C-; で実行できるようにする
(define-key anything-map (kbd "C-;") 'anything-execute-persistent-action)
(define-key anything-map (kbd "M-;") 'anything-execute-persistent-action)
(require 'anything-startup)
(dolist (map (list
anything-map
anything-c-buffer-map
@hidenorigoto
hidenorigoto / gist:1223740
Created September 17, 2011 07:59
Stagehand_TestRunner for Symfony2

Symfony2のプロジェクトをStagehand_TestRunnerで継続テストする

準備

最初にプリロード用スクリプトを用意します。 プリロードスクリプトでは、Symfony2のカーネルディレクトリ(KERNEL_DIR)の設定と、Symfony2のブートストラップファイルの読み込みを行うようにします。 (app/testrunner_preload.phpに作成します)