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 / say.sh
Created June 2, 2023 07:31
simple portable text to speech using ffmpeg or ffplay
#!/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

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
-- Open directory viewer (like apache opendir, based on unix.opendir example)
--
-- Usage:
-- function OnHttpRequest()
-- if( not dir.serve() ) then
-- print("default")
-- Route()
-- end
-- end
--
@coderofsalvation
coderofsalvation / python-patterns.md
Last active October 20, 2022 14:52
python patterns

Useful Python Patterns/Functions NOTE: for 3D or lua JS patterns see my other patterns-gists 3D patterns-page

easy debugging/printing using pdb

import pdb

# somewhere in your code
pdb_settrace()
@coderofsalvation
coderofsalvation / comingsoon.md
Last active October 29, 2022 03:27
wrk.ist coming back soon

db d8b db d8888b. db dD d888888b .d8888. d888888b 88 I8I 88 88 8D 88 ,8P' 88' 88' YP ~~88~~' 88 I8I 88 88oobY' 88,8P 88 8bo. 88
Y8 I8I 88 888b 888b 88 Y8b. 88 8b d8'8b d8' 88 88. 88 88. db .88. db 8D 88
8b8' 8d8' 88 YD YP YD VP Y888888P `8888Y' YP

@coderofsalvation
coderofsalvation / iptables-proxy-forward-and-ratelimit-ports.md
Last active April 3, 2023 14:04
using iptables to redirect low ports to high ports with rootless podman docker containers

IPTABLES

server $ cat proxy

proxyport(){
  iptables -t nat -A PREROUTING -p tcp --dport $1 -j REDIRECT --to-port $2
  iptables -t nat -I OUTPUT -p tcp -d $(curl -s https://checkip.amazonaws.com) --dport $1 -j REDIRECT --to-port $2 # reverse ip
}
@coderofsalvation
coderofsalvation / howto rootless podman container connecting to REST api docker.sock.md.md
Last active April 19, 2023 17:05
howto rootless podman container connecting to REST api /var/run/docker.sock

Ok I was struggling a bit finding info about this. In a nutshell:

  • /var/run/docker.sock only works for root(ful) containers
  • there's no rootless socket-file created by default (you need to run an API listener service)

STEP 1: run API listener service (to create socketfile)

# whoami
@coderofsalvation
coderofsalvation / AFRAME.utils.throttleTicks.js
Last active September 22, 2022 09:12
AFRAME.utils.throttleTicks() allows central (throttle)control of all AFRAME components-ticks (without having to patch community components)
/*
* Usage:
*
* AFRAME.utils.throttleTicks({
* 'aabb-collider':{ "*": 150 },
* 'texturescroll':{ "*": 50 },
* 'foo': { "*": AFRAME.utils.device.isMobile() ? 150 : 50 }
* }, true)
*
*/
@coderofsalvation
coderofsalvation / checksum.sh
Created September 12, 2022 11:57
generate checksum from directory tree (unix / shell)
find . -type f -printf "%p %s\n" | LC_ALL=C sort | md5sum
# output: a71e7b59041f2db45adb105596519167 -
@coderofsalvation
coderofsalvation / index.html
Created September 7, 2022 13:12
Metaradio.at
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="#">Metaradio</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li><a href="#link2" onclick="alert('todo')">About</a></li>
<li><a href="#link3" onclick="alert('todo')">Examples</a></li>
</ul>