Month: July 2022

  • 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!

  • 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;
      }
    }