Skip to content

Instantly share code, notes, and snippets.

View cam8001's full-sized avatar
💭
lol no

Cameron Tod cam8001

💭
lol no
  • Amazon Web Services
  • Wellington, New Zealand
  • 01:25 (UTC +12:00)
View GitHub Profile
@cam8001
cam8001 / go_lean.sh
Last active January 10, 2022 04:50
Disable all the stuff we don't need on a MyBookLive.
#!/bin/bash
# See http://mybookworld.wikidot.com/forum/t-583096
# See http://tech.roxee.tv/2012/06/12/solving-the-my-book-live-insane-load/
# http://community.wd.com/t5/My-Book-Live-Duo/New-MyBook-Duo-4Tb-astonishingly-slow-I-mean-really-soul/td-p/417642/page/5
# Disable all this stuff, but also make miocrawler drops its logs.
# vi /etc/rsyslog.d/miocrawler.conf
# [root@storagecasa rsyslog.d]# cat miocrawler.conf
@cam8001
cam8001 / dynamic_vhosts_ubuntu_17.04.md
Last active October 12, 2021 12:44
Set up dnsmasq for dynamic hosts on your local machine.

DNS

Install dnsmasq:

$ sudo apt-get install dnsmasq

Edit /etc/dnsmasq.conf to resolve all domains ending in ".lh" to your own machine:

@cam8001
cam8001 / userdata.sh
Created October 1, 2021 09:41
Unifi controller on Ubuntu 20.04 arm64 - AWS userdata
echo -e "Running custom Unifi userdata"
AWS_DEFAULT_REGION=ap-southeast-2
# Assoicate an elastic IP
ALLOC_ID=eipalloc-deadbeef
# Set timezone
ln -fs /usr/share/zoneinfo/Pacific/Auckland /etc/localtime
apt-key adv --keyserver keyserver.ubuntu.com --recv 06E85760C0A52C50
@cam8001
cam8001 / userdata.sh
Created October 1, 2021 09:38
Associate Elastic IP on every boot even with custom AMI (eg for autoscaling)
Content-Type: multipart/mixed; boundary="//"
MIME-Version: 1.0
--//
Content-Type: text/cloud-config; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="cloud-config.txt"
#cloud-config
@cam8001
cam8001 / userdata.sh
Last active June 26, 2021 00:06
Userdata to install Unifi Network (unifi controller) on Ubuntu 20.04 when launching an x86 instance on AWS
#!/bin/bash
# Associate this EIP on launch.
ALLOC_ID=eipalloc-0d896138148fed55c
AWS_DEFAULT_REGION=ap-southeast-2
echo "Updating packages..."
# Force grub to update in a silent mode
DEBIAN_FRONTEND=noninteractive apt-get -y -o DPkg::options::="--force-confdef" -o DPkg::options::="--force-confold" -qq --allow-remove-essential --allow-change-held-packages upgrade
# Update packages.
sudo apt-get upgrade -y
@cam8001
cam8001 / userdata.sh
Created September 30, 2020 21:33
AWS EC2 userdata for Unifi Controller on Ubuntu 16.04. Assumes Correto is installed and Ubiqiuiti repo is added
#!/bin/bash
echo "Updating Unifi..."
systemctl stop unifi
apt update
# Disable interactive prompts for the unifi installer
echo "unifi unifi/has_backup boolean true" | debconf-set-selections
DEBIAN_FRONTEND=noninteractive apt-get install --only-upgrade unifi
# Update the Unifi config for a system using Amazon Corretto instead of OpenJDK
curl https://gist.githubusercontent.com/cam8001/585bc721b25c80e185b83269fdb62e4a/raw/de847624ee14b89814c8c759e2559d7871d6c4ce/correto_unifi.sh > /usr/lib/unifi/bin/unifi.init
@cam8001
cam8001 / ssm-document.yml
Created June 25, 2021 10:51
SSM Run Command Document for syncing a folder to s3
---
schemaVersion: '2.2'
description: State Manager Bootstrap Example
parameters: {}
mainSteps:
- action: aws:runShellScript
name: backupUnifi
inputs:
runCommand:
- aws s3 --region ap-southeast-2 sync <your-folder> s3://<your-bucket>
@cam8001
cam8001 / package.json
Last active April 17, 2021 00:25
tsconfig.json for lambda with typescript
{
"name": "my-lambda-function",
"version": "1.0.0",
"scripts": {
"build": "tsc && npm run copy-config",
"copy-config": "cp -r configuration/* build/",
"release": "npm run build",
},
"dependencies": {
"aws-lambda": "^1.0.6",
@cam8001
cam8001 / curl-tricks.md
Created November 4, 2020 03:49
Test Cloudfront node performance

Find an IP for a local Cloudfront node.

$ dig example.com

Use a DNS server in the country you are targeting to get an IP for a Cloudfront node there. Eg, for Australia, you can check this list: https://public-dns.info/nameserver/au.html

$ dig example.com @168.1.79.229

Use a combination of:

@cam8001
cam8001 / lg-soundbar-network.md
Last active March 21, 2021 07:14
Trying to figure out what a weird device on my network was - turns out it was my FIL's LG soundbar

Trying to figure out what this thing is:

$ nmap -A -T4 -Pn 10.99.98.97 2>/dev/null                                                  

Starting Nmap 7.60 ( https://nmap.org ) at 2020-10-07 16:34 NZDT
Nmap scan report for 10.99.98.97
Host is up (0.0038s latency).
Not shown: 997 filtered ports
PORT      STATE SERVICE         VERSION
8008/tcp  open  http            Google Chromecast httpd