Skip to content

Instantly share code, notes, and snippets.

View trwatson's full-sized avatar

Troy Watson trwatson

  • Silicon Slopes
View GitHub Profile
@trwatson
trwatson / rasbian_gpg_fix.sh
Last active November 30, 2019 02:18
Raspbian GPG Key Fix
gpg --keyserver keyserver.ubuntu.com --recv-keys 7638D0442B90D010 8B48AD6246925553
gpg --armor --export 7638D0442B90D010 | apt-key add -
gpg --armor --export 8B48AD6246925553 | apt-key add -
@trwatson
trwatson / lcd_test.py
Last active April 24, 2019 21:02
adafruit lcd testing with ip for raspberry pi
#apt-get install -y i2c-tools python-smbus vim
#pip3 install --upgrade setuptools
#pip3 install RPI.GPIO adafruit-blinka adafruit-circuitpython-charlcd netifaces
import board
import digitalio
import busio
import os
import socket
import adafruit_character_lcd.character_lcd_rgb_i2c as character_lcd
import netifaces as ni
@trwatson
trwatson / dlthing.sh
Created July 27, 2018 17:58
Thingiverse Thing Downloader for Linux
#!/bin/bash
thingid=${1}
descr=$(curl -s https://www.thingiverse.com/thing:${thingid} | grep -A1 "dc:title" | tail -n1 | tr -s " " | sed 's/<\/span>//g' | tr -cd 'A-Za-z0-9_-')
zipURL="https://www.thingiverse.com/thing:${thingid}/zip"
dlDir="$(dirname "$0")/thing_files"
mkdir -p ${dlDir}/${descr}
echo "Writing file: ${dlDir}/${descr}/${descr}.zip"
curl -sL ${zipURL} -o ${dlDir}/${descr}/${descr}.zip
cd ${dlDir}/${descr}/
unzip ${descr}.zip && rm -f ${descr}.zip
@trwatson
trwatson / repetier_eeprom.gcode
Created May 5, 2018 21:09
Repetier Eeprom Setting Change
;how to update an eeprom setting on repetier
;get list of settings:
M205
;example line:
;Recv: EPR:3 145 210.000 X max length [mm]
;Update position 145 with 230.0
M206 T3 P145 X230.0
;save configuration
M500
@trwatson
trwatson / fixUbuntuColors.sh
Last active November 22, 2017 19:06
Replace Ubuntu Color with Blue
#!/bin/bash
#run as root
fileList=$(grep -nir "f07746" /usr/ | awk -F: '{print $1}' | sort -u)
for file in "$fileList";
do
sed -i 's/f07746/023c88/g' $file;
sed -i 's/F07746/023c88/g' $file;
done
@trwatson
trwatson / restart_zabbix_agent_linux.sh
Created October 4, 2017 20:11
Zabbix Agent Restart via zabbix_get
#!/bin/bash
agentAddr="$1"
#use zabbix server address here if you're not in aws using an ENI
eniAddr=10.10.10.5
sanityCheck=$(zabbix_get -s ${agentAddr} -k system.run["service zabbix-agent status"] -I ${eniAddr} 2>&1)
isSane=$(echo "$sanityCheck" | grep ZBX_NOTSUPPORTED | wc -l)
if [ $isSane -lt 1 ]
then
agentRestart=$(zabbix_get -s ${agentAddr} -k system.run["service zabbix-agent restart",nowait] -I ${eniAddr} && sleep 2)
isRunning=$(zabbix_get -s ${agentAddr} -k system.run["service zabbix-agent status"] -I ${eniAddr} 2>/dev/null)
@trwatson
trwatson / check_connection.sh
Last active April 3, 2017 01:43
checks if it can connect to the internet - restarts router if fails - XyXEL CenturyLink Router Restart
#!/bin/bash
check_connection(){
checkMyIP=''
checkGoogle=''
checkMyIP=$(curl -s icanhazip.com | egrep [0-9] | head -n1 | wc -l)
checkGoogle=$(curl -s google.com | grep HEAD | head -n1 | wc -l)
internetHealth=$(echo $checkMyIP+$checkGoogle|bc)
printf "$internetHealth"
}
timestamp() {
@trwatson
trwatson / myBashTemplate.sh
Last active September 29, 2017 20:16
Some bash conventions as an example
#!/bin/bash
##################################################################################
## A NOTE ABOUT YOUR SCRIPT ##
##################################################################################
VARIABLE="MyString123"
FILE_NAME="${VARIABLE}.txt"
EMPTY_ARRAY=()
COMMAND_OUTPUT=$(echo $VARIABLE) #MyString123
BACK_TRIMMED_VARIABLE=${VARIABLE::(-1)}; #MyString12
FRONT_TRIMMED_VARIABLE=${VARIABLE:(1)}; #yString123
#!/bin/bash
if [ -a /Applications/YakYak.app/Contents/Info.plist ]
then
YAK_INSTALLED=1
YAK_CUR_VERS=$(cat /Applications/YakYak.app/Contents/Info.plist | grep -A1 CFBundleVersion | grep '<string' | cut -f2 -d">"|cut -f1 -d"<" | tr -d '.')
else
YAK_INSTALLED=0
YAK_CUR_VERS=0
fi
YAK_STABLE_VERS=$(curl -sL https://github.com/yakyak/yakyak/releases/latest | grep -we "yakyak/yakyak/releases/download/.*/yakyak-osx.app.zip" | awk -F'\/' '{print $6}' | tr -d '.' | tr -d 'v')