Skip to content

Instantly share code, notes, and snippets.

@kch
Created May 12, 2016 12:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kch/f0ca9bb348886c557a178a89ddf10712 to your computer and use it in GitHub Desktop.
Save kch/f0ca9bb348886c557a178a89ddf10712 to your computer and use it in GitHub Desktop.
sort wgt bands by time, append location
#!/usr/bin/env ruby
s = ARGF.read =~ /Freitag, 13. Mai 2016.*?(?=\n\n)/m && $&
s.gsub! /^(\d\d)\.(\d\d)\u00A0Uhr\n/, "\\1:\\2h -- "
days = []
s.lines.each do |l|
case l
when /^\d\d:\d\dh -- Einlaß/ then :pass
when /Mai 2016$/ then days << [l, []]
when /^\d\d:\d\dh -- / then days.last[1] << l.sub(/\Z/, " -- @ #{$x}")
else $x = l.chomp
end
end
days.each{|d,ls| ls.sort_by!{|l| [(l =~ /^0/ ? 1 : 0), l] }}
puts days.flat_map{|d,ls| [nil,'== ' + d,ls] }
__END__
Usage:
curl -s http://www.wave-gotik-treffen.de/prog/programm.php | textutil -stdin -stdout -format html -convert txt | $0
cat programm.html | textutil -stdin -stdout -format html -convert txt | $0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment