Skip to content

Instantly share code, notes, and snippets.

View JoeStanton's full-sized avatar

Joe Stanton JoeStanton

  • DeepMind
  • London
View GitHub Profile
@JoeStanton
JoeStanton / ntlm.js
Last active December 1, 2022 08:46
NTLM Authentication with node-fetch
/* eslint-disable no-console */
const https = require('https');
const fetch = require('node-fetch');
const ntlm = require('httpntlm').ntlm;
const keepAlive = new https.Agent({ keepAlive: true });
const handleErrors = (response) => {
if (!response.ok) {
@JoeStanton
JoeStanton / ec2-provision.sh
Last active January 18, 2019 07:47
Install Chef-Solo and provision the specified role on a bare EC2 instance.
#!/usr/bin/env bash
echo Starting to provision server with role: $1
echo -e "\nInstalling and bootstrapping chef-solo..."
apt-get -y update
apt-get --no-install-recommends -y install build-essential ruby ruby-dev rubygems libopenssl-ruby
gem install chef ruby-shadow --no-ri --no-rdoc
echo 'PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/var/lib/gems/1.8/bin"' > /etc/environment
import {SuitType} from "./types";
import {generateSchema} from "flow-runtime";
const validate = (value, type) => {
return joi.validate(value, generateSchema(type), {
abortEarly: false
});
}
// Validation calls
@JoeStanton
JoeStanton / handler.js
Last active January 17, 2017 14:24
Lambda container lifetime
var startedAt = (new Date).toString();
var lastExecuted = null;
exports.ping = function(event, context, done) {
lastExecutedCopy = lastExecuted;
lastExecuted = (new Date).toString();
done(null, {
warm: !!lastExecutedCopy,
startedAt: startedAt,
last: lastExecutedCopy,
// Type Definitions
type UserListing = {
users: Array<User>
}
type ProfilePic = {
url: string,
width: number,
height: number
@JoeStanton
JoeStanton / flow-runtime-types.js
Last active October 2, 2016 23:05
Flow Runtime Types
type Suit =
| "Diamonds"
| "Clubs"
| "Hearts"
| "Spades";
// Babel transformed into Flow AST:
export const SuitType = {
type: 'UnionTypeAnnotation',
@JoeStanton
JoeStanton / Gemfile
Last active September 15, 2016 08:48
React onChange event not firing under Poltergeist
source "https://rubygems.org"
gem 'rspec'
gem 'capybara'
gem 'poltergeist'
gem 'selenium-webdriver'
@JoeStanton
JoeStanton / pipe.js
Last active January 28, 2016 13:05
Piping - In the absence of the `|>` operator, a Clojure-like threading function
import {map, unique} from "prelude-ls";
function pipe(input, ...funcs) {
return funcs.reduce((step, f) => f(step), input);
}
function curry(fn, ...args) {
if (args.length >= fn.length) {
return fn(...args);
}
@JoeStanton
JoeStanton / pipe.js
Created January 28, 2016 11:36
Nice ES7 pipeline syntax
import {map, unique, sort} from "prelude-ls"
types
::map(v => v[type])
::unique
::sort
::map(toOption);
@JoeStanton
JoeStanton / gist:7303958
Created November 4, 2013 15:14
Sample task that can be hooked into Capistrano for deploy-time annotations.
require 'librato/metrics'
REPO_NAME = 'JoeStanton/my-project'
Librato::Metrics.authenticate 'joe.stanton@red-badger.com', 'API_KEY'
sha, msg = `git log -n 1 --pretty="%h:%s"`.strip.split(":", 2)
Librato::Metrics.annotate :deployments, "Deployed #{sha}", {
description: msg,
links: [ {rel: "github", href: "http://github.com/#{REPO_NAME}/commit/#{sha}"} ]
}