Skip to content

Instantly share code, notes, and snippets.

@vhagerty
vhagerty / springer-free-maths-books.md
Created December 29, 2015 11:24 — forked from bishboria/springer-free-maths-books.md
Springer have made a bunch of books available for free, here are the direct links
# Something in lines of http://stackoverflow.com/questions/348630/how-can-i-download-all-emails-with-attachments-from-gmail
# Make sure you have IMAP enabled in your gmail settings.
# Right now it won't download same file name twice even if their contents are different.
import email
import getpass, imaplib
import os
import sys
detach_dir = '.'
def extract_form_fields(self, soup):
"Turn a BeautifulSoup form in to a dict of fields and default values"
fields = {}
for input in soup.findAll('input'):
# ignore submit/image with no name attribute
if input['type'] in ('submit', 'image') and not input.has_key('name'):
continue
# single element nome/value fields
if input['type'] in ('text', 'hidden', 'password', 'submit', 'image'):
@vhagerty
vhagerty / OpenCalais.class.php
Created October 9, 2012 18:17
Wrapper for the OpenCalais semantic parser
<?php
/*
OpenCalais: A wrapper for Thomson Reuters' OpenCalais semantic parser
(http://www.opencalais.com/)
Author: Vaughn Hagerty
Usage: new OpenCalais(api_key, submitter[, relevance]), OpenCalais->parse(HTML_formatted_article)
api_key and submitter are required and created when registering for OpenCalais account
relevance is a decimal value between 0 and 1 optional and determines how strictly you want to parse
HTML_formatted_article is the article to parse
@vhagerty
vhagerty / YGeocode.class.php
Created October 9, 2012 18:13
Wrapper for Yahoo's REST Placemaker geocoder
<?php
/*
YGeocode: A wrapper for Yahoo's Placemaker geocode service to access certain properties
Author: Vaughn Hagerty
Usage: new YGeocode(<API Key>), YGeocode->geocode(<query>), where <query> is an address
Methods and properties:
->geocode(<query>) : geocode a non-urlescaped query (address, zip code, city)
->lat : return the latitude. If geocode fails, it returns 0
->lon : return the longitude. If geocode fails, it returns 0
@vhagerty
vhagerty / GGeocode.class.php
Created October 9, 2012 18:09
Wrapper for Google's REST geocoder
<?php
/*
GGeocode: A wrapper for Google's geocode service to access certain properties
Author: Vaughn Hagerty
Usage: new GGeocode(), GGeocode->geocode(<query>), where <query> is an address
Methods and properties:
->geocode(<query>) : geocode a non-urlescaped query (address, zip code, city)
->lat : return the latitude. If geocode fails, it returns 0
->lon : return the longitude. If geocode fails, it returns 0