Skip to content

Instantly share code, notes, and snippets.

@babie
babie / temperature.rb
Last active December 21, 2015 05:39
require Ruby 2.0.0 or newer
#!/usr/bin/env ruby
module Temperature
refine Numeric do
def to_fahr
self.to_f * 9 / 5 + 32
end
def to_cels
(self.to_f - 32) * 5 / 9
Earthquake.init do
_ = config[:auto_restart] ||= {}
_[:interval] ||= 60 * 60
system "stty echo" # for readline
EM.defer do
sleep config[:auto_restart][:interval]
loop do
if Readline.line_buffer.nil? || Readline.line_buffer.empty?
require "date"
Earthquake.init do
_ = config[:fav_machine] ||= {}
_[:dir] ||= File.expand_path("./fav_machine", config[:dir])
_[:screen_names] ||= [twitter.info["screen_name"]]
FileUtils.mkdir_p(_[:dir]) unless Dir.exist? _[:dir]
output_filter do |item|
if item["event"] == "favorite" && config[:fav_machine][:screen_names].include?(item["source"]["screen_name"])
module TwitterOAuth
class Client
def update_profile(params)
post("/account/update_profile.json", params)
end
end
end
Earthquake.init do
%w[name description url location].each do |word|
module TwitterOAuth
class Client
def get_lists(user)
get("/lists/list.json?screen_name=#{user}")
end
end
end
module Earthquake::Input
def lists
require "date"
Earthquake.init do
_ = config[:save_image] ||= {}
_[:dir] ||= File.expand_path("./image", config[:dir])
FileUtils.mkdir_p(_[:dir]) unless Dir.exist? _[:dir]
command :save_image do |m|
tweet = twitter.status(m[1])
media = tweet["entities"]["media"]
# Earthquake.config[:event_chain] = {
# :favorite => [':retweet %{id}'],
# :favorited => [':update @%{him} thx 4 ur fav!'],
# :followed => ['unblock %{him}', ':follow %{him}'],
# }
module Earthquake::Input
def passivise(str)
if str.end_with?("ed")
str
elsif str.end_with?("e")
description "earthquake server"
author "babie <babie@example.com>"
start on filesystem or runlevel [2345]
stop on runlevel [!2345]
respawn
respawn limit 10 5
setuid babie
description "earthquake server"
author "babie wildheart <babie@example.com>"
# start,stopは正常に動くがsocat&reptyrで繋いだ時、文字入力に不具合がある
start on filesystem or runlevel [2345]
stop on runlevel [!2345]
respawn
respawn limit 10 5
description "earthquake server"
author "babie wildheart <babie@example.com>"
start on filesystem or runlevel [2345]
stop on runlevel [!2345]
respawn
respawn limit 10 5
setuid babie