Skip to content

Instantly share code, notes, and snippets.

@Gronis
Gronis / Cargo.toml
Last active January 6, 2024 01:28
mkfont - A small cli utility app for converting png images to 1-bit per pixel binary representations. Typically used for pixel art fonts that need to embed graphics into the executable binary
[package]
name = "mkfont"
version = "0.1.0"
edition = "2021"
[dependencies]
minipng = "0.1.1"
@Gronis
Gronis / config
Last active October 23, 2024 17:40
hammerspoon application toggler
# .config/ghostty/config
theme = shades-of-purple
background = #1f1f1f
foreground = #ffffff
cursor-color = #ffffff
selection-foreground = #000000
selection-background = #eeeeee
bold-is-bright = true
@Gronis
Gronis / .zshrc
Last active January 15, 2024 09:22
fzf zsh history search ctrl-r
###########################################################################
# Put config here
###########################################################################
# alias ssh="kitty +kitten ssh"
alias ssh="TERM=xterm-256color ssh"
###########################################################################
@Gronis
Gronis / reboot-on-low-mem.sh
Created November 1, 2022 23:13
Reboot if system has less than 64MB of system memory left. Useful when running RAM filesystem and reboots can be used for cleanup. Put in cron
#!/usr/bin/env bash
bash -c "[ $(cat /proc/meminfo | grep MemAvailable | awk '{ printf("%d", $2 < 65536) }') == '1' ] && reboot"
@Gronis
Gronis / hdr10conversion.js
Last active January 29, 2024 17:10
This script takes a hdr10 video and returns a string for x265 encoder with the correct light levels.
#! /usr/bin/env node
// For info about hdr transcoding, go here:
// https://codecalamity.com/encoding-uhd-4k-hdr10-videos-with-ffmpeg/
//
// This script takes a hdr video and returns a string for x265 encoder with the correct light levels like this:
// "hdr-opt=1:repeat-headers=1:colorprim=bt2020:transfer=smpte2084:colormatrix=bt2020nc:master-display=G(13250,34500)B(7500,3000)R(34000,16000)WP(15635,16450)L(11000000,0):max-cll=0,0"
//
const proc = require('child_process');
@Gronis
Gronis / cleardockerlogs.sh
Created October 5, 2021 20:42
Docker shell scripts
#!/bin/bash
date "+%Y-%m-%d %H:%M:%S"
sudo sh -c 'truncate -s 0 $(docker system info 2> /dev/null | grep "Docker Root Dir" | cut -d ":" -f2 | cut -d " " -f2-)/containers/*/*-json.log';
@Gronis
Gronis / node_datachannel_wrtc.js
Created August 17, 2021 16:54
A (partially) wrtc compatible wrapper layer around node-datachannel so that node-datachannel can be used as wrtc backend for various webrtc libraries when running inside a nodejs environment.
import libdatachannel from 'node-datachannel';
const do_nothing = (..._) => { };
const decorate_channel = channel => {
Object.defineProperty(channel, "readyState", {
get: function () {
return channel.isOpen() ? 'open' : 'closed'
}
});
Object.defineProperty(channel, "label", {
@Gronis
Gronis / README.md
Last active October 5, 2021 23:15
Home assistant xmrig config

Control the number of mining cores on xmrig from home assistant. The script calls the http interface on xmrig and sets the number of cores used for mining with cn-pico algorithm. Feel free to edit to your usecase.

Put __init__.py file in <homeassistant_root>/custom_components/xmrig/__init__.py

Then add the following to your configuration.yaml

xmrig:
  host: <host>
 port: 
@Gronis
Gronis / Dockerfile
Last active September 1, 2021 11:50
Kryptokrona node on docker
FROM ubuntu as builder
ENV CC=gcc-8
ENV CXX=g++-8
RUN apt-get update && apt-get install -y \
software-properties-common &&\
add-apt-repository -y \
ppa:ubuntu-toolchain-r/test &&\
@Gronis
Gronis / get_mac_address
Last active June 20, 2020 18:30
Get the mac address for a certain host.
#!/bin/bash
#
# Get the mac address for a certain host.
#
# Requires ping and arp tool.
#
# Usage:
# get_mac_address HOSTNAME
#