Skip to content

Instantly share code, notes, and snippets.

View alexbilbie's full-sized avatar
👋

Alex Bilbie alexbilbie

👋
View GitHub Profile
@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 / 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 / gist:3691756
Created September 10, 2012 16:02
CodeIgniter OAuth controller example
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Oauth extends CI_Controller {
private $oauth;
public function __construct()
{
parent::__construct();
@alexbilbie
alexbilbie / ms.less
Created July 1, 2012 18:45
Modular size typography
/* Modular Size typography */
@base-font-size: 14; // this is the base f
@important-font-size: 44;
@font-ratio: 1.618;
@base-diff: @important-font-size / @base-font-size;
@h1: @important-font-size;
@h2: (@base-diff / (@base-diff - (@base-diff / @font-ratio)));
@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\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;
<?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
namespace OAuth;
class AccessToken
{
/**
* @var string
*/
protected $type = 'Bearer';