Skip to content

Instantly share code, notes, and snippets.

View ljjjustin's full-sized avatar

Jiajun Liu ljjjustin

View GitHub Profile
@ljjjustin
ljjjustin / modify-qcow2-image.sh
Created December 8, 2016 08:55
modify qcow2 image using qemu-nbd
#!/bin/bash
if [ $# -ne 1 ]; then
echo "usage: $0 <qcow2 image>"
exit
fi
image=$1
target=$(mktemp -d)
cleanup_on_exit() {
@ljjjustin
ljjjustin / socat-tcp-to-unix-socket.sh
Last active April 4, 2024 15:00
socat-unix-socket-to-tcp.sh
#!/bin/bash
if [ $# -ne 3 ]; then
echo "usage: $0 <unix socket file> <host> <listen port>"
exit
fi
SOCK=$1
HOST=$2
PORT=$3
@ljjjustin
ljjjustin / README.md
Created July 11, 2017 06:19 — forked from andyshinn/README.md
pbcopy over SSH

Install

  • Add pbcopy.plist to your ~/Library/LaunchAgents/ folder.
  • Launch the listener with launchctl load ~/Library/LaunchAgents/pbcopy.plist.
  • Add RemoteForward 2224 127.0.0.1:2224 in your ~/.ssh/config file under your Host * or specific hosts sections.
  • Add [ -n "$SSH_CLIENT" ] && alias pbcopy="nc localhost 2224" to your remote ~/.bash_profile or other shell profile.
  • Enjoy pbcopy remotely!
mysql -e "CREATE USER 'repl'@'%' IDENTIFIED BY 'slavepass'"
mysql -e "GRANT REPLICATION SLAVE ON *.* TO 'repl'@'%'"
#!/bin/bash
if [ $# -ne 1 ]; then
echo "usage: $0 <uuid or name>"
exit
fi
get_ephymeral_port() {
LPORT=32768;
UPORT=60999;
@ljjjustin
ljjjustin / nginx.conf
Created August 30, 2017 13:56 — forked from dctrwatson/nginx.conf
Caching NPM proxy using Nginx
user www-data;
worker_processes 4;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
@ljjjustin
ljjjustin / sslvpn.sh
Created December 12, 2017 01:26
setup ssh vpn in one script
#!/bin/bash
vpn_server=10.70.239.196
vpn_tunnel_id=8
vpn_ip_prefix=192.168.48
vpn_monitor_port=50008
ensure_tun_device() {
local host=$1
local device=$2
#!/bin/bash
if [ $# -ne 1 ]; then
echo "usage: $0 <image name>"
exit
fi
image=$1
rbd -p pool-beishu snap unprotect ${image}@snap
rbd -p pool-beishu snap rm ${image}@snap
#!/bin/bash
if [ $# -ne 1 ]; then
echo "usage: $0 <image name>"
exit
fi
image=$1
rbd -p pool-beishu snap unprotect ${image}@snap
rbd -p pool-beishu snap rm ${image}@snap
#!/bin/bash
if [ $# -ne 1 ]; then
echo "usage: $0 <volume id>"
fi
volume_id=$1
## check if volume exists
if cinder show ${volume_id} | grep -q 'No volume'; then