Created
December 9, 2013 06:32
-
-
Save panozzaj/7868223 to your computer and use it in GitHub Desktop.
Random pulling of post ideas and printing to console
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
ideas = [] | |
current_lines = [] | |
lines = File.read('post_ideas.txt') | |
lines.split("\n").each do |line| | |
next if line.strip == '' | |
if line =~ /^==========/ | |
if current_lines != [] | |
ideas << current_lines.join("\n") | |
current_lines = [] | |
end | |
else | |
current_lines << line | |
end | |
end | |
if current_lines != [] | |
ideas << current_lines.join("\n") | |
end | |
puts ideas.sample(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment