Skip to content

Instantly share code, notes, and snippets.

@cpilsworth
cpilsworth / lambda-basic-auth.js
Last active May 22, 2019 23:42 — forked from lmakarov/lambda-basic-auth.js
Basic HTTP Authentication for CloudFront with Lambda@Edge without credentials in code
'use strict';
var crypto = require('crypto');
// Lambda@Edge does not allow for environment variables so compare credential hash rather than store credentials in code
// sha256 hex digest of the Basic base64(username:password) header
// e.g. show below, generated on mac:
// echo -n "Basic `(echo -n 'admin:password' | openssl base64)`" | shasum -a 256
const authStringSha256 = '9f19de0237c9bd59f803de1785f7aea4e3499b6929df3428e1b415fed81f797a';
@cpilsworth
cpilsworth / lambda-basic-auth.js
Created March 3, 2018 19:58 — forked from lmakarov/lambda-basic-auth.js
Basic HTTP Authentication for CloudFront with Lambda@Edge
'use strict';
exports.handler = (event, context, callback) => {
// Get request and request headers
const request = event.Records[0].cf.request;
const headers = request.headers;
// Configure authentication
const authUser = 'user';
const authPass = 'pass';
@cpilsworth
cpilsworth / 001-index.md
Last active May 23, 2018 20:16
A+ SSL using Java 9

Configuring java for an A+ ssllabs.com server rating

It never used to be possible to get an A+ rating, as Java missed a couple of necessary features

Setting up the server

Getting Java 9

wget http://download.java.net/java/GA/jdk9/9/binaries/jdk-9+181_linux-x64_bin.tar.gz

Getting the LetsEncrypt/EFF certbot

@cpilsworth
cpilsworth / pom.xml
Created July 29, 2016 10:44
Maven module pom for wrapping jjwt 0.6.0 and making android.util import optional
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.myapp</groupId>
<artifactId>jjwt</artifactId>
<version>0.6.0</version>
<packaging>bundle</packaging>
<name>JSON Web Token support for the JVM</name>
<description>
This bundle simply wraps ${pkgGroupId}-${pkgVersion}.jar and makes android.util optional
</description>
@cpilsworth
cpilsworth / service-checklist.md
Created March 24, 2016 14:37 — forked from acolyer/service-checklist.md
Internet Scale Services Checklist

Internet Scale Services Checklist

A checklist for designing and developing internet scale services, inspired by James Hamilton's 2007 paper "On Desgining and Deploying Internet-Scale Services."

Basic tenets

  • Does the design expect failures to happen regularly and handle them gracefully?
  • Have we kept things as simple as possible?
@cpilsworth
cpilsworth / post.POST.html
Last active April 21, 2016 13:42
Using acs-aem-commons forms functionality with Sightly
<sly data-sly-use.form="test.js"></sly>
sly data-sly-test.errors="${form.validate}"></sly>
<sly data-sly-test="${errors}">${form.renderForm}</sly>
<sly data-sly-test="${!errors}">${form.redirectSuccess}</sly>

Install XCode command line tools

gcc will trigger the download dialog.

Download brew

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Install Brews

brew install git
@cpilsworth
cpilsworth / aem-is-a-two-stack-cms.md
Last active September 16, 2015 18:04
Comparison of the Two Stack CMS pattern with Adobe Experience Manager

Adobe AEM - Two Stack CMS comparison

TL;DR

The architecture outlined by Martin Fowler in his Two Stack CMS article is very similar to that used by Adobe AEM. One key difference is that AEM does not split out a separate "preview layer", so that content can be previewed as it is being prepared.

Overview

@cpilsworth
cpilsworth / eddystone-url-beacon
Last active September 11, 2015 13:49
Simple node app to advertise a URL over BT4 using eddystone protocol
== title
@cpilsworth
cpilsworth / display-websocket.html
Last active August 29, 2015 14:19
Displays the responses from a web socket
<!doctype html>
<html>
<body>
<pre id="server_events"></pre>
<script>
var socket = new WebSocket("ws://" + window.location.hostname + ":8888/");
var code = document.getElementById("server_events");
var msgs = 0;
socket.onopen = function(){