User:Lidia.Pereira/PNMII/WB/PCM: Difference between revisions
< User:Lidia.Pereira | PNMII | WB
No edit summary |
No edit summary |
||
(3 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
[[File:Procrastinatometer.png|755px]] | [[File:Procrastinatometer.png|755px]] | ||
Disclaimer: For now this is a | Disclaimer: For now this is a local 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. | 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. | ||
< | <source lang="python"> | ||
#!/usr/bin/env python | #!/usr/bin/env python | ||
#-*- coding:utf-8 -*- | #-*- coding:utf-8 -*- | ||
Line 12: | Line 12: | ||
date = time.strftime("%x") | date = time.strftime("%x") | ||
f = open(" | f = open("dates.txt","w") | ||
m = open("dates.txt") | |||
lines = m.readlines() | |||
places = sqlite3.connect("/Users/lidiapereira/Library/Application Support/Firefox/Profiles/w3om15u2.default/places.sqlite") | places = sqlite3.connect("/Users/lidiapereira/Library/Application Support/Firefox/Profiles/w3om15u2.default/places.sqlite") | ||
Line 19: | Line 21: | ||
database.execute('''SELECT url FROM moz_places''') | database.execute('''SELECT url FROM moz_places''') | ||
if lines: | |||
for line in | for line in lines: | ||
if data not in line: | |||
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"] | url_list = ["https://www.youtube.com","https://www.facebook.com","http://www.reddit.com","http://vodly.to","http://www.lastfm.com"] | ||
def getCount(): | def getCount(): | ||
Line 39: | Line 40: | ||
count = getCount() | count = getCount() | ||
print "Content-Type: text/html" | print "Content-Type: text/html" | ||
Line 64: | Line 62: | ||
height: ; | height: ; | ||
position: fixed; | position: fixed; | ||
top: | top: 1.3%; | ||
left: 0; | left: 0; | ||
} | } | ||
Line 70: | Line 68: | ||
</head> | </head> | ||
""" | """ | ||
if count < 13: | |||
if count < | |||
print """ | print """ | ||
<body> | <body> | ||
Line 78: | Line 75: | ||
print """ | print """ | ||
<body> | <body> | ||
<img src ='/ | <img src ='/count_dracula.gif'/> | ||
""" | """ | ||
f.write(date+"\n") | |||
f.close() | |||
print """ | print """ | ||
</body> | </body> | ||
</html> """ | </html> """ | ||
</ | </source> | ||
[[File:Procrastinatometer2.png|755px]] | [[File:Procrastinatometer2.png|755px]] |
Latest revision as of 20:41, 30 March 2014
Disclaimer: For now this is a local 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.
#!/usr/bin/env python
#-*- coding:utf-8 -*-
import sqlite3
import time
date = time.strftime("%x")
f = open("dates.txt","w")
m = open("dates.txt")
lines = m.readlines()
places = sqlite3.connect("/Users/lidiapereira/Library/Application Support/Firefox/Profiles/w3om15u2.default/places.sqlite")
database = places.cursor()
database.execute('''SELECT url FROM moz_places''')
if lines:
for line in lines:
if data not in line:
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()
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: 1.3%;
left: 0;
}
</style>
</head>
"""
if count < 13:
print """
<body>
<img src='/procrastimeter%s.png'/> """ % count
else:
print """
<body>
<img src ='/count_dracula.gif'/>
"""
f.write(date+"\n")
f.close()
print """
</body>
</html> """