techie

    I linux-ified my aging windows laptop over the weekend

    All good, in general, and I’ll be able to get another couple of years out of it

    I found that:

    • I had to run the installer twice before it worked

    • gpodder picked up all my subscriptions from gpodder.net, which was handy, because I’d forgotten to export the opml

    • I had to log out and back in again to get gpodder to save to the folder I specified

    • Spotify seems identical. I use custom order, which I wasn’t expecting to be there in the Linux version….I’m wondering whether it’s actually the windows version running under wine

    • it’s a shame PSClock won’t run

    • I installed the Mate desktop…I very much prefer that to the default Ubuntu one

    • I haven’t got gvim set up yet

    • or VS Code

    • or any powershell stuff beyond installing it

    ……but it’s all good

    Ubuntu mate wall paper with a new Brighton lighthouse apparently

    Today’s newly-acquired superpower is remembering that, in vim, ‘*’ jumps you to the next occurrence of the word the cursor is on. Super useful for jumping between a function and calls to that function.

    superman picking up a car

    This isn’t perfect, in that it doesn’t cope with the ‘nd’ in ‘2nd’, bit it’s good enough

    A vim mapping to insert the day and date as a header for notes, journals etc

    map <Leader>m :put =strftime('%A %dth %B %Y')<cr>:s/ 0/ /<cr>kJi## <Esc>
    

    #TodayILearned that:

    Initialisms are made from the first letter (or letters) of a string of words, but can’t be pronounced as words themselves (e.g. FBI, CIA). Acronyms are made from the first letter (or letters) of a string of words but are pronounced as if they were words themselves (e.g. NASA, hazmat). What I Learned: The Phoenix Project Audiobook - IT Revolution

    Personally, I’m not sure that this is a very useful distinction, but it’s interesting

    I guess ‘SQL’ is an initialism to those who pronounce it ‘S.Q.L’ and and acronym for those who say ‘sequel’.

    How to set default parameters for other people's Powershell cmdlets

    Not exactly #TodayILearned because I vaguely remember learning that you can do this, but had never got around to doing so.

    This is how you can set a default parameter in Powershell. As far as I know, it works with any cmdlet. I’m using it here to set the default for Pester to show me all the results of all the tests….because I love seeing that sea of green :)

    $PSDefaultParameterValues += @{ 'Invoke-Pester:Output' = 'Detailed' }
    

    #Powershell

    I got an email about HIMSS24. It stands for ' Healthcare Information and Management Systems Society 2024'….and I’m sure it’s marvellous, but being a sad, techie sort of geek I thought ‘HIMSS24’ looked like a datetime format gone wrong.

    Setting up a file-specific (not filetype-specific) colorscheme in vim

    Setting up a file-specific (not filetype-specific) colorscheme in vim is a two step process.

    First, you need a ‘modeline’[^1] in the file like this: [^1] a ‘modeline’ is a comment with vim instructions in it. My actual modeline for this file is ‘# vim: ft=readme syntax=markdown tabstop=2 shiftwidth=2 softtabstop=2 expandtab’. There’s some explanation of modelines here: https://vim.fandom.com/wiki/Modeline_magic

    # vim: ft=readme
    

    ‘ft’ here is, somewhat confusingly given my post’s title, short for filetype. The name of the filetype is kind-of arbitrary. It’s probably best to be descriptive, and better if it doesn’t correspond to an actual filetype like .md or ‘markdown’ or ‘txt’

    Second, you need like this in your vimrc

    autocmd FileType readme colorscheme peachpuff
    

    Why would I do such a thing

    I have a couple of ‘big old text files’ open most of the time.

    One is for general notes, and a record of what’s happened during the week. The other is when I’m doing a chunky-ish bit of coding which records decisions, todo’s, worries and web-clippings which are specific to that code

    Having a separate colour scheme just makes it handier to find either of the files I want when I’m alt-tabbing through my 103 open windows

    Vim commands to write out parameter list

    Executive summary :)

    For each line

    
    0
    
    D
    
    PP
    
    

    From the colon prompt:

    
    %s/^  */    write-dbg "`
    
    %s/  *\$/: <\$
    
    %s/$/>"
    
    %s/,//g
    
    

    The gory details

    Starting with a parameter clause like this:

    
    Param(
         $Parameter1,
         $Parameter2,
         $Parameter3,
         $Parameter4
    )
    

    The manual bits

    First, take off the ‘Param(i’, and the bracket at the end

    Second, for each line do this:

    0
    D
    PP
    

    … to get:

         $Parameter1,     $Parameter1,
         $Parameter2,     $Parameter2,
         $Parameter3,     $Parameter3,
         $Parameter4     $Parameter4
    

    The colon prompt bits

    Replace spaces at the front with the write-dbg, a double-quote, and then a backtick. The backtick is because I need to escape the name of the variable

    :%s/^  */    write-dbg "`
    

    This gives:

        write-dbg "`$Parameter1,     $Parameter1,
        write-dbg "`$Parameter2,     $Parameter2,
        write-dbg "`$Parameter3,     $Parameter3,
        write-dbg "`$Parameter4     $Parameter4
    
    

    Replace the spaces between the repeated variables with ‘: <’

    :%s/  *\$/: <\$
    
    

    ….giving:

        write-dbg "`$Parameter1,: <$Parameter1,
        write-dbg "`$Parameter2,: <$Parameter2,
        write-dbg "`$Parameter3,: <$Parameter3,
        write-dbg "`$Parameter4: <$Parameter4
    
    

    End the string:

    %s/$/>"
    

    ….which gives:

        write-dbg "`$Parameter1,: <$Parameter1,
        write-dbg "`$Parameter2,: <$Parameter2,
        write-dbg "`$Parameter3,: <$Parameter3,
        write-dbg "`$Parameter4: <$Parameter4
    
    

    Finally get rid of the commas

    %s/,//g
    
    
    

    Leaving:

        write-dbg "`$Parameter1: <$Parameter1>"
        write-dbg "`$Parameter2: <$Parameter2>"
        write-dbg "`$Parameter3: <$Parameter3>"
        write-dbg "`$Parameter4: <$Parameter4>"
    

    How to post to micro.blog with powershell

    Get the token

    Go to the account page in micro.blog, scroll down to the bottom where there is ‘App tokens’ and click on the link which has the text ‘5 apps’ (or however many apps you’ve authorized)

    Screenprint of the link

    Pick an app name (I went wild with my imagination and called it Powershell), and click on ‘Generate Token’

    Screenprint of the App name box

    Reveal the token and Ctrl-C it.

    Do the powershell bit

    Convert the token into a securestring

    $Token = 'whatever-the-token-is' |  ConvertTo-SecureString -AsPlainText -Force
    

    Set up the $Body

    $Body = @{
      content = 'Testing again. 1 , 2, 1, 2'
      h = 'entry'
      'post-status' = 'draft'
    }
    

    You need the quotes around ‘post-status’ because Powershell doesn’t like hyphens in variable names. I’m keeping this post as draft, because the content is even less interesting than my other posts

    Then call invoke-restmethod as follows:

    invoke-restmethod https://micro.blog/micropub -Method post  -Authentication Bearer -Token $Token -Body $Body
    

    …and Bob’s your uncle

    Screen-print of the post

    There is, clearly, a lot more really basic stuff that I need to work out:

    • how to create a title

    • how to make the URL more meaningful (tbf, I don’t know how to do that through the browser as yet)

    • how to attach a photo

    • how to post to the testing blog rather than the default one

    Then, I’d like to:

    • create a function to select a particular post, download it, edit in in vim or vscode, then post the new version