Skip to content

Instantly share code, notes, and snippets.

View Shinpeim's full-sized avatar

Shinpei Maruyama Shinpeim

View GitHub Profile
function akari(){
echo "わぁい$1 あかり$1大好き"
}
# -*- coding: utf-8 -*-
Y = lambda { |f|
lambda{|proc|
f.call(lambda{|args| proc.call(proc).call(args)})
}.call(
lambda{|proc|
f.call(lambda{|args| proc.call(proc).call(args) })
}
)
}
@Shinpeim
Shinpeim / nginx-conf.rb
Created July 12, 2012 05:14
rails + unicorn + nginx の立ちあげちょっと簡単にするやつ
#!/usr/bin/env ruby
require 'thor'
class NginxConf < Thor
desc 'register PORT', 'install new config file'
option :prefix, type: :string, default: "/usr/local"
def register(port)
root = Dir::pwd
project = root.split(/\//).last
@Shinpeim
Shinpeim / validator.rb
Created July 12, 2012 12:04
こんな感じの動きするやつ欲しい
# -*- coding: utf-8 -*-
class PersonValidator < Validator
validates :name, {
:presence => true,
:format => { :with => /\A[a-zA-Z]+\z/, :message => "お名前に使えるのはアルファベットだけだよ!" }
}
validates :sex, {
:inclusion => ["male", "female", "other"],
:messages => "unknown parameter",
}
# -*- coding: utf-8 -*-
class Nyan
def nyan
return "にゃーん"
end
end
# 別のところで 上書きしたい classを openする
@Shinpeim
Shinpeim / github.txt
Created July 20, 2012 02:33 — forked from rummelonp/github.txt
Fork me!!
 (\ (\
(,, 0 ω 0) < Github
(/ (/ \) \)

unicornのシグナルまとめ

Masterに送るシグナル

HUP

unicornに食わせた設定ファイルの preload_app が false なら、application codeのあらゆる変化を読み込んだ上でworkerをリスタートする。preload_appがtrueならばapplication codeが変化しててもそれを反映しない。その場合USR2 + QUIT使わないとだめ

reloadするときに Gem.refresh が呼ばれるので、Gemfileに新しいライブラリ書いてあればそれ読み込むよ

@Shinpeim
Shinpeim / tex.c
Created July 31, 2012 05:49
理系男子に朗報
#include <stdio.h>
int main(int argc, char *argv[]){
char chars[] = "TeX";
chars[0]--;
printf("%s",chars);
return 0;
}
# -*- coding: utf-8 -*-
class C季節
def next
next_season.new
end
end
class C春 < C季節
def next_season
C夏
def expect_block(&block)
p block.class # => Proc
p block_given? # => true
yield # => this is block
deep_method(&block)# => this is block
deep_method(block) # error
end
def deep_method