Skip to content

Instantly share code, notes, and snippets.

@link89
link89 / pinyin_table.py
Last active September 22, 2023 06:59
table of all valid pinyi
# uincode version, keep ü
pinyin = ['a', 'o', 'e', 'er', 'ai', 'ao', 'ou', 'an', 'en', 'ang', 'eng', 'yi', 'ya', 'yao', 'ye', 'you', 'yan', 'yin', 'yang', 'ying', 'yong', 'wu', 'wa', 'wo', 'wai', 'wei', 'wan', 'wen', 'wang', 'weng', 'yu', 'yue', 'yuan', 'yun', 'ba', 'bo', 'bai', 'bei', 'bao', 'ban', 'ben', 'bang', 'beng', 'bi', 'biao', 'bie', 'bian', 'bin', 'bing', 'bu', 'pa', 'po', 'pai', 'pei', 'pao', 'pou', 'pan', 'pen', 'pang', 'peng', 'pi', 'piao', 'pie', 'pian', 'pin', 'ping', 'pu', 'ma', 'mo', 'me', 'mai', 'mei', 'mao', 'mou', 'man', 'men', 'mang', 'meng', 'mi', 'miao', 'mie', 'miu', 'mian', 'min', 'ming', 'mu', 'fa', 'fo', 'fei', 'fou', 'fan', 'fen', 'fang', 'feng', 'fu', 'da', 'de', 'dai', 'dei', 'dao', 'dou', 'dan', 'den', 'dang', 'deng', 'dong', 'di', 'diao', 'die', 'diu', 'dian', 'ding', 'du', 'duo', 'dui', 'duan', 'dun', 'ta', 'te', 'tai', 'tei', 'tao', 'tou', 'tan', 'tang', 'teng', 'tong', 'ti', 'tiao', 'tie', 'tian', 'ting', 'tu', 'tuo', 'tui', 'tuan', 'tun', 'na', 'ne', 'nai', 'nei', 'nao', 'n
@link89
link89 / timeout-wrapper.sh
Last active November 1, 2023 04:22
bash script to kill a process if no output for 60 seconds (feat. ChatGPT)
#!/bin/bash
# This script runs a command and kills it if there is no output for a certain time
# Define the command to run and the output file
COMMAND="lmp_mpi -in input.lmp"
OUTPUT_FILE="lammps.log"
# Define the timeout value in seconds
TIMEOUT=60
@link89
link89 / build-elpa-with-oneapi.md
Last active November 10, 2023 01:28
Compile ELPA with intel oneapi

Note

  1. The latest OneAPI that supports CentOS 7 is 2022.3.1
  2. Use lscpu to check the arch of CPU.

Build

# download source code
wget https://elpa.mpcdf.mpg.de/software/tarball-archive/Releases/2022.11.001/elpa-2022.11.001.tar.gz
tar -xvf elpa-2022.11.001.tar.gz
@link89
link89 / build-plumed-with-oneapi.md
Created November 9, 2023 12:12
Build Plumed with oneapi

Note

  1. use mkl's fftw build

Build

wget https://www.cp2k.org/static/downloads/plumed-src-2.8.2.tgz --no-check-certificate
tar -xvf plumed-src-2.8.2.tgz
cd plumed-2.8.2

./configure FC=mpiifort CC=mpiicc CXX=mpiicpc CXXFLAGS="-O3 -mtune=icelake-server" --enable-mpi \
@link89
link89 / build-libint-with-oneapi.md
Last active November 10, 2023 02:55
Build libint with OneAPI
@link89
link89 / openpbs-install-tips.md
Created November 17, 2023 09:37
OpenPBS source install tips for ubuntu 22.04
@link89
link89 / improve-download-speed.md
Last active November 21, 2023 07:22
Tips on improve download speed

Improve Download Speed

Use BBR congestion control

Ubuntu

Update /etc/sysctl.conf

net.core.default_qdisc=fq
net.ipv4.tcp_congestion_control=bbr
@link89
link89 / sample_data_frame.py
Created November 24, 2023 09:30
A script to sample text frame data (each frame has fixed lines)
import numpy as np
def sample_data_frame(path: str, frame_lines: int, nsample: int, out_path: str,
total_lines: int = -1, encoding='utf-8',
write_buffer_size=10 * 1024 * 1024,
):
"""
Sample data frame from file randomly
A data file is composed of multiple frames, each frame has fixed number of lines.
@link89
link89 / poc-typescript-dataformat-llm.md
Created December 14, 2023 03:11
POC: use typescript as container of structured data for LLM

POC: use typescript as container of structured data for LLM

Prompt

The following is Typescript code that describe the data structure of reactions. The reactions to be exported are not implement yet.

/**
 * This is a typescript prompt file to export reactions data.
 */
@link89
link89 / build-deepmd-lammps-with-conda.md
Last active January 29, 2024 02:57
Build deepmd + lammps in a conda environment

Build DeepMD-kit + LAMMPS in a conda envrionment

Steps

Create conda environment

conda create -p 2.2.5/gpu python==3.10.13  tensorflow=2.10.*=gpu*

Note:

  • Install tensorflow with conda instead of pip will have less trouble (for example, conda will install the right cudnn for you)