Skip to content

Instantly share code, notes, and snippets.

View frederickding's full-sized avatar

Frederick Ding frederickding

View GitHub Profile
@frederickding
frederickding / .bashrc
Created July 18, 2018 23:42
Share a ssh-agent between WSL bash instances, but kill it when the last instance closes
# add to .bashrc
# Set up ssh-agent
SSH_ENV="$HOME/.ssh/environment"
function start_ssh_agent {
echo "Initializing new SSH agent..."
touch $SSH_ENV
chmod 600 "${SSH_ENV}"
/usr/bin/ssh-agent | sed 's/^echo/#echo/' >> "${SSH_ENV}"
@frederickding
frederickding / veeam-tape-escpos-receipt.ps1
Created August 12, 2023 23:59
Veeam Tape Backup post-job receipt script for ESC/POS
Import-Module Veeam.Backup.PowerShell
$outputBuilder = New-Object System.Text.StringBuilder
[void]$outputBuilder.AppendLine('ESC "@"')
[void]$outputBuilder.AppendLine('ESC "2"')
$job = Get-VBRTapeJob -Name ExampleJobName
$lastjob = (Get-VBRTapeBackupSession -Job $job | Sort-Object EndTime | Select-Object -Last 1)
# get the tape name
$tape = (Get-VBRTapeMedium -MediaPool $job.Target | Sort-Object LastWriteTime | Select-Object -Last 1)
#!/usr/bin/env python3
from escpos import *
import argparse
import os
import sys
import datetime
cli_parser = argparse.ArgumentParser(description='Print to a network ESCPOS receipt printer.')
cli_parser.add_argument('file', help='text file to print')
cli_parser.add_argument('--printer', '-p', default="192.168.1.253", help='IP address or hostname of printer')
@frederickding
frederickding / find.sh
Created July 9, 2022 20:55
Find command for excluding annoying directories
#!/bin/sh
find /mnt/isos -type f -not \( -path '#recycle' -o -name '.DS_Store' -o -path '*@eaDir*' \) 2>/dev/null | sort
@frederickding
frederickding / traefik
Created July 10, 2021 21:32
Basic openrc init file for traefik (/etc/init.d/traefik)
#!/sbin/openrc-run
LOG_FILE=/var/log/traefik.log
name="traefik"
command="/usr/local/bin/traefik"
command_args=" --log"
pidfile="/run/${RC_SVCNAME}.pid"
output_log=${LOG_FILE}
error_log=${LOG_FILE}
@frederickding
frederickding / dm3-to-tif-png.ijm
Created July 27, 2012 19:02
ImageJ macro to convert DM3 digital micrograph files (e.g. transmission electron microscope) to TIF and PNG
/**
* ImageJ macro to convert DM3 digital micrograph files to TIF and PNG
*
* @author Frederick Ding
*/
/*
* Option switches
*
* debug: when set to true, some variables will be outputted to the log
@frederickding
frederickding / ibi-lite.txt
Created December 10, 2020 02:57 — forked from alanhuang122/ibi-lite.txt
Sample IBI Lite barcode translation
Sourced from https://patents.google.com/patent/US7882036B1
Field # Length Offset Name
1 1 0 Indicia Version Number
2 4 1 Piece Counter
3 1 5 IBI Vendor/Model
4 3 6 PSD Serial Number
5 3 9 Postage Value (in 1/10s of a cent)
6 2 12 Intelligent Mail Service
7 6 14 HMAC Message Digest
@frederickding
frederickding / gpg2-vmimage.sh
Last active February 13, 2020 17:49
gpg2-vmimage
#!/bin/bash
## Usage: gpg2-vmimage.sh FILENAME
##
## FILENAME can be:
## - a tar archive (in which case this script will apply zstd
## compression before encrypting & signing with GnuPG)
## - an already-compressed OVA file (in which case this script
## will not further compress)
##
## The output will be a .zstd.gpg or .gpg of the input file and
@frederickding
frederickding / local-storage-debug-script.js
Created November 30, 2018 17:22
local-storage-debug-script.js
Object.defineProperty(window, 'localStorage', {
configurable: true,
enumerable: true,
value: new Proxy(localStorage, {
set: function (ls, prop, value) {
console.log(`direct assignment: ${prop} = ${value}`);
debugger;
ls[prop] = value;
return true;
},
system type : UBNT_E300
machine : Unknown
processor : 0
cpu model : Cavium Octeon III V0.2 FPU V0.0
BogoMIPS : 2000.00
wait instruction : yes
microsecond timers : yes
tlb_entries : 256
extra interrupt vector : yes
hardware watchpoint : yes, count: 2, address/irw mask: [0x0ffc, 0x0ffb]