Skip to content

Instantly share code, notes, and snippets.

@morygonzalez
Created January 9, 2013 05:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save morygonzalez/4490769 to your computer and use it in GitHub Desktop.
Save morygonzalez/4490769 to your computer and use it in GitHub Desktop.
earthquake.gem で必ず140文字投稿する
# coding: utf-8
# always tweet with 140 characters
# port of https://gist.github.com/453709
#
Earthquake.init do
command :t140 do |m|
max = 140
body = m[1]
len = body.length
mod = max % len
ext = (0..len).to_a.sort_by { rand }.take(mod)
str = body.split(//).each_with_index.map {|c, i|
c * (max / len + (ext.include?(i) ? 1 : 0))
}.join('')
input str
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment