Skip to content

Instantly share code, notes, and snippets.

@jes
jes / th-decode.pl
Created July 4, 2023 15:02
opensips topology_hiding Contact param decoder
#!/usr/bin/perl
#
# Decoder for OpenSIPS topology_hiding Contact header data params
# James Stanley 2023
#
# The OpenSIPS topology_hiding module can encode information in
# a Contact header URI parameter. The encoding is just XOR against the
# key, with the key repeating when it is too short. The plaintext
# contains the contents of the Record-Route headers, Contact header,
# and receiving socket address of the message that came into OpenSIPS.

The Gambler's Ballad

or, An Incident in Jakes's Saloon

by Milan Bulovic, 1971

Transcribed from https://www.youtube.com/watch?v=l23K3OLc1Es

One afternoon in Jake's Saloon gamblers were in the back.
A breed of men in a smoky den, all with a losing knack.

$ cat app.ts
const rl = require('readline').createInterface({
input: process.stdin,
});
rl.on('line', (n: number) => {
const m = n + 1;
console.log(`m = ${m}`);
});
Note that these are measured in bytes (from my Linux system) rather than words. The size in words is half the size in bytes.
$ ls -lS sys/*.bin
-rw-rw-r-- 1 jes jes 49494 Aug 10 15:33 slangi.bin
-rw-rw-r-- 1 jes jes 40426 Aug 10 15:04 asm.bin
-rw-rw-r-- 1 jes jes 40362 Aug 10 15:04 lisp.bin
-rw-rw-r-- 1 jes jes 38508 Aug 10 15:04 slangc.bin
-rw-rw-r-- 1 jes jes 37650 Aug 10 15:04 rude.bin
-rw-rw-r-- 1 jes jes 31168 Aug 10 15:04 kilo.bin
-rw-rw-r-- 1 jes jes 22382 Aug 10 15:53 sh.bin
>>> def f():
... return 1
...
>>> def g():
... return f()
...
>>> g()
1
>>> def f():
... return 2
//var f = "uncomment me to change colours";
var yellow = new Uint16Array([0x0000,0xFFC0],0,1); // black, yellow
var white = new Uint16Array([0x0000,0xffff],0,1); // black, white
var red = new Uint16Array([0x0000,0xf800],0,1); // black, red
var buf = Graphics.createArrayBuffer(240,160,1, {msb:true});
function flip(x,y,palette) {
g.drawImage({width:240,height:40,bpp:1,buffer:buf.buffer, palette:palette},x,y);
#!/usr/bin/perl
# neural net to represent an image by mapping (x,y) => (r,g,b)
# James Stanley 2021
# inspired by https://news.ycombinator.com/item?id=28448626
use strict;
use warnings;
use AI::FANN qw(:all);
/* Cat Laser */
#include <Servo.h>
// pin configuration
const int xservopin = 2;
const int yservopin = 3;
const int speedpin = A0;
const int dwellpin = A1;
const int xrangepin = A2;
#!/usr/bin/env python3
import gzip, os, sys
infile = open("fresh-food-16.json", "r")
b = bytes(infile.read(),"utf8")
n = 0
# This is the tyre squeal model from this clip: https://youtu.be/Likwgc5s_T0
# You need an "AudioStreamPlayer3D" at the position of each wheel, and then run
# this function from _process_physics, with each wheel node passed
func tyre_squeal(tyre):
# increase squeal amplitude with road speed
var speed_factor = 1
if (get_speed_kph() < 100):
speed_factor = 0.5 + 0.5 * (get_speed_kph()/100)