Skip to content
Browse files

Project folder bookkeeping

  • Loading branch information...
1 parent 3650143 commit 2288c9eba1abf0dadaac7744d4ee82959780204d @andreyvit andreyvit committed
Showing with 24 additions and 3 deletions.
  1. +6 −0 .gitignore
  2. +18 −0 parse-logs.rb
  3. +0 −3 site/ping.txt
View
6 .gitignore
@@ -4,3 +4,9 @@ xcuserdata
/dist
/logs
/raw-logs
+/Supplementary
+site/css/livereload.css
+example/*.css
+example/*.js
+example/*.html
+example/.sass-cache
View
18 parse-logs.rb
@@ -0,0 +1,18 @@
+require 'date'
+require 'cgi'
+
+puts %Q<DELETE FROM stats;>
+
+Dir['logs/*'].each do |file|
+ File.read(file).each_line do |line|
+ if line =~ /\[(\d+\/\w+\/\d{4}:\d+:\d+:\d+ \+\d+)\] (\d+\.\d+\.\d+\.\d+).*ping.txt\?v=([0-9.]+).*"([^"]+)" -$/
+ time, ip, ver, ua = $1, $2, $3, CGI.unescape($4)
+ time.sub! ':', ' '
+ d = DateTime.parse(time).new_offset(0)
+ utime = Time.gm(d.year, d.month, d.day, d.hour, d.min, d.sec).to_i
+ date = d.strftime('%Y-%m-%d')
+ raise "bad UA found!" if ua.include? '"'
+ puts %Q<INSERT INTO stats(time, date, ip, version, agent) VALUES(#{utime}, FROM_UNIXTIME(#{utime}), "#{ip}", "#{ver}", "#{ua}");>
+ end
+ end
+end
View
3 site/ping.txt
@@ -1,3 +0,0 @@
-We use pings to measure the number of active LiveReload users.
-
-No data is sent over the wire, which means certainly no user-identifiable data.

0 comments on commit 2288c9e

Please sign in to comment.
Something went wrong with that request. Please try again.