aboutsummaryrefslogtreecommitdiff

The repository contains a collection of random scripts and short programs.

Requirements

  • Ruby 3 for Ruby scripts.
  • For Haskell: The GHC compiler and cabal build system. The programs can be then built and run with cabal run program-name -- --options.

Contents

  1. 7digital
  2. cross_toolchain.rb
  3. rename.rb
  4. pg_jekyll.rb
  5. locopy

7digital

7digital sells digital music but they can't handle files with non-English names.

7digital takes 2 arguments, a zip archive with audio files and a target directory. It extracts the archive into the directory and renames its contents according to the meta information saved in the audio files. The audo file format is "{2-digit track number} - {song title}.{extension}". Each file is put into a subdirectory named after the album.

cross_toolchain.rb

bin/cross_toolchain.rb builds a cross toolchain for 32-bit RISC-V (G). The script should work on Mac OS with preinstalled GNU tools and case-sensitive file system and Linux. The resulting GCC is to be found in ./tmp/rootfs/bin/riscv32-unknown-linux-gnu-*.

rename.rb

Changes the extension of all files matching a pattern in the given directory. Call the rename.rb without arguments to see the usage information and an example.

pg_jekyll.rb

This script was used to migrate blog posts from a PostgreSQL database to a static site generator in Jekyll-like format. pg_jekyll.rb cannot be used as is: the query and columns should be adjusted for a concrete case, but it can be a starting point and example for such a migration. Also it expects environment variables USER and DBNAME to be present in the environment.

Pages are written into the posts/ directory. A column named slug is used for the name with .html extension.

locopy

locopy updates Wordpress siteurl and home options and sets them to some address, so that the Wordpress instance can run locally.

locopy reads Wordpress database configuration from the wp-config.php that it should be able to find. Invokation example:

locopy wordpress --root /path/to/wordpress --siteurl "http://localhost:8083"