Archive of September 2023

Counting with Different Script Languages

Every day at work, I make sure to learn at least one more Powershell function, and I'm bridging my bash knowledge over. Net goal; I can do everything on a Windows server that I can do on a Linux server, if not more.

I do a huge amount of log file review, and one common thing I'll do is to take data like this:

2023-09-06 12:22:47.008 [Pickle Thread] Reticulating Splines 2023-09-06 12:22:47.019 [Apple Thread] Forecasting future misinformation 2023-09-06 12:22:48.100 [Pickle Thread] Neglecting the step children 2023-09-06 12:22:48.219 [Apple Thread] Registering pain points 2023-09-06 12:22:49.062 [Banana Thread] Organizing a Raffle

.. let's say this goes on indefinitely. I want to know how many times in my log each of my fruity threads appears. In Bash, that looks like this:

cat sample.log | sed 's/.*\[//;s/\].*//' | sort | uniq -c 2 Apple Thread 1 Banana Thread 2 Pickle Thread

In powershell, that looks like this

gc .\sample.log | Group-Object { $_ -match "\[(.*?)\]" | Out-Null; $Matches[1] }
Count Name Group
----- ---- -----
2 Pickle Thread {Pickle Thread, Pickle Thread}
2 Apple Thread {Apple Thread, Apple Thread}
1 Banana Thread {Banana Thread}

Lunchtime RTLSDR

I want to use my iPad to listen to 101.5 FM. Before you mention that I could find the online stream, and yeah, I know that's a thing, that's too easy.

This is the Raspberry Pi 4 running headless, displaying it's IP and wifi SSID, and connected to a Software Defined Radio (the silver USB dongle) which is in turn connected to the antenna hanging in the tree. It's taking its audio from the FM channel and streaming it over the USB-C connection to the iPad over VLC.

The script looks like this:

#!/bin/bash

rtl_fm -g50 -f 101.5M -M wfm -s 180k -E deemp |\ sox -traw -r180k -es -b16 -c1 -V1 - -t flac - |\ cvlc - --sout '#standard{access=http,mux=ogg,dst=10.55.0.1:8080/audio.ogg}'

I would love to claim that I knew all of this, but I picked it up from a random google result that has since escaped my history, else I'd credit the writer. Whoops.

RTL_FM is telling the radio how to hit my station. Sox is taking the raw output of that and encoding it, and cvlc is my transmitter. On the iPad, I've asked VLC to play the stream from http://10.55.0.1:8080/audio.ogg and I get to hear my station.

It has some occasional issues where the audio drops, and I'm working through that. My intention is to also pipe my Pi's pulseaudio output to the same method so that I can hear what it's doing; that's my last impediment to running DOSBox with audio and without shenanigans using iPad Dev Mode and signing packages every seven days. Need to remember this link.