Skip to content

Instantly share code, notes, and snippets.


Alun Davey 4lun

View GitHub Profile
4lun /
Last active Nov 20, 2020
NGINX config for using Let's Encrypt via the client, assumes the existence of a `/var/www/.letsencrypt` directory and enforces HTTPS while allowing cert issue/renewal over HTTP
server {
listen 80;
include letsencrypt_params;
server {
listen 443;
4lun / reddit-unsubscribe-all-subreddits.js
Last active Oct 12, 2020
Unsubscribe from all subreddits
View reddit-unsubscribe-all-subreddits.js
// Visit and run the following in console (browser dev tools)
// Wait until all the buttons have visibly toggled, refresh page to confirm.
$('.fancy-toggle-button .remove').each(function(i, elem) { setTimeout(function(){ $(elem).trigger('click'); }, i*500) });
4lun / class-names.css
Last active Nov 17, 2019
Ideas for CSS class names
View class-names.css
View index.html
<meta name="viewport" content="width=device-width, initial-scale=1.0">
body {
box-sizing: border-box;
margin: 0;
padding: 2vh 5vh 4vh;
background: #050505;
4lun / str.slug.js
Created Dec 10, 2014
Slug function in JS matching the Laravel 4 implementation (Str::slug) - Note: does not include the transliteration of a UTF-8 value to ASCII
View str.slug.js
function slug(title, separator) {
if(typeof separator == 'undefined') separator = '-';
// Convert all dashes/underscores into separator
var flip = separator == '-' ? '_' : '-';
title = title.replace(flip, separator);
// Remove all characters that are not the separator, letters, numbers, or whitespace.
title = title.toLowerCase()
.replace(new RegExp('[^a-z0-9' + separator + '\\s]', 'g'), '');
4lun /
Last active Jul 9, 2019
How to trigger a remote build via a URL for a Jenkins job
  1. Create new user (e.g. webhook) with the following permissions: Overall > Read, Job > Build, Job > Read & Job > Workspace. Login as the user and get their API token
  2. Under a job, enable "Trigger Builds Remotely" and set an authentication token
  3. Trigger a POST request with the following structure:


/usr/bin/ruby -e "$(curl -fsSL"
brew install nvm && echo -e "\
NVM_DIR=\"$HOME/.nvm\"\n. \"/usr/local/opt/nvm/\"
" >> ~/.bash_profile && source ~/.bash_profile &&
nvm install v8 --default &&
brew cask install iterm2 chromium visual-studio-code 1password authy alfred
sudo rm -rf Downloads/
ln -s ~/Desktop Downloads
4lun /
Last active Jul 3, 2018
Pack list for travelling and outdoor pursuits

Pack List


  • Bag
  • T-shirts
  • Trousers
  • Socks
  • Underwear
  • Travel adapter
  • Plug splitter
  • Various chargers
4lun /
Created Aug 29, 2017
Install and run a vanilla Minecraft server (1.7.4) on a new install of Ubuntu 16.04
fallocate -l 1G /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
apt update
apt install -y screen default-jdk
ln -s minecraft_server.1.7.4.jar minecraft_server.jar
screen -S minecraft
4lun / s3-redirect-routing-rules.xml
Last active Jun 4, 2017
Redirect all requests from an S3 bucket to another domain with explicit path (example redirects all requests to Substitute 404 code with 403 if bucket is not publicly readable. Note this all assumes there are no matching files in the bucket.
View s3-redirect-routing-rules.xml
You can’t perform that action at this time.