Skip to content

Instantly share code, notes, and snippets.

View chongshenng's full-sized avatar

Chong Shen Ng chongshenng

View GitHub Profile
@chongshenng
chongshenng / .bash_profile
Last active January 3, 2023 11:30
Useful .bash_profile settings for MacOS and *nix
export PS1='\u@mac \W:~\$ '
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
alias ls='ls -Ga --color'
alias ll='ls -l'
alias llrt='ll -rth'
alias lls='ll -l --block-size=MB'
alias la='ls -a'
@chongshenng
chongshenng / Plot_Examples.md
Created January 25, 2021 15:57 — forked from gizmaa/Plot_Examples.md
Various Julia plotting examples using PyPlot
@chongshenng
chongshenng / Makefile
Created October 8, 2021 09:49 — forked from mpneuried/Makefile
Simple Makefile to build, run, tag and publish a docker containier to AWS-ECR
# import config.
# You can change the default config with `make cnf="config_special.env" build`
cnf ?= config.env
include $(cnf)
export $(shell sed 's/=.*//' $(cnf))
# import deploy config
# You can change the default deploy config with `make cnf="deploy_special.env" release`
dpl ?= deploy.env
include $(dpl)
@chongshenng
chongshenng / fix-vpn-wifi.txt
Created April 29, 2022 08:28
Fix Ubuntu wifi after disconnecting from VPN
# Restart NetworkManager
nmcli networking off
nmcli networking on
# Restart Wireless interface via ifconfig
# Replace wlo1 with your wifi network name (check with ifconfig)
sudo ifconfig wlo1 down
sudo ifconfig wlo1 up
@chongshenng
chongshenng / textdiff.py
Last active May 11, 2022 13:10
Python function to print text diffs with html using Google's diff-match-patch
# Import tools for displaying Htmls
from IPython.display import display, HTML
# Import library for string diff
import diff_match_patch as dmp_module
def print_text_diff(text1, text2):
# Compute the diff
dmp = dmp_module.diff_match_patch()
diff = dmp.diff_main(text1, text2)
# Return a pretty Html sequence
# Check what process is occupying port 8080
netstat -apln | grep 8080
# Display information about current process
ps -ef | grep <process-id>
@chongshenng
chongshenng / set_env.sh
Last active May 20, 2022 09:55
Export environment variables to workspace
#!/usr/bin/env bash
# Usage:
# source ./set_env.sh
# Reference:
# https://stackoverflow.com/a/20909045
# Export env vars
export $(grep -v '^#' env_vars.env | xargs)
@chongshenng
chongshenng / gist:f473e7b4dc59b263661b20a26a79c834
Created May 20, 2022 08:31
Enable 3-finger pan like MacOS on Ubuntu 20.04
1. Install steps from https://github.com/marsqing/libinput-three-finger-drag
2. Run `sudo apt-get install -y libinput-tools`
3. Run `sudo apt-get install -y libxdo-dev`
4. Create custom libinput-gestures at `~/.config/libinput-gestures.conf`
5. Test by running binary from step 1
@chongshenng
chongshenng / docker_quick_install.txt
Created June 6, 2022 11:42
Quick install Docker on Ubuntu 20.04LTS
# Reference: https://github.com/adap/flower/tree/main/examples/embedded_devices#setting-up-a-raspberry-pi-3b-or-4b
# make sure your OS is up-to-date
$ sudo apt-get update
# get the installation script
$ curl -fsSL https://get.docker.com -o get-docker.sh
# install docker
$ sudo sh get-docker.sh
@chongshenng
chongshenng / check_powerline_symbols.txt
Created June 8, 2022 08:40
Check that symbols in powerline fonts work as expected
# Ref: https://github.com/gpakosz/.tmux/issues/171#issuecomment-406661487
printf '%b\n' '\ue0b0\ue0b1\ue0b2\ue0b3'