File exists in nodejs

There are two functions fs.exists() and fs.existsSync(). Function fs.exists() is deprecated, but fs.existsSync() is not. Everyone should use fs.stat() or fs.access() instead, these functions are part of Callback API and can be easily transform to the promise:

#!/usr/bin/env node --experimental-modules

import {access, constants} from 'fs';
import {homedir} from 'os';

let fileExists = s => new Promise(resolve => access(s, constants.F_OK, error => resolve(!error)));
const exists = await fileExists(`${homedir()}/Downloads/something.png`);


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


AutoExpand textarea

import autosize from "";

 * WebComponent with autosized textarea
 * @see
 * @see
class AutoExpand extends HTMLTextAreaElement {
    constructor() {

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


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


August 2021


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


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

MacOS App

  • Raycast - control your tools with a few keystrokes

Monospaced fonts



July 2021



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



  • 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


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


Display HTML with embed tag

<!DOCTYPE html>
<html lang="en">
  <meta charset="utf-8" />
  <embed type="text/html" id="response" scrolling="no" style="height: 640px; width:100%;">
(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));

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

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