Rename OneDrive Business Folder Name on MacOS

Onedrive for bussiness forces adding the business name suffix in the sync folder. For example, if your business is “Foo”, the sync folder under your home directory will be like OneDrive - Foo. It will be more anonying if your business name is long and have spaces. The setting from the client doesn’t have an option for renaming the folder. There are “user feedback” to Mircosoft (https://onedrive.uservoice.com/forums/913522-onedrive-on-windows/suggestions/8729746-allow-onedrive-for-business-folder-to-be-renamed) for years but as you seen nothing happened yet. Funny the feedback was deleted finally, and here is a new one https://feedbackportal.microsoft.com/feedback/idea/0b4d42ab-d51c-ec11-b6e7-0022481f8143.

What I’m introducing a “hacking” way. Please use it carefully. No garantee it won’t harm your computers, but at least below are what I do on my Mac and works well.

  1. Quit OneDrive client.
  2. First locate the setting folder. It should be under $HOME/Library/Containers/com.microsoft.OneDrive-mac/Data/Library/Application Support/OneDrive/settings/Business1/.
  3. Looking for a .ini file in the folder. It’s name is a UUID. For example, it looks like a27edc43-553b-4447-82af-857f36d750ef.ini. In the first line you can see your sync folder name there. Change it to any name you’d like. I simply rename it to “OneDrive”. Note just using OneDrive might have a problem if you are using a personal account on this computer too, but it’s not my casse.
  4. For safty, run find . -type f|xargs grep Foo (replace Foo by your businese name) to find out any other files haveing the old folder name. Change them too.
  5. Dont’ forget change the folder name in your home directory.

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*")]

A Better Feature Branch Naming in Intellij IDEA

Intellij Idea has a very nice feature: you can customize feature branch name. When create a new task, the Intellij IDEA will help you create a new (git) branch. The default name of the branch is the task number, e.g. FOO-1 for Jira, or #1 for gitlab.

However, we can make the branch name better by adding the task summary to it. It will be like FOO-1-add-a-new-feature. To configure it, goes to Preferences->Tools->Task and change the Feature branch name format to {id}-{summary}

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)

SSH Reverse Tunnel

The SSH has many advance usages. The reverse tunnel is a good example and a very useful one. It answers the question: if a user can ssh from a server A to a server B, can the user ssh back from B to A, even A is behind a router? In my case, it is very helpful. I have a desktop in the office, but the office VPN has not been set up yet. How can I ssh to my office desktop from home? The answer is SSH reverse tunnel, using a server with a public IP as a jumper. Followings show how did I do it.

Read more