Skip to content

Instantly share code, notes, and snippets.

View adonis0147's full-sized avatar

Adonis Ling adonis0147

View GitHub Profile
@adonis0147
adonis0147 / save_ssh_client_ip.sh
Created October 25, 2023 15:33
Save SSH client IP
ssh -t <host> "export CLIENT_IP=${SSH_CLIENT/ */}; bash -l"
# # .bash_profile
# if [[ -f "${HOME}/devel/bin/zsh" ]]; then
# exec "${HOME}/devel/bin/zsh" -l
# fi
### Zinit Setting
if dircolors_cmd="$(command -v gdircolors || command -v dircolors)"; then
eval "$("${dircolors_cmd}")"
#!/usr/bin/expect
trap {
set rows [stty rows]
set cols [stty columns]
stty rows $rows columns $cols < $spawn_out(slave,name)
} WINCH
env:
TERM: alacritty
colors:
primary:
foreground: '#F8F8F2'
background: '#272822'
normal:
black: '#272822'
red: '#F92672'
@adonis0147
adonis0147 / QEMU.md
Last active October 11, 2021 14:20
QEMU scripts

QEMU

Prerequisite

  • MacOS >= Big Sur
  • vde_vmnet

Install vde_vmnet

  1. Install https://github.com/lima-vm/vde_vmnet.
  2. Modify /Library/LaunchDaemons/io.github.virtualsquare.vde-2.vde_switch.plist and /Library/LaunchDaemons/io.github.lima-vm.vde_vmnet.plist to use the correct program path.
  3. Start the vde_switch and vde_vmnet.
# DockerHub: https://hub.docker.com/_/postgres
# Start an instance.
docker run --name postgres -e POSTGRES_PASSWORD=postgres -d postgres
# Link the instance.
docker run -it --rm --link postgres postgres psql -h postgres -U postgres
set tui tab-width 2
define hook-file
directory
end
@adonis0147
adonis0147 / iptables-conf.sh
Last active September 28, 2018 15:26
iptables forwarding between two interfaces (connect docker containers in virtual machine with host)
#!/bin/bash
# reference: https://serverfault.com/questions/431593/iptables-forwarding-between-two-interface
# MacOS host
# sudo route -n add 172.17.0.0/16 192.168.1.9
# virutal machine which runs docker containers
# echo 1 > /proc/sys/net/ipv4/ip_forward
sudo iptables -A FORWARD -i ens33 -o docker0 -j ACCEPT
sudo iptables -A FORWARD -i docker0 -o ens33 -m state --state ESTABLISHED,RELATED -j ACCEPT
@adonis0147
adonis0147 / bin.xml
Created August 9, 2018 06:30
maven project settings
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd">
<id>all</id>
<formats>
<format>tar.gz</format>
</formats>
<fileSets>
<fileSet>
<directory>target</directory>
@adonis0147
adonis0147 / .tmux.conf
Last active May 26, 2023 03:23
tmux-config
# https://gist.github.com/bbqtd/a4ac060d6f6b9ea6fe3aabe735aa9d95
set -g default-terminal "tmux-256color"
set -g mode-keys vi
set -g mouse on
set -g escape-time 10
set -g focus-events on
set -sa terminal-overrides ',alacritty:RGB'
set -s set-clipboard on
set -g status-style bg=colour148,fg=colour22,bold