Permalink
Browse files

first commit

  • Loading branch information...
0 parents commit 1c62f6faca07503dd6a3fa6a28fb8a1c5501e8f4 @sickill committed Mar 21, 2009
Showing with 18 additions and 0 deletions.
  1. +1 −0 .gitignore
  2. +17 −0 sickounter.rb
@@ -0,0 +1 @@
+counters/*
@@ -0,0 +1,17 @@
+require 'rubygems'
+require 'sinatra'
+
+get '/' do
+ url = params[:f]
+ filename = url.gsub(/https?:\/\//, "").gsub(/[^a-zA-Z0-9_-]/, ".") + ".txt"
+ path = "counters/#{filename}"
+ val = (File.read(path).strip.to_i rescue 0) + 1
+ puts val
+ File.open(path, "w") do |f|
+ f.flock(File::LOCK_EX)
+ f.puts(val.to_s)
+ f.flock(File::LOCK_UN)
+ end
+ redirect(url)
+end
+

0 comments on commit 1c62f6f

Please sign in to comment.