Skip to content

Instantly share code, notes, and snippets.

View luckman212's full-sized avatar

Luke Hamburg luckman212

View GitHub Profile
@luckman212
luckman212 / Tags to YAML.md
Created April 17, 2021 13:07
Obsidian Templater script to fetch tags and format them as YAML frontmatter
<%*
  var yaml = '';
  var tArr = tp.file.tags;
  tArr.sort();
  var tStr = tArr.join(', ').replace(/#/g,'');
  if (tStr.length) {
    yaml = '---\ntags: [' + tStr + ']\n---\n';
  }
%&gt;&lt;%* tR += yaml %&gt;
@luckman212
luckman212 / Insert current search as a markdown link.js
Last active April 8, 2022 15:17
Templater: Insert current search as a markdown link
@luckman212
luckman212 / obsidian_link.sh
Last active November 4, 2024 23:40
URL-encode Obsidian links - meant to be used with Service Station, Alfred etc.
'use strict';
var obsidian = require('obsidian');
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
@luckman212
luckman212 / wgfix.sh
Last active October 3, 2022 21:02
poor man's fail back for wireguard tunnels on pfSense 2.5/2.6 (deprecated: use v2: https://github.com/luckman212/wgfix)
#!/bin/sh
# put the line below at the end of /etc/rc.gatway_alarm, just above the final `exit`:
# /root/wgfix.sh "${GW}" "${alarm_flag}"
# set the 2 variables below to match the interface name and public key
# of the wg tunnel that you want to "fail back" when your default gateway changes
# WG_PEER_PUBLIC_KEY should be the public key from the FAR side (i.e the one from the PEERS tab)
WG_IFNAME='tun_wg0'
WG_PEER_PUBLIC_KEY='Vh+y3uVDnbmJtL7O4tgjaInRmerV3dWq/dM8LeSqbFY='
/*
THIS IS A GENERATED/BUNDLED FILE BY ROLLUP
if you want to view the source visit the plugins github repository
*/
'use strict';
var obsidian = require('obsidian');
/*! *****************************************************************************
@luckman212
luckman212 / ptest.sh
Last active February 15, 2022 12:09
simple shell script to test system patches at the console
#!/bin/sh
c='https://github.com/pfsense/pfsense/commit'
retval=0
if [ "$1" = "-r" ]; then
verb='reverted'
shift
else
verb='applied'

git rebase method

  1. Note the commit hash of your current state

    $ git log -1 --oneline
    5b0ab1a (HEAD -> add-regex-matching, origin/add-regex-matching) don't strip .md from filepath
  2. Squash (merge) the last 2 commits

@luckman212
luckman212 / brew-recent.sh
Last active December 23, 2021 03:23
Find recently updated Homebrew formulae
#!/usr/bin/env bash
# https://apple.stackexchange.com/questions/304345/show-installation-date-of-packages-installed-with-homebrew/432218#432218
# https://apple.stackexchange.com/questions/373442/how-to-generate-list-of-homebrew-formulas-packages-sorted-by-most-recently-upda/
#default timeframe
tf=1d
case $1 in
-h|--help) echo "usage: ${0##*/} [time] e.g. 90m, 1h, 3d (default: $tf)"; exit;;
@luckman212
luckman212 / float2.lua
Created December 14, 2021 15:06
Hammerspoon module for draggable live updating floating preview windows
--[[ Live-updating floating previews
https://www.hammerspoon.org/docs/hs.window.html
https://www.hammerspoon.org/docs/hs.canvas.html
https://www.hammerspoon.org/docs/hs.image.html
https://www.hammerspoon.org/docs/hs.mouse.html
https://www.hammerspoon.org/docs/hs.timer.html
https://www.lua.org/manual/5.4/manual.html#6.2 (coroutines)
https://github.com/Hammerspoon/hammerspoon/issues/2710#issuecomment-788266990 (thanks @asmagill)