Skip to content

Instantly share code, notes, and snippets.

View richardTowers's full-sized avatar

Richard Towers richardTowers

View GitHub Profile
@richardTowers
richardTowers / README.md
Created October 20, 2022 09:00
Send lots of emails with attached files using GOV.UK Notify

Send lots of emails with attached files using GOV.UK Notify

Usage

Create a template with a single ((link_to_file)) placeholder in Notify, and an API key. Then call the script with the filename to attach, the API key, and the template ID as environment variables, and a list of email addresses on standard in.

export API_KEY="redacted"
export TEMPLATE_ID="redacted"
export FILENAME_TO_UPLOAD="whatever.docx" 
@richardTowers
richardTowers / README.md
Created February 13, 2019 11:43
How to disable "Don't ask again on this computer" for google's MFA

Google have good support for MFA. They support U2F tokens, and you can register more than one to the same account (cough AWS cough).

However, to make using MFA more convenient for users, they auto-check a "Don't ask again on this computer" checkbox. This means you generally don't get asked for you MFA device, because the machine you're on is already trusted.

I feel that the convenience of this is not worth the security trade off though - I'd prefer to have to use my security key each time.

I had a play with the cookies google uses. If you block the SMSV cookie on accounts.google.com you can force google not to trust your machine and ask you to perform MFA each time you log in.

@richardTowers
richardTowers / monokai-slack-theme.txt
Created April 30, 2018 16:43
Monokai theme for the slack sidebar
#141411,#383830,#383830,#F92672,#383830,#E6E6E6,#A6E22A,#66D9EF
@richardTowers
richardTowers / vimrc
Last active February 8, 2018 14:40
A vim macro to expand a name into a Co-authored-by line
# Usage: IRichard Towers<ESC>@a
# Result: Co-authored-by: Richard Towers <richard.towers[at]digital.cabinet-office.gov.uk>
let @a='ICo-authored-by: ly$A <@digital.cabinet-office.gov.uk>F@Pva<guf r.'

Keybase proof

I hereby claim:

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

To claim this, I am signing this object:

./|,,/|
< o o)
<\ ( |
<\\ |\ |
<\\\ |(__)
<\\\\ |
N1C4AA
N1C4AB
N1C4AD
N1C4AE
N1C4AF
N1C4AH
N1C4AJ
N1C4AL
N1C4AN
N1C4AP
@richardTowers
richardTowers / LinkedListVsList.cs
Last active December 18, 2015 17:09
A comparison of LinkedList performance against List performance. Inserting elements at the start of the list.
void Main()
{
const int maxHits = 100*1000;
var list = new List<Tuple<int, TimeSpan, TimeSpan>>();
for(var i = 10; i < maxHits; i *= 2)
{
var output = Test(i);
list.Add(Tuple.Create(i, output.Item1, output.Item2));
}
@richardTowers
richardTowers / gist:5207061
Last active December 15, 2015 05:09
Quick demo of pitfalls of `this` in JavaScript
<!doctype html>
<html>
<head>
<title>this</title>
</head>
<body>
<div><a id="broken" href="#">Incorrectly bound click</a></div>
<div><a id="working" href="#">Correctly bound click</a></div>
<div><a id="working2" href="#">Also correctly bound click</a></div>
<script>
@richardTowers
richardTowers / MozartNotes.rb
Created February 1, 2013 22:50
Reads a music XML file and counts the notes that are C5.
require "rexml/document"
include REXML
file = File.new( "String Quartet No. 3 in G Major, K. 156.xml" )
doc = Document.new file
notes = XPath.match( doc, "//note/pitch[step='C' and octave='5' and not(alter)]" )
puts notes.length