Skip to content

Instantly share code, notes, and snippets.

# Thanks to this post:
# http://blog.ikato.com/post/15675823000/how-to-install-consolas-font-on-mac-os-x
which cabextract>/dev/null || which brew>/dev/null || { echo Please install Homebrew!; exit 1; }
install() {
local url=https://sourceforge.net/projects/mscorefonts2/files/cabs/PowerPointViewer.exe
which cabextract>/dev/null || brew install cabextract
mkdir -P ~/tmp/consolas \
&& pushd ~/tmp/consolals \
&& curl -LO "${url}" \
@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 / ProxyTest.java
Last active June 16, 2022 19:07
java.lang.reflect.Proxy over Annotation
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.HashMap;
import java.util.Map;
import org.junit.Assert;
import org.junit.Test;
@nathansgreen
nathansgreen / AccessLogValve.java
Last active July 23, 2021 23:05
Send Embedded Tomcat Access Logs to Application Logger
@lombok.extern.log4j.Log4j2
public class AccessLogValve extends
org.apache.catalina.valves.AbstractAccessLogValve {
@Override
protected void log(java.io.CharArrayWriter message) {
log.info(message.toString());
}
}
@nathansgreen
nathansgreen / renew.udhcp.sh
Created May 19, 2020 21:48
Renew DHCP lease on Alpine Linux (using udhcp as the client)
#!/usr/bin/env sh
pkill -USR1 udhcpc
@nathansgreen
nathansgreen / README.md
Last active May 19, 2020 21:23
USG Disable DNS over HTTPS on local LAN with dnsmasq

I wanted a way to disable DNS over HTTPS so I can control DNS activity on my local network. I also block unauthorized outbound DNS requests with firewall rules.

The biggest limitation of this approach is the need to put all forwarding options in the config. Leaving out options, especially the 'server=' can break DNS on your whole network, so be careful. SSH into your USG and run mca-ctrl -t dump-cfg to find your current options and use them to replace the values in the file here.

I recommend running cat /etc/dnsmasq.conf before and after applying this config to see if you are missing things you need.

@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 / 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"
]