Skip to content

Instantly share code, notes, and snippets.

View Informatic's full-sized avatar
🤔
excuse me, is this facebook

Piotr Dobrowolski Informatic

🤔
excuse me, is this facebook
View GitHub Profile
@Informatic
Informatic / network.nix
Created January 20, 2019 21:32
NixOS OVH IP Failover virtual machine configuration
{
# [...]
# Assuming failover IP being 1.2.3.4 and host primary IP being 5.6.7.8
networking.interfaces.ens3.ipv4.addresses = [ {
address = "1.2.3.4";
prefixLength = 32;
} ];
networking.interfaces.ens3.ipv4.routes = [ {
address = "5.6.7.254";
@Informatic
Informatic / janus.py
Last active March 24, 2019 08:34
Minimal janus-gateway REST API python client
# Reference:
# https://janus.conf.meetecho.com/docs/rest.html
# https://janus.conf.meetecho.com/docs/streaming.html
import requests
import json
import pprint
import random
import string
{ stdenv, fetchurl, patchelf, makeWrapper, xorg, gcc, gcc-unwrapped, freetype, fontconfig, liberation_ttf }:
stdenv.mkDerivation rec {
name = "IPMIView-${version}";
version = "2.16.0";
buildVersion = "190528";
src = fetchurl {
url = "https://www.supermicro.com/wftp/utility/IPMIView/Linux/IPMIView_${version}_build.${buildVersion}_bundleJRE_Linux_x64.tar.gz";
sha256 = "0pz4q8vsnv6wqpiy6am333c2cgsdjmxc6w9vm4hi8qyaavfbq0w2";
@Informatic
Informatic / tagify-cookbook
Created August 5, 2019 13:18
Quickly add git version tags for specified chef cookbook (could easily be adapted to any other piece of infrastructure, eg. npm package.json file, as long as one is able to extract unique version identifier on specified git ref)
#!/usr/bin/env bash
# Creates local version tags based on cookbook metadata.rb change history
# Usage: bash tagify-cookbook [cookbook_name]
cookbook=${1:-some_cookbook}
git log --pretty=format:"%h" cookbooks/$cookbook/metadata.rb | while read ref; do
tag="$cookbook-$(git show $ref:cookbooks/$cookbook/metadata.rb | grep "^version '" | sed -E "s/.* '(.*)'/\1/g" )"
echo "ref: $ref -> $tag";
@Informatic
Informatic / gziplogging.py
Last active October 23, 2020 10:24
python logging rotating gzipping handler
#
# A quick tip on how to set up rotating logging handler with
# automatic gzipping of rotated files. Tested on python 3.7
#
#
# Testing tip:
# python gziplogging.py
# touch example.log --date='2005/01/01'
# python gziplogging.py
# ls -lah *.log*
@Informatic
Informatic / README.md
Last active May 28, 2024 22:22
openlgtv webOS hacking notes

This is just a dump of some interesting undocumented features of webOS (3.8 specifically, on early 2018 4k LG TV) and other development-related tips.

Homebrew app ideas

@Informatic
Informatic / cursors.sh
Created April 16, 2021 18:05
simple tool to apply overlayfs over specific directories
#!/bin/sh
# Directory to store overlays in (one directory structure is created per overlay configured down below)
OVERLAY_BASE=/home/root/overlays
overlay() {
set -e
overlay_id="$(echo $1 | sed 's;/;__;g')"
unset TARGET SOURCE FSTYPE OPTIONS
eval $(findmnt -P $1)
@Informatic
Informatic / 50-customca
Last active June 2, 2024 12:30
Let's Encrypt fix for webOS. Tested on 3.8 only, put this into /var/lib/webosbrew/init.d and you should be probably done.
#!/bin/sh
# Directory to store overlays in (one directory structure is created per overlay configured down below)
OVERLAY_BASE=/var/lib/webosbrew/customca
overlay() {
set -e
overlay_id="$(echo $1 | sed 's;/;__;g')"
unset TARGET SOURCE FSTYPE OPTIONS
eval $(findmnt -P $1)

Advanced Recursive Diffing™

Ever needed to diff two trees of files, while doing some preprocessing on modified files? Well - we've got a solution for you. Or rather... our long friend git has.

Turns out it's perfectly legal to just use git diff --no-index on directories outside of (any) git repository. With that, we can (ab-)use built in git diff per-path/extension preprocessing feature.

networking.networkmanager = {
enable = true;
# Let's just use networkmanager for modem support for now
unmanaged = [ "wlan0" ];
};
systemd.services.NetworkManager.requires = [ "ModemManager.service" ];
systemd.services.ModemManager.requires = [ "rmtfs.service" ];