Skip to content

Instantly share code, notes, and snippets.

Tom Morris tommorris

Block or report user

Report or block tommorris

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
tommorris /
Last active Jun 15, 2019
Little code sample for blog post
def prefix_check(url):
for prefix in PREFIXES:
if url.startswith(prefix):
return url
return ""
tommorris /
Created Jun 7, 2019
Google Cloud Function for creating QR codes
import io
from flask import send_file
import qrcode
def make_qr(data, box_size=10, border=2):
qr = qrcode.QRCode(version=1,
tommorris /
Created Mar 6, 2019
An issue with GitHub Pages settings

I have a site that uses GitHub Pages - It used to not serve an HTTPS certificate, but I moved the DNS around today so it is now pointing to GitHub Pages using an ANAME.

The SSL certificate works fine (and Let's Encrypt is a great addition to GitHub Pages), but the UI has a slight issue. I go to the repos Settings page and see this...

screenshot 2019-03-06 at 21 52 14

So I tick the box. A green tick appears.

screenshot 2019-03-06 at 21 53 09

tommorris /
Created Jan 31, 2019
Sample Google Cloud function
import nexmo
from flask import jsonify
def send_sms(request):
data = request.get_json()
# NEXMO_API_KEY and NEXMO_API_SECRET are in env vars
# which are set in the Google Cloud function
client = nemxo.Client()
tommorris / 7segment.scala
Last active Nov 22, 2018
A Scala implementation of tomscott's 7-segment display problem
View 7segment.scala
import scala.util.matching.Regex
val matcher: Regex = "[gkmqvwxzio]".r
def displayableOn7SegmentDisp(str: String) = matcher.findAllIn(str).isEmpty
val filename = "/Users/tom/Desktop/words_alpha.txt"
val words = Source.fromFile(filename).getLines.toStream
val longestWord = words.filter(displayableOn7SegmentDisp).sortWith(_.length > _.length).head
tommorris /
Last active Nov 2, 2018
An example of how to retrieve API keys from 1Password vault
eval $(op signin <yoursubdomain>) # this will prompt you to log in
export NEXMO_API_KEY=$(op get item Nexmo | jq '.details.sections[]? | select(.fields) | .fields[] | select(.t == "key").v')
export NEXMO_API_SECRET=$(op get item Nexmo | jq '.details.sections[]? | select(.fields) | .fields[] | select(.t == "secret").v')
View encoded.txt
tommorris /
Created Aug 30, 2017
Perl source code for lns utility (archived)
# desc{ a friendly program for making symbolic links }
$VERSION = '2.01'; # Time-stamp: "2008-08-19 19:26:35 AKDT"
=head1 NAME
lns -- a friendly program for making symbolic links
tommorris / query.sparql
Created Aug 19, 2017
Wikidata SPARQL: editions of books/works in languages other than the original
View query.sparql
SELECT ?original ?originalLabel ?translation ?translationLabel ?originalLang ?originalLangLabel ?translationLang ?translationLangLabel
?translation wdt:P629 ?original .
?translation wdt:P364 ?translationLang .
?original wdt:P364 ?originalLang .
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,fr,it,es,pt,de,dk,nl,pl,ru,he,ar,zh,jp". }
FILTER (?translationLang != ?originalLang)
tommorris / trump_status.json
Created Aug 4, 2017
Has Trump Been Impeached (JSON)
View trump_status.json
"uid": "urn:uuid:4a1c45a3-5cd5-46e2-a4e0-938cb6d060c4",
"updateDate": "2017-08-04T00:00:00.0Z",
"titleText": "Has Trump Been Impeached?",
"mainText": "Donald Trump has not been impeached."
You can’t perform that action at this time.