Skip to content

Instantly share code, notes, and snippets.

@jftuga
jftuga / rows_cols.go
Created March 13, 2019 00:13
two dimensional slice in Go
package main
import (
"fmt"
"os"
"strconv"
)
@jftuga
jftuga / add.reg
Last active March 16, 2019 01:38
Add command to Windows context menu
Windows Registry Editor Version 5.00
; https://www.reddit.com/r/PowerShell/comments/b1ew3f/is_there_a_way_to_create_an_explorer_shell/?
[HKEY_CLASSES_ROOT\.rmt]
[HKEY_CLASSES_ROOT\.rmt\shell]
[HKEY_CLASSES_ROOT\.rmt\shell\Posted]
@jftuga
jftuga / getDNSInfo.go
Created August 6, 2019 10:33
getDNSInfo.go
// +build windows
package main
import (
"bytes"
"fmt"
"syscall"
"unsafe"
)
@jftuga
jftuga / getNames.bat
Created December 31, 2019 15:00
Quick jq example
@echo off
rem use -r to return strings without surrounding double-quotes
jq -r ".Buckets | .[] | .Name" s3.json
@jftuga
jftuga / go-aws-new.go
Created January 12, 2020 05:00
Fixed version of go-aws-new.go
package main
import (
"fmt"
"log"
"time"
awsNews "github.com/circa10a/go-aws-news"
)
func main() {
@jftuga
jftuga / make_backup.sh
Last active May 19, 2020 17:21
Raspberry Pi backup script
#!/bin/bash
# Side note:
# for better performance append to /etc/sysctl.conf (and then reboot)
# vm.vfs_cache_pressure = 50
# vm.swappiness = 10
# vm.dirty_writeback_centisecs = 1500
# location of backups
BASE="/data/backups"
@jftuga
jftuga / create_scheduled_task.ps1
Created July 17, 2020 11:43
How to create a Scheduled Task with PowerShell
# This task will run once per day at 9AM, only on week days
$A = New-ScheduledTaskAction -Execute "c:\scripts\my_project\scheduled_task.bat" -WorkingDirectory "c:\scripts\my_project"
$T = New-ScheduledTaskTrigger -At 9am -Weekly -DaysofWeek Monday,Tuesday,Wednesday,Thursday,Friday
$P = New-ScheduledTaskPrincipal -UserId "LOCALSERVICE" -LogonType ServiceAccount
$S = New-ScheduledTaskSettingsSet
$D = New-ScheduledTask -Action $A -Principal $P -Trigger $T -Settings $S
Register-ScheduledTask "My Project" -InputObject $D
@jftuga
jftuga / ec2info.bat
Last active July 19, 2020 14:03
ec2info: retrieve all EC2 instance type info such as vCPU, clock speed, memory, network
@echo off
setlocal
rem ec2info.bat
rem -John Taylor
rem Jul-19-2020
rem Retrieve all EC2 instance type info such as vCPU, clock speed, memory, network
rem Save results to a tab separated file, named 'ec2_types.tsv'
rem Note: the 'RAM in GB' column is rounded to the nearest whole number
#!/bin/bash
# ec2info.sh
# -John Taylor
# Aug-03-2020
# Retrieve EC2 instance type info such as vCPU, clock speed, memory, network
# This queries your default AWS region
# Results are saved to the user-defined file name: $TSV and also to the MacOS clipboard
# Note: the 'RAM in GB' column is rounded to the nearest whole number
@jftuga
jftuga / update_pihole_block_lists.sh
Created August 15, 2020 11:40
Update block lists in a dockerized version of PiHole
#!/bin/bash
# Update block lists in a dockerized version of PiHole
# the log file should be: update_pihole_block_lists.log
#
# run this script from cron each Saturday morning with this contab entry:
# 00 3 * * 6 /root/update_pihole_block_lists.sh
IMAGE=pihole
LENGTH=12