Skip to content

Instantly share code, notes, and snippets.

Seb Maynard sebmaynard

Block or report user

Report or block sebmaynard

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@sebmaynard
sebmaynard / create_dns_records.sh
Created Mar 7, 2019
Create dns records on route53 from a text file
View create_dns_records.sh
#!/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 Mar 17, 2019
Evernote HTML Editor
View bookmarklet.js
/*
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 Mar 16, 2015
Clacks Middleware for Cowboy on Erlang.
View clacks_middleware.erl
%% 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 Aug 29, 2015
A fast, simple find/grep wrapper targetted at Erlang projects
View erlfind.sh
#!/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 Dec 29, 2015
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
View .tmux.conf
set-window-option -g xterm-keys on
@sebmaynard
sebmaynard / crontab
Last active Dec 19, 2015
Generate an images-only feed for the Dilbert comic.
View crontab
# update dilbert rss every morning at 2am
0 2 * * * /home/user/bin/update_dilbert.sh
@sebmaynard
sebmaynard / emacsclient_gui.sh
Created Jun 14, 2013
Start emacsclient with some progress of what's going on (useful for desktop launchers)
View emacsclient_gui.sh
#!/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 Jun 12, 2013
Upgrade an owncloud instance. Check the notes at the top for assumptions
View owncloud-upgrade.sh
#!/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 Jun 12, 2013
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.
View restore_dotfiles.sh
#!/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 Jun 10, 2013
A Cowboy middleware to set some CORS headers for every request, and to handle OPTIONS requests without needing to implement them in every handler.
View ca_cowboy_middleware.erl
-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),
You can’t perform that action at this time.