Categories
Uncategorized

Thunderbird Fonts & Colors

Saving this as a post here for my future reference.

The key to getting the “default” fonts to apply to plain-text (and all mails with the allow messages to use other fonts setting off) is also changing the fonts for Other Writing Systems.

Why is it like this? Who knows!

This answer brought to you by a semi-not-recent reddit thread.

[–]Yukness   2 points 3 years ago

The display fonts are set in the Advanced section of Language & Appearance in Options. Did you set the fonts with Fonts for-Other Writing Systems? If not, that might explain why Unicode plain text in received mail doesn’t look like what you specified.

Shoutout to /u/Yukness for this one!

Categories
Uncategorized

Mastodon Admin Notes

This is the cron job that runs daily to do media and federation data cleanup:

#!/bin/sh

printf "%s: running cleanup tasks\n" "$(date)"
RAILS_ENV=production /home/mastodon/.rbenv/shims/ruby /home/mastodon/live/bin/tootctl media remove --days=7
RAILS_ENV=production /home/mastodon/.rbenv/shims/ruby /home/mastodon/live/bin/tootctl media remove --days=7 --remove-headers
RAILS_ENV=production /home/mastodon/.rbenv/shims/ruby /home/mastodon/live/bin/tootctl media remove --days=7 --prune-profiles
RAILS_ENV=production /home/mastodon/.rbenv/shims/ruby /home/mastodon/live/bin/tootctl media remove-orphans
RAILS_ENV=production /home/mastodon/.rbenv/shims/ruby /home/mastodon/live/bin/tootctl preview_cards remove --days=30

printf "%s: dumping db\n" "$(date)"
pg_dump -Fc mastodon_production | ssh rsync "dd of=mastodon/db.dump"

date

This is the wrapper script I use to make sure I restart all necessary processes after updates.

root@mastodon:~# cat /usr/local/bin/masto
#!/bin/sh

case $1 in
        start|restart|stop|status)
                printf "%sing mastodon services\n" "$1"
                ;;

        logs)
                exec journalctl -fu mastodon-\*
                ;;
        *)
                printf "%s: invalid action. try logs, status, start, stop, restart.\n" "$1"
                exit 1
                ;;
esac

exec systemctl $1 mastodon-web \
        mastodon-streaming \
        mastodon-sidekiq@default \
        mastodon-sidekiq@pull \
        mastodon-sidekiq@push \
        mastodon-sidekiq@mailers \
        mastodon-sidekiq@scheduler \
        mastodon-sidekiq@ingress

The mastodon-sidekiq@.service units were added to address queues backing up and is essentially the same as the default unit file but with the -q queue name parameter added.

Categories
Uncategorized

tilde.team subdomains as bluesky handles

This is a quick tutorial on using your tilde.team subdomain as a handle on bluesky. Domain verification on bluesky can be done with a DNS challenge or by serving a text file from .well-known in your webroot.

Since adjusting the Content-Type for plaintext files with no extension isn’t possible without changing global nginx configs, the quickest way is to use a tiny php script.

<?php header("Content-Type: text/plain");
echo "did:plc:v7tbr6qxk6xanxzn6hjmbk7o";

Make sure that the following directory exists ~/public_html/.well-known/atproto-did and put the above script in there as index.php, replacing the did with your own.

Then go to Settings > Change Handle on bsky.app, pick “I have my own domain”, then pick the No DNS Panel tab. Enter your subdomain and hit Verify Text File.

You can use any of the domains that are hooked up to your ~/public_html. See the list on the tilde.team wiki.

Here’s the source for mine on tildegit.

Categories
Uncategorized

WordPress block theme fragment offset

I just solved a slight visual bug on a wordpress site (tcpinball.org) with id permalinks.

I recently added made the site header sticky on there, which started covering the heading you jumped to when clicking a fragment id.

Here’s the solution:

[id] {
    scroll-margin-top: 80px;
}

You can add this CSS snippet in the block editor with the “Additional CSS” option in the global styles panel.

Easy fix without editing any theme or plugin files!

Categories
Uncategorized

git diff-highlight

Diff output from git can be hard to read. Luckily there’s a nice tool bundled with git that can help us out.

Enter diff-highlight, a little perl script found in git’s contrib directory.

From its own documentation:

[diff-highlight] post-processes the line-oriented diff, finds pairs of lines, and highlights the differing segments.

diff-highlight is shipped in a default git install but it needs to be bundled and added to your $PATH. Here’s how to do it on debian:

$ sudo make -C /usr/share/doc/git/contrib/diff-highlight
$ sudo ln -s /usr/share/doc/git/contrib/diff-highlight/diff-highlight /usr/local/bin/

Now you can pipe git’s diff output to to diff-highlight to get a better view of what actually changed.

git diff | diff-highlight

Optionally, you can configure git to use it all the time. Add the following to your ~/.gitconfig:

[pager]
log = diff-highlight | less
show = diff-highlight | less
diff = diff-highlight | less

See the documentation for more usage tips!

Categories
Uncategorized

WordPress with sqlite3

Update: there’s a proposal in WordPress core to merge sqlite support: https://make.wordpress.org/core/2023/04/19/status-update-on-the-sqlite-project/. The recommended way to use sqlite is currently by using the official plugin: https://wordpress.org/plugins/sqlite-database-integration/.


Running WordPress with sqlite is quick, easy, and can be much less system administration load as it eliminates the need for a separate database process.

Here’s how to run WordPress with sqlite using aaemnnosttv’s drop-in.

Set it up

  1. download https://wordpress.org/latest.tar.gz
  2. extract it into your webroot (something like /var/www)
  3. download db.php and add it to /var/www/yoursite/wp-content/
  4. follow the normal setup instructions but skip the database fields
  5. profit????

