Skip to content

Instantly share code, notes, and snippets.

View masuidrive's full-sized avatar

Yuichiro MASUI masuidrive

View GitHub Profile
# Cucumber email_steps.rb for Merb
Given /^clear mailbox$/ do
Merb::Mailer.deliveries.clear.should == []
end
Then /^I should receive (an|\d+) emails?$/ do |amount|
amount = 1 if amount == "an"
Merb::Mailer.deliveries.size.should == amount
end
var funcs = [];
for(var i=0; i<10; ++i) {
funcs[i] = function() { console.log(i); }
}
i = -1;
for(var ii=0; ii<10; ++ii) funcs[ii]();
// -1が10回表示
@masuidrive
masuidrive / build-adhoc.rb
Created August 31, 2009 13:31
Automatic to build iPhone app package for AdHoc distribution
#!/usr/bin/env ruby
#
# build AdHoc package
#
# Install:
# sudo gem install mechanize
#
# Usage:
# ruby build-adhoc.rb adhoc.yaml
require 'open3'
require 'rubygems'
require 'zip/zipfilesystem'
require 'fileutils'
module Tempdir
def self.path(&block)
result = path = nil
begin
path = File.join((ENV['TMPDIR'] || ENV['TMP'] || ENV['TEMP'] || '/tmp'), "temp.#{$$}.#{Time.now.to_f}")
@masuidrive
masuidrive / geohash.rb
Created October 18, 2009 03:18
Geohash encode for pure ruby
=begin
geohash.rb
Geohash library for pure ruby
(c) 2009 Yuichiro MASUI
Distributed under the MIT License
move to http://github.com/masuidrive/pr_geohash
=end
@masuidrive
masuidrive / gist:212597
Created October 18, 2009 08:48
東京付近のGeoHashの精度
=begin
東京付近のGeoHashの精度
|文字数| 南北 | 東西 |
| 6| 609.08m| 988.77m|
| 7| 152.27m| 123.60m|
| 8| 19.03m| 30.90m|
| 9| 4.76m| 3.86m|
| 10| 0.59m| 0.97m|
# リファクタリング前
def encode(latitude, longitude, precision=12)
lat = [-90.0, 90.0]
lng = [-180.0, 180.0]
is_even = true
bit = ch = 0
geohash = ""
while geohash.length < precision do
point = is_even ? lng : lat
yum install gcc zlib-devel rpm-build openssl-devel readline-devel nkf
wget http://futuremix.org/downloads/checkinstall-1.6.1-1.x86_64.rpm
rpm -ivh checkinstall-1.6.1-1.x86_64.rpm
wget ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p174.tar.bz2
tar xfj ruby-1.8.7-p174.tar.bz2
cd ruby-1.8.7-p174
./configure --prefix=/usr --with-install-readline
make
#!/bin/sh
wget http://1978th.net/tokyocabinet/tokyocabinet-1.4.41.tar.gz
tar xvzf tokyocabinet-1.4.41.tar.gz
cd tokyocabinet-1.4.41
./configure; make
sudo make install
cd ..
wget http://1978th.net/tokyodystopia/tokyodystopia-0.9.13.tar.gz
tar xvzf tokyodystopia-0.9.13.tar.gz
From f57d62514eb35da0f87c880bb888bd620729e23d Mon Sep 17 00:00:00 2001
From: masuidrive <[email protected]>
Date: Wed, 10 Feb 2010 02:21:54 -0800
Subject: [PATCH] Compile on space included directory
---
wscript | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/wscript b/wscript