メモ

Table of Contents

1. NFS

My NFS mounts over wireguard weren't working one day from work, so I ran rpcinfo -p 10.0.0.9, which should ouput info like this:

program vers proto   port  service
    100000    4   tcp    111  portmapper
    100000    3   tcp    111  portmapper
    100000    2   tcp    111  portmapper
    100000    4   udp    111  portmapper
    100000    3   udp    111  portmapper
    100000    2   udp    111  portmapper
    100024    1   udp  45789  status
    100024    1   tcp  36707  status
    100005    1   udp  20048  mountd
    100005    1   tcp  20048  mountd
    100005    2   udp  20048  mountd
    100005    2   tcp  20048  mountd
    100003    4   tcp   2049  nfs

,but it actually printed out this:

program vers proto   port  service
    100000    4   tcp    111  portmapper
    100000    3   tcp    111  portmapper
    100000    2   tcp    111  portmapper
    100000    4   udp    111  portmapper
    100000    3   udp    111  portmapper
    100000    2   udp    111  portmapper
    100024    1   udp  45789  status
    100024    1   tcp  36707  status

Apparently mountd, the actual nfs shares server, wasn't started, so I ssh'd into the server and ran systemctl stop nfs-server which finished, but then running systemctl start nfs-server failed, so I checked journalctl -xe and it showed that a systemd mount unit was failing for one of my disks (maybe it's dead), so I commented it out of my fstab and ran systemd daemon-reload. After that, I ran systemd start nfs-server which worked this time. Then I checked the output of the rpcinfo command above and it displayed the first block, with the mountd entries. Finally mounting NFS shared works.

2. Nix

2.1. Pitfalls when reinstalling Nix

I'm running the Nix package manager on Arch Linux on a chromebook. The built-in storage is relatively small and I ran out of disk space when installing the Haskell toolchain. So I thought the only safe way to recover would be to run Nix's garbage collector, which did free up disk space, but then on my next attempt at a home-manager switch, I kept getting an error about missing "zip" functions or something, and I think non-home-manager Nix stuff kept working. So I thought maybe the garbage collector deleted something belonging to home-manager (I installed it as a channel, following this guide), or maybe the store reference database got corrupted (that's what happened when I ran out of disk space while using Guix). Reinstalling home-manager didn't fix the problem, so I decided to reinstall Nix entirely.

I found the official uninstall directions, and just copied and pasted the commands. It didn't explicitly mention that you need to remove Nix-created files and links from your home directory, so I cluelessly left those files in place and tried the official install script and the one from Determinate Systems, but both failed with an error about not finding a lock file related to my user. I eventually realized it's probably related to the references to the Nix store and other Nix-created files in my home directory, so I used find /home/anon -iname '\*nix\*' to find Nix related stuff besides the harmless config files under ~/.config. Then I ran:

rm -rf ~/.local/share/nix/ ~/.cache/nix/ ~/.nix-channels ~/.nix-defexpr ~/.nix-profile

This should remove all artifacts of the previous Nix installation from your home directory. Now Nix successfully reinstalls. The next hurdle was home-manager not installing. The error message said something about ~/.local/state/nix/profiles/channels/home-manager, so I thought "aha, more hidden state directories/links to the previous Nix store", and I tried removing it but accidentally removed the entire state directory: ~/.local/state/. Now on my next home-manager install attempt, I got:

適切なプロファイル ディレクトリが見つかりませんでした。/home/anon/.local/state/home-manager/profiles と /nix/var/nix/profiles/per-user/anon を試しました

(My locale is set to Japanese for full immersion and forced language learning.) It says it couldn't find these directories. So I created them:

mkdir -p /home/anon/.local/state/home-manager/profiles
mkdir -p /nix/var/nix/profiles/per-user/anon # run as root

Finally, home-manager too now installs without error.

Moral of the story is that, yes, Nix and Guix keep everything (packages and their related files) centrally located in the store and in their database and profile directories under /var. This is better than non-functional package managers which spew files all over /etc/, /bin/, etc., without the ability to cleanly roll-back. But conversely, Nix and Guix do spew stateful data and references to the store into several hidden directories in your home directory. Remember to remove them if a reinstall is necessary.

Actually, looking back, maybe I didn't run the garbage collector correctly, or maybe I should have tried a roll-back first; not sure if that would have helped in an out-of-disk-space situation, but I'll try it if it happens again.

3. Haskell

3.1. Create a project using Nix

$ nix-shell -p "haskellPackages.ghcWithPackages (pkgs: with pkgs; [ cabal-install ])" --run "cabal init"

Then create default.nix:

let
  pkgs = import <nixpkgs> { }; # pin the channel to ensure reproducibility!
in
  pkgs.haskellPackages.developPackage {
    root = ./.;
  }

Build and run the project:

$ nix-build
$ ./result/bin/yourprogram

Nix will automatically read the build-depends field in the *.cabal file to get the name of the dependencies and use the haskell packages provided in the configured package set provided by nix.

Details at https://nixos.wiki/wiki/Haskell under "Using developPackage (use the nix packages set for haskell)"

3.2. Add non-haskell nix packages to nix-shell environment

You need to set developPackage's modifier attribute to a function that takes a derivation drv and evaluates pkgs.haskell.lib.addBuildTools drv [extra packages].

let
  pkgs = import <nixpkgs> { }; # pin the channel to ensure reproducibility!
in
pkgs.haskellPackages.developPackage {
  root = ./.;
  modifier = drv:
    pkgs.haskell.lib.addBuildTools drv (with pkgs.haskellPackages;
      [cabal-install
       ghcid]);
}

4. How to download twitter videos, for Falkon users

Falkon is basically a slimmed down chromium by the KDE project. I use it because its start up time is faster and, most importantly, for it's more minimal UI.

Downloading twitter videos used to be a simple yt-dlp <post-url>, but now you need to be signed-in and use the --cookies-from-browser <browser> option. As of now, there's support for chromium but not falkon, but since falkon is just reskinned chromium, all you need to do is cd ~/.config/; ln -s falkon chromium. This makes a chromium alias for falkon's config directory. yt-dlp --cookies-from-browser chromium https://twitter.com/i/status/1693846836724060475 now works since it can find a chromium config directory. Add --cookies-from-browser chromium to ~/.config/yt-dlp/config so you don't have to write the option on the command line.

Oddly, at least on my system, mpv still can't play twitter videos when given the twitter post url, so you have to download it first with yt-dlp, then run mpv on it.

5. How to watch WNI AU Pay Market streams on desktop

AU Pay tries to make you watch on a phone by refusing to deliver the stream page to desktop browsers, so you have to do the following:

  1. An anon found a link like this on AU Pay's site. https://wowma.jp/event/live-tv/live.html?id=10213&spe_id=livelp_program.
  2. Change your desktop browser's user agent string in settings to the first one on this page https://qiita.com/niwasawa/items/21b12f5fd0541837d887. If that link doesn't work just search for "iphone user agent string".
  3. Visit the stream page from step 1. You'll get the mobile site.
  4. Find the stream's video player and right click on it. Inspect element.
  5. Under the HTML5 video element, the source element has the raw .m3u8 stream url.
  6. Watch that url with mpv or vlc.
  7. Unset the fake user agent string. This step is necessary because 4chan wouldn't give me a captcha until I did so, and anyways, I would keep getting mobile versions of sites if I didn't.

UPDATE: Firefox and Chromium have easy user agent switches either built-in or as extentions. Also, it seems that https://live.check.tv/live1/index.m3u8 is always the link to the current live stream. Visit https://gg.vern.cc/wn/segment/?n=au%20PAY for links to VODs

6. Japanese announcer names

With notes on how to type their kanji when my input method doesn't suggest the right one.

7. Japanese idol and athlete names

8. 日本語

9. SQL

10. Emacs

10.1. Syntax highlighting in org-mode html output

Nix's Emacs package doesn't come with emacs-htmlize, so add it to your emacs packages list in your home-manager config.

11. git

12. wireguard

13. network debugging

  • nmap -Pn <host> -p 22 to check if ssh is open
  • -T and -I options to traceroute to use TCP and ICMP

14. VP9 encoding

15. Change framerate in ffmpeg without reencoding

https://superuser.com/questions/1689046/ffmpeg-force-re-generate-pts-i-e-alter-frame-rate-without-re-encoding-on-any You can do this using the bitstream filter setts. This also avoids the hassle of writing a raw stream out to a file, then remuxing it. This works because while you can't use normal filters with codec copy (-c:v copy) since they work on the decoded video stream, you can use bitstream filters which work on the encoded stream.

For example to change frame rate to 60 fps, insert

-bsf:v setts=ts=STARTPTS+N/TB_OUT/60

This should set both pts and dts without decoding the stream. If you have a variable frame rate video you may need something like this instead

-bsf:v setts=ts='if(PREV_OUTPTS+9223372036854775808\,PREV_OUTPTS\,STARTPTS)+PREV_OUTDURATION*2'

This modifies the durations of the frame instead of assuming each frame has a constant duration. The odd looking if expression is to ensure the first frame is offset correctly, since PREVOUTPTS is set to -9223372036854775808 (min value of 64-bit int) during the first frame, and we need to replace it with zero.

If you have B-frames, this may mess up decoding since dts may need to be smaller than pts, but it seems to work fine for me anyways. You can try replace setts=ts with setts=pts if you run into trouble. See https://ffmpeg.org/ffmpeg-bitstream-filters.html#setts for details

16. 4chan archivers

  • warosu.org has ​/jp​/ and archives the images too
  • archived.moe also has ​/jp​/ but doesn't archive the images
  • 4plebs.org doesn't have ​/jp​/ but I used it once for ​/tv​/

17. Useful links

18. Why pta?

Fan of idol groups Peel the Apple and Perfume. "ske", after SKE48, would have been a good account name too.


This page is written in emacs's org-mode. Replace .html with .org to see the org source. Last modified 2023-12-27