Making Buttons On A Local Hugo Site To Edit The Files

September - 2020

youtube: https://www.youtube.com/watch?v=l0k20Id3_iA

I realized that doing streams is a lot like Rubber Duck Debugging. Talking to the stream makes you think through things the same way you would to the duck (or, you know, to someone else.)

Also, I don't really use it for debugging, but instead of a duck, I have a Memento Mori.

Notes from the stream:

  • Running PHP in MAMP, you can use this to launch a file in whatever editor it's defaulted to:
shell_exec('open /path/to/file/index.md');
  • Here's the stuff I tried that didn't work:
    exec("'/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl' /Users/alans/woodshed/launchpad/html-prod");

    exec("python -c 'import os; os.system(\'/usr/local/bin/st\')'");

    $cmd = "python -c 'import os; os.system(\"open /Users/alans\")'";
    exec($cmd);

    $cmd = 'open "/Applications/Sublime Text.app"';
    exec($cmd);

    $cmd = "python -c 'import os; os.system(\"/usr/local/bin/st\")'";
    exec($cmd);
    
    $cmd = '"/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl"';
    exec($cmd);

    shell_exec('/bin/bash -c open .');  

Links from the stream:

This is a great piece of code from stackify that setups up so you can send php messages to the console.

https://stackify.com/how-to-log-to-console-in-php/

<?php
function console_log($output, $with_script_tags = true) {
    $js_code = 'console.log(' . json_encode($output, JSON_HEX_TAG) . 
');';
    if ($with_script_tags) {
        $js_code = '<script>' . $js_code . '</script>';
    }
    echo $js_code;
}