Skip to content

Instantly share code, notes, and snippets.

@ianhomer
ianhomer / fitbit-weight-to-csv.sh
Last active March 20, 2018 21:37
convert-fitbit-weight-json-to-csv
# Download fitbit weight as JSON and put in weight.json
# Download it by accessing page in the web https://www.fitbit.com/weight?end-date=2018-03-20&period=all&start-date=2018-02-20
# and then find the content in the web traffic. Note that the API restricts to 30 days.
cat fitbit-weight.json | python -m json.tool | grep 'dateTime\|weight' | awk 'ORS=/,$/?" ":"\n"' | awk '{print $1 $4}' > weight.csv
# Then you can import this into where ever you want ...
#!/bin/bash
# Set static routing tables to route some external IP addresses to a different gateway, for example if tend
# to connect on a VPN and you want to route some traffic to avoid the VPN.
#
# I use this on a Mac - if you're lucky it might work on other operating systems. This script does update
# your /etc/hosts files AND route table. Take appropriate due care.
#
# Usage
# -----
@ianhomer
ianhomer / Clear disk space
Last active October 16, 2015 08:38
Diskspace
# If syslog is big then you can rotate log and then clear up
savelog -g adm -m 640 -u root -c 7 /var/log/syslog
#!/bin/bash
# Set static routing tables to route some external IP addresses
# direct instead of via VPN
action=${1:-create}
gateway=${2:-192.168.1.254}
nonVpnHosts=${3:-$NON_VPN_HOSTS}
if [ -z "$nonVpnHosts" ] ; then
@ianhomer
ianhomer / curl-ipv4.sh
Last active March 22, 2025 06:45
Force CURL to use ipv4
# curl not smart enough for ipv6, so force ipv4
# on my mac I started to get localhost connect failure
#
# curl: (7) Failed to connect to localhost port 9031: Connection refused
echo '--ipv4' >> ~/.curlrc
@ianhomer
ianhomer / ldap-continue-after-error
Created May 8, 2015 12:50
LDAP Add continue after error
# -c => Continue after error
ldapadd -c -x -W -D "cn=admin,dc=id,dc=sdl,dc=com" -f id_test_data.ldif
@ianhomer
ianhomer / find-needle-in-haystack.sh
Last active August 29, 2015 13:59
Find text in files in folder (recursively)
ack needle
@ianhomer
ianhomer / report-jar-implementations.sh
Last active August 29, 2015 13:57
List implementation details (including version) from jar manifests (ONE LINE)
find . -name "*.jar" -exec unzip -p {} META-INF/MANIFEST.MF \; | grep Implementation
# Add to /etc/bashrc to customise command prompt
[ "$PS1" = "\\s-\\v\\\$ " ] && PS1="(production) - \u@\[\e[1;31m\]myhost.com\[\e[0m\]:\w \\$ "