Skip to content

Instantly share code, notes, and snippets.

@twaddington
twaddington / nut.conf
Last active April 22, 2024 06:30
Network UPS Tools (NUT) on Debian
MODE=standalone
@twaddington
twaddington / charles-proxy-android.md
Last active April 20, 2024 17:26
How to set up Charles Proxy for the Android Emulator.

Charles Proxy Android

Note: Consider using mitmproxy instead of Charles. There is better, more recent, documentation for using mitmproxy on Android.

Steps

1. Add the Network Security Configuration to your app

@twaddington
twaddington / UserAgentInterceptor.java
Created October 12, 2017 02:17
Injects a User-Agent header into outgoing OkHttp requests.
package com.enlighthq.mobile.http;
import android.os.Build;
import java.io.IOException;
import java.util.Locale;
import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;
@twaddington
twaddington / gist:67eba3288b092960106126081782fd82
Created July 18, 2022 21:45
Publish a Maven dependency (e.g. aar) to your local maven repo

Publish a Maven dependency (e.g. aar) to your local maven repo

$ mvn install:install-file \
    -Dfile=/path/to/file.aar \
    -DpomFile=/path/to/file.pom

// If you don't have a valid pom
$ mvn install:install-file \
 -Dfile=/path/to/file.aar \
@twaddington
twaddington / android-gradle-github-mvn.md
Last active July 18, 2022 21:42
Publishing a package from a file to a private GitHub Maven repository

Publishing a package from a file to a private GitHub Maven repository

Add your credentials to ~/.m2/settings.xml

Where token is your personal access token.

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
@twaddington
twaddington / AppleVolumes.default
Created July 22, 2011 02:20
Netatalk Time Machine Config
# This line goes in /etc/netatalk/afpd.conf
- -tcp -noddp -uamlist uams_guest.so,uams_dhx.so,uams_dhx2.so -nosavepassword
# The remaining lines go in /etc/netatalk/AppleVolumes.default
# The line below sets some DEFAULT, starting with Netatalk 2.1.
:DEFAULT: options:upriv,usedots
# Regular AFP share
/mnt/storage "Storage" cnidscheme:dbd options:usedots,upriv
@twaddington
twaddington / gist:6ba44e4f8d74f40ab0d973e1af040d9b
Last active June 22, 2022 06:06
mitmproxy with Java and OkHttp

Add cert to Java keystore

sudo keytool -import -trustcacerts -cacerts -storepass changeit -alias mitmproxycert -file ~/.mitmproxy/mitmproxy-ca-cert.pem

Configure OkHttp

@twaddington
twaddington / gist:a6ffbeba9c964aff0257643b3f593c06
Created March 2, 2022 00:22
WeatherFlow Tempest UDP Monitoring
sudo tcpdump -i eth0 -s 0 udp port 50222 -A -v
https://weatherflow.github.io/Tempest/api/udp.html
@twaddington
twaddington / LICENSE
Last active February 2, 2022 03:57
This code demonstrates a method of signing OkHttp requests with an OAuth access token. An Authenticator is provided to renew an expired token using a refresh token.
Copyright (C) 2017 Tristan Waddington <tristan.waddington@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
// List all security providers
for (Provider p : Security.getProviders()) {
Log.d(TAG, String.format("== %s ==", p.getName()));
for (Provider.Service s : p.getServices()) {
Log.d(TAG, String.format("- %s", s.getAlgorithm()));
}
}