Skip to content

Instantly share code, notes, and snippets.

@link89
link89 / st_ext.py
Last active December 2, 2025 06:31
Cookie based session for Streamlit
from streamlit.web.server.websocket_headers import _get_websocket_headers
from streamlit.components.v1 import html
import streamlit as st
from http.cookies import SimpleCookie
from uuid import uuid4
from time import sleep
def get_cookie():
@link89
link89 / scow-db.md
Created October 31, 2024 08:33
Modify SCOW database

SCOW 数据表修改

通过数据库操作支持一些目前暂不支持在界面操作的 SCOW 功能。 以下操作需在 mis 的 db 容器中完成。

docker exec -it <container-id> bash
mysql -p 
<enter password>

Summary

  • build a new deepmd-kit plugin for an existed LAMMPS
  • export new LD_LIBRARY_PATH and LAMMPS_PLUGIN_PATH properly

Build

bash build.sh

Test

@link89
link89 / build-deepmd-3.0.0b-with-conda.md
Last active January 2, 2025 06:39
Build DeepMD-3.0.0b with Conda

Note

  • It's for CentOS 7, so the conda version have to be limited to cuda 11.8

Steps

CONDA_OVERRIDE_CUDA=11.8 nohup conda create -y -p ./3.0.0b0-cuda118 pytorch=2.1.2=cuda118*  python=3.11.* cudatoolkit=11.8  zlib cudnn cusparselt -c conda-forge --override-channels &
cd ./3.0.0b0-cuda118
source activate ./
pip install tensorflow==2.14.1
ln -s <path to source> source
@link89
link89 / use-conda-to-build-deepmd-with-lammps.md
Last active September 26, 2024 09:12
Use a conda envionment to build deepmd with lammps support

Summary

  • Use conda to install pytorch will have less trouble than with pip
  • Install lammps with openmpi support from conda-forge channel (or you can build your own lammps if you like)
  • Install lammps from source or else your conda environemnt will be messed up!
  • Install tensorflow with pip instead of conda as it is slow to resolve environment!
  • Install pytorch and tensorflow with conda at the same time to avoid abi incompatible issue!
  • For the sake of C++ABI compatibility, use conda to install tensorflow and pip for pytorch
  • Don't use full oneapi with openmpi, just use mkl or else there will be segmentation fault

Steps

@link89
link89 / rclone-backup.md
Created April 28, 2024 06:59
Use rclone to backup directory

Use copy to backup files

rclone copy ikkem-hpc-fq:/public/home/fqgong666/pretrained-model/all-test/dataset-2nd/2nd_data office:/public/dynacat/2nd_data --check-first  --verbose --dry-run

FQA

400 error of minio

If you see the following error

@link89
link89 / build-lammps-mace.md
Last active March 3, 2025 00:55
Script to build LAMMPS with MACE support

Summary

  • Use rocky8 singularity container to build and run to work around legacy glibc issue.

Build

 singularity exec -B /public,/etc --nv /public/groups/ai4ec/libs/images/rocky8.sif /bin/bash -l build_lammps.sh

Run

@link89
link89 / ffmpeg.sh
Last active March 17, 2024 07:48
a ffmpeg wrapper script to kill process when timeout
#!/bin/bash
trap 'echo ffmpegexit && pkill -P $$' EXIT SIGINT SIGTERM SIGHUP
# Define the timeout duration in seconds for file change
TIMEOUT_IN_S=10
TOTAL_TIMEOUT_IN_S=7200
# Get the last argument as the output file
OUTPUT_FILE="${@: -1}"
@link89
link89 / win-xp-guest-cockpit.md
Last active March 11, 2024 03:33
setup windows xp virtual machine with cockpit

Background

  • A windows XP guest machine exported from VMWare as OVF format

Tips

  • Install cockpit and cockpick-machines: sudo apt install cockpit cockpit-machines
  • Convert vmdk image to qcow2 with the following command: qemu-img convert -f vmdk -O qcow2 xp-wire-disk1.vmdk xp-wire-disk1.qcow2
  • Create winxp virtual machine by importing existed disk, OS type should select unknown, don't start vm after import.
  • Edit network interfaces, change model to e1000(PCI, legacy)
  • Download e1000 driver iso from: https://archive.org/details/intel-pro1000-mt-desktop-82540em-winxp
  • Add ISO as CD/ROM
@link89
link89 / netowork-tips-for-china-devloper.md
Created February 4, 2024 07:41
Essential network tips for China developer.

Docker

set proxy for docker build and docker run

You can add proxy configurations for the Docker client using a JSON configuration file, located in ~/.docker/config.json. Builds and containers use the configuration specified in this file.

{
 "proxies": {
   "default": {
     "httpProxy": "http://proxy.example.com:3128",
 "httpsProxy": "https://proxy.example.com:3129",