Skip to content

Instantly share code, notes, and snippets.

@zz-jason
zz-jason / periodically.sh
Created November 29, 2023 07:49
Run a command periodically
#!/bin/bash
# Set the default period to 1 second
period=1
# Parse the command line arguments
while getopts ":p:" opt; do
case ${opt} in
p )
period=$OPTARG
@zz-jason
zz-jason / dump-stack-trace.md
Created November 23, 2023 05:41
Dump stack trace with pstack or gdb

Dump stack trace for all threads with GDB

For running process:

gdb attach -p ${PID} -ex "thread apply all bt" -ex "detach" -ex "quit" > stacktrace-${PID}.log

For coredump:

@zz-jason
zz-jason / build-gcc-from-source.md
Last active November 17, 2023 08:53
Build GCC from source

Build GCC from source

Download:

wget https://ftp.tsukuba.wide.ad.jp/software/gcc/releases/gcc-12.3.0/gcc-12.3.0.tar.gz
tar zxf gcc-12.3.0.tar.gz
cd gcc-12.3
./contrib/download_prerequisites
package main
import (
"math/rand"
"sync"
"sync/atomic"
"testing"
"time"
)

Download, Build, and Install

export ZSH_HOME=/opt/zsh-5.9

wget https://sourceforge.net/projects/zsh/files/zsh/5.9/zsh-5.9.tar.xz/download
tar -xvJf download
mv zsh-5.9 zsh-5.9-src && cd zsh-5.9-src

./configure --prefix=$ZSH_HOME

1. Install Dependencies:

sudo yum install git gcc gcc-c++ ncurses-devel python3 python3-devel -y

2. Clone:

git clone --depth 1 https://github.com/vim/vim ~/vim
################################################################################
# brew configuration
################################################################################
eval "$(/opt/homebrew/bin/brew shellenv)"
export PATH=/opt/homebrew/opt/libtool/libexec/gnubin:$PATH
################################################################################
# fzf configuration
###############################################################################
# COLOUR (Solarized dark) #
###############################################################################
set-option -g status-style fg=yellow,bg=black #yellow and base02
set-window-option -g window-status-style fg=brightblue,bg=default #base0 and default
set-window-option -g window-status-current-style fg=brightred,bg=default #orange and default
set-option -g pane-border-style fg=black #base02
set-option -g pane-active-border-style fg=brightgreen #base01
set-option -g message-style fg=brightred,bg=black #orange and base01
@zz-jason
zz-jason / .vimrc
Last active January 19, 2024 06:48
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" General
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" set how many lines of history VIM has to remember
set history=1000
" enable filetype plugins
" filetype plugin on
" filetype indent on
filetype on
@zz-jason
zz-jason / prompt.md
Last active January 4, 2023 05:30
prompts

bash

export PS1='\n\033[0;33m\u@10.150.180.208:\033[0;34m\w\033[0;32m$(__git_ps1 " (git:%s)") \033[0;39m\n$ '

mysql

export mysql_local = 'mysql --default-character-set=utf8 -h 127.0.0.1 -P 3306 -u root -D test --local-infile --prompt="MySQL(\\u@\\h:\\d) > "'