Skip to content

Instantly share code, notes, and snippets.

View quick-boot-repair.sh
#!/bin/bash
sudo add-apt-repository -y ppa:yannubuntu/boot-repair && sudo apt-get update
sudo apt-get install -y boot-repair && boot-repair
@sebmaynard
sebmaynard / camisc_unique.erl
Created May 15, 2013
Generate a somewhat unique 64 bit number.
View camisc_unique.erl
-module(camisc_unique).
-export([semi_unique/0, get_timestamp/0, test/0]).
%% ===================================================================
%% API
%% ===================================================================
%% Generate a somewhat unique 64 bit number.
%%
@sebmaynard
sebmaynard / module_starter_hack.erl
Created Jun 6, 2013
A hack to try and startup an erlang application and its dependencies. Should only really be used for lazy development/fiddling as reltool/relx/rebar will handle all this for you.
View module_starter_hack.erl
-module(module_starter_hack).
-export([try_force_start_application/1]).
try_force_start_application(App) ->
start_application_process_result(App, try_start_application(App)).
%%%%%%%%%%%%%%%
%% Helpers
@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),
@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 / 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 / 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 / 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 / .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 / 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/*" ! \