Skip to content

Instantly share code, notes, and snippets.

View jbfriedrich's full-sized avatar
👨‍💻
Learning more Python 🐍

Jason Friedrich jbfriedrich

👨‍💻
Learning more Python 🐍
View GitHub Profile
@jbfriedrich
jbfriedrich / nsmb.conf
Last active April 25, 2024 14:58
macOS 11.2 NSMB configuration
# /etc/nsmb.conf - macOS 11.3 - 2021-04-29
#------------------------------------------------------------------------------
# SMB configuration for macOS 11.3 <-> Synology
#------------------------------------------------------------------------------
# Additional information:
# -----------------------
# https://support.apple.com/de-de/HT211927
# https://support.apple.com/en-us/HT208209
# https://apple.stackexchange.com/questions/309016/smb-share-deadlocks-since-high-sierra
# https://photographylife.com/afp-vs-nfs-vs-smb-performance
@jbfriedrich
jbfriedrich / do_firewall.sh
Last active January 7, 2024 22:52
DigitalOcean Firewall Scripts
#!/bin/bash
################################################################################
# DigitalOcean Droplet Firewall Script
#===============================================================================
# This Firewall script is supposed to be used with DigitalOcean Droplets. It
# uses eth0 as external, and eth1 (if present) as internal network interface.
# It automatically detects IP addresses and blocks all traffic but SSH from a
# list of safe IP addresses.
# Two white lists can be defined, one for internal IPv4 IP addresses and one
# for public IPv4 addresses.
@jbfriedrich
jbfriedrich / esxi_firewall.sh
Last active January 7, 2024 22:51
IPtables firewall on a router virtual machine running on a remote VMware ESXi host (it ran on Hetzner in this example). It requires a separate subnet, a dedicated vm router IP address and only supports IPv4.
#!/bin/bash
################################################################################
# 2014-08-03 | Jason Friedrich
#-------------------------------------------------------------------------------
# Version history:
# v1.2 | 2022-06-27
# - Partial rewrite for net network structure
# v1.1 | 2014-08-03
# - Complete rewrite for new network structure
################################################################################
@jbfriedrich
jbfriedrich / pickpocket.py
Created June 26, 2023 21:56
Delete entries from your pocket list that are older than a day
#!/usr/bin/env python
# pocket-appi module, not pocket
from pocket import Pocket, PocketException
import datetime as dt
p = Pocket(
consumer_key='myconsumerkey',
access_token='myaccesstoken'
)
@jbfriedrich
jbfriedrich / connect_vusb0.sh
Last active February 19, 2023 21:14
Check if vusb0 NIC link is up and add it to vDS uplink port group (based on script from https://labs.vmware.com/flings/usb-network-native-driver-for-esxi that only supports vSS)
# Add contents to /etc/rc.local.d/local.sh
vds_name="vDS"
vds_uplink_pg="dvportgroup-82"
free_vds_uplink_port=$(esxcli network vswitch dvs vmware list | grep -A 2 "DVPortgroup ID: $vds_uplink_pg" | grep -A 1 'In Use: false' | grep 'Port ID' | awk '{print $NF}' | head -1)
vusb0_status=$(esxcli network nic get -n vusb0 | grep 'Link Status' | awk '{print $NF}')
count=0
while [[ $count -lt 20 && "${vusb0_status}" != "Up" ]] ]
do
sleep 10
count=$(( $count + 1 ))
@jbfriedrich
jbfriedrich / detox.py
Created April 18, 2022 16:10
Remove unsafe and unwanted character from Audible flac/mp3 export
#!/usr/bin/env python3
import os
import re
def replace(basepath, item):
"""
Replace unsafe character from items
"""
@jbfriedrich
jbfriedrich / pagination.html
Created April 15, 2022 19:06
Hugo Template Snippet - Pagination
{{ $pag := $.Paginator }} {{ if gt $pag.TotalPages 1 }} {{ $.Scratch.Set "dot_rendered" false }}
<ul class="pagination">
<!-- Disable on 1st and 2nd page -->
{{ if and (ne $pag.PageNumber 1) (ne $pag.PageNumber 2) }}
<li class="page-item page-first"><a href="{{ $pag.First.URL }}" rel="first" class="page-link">« First</a></li>
{{ else }}
<li class="page-item page-first disabled"><a href="" rel="first" class="page-link">« First</a></li>
{{ end }} {{ if $pag.HasPrev }}
<li class="page-item page-prev"><a href="{{ $pag.Prev.URL }}" rel="prev" class="page-link">‹ Prev</a></li>
@jbfriedrich
jbfriedrich / menu.html
Created January 5, 2022 05:16
Hugo Template - List All Menu Entries
<!-- Loop through the navigation items -->
{{ $currentPage := . }}
{{ $menuitems := (.Site.Menus.main) }}
{{ $len := (len $menuitems) }}
{{ range $index, $element := $menuitems }}
{{ $id := .Identifier }}
<li class="header-nav-item">
<a class="header-nav-entry{{if or ($currentPage.IsMenuCurrent "main" .) ($currentPage.HasMenuCurrent "main" .) }} active{{end}}" title="{{ .Name }}" href="{{ .URL }}">
<span class="header-nav-entry-icon">{{ .Pre }}</span>
@jbfriedrich
jbfriedrich / list.html
Last active January 5, 2022 05:00
Hugo Template - List All Regular Pages
{{/* This can be used to loop through all regular pages on the whole site. */}}
{{ $pages := .Paginate ( where .Site.RegularPages "Type" "in" site.Params.mainSections ) }}
{{ range $pages.Pages }}
<article class="post type-{{ .Section }}">
{{ if eq .Section "posts" }}
<a class="post-full-link" href="{{ .RelPermalink }}">
<h4 class="post-date">{{ .Page.Date.Format "2 Jan 2006, 15:04 MST" }}</h4>
<h1 class="post-title">{{ .Title }}</h1>
<div class="post-summary">
@jbfriedrich
jbfriedrich / writeas.css
Last active December 18, 2021 03:17
Write.as CSS for micro.jason.re
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans:ital,wght@0,400;0,700;1,400&display=swap');
@import url("https://cdn.jsdelivr.net/npm/bootstrap-icons@1.5.0/font/bootstrap-icons.css");
#post .alert,
#post article,
body#collection article,
body#subpage #wrapper h1,
body#subpage article, pre {
max-width: 45rem;
}