Skip to content

Instantly share code, notes, and snippets.

@kartben
Last active December 11, 2015 02:49
Show Gist options
  • Save kartben/4533142 to your computer and use it in GitHub Desktop.
Save kartben/4533142 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'pp'
require 'date'
content = STDIN.read()
REGEX = %r{
(?:
\/koneki\/products\/.*/?org.eclipse.koneki.ldt.product-
(?<product-name>.*?\..*?\..*?)\.(?:.*)
\t
(?<xxx>(?:
(?<date>\d+-\d+-\d+) \t (?<hits>\d+) \n
)+)
.*\n
)+
}x
REGEX_SIMREL = %r{
(?:
\/stats\/releases\/juno\/
(?<release>.*?\..*?\..*?)\.(?:.*)
\t
(?<xxx>(?:
(?<date>\d+-\d+-\d+) \t (?<hits>\d+) \n
)+)
.*\n
)+
}x
glitches = Hash.new
glitches["linux.gtk.x86_64"] = Hash.new
glitches["linux.gtk.x86_64"]["2012-10-05"] = 1
glitches["linux.gtk.x86_64"]["2012-10-06"] = 1
glitches["linux.gtk.x86_64"]["2012-10-07"] = 2
glitches["linux.gtk.x86_64"]["2012-10-08"] = 1
glitches["linux.gtk.x86_64"]["2012-10-09"] = 2
glitches["linux.gtk.x86_64"]["2012-10-10"] = 1
glitches["macosx.cocoa.x86_64"] = Hash.new
glitches["macosx.cocoa.x86_64"]["2012-10-05"] = 2
glitches["macosx.cocoa.x86_64"]["2012-10-06"] = 2
glitches["macosx.cocoa.x86_64"]["2012-10-07"] = 3
glitches["macosx.cocoa.x86_64"]["2012-10-08"] = 2
glitches["macosx.cocoa.x86_64"]["2012-10-09"] = 1
glitches["macosx.cocoa.x86_64"]["2012-10-10"] = 1
glitches["win32.win32.x86_64"] = Hash.new
glitches["win32.win32.x86_64"]["2012-02-15"] = 15
glitches["win32.win32.x86_64"]["2012-03-03"] = 10
glitches["win32.win32.x86_64"]["2012-10-05"] = 2
glitches["win32.win32.x86_64"]["2012-10-06"] = 2
glitches["win32.win32.x86_64"]["2012-10-07"] = 2
glitches["win32.win32.x86_64"]["2012-10-08"] = 3
glitches["win32.win32.x86_64"]["2012-10-09"] = 2
glitches["win32.win32.x86_64"]["2012-10-10"] = 2
glitches["win32.win32.x86"] = Hash.new
glitches["win32.win32.x86"]["2012-02-20"] = 60
glitches["win32.win32.x86"]["2012-03-11"] = 30
glitches["win32.win32.x86"]["2012-03-30"] = 20
glitches["win32.win32.x86"]["2012-10-05"] = 3
glitches["win32.win32.x86"]["2012-10-06"] = 2
glitches["win32.win32.x86"]["2012-10-07"] = 2
glitches["win32.win32.x86"]["2012-10-08"] = 3
glitches["win32.win32.x86"]["2012-10-09"] = 2
glitches["win32.win32.x86"]["2012-10-10"] = 3
#####################
# downloads
#####################
content.scan(REGEX) do |m|
#pp "#{m[1]}"
res = m[1]
res.gsub!(/(\d+-\d+-\d+)/, "#{m[0]}\t\\1")
glitches.each do |platform, days|
days.each do |day, count|
# pp day
# pp count
res.gsub!(/(#{platform}\t#{day}\t)\d+/, "\\1#{count}")
end
end
puts res
end
#####################
# juno stats
#####################
content.scan(REGEX_SIMREL) do |m|
puts m[1].gsub(/(\d+-\d+-\d+)/, "juno\t\\1")
end
#####################
# marketplace stats
#####################
marketplace = []
marketplace[2011] = []
marketplace[2012] = []
marketplace[2013] = []
marketplace[2011][11] = 103
marketplace[2011][12] = 225
marketplace[2012][1] = 229
marketplace[2012][2] = 234
marketplace[2012][3] = 247
marketplace[2012][4] = 210
marketplace[2012][5] = 242
marketplace[2012][6] = 257
marketplace[2012][7] = 326
marketplace[2012][8] = 273
marketplace[2012][9] = 281
marketplace[2012][10] = 300
marketplace[2012][11] = 299
marketplace[2012][12] = 284
marketplace[2013][01] = 164 * 31/14
(Date.new(2011,11,01) .. Date.new(2013,01,14)).each do |day|
puts ("marketplace\t" + day.to_s + "\t" + (marketplace[day.year][day.month] / 30).to_s)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment