This file contains 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/env ruby | |
=begin | |
- clone current source before execute this. | |
$ git clone --depth=1 git://github.com/sandal/prawn.git | |
- fix font in line 14 | |
=end | |
$KCODE = "u" | |
$: << "./prawn/lib" |
This file contains 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
# | |
# get current IP addr. | |
# reject internal netwok(eg. vmnet0, for VMware) at the end of method chain. | |
# is there better way? | |
# | |
Socket.getaddrinfo(Socket.gethostname, 0, Socket::AF_INET). | |
map{|e| e[2] }. | |
uniq. | |
reject{|addr| addr =~ /\.1\Z/ } |
This file contains 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/env ruby | |
# vim:set fileencoding=utf-8 filetype=ruby | |
$KCODE = 'u' | |
describe "text spliting" do | |
before do | |
special = [ | |
[0x3001].pack("U"), # ten | |
[0x3002].pack("U"), # maru | |
[0x30fc].pack("U"), # bar/multibyte hyphun |
This file contains 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/env ruby | |
# vim:set fileencoding=utf-8 filetype=ruby | |
$KCODE = 'u' | |
require 'webrick/httpserver' | |
s = WEBrick::HTTPServer.new(:Port=>3030) | |
s.mount_proc("/deploy") do |req, res| | |
IO.popen("cap deploy"){|x| res.body = x.read } | |
res.status = ($? == 0 ? WEBrick::HTTPStatus::OK : WEBrick::HTTPStatus::BadRequest).code | |
end |
This file contains 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
# Methods added to this helper will be available to all templates in the application. | |
module ApplicationHelper | |
def javascript_include_file(filename) | |
if ::Rails.env == "development" | |
fullpath = File.expand_path("public/javascripts/#{filename}.js", ::Rails.root) | |
javascript_tag File.read(fullpath) | |
else | |
javascript_include_tag filename | |
end | |
end |
This file contains 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
# ============= Definition ============== | |
class User < ActiveRecord::Base | |
has_many :memberships | |
def accessible(klass) | |
klass.scoped( :conditions=>[<<-SQL, klass.name, self] ) | |
#{klass.table_name}.id IN ( | |
SELECT a.accessible_id | |
FROM accessibilities AS a | |
JOIN memberships AS m ON a.role_id = m.role_id |
This file contains 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/env ruby | |
$KCODE = 'u' | |
require 'rubygems' | |
require 'hpricot' | |
require 'thin' | |
require 'rack' | |
describe "My Rails App" do |
This file contains 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
皆様, | |
産総研の江渡です.お世話になっております. | |
第130回SIGHCI研究会の参加募集です. | |
今回は招待講演が3件もあり,充実しています. | |
今回は特に,ニコニコ動画の開発者として有名な戀塚昭彦氏に来ていただける | |
ことになりました.ニコニコ動画の裏側に,どのようなインタラクション上の | |
工夫があるかについてお話ししていただきます. |
This file contains 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
# Commonly used webrat steps | |
# http://github.com/brynary/webrat | |
When /言語は"(.*)"/ do |lang| | |
header("ACCEPT_LANGUAGE", lang) | |
end | |
When /^"(.*)"ボタンをクリックする$/ do |button| | |
clicks_button(button) | |
end |
This file contains 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
# Sets up the Rails environment for Cucumber | |
ENV["RAILS_ENV"] = "test" | |
require File.expand_path(File.dirname(__FILE__) + '/../../config/environment') | |
require 'cucumber/rails/world' | |
Cucumber::Rails.use_transactional_fixtures | |
# Comment out the next line if you're not using RSpec's matchers (should / should_not) in your steps. | |
require 'cucumber/rails/rspec' | |
ActionController::Base.class_eval do |
OlderNewer