Skip to content

Instantly share code, notes, and snippets.

View AndrewFarley's full-sized avatar

Farley Farley (yes, really) AndrewFarley

  • New Plymouth, New Zealand
View GitHub Profile
@AndrewFarley
AndrewFarley / macos-recovery-server.md
Created May 25, 2018 10:29
Fixing "The recovery server could not be contacted" in MacOS High Sierra

I was trying to reinstall High Sierra on an older MacBook Air using internet recovery and I kept on getting an error message when trying to reinstall High Sierra.

The recovery server could not be contacted

It appears that this has to do with the time on the machine not being synchronized, so when the MacBook tries to reach out to the recovery server the certificates do not validate and we get this useless error message.

To fix this.

  1. Open up a Terminal from the utilities menu
  2. Enter the following command
@AndrewFarley
AndrewFarley / autossh.service
Created May 30, 2018 08:44 — forked from thomasfr/autossh.service
Systemd service for autossh
[Unit]
Description=Keeps a tunnel to 'remote.example.com' open
After=network.target
[Service]
User=autossh
# -p [PORT]
# -l [user]
# -M 0 --> no monitoring
# -N Just open the connection and do nothing (not interactive)
@AndrewFarley
AndrewFarley / sigterm.py
Created June 7, 2018 12:48 — forked from honza/sigterm.py
Sigterm handler in Python
"""
This snippet shows how to listen for the SIGTERM signal on Unix and execute a
simple function open receiving it.
To test it out, uncomment the pid code and kill the process with:
$ kill -15 pid
"""
import signal
import sys
@AndrewFarley
AndrewFarley / Ubuntu 16.04
Created July 4, 2018 21:37 — forked from dhoeric/Ubuntu 16.04
install-docker-aws-ec2-user-data
#!/bin/bash
# Install docker
apt-get update
apt-get install -y apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
apt-get update
import bcrypt
import hashlib
import time
import random
import string
from datetime import datetime, date
print("100 iterations of hashing")
print("=========================")
@AndrewFarley
AndrewFarley / backup-gitlab-to-s3.sh
Created September 5, 2018 11:57
A Shell Script to Backup Gitlab to S3 (with slack notifications)
#!/bin/bash
LOGFILE=/tmp/backup-gitlab-to-s3.log
GITLAB_BACKUP_FOLDER=/var/opt/gitlab/backups
S3_FILE_PREFIX=gitlab
S3_BUCKET_PATH=bucket-name-goes-here/gitlab-rotating-backups
SLACK_USERNAME="Backup Gitlab Daily - `hostname`"
SLACK_CHANNEL="#farley-testing"
# SLACK_CHANNEL="#monitoring"
SLACK_ICON="https://s3.amazonaws.com/kudelabs-archives/harddrive256.png"
@AndrewFarley
AndrewFarley / Gitlab Squasher
Created February 5, 2019 21:21
This simple Python code force squashes, if you call this via a webhook automatically via gitlab, then "magic" all merges will squash
import os
import flask
import requests
BASE_URL = 'https://YOURGITLABURL/api/v4'
TOKEN = 'YOURADMINAPITOKEN'
app = flask.Flask(__name__)
kubectl create clusterrolebinding cluster-admin-binding \
--clusterrole cluster-admin \
--user $(gcloud config get-value account)

Keybase proof

I hereby claim:

  • I am andrewfarley on github.
  • I am farleyfarley (https://keybase.io/farleyfarley) on keybase.
  • I have a public key ASBUtTMxseOpuT_0pnSQpvra0ZWIHVQCfJGLAOhx9Ns9xAo

To claim this, I am signing this object:

@AndrewFarley
AndrewFarley / gitlab-runner-aws-autoscaling-ec2-config.toml
Created October 19, 2020 05:40
Gitlab Runner - AWS EC2 Autoscaling Runners config.toml file
concurrent = 10
check_interval = 0
[session_server]
session_timeout = 1800
[[runners]]
name = "shared-autoscaling"
url = "https://gitlab.WEBSITE.com/"
token = "AUTO-INSERTED-FROM-REGISTER"