Skip to content

Instantly share code, notes, and snippets.

Avatar
👨‍💻
Learning more Python 🐍

Jason Friedrich jbfriedrich

👨‍💻
Learning more Python 🐍
View GitHub Profile
@jbfriedrich
jbfriedrich / detox.py
Created Apr 18, 2022
Remove unsafe and unwanted character from Audible flac/mp3 export
View detox.py
#!/usr/bin/env python3
import os
import re
def replace(basepath, item):
"""
Replace unsafe character from items
"""
@jbfriedrich
jbfriedrich / pagination.html
Created Apr 15, 2022
Hugo Template Snippet - Pagination
View pagination.html
{{ $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 Jan 5, 2022
Hugo Template - List All Menu Entries
View menu.html
<!-- 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 Jan 5, 2022
Hugo Template - List All Regular Pages
View list.html
{{/* 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 / entitlements.xml
Created Jun 21, 2021
Replace certs on Slack.app to allow use of OBS VirtualCam
View entitlements.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.cs.disable-library-validation</key>
<true/>
</dict>
</plist>
@jbfriedrich
jbfriedrich / commands.sh
Last active May 29, 2021
Workaround for "gh delete" until #3625 is implemented
View commands.sh
# 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 Apr 18, 2021
Hammerspoon configuration to replace the functionality of the now deprecated Mosaic app (used in tandem with Reactangle.app)
View init.lua
--------------------------------------------------------------------------------
-- 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 Dec 18, 2021
Write.as CSS for micro.jason.re
View writeas.css
@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
WriteAS Fastodon Theme CSS
View writeas_fastodon.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). */
@jbfriedrich
jbfriedrich / templatize_ubuntu1804.sh
Created Jan 19, 2020
Script to "sanitize" a Ubuntu VM to turn it into a template.
View templatize_ubuntu1804.sh
#!/bin/bash
# Configure Package Repos
cat <<EOF >/etc/apt/sources.list
deb http://archive.ubuntu.com/ubuntu bionic main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu bionic main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu bionic-updates main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu bionic-updates main restricted universe multiverse