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:

@richardTowers
richardTowers / angular-simple-matches-validator.js
Last active October 20, 2015 15:31
A simple directive to add "matches" validation, e.g. to check if a password matches a confirmation
function crMatches () {
return {
require: 'ngModel',
scope: {
crMatches: '='
},
link: function(scope, elem, attrs, ctrl) {
scope.$watch('crMatches', function (newValue) {
if (newValue) { ctrl.$setValidity('matches', newValue === elem.val()); }
});
@richardTowers
richardTowers / index.js
Created September 30, 2015 08:08
requirebin sketch
var Immutable = require('immutable');
var list = Immutable.List.of(1,2,3,4,5,6,7);
var result =
list
.map(function (x) { return x*x; })
.filter(function (x) { return x < 10 })
.reduce(function (acc, x) { return acc + x })
var injector = angular.injector(['ng']);
injector.instantiate(function ($http) {
window.$http = $http;
});
$http.get('https://whatever.com');
@richardTowers
richardTowers / designer.html
Last active August 29, 2015 14:13
designer
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-header-panel/core-header-panel.html">
<link rel="import" href="../core-animated-pages/core-animated-pages.html">
<link rel="import" href="../core-animated-pages/transitions/hero-transition.html">
<link rel="import" href="../core-animated-pages/transitions/cross-fade.html">
<link rel="import" href="../core-animated-pages/transitions/slide-down.html">
<link rel="import" href="../core-animated-pages/transitions/slide-up.html">
<link rel="import" href="../core-animated-pages/transitions/tile-cascade.html">
@richardTowers
richardTowers / bindToSeparateDateFieldFactory.js
Created January 2, 2015 16:12
function which takes two expressions and binds them together (useful for date processing)
function bindToSeparateDateFieldFactory ($rootScope, $parse) {
return function (context, srcExpression, targetExpression) {
var getTarget = $parse(targetExpression),
setTarget = getTarget.assign,
getSrc = $parse(srcExpression),
setSrc = getSrc.assign;
$rootScope.$watch(
function () { return getTarget(context); },
function (newValue) { newValue && setSrc(context, newValue + 'T00:00:00.000Z'); }