Skip to content

Instantly share code, notes, and snippets.

View BinaryShrub's full-sized avatar

Justin BinaryShrub

  • California, US
View GitHub Profile
@BinaryShrub
BinaryShrub / logger.ts
Last active August 21, 2023 20:43
Winston with console.log and colors support with util.format
import winston from 'winston';
import util from 'util';
const utilFormat = (enableColor: boolean) => {
const printFormat = winston.format.printf(({ level, message, timestamp }) => `${timestamp} ${level}: ${message}`);
const format = winston.format.combine(winston.format.timestamp({ format: 'YYYY-MM-DD HH:mm:ss.SSS' }), {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
transform: (info: any) => {
const args = info[Symbol.for('splat')] || [];
info.message = util.formatWithOptions({ colors: enableColor }, info.message, ...args);
@BinaryShrub
BinaryShrub / README.md
Last active January 11, 2021 18:22
Plant UML Theme

To use this theme, add !include right after @startuml

@startuml
!include https://gist.githubusercontent.com/BinaryShrub/f60cd9e5a9658ae5b0f53b69969ac577/raw/6003ccc69dfffbe66f8984614bfedaa1e0e1507d/theme.puml

.
.
.
@BinaryShrub
BinaryShrub / initramfs-unlocker.sh
Last active May 29, 2020 04:32
LUKS remote decrypt (dropbear) for Ubuntu 16.04.1 on btrfs array
#!/bin/bash
## LUKS remote decrypt for Ubuntu 16.04.1 - by BinaryShrub
# NOTES:
# Tailor lines 67 - 69 to your system before running!
# Use at your own risk!
# Safety Check
if [ "$EUID" -ne 0 ]
then echo "You must run this as root"
@BinaryShrub
BinaryShrub / index.js
Last active May 10, 2020 02:22
Alexa, play white noise
/**
* Alexa Skill Lambda Function that will play an audio file
* on loop, indefinitely - no libraries required! 🎉
*/
const debug = false
exports.handler = async(event) => {
const session = { event, response: error() }
@BinaryShrub
BinaryShrub / dnd.sh
Created March 20, 2020 04:29
macOS Mojave script that automates Do No Disturb and Badge app icons in the Dock 🎉
#!/bin/bash
# run 'dnd' to enable Do Not Disturb and disable all Badge app icons in the Dock
# run 'dnd off' to disable Do Not Disturb and enable all Badge app icons in the Dock
dnd () {
local ENABLE
local ENABLE_NUM
local ENABLE_STRING_NEG
case "$1" in
off)