Skip to content

Instantly share code, notes, and snippets.

View grammy-jiang's full-sized avatar
:octocat:
Do one thing, do it well

Grammy Jiang grammy-jiang

:octocat:
Do one thing, do it well
View GitHub Profile
@grammy-jiang
grammy-jiang / postgresql_dump_and_restore.md
Last active September 17, 2022 01:21
PostgreSQL dump and restore within Docker

PostgreSQL dump and restore within Docker

Dump a database in PostgreSQL with pg_dump inside a docker container

docker run \
  -it --rm -v <volume>:/tmp/pg_dump postgres:latest \
  pg_dump \
  --host=<host> --port=<port> \
  --username=<username> --password \
 --dbname= -f /tmp/pg_dump/.sql
@grammy-jiang
grammy-jiang / update_all_docker_images_and_remove_none_label_images.md
Last active December 10, 2020 20:37
Update all docker images & Remove the images with the label '<None>'

Update all docker images and remove dangling ones

Update all images with the 'latest' label

docker images --format "{{.Repository}}:{{.Tag}}" | grep ':latest' | xargs -L1 docker pull

Remove the dangling images

docker rmi $(docker images --quiet --filter "dangling=true")
@grammy-jiang
grammy-jiang / mongo_dump_and_restore.md
Last active October 7, 2022 13:37
MongoDB dump and restore within Docker

MongoDB dump and restore within Docker

MongoDB dump

prompt the user for password

foo@bar:~$ docker run --interactive --tty --rm --network=<network> --volume=<volume>:/tmp \
  mongo:latest \
  mongodump \
@grammy-jiang
grammy-jiang / docker for mssql.md
Last active June 13, 2019 01:58
Docker for MSSql
  1. start MSSql with docker-compose
version: "3"
services:
  mssql:
    container_name: dc-mssql
    environment:
      ACCEPT_EULA: Y
      SA_PASSWORD: P@ssw0rd
@grammy-jiang
grammy-jiang / setup_raspberry_pi_environment.md
Last active May 31, 2024 14:09
Setup Raspberry Pi Environment (Raspbian)

Major Tools

foo@bar:~$ sudo -- sh -c "timedatectl set-timezone Australia/Sydney && date" && \
sudo -- sh -c "apt-get update && apt-get upgrade -y && apt-get dist-upgrade -y && apt-get autoremove -y" && \
sudo -- sh -c "apt-get install -y vim-nox && wget --output-document=/etc/vim/vimrc.local https://git.io/JvpS2" && \
sudo -- sh -c "apt-get install -y curl direnv exa git lnav mosh tig tree vifm watchman" && \
sudo -- sh -c "apt-get install -y python3-pip python3-testresources python3-pywatchman"
@grammy-jiang
grammy-jiang / vimrc.local
Last active October 31, 2022 12:17
/etc/vim/vimrc.local
" =============================================================================
" Github URL
" https://gist.githubusercontent.com/grammy-jiang/ae2218062be5f493e24492ad6b62b3a2/raw
" Shorten URL
" https://git.io/JvpS2
" =============================================================================
set nocompatible
" Vim5 and later versions support syntax highlighting. Uncommenting the next
@grammy-jiang
grammy-jiang / knockd (etc_defalut_knockd)
Last active March 7, 2020 12:50
/etc/default/knockd on Raspberry Pi, refer to https://linux.die.net/man/1/knockd
# control if we start knockd at init or not
# 1 = start
# anything else = don't start
# PLEASE EDIT /etc/knockd.conf BEFORE ENABLING
START_KNOCKD=1
# command line options
KNOCKD_OPTS="--interface eth0"
@grammy-jiang
grammy-jiang / knockd.conf
Last active March 8, 2020 05:06
/etc/knockd.conf on Raspberry Pi, refer to https://linux.die.net/man/1/knockd
[options]
UseSyslog
[opencloseSSH]
sequence = 7000,8000,9000
seq_timeout = 5
tcpflags = syn
start_command = /usr/bin/firewall-cmd --zone=public --add-service=ssh
cmd_timeout = 10
stop_command = /usr/bin/firewall-cmd --zone=public --remove-service=ssh
@grammy-jiang
grammy-jiang / public.xml
Last active March 16, 2020 01:27
The zone configuration of public
<?xml version="1.0" encoding="utf-8"?>
<zone>
<short>Public</short>
<description>For use in public areas. You do not trust the other computers on networks to not harm your computer. Only selected incoming connections are accepted.</description>
<interface name="eth0"/>
<service name="dhcpv6-client"/>
<service name="mosh"/>
</zone>
@grammy-jiang
grammy-jiang / firewalld.conf
Created March 16, 2020 04:14
The configuration of firewalld
# firewalld config file
# default zone
# The default zone used if an empty zone string is used.
# Default: public
DefaultZone=public
# Minimal mark
# Marks up to this minimum are free for use for example in the direct
# interface. If more free marks are needed, increase the minimum