Skip to content

Instantly share code, notes, and snippets.

# test utf8mb4
"𠜱"
require 'singleton'
class GlobalThingy
include Singleton
end
GlobalThingy.instance
GlobalThingy.instance.object_id
GlobalThingy.new
@yinquanteo
yinquanteo / string_inquirer.rb
Last active December 31, 2015 13:09
ActiveSupport::StringInquirer
require 'active_support'
module Yink
def self.feeling
ActiveSupport::StringInquirer.new(@emotion || "")
end
def self.feeling= emotion
@emotion = emotion
end
@yinquanteo
yinquanteo / estimate.rb
Created June 4, 2013 16:40
How much of Singapore is within 200m of any bus stop? http://blog.yinquanteo.com/post/52148740742
require 'httparty'
require 'json'
@distance_threshold = 0.2 # km
@num_points = 1000
# bus stop data from https://github.com/cheeaun/busrouter-sg
bus_stops = JSON.parse(File.read("coords.json"))
LAT_BOUNDS = [1.2090608106559089, 1.4827849060588993]
LNG_BOUNDS = [103.6040031910045 , 104.08637166024278]