Skip to content

Instantly share code, notes, and snippets.

View krhitoshi's full-sized avatar

Hitoshi Kurokawa krhitoshi

View GitHub Profile
def ask_password(message)
HighLine.new.ask(message) do |q|
q.echo = false
end
end
@ktsugita
ktsugita / tai64.rb
Created July 28, 2008 23:43
tai64.rb
# tai64.rb
# http://cr.yp.to/libtai/tai64.html
class Time
TAI64_REGEX = Regexp.new(/(?:^\@)?([0-9a-fA-F]{16})/)
TAI64N_REGEX = Regexp.new(/#{TAI64_REGEX}([0-9a-fA-F]{8})/)
def self.tai64(str, leapseconds=10)
if match = TAI64N_REGEX.match(str).to_a.values_at(1)
tai64 = match[0].hex - 2**62 - leapseconds
return Time.at(tai64)