Skip to content

Instantly share code, notes, and snippets.

View coderofsalvation's full-sized avatar

Coder of Salvation / Leon van Kammen coderofsalvation

View GitHub Profile
@coderofsalvation
coderofsalvation / nix-create-a-package-cheatsheet-2024.md
Last active January 6, 2024 09:58
nix create/tweak a package cheatsheet
View nix-create-a-package-cheatsheet-2024.md

Update a sha256/Hash

$ nix store prefetch-file <url>                                                                                        

build a derivation

  1. get default.nix from nixpkgs master-repo
  2. run the command below
@coderofsalvation
coderofsalvation / workflow.sh
Created December 20, 2023 08:42
parallel workflow orchestration using wait-cmd in shellscript #bash #parallel #shellscript #speedupCI #windmill #airflow
View workflow.sh
#!/bin/bash
#
# Q: how can I track & run tasks in parallel (speed up CI pipeline e.g.)
# confidently without introducing platforms like Apache
# Airflow or Windmilll?
#
# A: the 'wait' command in shellscript
#
set -eE && trap "echo '❌ halting flow'" ERR
run(){ time "$@" 2>&1 | sed "s/^/[$1] /g" | tee .log; }
@coderofsalvation
coderofsalvation / shell.nix
Created December 15, 2023 10:22
chatgpt's take on using packages of different versions in nix.shell (which seems to be what niv+nix-flakes solve too)
View shell.nix
{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
buildInputs = [
# Packages from the default nixpkgs channel
pkgs.python
pkgs.vim
# Packages from another channel
(import (builtins.fetchTarball {
View index.html
<!DOCTYPE html>
<html lang="en">
<head>
<title></title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style type="text/css">
#videos{
display:grid-auto-columns;
grid-column-gap:5px;
@coderofsalvation
coderofsalvation / app.sh
Last active December 12, 2023 18:15
podman rootless forgejo actions setup
View app.sh
#!/bin/sh
# below is based on this forgejo actions admin guide: https://forgejo.codeberg.page/docs/v1.20/admin/actions/
PORT=8621
TOKEN=XXXXXXX_REPLACE_TOKEN_HERE_XXXXXXXX
URL=https://yourinstancehere.org
UID=`id -u`
docker=`which docker || which podman`
test -d data || mkdir data
@coderofsalvation
coderofsalvation / visual-meta.js
Created November 21, 2023 09:29
visual-meta / bibtex parser (incl. sections & multiplex/demultiplex of text/metadata)
View visual-meta.js
var bibtex = {
decode: (str) => {
// bibtex: ↓@ ↓<tag|tag{phrase,|{ruler}> ↓property ↓end
let pat = [ /@/, /^\S+[,{}]/, /},/, /}/ ]
let tags = [], text='', i=0, prop=''
let lines = str.replace(/\r?\n/g,'\n').split(/\n/)
for( let i = 0; i < lines.length && !String(lines[i]).match( /^@/ ); i++ )
text += lines[i]+'\n'
str = lines.join('\n').substr( text.length )
@coderofsalvation
coderofsalvation / README.md
Last active December 19, 2023 08:17
NixOS Lenovo ideapad s540 nvidia GTX1650 powersave
View README.md

Welcome ideapad s540 GTX1650 Nix-friends (good news ahead)

I've spend way too long to get the NVIDIA-driver to work, as well as taming the overheating problem which has haunted my ideapad forever. I hope this config can save somebody else lots of time (please comment!), as I experienced weird catch22 scenarios because of the dual-video driver.

note: if you laptop still overheats, lower the CPU_SCALING_MAX_FREQ variables.

You can now run apps on the NVIDIA GPU by creating this nvidia-run shellscript-wrapper:

@coderofsalvation
coderofsalvation / say.sh
Created June 2, 2023 07:31
simple portable text to speech using ffmpeg or ffplay
View say.sh
#!/bin/sh
# usage: say hello # plays audio (ffplay)
# OUTPUT=/tmp/hello.wav say hello # saves wav (ffmpeg)
dbus_session_file=~/.dbus/session-bus/$(cat /var/lib/dbus/machine-id)-0
if [ -e "$dbus_session_file" ]; then
. "$dbus_session_file"
export DBUS_SESSION_BUS_ADDRESS DBUS_SESSION_BUS_PID
fi
@coderofsalvation
coderofsalvation / README.md
Last active March 31, 2023 10:21
deadsimple literal-ish documentation-generator using awk #tiny #superflexible #markdown
View README.md

Foo

bar is printed

The code


//  # Foo
//

function foo(){
@coderofsalvation
coderofsalvation / opendirectory.lua
Last active November 7, 2022 10:17
open directory for redbean / rclone
View opendirectory.lua
-- Open directory viewer (like apache opendir, based on unix.opendir example)
--
-- Usage:
-- function OnHttpRequest()
-- if( not dir.serve() ) then
-- print("default")
-- Route()
-- end
-- end
--