Skip to content

Instantly share code, notes, and snippets.

Alun Davey 4lun

Block or report user

Report or block 4lun

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
View macos-dev-setup.sh
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew install nvm && echo -e "\
NVM_DIR=\"$HOME/.nvm\"\n. \"/usr/local/opt/nvm/nvm.sh\"
" >> ~/.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
4lun / domain.com
Last active Jul 31, 2018
NGINX config for using Let's Encrypt via the acme.sh client, assumes the existence of a `/var/www/.letsencrypt` directory and enforces HTTPS while allowing cert issue/renewal over HTTP
View domain.com
server {
listen 80;
server_name domain.com;
include letsencrypt_params;
}
server {
listen 443;
server_name domain.com;
@4lun
4lun / pack-list.md
Last active Jul 3, 2018
Pack list for travelling and outdoor pursuits
View pack-list.md

Pack List

General

  • Bag
  • T-shirts
  • Trousers
  • Socks
  • Underwear
  • Travel adapter
  • Plug splitter
  • Various chargers
@4lun
4lun / ubuntu-minecraft-server.sh
Created Aug 29, 2017
Install and run a vanilla Minecraft server (1.7.4) on a new install of Ubuntu 16.04
View ubuntu-minecraft-server.sh
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
wget https://s3.amazonaws.com/Minecraft.Download/versions/1.7.4/minecraft_server.1.7.4.jar
ln -s minecraft_server.1.7.4.jar minecraft_server.jar
screen -S minecraft
@4lun
4lun / jenkins-remote-build-trigger.md
Last active Sep 10, 2018
How to trigger a remote build via a URL for a Jenkins job
View jenkins-remote-build-trigger.md
  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:

http://{USER}:{API_TOKEN}@{JENKINS_URL}/job/{JOB}/build?token={AUTHENTICATION_TOKEN}

@4lun
4lun / letsencrypt-acme-nginx.sh
Last active Mar 10, 2017
Generate and install SSL certificate with letsencrypt (for nginx)
View letsencrypt-acme-nginx.sh
export DOMAIN="mydomain.com"
curl https://get.acme.sh | sh
bash --login
mkdir -p /etc/nginx/certs/$DOMAIN/
acme.sh --issue -d $DOMAIN -w /var/www/$DOMAIN/public/
acme.sh --install-cert -d $DOMAIN \
--certpath /etc/nginx/certs/$DOMAIN/cert.pem \
--keypath /etc/nginx/certs/$DOMAIN/key.pem \
--fullchainpath /etc/nginx/certs/$DOMAIN/fullchain.pem \
@4lun
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 newdomain.com/?referrer=olddomain). 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
<RoutingRules>
<RoutingRule>
<Condition>
<HttpErrorCodeReturnedEquals>404</HttpErrorCodeReturnedEquals>
</Condition>
<Redirect>
<HostName>newdomain.com</HostName>
<ReplaceKeyWith>?referrer=olddomain</ReplaceKeyWith>
</Redirect>
</RoutingRule>
@4lun
4lun / generate-self-signed-cert.sh
Created Feb 14, 2017
Generate a self signed wildcard SSL cert (run one line at a time)
View generate-self-signed-cert.sh
# Based on: http://blog.celogeek.com/201209/209/how-to-create-a-self-signed-wildcard-certificate/
# Replace .domain.com with desired domain (and x.domain instances)
openssl genrsa 2048 > x.domain.key
openssl req -new -x509 -nodes -sha1 -days 3650 -key x.domain.key > x.domain.cert
# Interactive prompt: enter *.domain.com for the Common Name
openssl x509 -noout -fingerprint -text < x.domain.cert > x.domain.info
cat x.domain.cert x.domain.key > x.domain.pem
@4lun
4lun / generate-instagram-access-token.md
Created Jan 17, 2017
Generate a personal access token for Instagram
View generate-instagram-access-token.md
  1. Register a client at https://www.instagram.com/developer/ (redirect_uri can be something simple such as http://localhost)
  2. Go to the 'Security' tab for your client (under manage) and untick 'Disable implicit OAuth'
  3. Take the following URL, subsitute the [client_id] with your own and the [redirect_uri] with one you specified during the registration process: https://api.instagram.com/oauth/authorize/?client_id=[client_id]&redirect_uri=[redirect_uri]&response_type=token
  4. Navigate to the URL in the browser (while logged in as the same user), after accepting any prompts you should be redirected to your specified redirect_uri with the access token appended
@4lun
4lun / propositions.md
Last active May 12, 2017
Notes on Propositions from Computer logic and arithmetic lecture, including Javascript equivalents
View propositions.md

Propositions

Javascript equivalents in quotes for comparison

AND (∧)

A ∧ B = a && b

OR (∨)

A ∨ B = a || b

NOT (¬)

You can’t perform that action at this time.