Skip to content

Instantly share code, notes, and snippets.

Avatar

Ben Yanke benyanke

View GitHub Profile
@benyanke
benyanke / feastday-ps1.sh
Created Sep 6, 2020
Provides the feast day in your bashrc
View feastday-ps1.sh
function feast() {
tmp="`mktemp`"
export date="`date +"%Y-%m-%d"`"
timeout 1 curl https://www.missalemeum.com/en/api/v3/date/$date 2> /dev/null > $tmp
export title="`cat $tmp | jq -r .[].info.title`"
export tempora="`cat $tmp | jq -r .[].info.tempora`"
export rank="`cat $tmp | jq -r .[].info.rank`"
@benyanke
benyanke / mikrotik-dhcp-dns-script
Created Jun 16, 2019
Mikrotik DHCP-to-DNS Script
View mikrotik-dhcp-dns-script
# NOT fully complete with all the desired features but it does work
# Suggested usage - place in the system scheduler and run every few minutes
# Set root domain here
:local zone "your.internal.domain.com";
:local ttl "00:00:10"
:local staticTtl "00:00:30"
# TODO : add "nodns" check in static lease comment
@benyanke
benyanke / .bashrc 6-8-2019
Created Jun 9, 2019 — forked from ageis/.bashrc 02-25-2020
@ageis's ~/.bashrc 🖥️ with numerous useful functions, aliases and one-liners. ⚠️ NOTE: many paths in sourced scripts and environment variables are specific to my system, but if you dig in I hope you'll find something you can use!
View .bashrc 6-8-2019
#!/bin/bash
#~/.bashrc: executed by bash(1) for non-login shells.
# kevin gallagher (@ageis) <kevingallagher@gmail.com>
export MYUID=$(id -u)
export USER="$(id -un)"
if [[ "$TILIX_ID" ]] || [[ "$VTE_VERSION" ]]; then
source /etc/profile.d/vte.sh
fi
View raspi watchdog
sudo apt-get install watchdog
sudo echo bcm2708_wdog >> /etc/modules
sudo cp /etc/watchdog.conf /etc/watchdog.conf.orig
sudo sed -i 's/^#max-load/max-load/' /etc/watchdog.conf
sudo reboot
@benyanke
benyanke / Elastic Beanstalk Drop All Tables
Created Feb 15, 2019
This drops all the tables in elastic beanstalk
View Elastic Beanstalk Drop All Tables
echo "SET FOREIGN_KEY_CHECKS = 0; `mysqldump --add-drop-table --no-data -h $RDS_HOSTNAME -u $RDS_USERNAME -p$RDS_PASSWORD $RDS_DB_NAME | grep 'DROP TABLE'` ;SET FOREIGN_KEY_CHECKS = 1;" | mysql -h $RDS_HOSTNAME -u $RDS_USERNAME -p$RDS_PASSWORD $RDS_DB_NAME
View Add to bottom of bashrc
##############################
# Load the serial console on shell open
##############################
echo ""
echo ""
echo ""
echo "######################"
echo "Loading serial console... press ctrl+c to drop to bash instead"
@benyanke
benyanke / gsysmon - POC
Created Jul 20, 2018
Proof of concept for a system stats monitor
View gsysmon - POC
package main
import (
"fmt"
"github.com/shirou/gopsutil/cpu"
"github.com/shirou/gopsutil/host"
"github.com/shirou/gopsutil/load"
"github.com/shirou/gopsutil/mem"
)
View restoreBackup.sh
#!/bin/bash
# Run this script with sudo
[ `whoami` = root ] || { echo "Need to run as root"; exit 1; }
# Update config here and run the script - example values used below
export PASSPHRASE="12345678901234567890"
@benyanke
benyanke / Client Script
Last active Jul 4, 2018
SSH Reverse Tunnel Configuration
View Client Script
#!/usr/bin/env bash
# run me in cron every minute and on boot
ssh revtun@[host] -i [keypath] -R 8202:localhost:22 -N -f
View log output
Creating nextcloudtmp_redis_nc_1 ... done
Creating nextcloudtmp_nextcloud-db_1 ... done
Creating nextcloudtmp_nextcloud-db_1 ...
Creating nextcloudtmp_nextcloud_1 ... done
Attaching to nextcloudtmp_nextcloud-db_1, nextcloudtmp_redis_nc_1, nextcloudtmp_nextcloud_1
nextcloud-db_1 | Initializing database
nextcloud-db_1 | 2018-06-14 21:51:15 0 [Warning] InnoDB: Failed to set O_DIRECT on file./ibdata1;CREATE: Invalid argument, ccontinuing anyway. O_DIRECT is known to result in 'Invalid argument' on Linux on tmpfs, see MySQL Bug#26662.
nextcloud-db_1 | 2018-06-14 21:51:15 0 [ERROR] InnoDB: preallocating 50331648 bytes for file ./ib_logfile1 failed with error 28
nextcloud-db_1 | 2018-06-14 21:51:15 0 [ERROR] InnoDB: Cannot set log file ./ib_logfile1 size to 50331648 bytes
You can’t perform that action at this time.