0xcafeface
handmade. minimalistic. no bloatware.
Welcome. This is a small collection of my C sourcecode for linux. Feel free to download, check, use and comment:
Jörg Reinhard <info@finalmedia.de>. Check pubkey signature 0xF67E4634D2A96AF9.
Framebuffer
- fbtools.tar.gz 29-Apr-2023 20:31 96K sha256sum:c3ef06f7ff33485699bc0dc6c07e22e2656fd03520130b2c0ca79343bceaf082 My tiny linux framebuffer toolset (fbdraw, fbenv, fbtouch, fbmouse) for drawing rectangles, pixels and graphics to /dev/fb0, reading touchscreen and mouse events (click/scroll) from /dev/input/event0 and /dev/input/mice for getting coords and an integer id for floating 64px Grid. Tools in c as filters. All Scriptable in userspace by using shell scripts and pipe constructors. Demo included. See README.de.md or README.en.md for further information. You can use this toolset to build small GUIs on embedded devices. fbtools.tar.gz includes some Public Domain Icons, Example-Scripts, a tiny Paint App. Additionally you can download a Testimage (rgb800.fbd.gz) rgb800 (6.8 MB) or some other Assets: fbdraw_assets.tar.gz (14 MB) (converted pexel photos as compressed fbdraw commandlist - using included script examples/convert2fbdraw.sh (using imagemagick and gawk), furthermore colorful and handpicked icons from icons8 and already converted to fbdraw p x y r g b format.) Also have a look at my tools in section dataprocessing on this website: "charforce" and "intrange". charforce is useful to provide and force a offset for your drawing operations in a pipe. .. | charforce o 128 128 | fbenv fbdraw > /dev/null. Further Usage for binding a 64px grid window do specific tcp socket, and limit to a single 64x64px Window, given at position x=128 y=128: socat TCP4-LISTEN:40001,fork,reuseaddr - | tr -dc "p0-9 \n" | grep "^p" | intrange 2 0 64 | intrange 3 0 64 | charforce o 128 128 | fbenv fbdraw | logger -t fbdraw > /dev/null so you can use in bash something like echo p 2 2 230 0 0 > /dev/tcp/127.0.0.1/40001 for remote drawing a red pixel to x=4 y=4, offset on serverside to +128px, so finally in x=130 y=130 on serverside framebuffer. Caveat: use something like stdbuf -i0 -o0, and unshare -r -n and setuidgid limiteduser before parsing commands to define buffer and more secure user context.
- fbvnc_mod.tar.gz 11-Sep-2013 18:07 12K sha256sum:f0c42dfd39a3c94fbedaa505df34e8ad76ed93175aa6f4909782f10fd6107f62 A VNC Client for direct output to linux framebuffer device (fbdev). This is my modified version (german keyboard, mousewheel) of fbvnc from Ali Gholami Rudi. Also have a look at the tools from Uwe Klatt, e.g. a fork of fbvnc (with VNC AUTH Support and ZLIB) and a also a fork of framebuffer-vncserver (using libvncserver).
- fbyell.tar.gz 19-Sep-2013 18:01 2.6K sha256sum:4e221e7b7c2baac3344e3ecb03d83d22f620feb3db068837ea160365c6ce8aef Modified and optimized version of txt2fb. Tool for displaying ASCII Text on Framebuffer Devices, without opening /dev/fb0. Writing to stdout, so you can redirect to different device, or do multiscreen hack with ... | tee /dev/fb0 > /dev/fb1. This is modified by Ali Gholami Rudi (http://litcave.rudi.ir). really nice font zoom/scale function.
- txt2pxyrgb.tar.gz 17-Apr-2023 13:48 2.1K sha256sum:1920bc39fe6e93f3d415472c9941b4e78727080e1baa4cb474ba0b7f645f0e55 Reading ascii text from stdin, using embedded 8x8 Pixel font and output fbdraw pixel commands in format p x y r g b. Usage Example: (date; echo Test; ls -l) | txt2pxyrgb 250 0 0 | charforce o 200 300 | fbenv fbdraw > /dev/null
- txt2fb.tar.gz 13-Sep-2013 09:47 6.9K sha256sum:8da3a1b34e069fa905f5b3db5a2bbfd54c837a751843de969930946871554d13 Tool for displaying ASCII Text on Framebuffer Devices, without opening /dev/fb0. Writing to stdout, so you can redirect to different device, or do multiscreen hack with ... | tee /dev/fb0 > /dev/fb1
- ascii2fbdev.tar.gz 26-Feb-2014 19:12 109K sha256sum:a08867d5e6f6bd117774d995731f590b90087baf7eec58ffc6a65fb51791cf0e Ascii Char sequence (0 black/ 1 white) on stdin to stdout for framebuffer like /dev/fb0 in different resolutions and depths. Auto detecing newline!
- bit2fbdev.tar.gz 26-Feb-2014 19:12 58K sha256sum:8d63ce2e0f60e2a815498732c079357cfb1829a8b6a9e149c14b73c320cbe1d7 Binary Bit sequence (0 black/ 1 white) on stdin to stdout for framebuffer like /dev/fb0 in different resolutions and depths.
- unifont.tar.gz 11-Sep-2013 18:02 6.7M sha256sum:ecc074fcbe113b414d43913cd563dfc99b52495ab940529d17bac5af44bd42f4 A Mirror of unifont.hex file, including some scripts. Unifont.hex is a UTF-8 Bitmap Font
Audio
- sid2pcm.tar.gz 10-Sep-2014 01:54 10K sha256sum:77e0876088893a6c038a04a696558a0cf57a6e775cfdf0194f60fae5e96fd47e My hacked/modified version of TinySID 0.94 by T. Hinrichs and R. Sinsch, so it can be used as a filter (writes to stdout) at linux commandline. First parameter is your SID Music File (MOS Technology SID Soundchip 6581, used in Commodore C64 an C128 in the 1980s), output to stdout. Example Usage: sid2pcm [sid-file] > /dev/dspW (set samplerate first! 44.1 kHz, signed 16 bit little endianess,mono - e.g. using sox?), or via pipe to alsa: sid2pcm [sid-file] | aplay -c 1 -f s16_le -r 44100, or to pulseaudio: sid2pcm [sidfile] | pacat --format=s16le --rate=44100 --channels=1, or to file: sid2pcm [sid-file] > example.s16le.mono.pcm. You can also pipe to ffmpeg and encode to different audiocodecs like opus, mp3, aac, ogg. Example using opusenc, a tiny standalone opus encoder: sid2pcm [sidfile] | opusenc - --raw-bits 16 --raw-rate 44100 --raw-chan 1 --raw-endianness 0 --raw output.opus. This is imho a much more flexible solution then directly accessing via soundcard.o. For Sample SID-Files have a look at the famous High Voltage SID Collection (http://hvsc.de). Also have a look to this nice thing.
- tonegenerator.tar.gz 21-Jan-2015 14:50 4.3K sha25sum:6e7527956189805074a4fb80f9064845180a74ff519945db4945bf7fe67e6166 This is my small Stereo, Multiple Sinus-Tone-Generator - just Sinus and Noise. It generates a RAW PCM 48khz, Stereo, 16 Bit little endian bitstream at stdout. So you can use ./tonegenerator | aplay -c 2 -f s16_le -r 48000. Compiled and linked with dietlibc, your executable binary(!) is also ~4kb only. The Example code generates Sinus Tone at 440 Hz at 80% volume and 1200 Hz at 20% volume. Mixed together. You can specify volume of each tone and can add further frequencies or noise.
Dataprocessing
- ratio10.tar.gz 11-Sep-2013 18:43 666 sha256sum:53c4bb74e1187f48adab25424b983e130e67096ceb6ca4a86502fcb47ceefead filter. Cloning stdin to stdout. byte by byte. while calculate ratio beetween up- and downbits as output on stderr. It is used to calculate spreading/distribution of 0 or 1 in a binary-data stream. Every input-byte is analysed bitwise, meaning reading 8 bit, counting 1 and 0. Redirect stderr to datafile, so you can visualize spreading afterwards.
- bit2ascii.tar.gz 26-Feb-2014 17:59 859 sha256sum:d5491ebd1d52638fbf5015d337f4e88784cfbb2d04814ee5c5f717d909a06115 filter. Binary Bit sequence on stdin to ascii bit sequence of character 0 or 1 on stdout.
- ascii2bit.tar.gz 26-Feb-2014 17:59 969 sha256sum:e7190f8fce5de50b176020fdbc39c7163f76dff6e716bc50e07d41ffdf575cab filter. Ascii Char sequence of character 0 or 1 as bits on stdin to real binary bit sequence in little endian on stdout.
- teetime.tar.gz 04-Sep-2020 20:45 957 sha256sum:2ba340de4b975cdad4071a14f7f848dc09e131d7f98208e7179de1b66f31f3e3 filter. Cloning stdin to stdout. byte by byte. terminate process after n seconds, if there is no further input on stdin. Useful to terminate a whole pipe if data stalled. this tool uses a refreshed SIGALRM signal as a kind of dead-man switch for pipes. use it to terminate a stalled openssh session.
- prepend_crc32.tar.gz 25-Apr-2023 21:50 1094 sha256sum:6ba16b1d4a65118524308284c423339de44f4f6324744b3af250076bb47cd399 filter. Cloning stdin to stdout. line by line. calculate crc checksum for each line and prepend this checksum in ascii hexadecimal notation, followed by space character. processing line by line.
- prepend_cubehash.tar.gz 25-Apr-2023 21:50 3580 sha256sum:a5da12f4da646b436c029b27d35e9befa4442863213b61b7a3f740dc9c1283cb filter. Cloning stdin to stdout. line by line. this tool just reads every line, calculates cubehash 256 revision 3 for each line and prepends the hash in ascii hexadecimal notation, followed by space character. processing line by line.
- onlyif.tar.gz 25-Apr-2023 21:20 2208 sha256sum:a513e62753687a9359295bce10a2927b815627d76906bb8b3a2ab6123033fed0 filter. Cloning stdin to stdout. line by line, if - and only if - a given searchterm is found in current line at given position and length. searchterms are dynamically defined at runtime by checking if a filename exists, matching the searchterm.. So you just have to touch a file in given directory, to supply new searchterms, and remove those file to remove the searchterm. example usage: mkdir tokendir; touch tokendir/abcd; tail -n0 -F file.log | onlyif 10 14 tokendir/ | ...further pipe commands... and trigger with echo "12345678 abcd testentry" > file.log. IMPORTANT HINT: "onlyif" disallows every filename beginning with slash or dot. lines containing searchterms beginning with this characters "." or "/" are omitted. Furthermore every dot "." and backslash "\" will get replaced by a slash "/" before checking filename/paths. so it is still possible to check for files in subfolders, but not possible to leave given root directory, if no symlinks are present. searchpaths exceeding 1024 characters get truncated.
- writelinefile.tar.gz 03-May-2023 21:08 1681 sha256sum:638b953f714863724a2419b357438fbfea26319a77160d1b3d24337e4a910a58 filter. Read from stdin. line by line. Parsing each line for first occurance of space character (separator). extract string before separator as filename (fullpath), and write string after separator in a file named by this currently extracted string. omit whole line, if no space character is found. if file was successfully written, also clone line to stdout. example usage: umask 022; (echo "/mnt/data/data.txt 12345678"; echo "/mnt/data/test.txt nonsense") | ./writelinefile so content of file /mnt/data/data.txt will be 12345678 and content of /mnt/data/test.txt will be nonsense. another example: ls -l ../*.dat | prepend_crc32 | writelinefile. Caveat: since character set is not limited (except newline and space character in our case), and linux even allows control-characters and nullbyte as filenames, be aware of any security problems. Limit character set of your pipe to Posix Portable Character Filename Set via .. | tr -dc "0-9a-zA-Z._- \n" | .. for filename and content. Have a look at this Essay from David A. Wheeler https://dwheeler.com/essays/fixing-unix-linux-filenames.html. Example Usage: ls -1 | prepend_cubehash | sed "s.^./home/user/targetdir/hashes/.g" | writelinefile
- runline.tar.gz 1-May-2024 12:24 653 sha256sum:e9282d0b01977d8a9780c10861619849e32c8364dd0b9705870aa3f1db31de30 filter. Read from stdin. line by line. Trivial tool, just parsing each line for given commandline. execute this commandline. reading endlessly from stdin, so you have to send strg+c to stop it. It is useful to combinate this tools with fbtouch from fbtools package - example: fbenv fbtouch | stdbuf -i0 -o0 grep "^# touch" | stdbuf -i0 -o0 cut -d " " -f3 | stdbuf -i0 -o0 tr -dc "0-9\n" | stdbuf -i0 -o0 sed "s|^|/touchcommands/|g" | stdbuf -i0 -o0 sed "s|$| \&|g" | stdbuf -i0 -o0 unshare -n -S1000 -G1000 runline >/dev/null if you have some executable scripts, 1,2,3...64 (named after the gridID of fbtouch screenscreen grid) in given directory /touchcommands/.
- charforce.tar.gz 29-Mar-2023 21:07 995 sha256sum:e3b945a6d25a87eac746ef9f15fa9ec5fda80a5cc54a5f65021b9336a52a6f4f filter. reading line by line. just write a given line of args to stdout once(!) and then just clone all incoming lines from stdin to stdout, but only if line does NOT begin with the first(!) character of the given args line. terminates pipe if no arguments are given. example: charforce o x y, write a line "o x y" to stdout once(!) and then just clones all incoming lines from stdin to stdout, but only if incoming line does NOT begin with "o". you can use it in this way to force a offset for fbdraw: .. | charforce o 128 128 | fbenv fbdraw | .., so every fbdraw offset command "o" in pipe will get discarded, except the one you provided: o 128 128.
- intrange.tar.gz 29-Mar-2023 21:10 1977 sha256sum:ebded18106c1f98c80051ccc528679db7280ddb94d15b2cc417bacbc74bf6ee7 filter. reading line by line. cloning stdin to stdout. additionally inspecting, if space separated n-th element is between a and b (including those values) and omit this line, if not. example: intrange 4 88 99, means the 4th column has to be an integer value between 88 and 99, matching and hiding a line "136 try this 90 99 demo", but not hiding "136 try this 87 99 demo" or "136 9999 9999 9999 demo". only analysing given column, and omit if no match, but DO NOT omit everything else. Only omit those lines in given column, but allow all other columns and combinations.
Sysutils
- every.tar.gz 01-Sep-2020 22:57 586 sha256sum:7ee7451f3fc3e7ba3fb70e13dfda15babd71236ce2ec209ca4946522c2576f25 execute a program periodically. Quick hack as a minimalistic version of "watch" without curses or fullscreen mode. This tool is running a given program, sleeping n seconds and streaming its output to stdout. endlessly, over and over again and usable in a pipe, "collecting" all output. simple example: every 10s date .another example in bash for redirecting output to specific host via tcp: every 2s "date > /dev/tcp/hostname/port". another example, running endlessly doing 4 pings and waiting 60 seconds after every 4 ping cycle: every 60s "ping -c 4 hostname" | tee -a logfile. another example: every 20s "ls -1 | wc -l" | tai64n | tee -a dir.log another example, usable for a tiny anacron solution (at replacement) to run scripts at a given point of time in background process. just copy or symlink your scripts in a folder in the style /etc/timerun/YYYYmmddHHMMSS/ and use this example to check every second for runnable parts in given directory of the current second. important: use single quote ' and do not use double quote ", since you want to evalute the date command in the child shell every second - not once in the parent shell. and do not forget to put the child shell in background, by using & otherwise the child shell probably runs longer than 1 second and the evalation of the next child shell wouldn't spawn right on time (since every run-parts command would have to exit cleanly before next run). example: every 1s 'run-parts /etc/timerun/$(date +'%Y%m%d%H%M%S')/ &' 2> /dev/null. Generally be aware: the child shell is "sh" since system() is used. if you need bash, or zsh you have to use a forked fork call: every 2s "bash -c 'your commandchain'". another funny example: every 1s "echo hear_and_feel_the_heartbeat | aplay -q -f cd -r 2000"
Graphics
- bit2pbm.tar.gz 11-Sep-2013 18:55 1.1K sha256sum:df822e2cfd7c81078740e9fced16abd93c76aae60e9a3190aa8c1f7e3ae1595a Transform any sort of binary datastream on stdin to an uncompressed(!) black/white PBM-image Type P1 (1024x768 Pixel) on stdout. You can edit in in a normal plain/text-editor afterwards.
- barnsley_fern.tar.gz 07-Jan-2014 13:45 2.0K sha256sum:30369ab3a20314bc8a587382768c29ffc93cf2d03e4639ce543fec6d83a95bfd Generating Barnsley Fern (Hausdorff-Konvergenz) as PBM Image at stdout. Also including an hacked version that generates SVG output with lot of squares. (Original Source by Paul Bourke and Jay Link coding for svgalib. 1988, http://paulbourke.net/fractals/ifs_fern_a). Another really beautiful implementation, only 538 bytes, directly written in postscript: barnsley_fern.ps (538 bytes) by Eric Wicklund, 1993
Patches
Patches to 3rd party software
- patches/gatling 30-Jul-2015 19:47 -- Collection of patches for gatling http daemon, version 0.13/0.14
- daemontools.tgz 25-Feb-2024 13:04 -- Patched Version of djb daemontools 0.76 (tai64nlocal) and disabled locking of supervise and multilog.
Playground
- geonames_symlink_database.htm 02-Feb-2020 10:43 -- Howto build a smart and tiny geonames resolver (resolving name of point of interest, like a city or street, to geo coordinate) without using any database backend, cgi, php or any external service - just by using broken symlinks and gatling httpd. Update: Added variant: cdb, ucspi-tcp, daemontools
- poetherm (german) 11-Nov-2019 20:42 -- PoE Thermologging with Olimex ESP32 PoE Development Board and DS3231 Realtime Clock Module (german)
- otp.htm 16-Jan-2020 21:48 -- Some trivial XOR Cheatsheet and Codecard Generator Scripts, useable as "computerless" one time pad. use a better random number generator, not /dev/urandom. don't use computers at all. pen and paper. 16 sided dices. just for fun.
- oneliners.htm 26-Aug-2020 15:48 -- collection of some conveniant shell script oneliners. no collection yet ;)
- tiny.htm 28-Mar-2020 14:39 -- keep your html source clean and tiny. this is a collection of some tricks, a recommendation to slim down your html code for saving traffic and avoid unnecessary requests.
- utf8symbols.htm 29-Mar-2020 15:16 -- index of utf8 symbols and pictograms in html character references in UCS codepoint format &#nnnnnn; (decimal).
- utf8.htm 19-Mar-2024 15:16 -- collection of utf8 symbols and german description
- c64mynor.htm 19-Jan-2021 21:45 -- Hardware Playground: c64 uart cartridge and mynor single board computer
- miniknot 25-Feb-2024 13:16 -- TechDemo MiniKnot MicroVM busybox qemu (German)
- slidemaker 10-Mar-2024 18:16 -- TechDemo Slidemaker Javascript
- namegen 22-Mar-2024 17:20 -- Namegenerator Toy Javascript
- audiosrv 05-Apr-2024 19:00 -- Easy Playground Audioserver Toy via busybox httpd (German)
- minimail 29-Sep-2024 23:00 -- minimal REST API for postfix maildirs, busybox httpd cgi-bin
Tutorials
I wrote some (german) sysadmin tutorials in my knowledge base. You'll find some of them here with permanent links:
- 8f9d6d5bbd15 CheckMk Query Language (Monitoring Auswertung/Automatisierung)
- 44a6d6f522d7 KVM qemu FreeBSD
- 51fe605edb29 KVM qemu und Luks allgemein
- aa5327d2f5ca KVM qemu Windows 10
- c4fdcb7a96b2 KVM qemu Windows 11
- a6a5d0f51234 KVM qemu TrueNAS
- 2d11f99fd2e1 20190106 cifs in linux einbinden
- 8d65d3e58722 20211113 djb djbdns
- dc1f53f284da 20211113 djb publicfile httpd
- bf1cb01b11d9 20211116 checkmk local plugins
- 19c2ff48d100 20211107 truenas iscsi und einbindung in linux
- abfcd202dd88 20211123 minio in alpine
- 0ee3d2b8b7df 20211125 eigene .bashrc via ssh forwarden und remote mitnutzen
- d4b80f4818a1 20211125 qgis openstreetmap tiles tilenames.c leaflet download busybox httpd selfhosted
- d34cf866f262 20211006 ssh und tor
- 32ca80d8cdf7 20220822 ssh ethernet tunnel
- 8bc74c61547a 20220212 apc usv nic trick
- b6cd1d5feaa3 20220711 Zweifaktor Auth TOTP login systemuser und auch via keybased ssh
- 02d07e6e3aed 20221116 djb envdir
- d149e722d8b9 20221204 Hausnetzerkennung via LLDP 0x88cc im Ethernet
- eaa7c36b06ee 20221217 fefe tinyldap server
- b899617b6c17 20221227 MQTT Mosquitto & Mikrotik KNOT & Blutooth Beacons
- d37fdd997fe7 20230331 tiny URL shortener Service
- c378badd8e9b 20230429 gzip content hash Fallstrick
- 0bc1e96d458b 20230706 socklog als rsyslog UDP multilog einrichten
- dbe1a78af354 20230711 mikrotik wireguard vxlan outdoor bridge
- 92ef3170bf62 20240129 mutt mail client crypted muttrc
- 78511cb95594 20240204 x509 eigene clientzertifikate zur zusatzabsicherung eines Apache
- 2321e8d6b3c3 20240215 shellcode guide
- 679c3684bdec 20240412 openssh forced command getter setter keyvalue storage
- 4fc8962abf25 20240704 alpine chromium boot kiosk system
- 2e2e2f6d81de 20241216 anti path traversal guide
- 4690417875f5 20241225 sixels compact
- abba48ceb2e4 20250120 homoglyphen angriffe am beispiel
Please link to this page via http://cafeface.de or reinhard.xyz.
This site ist non-commercial. no cookies. no annoying banners. no data-mining. privacy friendly.
If you like this site, you will also like (much more) those sites: Felix von Leitner, Ali Gholami Rudi, D. J. Bernstein, Bruce Guenter, Uwe Ohse, Paul Bourke, Dmitry Marakasov (AMDmi3), Nayuki, Jörg Schulenburg, b0llix, skarnet, Gerrit Pape, Dr. Erwin Hoffmann, core.suckless.org
Other interesting sites to visit: mynor.org