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 -*- | |
require 'open-uri' | |
require 'rubygems' | |
require 'active_support/core_ext' | |
class GetQrcode | |
API_URL = "http://chart.apis.google.com/chart" | |
API_TYPE = "qr" | |
IMAGE_SIZE = "100x100" |
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
require 'rack' | |
HANDLER = Rack::Handler::Thin | |
PORT = 9292 | |
PUBLIC_DIR = "public" | |
module Rack | |
class File | |
def _call(env) | |
@path_info = Rack::Utils.unescape(env["PATH_INFO"]) |
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/sh | |
OSTYPE=`uname` | |
SED="sed" | |
if [ "${OSTYPE}x" != 'Linuxx' ] | |
then | |
SED="gsed" | |
fi | |
for i in `find app config db lib test spec -type f \( -name '*.rb' -o -name '*.rjs' -o -name '*.erb' -o -name '*.sel' \)` |
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
src=${HOME}/src | |
vimpath=${HOME}/bin/vim73 | |
mkdir -p $src | |
mkdir -p $vimpath | |
cd $src | |
hg clone https://vim.googlecode.com/hg/ vim | |
cd vim | |
./configure --prefix=$vimpath --enable-multibyte --with-features=huge --without-x --disable-gui | |
make && make install |
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
def fibs(n) | |
results = [] | |
a, b = 0, 1 | |
n.times do | |
results << a | |
a, b = b, a + b | |
end | |
results | |
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
function fibs(n) { | |
var generator = (function(){ | |
var beforeNum = 0; | |
var nextNum = 1; | |
var resultNum; | |
var f = function() { | |
resultNum = beforeNum; | |
beforeNum = nextNum; | |
nextNum = resultNum + nextNum; | |
return resultNum; |
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
gem 'nokogiri' | |
gem 'rack' | |
gem 'thin' |
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 -*- | |
require 'rack' | |
require 'action_controller/request' | |
require 'action_controller/response' | |
require 'action_controller/test_process' | |
module RequestSpecHelper | |
def self.included(closure) | |
closure.send :include, Helpers | |
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
# -*- coding: utf-8 -*- | |
# | |
# support_#{feature}? などというメソッドで、 | |
# 機能をサポートしているかどうかを返せるようにするためのモジュール | |
# | |
# インクルードしたクラスで | |
# | |
# feature :foo, :baa | |
# feature :hoge, :support => false | |
# feature :fuga, :support => true |
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
require 'ripper' | |
require 'cgi' | |
class Ruby2HTML < Ripper::Filter | |
def on_default(event, tok, f) | |
f << CGI.escapeHTML(tok) | |
end | |
private | |
def respond_to?(name, priv = false) |