Skip to content

Instantly share code, notes, and snippets.

@gregjhogan
gregjhogan / macos-proxy.sh
Created November 14, 2017 18:36
proxy settings for macOS
#!/bin/bash
PROXY_STATE=${1:-on}
PROXY_HOST=<host>
PROXY_PORT=<port>
#export HTTP_PROXY=http://$PROXY_HOST:$PROXY_PORT
#export HTTPS_PROXY=$HTTP_PROXY
@gregjhogan
gregjhogan / macos-port-forward.sh
Last active October 12, 2022 07:19
local port forwarding on macOS
#!/bin/bash
ifconfig lo0 alias 127.0.1.1
ifconfig lo0 alias 127.0.10.1
# clear rules
pfctl -F all -f /etc/pf.conf
# set rules
echo "
@gregjhogan
gregjhogan / .bash_profile
Last active March 4, 2018 21:10
macOS bash shell profile
[ -f /usr/local/etc/bash_completion ] && . /usr/local/etc/bash_completion
GIT_PS1_SHOWDIRTYSTATE=true
PS1='\[\033[1;32m\]\u \[\033[0;36m\]\w\[\033[1;33m\]$(__git_ps1)\n\[\033[0m\]$ '
export CLICOLOR=1
export GREP_OPTIONS="--color=auto"
export GREP_COLOR="1;32"
alias ls='ls -GFh'
eval "$(pyenv init -)"
@gregjhogan
gregjhogan / python-setup.sh
Created December 14, 2017 14:03
python setup
sudo apt-get -y install python python-setuptools
sudo easy_install pip
@gregjhogan
gregjhogan / cabana-fingerprint.js
Created December 19, 2017 17:50
cabana fingerprint
const fs = require('fs');
const content = fs.readFileSync('./data.csv', 'utf8');
const messages = content
.split('\n')
.map(line => line.trim())
.filter(line => line.length > 0 && line !== 'time,addr,bus,data')
.map(line => line.split(','))
.map(msg => ({
addr: parseInt(msg[1]),
@gregjhogan
gregjhogan / cabana-panda-replay-log.py
Last active March 4, 2018 18:09
replay a cabana log through a panda
#!/usr/bin/env python
import sys
import time
import struct
from panda import Panda
DEBUG = False
def main():
logfile = sys.argv[1]
@gregjhogan
gregjhogan / grey-panda-nmea-server.py
Created April 9, 2018 06:52
Run a GNSS NMEA TCP/IP server for mocking your location on an Android device (with RTK support)
#!/usr/bin/env python
# plug in grey panda
# open Lefebure NTRIP Client android app
# configure it:
# - Receiver Settings -> External via TCP/IP (enter the IP of the machine running this script and port 3001)
# - Receiver Settings -> GPS Mock Locations (check checkbox)
# - NTRIP Settings -> Caster IP/Port/Username Password for your local RTK network
# - NTRIP Settings -> Data Stream needs to be an RTCM3 source
# go into android developer settings and select the Lefebure NTRIP Client app to use for mock locations
@gregjhogan
gregjhogan / date-from-epoc-input.sh
Created April 22, 2018 00:13
bash date from epoc in local timezone
TZ=America/Los_Angeles date -d @1524291778
@gregjhogan
gregjhogan / setup-virtualbox.sh
Created April 22, 2018 23:12
ubuntu virtualbox install
sudo apt install virtualbox virtualbox-ext-pack
@gregjhogan
gregjhogan / chage-user-id-and-group-id.sh
Created April 23, 2018 23:20
change user's user ID and group ID
#!/bin/bash
set -e
LOGIN=<USER>
NEWUID=<NEWUID>
NEWGID=<NEWGID>
OLDUID=<OLDUID>
OLDGID=<OLDGID>
usermod -u $NEWUID $LOGIN