Skip to content

Instantly share code, notes, and snippets.

Earthquake.init do
command :size do |m|
p m[1].size
end
end
@no6v
no6v / bitly.rb
Created February 20, 2012 21:56 — forked from jugyo/bitly.rb
# earthquake.gem plugin
# shorten url using bit.ly if text is over 140
Earthquake.init do
config[:bitly] ||= {}
config[:bitly][:username] ||= 'earthquakegem'
config[:bitly][:api_key] ||= 'R_22e702353baf49751d053660e4c71a30'
config[:bitly][:domain] ||= 'j.mp'
input_filter do |text|
if /^:(update|reply|retweet|message)\s+/ === text and text.size - $&.size > 140
# http://d.hatena.ne.jp/sugyan/20120219/1329623605
Earthquake.init do
command :reduce_friends do
catch(:q) do
puts "YOU MAY LOSE YOUR ALL FRIENDS WHILE IDLING THE DAY AWAY".c(:notice)
until (friends = twitter.friends(page = (page ||= 0).next)).empty?
friends.shuffle.each do |friend|
name = friend["name"]
screen_name = friend["screen_name"]
@no6v
no6v / name_colors.rb
Created January 21, 2012 14:06
Customized colors for names and hashtags
# encoding: UTF-8
# ### Customized colors for names and hashtags
#
# # See Earthquake.config[:color] for available color names.
# # Only which looks like a color name is the name of the color :).
#
# ⚡ :eval config[:color]
#
# # Colors also can be specified by a single number.
# # Using colors for background (ex. 44) will not work well on search results.
diff --git a/lib/earthquake.rb b/lib/earthquake.rb
index be11649..328df67 100644
--- a/lib/earthquake.rb
+++ b/lib/earthquake.rb
@@ -27,4 +27,5 @@ Encoding.default_external = Encoding.find('UTF-8')
help
commands
id_var
+ item
).each { |name| require_dependency File.expand_path("../earthquake/#{name}", __FILE__) }
diff --git a/lib/earthquake/commands.rb b/lib/earthquake/commands.rb
index 755e600..13748fe 100644
--- a/lib/earthquake/commands.rb
+++ b/lib/earthquake/commands.rb
@@ -343,7 +343,7 @@ Earthquake.init do
command :sent_messages do
puts_items twitter.sent_messages.each { |s|
- s["user"] = {"screen_name" => s["sender_screen_name"]}
+ s["user"] = {"screen_name" => s["recipient_screen_name"]}
@no6v
no6v / trace.rb
Created December 28, 2011 22:26
Trace back home or user timeline
# encoding: UTF-8
Earthquake.once do
module TwitterOAuth
class Client
def list_statuses(user, list, **options)
options = URI.encode_www_form(options)
get("/lists/statuses.json?slug=#{list}&owner_screen_name=#{user}&#{options}")
end
end
end
@no6v
no6v / em.rb
Created December 25, 2011 02:02
require "eventmachine"
EventMachine.run do
Thread.new do
begin
system("cat")
rescue Exception => e
p e
ensure
EventMachine.stop_event_loop
diff --git a/lib/earthquake/commands.rb b/lib/earthquake/commands.rb
index 6551bfc..033578b 100644
--- a/lib/earthquake/commands.rb
+++ b/lib/earthquake/commands.rb
@@ -232,12 +232,14 @@ Earthquake.init do
}
command %r!^:filter off$!, as: :filter do
+ highlights.delete(:filter_keyword)
config[:api] = default_stream
@no6v
no6v / trends.rb
Created December 5, 2011 12:46
Show top 10 trends for the location