Skip to content

Instantly share code, notes, and snippets.

View te-online's full-sized avatar

Thomas Ebert te-online

View GitHub Profile
@te-online
te-online / howto.md
Created February 25, 2016 14:55
svg-sprites

SVG Spritesheets

  1. Illustrator export with presentation attributes.
  2. SVGO the single files.
  3. svg-sprite --symbol svg/*.svg --dest=out # where the single files are in svg/ and output will be in out/
  4. Use jade: svg use(xlink:href="#id_of_symbol")
scp -rp sourcedirectory user@dest:/path
from http://serverfault.com/questions/264595/can-scp-copy-directories
@te-online
te-online / imapsync.sh
Created March 12, 2016 13:30
Moving mailboxes.
echo -n "Enter FROM hostname: "
read HOST1
echo -n "Enter FROM user: "
read USER1
echo -n "Enter FROM password: "
read -s PASS1
echo -n "Enter TO hostname: "
@te-online
te-online / Delete Backups.au3
Created April 4, 2016 07:51 — forked from numeralnathan/Delete Backups.au3
An AutoIt script to delete Windows Backups when disk space falls below threshold
#include <AutoItConstants.au3>
#include <MsgBoxConstants.au3>
; This is where the backups are stored
Global Const $BACKUP_DIR = "G:\NREYNOLD-LAP"
$free = DriveSpaceFree($BACKUP_DIR)
; Don't delete backups if more than 60 GB is available (i.e. enough for another new backup directory to be created)
if $free > 60 * 1024 then
@te-online
te-online / smartd-telegram-notify.md
Last active January 4, 2024 15:27
How to make smartmontools send errors to you via Telegram messenger.

###Step by step

Installing smartmontools

  1. Install smartmontools with sudo apt-get install smartmontools

Create your new bot

  1. Create a new telegram bot via the botfather (see https://core.telegram.org/bots#3-how-do-i-create-a-bot). You will need the token of the bot from botfather.
  2. Initiate a chat with your new bot.
  3. Send a GET to https://api.telegram.org/bot{YOUR_TOKEN}/getUpdates.
@te-online
te-online / telegram-notify.sh
Last active December 5, 2022 11:58
A shell file that takes a message to send with a telegram bot (e.g. a system notification).
#!/bin/bash -e
chatid="CHAT_ID"
message=$1
apikey="BOT_TOKEN"
curl -G --data-urlencode "chat_id=${chatid}" --data-urlencode "text=${message}" --data-urlencode "parse_mode=Markdown" https://api.telegram.org/bot${apikey}/sendMessage
# Usage: sh telegram-notify.sh "Message"
@te-online
te-online / critical-diskspace-notify.sh
Last active December 5, 2022 11:58
A shell file that uses telegram-notify.sh to send a Telegram message via a bot when the diskspace gets to a critical level.
#!/bin/bash
CURRENT_ROOT=$(df / | grep / | awk '{ print $5}' | sed 's/%//g')
CURRENT_BACKUP=$(df /dev/sda | grep / | awk '{ print $5}' | sed 's/%//g')
THRESHOLD_ROOT=85
THRESHOLD_BACKUP=75
MESSAGE_ROOT="My root disk's remaining free space is critically low. 🙈
*Used: ${CURRENT_ROOT}%.*"
MESSAGE_BACKUP="My backup disk's remaining free space is critically low. 🙈
*Used: ${CURRENT_BACKUP}%.*"
@te-online
te-online / check-diskspace-notify.sh
Created April 23, 2016 21:35
A shell file that uses telegram-notify.sh to send a Telegram message via a bot when you check it.
#!/bin/bash
CURRENT_ROOT=$(df / | grep / | awk '{ print $5}' | sed 's/%//g')
CURRENT_BACKUP=$(df /dev/sda | grep / | awk '{ print $5}' | sed 's/%//g')
MESSAGE="Just had a look at the space of my disks 🔬.
My *root disk's* remaining free space is *${CURRENT_ROOT}%*.
My *backup disk's* remaining free space is *${CURRENT_BACKUP}%*."
sh telegram-notify.sh "${MESSAGE}"
@te-online
te-online / functions.php
Created April 27, 2016 21:19
Add this to functions.php if you want to disable login for users when moving servers or doing maintenance.
<?php
if(is_admin()) {
wp_die('Sorry, the WordPress interface is currently not available. This website is moving to another server just now. Please come back later.');
}
?>