Skip to content

Instantly share code, notes, and snippets.

View AndreasGrip's full-sized avatar

AndreasGrip

View GitHub Profile
@AndreasGrip
AndreasGrip / Tibber.json
Created January 10, 2023 09:35
Home Assistant Node js. Get priceses from tibber, and calculate when it's cheapest based on hours it takes.
[
{
"id": "f5409b74bf753a05",
"type": "tab",
"label": "Tibber",
"disabled": false,
"info": "",
"env": []
},
{
@AndreasGrip
AndreasGrip / UbuntuServerReclaimSpace.sh
Last active June 2, 2022 08:50
Ubuntu reclaim space. (needed on free aws servers)
#!/bin/sh
echo df -h before run
df -h
# Remove old versions of snap no longer used
set -eu
snap list --all | awk '/disabled/{print $1, $3}' |
while read snapname revision; do
#echo "$snapname" "$revision"
@AndreasGrip
AndreasGrip / removeOldSnapVersions.sh
Last active June 2, 2022 08:51
Remove old unused versions of snap. To be used on AWS servers as lack of space can be a big problem as AWS snap crap chews up alot
#!/bin/sh
set -eu
snap list --all | awk '/disabled/{print $1, $3}' |
while read snapname revision; do
#echo "$snapname" "$revision"
snap remove "$snapname" --revision="$revision"
done
@AndreasGrip
AndreasGrip / mysqldump.sh
Created January 12, 2022 07:35
Dump/backup mysql database.
#!/bin/sh
#"password" should be replaced with your password
#"database1" and "database2" should be replaced with the names of your databases.
TIMESTAMP=$(date +%Y-%m-%d_%H%M%S)
mysqldump -u root -ppassword database1 | gzip > database1_$TIMESTAMP.dump.sql.gz
mysqldump -u root -ppassword database2 | gzip > database2_$TIMESTAMP.dump.sql.gz
#!/bin/bash
inputPeriod=$1
runCommand=$2
RUN_TIME=60
RUN_TIME_LEFT=1
error="no"
SECONDS=0
if [ 'x'"$runCommand" != 'x' ]