Skip to content

Instantly share code, notes, and snippets.

@drunkensouljah
drunkensouljah / simplePDFtableScraper.py
Created March 19, 2017 15:01 — forked from psychemedia/simplePDFtableScraper.py
Example Python code for a simple PDF table scraper
# 1. Add some necessary libraries
import scraperwiki
import urllib2, lxml.etree
# 2. The URL/web address where we can find the PDF we want to scrape
url = 'http://cdn.varner.eu/cdn-1ce36b6442a6146/Global/Varner/CSR/Downloads_CSR/Fabrikklister_VarnerGruppen_2013.pdf'
# 3. Grab the file and convert it to an XML document we can work with
pdfdata = urllib2.urlopen(url).read()
#!/usr/bin/env python
"""Script that I keep in a Git repository along with my dotfiles. In the
repository, the files don't have the dot prefix so I can see them more easily.
Running the script symlinks all the files to ~/.<filename>, checking allowing
you to cancel if the file exists.
"""
import os
import glob
@drunkensouljah
drunkensouljah / send_mail.py
Created July 19, 2016 17:15 — forked from vjo/send_mail.py
[Python] Send email with embedded image and application attachment
#! /usr/bin/python
import smtplib
from optparse import OptionParser
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.mime.image import MIMEImage
from email.mime.application import MIMEApplication
@drunkensouljah
drunkensouljah / ajax-form.js
Created July 11, 2016 22:50 — forked from havvg/ajax-form.js
jQuery AJAX form submit with Twitter Bootstrap modal
jQuery(function($) {
$('form[data-async]').live('submit', function(event) {
var $form = $(this);
var $target = $($form.attr('data-target'));
$.ajax({
type: $form.attr('method'),
url: $form.attr('action'),
data: $form.serialize(),
@drunkensouljah
drunkensouljah / Pinboard Mod 2015.css
Created July 6, 2016 12:12 — forked from poritsky/Pinboard Mod 2015.css
Just a modification for Pinboard.in, inspired by Brett Terpstra. Works best on OS X.
@font-face{font-family:'FontAwesome';src:url('http://maxcdn.bootstrapcdn.com/font-awesome/4.2.0/fonts/fontawesome-webfont.eot?v=4.2.0');src:url('http://maxcdn.bootstrapcdn.com/font-awesome/4.2.0/fonts/fontawesome-webfont.eot?#iefix&v=4.2.0') format('embedded-opentype'),url('http://maxcdn.bootstrapcdn.com/font-awesome/4.2.0/fonts/fontawesome-webfont.woff?v=4.2.0') format('woff'),url('http://maxcdn.bootstrapcdn.com/font-awesome/4.2.0/fonts/fontawesome-webfont.ttf?v=4.2.0') format('truetype'),url('http://maxcdn.bootstrapcdn.com/font-awesome/4.2.0/fonts/fontawesome-webfont.svg?v=4.2.0#fontawesomeregular') format('svg');font-weight:normal;font-style:normal}
#tag_cloud{display:none}
#timer{display:none;}
#logo{margin-left:120px;}
#pinboard{width:100%;padding:0 !important;margin:0 !important;background-color:#f9f9f9 !important;}
#banner{background:rgb(15,128,255) !important;width:100% !important;min-width:1100px;position:fixed;left:0;padding:15px 0 16px 0 !important;z-index:10;font-family:"Avenir Next Condensed";}
#
#!/usr/bin/env python
import fcntl, termios, struct, os
import random
import time, sys
def ioctl_GWINSZ(fd):
''' Get terminal size, by giving the proper file descriptor '''
try:
cr = struct.unpack('hh', fcntl.ioctl(fd, termios.TIOCGWINSZ, '1234'))
@drunkensouljah
drunkensouljah / grab links.bookmarklet
Created June 26, 2016 11:38 — forked from ttscoff/grab links.bookmarklet
Create a bookmark and paste the code from `grab links.bookmarklet` into the url. Trigger it on a page containing links you want to save and then click the section of the page containing the links. A Markdown list of all links will be generated, and clicking the resulting list will select all for copying.

Keybase proof

I hereby claim:

  • I am drunkensouljah on github.
  • I am exon (https://keybase.io/exon) on keybase.
  • I have a public key whose fingerprint is 85F9 404B 2900 FBD4 F95F B18A 8A7D 7600 7330 542B

To claim this, I am signing this object:

#!/usr/bin/python
#
# from http://www.pythonforbeginners.com/feedparser/using-feedparser-in-python
# installed feedparser with `pip`, after installing pip with apt-get
#
import feedparser
import time
from subprocess import check_output
from lxml import html
import os
import random
import requests
import string
unsplash = requests.get("https://unsplash.com/")
html_tree = html.fromstring(unsplash.text)
# Collects picture source as URL