Skip to content

Instantly share code, notes, and snippets.

View zouppen's full-sized avatar

Joel Lehtonen OH64K zouppen

View GitHub Profile
@zouppen
zouppen / README.md
Last active September 6, 2024 12:43
Limit laptop battery charging at home, full charge elsewhere

Limit laptop battery charging at home

Lithium batteries wear more quickly when fully charged but of course you need the capacity on the move. Here's a solution: When at home, charge to 85% and 100% when not connected to your home network (wired or wireless).

Pre-requirements: Linux, NetworkManager

Installation

@zouppen
zouppen / Korttipeli.hs
Created August 9, 2024 10:33
Small example about decoding values
{-# LANGUAGE RecordWildCards #-}
module Korttipeli where
import Control.Monad.State
decodeValue :: Integer -> State Integer Integer
decodeValue n = state $ \s -> let (s', ord) = divMod s n
in (ord, s')
decodeValues :: Traversable t => t Integer -> Integer -> Maybe (t Integer)
@zouppen
zouppen / ratas-v8.stl
Last active February 27, 2023 00:41
Hammasrattaan ripustin polkupyörägeneraattoriin
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@zouppen
zouppen / README.md
Last active December 25, 2022 00:54
Advent of code 2022 epic häx

Advent of code 2022 epic häx

Zouppen is not trying to solve 'em all but just show some epic overoptimized stuff.

@zouppen
zouppen / README.md
Last active December 12, 2022 23:11
Command-line tool to convert Lightning Address to LN invoice

Command-line tool to convert Lightning Address to LN invoice

Usage:

lnaddress [email protected] 1000 "Thanks a lot!"

Probably not 100% compliant with LUDS but should almost fulfill LUD-01, LUD-06, and LUD-12.

@zouppen
zouppen / README.md
Last active April 17, 2024 21:52
Block incoming traffic from Tor exit nodes on Linux + ipset

Block Tor exit nodes with Linux and ipset

This gist blocks incoming traffic from Tor exit nodes. You can also use it to MARK or redirect the incoming traffic, depending of your needs.

This guide is for IPv4 only, feel free to contribute IPv6 support if you have it.

Installing

@zouppen
zouppen / README.md
Last active October 31, 2022 13:13
Throttle Raspberry Pi CPU to avoid overheating

Raspberry Pi overheating protection

If your Raspberry Pi is overheating, a common solution is to add a fan. Sometimes it's not feasible and in most cases the computer is runnning smoothly without a fan.

To limit heating, CPU throttling is a solution which keeps your computer not crashing during long compiles or so, but gives out the peak performance for shorter period of times. It depends of your application, if this is good enough solution. For me it is. I like my

@zouppen
zouppen / README.md
Last active September 16, 2022 15:25
Command line TOTP (Google Authenticator) validator

TOTP (Google Authenticator) support in shell scripts

Here is a POSIX shell compliant TOTP validator.

Requires oathtool which is available from Debian / Ubuntu repositories and probably many other distros as well.

@zouppen
zouppen / README.md
Last active October 2, 2024 11:12
How to setup a minimal diskless Debian initramfs with debootstrap for QEMU or iPXE

How to setup a minimal diskless Debian (year 2022 style)

This guide helps you to setup a minimal stateless and diskless Debian initramfs with debootstrap. It is suitable for running from QEMU or network booting with (e.g. with iPXE).

This guide is for amd64 architecture.

Motivation

@zouppen
zouppen / taikavehje.sh
Created September 1, 2022 22:42
A compact example how to convert rows to JSON objects in shell & jq
#!/bin/sh -eu
export ydin=`uname -r`
export os=`uname`
lspci | jq -Rs '{os: env.os, ver: env.ydin, laitteet: split("\n") | map(capture("^[^ ]* (?<key>[^:]*): (?<value>.*)$") ) | from_entries}'