Jupyter Notebook

Environment macOS: 10.15.3 Python: pyenv installed Install pip install -U pip pip install jupyter How to Run jupyter-notebook run the Jupyter. % jupyter-notebook [I 19:21:07.376 NotebookApp] Serving notebooks from local directory: /Users/atlex/nlp [I 19:21:07.376 NotebookApp] The Jupyter Notebook is running at: [I 19:21:07.376 NotebookApp] http://localhost:8888/?token=8637cf3f5b526b4ac33e93964844ecf7626ccd7be92616a2 [I 19:21:07.376 NotebookApp] or http://127.0.0.1:8888/?token=8637cf3f5b526b4ac33e93964844ecf7626ccd7be92616a2 [I 19:21:07.376 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation). [C 19:21:07.381 NotebookApp] To access the notebook, open this file in a browser: file:///Users/atlex/Library/Jupyter/runtime/nbserver-15083-open.

Ansible Vault

Prepare: a password file Create a simple password file. In this post, I store it at ~/.ansible_vault_password. How to use Here are the simple snippets: # Make encrypted file and start editing ansible-vault create --vault-password-file ~/.ansible_vault_password ./foo.key # Edit encrypted file ansible-vault edit --vault-password-file ~/.ansibe_vault_password ./foo.key # Encrypt original file ansible-vault encrypt --vault-password-file ~/.ansible_vault_password ./foo.key Tips Ansible-vault usees AES as its encryption algorithm. You can use executable file as a password file (don’t forget to add executable permission, unless you’ll get a HMAC error (you can check by appending -vvvv option).

Linux CLI snippets

for loop of all files in a directory The following snippet shows all files in Loop_dir. Loop_dir="path_to_dir" for entry in "$Loop_dir"/* do echo "$entry" done cf) https://stackoverflow.com/questions/13210880/replace-one-substring-for-another-string-in-shell-script/13210909 Check argument is set or not https://www.cyberciti.biz/faq/unix-linux-bash-script-check-if-variable-is-empty/ process tree ps -aef —forest Find from all files in the directory Find all lines from files in the current directory find ./ -type f -print | xargs grep 'foo' I created my custom alias. alias afind="find -type f -print | xargs grep" Delete prefix of files in a directory Here is a pioneer.

Table Of Contents (TOC) in Hugo

Enabling TOC Here is the official document about TOC. When you want to enabling TOC feature in Hugo, add the following line in config.toml. Then, TOC will enabled at all posts. [Params] ... toc = true ... Configure TOC Here is the official document about TOC configurations. I don’t need to configure it detail enough, added the disription in config.toml. [markup] [markup.tableOfContents] startLevel = 2 endLevel = 4 ordered = false startLevel = 1: List to the TOC from #.

rsync (Draft)

Why rsync not SCP It can restart download (fragmentation method?). Download a file from remote Download a folder from remote (@rsync_dir) rsync -avzhP remote_user@remote.com:/path/to/dir ./ -a: archive -h: human redable output -z: compress (like zip) data during the transfer -v: verbose -P: –partial + –progress Sync - upload a current structure under the remotedir In dir, rsync -ahzv ./* remote-user@remote.com:/path/to/dir/ It will overwrite the same name file!!` Skip (almost) same contents --size-only skips files that match in size.

Regular expressionexp - snippets

Regular expression Regular expression is a basic concept in theoretical computer science. Once you see the Wikipedia page of “Regular expression”, you can realize how important it is for understanding computer science. But for beninner of web engineer, the simple explanation of regular expression could be, it is just a “pattern” in a nut shell. Regular expression is often abbreviated to regex. Regex rules (To be updated…) Here is often used regex syntax.

Docker - intro

Install macOS Environment: macOS 10.15.3 (Intel chip), Mar. 2020. Installing Docker in macOS, the official document seems to recommend installing Docker Desktop with the installer. I don’t need desktop function so far, but this is not so critical when I learn Docker. And it is the easiest way to install Docker CLI in macOS. If you don’t have DockerID, please make it first. Related official Documents: https://docs.docker.com/docker-for-mac/install/ https://hub.docker.com/?overlay=onboarding Don’t forget that you need to exec docker once because of permissions of macOS.

snippets

/etc/modules Here are the list of modules that Kernel load at boot. logrotate Good tool. OpenProject Using docker image docker run -d -p 8080:80 -e SECRET_KEY_BASE=secret openproject/community:latest Docker or LXD https://iopscience.iop.org/article/10.1088/1742-6596/1211/1/012042 -> not so good for me https://discuss.linuxcontainers.org/t/do-i-need-docker/605 -> comprehensive and this is what I want. Compare 2 directories diff -qr dir1/ dir2 Wildcard server auth TLS certificate The wildcard *.foo.com can’t indicate sub-subdirectory such as this.is.foo.com. Vim - centerning the cursor aloways http://vimdoc.

Snippets of Git

Completely delete submodule from the repository Here is the graceful memo. I copy&paste it to here. To remove a submodule you need to: Delete the relevant section from the .gitmodules file. Stage the .gitmodules changes git add .gitmodules Delete the relevant section from .git/config. Run git rm –cached path_to_submodule (no trailing slash). Run rm -rf .git/modules/path_to_submodule (no trailing slash). Commit git commit -m “Removed submodule ” Delete the now untracked submodule files rm -rf path_to_submodule Do you forgot to clone with --recursive ?

Cache (HTTP)

What is the Cache Cache is temporarily stored data. This is a general concept, and I think this is why many developers struggle with it a lot. Because Cache is temporary data, we should think where and how long to store the data. Where are the data stored There are several locations where we can save cache data. The most common place is the browser in a client. Not only client sides but also server sides (origin servers) can hold a cache.