Skip to content

Instantly share code, notes, and snippets.

@hexgnu
Created January 4, 2012 17:49
Show Gist options
  • Save hexgnu/1561166 to your computer and use it in GitHub Desktop.
Save hexgnu/1561166 to your computer and use it in GitHub Desktop.
RandomTwitter
require 'randomizer'
class RandomTwitter
def initialize(post_id = 154614963917438976, user_id = 309802181)
@post_id = post_id
@user_id = user_id
end
def random_twitter_hash
{
:text => "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Vivamus vitae risus vitae lorem iaculis placerat. Aliquam sit amet felis. Etiam co",
:geo => nil,
:favorited => [true, false][rand.round],
:retweet_count => rand(100).round,
:in_reply_to_screen_name => nil,
:source => "beep",
:in_reply_to_status_id_str => nil,
:id_str => (@post_id += 1).to_s,
:entities => random_entities_hash,
:in_reply_to_status_id => nil,
:place => nil,
:retweeted => [true, false][rand.round],
:in_reply_to_user_id_str => nil,
:truncated => false,
:created_at => Time.now.strftime("%a %b %d %H:%M:%S +0000 2012"),
:coordinates => nil,
:user => random_user_hash
}
end
def random_entities_hash
{
:user_mentions => [{"indices" => [17,31],"screen_name" => "LaurisSabogal","id_str" => "181264929","name" => " Laura Sabogal","id" => 181264929}],
:hashtags => [],
:urls => []
}
end
def random_user_hash
u = RandomUser.new
{ "time_zone"=>"Central Time (US & Canada)",
"profile_background_color"=>"8e86eb",
"is_translator"=>[true,false][rand.round],
"contributors_enabled"=>false, "profile_background_tile"=>true,
"profile_background_image_url_https"=>"https://si0.twimg.com/images/themes/theme1/bg.png",
"friends_count"=>rand(4_000_000).to_i, "followers_count"=>rand(4_000_000).to_i,
"profile_image_url"=>"http://a1.twimg.com/profile_images/1379132084/M__paula_normal.jpg",
"default_profile"=>false, "listed_count"=>rand(30).to_i,
"profile_sidebar_fill_color"=>"363321",
"location"=>"Bogota -Colombia",
"screen_name"=>u.nickname,
"description"=> "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Vivamus vitae risus vitae lorem iaculis placerat. Aliquam sit amet felis. Etiam congue. Donec risus risus, pretium ac, tincidunt eu, tempor eu, quam. Morbi blandit mollis magna. Suspendisse eu tortor. Donec vitae",
"statuses_count"=>rand(3_000).to_i,
"verified"=>[true,false][rand.round],
"profile_sidebar_border_color"=>"0e9ae6",
"id_str"=>(@user_id += 1).to_s,
"lang"=>"en",
"default_profile_image"=>false,
"notifications"=>nil,
"profile_use_background_image"=>true, "profile_image_url_https"=>"https://si0.twimg.com/profile_images/1379132084/M__paula_normal.jpg",
"follow_request_sent"=>nil,
"geo_enabled"=>false,
"created_at"=>Time.at(Time.now.to_i - rand(4_000_000).to_i).strftime("%a %b %d %H:%M:%S +0000 2012"),
"profile_text_color"=>"e1e9ed",
"protected"=>false,
"following"=>nil,
"profile_background_image_url"=>"http://a0.twimg.com/images/themes/theme1/bg.png",
"name"=>u.full_name,
"show_all_inline_media"=>false,
"favourites_count"=>rand(30).to_i,
"profile_link_color"=>"e617e6",
"id"=>309802181,
"utc_offset"=>-21600,
"url"=>nil}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment