Category Archives: Computer

Audio switcher

Doing my work from home via Jitsi (Jabra headset) and Listening to music on my speakers. Sometimes i want to switch output. For example spotify on my headset.

Using below code, i can easily switch between output sinks.

#!/bin/bash

if [ -z "$1" ]; then
    echo "DEVICE"
    pactl list sinks | egrep "^Sink|Description" | sed 'N;s/\n/,/' |sed -e 's/\t/ /g'  | cut -f2,5- -d" "
        echo "APPLICATIONS"
    pactl list sink-inputs | egrep -ie "^Sink|application.name" | grep -v "\-application-name" | sed 'N;s/\n/,/' | sed -e 's/\t/ /g' | sed -e 's/  / /g' | cut -f3,6- -d" "
    echo "Usage: $0 APPID DEVICEID" >&2
    exit 1
fi

pactl move-sink-input $1 $2

It shows output devices, and applications which are using audio sinks.
Just match them up.

OldSkool Computer Cartridges/expansions/add-ons

(Todo : add photos/designs )

Amiga:

Action Replay IIOwned since … 80s 90s?

Modded this one, as part of my modular
amiga system where i wanted to remake
every part onto 10×15 euro prints. So i could
swap things out for other boards.
Memory expansion512k .. missing in action
Go a new one in … ?
Boot selectorSwaps df0 and df1
DIY version was a wirewrap ic socket with a cross switch, now i have a Gotek buffered switching module with can be actvated with a keystroke.
(Gotek post)
Keyboard modHidden key (in the space of the stands, which triggered a extra key stroke)
Kickstart selectorA print you can insert in the ROM socket of your amiga. Had only 1.2 and 1.3.
Now there are many .. like diagnostic roms.
I made a altered 1.2 version .. which was unusable .. i f*cked it up
SID modAdded a sid parallel on the 8020 CIA chip
Gotek driver emulatorI made a arduino version to read disks. (Other post)
But this is a disk image drive emulator.
See Gotek post
Boot sector warnPiezo beeper which warned me when a boot sector was being written (virus alert)
Sound filter fixAmiga audio filter enhancer, using capacitors and resistors

C64:

Final Cartridge III
Led modMemory activation leds
KCS Power CartridgeSepp’s old cartridge?
Rom selectorDIY rom selector
Data Manager 2Can’t find anything on this one on other sites !?!?!
https://www.henriaanstoot.nl/2022/07/17/mystery-cartridge-c64/

Atari:

Vic-20:

Reset modDIY reset mod
ROM selectorDIY ROM selector
Many cartridgesSold in 2022, kept only some useful once’s

PC:

PC speaker modSpeaker to audio jack
Seek time monitorWhen a seek took too long, LEDs would light up, time to defrag!
Covox modA pre sound card parallel to audio resistor bridge.
Only a few demo’s and games supported this mod.
VGA to scartDisplay hack
VGA to Scart hack

Monitor:

Monitor modDIY horizontal flip using relays
Color modGreyscale / RGB switcher

Generic:

Joystick recorderrecorded movements when playing a game, so it could replay parts.

MQTT Keyboard

A fancy keyboard….. At last a clickety keyboard. A Razer Blackwidow V3 mechanical keyboard. I’m not a gamer, but i like the clickety sounds. RGB leds are always nice to play with.

One of the nice things about razer is the Linux support!

Some nice links:

https://github.com/openrazer/openrazer

https://openrazer.github.io/

Even several python scripts can be found, but no MQTT.
So made a fast ‘n simple hack to control my keyboard with mqtt/nodered.

When someone is at the frontdoor, my keyboard changes from white to red.

Below a node-red example

My python code:

import paho.mqtt.client as mqttClient
import time
import os
import subprocess
import json

def on_connect(client, userdata, flags, rc):
    if rc == 0:
        print("Connected to broker")
        global Connected
        Connected =True
    else:
        print("Connection failed")

def on_message(client, userdata, message):
    subprocess.Popen(["razer-cli", "-c", message.payload])

Connected = False

broker_address = "your.mqtt.brokerip.here"
port = 1883
#user = "user"
#password = "password"
client = mqttClient.Client("mqttrazer")
#client.username_pw_set(user, password=password)
client.on_connect = on_connect
client.on_message = on_message

client.connect(broker_address, port=port)
client.loop_start()

while Connected != True:
    time.sleep(0.1)

client.subscribe('razer/in')

try:
    while True:
        time.sleep(1)

except KeyboardInterrupt:
    print ("exiting")
    client.disconnect()
    client.loop_stop()

Ipcam sphere panorama

I made a little script to make a 360 spherical panorama photo, using a remote controlled IP cam,

Looking at the API CGI, i only needed to control the movement of the camera and getting a snapshot.

  • Point camera down
  • Point camera maximal left
  • Take picture
  • Point a little to the right
  • Take picture, loop until max right
  • Point a little more up and go max left
  • Doing same loop as above, until pointing maximal up
Made a little animation in blender

After getting all those pictures, i only needed to stitch them using Hugin.
When viewing the image with VR Glasses, i could look around my room, without image distortion, like below flattend example.

The ipcam generates a token, which you have to use in your curl commands.

TOKEN PART

token=$( curl -s -d  '[{"cmd":"Login","action":0,"param":{"rs": "abcd", "User":{"userName":"admin","password":"SECRETPASSWORD"}}}]'  "http://camera.ip.number.here/cgi-bin/api.cgi?cmd=Login&token=null"  -H 'Content-Type: application/json' | grep name | cut -f4 -d\" )

GETTING A IMAGE FROM IPCAM

wget "http://camera.ip.number.here/cgi-bin/api.cgi?cmd=Snap&channel=0&rs=123asd&user=admin&password=SECRETPASSWORD" -O output.jpg

CONTROLLING MOVEMENT

curl -X POST  -d '[{"cmd":"PtzCtrl","action":0,"param":{"rs": "abcd", "channel":0,"op":"Left","speed":1,"id":1}}]' "http://camera.ip.number.here/cgi-bin/api.cgi?cmd=PtzCtrl&token=$token"

COMPLETE SCRIPT

#!/bin/bash
token=$( curl -s -d  '[{"cmd":"Login","action":0,"param":{"rs": "abcd", "User":{"userName":"admin","password":"SECRETPASSWORD"}}}]'  "http://camera.ip.number.here/cgi-bin/api.cgi?cmd=Login&token=null"  -H 'Content-Type: application/json' | grep name | cut -f4 -d\" )
echo $token

if [ $2 == "max" ]; then
curl -X POST  -d '[{"cmd":"PtzCtrl","action":0,"param":{"rs": "abcd", "channel":0,"op":"'$1'","speed":1,"id":1}}]' "http://camera.ip.number.here/cgi-bin/api.cgi?cmd=PtzCtrl&token=$token"
exit 0
fi


for x in $(seq -w 1 25) ; do
	for y in $(seq -w 1 12) ; do
                wget "http://camera.ip.number.here/cgi-bin/api.cgi?cmd=Snap&channel=0&rs=123asd&user=admin&password=SECRETPASSWORD" -O ${x}${y}.jpg
		curl -X POST  -d '[{"cmd":"PtzCtrl","action":0,"param":{"rs": "abcd", "channel":0,"op":"Right","speed":1,"id":1}}]' "http://camera.ip.number.here/cgi-bin/api.cgi?cmd=PtzCtrl&token=$token"
		sleep 0.5
		curl -X POST  -d '[{"cmd":"PtzCtrl","action":0,"param":{"rs": "abcd", "channel":0,"op":"Stop","speed":1,"id":1}}]' "http://camera.ip.number.here/cgi-bin/api.cgi?cmd=PtzCtrl&token=$token"
		sleep 5
	done

	curl -X POST  -d '[{"cmd":"PtzCtrl","action":0,"param":{"rs": "abcd", "channel":0,"op":"Left","speed":1,"id":1}}]' "http://camera.ip.number.here/cgi-bin/api.cgi?cmd=PtzCtrl&token=$token"
	sleep 30
	curl -X POST  -d '[{"cmd":"PtzCtrl","action":0,"param":{"rs": "abcd", "channel":0,"op":"Stop","speed":1,"id":1}}]' "http://camera.ip.number.here/cgi-bin/api.cgi?cmd=PtzCtrl&token=$token"
	sleep 1
        curl -X POST  -d '[{"cmd":"PtzCtrl","action":0,"param":{"rs": "abcd", "channel":0,"op":"Up","speed":1,"id":1}}]' "http://camera.ip.number.here/cgi-bin/api.cgi?cmd=PtzCtrl&token=$token"
	sleep 0.5
	curl -X POST  -d '[{"cmd":"PtzCtrl","action":0,"param":{"rs": "abcd", "channel":0,"op":"Stop","speed":1,"id":1}}]' "http://camera.ip.number.here/cgi-bin/api.cgi?cmd=PtzCtrl&token=$token"
sleep 5
done
1st panorama (Black and White due to night mode camera)

Retropi handheld

I’ve got a retro-pi running for some time, now .. posting a little movie.
The gamehat i’ve got a week now.

Retropi met Darish Zone King Image

  • 512GB
  • 23000 games
  • 50 systems

Own hacks on this system:

  • Added dos emulator
  • Added DOS games
  • Added Amiga demos menu entry
  • Changed Font sized and look

I’ve got a bigben controller which i can connect to the Raspberry USB .

375403 (600×315)

Gluster testing with docker

GlusterFS (Gluster File System) is an open source Distributed File System that can scale out in building-block fashion to store multiple petabytes of data.

Below is a test environment which creates 5 docker instances, which represent 5 gluster servers.
This was for test repairing our work gluster.

First install gluster and pull a image: docker pull gluster/gluster-centos

gethosts

for f in 1 2 3 4 5;
do 
echo "$(docker exec -it gluster_${f} ip a s | grep 172 | awk '{ print $2 }' | cut -f1 -d/) gluster_${f}"
done

create_dockers

for f in 1 2 3 4 5; do
docker run --name gluster_${f} --privileged=true -d gluster/gluster-centos /usr/sbin/init
done

create_bricks

for f in 1 2 3 4 5; do
docker exec -it gluster_${f} mkdir -p /bricks/brick01
done

destroy_dockers

for f in 1 2 3 4 5; do
docker stop gluster_${f}
docker rm gluster_${f}
done

diskcreator

for f in $(seq 1 5); do
dd if=/dev/zero of=/root/disk${f} count=1 bs=100M
losetup /dev/loop${f} /root/disk${f}
docker run --name gluster_${f} --privileged=true --device=/dev/loop${f} -d  gluster/gluster-centos /usr/sbin/init
done

lvm-dockers

modprobe dm_thin_pool (in docker)
modprobe dm_thin_pool (ook in VM zelf)
modprobe device-mapper ??

pvcreate /dev/loop0
vgcreate brick01 /dev/loop0
lvcreate -L 50M -T brick01 -n thin_brick01

lvcreate -V 40M -T brick01/thin_brick01 -n testvolume
mkfs -t xfs -i size=512 /dev/brick01/testvolume
mount /dev/brick01/testvolume /bricks/brick01

lvextend -L+10M /bricks/brick01
xfs_growfs /dev/brick01/testvolume
fash@fash-Vortex:~$ cat docker-lvm
modprobe dm_thin_pool (in docker)
modprobe dm_thin_pool (ook in VM zelf)
modprobe device-mapper ??

pvcreate /dev/loop0
vgcreate brick01 /dev/loop0
lvcreate -L 50M -T brick01 -n thin_brick01

lvcreate -V 40M -T brick01/thin_brick01 -n testvolume
mkfs -t xfs -i size=512 /dev/brick01/testvolume
mount /dev/brick01/testvolume /bricks/brick01

lvextend -L+10M /bricks/brick01
xfs_growfs /dev/brick01/testvolume

How to use

./create

./gethosts voor info

docker exec -it gluster_1 /bin/bash

# GEEN HOSTSNAMES INGEVULD!
gluster peer probe 172.17.0.2
gluster peer probe 172.17.0.3
gluster peer probe 172.17.0.4
gluster peer probe 172.17.0.5

Geen persistent storage aangemaakt evt kunnen we ook in de docker zelf testen

docker exec -it gluster_1 mkdir -p /bricks/brick01
docker exec -it gluster_2 mkdir -p /bricks/brick01
docker exec -it gluster_3 mkdir -p /bricks/brick01
docker exec -it gluster_4 mkdir -p /bricks/brick01

gluster volume create testvolume 172.17.0.2:/bricks/brick01 172.17.0.3:/bricks/brick01 172.17.0.4:/bricks/brick01 172.17.0.5:/bricks/brick01 force

gluster volume start testvolume

### NOG TE TESTEN
#gluster volume create testvolume replica 2 172.17.0.2:/bricks/brick01 172.17.0.3:/bricks/brick01 172.17.0.4:/bricks/brick01 172.17.0.5:/bricks/brick01 force

### NOG TE TESTEN
#gluster volume create testvolume replica 2 arbiter 1 172.17.0.2:/bricks/brick01 172.17.0.3:/bricks/brick01 172.17.0.4:/bricks/brick01 172.17.0.5:/bricks/brick01 force

mount -t glusterfs 172.17.0.2:/testvolume /media/

cd /media

touch {1..9}

exit

for f in 1 2 3 4 ; do echo "gluster_${f}" ; docker exec -it gluster_${f} ls /bricks/brick01 ;done

# DESTROY 
for f in 1 2 3 4 5; do 
docker stop gluster_${f}
docker rm gluster_${f}
done

Howto reset-replicated-brick-same-server

Using clean glusterdockers

./create_dockers
./create_bricks
./gethosts

# docker exec -it gluster_1 /bin/bash


# gluster peer probe 172.17.0.2
# gluster peer probe 172.17.0.3
# gluster peer probe 172.17.0.4
# gluster peer probe 172.17.0.5

# Gluster peer status 
----------------------------------
(peers = 3 + localhost maakt 4 ;-)

# gluster volume create testvolume replica 2 172.17.0.2:/bricks/brick01 172.17.0.3:/bricks/brick01 172.17.0.4:/bricks/brick01 172.17.0.5:/bricks/brick01 force

# gluster volume start testvolume ; gluster volume info testvolume
----------------------------------

Volume Name: testvolume
Type: Distributed-Replicate
Volume ID: e5536d11-77ee-40a5-9282-e4223979f443
Status: Started
Snapshot Count: 0
Number of Bricks: 2 x 2 = 4
----------------------------------


# mount -t glusterfs 172.17.0.2:/testvolume /media/
# cd /media
# touch {1..9}

# exit

From dockerhost we see the files nicely spread over the bricks

# for f in 1 2 3 4 ; do echo "gluster_${f}" ; docker exec -it gluster_${f} ls /bricks/brick01 ;done
------------------------------------------------------------------------
gluster_1
1  5  7  8  9
gluster_2
1  5  7  8  9
gluster_3
2  3  4  6
gluster_4
2  3  4  6
---------------------------------------------------------------------------------



Logon op gluster_3
# docker exec -it gluster_3 /bin/bash
# rm -rf /bricks

- wacht ff -

# gluster volume status
----------------------------------------------------------------------------
Status of volume: testvolume
Gluster process                             TCP Port  RDMA Port  Online  Pid
------------------------------------------------------------------------------
Brick 172.17.0.2:/bricks/brick01            49152     0          Y       210  
Brick 172.17.0.3:/bricks/brick01            49152     0          Y       151  
Brick 172.17.0.4:/bricks/brick01            N/A       N/A        N       N/A   <----- gone  
Brick 172.17.0.5:/bricks/brick01            49152     0          Y       152 
----------------------------------------------------------------------------

# exit

From dockerhost:

# for f in 1 2 3 4 ; do echo "gluster_${f}" ; docker exec -it gluster_${f} ls /bricks/brick01 ;done
------------------------------------------------------------------------------------
gluster_1
1  5  7  8  9
gluster_2
1  5  7  8  9
gluster_3
ls: cannot access /bricks/brick01: No such file or directory
gluster_4
2  3  4  6
--------------------------------------------------------------------------------------

Logon on gluster_1
# docker exec -it gluster_1 /bin/bash

# gluster volume reset-brick testvolume 172.17.0.4:/bricks/brick01 start

#This is the moment to swap the md3260, but we are using here the next commands:

Create new storage on gluster_3
# docker exec -it gluster_3 mkdir -p /bricks/brick01 
# docker exec -it gluster_3 ls /bricks/brick01 

Logon on gluster_1
# docker exec -it gluster_1 /bin/bash

# gluster volume reset-brick testvolume 172.17.0.4:/bricks/brick01  172.17.0.4:/bricks/brick01 commit force


[root@svr1035 ~]# 


From dockerhost we see the files nicely spread over the bricks

# for f in 1 2 3 4 ; do echo "gluster_${f}" ; docker exec -it gluster_${f} ls /bricks/brick01 ;done
------------------------------------------------------------------------
gluster_1
1  5  7  8  9
gluster_2
1  5  7  8  9
gluster_3
2  3  4  6
gluster_4
2  3  4  6
---------------------------------------------------------------------------------