Skip to content

Instantly share code, notes, and snippets.

@lisanhu
lisanhu / pip-update-all.sh
Created November 5, 2018 17:03
pip update all outdated packages
pip list --format freeze | cut -f 1 -d = | xargs pip install --upgrade
@lisanhu
lisanhu / check-os-release.sh
Created November 6, 2018 19:04
commands for checking linux os release info (name, etc.)
# origin at https://www.cyberciti.biz/faq/how-to-check-os-version-in-linux-command-line/
cat /etc/os-release
lsb_release -a
hostnamectl
uname -a
@lisanhu
lisanhu / openacc_test.c
Created March 24, 2019 23:17
OpenACC test code
/**
* A test code to test whether PGI compiler is successfully installed and configured
* for openacc code.
*
* Origin: https://www.olcf.ornl.gov/tutorials/openacc-vector-addition/
*
* Minor changes to print out information when data initialization on host is done
* Compile the code with command line: `pgcc -Minfo -ta=tesla openacc_test.c -o test.out`
*/
#include <stdio.h>
@lisanhu
lisanhu / cmake-test-vendor.txt
Created March 25, 2019 00:48
CMake testing C/CXX compiler vendor
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
# using GCC
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
# using Clang
#elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
# using Intel C++
#elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
# using Visual Studio C++
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "PGI")
# using PGI
@lisanhu
lisanhu / custom_lib_setting.sh
Last active April 2, 2019 20:29
custom lib path settings
# Custom lib home
export LIB_HOME=/home/lisanhu/mine/lib;
# Normal lib config
export PATH=$LIB_HOME/bin:$PATH;
export CPATH=$LIB_HOME/include:$CPATH;
export MANPATH=$MANPATH:$LIB_HOME/share/man;
export LIBRARY_PATH=$LIB_HOME/lib:$LIBRARY_PATH; # for static libraries
export LD_LIBRARY_PATH=$LIB_HOME/lib:$LD_LIBRARY_PATH; # for dynamic libraries
@lisanhu
lisanhu / pgi_silent_env.sh
Last active May 3, 2019 01:50
Environment Variables for PGI compiler installation (silent install env and bashrc settings)
# Pre-install environment variables
export PGI_SILENT=true;
export PGI_ACCEPT_EULA=accept;
export PGI_INSTALL_DIR=~/opt/pgi;
export PGI_INSTALL_TYPE=single;
export PGI_INSTALL_NVIDIA=false; # For systems without NVIDIA or pre-installed CUDA
# Post-install environment settings
export PGI=~/opt/pgi; # Note: this is the custom installation folder instead of the default /opt/pgi
export PGI_ARCH=linux86-64;
@lisanhu
lisanhu / TUTORIAL.txt
Created June 3, 2019 20:12
Emacs Tutorial Cheat Sheet
# Moving short-cuts
C-v next page
M-v previous page
C-l make cursor middle
Number means how many lines above this line
C-n next line
C-p previous line
C-f one character forward
C-b one character backward
@lisanhu
lisanhu / cleanup.sh
Last active July 3, 2019 04:14
Clean up PATH like environment variables to remove duplicates
echo -n $PATH | awk 'NF && !seen[$0]++ {printf "%s:", $0}' RS=':'
@lisanhu
lisanhu / .rustfmt.toml
Created August 13, 2019 02:31
rustfmt format configuration
brace_style = "PreferSameLine"
@lisanhu
lisanhu / sample.cc
Created February 24, 2020 21:06
Deepcopy Sample code in Cpp
typedef struct Outer {
int *data, w, h;
#pragma acc policy<dpmove> copy(data[:w])
// Outer(int *data = nullptr, int w = 0, int h = 0): data(data) {}
} Outer;
Outer init_outer(int *data, int w, int h) {
Outer r = {data, w, h};
return r;
}