Skip to content

Instantly share code, notes, and snippets.

@theSage21
theSage21 / college_todo.md
Created October 7, 2014 03:20
College site todo list

#Todo

  • attendance/home.html
  • principal_home.html
  • notice_view.html
  • notice_home.html
  • event.html
  • department.html
  • contact.html
  • archive.html
  • alumni.html
@theSage21
theSage21 / get_emails.py
Last active August 29, 2015 14:21
Email extractor from html table.
import os
import re
from bs4 import BeautifulSoup
def get_files():
folder = os.path.join(os.getcwd(), 'html')
names = [os.path.join(folder, i) for i in os.listdir(folder)]
names.sort()
return names
@theSage21
theSage21 / get_results.py
Last active August 29, 2015 14:21
Cbse result fetcher.
from requests import post
def save_page(html):
f = open('html/' + str(hash(html)), 'w')
f.write(html)
f.close()
def mark_done(roll):
@theSage21
theSage21 / proposal_order.py
Created June 8, 2015 12:22
Order the proposal lists in pyconIndia
from bs4 import BeautifulSoup as BS
from urllib2 import urlopen
html = urlopen('https://in.pycon.org/cfp/pycon-india-2015/proposals/')
html = ''.join(html.readlines())
html[:30]
soup = BS(html)
soup.find_all('div',{'class':'user-proposals'})
proposals=soup.find_all('div',{'class':'user-proposals'})
ordered = []
for p in proposals:
@theSage21
theSage21 / call_speed.py
Created June 20, 2015 13:46
Speedtesting
from time import time
# dummy functions
def html_minify(content, ignore_comments, parser):
"Constant time function"
return content
class Request:
def __init__(self):
self._hit_htmlmin = True
@theSage21
theSage21 / primer.py
Created June 30, 2015 17:39
Prime number generator
class Primer:
def __init__(self, store_name='data'):
self.store_name = store_name
try:
fl = open(self.store_name, 'r')
fl.close()
except:
with open(self.store_name, 'w') as fl:
fl.write('2\n')
@theSage21
theSage21 / Results1
Last active August 29, 2015 14:27
Speedtesting results on html2text
Wrote profile results to testing.py.lprof
Timer unit: 1e-06 s
Total time: 18.9654 s
File: html2text/__init__.py
Function: optwrap at line 784
Line # Hits Time Per Hit % Time Line Contents
==============================================================
784 @profile
@theSage21
theSage21 / Result2
Created August 19, 2015 07:29
Results after changes
Wrote profile results to testing.py.lprof
Timer unit: 1e-06 s
Total time: 0.001185 s
File: html2text/__init__.py
Function: feed at line 121
Line # Hits Time Per Hit % Time Line Contents
==============================================================
121 @profile
@theSage21
theSage21 / new_project.sh
Last active October 1, 2015 09:53
Start new python projects
#! /bin/bash
echo Creating directory
mkdir $1
# copy standard project stuff
echo Copying License
lic=$1/LICENSE
@theSage21
theSage21 / check.py
Last active October 1, 2015 10:11
Check if a list of URLs has had any content changed. Useful for websites with no RSS feed
import os
from requests import get
from hashlib import md5
urls = ['http://ststephens.edu/',
'http://cmi.ac.in/']
try:
with open('.website_signatures', 'r') as fl: