-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
149 lines (123 loc) · 12.7 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
require 'rubygems'
require "active_record"
require './server.rb'
dbconfig = YAML.load(File.read('config/database.yml'))
env = ENV['SINATRA_ENV'] || 'production'
ActiveRecord::Base.establish_connection dbconfig[env]
namespace :db do
desc "Migrate the database"
task(:prepare) do
ActiveRecord::Schema.define do
create_table "users", :force => true do |t|
t.column "id_string", :string
t.column "email", :string
t.column "lat", :float
t.column "lng", :float
t.column "contact_method", :string
t.column "postal_code", :string
t.timestamps
end
create_table "posts", :force => true do |t|
t.column "i_got", :text
t.column "u_got", :text
t.column "contact_method", :text
t.column "email", :text
t.column "secret_id", :string
t.column "lat", :float
t.column "lng", :float
t.column "user_id", :integer
t.column "deleted", :boolean, :default => false
t.timestamps
end
create_table "tags", :force => true do |t|
t.column "name", :string
t.timestamps
end
create_table "taggings", :force => true do |t|
t.column "tag_id", :integer
t.column "post_id", :integer
t.column "user_id", :integer
t.timestamps
end
end
end
desc "Fill with noise"
task(:fill) do
jabberwock = <<-JABBER
<font size="+2">
`Twas brillig, and the slithy toves<br>
Did gyre and gimble in the wabe:<br>
All mimsy were the borogoves,<br>
And the mome raths outgrabe.<p>
</center>
<img src="/pics/jabberwocky.jpg" align="right" border=0 width=291
height=432>
<p><br>
"Beware the Jabberwock, my son!<br>
The jaws that bite, the claws that catch!<br>
Beware the Jubjub bird, and shun<br>
The frumious Bandersnatch!"<br>
<p>
He took his vorpal sword in hand:<br>
Long time the manxome foe he sought --<br>
So rested he by the Tumtum tree,<br>
And stood awhile in thought.<br>
<p>
And, as in uffish thought he stood,<br>
The Jabberwock, with eyes of flame,<br>
Came whiffling through the tulgey wood,<br>
And burbled as it came!<br>
<p>
One, two! One, two! And through and through<br>
The vorpal blade went snicker-snack!<br>
He left it dead, and with its head<br>
He went galumphing back.<br>
<p>
"And, has thou slain the Jabberwock?<br>
Come to my arms, my beamish boy!<br>
O frabjous day! Callooh! Callay!'<br>
He chortled in his joy.<br>
<br clear="all"><center><br>
`Twas brillig, and the slithy toves<br>
Did gyre and gimble in the wabe;<br>
All mimsy were the borogoves,<br>
And the mome raths outgrabe.
<p>
JABBER
haves = ['broccoli', 'cabbage', 'bok choy', 'horseradish', 'mustard greens', 'arugula', 'brussels sprouts', 'cauliflower', 'radishes', 'kohlrabi', 'broccoli rabe', 'organic kale', 'collards', 'turnips', 'rutabaga', 'watercress', 'beets', 'yams', 'carrots', 'parsnips', 'radish', 'potatoes', 'sweet potatoes', 'zucchini', 'strawberries', 'blueberries', 'grapes', 'rhubarb', 'home-brew beer', 'coffee beans','carrots', 'eggs', 'spinach', 'rhubarb', 'so much rhubarb', 'beans', 'basil', 'honey', 'zuchinni', 'cukes','lettuce','almonds', 'hazelnuts']
wants = ['broccoli', 'cabbage', 'bok choy', 'horseradish', 'mustard greens', 'arugula', 'brussels sprouts', 'cauliflower', 'radishes', 'kohlrabi', 'broccoli rabe', 'organic kale', 'collards', 'turnips', 'rutabaga', 'watercress', 'beets', 'yams', 'carrots', 'parsnips', 'radish', 'potatoes', 'sweet potatoes', 'zucchini', 'strawberries', 'blueberries', 'grapes', 'rhubarb', 'home-brew beer', 'coffee beans','carrots', 'eggs', 'spinach', 'rhubarb', 'so much rhubarb', 'beans', 'basil', 'honey', 'zuchinni', 'cukes','lettuce','almonds', 'hazelnuts']
tags = ['tasty', 'friendly', 'sketchy', 'so good', 'organic', 'vegetables','fruit','nuts','spinach','greens','root veg','canned','broccoli', 'cabbage', 'bok choy', 'horseradish', 'mustard greens', 'arugula', 'brussels sprouts', 'cauliflower', 'radishes', 'kohlrabi', 'broccoli rabe', 'organic kale', 'collards', 'turnips', 'rutabaga', 'watercress', 'beets', 'yams', 'carrots', 'parsnips', 'radish', 'potatoes', 'sweet potatoes', 'zucchini', 'strawberries', 'blueberries', 'grapes', 'rhubarb', 'home-brew beer', 'coffee beans','carrots', 'eggs', 'spinach', 'rhubarb', 'so much rhubarb', 'beans', 'basil', 'honey', 'zuchinni', 'cukes','lettuce','almonds', 'hazelnuts']
names = ["Dr. Clarabelle Casper", "Ms. Uriel Zboncak", "Rhea Corwin I", "Miss Chester Kovacek", "Erling Dicki", "Frieda Lakin", "Dr. Gayle Blanda", "Dr. Florian Block", "Dax Kling", "Reva Crona", "Annette Fritsch III", "Nettie Stiedemann", "Glenna Rempel", "Gail Ward", "Bernadine Strosin", "Ms. Craig Kulas", "Johnnie Auer", "Jennie Watsica", "Roslyn Towne", "Tristian Conn III", "Ansley Gleichner", "Marshall Koelpin", "Earl Lang Jr.", "Colby Purdy", "Mortimer Feil Jr.", "Brandyn Anderson PhD", "Flavio Williamson", "Ms. Emma Schmitt", "Clifton Donnelly DDS", "Dr. Lucio Eichmann", "Dr. Iliana Hirthe", "Steve Adams DDS", "Isabella Hauck MD", "Miss Nikko Strosin", "Ora Bartoletti", "Carol Kassulke V", "Ethelyn Miller", "Sydnie Roberts", "Mr. Patsy O'Hara", "Tyrel Reichel", "Caleb Armstrong", "Cedrick Oberbrunner DVM", "Alessandro Nienow", "Camilla Considine", "Edd Bailey V", "Renee Schinner", "Randal Shanahan I", "Delphia Walker", "Ms. Audra Thompson", "Verdie Shields DVM", "Misty Rutherford", "Tremaine Pouros", "Garth Gutmann", "Loren Hammes", "Yvette Gottlieb", "Carter Nikolaus", "Dr. Karlie Fritsch", "Kari Lynch", "Chaz Parisian I", "Omari King DVM", "Nathaniel Collier", "Robyn Gorczany", "Savannah Rohan", "Ms. Marilie Metz", "Kelli Gerlach", "Luz Nitzsche", "Velva Bruen", "Sammy Altenwerth", "Mr. Jonathon Ebert", "Kailey Monahan", "Ramiro Jacobi", "Murray Runte", "Zachary Weissnat", "Gaetano Glover", "Nicklaus Kuhic", "Cayla Bosco", "Olen Raynor PhD", "Mr. Abagail Senger", "Mrs. Arvilla Walsh", "Ceasar Mayert", "Gia Wiza", "Heath Schiller", "Lulu Braun", "Kacie Paucek", "Zula Rosenbaum V", "Vickie Ledner DDS", "Mrs. Taylor Bashirian", "Saige Bergnaum", "Simone Lynch", "Elton Dietrich", "Demetris Schaden", "Cordia Will", "Miss Wyman Tremblay", "Vivien Gusikowski", "Bernie Fay", "Sydney Fay", "Mrs. Stewart Harvey", "Ms. Lance Roberts", "Luciano Raynor", "Destiny Fahey"]
email = ["[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]"]
phone = ["(733)916-7078 x55509", "1-197-085-4996 x385", "622.112.0744 x28640", "381.323.9057 x79940", "1-943-259-8714 x034", "(929)281-5587 x7915", "1-633-347-1133", "(584)576-8449 x473", "1-897-577-8239", "1-183-749-0668 x38583", "1-248-463-3661", "843.522.9003", "1-726-417-8757", "1-201-589-4828 x9435", "1-213-006-0928", "1-547-141-1806", "1-329-958-5914 x175", "1-286-582-9931", "499.816.6683 x612", "1-212-072-5151 x6905", "845-528-8223 x9655", "1-454-631-0244 x661", "464-149-3031", "351-605-8405 x014", "145.468.7729 x396", "1-226-463-8328", "1-397-790-7422 x16119", "1-666-659-8867 x2434", "1-078-252-7339", "005.200.4078", "721.199.0257 x24131", "315-960-9551 x344", "1-271-603-8861 x85752", "647-469-6175", "031-331-0341", "906-632-4775 x9414", "146-682-7236 x84675", "1-624-810-6960", "814.370.3800", "969-456-4465 x663", "(344)441-9308 x62189", "1-031-480-0639 x3030", "606-557-6390 x8116", "923.776.3335", "778.232.3066", "401-978-6255", "962.604.8760", "885.053.4263 x2457", "143.640.5334 x751", "175.481.5828", "1-832-022-8384 x20087", "1-383-047-9779", "1-694-526-3705 x76769", "(120)284-6722 x03328", "617.320.2787 x76849", "348-580-4777 x807", "539.740.9514", "891-704-0045", "1-419-627-2989", "467.648.9416", "1-635-043-1216 x52131", "(865)849-6552 x62609", "766.821.4747 x11373", "318-247-4936 x75020", "026.498.5927 x26268", "(852)638-4422 x171", "(828)868-7297 x689", "389-735-9653", "(178)344-3153 x495", "741-902-3535 x24879", "908.493.7515", "1-129-590-2862", "(149)860-3927", "(281)387-9663", "(039)138-1186 x9305", "049-599-0900", "886.098.7785 x300", "1-783-362-8286 x747", "655-011-0765", "192.667.1692", "405.070.0491 x5747", "682-286-3534 x1327", "013.612.3210 x788", "(748)879-0731", "271-588-9477", "(107)851-9677", "921-622-5552 x96266", "1-926-656-2936", "1-479-794-8686", "(828)464-2722 x28377", "652.919.1648 x89866", "(997)353-5906 x994", "855-295-0921 x5792", "(699)590-8829", "1-582-525-2877 x351", "836.448.0751 x5711", "473.854.7915", "(902)346-6519 x845", "(902)795-1204 x822", "333-688-8140"]
amounts = ['a handful of', 'a pound of', 'a wheelbarrel of', 'so much', 'more than i can use', 'a bit of', 'hella', 'hecka', 'my goodness, so muuch', 'some']
contacts = ["call me after 6pm: #{phone[rand(phone.length)]}", "email is best, #{email[rand(email.length)]}", "anytime before 11pm at, #{phone[rand(phone.length)]}","#{email[rand(email.length)]} "]
100.times do
post = Post.create(
:i_got => "#{amounts[rand(amounts.length)]} #{wants[rand(wants.length)]} and #{amounts[rand(amounts.length)]} #{haves[rand(haves.length)]}",
:u_got => "#{amounts[rand(amounts.length)]} #{wants[rand(wants.length)]} ",
:contact_method => contacts[rand(contacts.length)],
:lat => "34.10300320 - (rand() * 5)",
:lng => "-118.41046840 - (rand() * 5)")
rand(4).times {
begin
post.tags << Tag.find_or_create_by_name(:name => tags[rand(tags.length)])
rescue
end
}
end
end
end
desc "This task is called by the Heroku cron add-on"
task :cron do
Post.where(["created_at < ?", Time.now - 7.days]).each {|post| post.deleted = true; post.save }
# if Time.now.hour % 4 == 0 # run every four hours
# puts "Updating feed..."
# NewsFeed.update
# puts "done."
# end
#
# if Time.now.hour == 0 # run at midnight
# User.send_reminders
# end
end