Introduction ✨#

Welcome to Programming Notebook, a notebook mainly about my scientific notes and gains in learning Programming and Geophysics, and I am very glad if it is helpful for your research.

Admonition

There is no guarantees of correctness, and if you spot an error or a doubtful statement, kindly let me know.

Enjoy ✨#

The main contents of the notebook are as follows:

Programming Environment

_images/macos.jpg

Configure the programming environment in MacOS.

App Development

_images/pyside6.png

Develop a python package, GUI, and Dashboards.

Parallel Computing & HPC Platform

_images/hpc.webp

Parallel computing skills in Python and C++, and HPC tutrials.

Machine Learning & Deep Learning

_images/network.jpg

Machine learning and deep learning approaches in Python.

MacOS Software

_images/software.webp

Useful softwares in MacOS system.

Geophysics Software

_images/specfem3d.jpg

Useful geophysics softwares.


About the Book ✨#

The notebook is powered by Jupyter Book, which uses MyST Markdown syntax.

All the source files are edited in VSCode, run_jb_build.py is a Python script to build the HTML and fresh it in Chrome browser automatically.

  • run_jb_build.py uses git to check whether any of the files have been changed. If something are changed, it will rebuild the notebook and refresh the HTML in Chrome browser.

  • run_jb_build.py uses git in dev branch, and after modifying all files, you need to switch to main branch, and push it to Github.

  • put run_jb_build.py in the root directory of your notebook project, and run it before you edit anytime.

import os
import time
import subprocess
from selenium import webdriver

"""
Use jupyter-book to generate html automatically.
    1. Download Chrome-driver Plug-in for selenium package from https://chromedriver.chromium.org/
    2. Make sure the project have 'dev' branch
    3. Run this script in the root directory of book-project

@Author: Fu Yin || Fri Jul 22 21:59:08 2022
"""

#%% Functions
def jb_build(driver,book):
    print("Start:", time.ctime())
    os.system(f"jb build {book}")
    driver.refresh()

def git_status():
    cmd_git = subprocess.Popen(['git status -s'], shell = True, \
        stdin = subprocess.PIPE, stdout = subprocess.PIPE, cwd = "./")  
    cmd_out_raw = cmd_git.stdout.read()
    cmd_git.wait()
    cmd_git.stdout.close()
    cmd_out = cmd_out_raw.decode()
    out = cmd_out.split("\n")
    return out

def git_commit():
    os.system(""" git add . """)
    os.system(""" git commit -m "auto" """)

def main():
    driver= webdriver.Chrome()
    driver.get(url)
    os.system("git switch dev")
    jb_build(driver, book)
    while True:
        time.sleep(sleep_time)
        out = git_status() 
        if len(out) != 1:
            print("Change number = ", len(out))
            jb_build(driver, book)
            git_commit()
        else:
            print("No change and continue...")
            continue

#%% Main
url = "file:///path_to_your_notebook/book/_build/html/intro.html"
book= "./book"          # jupyter-book build ./book
sleep_time = 0.1        # unit/s

if __name__ == '__main__':
    main()

Acknowledgements ✨#

Many thanks to…

🍿 If you enjoy the blog, please consider sponsoring 🍿

⏬   For Chinese friends:

Alipay

_images/Alipay.jpg

WeChat

_images/WeChat.jpg

⏬   For Non-Chinese friends:

Coffee

https://user-images.githubusercontent.com/1376749/120938564-50c59780-c6e1-11eb-814f-22a0399623c5.png

PayPal

https://cdn.jsdelivr.net/gh/twolfson/paypal-github-button@1.0.0/dist/button.svg