Airflow Remove Example Dags

When you start your local airflow based on the official documentation, the airflow will fill the db with a bunch of examples. If you want to remove them, first you need to find the airflow.cfg find under the airflow home directory (usually it is $HOME/airflow) and change the line load_examples = True to load_examples = False. After the change, however, the examples are still in you airflow’s DB. You need to run airflow resetdb to reset the airflow DB. Finally the examples are gone.

Python how to list files under a directgory

There are so many ways, but in python 3 looks the most popular way is using pathlib. Here is an example to list all
files starting with bar under dir /foo

1
[x.absolute() for x in pathlib.Path("/foo").glob("bar*")]

Generate Random Numbers from Command Line

On mac or bsd, we can use jot.
jot -r 1 0 10000

or
jot -r 1 0 0x7fffffffffffffffL

On linux need to install the package athena-jot:
sudo apt-get install athena-jot

Docker How To Delete Everything

Just want fresh restart and delete all containers? Here is the code:

docker stop $(docker ps -a -q) docker rm $(docker ps -a -q)

If you want to delete all images too:
docker stop $(docker ps -a -q) docker rmi $(docker images -a -q)