Skip to content

Instantly share code, notes, and snippets.

View stevenharradine's full-sized avatar

Steven Harradine stevenharradine

View GitHub Profile
@stevenharradine
stevenharradine / roots crontjob
Created February 27, 2020 18:59
Update on boot cronjob
@reboot PATH=/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin && /usr/bin/apt update > /tmp/update.log && /usr/bin/apt -y upgrade >> /tmp/update.log
@stevenharradine
stevenharradine / first access to mariadb-mysql
Created November 14, 2018 17:29
first access to mariadb/mysql
Sorry dont have a name to give credit too but sourced from: https://askubuntu.com/questions/766334/cant-login-as-mysql-user-root-from-normal-user-account-in-ubuntu-16-04/801950
I recently upgrade my Ubuntu 15.04 to 16.04 and this has worked for me:
First, connect in sudo mysql
sudo mysql -u root
Check your accounts present in your db
@stevenharradine
stevenharradine / sync-pihole.sh
Created August 14, 2018 05:54
synchronises an adhole server with others via ssh
#!/bin/bash
settingsHash=`cat /etc/pihole/blacklist.txt /etc/pihole/whitelist.txt | md5sum`
if [ "$settingsHash" == "`cat /home/pi/current-pihole-settings.md5`" ]; then
echo "nothing to see"
else
echo "it changed"
cat /etc/pihole/blacklist.txt /etc/pihole/whitelist.txt | md5sum > current-pihole-settings.md5
scp /etc/pihole/blacklist.txt /etc/pihole/whitelist.txt [email protected]:~/
ssh [email protected] "sudo mv blacklist.txt whitelist.txt /etc/pihole/ && sudo service pihole-FTL restart"
fi
#!/bin/bash
7za a -tzip -pMY_SECRET -mem=AES256 secure.zip doc.pdf doc2.pdf doc3.pdf
@stevenharradine
stevenharradine / fix-steam.sh
Created December 6, 2017 02:44
This script fixes steam so it can start up on ubuntu 16.04
#!/bin/bash
# This script fixes steam so it can start up on ubuntu 16.04
# Source: https://bbs.archlinux.org/viewtopic.php?id=193802 on 20171206 @ 02:43 UTC
rm ~/.local/share/Steam/ubuntu12_32/steam-runtime/amd64/installed/libstdc++6-4.6-pic_4.6.3-1ubuntu5+srt4_amd64
rm ~/.local/share/Steam/ubuntu12_32/steam-runtime/amd64/installed/libstdc++6-4.6-pic_4.6.3-1ubuntu5+srt4_amd64.md5
rm ~/.local/share/Steam/ubuntu12_32/steam-runtime/amd64/installed/libstdc++6_4.8.1-2ubuntu1~12.04+steamrt2+srt1_amd64
rm ~/.local/share/Steam/ubuntu12_32/steam-runtime/amd64/installed/libstdc++6_4.8.1-2ubuntu1~12.04+steamrt2+srt1_amd64.md5
rm ~/.local/share/Steam/ubuntu12_32/steam-runtime/amd64/usr/lib/gcc/x86_64-linux-gnu/4.6/libstdc++_pic.a
rm ~/.local/share/Steam/ubuntu12_32/steam-runtime/amd64/usr/lib/gcc/x86_64-linux-gnu/4.6/libstdc++_pic.map
rm ~/.local/share/Steam/ubuntu12_32/steam-runtime/amd64/usr/lib/x86_64-linux-gnu/libstdc++.so.6
Format/result Command Output
YYYY-MM-DD_hh:mm:ss date +%F_%T 2017-10-16_21:47:43
YYYYMMDD_hhmmss date +%Y%m%d_%H%M%S 20171016_214743
YYYYMMDD_hhmmss (UTC version) date --utc +%Y%m%d_%H%M%SZ 20171016_124743Z
YYYYMMDD_hhmmss (with local TZ) date +%Y%m%d_%H%M%S%Z 20171016_214743JST
YYYYMMSShhmmss date +%Y%m%d%H%M%S 20171016214743
YYYYMMSShhmmssnnnnnnnnn date +%Y%m%d%H%M%S%N 20171016214743670195402
YYMMDD_hhmmss date +%y%m%d_%H%M%S 171016_214743
Seconds since UNIX epoch: date +%s 1508158063
@stevenharradine
stevenharradine / best-camera.sh
Last active June 11, 2017 21:04
Make default camera /dev/video0 point to the "best" camera present.
#!/bin/bash
# Make default camera /dev/video0 point to the "best" camera present.
# Source: https://askubuntu.com/questions/396952/how-to-change-the-default-webcam-changing-dfaults-in-multimedia-selctor-not-wor
# Date: 20170611@21:02UTC
# By: Jason Eisner (https://github.com/jeisner)
if [ -h /dev/video0 ]; then
sudo rm /dev/video0 # not first run: remove our old symlink
elif [ -e /dev/video0 ]; then
sudo mv /dev/video0 /dev/video0.original # first run: rename original video0
@stevenharradine
stevenharradine / Headless OSMC set up.md
Last active September 5, 2017 16:22
To set up an autoplaying headless media center

Headless OSMC set up

To set up an autoplaying headless media center

Requirements

  • Raspberry Pi
  • monitor/keyboard for setup

Steps

  1. Download OSMC (https://osmc.tv/download/)
  2. Flash it to SD card
@stevenharradine
stevenharradine / send-disk-usage-to-slack.sh
Last active April 24, 2017 19:57
send disk usage to slack
slacktoken="TOKEN/TOKEN/TOKEN"
slackchannel="#welcome"
hostname=`cat /etc/hostname`
diskspace=`/bin/df -h | /usr/bin/xargs -L 1 /bin/echo "\n"`
curl -X POST --data-urlencode 'payload={"channel": "$slackchannel", "username": "webhookbot", "text": "'"$hostname""\n""$diskspace"'", "icon_emoji": ":ghost:"}' https://hooks.slack.com/services/$slacktoken
@stevenharradine
stevenharradine / node-tls-detect.js
Last active September 11, 2015 14:01 — forked from tg-x/node-tls-detect.js
TLS detection for node.js
/*
* Autodetect if SSL/TLS is used by having a look at the first incoming bytes
* This technique is from http://webview.jabberd.org/cgi-bin/viewvc.cgi/trunk/jadc2s/clients.cc?view=markup
*
* used heuristic:
* - an incoming connection using SSLv3/TLSv1 records should start with 0x16
* - an incoming connection using SSLv2 records should start with the record size
* and as the first record should not be very big we can expect 0x80 or 0x00 (the MSB is a flag)
* - everything else is considered to be unencrypted
*/