Skip to content

Instantly share code, notes, and snippets.

View alexbilbie's full-sized avatar
👋

Alex Bilbie alexbilbie

👋
View GitHub Profile
@alexbilbie
alexbilbie / pip.js
Created May 1, 2020 11:53
Picture in picture
function startPiP() {
var videos = document.getElementsByTagName('video');
for(vid in videos) {
if(videos[vid].src) videos[vid].webkitSetPresentationMode("picture-in-picture");
}
}
startPiP();
@alexbilbie
alexbilbie / handler.js
Created December 27, 2018 09:19
Lambda@Edge security headers
'use strict';
exports.handler = (event, context, callback) => {
//Get contents of response
const response = event.Records[0].cf.response;
const headers = response.headers;
//Set new headers
headers['Strict-Transport-Security'] = [{ key: 'Strict-Transport-Security', value: 'max-age= 63072000; includeSubdomains; preload' }];
headers['Content-Security-Policy'] = [{ key: 'Content-Security-Policy', value: "default-src 'none'; img-src 'self'; script-src 'self'; style-src 'self'; object-src 'none'" }];
headers['X-Content-Type-Options'] = [{ key: 'X-Content-Type-Options', value: 'nosniff' }];

HOWTO: Installing Vault On AWS Linux

This is quick howto for installing vault on AWS Linux, mostly to remind myself. At the end of this tutorial, you'll have a working vault server, using s3 for the backend, self signed certificates for tls, and supervisord to ensure that the vault server is always running, and starts on reboot.

Setting up S3

First things first, let's set up an s3 bucket to use as the storage backend for our s3 instance.

  1. From the AWS Mangement Console, go to the S3 console.

  2. Click on the Create Bucket button

@alexbilbie
alexbilbie / keybindings.json
Created May 20, 2016 08:08
Visual Studio Code settings
[
{
"key": "alt+cmd+l",
"command": "editor.action.format",
"when": "editorTextFocus"
},
{
"key": "cmd+l",
"command": "expandLineSelection",
"when": "editorTextFocus"
<?php
use League\OAuth2\Server\ResourceServer;
use OAuth2ServerExamples\Repositories\AccessTokenRepository;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Slim\App;
include __DIR__ . '/../vendor/autoload.php';
<?php
use League\OAuth2\Server\AuthorizationServer;
use League\OAuth2\Server\Exception\OAuthServerException;
use League\OAuth2\Server\Grant\PasswordGrant;
use OAuth2ServerExamples\Repositories\AccessTokenRepository;
use OAuth2ServerExamples\Repositories\ClientRepository;
use OAuth2ServerExamples\Repositories\RefreshTokenRepository;
use OAuth2ServerExamples\Repositories\ScopeRepository;
use OAuth2ServerExamples\Repositories\UserRepository;
@alexbilbie
alexbilbie / hook.rb
Created March 4, 2016 14:19 — forked from asimihsan/hook.rb
Hook for letsencrypt.sh to do DNS challenges
#!/usr/bin/env ruby
require 'aws-sdk'
require 'pry'
require 'awesome_print'
# ------------------------------------------------------------------------------
# Credentials
# ------------------------------------------------------------------------------
# pick up AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY by default from
DOCKER_ENV="$HOME/.dockerenv"
DOCKER_MACHINE_NAME="default"
# Docker environment helpers
denv() {
eval "$(cat $DOCKER_ENV)"
}
dstart() {
@alexbilbie
alexbilbie / Caddyfile
Created January 7, 2016 15:29
PHP-FPM Caddyfile example
root /app/public
tls /app/_docker/caddy/server.crt /app/_docker/caddy/server.key
fastcgi / php:9000 php
errors visible
rewrite {
regexp .*
ext /
to /index.php?{query}
}
@alexbilbie
alexbilbie / lambda-run.js
Created November 19, 2015 11:15
Lambda run.js for local testing
// Import the Lambda function
var lambda = require('./MyModule');
// Faking the Lambda context object
var context = {
done: function (error, success) {
console.log('-------DONE--------');
if (error !== undefined && error !== null) {
console.log('Error: ' + error);