Skip to content

Instantly share code, notes, and snippets.

View shanehull's full-sized avatar
🙃

Shane Hull shanehull

🙃
View GitHub Profile
-- **User command to insert a decision template at the current line** --
vim.api.nvim_create_user_command("Decision", function()
local template = [[
**Mental/physical state:**
- [ ] Energized
- [ ] Focused
- [ ] Relaxed
- [ ] Confident
- [ ] Tired
@shanehull
shanehull / zettelkasten.lua
Last active April 10, 2024 11:25
NeoVim Zettelkasten Command
-- Command to create a new zettelkasten style note in 0-inbox of your second brain
vim.api.nvim_create_user_command("Zet", function()
local directory = os.getenv("SECOND_BRAIN") .. "/0-inbox" or os.getenv("HOME") .. "secondbrain/0-inbox/"
-- Get the file name from the user
local status, result = pcall(function()
Fname = vim.fn.input("File name: ", "", "file")
end)
-- Handle error (e.g. keyboard interrupt)
if not status then
@shanehull
shanehull / routerbackup.rsc
Created November 18, 2018 22:56
Script to backup Mikrotik config to disk, upload via FTP and ping healthchecks.io url.
# Settings
:local backupPath path/to/mikrotik.backup
:local healthchecksURL https://hc-ping.com/example
:local ftpAddress 192.168.1.10
:local ftpFullPath path/to/ftpserver/mikrotik.backup
:local ftpUser ftpuser
:local ftpPassword password
# Check if router can ping WAN
if ([/ping 8.8.8.8 count=5]=5) do={
@shanehull
shanehull / rotate-backup.sh
Last active November 26, 2018 01:57
Check if specified file exists and was created on current date. If so, copy specified file and append date to the copy, then delete files matching "$FILE*" older than retention period.
#!/bin/bash
FILE="/source/"
HEALTHCHECKSURL=""
RETENTION=10
FILEAGE=1
#### Display command usage ########
usage()
{
cat << EOF
@shanehull
shanehull / chromecastreboot.py
Created September 12, 2017 01:02
Script to reboot all Chromecasts on 172.16.31.1
import requests
payload = {"params": "now"}
while True:
for ip in range (1, 255):
try:
print("working on 172.16.31.{}".format(ip))
response = requests.post("http://172.16.31.{}:8008/setup/reboot".format(ip), json=payload, timeout=1.0)
import requests
payload = {"settings":{"control_notifications":2}}
while True:
for ip in range (1, 255):
try:
print("working on 172.16.31.{}".format(ip))
response = requests.post("http://172.16.31.{}:8008/setup/set_eureka_info".format(ip), json=payload, timeout=1.0)