Skip to content

Instantly share code, notes, and snippets.

View alchem0x2A's full-sized avatar
👨‍🍼

T.Tian alchem0x2A

👨‍🍼
View GitHub Profile
@alchem0x2A
alchem0x2A / blender_snippet_2.8x_1.org
Created September 15, 2019 20:40
New python snippets Blender 2.8x
@alchem0x2A
alchem0x2A / blender_cluster.org
Last active September 7, 2023 12:05
Render Blender file on cluster

Render Blender files on cluster

This is a easy workaround to enable Blender rendering on a super-computing cluster. The samples shown here are based on the Euler cluster of ETH Zürich (IBM LSF batch system).

Step 1: install Blender binary on cluster

@alchem0x2A
alchem0x2A / blender_venv.org
Last active November 27, 2024 20:37
Enable 3rd-party packages in Blender using virtualenv

Install external python packages + virtualenv with Blender

Requirements: Blender 2.80+ (2.79 should also work with pip method, not tested thoroughly)

Step 1: Install virtualenv on the system

In order not to mix the packages installed for Blender (such as scipy, matplotlib) with those system-wide packages, we need to create a virtual environment for the Blender alone.

Best practice is to use a single virtualenv for each version of

@alchem0x2A
alchem0x2A / mathfont.org
Last active May 26, 2023 13:51
Useful math fonts in LaTeX

Math fonts that worth noting

Solutions taken from ftp://tug.ctan.org/pub/tex-archive/info/Free_Math_Font_Survey/survey.html in TUG.

Times-resemble math font

Use either txfonts or mathptmx for Times font support. I personally prefer txfonts since its mathcal symbols look more natural to me.

To use: include \usepackage{txfonts} or \usepackage{mathptmx} in

@alchem0x2A
alchem0x2A / wrapper.sh
Last active August 18, 2019 16:19
[Emacs] Wrapping up emacsclient to automatically start server
#!/bin/sh
# Provide a wrapper of emacsclient that automatically opens up Emacs or server
function ec_wrapper {
GREEN='\033[0;32m'
NC='\033[0m'
buffers=$@
cmd="emacsclient -nqc"
# Excecute command
@alchem0x2A
alchem0x2A / convert.py
Last active December 10, 2018 11:15
Convert all video files under current folder to mp4
import os, os.path
import subprocess
def convert(in_name, out_name, delete=True):
prog = "ffmpeg"
params = ["-i", "{}".format(in_name),
"-pix_fmt", "yuv420p",
"-vcodec", "libx264",
"{}".format(out_name)]
res = subprocess.call([prog, *params])
@alchem0x2A
alchem0x2A / gpaw_config_euler_intel.md
Last active July 6, 2018 09:56
Install GPAW with intel on Euler

Preparation

  • Compiler: intel/15.0, open_mpi/1.10.0, libxc/3.0.0, fftw/3.3.4, scalapack
  • tar for numpy scipy matplotlib

Compile python with intel

Download the python tarball, untar and cd into the root directory.

./configure --prefix="abs/path/to/build" --with-icc CC=icc CXX=icpc
@alchem0x2A
alchem0x2A / uninstall.sh
Created July 5, 2018 13:00 — forked from myusuf3/uninstall.sh
how to cleanly uninstall python packages installed with python setup.py
# Next time you need to install something with python setup.py -- which should be never but things happen.
python setup.py install --record files.txt
# This will cause all the installed files to be printed to that directory.
# Then when you want to uninstall it simply run; be careful with the 'sudo'
cat files.txt | xargs sudo rm -rf
@alchem0x2A
alchem0x2A / gpaw_config_euler.md
Last active September 23, 2019 14:20
Configure GPAW on euler cluster

Preparation

  • Compiler: python/3.1.1 (shipped) gcc-6.3.0, open_mpi/3.0.0, libxc/4.3.0, fftw/3.3.3, openblas/0.2.13_seq, scalapack
  • tar for numpy scipy matplotlib

Working on virtualenv

python -m venv gpaw
source ~/.virtualenv/gpaw/bin/activate

Alternatively, if you want to use the shipped =numpy= and =scipy= versions,

@alchem0x2A
alchem0x2A / sub_job_comsol_lsf.sh
Last active May 26, 2018 10:32
Template submission script for comsol in lsf
#Generic script for submitting comsol job
#usage: sub_job.sh [COMSOL_IN_NAME] [optional:MEM]
INFILE=$1
OUTFILE=$(echo $INFILE | cut -f 1 -d ".")
OUTFILE+="_out.mph"
#Memory alloc
MEM=4096
if [ $# -ge 2 ]; then
MEM=$2