Skip to content

Instantly share code, notes, and snippets.

Avatar

Farley Farley (yes, really) AndrewFarley

  • New Plymouth, New Zealand
View GitHub Profile
View AWS-MFA-Complete.json
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowListUsersAllIfMFA",
"Effect": "Allow",
"Action": [
"iam:ListUsers",
"iam:ListPolicies",
"iam:ListGroups",
@AndrewFarley
AndrewFarley / delete-github-actions-old-workflows.py
Created Jun 26, 2021
Github Actions API Python script to delete workflows of a specific type
View delete-github-actions-old-workflows.py
#!/usr/bin/env python3
from ghapi.all import GhApi
import time
import json
api = GhApi()
# If you have rate limit issues, you might need this to check it...
#data = api.rate_limit.get()
#print(data)
#exit(0)
@AndrewFarley
AndrewFarley / multiregional-aws-terraform-providers.tf
Last active Jun 15, 2021
A file useful for CloudTrail or Guardduty to be able to iterate on all the AWS Regions easily
View multiregional-aws-terraform-providers.tf
# List of all (public) AWS regions as of Jun 15, 2021
locals {
aws_regions_list = [
"ap-northeast-1",
"ap-northeast-2",
"ap-northeast-3",
"ap-south-1",
"ap-southeast-1",
"ap-southeast-2",
"ca-central-1",
@AndrewFarley
AndrewFarley / gitlab-runner-userdata.sh
Created Oct 19, 2020
Gitlab Runner ec2 autoscaling userdata - auto-renew ecr credentials/access
View gitlab-runner-userdata.sh
#!/bin/bash
apt update -y && apt install awscli make joe -y
mkdir -p ~/.aws/
cat > ~/.aws/config <<EOL
[default]
region = us-east-2
aws_access_key_id = TODOTODO
aws_secret_access_key = TODOTODO
EOL
aws ecr get-login --region us-east-2 | sed 's/-e none//' | bash
@AndrewFarley
AndrewFarley / gitlab-runner-aws-autoscaling-ec2-config.toml
Created Oct 19, 2020
Gitlab Runner - AWS EC2 Autoscaling Runners config.toml file
View gitlab-runner-aws-autoscaling-ec2-config.toml
concurrent = 10
check_interval = 0
[session_server]
session_timeout = 1800
[[runners]]
name = "shared-autoscaling"
url = "https://gitlab.WEBSITE.com/"
token = "AUTO-INSERTED-FROM-REGISTER"
View keybase.md

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:

View gist:1448f3f30e579f65f87d362a4808c92a
kubectl create clusterrolebinding cluster-admin-binding \
--clusterrole cluster-admin \
--user $(gcloud config get-value account)
@AndrewFarley
AndrewFarley / Gitlab Squasher
Created Feb 5, 2019
This simple Python code force squashes, if you call this via a webhook automatically via gitlab, then "magic" all merges will squash
View Gitlab Squasher
import os
import flask
import requests
BASE_URL = 'https://YOURGITLABURL/api/v4'
TOKEN = 'YOURADMINAPITOKEN'
app = flask.Flask(__name__)
@AndrewFarley
AndrewFarley / backup-gitlab-to-s3.sh
Created Sep 5, 2018
A Shell Script to Backup Gitlab to S3 (with slack notifications)
View backup-gitlab-to-s3.sh
#!/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"
View TestPasswordHashingInPython.py
import bcrypt
import hashlib
import time
import random
import string
from datetime import datetime, date
print("100 iterations of hashing")
print("=========================")