Skip to content

Instantly share code, notes, and snippets.

View kakutani's full-sized avatar

Kakutani Shintaro kakutani

View GitHub Profile
diff --git a/tdiary/dispatcher.rb b/tdiary/dispatcher.rb
index 4be53ca..ee8ef11 100644
--- a/tdiary/dispatcher.rb
+++ b/tdiary/dispatcher.rb
@@ -96,7 +96,7 @@ module TDiary
body = tdiary.eval_rhtml
head['ETag'] = %Q["#{Digest::MD5.hexdigest( body )}"]
if ENV['HTTP_IF_NONE_MATCH'] == head['ETag'] and /^GET$/i =~ @cgi.request_method then
- head['status'] = CGI::HTTP_STATUS['NOT_MODIFIED']
+ status = CGI::HTTP_STATUS['NOT_MODIFIED']
oops. this gist is wrong.see http://gist.github.com/729103
@kakutani
kakutani / gist:662448
Created November 4, 2010 13:20
drbspec
#!/usr/bin/env ruby
require 'drb'
begin
begin
DRb.start_service("druby://localhost:0")
rescue SocketError, Errno::EADDRNOTAVAIL
DRb.start_service("druby://:0")
end
#!/usr/bin/env ruby19
require 'csv'
require 'erb'
TEMPLATE = DATA.read
@titles = "* Title index\n"
@talks = ""
def each_entry(row, idx)
talk_idx = "%02d" % idx
diff --git a/app/models/rubyist.rb b/app/models/rubyist.rb
index 48ef14f..8fe9848 100644
--- a/app/models/rubyist.rb
+++ b/app/models/rubyist.rb
@@ -4,7 +4,7 @@ class Rubyist < ActiveRecord::Base
has_many :contributions
validates_uniqueness_of :username
- validates_format_of :username, :with => /^[\w-]+$/
+ validates_format_of :username, :with => /^[a-zA-Z_-]+$/
$:.unshift(File.dirname(__FILE__))
require 'spec_helper'
module BowlongGameMacro
class BowlongGamePlayer
def initialize
@game = Game.new
end
def roll_spare
$ spec -cfn spec/game_spec.rb
すべてガターの場合
should == 0
すべて1ピンの場合
should == 20
スペアの場合
次の投球で倒したピンがボーナス加算される
ストライクの場合
次のフレームの得点がボーナス加算される
ストライク、ガター、スペアの場合
#!/bin/sh
REPO=$1
newgrp src
GIT_DIR=/var/cache/git/$REPO git --bare init --shared
cd /var/cache/git/empty
git push ../$REPO master
describe 'to_branch' do
it do
to_branch(
:a => [:b, :c],
:b => [:d],
:c => [:d]
).should == [
[:a, :b, :d]
[:a, :c, :d]
]
@kakutani
kakutani / gist:287512
Created January 27, 2010 03:29 — forked from ursm/gist:274806
require "rack/openid"
require "warden"
use Rack::OpenID
use Warden::Manager do |manager|
Warden::Strategies.add(:openid) do
def authenticate!
if resp = env["rack.openid.response"]
case resp.status
when :success