Skip to content

Instantly share code, notes, and snippets.

@sebmaynard
sebmaynard / create_dns_records.sh
Created March 7, 2019 16:36
Create dns records on route53 from a text file
#!/bin/bash -e
usage() {
echo "Need a hosted zone name (abc.com.) with the dot on the end"
exit 1
}
HOSTED_ZONE_NAME=$1
if [[ "$HOSTED_ZONE_NAME" == "" ]] ; then
usage
@sebmaynard
sebmaynard / bookmarklet.js
Last active October 3, 2022 18:09
Evernote HTML Editor
/*
Copyright 2015 Seb Maynard
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
@sebmaynard
sebmaynard / clacks_middleware.erl
Created March 16, 2015 08:44
Clacks Middleware for Cowboy on Erlang.
%% A man is not dead while his name is still spoken.
-module(clacks_middleware).
-behaviour(cowboy_middleware).
-export([execute/2]).
execute(Req, Env) ->
ReqWithClacks = cowboy_req:set_resp_header(<<"x-clacks-overhead">>, <<"GNU Terry Pratchett">>, Req),
{ok, ReqWithClacks, Env}.
@sebmaynard
sebmaynard / erlfind.sh
Last active August 29, 2015 14:01
A fast, simple find/grep wrapper targetted at Erlang projects
#!/bin/bash
# speed things up quite a lot!
export LC_ALL=C
# uses -P (perl regular expressions) for speed
find ./ -type f ! \
-path "*/deps/*" ! \
-path "*/caerldeps/*" ! \
-path "*/_rel/*" ! \
@sebmaynard
sebmaynard / .tmux.conf
Last active December 29, 2015 15:19
Enable ctrl-<arrow> keys for moving between tmux and emacs panes (requires emacs, tmux and zsh). This allows you to use ctrl-<arrow> to switch panes in an emacs split, and then move to the nearest tmux pane once you get to the edge of the emacs window. Particularly useful if you have tmux split with emacs in one pane, and zsh in another
set-window-option -g xterm-keys on
@sebmaynard
sebmaynard / crontab
Last active December 19, 2015 02:38
Generate an images-only feed for the Dilbert comic.
# update dilbert rss every morning at 2am
0 2 * * * /home/user/bin/update_dilbert.sh
@sebmaynard
sebmaynard / emacsclient_gui.sh
Created June 14, 2013 08:43
Start emacsclient with some progress of what's going on (useful for desktop launchers)
#!/bin/bash
## for emacsclient:
## -c is gui window
## -n is no-wait - don't wait for the window to close
## sed buffers by default
## -u is unbuffered
## zenity expects text progress to start with #
emacsclient -c -n 2>&1 | sed -u -e 's/^/# /g' | zenity --title="Starting EmacsClient" --width=600 --progress --pulsate --auto-close
@sebmaynard
sebmaynard / owncloud-upgrade.sh
Created June 12, 2013 15:52
Upgrade an owncloud instance. Check the notes at the top for assumptions
#!/bin/bash
# Upgrade an owncloud instance. Makes the following assumptions:
# 1. you're running this as the same user who owns (and can write to) $OWNCLOUD_FOLDER
# 2. $TMP_FOLDER is writeable by this user
# These should be absolute paths
OWNCLOUD_FOLDER=/var/public_html_ssl/cloud
TMP_FOLDER=/tmp/owncloud-upgrade
@sebmaynard
sebmaynard / restore_dotfiles.sh
Created June 12, 2013 10:38
A bash script to restore dotfiles to ~/ from somewhere else (probably files under a git repository). Allows you to keep *some* of your dotfiles in git without needing everything, and a fast way to restore them on a new box.
#!/bin/bash
function link_files_to_folder() {
if [[ ! -d $1 || ! -d $2 ]] ; then
echo "Usage: link_files_to_folder <source_dir> <target_dir> [prefix]"
exit
fi
SOURCE_DIR=$1
TARGET_DIR=$2
@sebmaynard
sebmaynard / ca_cowboy_middleware.erl
Created June 10, 2013 08:42
A Cowboy middleware to set some CORS headers for every request, and to handle OPTIONS requests without needing to implement them in every handler.
-module(ca_cowboy_middleware).
-behaviour(cowboy_middleware).
-export([execute/2]).
execute(Req, Env) ->
{ok, ReqWithCorsHeaders} = set_cors_headers(Req),
{Method, ReqMethod} = cowboy_req:method(ReqWithCorsHeaders),