Skip to content

Instantly share code, notes, and snippets.

View StevenMaude's full-sized avatar
🏠
Working from home

Steven Maude StevenMaude

🏠
Working from home
View GitHub Profile
@StevenMaude
StevenMaude / das_notes.md
Last active April 17, 2018 20:33
Destroy All Software screencast notes

Destroy All Software screencast notes

Earlier this year, the Destroy All Software screencasts were free to download. I grabbed a few that sounded interesting to watch.

These are notes of new things I learned.

0004: Source Code History Integrity

@StevenMaude
StevenMaude / password_animation.py
Last active August 24, 2016 22:33
Movie-like password cracking animation in Python that looks nifty. Code for guessing a string written for a problem in "Problem Solving with Algorithms and Data Structures" with my additional idea of printing every attempt and slowing down prints to make them readable. Tested with Python 2.7/3.4.
from __future__ import print_function, unicode_literals
import random
import time
def generate_random_guess(chars):
return random.choice(chars)
def repeated_guesses(target):
@StevenMaude
StevenMaude / signature_count.sh
Last active June 25, 2016 21:40
Count up UK Government petition signatures, across countries and constituencies.
#!/bin/sh -e
if [ -z "$1" ]; then
echo "Usage: signature_count.sh <UK_GOVERNMENT_PETITION_JSON_URL>"
echo "e.g. signature_count.sh https://petition.parliament.uk/petitions/131215.json"
fi
DATA=$(wget -qO - "$1")
echo "Signatures by country:"
echo "$DATA" | jq .data.attributes.signatures_by_country[].signature_count | awk '{ sc += $1 } END { print sc }'
echo "Signatures by constituency:"
@StevenMaude
StevenMaude / get_coffee_break_french_podcasts.sh
Last active May 8, 2016 20:23
Download the Coffee Break French podcasts using curl
#!/bin/bash
for i in {01..02} {04..24} {26..80} {301..340} ; do
curl -f -O -J -L https://media.libsyn.com/media/coffeebreakfrench/cbf-$i-basic.mp3
done
for i in {401..424} {426..440} ; do
curl -f -O -J -L https//media.libsyn.com/media/coffeebreakfrench/cbf-$i-main.mp3
done
# Handle cases which don't fit the normal pattern.
@StevenMaude
StevenMaude / iplayer-url-to-pid.sh
Created March 26, 2016 22:56
Get episode PIDs from a file containing BBC iPlayer URLs, one per line
#!/bin/sh
# Usage: ./url-to-pid.sh <URL file>
cat $1 | grep -oP '(?<=episode/)\w+' | paste -d"," -s
@StevenMaude
StevenMaude / extract_gpx_data.py
Last active March 15, 2016 00:42
Quick hacky script to extract date and 2D length data from GPX files to CSV using gpxpy; at least compatible with Py2.7/3.4
#!/usr/bin/env python
""" Extract date and 2D length data from GPX files in current directory. """
from __future__ import division, print_function
import decimal
import glob
import gpxpy
def main():
@StevenMaude
StevenMaude / extract_text_and_remove_line_breaks_from_html.py
Last active August 29, 2015 14:18
Clean up unwanted line breaks in HTML text; takes two arguments: input HTML filename and output name. (Uses lxml 3.4.2; later versions may be OK too.)
#!/usr/bin/env python
# encoding: utf-8
from __future__ import (unicode_literals, print_function,
absolute_import, division)
import codecs
import re
import sys
import lxml.html
@StevenMaude
StevenMaude / jq_select
Created November 5, 2014 11:07
Simple jq select statement to match JSON files with title value of "some title"
jq '.["title"] | select(. == "some title")' *.json
@StevenMaude
StevenMaude / pdf_to_html.py
Created May 16, 2014 09:53
pdf_to_html_preview messy hack to work on Windows
#forked from: Julian_Todd / PDF to HTML (https://scraperwiki.com/views/pdf-to-html-preview-1/)
#input url goes to line
import sys
import urllib, urllib2, urlparse
import lxml.etree, lxml.html
import re, os
def Pageblock(page, index):
'''