Category: General Silliness

  • Logitech and Solaar

    I have a Logitech keyboard K380s, mouse M350s (pebble) kit, which I used on my StarLite tablet with Bluetooth.

    When i wanted to use the included “Logitech Bolt” USB dongle, none of the two peripherals wanted to connect using the dongle.

    After some taking batteries out, disabling Bluetooth on the computer, turning things on and off, the keyboard connected. I don’t know how and why.

    The mouse seemed lost, or maybe not paired with the dongle.

    (more…)
    Fediverse Reactions
  • WordPress drama

    As a WordPress user for two-decades, I have followed the latest drama in the WordPress world with some attention.

    WordPress founder Matt Mullenweg has been lashing out against WP Engine, a competitor to his own company Automattic. Both engage in large-scale hosting of small websites, based on modified versions of the open-source WordPress software.

    The whole debacle has revealed what a sordid mess the governance of the WordPress project is.

    (more…)
  • Post length with ActivityPub

    Many WordPress web-sites now use the ActivityPub plugin, which federates the web-site with the rest of the Fediverse.

    I’ve quite come to like the idea of such an integration — if only people would comment some more 🙂

    What has bothered me a bit, is that plenty of Fediverse posts coming from WordPress blogs contain the entire post, which is sometimes very long. Get a few of those in a search result on your phone, and you’ll be scrolling a lot for very little gain.

    The problem is that when configuring the ActivityPub plugin, the only options are either the entire content, or just the excerpt. If you actually use the excerpt field as intended, that’s either everything or at most 150 characters.

    We need something in between. Fortunately, there’s a way.

    Shortcodes

    Luckily, the things that look like shortcode in the ActivityPub plugin settings, actually are shortcodes.

    This means that it is straightforward to make another shortcode to send the ‘right’ amount of text to the Fediverse.

    Add to that some of the latest additions to the WordPress API — the WP_HTML_Tag_Processor class — and it is not that difficult to extract and sanitize bits of a post to create an automatic excerpt of intermediary length.

    A code example

    Below is an example which works for me on some sites.

    I often write a few paragraphs of introduction before the first header, and the idea is to extract those paragraphs, sanitizing the code to make sure only basic HTML gets through.

    The code below imposes a character limit, so a post without any header won’t get too long.

    It always selects entire paragraphs, within the character limit.

    HTML tags for simple text markup are reduced to the basics. It will pass bold and italics and links. Figures and images are removed. It handles the markup WordPress generates for footnotes and multilingual texts.

    It doesn’t expand the post content completely, so patterns aren’t expanded. This is on purpose, as I have a site with various boxes in the margins, which I don’t want included.

    
    /************************************************************
     *
     * Generate a longer excerpt of a post with limited markup.
     *
     * It extracts leading paragraphs from the content, outputting
     * always a set of whole paragraphs, within the character
     * limit of $max_length.
     *
     * Processing stops at any unrecognised tag, such as
     * headers, lists, blockquotes etc., and at the <!--more-->
     * marker to allow manual intervention.
     *
     ************************************************************/
    
    function generate_excerpt( $post, $max_length = 1000 ) {
        $post = get_post( $post );
    
        // Expand in-text shortcodes but not blocks/patterns
        $input = do_shortcode( $post->post_content );
    
        $paragraphs = [];        // found paragraphs
        $buffer = '';       // output buffer
    
        $done = false;
    
        $parser = new \WP_HTML_TAG_Processor( $input );
        while ( !$done && $parser->next_token() ) {
    
            switch ( $parser->get_token_type() ) {
            case '#text':
                $buffer .= $parser->get_modifiable_text();
                break;
    
            case '#comment':
                if ( 'more' === $parser->get_modifiable_text() )
                    $done = true;
                break;
    
            case '#tag':
                $tag = $parser->get_token_name();
    
                switch ( $tag ) {
                case 'I':   // Copy along
                case 'EM':
                case 'B':
                case 'STRONG':
                    if ( $parser->is_tag_closer() )
                        $buffer .= "</$tag>";
                    else
                        $buffer .= "<$tag>";
                    break;
    
                case 'A':   // Copy with href
                    if ( $parser->is_tag_closer() )
                        $buffer .= "</$tag>";
                    else {
                        $href = $parser->get_attribute( 'href' );
                        $buffer .= sprintf( '<A HREF="%s">', $href ?? '' );
                    }
                    break;
    
    
                case 'SUP':
                case 'FIGURE':
                    // Footnote and figure markup -- ignore
                    // everything up to the closing tag -- This is
                    // very primitive - sorry!
                    if ( $parser->is_tag_closer() )
                        $buffer = $stashed;
                    else
                        $stashed = $buffer;
                    break;
    
                case 'IMG':
                    // Images -- skip the markup
                    break;
    
                case 'BDO':
                    // Text in other languages -- skip the markup
                    break;
    
                case 'P':
                    if ( $parser->is_tag_closer() ) {
                        // Take into account <P> </P> and a newline
                        $max_length -= strlen( $buffer ) + 8;
                        if ( $max_length >= 0 )
                            $paragraphs[] = trim( $buffer );
                        else
                            $done = true;
    
                        $buffer = '';
                    }
                    break;
    
                default:
                    // Unknown markup will stop processing, but
                    // also ditch the partially processed
                    // paragraph. This might not be optimal, but
                    // it resolves the problem of having
                    // surprising breaks in the text.
    
                    $done = true;
                }
            }
        }
    
        if ( empty( $paragraphs ) )
            return get_the_excerpt( $post );
    
         return '<P>' . join( "</P>\n<P>", $paragraphs ) . '</P>';
    }
    
    

    Lastly, a thank you to @pfefferle@mastodon.social for the ActivityPub plugin, which is fantastic.

    Fediverse Reactions
  • Merry Christmas

    Merry Christmas

    René in the Grande Canal at Christmas

    Merry Christmas God Jul Buon Natale

  • A Roman boy in 1912

    A Roman boy in 1912

    I’m currently listening to a podcast on the Byzantine Empire, which is very interesting.

    An episode discussing the identity of the people of the Byzantine Empire mentioned a story of a little boy on an island that had been part of the Ottoman empire but was passing to Greece. A Greek soldier met a small boy who asked him: “What are you?”. “I’m Greek like you” the soldier answered. The boy replied “No, I’m Roman.”

    A self-image of being “Roman” almost 500 years after the fall of the Byzantine Empire.

  • 2012

    2012

    I haven’t updated this blog for ages, too much work generally, which naturally gives me no right to complain. To compensate I have picked a one or two photos from each month of 2012, showing a bit of what I’ve been doing this past year.

    January

    In January I was back in Denmark to see family, and also to see ‘my’ dog from back when I lived there. Jamil, a beautiful eight year old beagle, is now living with my ex-wife, but he is being taken good care of, and even if I already knew that would be the case, it was nice to see him again after several years.

    February

    The Italian sea kayak association Sottocosta has a yearly meet-up of the Italian sea kayak coaches, and I was invited to participate even though I don’t have an Italian coaching award. The meeting was held on the Island of Elba, which is a marvel of Mediterranean beauty, and I got to know a lot of the Italian coaches.

    March

    Since I moved to Venice several years ago I’ve been living in a lot of different places, rented rooms and apartments, on informal or short-term contracts, but in March I finally found a home. By a lucky stroke I found a small and affordable apartment smack in the middle of Venice, on one of the most beautiful historical squares of the city, the Campo S.S. Giovanni e Paolo. It is so very nice not being a nomad any more.

    April

    Kayaking season in Venice usually starts in late March or April, depending on the date of Easter. Last year we started doing tours in earnest in mid April, and we continued doing tours until November. By now I’ve been paddling down the Canal Grande several hundred times, and I’ve had many thousands paddlers from all over the world with me.

    May

    The main rowing and paddling event in Venice is the Vogalonga, which usually happens in May. This year I didn’t participate myself, but stay on the Certosa island to send people off and take over when they came back in again. In there 2012 Vogalonga there were over 1800 boats registered, and some 6-7000 persons.

    June

    We were rather unfortunate in June last year. A tornado (EF2) hit parts of Venice and a bunch of lagoon islands, including ‘our’ island of Certosa. Where the were no damages in the marina, our gear took a straight hit, and when I came out to the island later, the kayaks were strewn all over, some tossed as far as 50m, and others thrown up into the air to come down as missiles on the other boats. We lost a few boats, and still have damages to repair on some, but we were very lucky and we were back to work two days after the tornado.

    July

    I haven’t had a summer holiday for years, since I started Venice Kayak, but this year, thanks to the concerted effort of my partner Marco and our guide Loretta, I had the chance to go to Canada to see my good friend Steve Lutsch, participate in the Great Lakes Sea Kayak Symposium, and get around to see a tiny bit of the fantastic country that is Canada. The photo above is from Flowerpot Island, near Tobermory on the Bruce Peninsula in Ontario.

    August

    Having found an apartment and finally having a bit of stability in my life, next step was to adopt a dog, and I was very lucky to find Stella up for adoption in Venice. She was one year and a half old, but since her first owners hadn’t been too bright, she’d had cubs twice in her short life. She is now sterilized, slightly overweight but fairly happy, I think. I still need to teach her to not eat all the rubbish she finds on the alleyways and squares in Venice.

    September

    The Regata Storica – the Historic Regatta – is one of the main events in September, but after five years in Venice I still hadn’t seen one. Last year we finally paddled down there, found a good spot and enjoyed the show and the races. Later the same month we went rowing ourselves, with a Dutch group of paddlers from Zwalker.nl. I’ve always enjoyed Venetian rowing, but too much moving around meant I haven’t rowed much for several years. That is definitely one of the things I want to chance in 2013.

    October

    Venice Kayak regularly ends up in the press around the world, but not all papers are equal. In October Venice Kayak was featured in the Sunday Times travelling section, and it can hardly get much bigger than that. October was also the month when I met a beautiful girl who just so happened to drop by on the Certosa island with her friends (this photo is from December in the Tivoli garden in Copenhagen).

    November

    Living in the middle of Venice brings a wide variety of experiences. Last year saw several occasions of high tide flooding the city, including the sixth-highest level ever measured. The damages caused by the high water are immense, and go far beyond the nuisance of walking in knee deep water to get milk, or tourists swimming and diving in St.Mark’s square. This photo shows people getting about their daily affairs in the Via Garibaldi. Not glamorous at all.

    December

    In December I was back in Denmark again for a very short visit. After the tornado had damaged my favourite kayak and I had tried a Valley Pintail, I had ordered one from Valley, through Kajakhotellet in Copenhagen. The Pintail is no longer in production, Valley stopped taking orders at the end of August, and my new Pintail in the colours of the flag of Venice is probably the last Pintail to be ever made. Since we had room on the car for more, we also picked up a Valley Nordkapp LV. I’m so looking forward to paddling this beauty around Venice in the coming years.    
  • Confirmed: He Who Sits the Most Dies the Soonest

    Confirmed: He Who Sits the Most Dies the Soonest

    I imagined that spending half my life kayaking would be good for my health, and then this news appears:

    http://www.theatlantic.com/health/archive/2012/04/confirmed-he-who-sits-the-most-dies-the-soonest/256101/

    maybe its time to look more into stand up paddling, or rather, given my current residence, Venetian rowing.

  • Cat and mouse

    Cat and mouse

    What does a cat do with a mouse? image (more…)