24. 3. 2020

Change the Default Screen Shot File Name in MacOS

Change Screen Shot filename to date and time only:

defaults write com.apple.screencapture name ""
killall SystemUIServer

Change the Screen Shot Save File Location:

defaults write com.apple.screencapture location ~/Downloads/
killall SystemUIServer

#macOS #screenshot

24. 3. 2020

Typora - the best editor for Markdowns

I am just found the best (for me) Markdown editor on the planet. Why?

Typora

You can download and install it with brew:

brew cask install typora

Homepage https://typora.io/ and Twitter

#mac #markdown

17. 3. 2020

Convert GIF to WebM with ffmpeg

ffmpeg -i my-animation.gif -c vp9 -b:v 0 -crf 41 my-animation.webm
<video autoplay loop muted playsinline>
  <source src="my-animation.webm" type="video/webm">
</video>

#bash #ffmpeg

16. 3. 2020

Bábovka s mákem

Zvlášť promíchat sypké a tekuté, tekuté vmíchat to sypkého. Do poloviny kakao, mák nebo ořechy. Péct 1/2 hod na 200, potom (cca taky 1/2 hod) na 170, test špejlí.

#Recepty #Pečení

2. 3. 2020

Convert video for iMovie with ffmpeg

You need to include the argument -pix_fmt yuv420p to generate H.264 content for Apple software/devices, and a bunch of other decoders that don't handle yuv444p.

ffmpeg -i input.avi -pix_fmt yuv420p output.mp4

Apple added ProRes support sometime in late 2014 since iMovie 10 you can use follow code:

ffmpeg -i input.avi -c:v prores -c:a pcm_s16le output.mov

Formats compatible with macOS Catalina:

Video formats:

Container formats

Audio formats

More information about incompatible media in iMovie for macOS

#bash #ffmpeg

2. 3. 2020

Add copy to clipboard button to all preformat code in pure Javascript

document.onreadystatechange = function () {
  if (document.readyState == 'complete') {

    // for all pre > code
    document.querySelectorAll('pre > code').forEach(function (codeBlock) {

      // create anchor element
      let copy = document.createElement('a');
      copy.className = 'btn-copy';
      copy.innerText = 'Copy';
      copy.title = 'Copy to Clipboard!';
      copy.href = '#';

      // add click event
      copy.addEventListener('click', function (e) {
        copy.innerText = 'Copied!';

        // copy innerText of preformat
        navigator.clipboard.writeText(codeBlock.innerText).then(function () {
          setTimeout(function () { copy.innerText = 'Copy'; }, 500);
        }, function (err) {
          copy.innerText = 'ERROR';
        });

        // do nothing else...
        e.preventDefault();
        e.stopPropagation();

      }, false);

      // insert before codeBlock <pre><a><code>
      codeBlock.parentNode.insertBefore(copy, codeBlock);
    });
  }
};
a.btn-copy, a.btn-copy:hover {
  color: black;
  user-select: none;
    position: absolute;
    padding: 8px;
    font-size: smaller;
    right: 0;
    top: 0;
}

As with many new APIs, navigator.clipboard is only supported for pages served over HTTPS. To help prevent abuse, clipboard access is only allowed when a page is the active tab. Pages in active tabs can write to the clipboard without requesting permission, but reading from the clipboard always requires permission.

https://developers.google.com/web/updates/2018/03/clipboardapi

#js

9. 2. 2020

Modern databases list

MongoDB

MongoDB is a general purpose, document-based, distributed database built for modern application developers and for the cloud era. No database makes you more productive.

Couchbase

Couchbase is open source the NoSQL database, distributed, document-oriented engagement database. It exposes a fast key-value store with managed cache for sub-millisecond data operations, purpose-built indexers for fast queries and a powerful query engine for executing SQL-like queries

Amazon DynamoDB

Amazon DynamoDB is a key-value and document database that delivers single-digit millisecond performance at any scale. It's a fully managed, multiregion, multimaster, durable database with built-in security, backup and restore, and in-memory caching for internet-scale applications.

Firebase - Cloud Firestore

Cloud Firestore is the successor to Firebase's original databasing system, Real-time Database, and allows for nested documents and fields rather than the tree-view provided in the Real-time Database.

Apache Cassandra

Apache Cassandra is a free and open-source, distributed, wide column store, NoSQL database management system designed to handle large amounts of data across many commodity servers, providing high availability with no single point of

Unbounded

Unbounded is the First Programmable NoSQL Database Effortlessly scale your data in the cloud using the language you already know.

PostgreSQL

PostgreSQL, also known as Postgres, is a free and open-source relational database management system (RDBMS) emphasizing extensibility and technical standards compliance. It is designed to handle a range of workloads, from single machines to data warehouses or Web services with many concurrent users. It is the default database for macOS Server, and is also available for Linux, FreeBSD, OpenBSD, and Windows.

MariaDB

MariaDB is a community-developed, commercially supported fork of the MySQL relational database management system (RDBMS), intended to remain free and open-source software under the GNU General Public License. Development is led by some of the original developers of MySQL, who forked it due to concerns over its acquisition by Oracle Corporation in 2009.

FaunaDB

FaunaDB is a global serverless database that gives you ubiquitous, low latency access to app data, without sacrificing data correctness and scale. Database built for serverless, featuring native GraphQL

#database

24. 1. 2020

Docker cleanup guide

Docker doesn't remove unused objects such as containers, images, volumes, and networks unless you explicitly tell it to do so. How To Remove them?

Removing All Unused Objects

Remove stopped containers, all dangling images, and all unused networks:

docker system prune
WARNING! This will remove:
  - all stopped containers
  - all networks not used by at least one container
  - all dangling images
  - all dangling build cache

Are you sure you want to continue? [y/N] 

You can also include all unused volumes, then add --volumes:

docker system prune --volumes

Docker Containers

docker container ls -a

Remove selected container

docker container rm [CONTAINER ID]

Remove all stopped containers

To remove all stopped containers use:

docker container prune

You can also list what will be removed:

docker container ls -a --filter status=exited --filter status=created 

Stop and remove all containers

docker container stop $(docker container ls -aq)
docker container rm $(docker container ls -aq)

Docker Images

You can list them:

docker image ls

Remove selected image

docker image rm [IMAGE ID]

Remove dangling images

A dangling image is an image that is not tagged and is not used by any container. You can remove them by:

docker image prune

Remove all unused images

To remove all images which are not referenced by any existing container, not just the dangling ones, use the prune command with the -a flag:

docker image prune -a

Docker Networks

You can list them with:

docker network ls

Remove selected network

docker network rm [NETWORK ID]

Remove all unused networks

Use the docker network prune command to remove all unused networks. Remove all networks that are created more than 12 hours ago:

docker network prune -a --filter "until=12h"

Docker Volumes

docker volume ls

Remove selected Volume

docker volume rm [VOLUME NAME]

Remove all unused volumes

docker volume prune

#Docker