Skip to content

Instantly share code, notes, and snippets.

@gregjhogan
gregjhogan / tensor-flow-gpu-cpu-compare.py
Last active June 8, 2018 06:24
tensor flow gpu vs cpu
# docker run -runtime=nvidia --rm -ti -v "${PWD}:/app" tensorflow/tensorflow:latest-gpu python /app/test.py gpu 10000
import sys
import numpy as np
import tensorflow as tf
from datetime import datetime
device_name = sys.argv[1] # Choose device from cmd line. Options: gpu or cpu
shape = (int(sys.argv[2]), int(sys.argv[2]))
if device_name == "gpu":
@gregjhogan
gregjhogan / tc-limit-bandwidth
Created May 17, 2018 22:10
tc traffic shaping (limit bandwidth)
# setup
sudo tc qdisc add dev $1 root tbf rate 1.0mbit latency 50ms burst 50kb mtu 10000
# remove
sudo tc qdisc del dev $1 root
ps -ef | grep <filter-here> | grep -v grep | awk '{print $2}' | xargs kill -9
@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
@gregjhogan
gregjhogan / setup-virtualbox.sh
Created April 22, 2018 23:12
ubuntu virtualbox install
sudo apt install virtualbox virtualbox-ext-pack
@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 / 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 / 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 / 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 / python-setup.sh
Created December 14, 2017 14:03
python setup
sudo apt-get -y install python python-setuptools
sudo easy_install pip