Skip to content

Instantly share code, notes, and snippets.

@a-h
a-h / .zshrc
Last active February 8, 2020 17:04
.zshrc
export PATH=/usr/local/go:/Users/adrian/go/bin/:$PATH
export PATH=/usr/local/bin/:$PATH
export PATH="$PATH:/Users/adrian/.dotnet/tools"
# Set the prompt.
NT_PROMPT_SYMBOL=❱
function precmd(){
autoload -U add-zsh-hook
setopt prompt_subst
@a-h
a-h / .vimrc
Last active April 8, 2020 09:55
My .vimrc
" Plugins used
" Install vim-plug.
" https://github.com/junegunn/vim-plug
" curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
" Install dependencies.
" python3 -m pip install --user --upgrade pynvim
" python -m pip install --user --upgrade pynvim
" :PlugInstall
@a-h
a-h / disablecaching.go
Created August 20, 2019 08:15
Disable caching and sniffing via HTTP headers
func DisableCachingAndSniffing(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate;")
w.Header().Set("pragma", "no-cache")
w.Header().Set("X-Content-Type-Options", "nosniff")
next.ServeHTTP(w, r)
})
}
@a-h
a-h / default.md
Last active August 20, 2019 22:13
Tools
{"lightId":"1","states":[true,true,true,true,true]}

Keybase proof

I hereby claim:

  • I am a-h on github.
  • I am adrianhesketh (https://keybase.io/adrianhesketh) on keybase.
  • I have a public key whose fingerprint is 0227 7F96 9055 ACF7 36CE 8954 9E01 3872 2232 3123

To claim this, I am signing this object:

@a-h
a-h / esp32_audio.ino
Created March 17, 2019 19:35
ESP32 DAC square wave
#include <U8x8lib.h>
U8X8_SSD1306_128X64_NONAME_SW_I2C u8x8(/* clock=*/15, /* data=*/4, /* reset=*/16);
// Timer setup.
volatile int interruptCounter;
volatile int totalInterruptCounter;
hw_timer_t *timer = NULL;
portMUX_TYPE timerMux = portMUX_INITIALIZER_UNLOCKED;
@a-h
a-h / lambda.js
Created February 5, 2019 14:09
Lambda@Edge to carry out redirects and apply default documents (index.html) to incoming requests
var path = require('path');
const redirects = {
"/about-us": { to: "/about", statusCode: 301 },
"/contact-us/head-office": { to: "/contact/head-office", statusCode: 302 },
};
exports.handler = async event => {
const { request } = event.Records[0].cf;
const normalisedUri = normalise(request.uri);
@a-h
a-h / redirect.yaml
Created February 5, 2019 09:09
Apex redirect handling using AWS Network and Application Load Balancers
---
AWSTemplateFormatVersion: '2010-09-09'
Description: Sets up the required resources for the website at example.com
Parameters:
DomainName:
Type: String
Description: The website domain name.
Default: example.co.uk
RedirectTo:
Type: String