tinydb

TinyDB is a lightweight document oriented database optimized for your happiness 🙂 It’s written in pure Python and has no external dependencies.

Example Code

>>> from tinydb import TinyDB, Query
>>> db = TinyDB('/path/to/db.json')
>>> db.insert({'int': 1, 'char': 'a'})
>>> db.insert({'int': 1, 'char': 'b'})

Query Language

>>> User = Query()
>>> # Search for a field value
>>> db.search(User.name == 'John')
[{'name': 'John', 'age': 22}, {'name': 'John', 'age': 37}]

>>> # Combine two queries with logical and
>>> db.search((User.name == 'John') & (User.age <= 30))
[{'name': 'John', 'age': 22}]

>>> # Combine two queries with logical or
>>> db.search((User.name == 'John') | (User.name == 'Bob'))
[{'name': 'John', 'age': 22}, {'name': 'John', 'age': 37}, {'name': 'Bob', 'age': 42}]

>>> # More possible comparisons:  !=  <  >  <=  >=
>>> # More possible checks: where(...).matches(regex), where(...).test(your_test_func)

usbrip

usbrip (inherited from “USB Ripper”, not “USB R.I.P.”) is a simple forensics tool with command line interface that lets you keep track of USB device artifacts (i.e., USB event history) on Linux machines.

https://github.com/snovvcrash/usbrip

usbrip is a small piece of software which analyzes Linux log data: journalctl output or contents of /var/log/syslog* (/var/log/messages*) files. Based on the collected data usbrip can build USB event history tables with the following columns:

  • “Connected” (date & time);
  • “Host”;
  • “VID” (vendor ID);
  • “PID” (product ID);
  • “Product”;
  • “Manufacturer”;
  • “Serial Number”;
  • “Port”;
  • “Disconnected” (date & time).

How to Upgrade containers with docker-compose?

Another question is how to upgrade to the latest version of nginx or wordpress docker images in our deployment. Since all user data is outside the containers, we can easily delete the containers and re-create them to upgrade our installation.

docker-compose down --rmi all
docker-compose up -d

https://www.linode.com/docs/guides/wordpress-with-docker-compose/

docker-compose down
docker-compose pull && docker-compose up -d

Code Syntax Block

docker-compose up -d
 Creating network "wordpress_app-network" with driver "bridge"
 Creating network "wordpress_default" with the default driver
 Pulling db (mysql:8.0)…
 8.0: Pulling from library/mysql
 a076a628af6f: Pull complete
 f6c208f3f991: Pull complete
 88a9455a9165: Pull complete
 406c9b8427c6: Pull complete
 7c88599c0b25: Pull complete
 25b5c6debdaf: Pull complete
 43a5816f1617: Pull complete
 1a8c919e89bf: Pull complete
 9f3cf4bd1a07: Pull complete
 80539cea118d: Pull complete
 201b3cad54ce: Pull complete
 944ba37e1c06: Pull complete
 Digest: sha256:feada149cb8ff54eade1336da7c1d080c4a1c7ed82b5e320efb5beebed85ae8c
 Status: Downloaded newer image for mysql:8.0
 Pulling wordpress (wordpress:php7.3-fpm-alpine)…
 php7.3-fpm-alpine: Pulling from library/wordpress
 4c0d98bf9879: Already exists
 ed03eff2d636: Already exists
 fa67667da1de: Already exists
 6961b2fabe93: Already exists
 498fe07e0f8a: Pull complete
 147460bbbd9b: Pull complete
 8885930dac6c: Pull complete
 ce285f7d484c: Pull complete
 d697d2ff50e2: Pull complete
 b19a07854ae1: Pull complete
 6b03587710a7: Pull complete
 97f7f5de7f5a: Pull complete
 62c4acafe9b4: Pull complete
 8c496551655c: Pull complete
 b9aa1a307678: Pull complete
 cd225f76bb67: Pull complete
 Digest: sha256:24519d3439393458dd4c80961ad8a42b51b262ef81bbf3d73d5fe12effc2095a
 Status: Downloaded newer image for wordpress:php7.3-fpm-alpine
 Pulling webserver (nginx:1.15.12-alpine)…
 1.15.12-alpine: Pulling from library/nginx
 e7c96db7181b: Pull complete
 264026bbe255: Pull complete
 a71634c55d29: Pull complete
 5595887beb81: Pull complete
 Digest: sha256:57a226fb6ab6823027c0704a9346a890ffb0cacde06bc19bbc234c8720673555
 Status: Downloaded newer image for nginx:1.15.12-alpine
 Pulling certbot (certbot/certbot:)…
 latest: Pulling from certbot/certbot
 801bfaa63ef2: Pull complete
 7678dd7631a2: Pull complete
 4c6139ab40d8: Pull complete
 ff5ef8cd8062: Pull complete
 cefde9442c97: Pull complete
 75077d3d5c26: Pull complete
 5f56a95649c4: Pull complete
 70db9e70bd0b: Pull complete
 1369e8589892: Pull complete
 a00c3b290f52: Pull complete
 4c657d1c5eac: Pull complete
 8410fa093244: Pull complete
 f6479610343a: Pull complete
 dcb91cb8d361: Pull complete
 Digest: sha256:9867da9d3345444b37bf2edc8126f04bf1fc093d693edf5555103c04fd71ba49
 Status: Downloaded newer image for certbot/certbot:latest
 Creating db … done
 Creating wordpress … done
 Creating webserver … done
 Creating certbot   … done