Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / gist:3691756
Created Sep 10, 2012
CodeIgniter OAuth controller example
View gist:3691756
<?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 Jul 1, 2012
Modular size typography
View ms.less
/* 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 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 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;
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 AccessToken.php
<?php
namespace OAuth;
class AccessToken
{
/**
* @var string
*/
protected $type = 'Bearer';