User:Lidia.Pereira/PNMII/WB/PCM

From XPUB & Lens-Based wiki

Procrastinatometer.png

Disclaimer: For now this is a personal script, seeing that it works with the sqlite database which stores my browsing history. In the future I'll try developing a browser plug-in (using Grease Monkey, perhaps) that does the same without depending on some local file.

<syntax highlight lang="python">

  1. !/usr/bin/env python
  2. -*- coding:utf-8 -*-

import sqlite3 import time

date = time.strftime("%x") f = open("day.txt","r+")

places = sqlite3.connect("/Users/lidiapereira/Library/Application Support/Firefox/Profiles/w3om15u2.default/places.sqlite") database = places.cursor()

database.execute(SELECT url FROM moz_places)


for line in f:

   if not date: #check this
       for data in database:
           database.execute(DELETE FROM moz_places WHERE url=?,(data))


url_list = ["https://www.youtube.com","https://www.facebook.com","http://www.reddit.com","http://vodly.to","http://www.lastfm.com"]


def getCount():

   i = 0
   for data in database:
       data = str(data)
       for url in url_list:
           if url in data:
               i = i + 1
   return i

count = getCount()

f.write(date) f.close()

print "Content-Type: text/html" print print """

   <!DOCTYPE html>
   <html>
   <head>
   <title>Procrastinatometer</title>
   <style>
       html{
       background: url('/procrastinatometer.png') no-repeat center center fixed;
       -webkit-background-size: cover;
       -moz-background-size: cover;
       -o-background-size: cover;
       background-size: cover;
       }
       img{
       min-height: 100%;
       min-width: 1024px;
       width: 100%;
       height: ;
       position: fixed;
       top: 0;
       left: 0;
       }
   </style>
   </head>
   """

if count < 14:

   print """
   <body>
    """ % count

else:

   print """
   <body>
    
   """

print """

   </body>
   </html> """

</syntax highlight>


Procrastinatometer2.png