nginx config

Adjust configs as needed. Here’s an example.

snippets/ssl/benharri.org includes the block from certbot that points to the right cert and key.

server {
  listen 80;
  server_name benharri.org;
  return 307 https://$server_name$request_uri;
}

server {
  listen 443 ssl;
  server_name benharri.org;
  include snippets/ssl/benharri.org;
  index index.php index.html;
  root /var/www/benharri.org;
  client_max_body_size 100M;
  include /var/www/benharri.org/nginx.conf; #w3tc caching

  location / {
    try_files $uri $uri/ /index.php?$args;
  }

  location = /favicon.ico {
    log_not_found off;
    access_log off;
  }

  location ~* wp-config.php {
    deny all;
  }

  location ~ \.php$ {
    include snippets/fastcgi-php.conf;
    fastcgi_intercept_errors on;
    fastcgi_pass unix:/run/php/php8.2-fpm.sock;
  }

  location ~ /\.ht {
    deny all;
  }
}
Categories
Uncategorized

Default git branch name

Update:

As of git 2.28, there’s a new configuration option and you don’t need to use the templateDir option:

git config --global init.defaultBranch main

Changing git’s default branch name has come up recently as an easy action we can take to update our language and remove harmful ideas from our daily usage.

I’m concerned that this effort to change the language used is ultimately a symbolic gesture to avoid scrutiny into actual change (notably github’s push for this change and continued contracts with ICE).

However, it’s an easy change to make.

Let’s have a look at how to change it for new repos:

mkdir -p ~/.config/git/template
echo "ref: refs/head/main" > ~/.config/git/template/HEAD
git config --global init.templateDir ~/.config/git/template

Note that you can put this template dir anywhere you like.

You can also set this system-wide (not just for your user) in /usr/share, but note that this might get overridden by package updates.

echo "ref: refs/head/main" | sudo tee /usr/share/git-core/templates/HEAD

The next time you git init, you’ll be on a branch named main.

To change an existing repo, you can use the -m switch of git-branch:

git checkout master
git branch -m master main

Push with -u to your remote if needed and update the default branch in the repo settings in the hosting platform of choice.

It’s a relatively easy change, but don’t kid yourself that it makes any real impact. go protest, donate and sign petitions, and get out there to fix the actual problems.

Categories
Uncategorized

WeeChat Setup

So you decided to try WeeChat?

What options do you need to set? what plugins? what scripts?

I’ll go over some of the most essential of these, and share my full configs.

Options

  • logger.level.irc
    The default is 9, which includes joins and parts. In most cases you can set this to 3, which only includes messages.
  • weechat.look.buffer_notify_default
    The default here is all, which will add joins and parts to your hotlist. set it to message.
  • weechat.look.confirm_quit
    Set this to on. You’ll thank me when you type /quit and mean /close.
  • weechat.look.highlight
    Add a comma-separated list of names/terms you’d like to trigger a highlight here
  • weechat.look.prefix_align_max
    Set this to something between 10 and 20. Otherwise, long nicks will crush your available screen real estate.
  • buflist.format.indent
    Adjusts the display of your channel list. I use ${color:237}${if:${buffer.next_buffer.local_variables.type}=~^(channel|private)$?├:└} to print some nice unicode characters to draw nice guides.
  • buflist.format.number
    If you want to skip the . or space after the number, set it to ${color:green}${number}
  • irc.look.color_nicks_in_names
    Set this to on
  • irc.look.color_nicks_in_nicklist
    Set this to on
  • irc.look.server_buffer
    Set this to independent to prevent automatic merges with the core WeeChat buffer. Especially useful if you plan on using autosort.py
  • irc.server_default.autoconnect
    Set this to on so you don’t have to set it for every new network you add.

Scripts

These scripts can be managed with the built in /script tool. Press i, then enter on the selected script to install it.

  • highmon.pl
    Set aside a buffer to list the places your nick has been mentioned.
  • colorize_nicks.py
    Show nicks in chat with colors.
  • go.py
    Fuzzy quick jump by buffer number or channel name.
  • autojoin.py
    Use /autojoin --run to save all the channels you’re currently in to be autojoined the next time you start WeeChat.
  • autosort.py
    Use this script in tandem with irc.look.server_buffer=independent to keep your channel and server list in order.
  • colorize_lines.pl
    I use this script to highlight the entire line of messages I’ve been mentioned in. Check the options in the source or with /help colorize_lines.
  • grep.py
    Quickly search history and buffers with /grep.

The rest of my configs

You can find the rest of my configs here. Be sure to keep the WeeChat Documentation handy as well.

If you have any questions, feel free to ping me on IRC. I’m ben on libera and tilde.chat.

Screenshot

Here’s a screenshot of my current configs

Bonus

If you have an existing setup, you can check the config changes you’ve made with /set diff.

Additionally, feel free to use my .gitignore, add your ~/.weechat to source control, and compare.

Hope you’ve enjoyed customizing your WeeChat!

EDIT: s/freenode/libera/g

Categories
Uncategorized

Utteranc.es

I somehow stumbled upon utterances today at lunch. (I think someone had it forked on their github page).

No matter how I found it, I still decided to add it to my blog here with bashblog. Utterances is a commenting system that leverages github issues. For example, a comment on a post shows up on github like this.

Now we just need to figure out if it can be pointed at a gitea instance like tildegit. Might be time for a PR!

Categories
Uncategorized

Dotfiles

Finally got around to updating my dotfiles to use gnu stow. I adapted ~tomasino’s makefile for use with the configs that I’m keeping with it.

Now I just need to figure out why my ssh config doesn’t copy/symlink my config to ~/.ssh when it already exists.