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
-- | |
-- expire record and memcached record | |
-- | |
require('Memcached') -- http://luamemcached.luaforge.net/ | |
-- http://mixi.jp/view_bbs.pl?id=33263045&comm_id=3528783 #20 | |
connect_memcache() | |
function expire() | |
local args = {} |
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
require 'rbconfig' | |
ruby_path = File.join(Config::CONFIG["bindir"], | |
Config::CONFIG["RUBY_INSTALL_NAME"]+ | |
Config::CONFIG["EXEEXT"]) | |
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
/* | |
* Take screen capture on AS2 | |
*/ | |
ExternalInterface.addCallback("take_snap", null, | |
function():Void { | |
var width:Number = Stage.width; | |
var height:Number = Stage.height; | |
var snap:BitmapData = new BitmapData(width, height); |
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
# 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 |
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
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回表示 | |
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 | |
# | |
# build AdHoc package | |
# | |
# Install: | |
# sudo gem install mechanize | |
# | |
# Usage: | |
# ruby build-adhoc.rb adhoc.yaml |
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
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}") |
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
=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 |
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
=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| |
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
# リファクタリング前 | |
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 |