Skip to content

Instantly share code, notes, and snippets.

View tommorris's full-sized avatar

Tom Morris tommorris

View GitHub Profile
@tommorris
tommorris / 7segment.scala
Last active November 22, 2018 21:22
A Scala implementation of tomscott's 7-segment display problem
import scala.util.matching.Regex
import scala.io.Source
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
println(longestWord)
@tommorris
tommorris / get_nexmo_keys.sh
Last active November 2, 2018 16:01
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')
SGFwcHkgYmlydGhkYXksIGNVUkwuIFlvdSBhcmUgYW4gZXNzZW50aWFsIHRvb2wuIFdlIGxvdmUgeW91IHRvIGJpdHMuIEtlZXAgYmVpbmcgYW1hemluZy4K
@tommorris
tommorris / lns.pm
Created August 30, 2017 16:28
Perl source code for lns utility (archived)
#!/usr/bin/perl
# desc{ a friendly program for making symbolic links }
$VERSION = '2.01'; # Time-stamp: "2008-08-19 19:26:35 AKDT sburke@cpan.org"
=head1 NAME
lns -- a friendly program for making symbolic links
=head1 SYNOPSIS
@tommorris
tommorris / query.sparql
Created August 19, 2017 17:40
Wikidata SPARQL: editions of books/works in languages other than the original
SELECT ?original ?originalLabel ?translation ?translationLabel ?originalLang ?originalLangLabel ?translationLang ?translationLangLabel
WHERE {
?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
tommorris / trump_status.json
Created August 4, 2017 16:33
Has Trump Been Impeached (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."
}
@tommorris
tommorris / flask_example.py
Created July 17, 2017 13:02
Nexmo: Flask incoming call, basic TTS response with NCCO JSON
from flask import Flask, jsonify
app = Flask(__name__)
@app.route("/incoming-call")
def incoming_tts_call():
ncco = [
{
"action": "talk",
@tommorris
tommorris / get_opentech_audio.sh
Created June 24, 2017 21:56
get all OpenTech 2017 audio using wget
wget -c http://www.opentech.org.uk/2017/audio/opentech-2017-{A..C}-{1..6}.mp3
@tommorris
tommorris / ft.js
Created April 24, 2017 11:01
FoldingText launcher written in JXA (JS for macOS Scripting Architecture). copy into your path and rename to whatever you want it to be (I use `ft`).
#!/usr/bin/env osascript -l JavaScript
ObjC.import('AppKit')
function run(argv) {
if (!(Application('FoldingText').running())) {
$.NSWorkspace.sharedWorkspace.launchApplication('/Applications/FoldingText.app')
}
var ft = Application("FoldingText");
argv.forEach(function (item) {
# MacBook Pro
$ john --wordlist=/usr/local/opt/john/share/john/password.lst --rules hashes.txt
Loaded 2 password hashes with 2 different salts (bcrypt [Blowfish 32/64 X2])
Press 'q' or Ctrl-C to abort, almost any other key for status
love (?)
london (?)
2g 0:00:00:24 100% 0.08100g/s 23.81p/s 27.37c/s 27.37C/s lionking..london
Use the "--show" option to display all of the cracked passwords reliably
Session completed