Skip to content

Instantly share code, notes, and snippets.

@nathansgreen
nathansgreen / usg-commands.md
Last active November 6, 2022 00:17
USG CLI commands

Ubiquit Security Gateway CLI Commands

Random commands I've used for various things.

mca-ctrl -t dump-cfg

renew dhcp interface eth0

show interfaces

@nathansgreen
nathansgreen / README.md
Last active May 15, 2020 04:50
UniFi Reserved IP for Access Point using DHCP

Read the last paragraph if you want a simpler solution.

The current (May 2020) controller interface doesn't give you a clear ability to reserve IP addresses for wireless access points. Instead it gives you the option of statically entering all of the information. You can use the customization features of config.gateway.json to do what the GUI does not let you do.

To figure out your network name, you'll probably want to ssh into your USG and then get your shared-network-name by running the following command: mca-ctrl -t dump-cfg. Once you have a network name and its associated subnet, you can enter in the static

@nathansgreen
nathansgreen / find_iphone_uuid.sh
Created April 24, 2020 16:22
Find iPhone device UUID/UDID
#!/usr/bin/env sh
system_profiler SPUSBDataType 2>/dev/null \
| sed -n '/iPhone/,/Serial/p' \
| grep "Serial Number:" \
| awk -F ": " '{print substr($2,1,8)"-"substr($2,9,24)}'
@nathansgreen
nathansgreen / setup-unifi-macos.sh
Last active August 23, 2022 12:07
UniFi Network Controller Setup for MacOS
#!/bin/sh
# https://community.ui.com/questions/Unifi-Controller-5-11-50-on-Mac-OS-X-Catalina-fails-to-start-/2fde6f63-b0ac-43a0-83f7-5cf43ba3d40f?page=2
brew cask install homebrew/cask-versions/adoptopenjdk8
brew cask install ubiquiti-unifi-controller
export CLASSPATH=/Applications/UniFi.app/Contents/Java/*
cd /Applications/UniFi.app/Contents/Resources
java com.ubnt.ace.Launcher start &
@nathansgreen
nathansgreen / perl-recent-version-compat.patch
Last active October 30, 2019 15:25 — forked from xywei/patch.txt
A patch for automake to compile it with later versions of Perl
Allow recent versions of Perl to compile automake.
For Yocto. Tested on poky (krogoth branch).
From https://gist.github.com/xywei/03b546054f0d2e2f76c5ac530c88268a
--- a/bin/automake.in 2015-01-06 03:25:55.000000000 +0800
+++ b/bin/automake.in 2017-07-26 13:58:07.086205701 +0800
@@ -3878,7 +3878,7 @@
sub substitute_ac_subst_variables
{
my ($text) = @_;
@nathansgreen
nathansgreen / jq-examples.md
Last active October 26, 2018 16:10
Stuff I've had to do with jq

Simple things to do using jq

# turn a delimted string into an array:
echo '"2368;3924"' | jq 'split(";")
[
  "2368",
  "3924"
]
@nathansgreen
nathansgreen / array_position.sql
Created January 5, 2018 16:57
PostgreSQL <9.5 array_position function
-- The array_position function was added in Postgres 9.5.
-- For older versions, you can get the same behavior with this function.
create function array_position(arr ANYARRAY, elem ANYELEMENT, pos INTEGER default 1) returns INTEGER
language sql
as $BODY$
select row_number::INTEGER
from (
select unnest, row_number() over ()
from ( select unnest(arr) ) t0
) t1
@nathansgreen
nathansgreen / cloud-init.sh
Created December 6, 2017 15:44 — forked from ambakshi/cloud-init.sh
Amazon Linux cloud-init script
#!/bin/bash
#
# Amazon Linux cloud-init script
#
# Amit Bakshi
# 10/2014
#
if [ `id -u` -ne 0 ]; then
sudo exec /bin/bash -x "$0" "$@"
fi
@nathansgreen
nathansgreen / postgresql-debugger-install-macos
Last active January 18, 2023 04:04 — forked from jhngrant/postgresql-debugger-install-ubuntu
Installing the PL/pgSQL Debugger Extension (pldbgapi) for pgAdmin III on PostgreSQL 9.4 and MacOS
# First install database
brew install postgres
# Clone and build the PL/pgSQL server-side debugger
srcdir=/usr/local/src
[ -e "$scrdir" ] || \
sudo sh -c "mkdir $srcdir && chgrp admin $srcdir && chmod g+w $srcdir"
cd "$srcdir"
@nathansgreen
nathansgreen / eb_iname.sh
Created November 16, 2016 15:41
AWS ElasticBeanstalk Instance Name
#!/usr/bin/bash
export INSTANCE_ID=$(curl http://169.254.169.254/latest/meta-data/instance-id)
export INSTANCE_NAME=$( ec2-describe-instances ${INSTANCE_ID} |grep -E "^TAG.+" |cut -f 4,5 |grep -E "^Name" |cut -f 2 )