Skip to content

Instantly share code, notes, and snippets.

MPV Radio

A bash script that turns mpv into a radio.

Requirements

  • mpv: to play the stream
  • dmenu: to choose radio stations
  • jq: to parse IPC responses from mpv
@kmwenja
kmwenja / radio
Created April 24, 2019 07:55
MPV Radio
#!/bin/bash
# initialize a fifo file to control what station mpv is playing
MPVFIFO=$HOME/.radio/mpv
if [[ ! -p $MPVFIFO ]]; then
mkfifo $MPVFIFO
fi
# select the radio station to start playing
STATION_NAME=$(cat .radio/stations | awk -F ',' '{print $1}' | dmenu -p 'Choose station:')
@kmwenja
kmwenja / N-Gram Similarity
Last active December 4, 2018 06:15
N-Gram Similarity
An experiment doing n-gram similarity.
Usage:
`$ python trigram.py '<left string>' '<right string>' <number of letters in a gram>`
Example:
```
$ python trigram.py 'hello' 'hallo' 3
@kmwenja
kmwenja / Life Token for Goroutines
Created October 31, 2017 09:17
Life Token for Goroutines
A tactic for managing long lived goroutines by handing them a "life" token.
The goroutines can check if the token "is dead" and quit while signalling that they have quit.
See `main.go` for an example usage.
@kmwenja
kmwenja / Python Memory Profiling
Last active July 10, 2017 08:31
Python Memory Profiling - A Quick Demo
Quick Demo of Python Memory Profiling
@kmwenja
kmwenja / tmux-monitor
Last active December 17, 2022 14:58
Tmux script for active server monitoring
Tmux Script for Active Server Monitoring
@kmwenja
kmwenja / Python and DLLs
Last active November 25, 2016 04:04
Use linux dynamic libraries in python. First run `make` then `python main.py`
Using linux dlls in python.
1. `make`
2. `python main.py`
@kmwenja
kmwenja / row_diff.py
Created August 5, 2014 12:24
Difference between the column value of 2 rows
def row_diff(rows, column_position):
"""
gets the difference between 2 row values
"""
# the column position parameter starts to count from 1
# so have to make it start counting from 0
column_position = column_position - 1
results = []
prev_value = None