Skip to content

Instantly share code, notes, and snippets.

@SydLambert
SydLambert / firefox-get
Created December 16, 2022 23:36
Simple script to manually install Firefox to the /opt/ directory on GNU/Linux. Also handles updating. Primarily here for my own reference, use it if you'd like, I made it quickly so there are definitely things to improve. Requires wget. I recommend purging other Firefox installs beforehand. This script doesn't touch your profile directory.
#!/usr/bin/env bash
# Syd Lambert 2022, sydlambert.com
usage () {
cut -c 5- <<EOF
Usage:
$(basename $0) command [options]
A simple script for manual installation of Firefox to the /opt/ directory.
@SydLambert
SydLambert / somafm-download-playlists.sh
Created October 9, 2022 16:53
Download the playlist files for all SomaFM stations into the current directory
#!/usr/bin/env sh
curl -s https://somafm.com/channels.xml | grep -Po '((?<=<title><!\[CDATA\[).+?(?=\])|(?<=id=").+?(?="))' | sed 'N;s/\n/ /' | while read -r p; do
stationName=$(echo "$(echo "$p" | grep -Po '(?<= ).+$')" | perl -ple '$_=lc; s/[^\w\s]//g; s/ /-/g')
echo "Downloading $stationName"
curl -s "https://somafm.com/$(echo "$p" | grep -Po '^.+?(?= )')130.pls" > "$stationName.pls"
done
@SydLambert
SydLambert / somafm-mpd-playlists.sh
Created May 2, 2020 18:59
Add all channels on Soma FM to MPD as individual playlists. Requires mpc and GNU grep. Will empty playlist before starting.
#!/usr/bin/env sh
mpc clear
curl -s https://somafm.com/channels.xml | grep -Po '((?<=<title><!\[CDATA\[).+?(?=\])|(?<=id=").+?(?="))' | sed 'N;s/\n/ /' | while read -r p; do
curl -s "https://somafm.com/$(echo "$p" | grep -Po '^.+?(?= )')130.pls" | grep -Po '(?<=File\d=).+$' | head -n 1 | xargs mpc add;
mpc save "Soma FM - $(echo "$p" | grep -Po '(?<= ).+$')"
mpc clear
done
@SydLambert
SydLambert / README.md
Created December 29, 2019 00:31
A Perl program to scrape all texts from Typeracer.

typeracer-text-scraper.pl

A Perl program to scrape all texts from Typeracer. Made with quick regular expressions, so no guarantees it will still work if they change their UI.

Installation

This program requires the following non-core Perl modules:

  • LWP::Simple
  • Mozilla::CA
  • JSON
@SydLambert
SydLambert / tp.sh
Last active May 17, 2019 20:47
Bash script to toggle the trackpad in xinput
#!/usr/bin/env bash
case "$1" in
id)xinput | grep TouchPad | grep --color=never -Po "(?<=id=)\\d+(?=\\t)" ;;
off);&
on)xinput set-prop "$($0 id)" "Device Enabled" "$([ "$1" = 'on' ]&&echo 1||echo 0)";;
*)echo "Usage: $0 {id|off|on}"
esac