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 / 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 / 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 / commands.sh
Last active May 29, 2021 15:04
Workaround for "gh delete" until #3625 is implemented
# From https://github.com/cli/cli/issues/3625
# one time:
$ gh alias set delete 'api -X DELETE repos/$1'
$ gh auth refresh -h github.com -s delete_repo
# usage (WARNING: no confirmation!)
$ gh delete user/myrepo
@jbfriedrich
jbfriedrich / init.lua
Created April 18, 2021 11:27
Hammerspoon configuration to replace the functionality of the now deprecated Mosaic app (used in tandem with Reactangle.app)
--------------------------------------------------------------------------------
-- Hammerspoon config to replace parts of Mosaic
--
-- References:
-- * https://www.hammerspoon.org/go/
-- * https://www.hammerspoon.org/docs/index.html
--------------------------------------------------------------------------------
hs.hotkey.bind({"cmd", "alt", "ctrl"}, "n", function()
@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;
}
@jbfriedrich
jbfriedrich / writeas_fastodon.css
Created May 3, 2020 06:44
WriteAS Fastodon Theme CSS
/* Fosstodon Hub theme written by Kev Quirk (https://kevq.uk) and released under the GPL v3 license (https://www.gnu.org/licenses/gpl-3.0.en.html). */
/* Import required font */
@import url('https://fonts.googleapis.com/css?family=Open+Sans:300,400,700&display=swap');
@import url('https://cdnjs.cloudflare.com/ajax/libs/prism/1.19.0/themes/prism-tomorrow.min.css');
/* Load PrismJS scripts and CSS */
/* Create colour variables to be used throughout the theme (makes colours easier to change globally). */