Skip to content

Instantly share code, notes, and snippets.

@alexbilbie
alexbilbie / pip.js
Created May 1, 2020
Picture in picture
View pip.js
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 Dec 27, 2018
Lambda@Edge security headers
View handler.js
'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' }];
View howto-installing-vault-on-aws-linux.md

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
Visual Studio Code settings
View keybindings.json
[
{
"key": "alt+cmd+l",
"command": "editor.action.format",
"when": "editorTextFocus"
},
{
"key": "cmd+l",
"command": "expandLineSelection",
"when": "editorTextFocus"
View resource-server-example.php
<?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';
View password-grant-example.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 Mar 4, 2016 — forked from asimihsan/hook.rb
Hook for letsencrypt.sh to do DNS challenges
View hook.rb
#!/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
View docker-helpers.sh
DOCKER_ENV="$HOME/.dockerenv"
DOCKER_MACHINE_NAME="default"
# Docker environment helpers
denv() {
eval "$(cat $DOCKER_ENV)"
}
dstart() {
@alexbilbie
alexbilbie / Caddyfile
Created Jan 7, 2016
PHP-FPM Caddyfile example
View Caddyfile
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 Nov 19, 2015
Lambda run.js for local testing
View lambda-run.js
// 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);