paulox, to ubuntu
@paulox@fosstodon.org avatar

🚀 I just published a short guide explaining how to upgrade PostgreSQL 🐘 from version 15 to 16 just after an upgrade to Ubuntu 24.04 LTS (Noble Numbat) 🦘

Read it 👇
https://www.paulox.net/2024/05/20/upgrading-postgresql-from-version-15-to-16-on-ubuntu-24-04-noble-numbat/

3sat, to HowTo German
@3sat@zdf.social avatar
Taffer, to HowTo
@Taffer@mastodon.gamedev.place avatar

New post - Linux Roundup https://taffer.ca/posts/2024/linux-roundup/

A description of various Linux distros that I’ve used, which might help someone else pick one.

tallship, to foss
@tallship@stella.place avatar

Here's a short, simple, and straightforward guide to installing the Mitra Fediverse Server.

I hope that helps :)

Enjoy!

.

WetHat, to HowTo
@WetHat@fosstodon.org avatar

Advanced C# Tricks for Developers 🔥 | Medium

Ten methods to boost code efficiency and readability for experienced developers.

https://medium.com/@kmorpex/10-advanced-c-tricks-for-experienced-developers-26a48c6a8c9c

Edent, to HowTo
@Edent@mastodon.social avatar

🆕 blog! “link rel="alternate" type="text/plain"”

Hot on the heels of yesterday's post, I've now made all of this blog available in text-only mode. Simply append .txt to the URl of any page and you'll get back the contents in plain UTF-8 text. No formatting, no images (although you can see the alt text), no nothing! Front page https://shkspr.mobi/blog/.txt This blog […]

👀 Read more: https://shkspr.mobi/blog/2024/05/link-relalternate-typetext-plain/

blog, to HowTo
@blog@shkspr.mobi avatar

link rel="alternate" type="text/plain"
https://shkspr.mobi/blog/2024/05/link-relalternate-typetext-plain/

Hot on the heels of yesterday's post, I've now made all of this blog available in text-only mode.

Simply append .txt to the URl of any page and you'll get back the contents in plain UTF-8 text. No formatting, no images (although you can see the alt text), no nothing!

This was slightly tricky to get right! While there might be an easier way to do it, here's how I got it to work.

Firstly, when someone requests /whatever.txt, WordPress is going to 404 - because that page doesn't exist. So, my theme's functions.php, detects any URls which end in .txt and redirects it to a different template.

//  Theme Switcheradd_filter( "template_include", "custom_theme_switch" );function custom_theme_switch( $template ) {    //  What was requested?    $requested_url = $_SERVER["REQUEST_URI"];    //  Check if the URL ends with .txt    if ( substr( $requested_url, -4 ) === ".txt")  {            //  Get the path to the custom template        $custom_template = get_template_directory() . "/templates/txt-template.php";        //  Check if the custom template exists        if ( file_exists( $custom_template ) ) {            return $custom_template;        }    }    //  Return the default template    return $template;}

The txt-template.php file is more complex. It takes the requested URl, strips off the .txt, matches it against the WordPress rewrite rules, and then constructs the WP_Query which would have been run if the .txt wasn't there.

//  Run the query for the URl requested$requested_url = $_SERVER['REQUEST_URI'];    // This will be /whatever$blog_details = wp_parse_url( home_url() );  // Get the blog's domain to construct a full URl$query = get_query_for_url(     $blog_details["scheme"] . "://" . $blog_details["host"] . substr( $requested_url, 0, -4 ));function get_query_for_url( $url ) {    //  Get all the rewrite rules    global $wp_rewrite;    //  Get the WordPress site URL path    $site_path = parse_url( get_site_url(), PHP_URL_PATH ) . "/";    //  Parse the requested URL    $url_parts = parse_url( $url );    //  Remove the domain and site path from the URL    //  For example, change `https://example.com/blog/2024/04/test` to just `2024/04/test`    $url_path = isset( $url_parts['path'] ) ? str_replace( $site_path, '', $url_parts['path'] ) : '';    //  Match the URL against WordPress rewrite rules    $rewrite_rules = $wp_rewrite->wp_rewrite_rules();    $matched_rule = false;    foreach ( $rewrite_rules as $pattern => $query ) {        if ( preg_match( "#^$pattern#", $url_path, $matches ) ) {            $matched_rule = $query;            break;        }    }    //  Replace each occurrence of $matches[N] with the corresponding value    foreach ( $matches as $key => $value ) {        $matched_rule = str_replace( "$matches[{$key}]", $value, $matched_rule );    }    //  Turn the query string into a WordPress query    $query_params = array();    parse_str(        parse_url( $matched_rule, PHP_URL_QUERY),         $query_params    );    //  Construct a new WP_Query object using the extracted query parameters    $query = new WP_Query($query_params);    //  Return the result of the query    return $query;}

From there, it's a case of iterating over the posts returned by the query. You can see the full code on my GitLab.

https://shkspr.mobi/blog/2024/05/link-relalternate-typetext-plain/

CppCon, to HowTo
@CppCon@mastodon.social avatar

We have released a new CppCon 2023 Video!

Lightning Talk: Writing a Better std::move – by @foonathan- CppCon 2023
https://youtu.be/hvnl6T2MnUk

GregCocks, to Battlemaps
@GregCocks@techhub.social avatar
Taffer, to HowTo
@Taffer@mastodon.gamedev.place avatar

New post - Auto-deploy: Hugo and Codeberg CI https://taffer.ca/posts/2024/hugo-ci/

A description of how I’ve set up Codeberg’s CI to automatically build and deploy changes to my website.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • anitta
  • kavyap
  • DreamBathrooms
  • InstantRegret
  • magazineikmin
  • cubers
  • GTA5RPClips
  • thenastyranch
  • Youngstown
  • rosin
  • slotface
  • tacticalgear
  • ethstaker
  • modclub
  • JUstTest
  • Durango
  • everett
  • Leos
  • provamag3
  • mdbf
  • ngwrru68w68
  • cisconetworking
  • tester
  • osvaldo12
  • megavids
  • khanakhh
  • normalnudes
  • lostlight
  • All magazines