Skip to content

Instantly share code, notes, and snippets.

@no6v
no6v / aa.rb
Created October 25, 2011 03:36
# -*- coding: utf-8 -*-
# show raw text (as an ascii-art :) of output from specified command
# Usage:
# * input
# ⚡ :aa[ENTER]
# [input EOF (e.g. Ctrl+D) at the last]
# た
# て
# が
# き
# replace t.co shortened url to origin if entity is available
Earthquake.init do
output_filter do |item|
text = item["text"]
entities = item["entities"]
if text and entities
[entities["urls"], entities["media"]].compact.flatten.each do |url_entity|
url, expanded_url = url_entity.values_at("url", "expanded_url")
text.gsub!(url, expanded_url)
diff --git a/lib/earthquake/commands.rb b/lib/earthquake/commands.rb
index 182dea9..7a4391e 100644
--- a/lib/earthquake/commands.rb
+++ b/lib/earthquake/commands.rb
@@ -212,10 +212,13 @@ Earthquake.init do
end
command %r|^:open\s+(\d+)$|, :as => :open do |m|
- if match = twitter.status(m[1])["text"].match(URI.regexp(["http", "https"]))
- browse match[0]
kintsuba_sweets:
hosted_by_en: 'Kintsuba Sweets (#kintsuba)'
hosted_by_ja: 'きんつばスイーツの会 (#kintsuba)'
name_en: 'Kintsuba Sweets'
name_ja: 'きんつばスイーツの会'
dtstart: '2011-07-02 13:30'
dtend: '2011-07-02 17:30'
url: 'https://gist.github.com/1043321'
location: 'Seika-cho, Kyoto, JAPAN'
diff --git a/lib/earthquake/commands.rb b/lib/earthquake/commands.rb
index 80d1841..d9dfd9b 100644
--- a/lib/earthquake/commands.rb
+++ b/lib/earthquake/commands.rb
@@ -79,6 +79,12 @@ Earthquake.init do
puts_items twitter.user_timeline(:screen_name => m[1])
end
+ # :recent jugyo $gg
+ # good shortcut to trace back through ones history
# -*- coding: utf-8 -*-
RUBY_DESCRIPTION # => "ruby 1.9.3dev (2011-05-11 trunk 31505) [x86_64-linux]"
s = "エンコーディング"
s # => "エンコーディング"
s.inspect # => "\"エンコーディング\""
s.inspect.encoding # => #<Encoding:UTF-8>
module Earthquake::Input
def friends
@friends ||= []
end
end
Earthquake.init do
output :friend_completion do |item|
next unless item["user"]
(friends << "@#{item["user"]["screen_name"]}").uniq!
module Earthquake::Input
def drafts
@drafts ||= []
end
end
dbfile = File.join(Earthquake.config[:plugin_dir], "draft.yml")
Earthquake.once do
draft = YAML.load(File.open(dbfile, "a+", &:read))
Earthquake.init do
icon_dir = File.join(config[:plugin_dir], "icons")
icon_path = ->(item){
icon_file = File.join(icon_dir, item["user"]["screen_name"])
mtime = File.exist?(icon_file) ? File.mtime(icon_file) : Time.at(0)
begin
image = open(item["user"]["profile_image_url"], "If-Modified-Since" => mtime.rfc2822, &:read)
File.open(icon_file, "wb"){|f| f.write(image)}
rescue OpenURI::HTTPError
end
# -*- coding: utf-8 -*-
# https://twitter.com/#!/jugyo/status/51959560084275200
Earthquake.init do
t = {
"u" => ":update",
"re" => ":reply",
"rt" => ":retweet",
"l" => ":recent",
"show" => ":status",
}