Skip to content

Instantly share code, notes, and snippets.

View wizzdm's full-sized avatar

Stephen Bridgwater wizzdm

View GitHub Profile
@wizzdm
wizzdm / compress_pdf.md
Created March 22, 2022 08:15 — forked from ahmed-musallam/compress_pdf.md
How to compress PDF with ghostscript

How to compress PDF using ghostscript

As a developer, it bothers me when someone sends me a large pdf file compared to the number of pages. Recently, I recieved a 12MB scanned document for just one letter-sized page... so I got to googlin, like I usually do, and found ghostscript!

to learn more abot ghostscript (gs): https://www.ghostscript.com/

What we are interested in, is the gs command line tool, which provides many options for manipulating PDF, but we are interested in compressign those large PDF's into small yet legible documents.

credit goes to this answer on askubuntu forum: https://askubuntu.com/questions/3382/reduce-filesize-of-a-scanned-pdf/3387#3387?newreg=bceddef8bc334e5b88bbfd17a6e7c4f9

<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="test.js"></script>
</head>
@wizzdm
wizzdm / web2csv.py
Created November 13, 2018 13:13 — forked from miglen/web2csv.py
Dead simple {for devs} python crawler (script) for extracting structured data from any website into CSV
#!/bin/env/python
#
# Source: http://blog.webhose.io/2015/08/16/dead-simple-for-devs-python-crawler-script-for-extracting-structured-data-from-any-almost-website-into-csv/
import sys, thread, Queue, re, urllib2, urlparse, time, csv
### Set the site you want to crawl & the patterns of the fields you want to extract ###
siteToCrawl = "http://www.amazon.com/"
fields = {}
fields["Title"] = '<title>(.*?)</title>'
fields["Rating"] = 'title="(S+) out of 5 stars"'
@wizzdm
wizzdm / tryjs_dom_getelementbyid.html
Created December 9, 2017 15:43
JavaScript DOM getElementById method to finds the HTML element with id="intro"
<!DOCTYPE html>
<html>
<body>
<p id="intro">Hello World!</p>
<p>This example demonstrates the <b>getElementById</b> method!</p>
<p id="demo"></p>
@wizzdm
wizzdm / keybase.md
Last active November 7, 2017 16:21

Keybase proof

I hereby claim:

  • I am wizzdm on github.
  • I am wizzdm (https://keybase.io/wizzdm) on keybase.
  • I have a public key ASB9aKy5xpEHZVaqZ1sWLdabbhnNKIFEWYP1avX9AIkHpAo

To claim this, I am signing this object:

@wizzdm
wizzdm / HotOnGitHub.js
Created August 1, 2017 04:56 — forked from greenido/HotOnGitHub.js
Apps Script code to fetch us into google sheet the top repos on github per technology (e.g. PHP, JS) over the last week.
/**
* Fetching data from githubarchive.org into BigQuery to see what is cool and hot on github
* Author: Ido Green
* Date: 2014-April-01
*
* A post on the subject: http://wp.me/pB1lQ-19i
* More on BQ: https://developers.google.com/bigquery/
*/
@wizzdm
wizzdm / get_n_results.py
Created March 17, 2017 06:56 — forked from erikbern/get_n_results.py
Get number of search results from Google
def get_n_results_dumb(q):
r = requests.get('http://www.google.com/search',
params={'q': q,
"tbs": "li:1"})
r.raise_for_status()
soup = bs4.BeautifulSoup(r.text)
s = soup.find('div', {'id': 'resultStats'}).text
if not s:
return 0
m = re.search(r'([0-9,]+)', s)