How to delete all local TimeMachine snapshots

Your Time Machine backup disk might not always be available, so Time Machine also stores some of its backups on your Mac. These backups are called local snapshots. Local TimeMachine snapshots take a large amount of disk space. This space is listed as purgeable in disk info, but cannot be actually used until the system decides to free it up. You can list all local backups with:

tmutil listlocalsnapshots /

Then delete one by one, with follow command:

sudo tmutil deletelocalsnapshots <snapshot date>

You can lists all snaphosts and deletes all of them in a loop:

for d in $(tmutil listlocalsnapshotdates | grep "-"); do sudo tmutil deletelocalsnapshots $d; done

#macOS#TimeMachine#2021

AutoExpand textarea

import autosize from "https://cdn.jsdelivr.net/npm/autosize@5.0.1/dist/autosize.min.js";

/**
 * WebComponent with autosized textarea
 *
 * @see https://blog.jim-nielsen.com/2020/automatically-resize-a-textarea-on-user-input/
 * @see https://codepen.io/jimniels/pen/MWeawPV
 */
class AutoExpand extends HTMLTextAreaElement {
    constructor() {
        super();
        autosize(this);
    }
}


customElements.define("auto-expand", AutoExpand, {extends: "textarea"});

And HTML:

<textarea is="auto-expand"></textarea>

#HTML#Javascript#Snippets#2021

August 2021

Javascript

  • nprogress - nano progress bar
  • heroicons - Beautiful hand-crafted SVG icons for Tailwind
  • pnpm - Fast, disk space efficient package manager

Social

  • Mastodon - Social networking, back in your hands - open source social network

MacOS App

  • Raycast - control your tools with a few keystrokes

Monospaced fonts

Gear

#notes#2021

July 2021

RollingSquare

PHP

  • Fork - A lightweight solution for running code concurrently in PHP

JS

Tools

  • Sequel Ace - MySQL/MariaDB database management for macOS
  • CleanMyDrive - remove junk from external drives
  • Mailtrain - Self Hosted Newsletter App Built on Top of Nodemailer
  • sendy - Send newsletters, 100x cheaper with AWS SES

#notes#2021

Join multiple GoPro MP4 files to single one

GoPro 'chapters' are footage around 4 GB - The camera starts a new file every ~ 10 minutes. If you have media files with exactly the same codec and codec parameters you can concatenate them quite easily. Fastest way, that I found, is use ffmpeg with concating function, but there is one unnecessary step with mylist.txt, the list of all files, you want to have concatenated.

for f in *.MP4; do echo "file '$PWD/$f'"; done > mylist.txt

If your shell supports process substitution (like Bash and Zsh), you can avoid explicitly creating a list file and do the whole thing in a single line:

ffmpeg -f concat -safe 0 -i <(for f in *.MP4; do echo "file '$PWD/$f'"; done) -c copy output.mp4

Here is also nice bash function, that can be put to your .bash_profile:

function video-concat() {
  ffmpeg -f concat -safe 0 -i <(for f in ${@:1:${#}-1}; do echo "file '$PWD/$f'"; done) -c copy $_
}

Then you can call video-concat function as follow:

video-concat *.MP4 output.mp3

#bash#ffmpeg#gopro#2021

Display HTML with embed tag

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8" />
  <title></title>
</head>
<body>  
  <embed type="text/html" id="response" scrolling="no" style="height: 640px; width:100%;">
</body>
</html>
(async function() {
  const embedResponse = document.getElementById('response');
    try {
      // clean content first     
      embedResponse.setAttribute('src', 'data:text/html;charset=utf-8,');
      const response = await fetch('/api/response',
        {
          method: 'post',
          // accept HTML response
          headers: {
            'Accept': 'application/json, text/plain, */*',
            'Content-Type': 'application/json'
          },
          // sent data if needed
          body: JSON.stringify({data: ''})
        });

      // encode HTML response
      const html = await response.text();
      embedResponse.setAttribute('src', 'data:text/html;charset=utf-8,' + encodeURIComponent(html));

    } catch (e) {
      // catch errors and show them
      embedResponse.setAttribute('src', 'data:text/html;charset=utf-8,' + encodeURIComponent(e));
      console.error(e);
    }
 })();

There is another option, you can display HTML in new window as blob data:

const content = URL.createObjectURL(new Blob([response.data + overlay || ''], {type: "text/html"}));
window.open(content, "response", `width=640, height=480`).focus();

#javascript#webdesign#2021