Skip to content

Instantly share code, notes, and snippets.

@lisanhu
lisanhu / colors.sh
Last active Sep 2, 2021
view terminfo colors and their corresponding color code
View colors.sh
#!/bin/bash
# origin: https://unix.stackexchange.com/questions/269077/tput-setaf-color-table-how-to-determine-color-codes
color(){
for c; do
printf '\e[48;5;%dm%03d ' $c $c # adding one more space in the end to seperate the numbers
done
printf '\e[0m \n'
}
@lisanhu
lisanhu / nvhpc-link-libs.txt
Created Aug 4, 2021
nvhpc linking libraries ( get from -dryrun flag )
View nvhpc-link-libs.txt
@lisanhu
lisanhu / sample.cc
Created Feb 24, 2020
Deepcopy Sample code in Cpp
View sample.cc
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;
}
@lisanhu
lisanhu / .tmux.conf
Last active Aug 10, 2022
tmux configuration
View .tmux.conf
# enable colors in tmux
set -g default-terminal "xterm-256color"
# changing prefix from 'Ctrl+b' to 'Ctrl+b'
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix
# enable mouse scrolling
set -g mouse on
@lisanhu
lisanhu / .rustfmt.toml
Created Aug 13, 2019
rustfmt format configuration
View .rustfmt.toml
brace_style = "PreferSameLine"
@lisanhu
lisanhu / cleanup.sh
Last active Jul 3, 2019
Clean up PATH like environment variables to remove duplicates
View cleanup.sh
echo -n $PATH | awk 'NF && !seen[$0]++ {printf "%s:", $0}' RS=':'
@lisanhu
lisanhu / TUTORIAL.txt
Created Jun 3, 2019
Emacs Tutorial Cheat Sheet
View TUTORIAL.txt
# 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 / .bashrc
Last active Aug 10, 2022
Pop OS defaut .bashrc file
View .bashrc
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
# don't put duplicate lines in the history. See bash(1) for more options
# ... or force ignoredups and ignorespace
HISTCONTROL=ignoredups:ignorespace
@lisanhu
lisanhu / cmake-test-vendor.txt
Created Mar 25, 2019
CMake testing C/CXX compiler vendor
View cmake-test-vendor.txt
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 Apr 2, 2019
custom lib path settings
View custom_lib_setting.sh
# 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