Skip to content

Instantly share code, notes, and snippets.

View ljjjustin's full-sized avatar

Jiajun Liu ljjjustin

View GitHub Profile
#!/bin/bash
# 96 core at most
calc_rps_cpus()
{
local cpu_ids=$(echo $@ | sort)
local h=0
local m=0
local l=0
@ljjjustin
ljjjustin / trace_net_drop.stp
Last active May 30, 2022 15:42
trace_net_drop.stp
https://cloud.tencent.com/developer/article/1631874
@ljjjustin
ljjjustin / README.md
Created May 21, 2022 15:06 — forked from chuyik/README.md
macOS 给 Git(Github) 设置代理(HTTP/SSH)
@ljjjustin
ljjjustin / vimrc
Last active December 25, 2022 07:26
use channel to send yanked content
function! s:send2ssh()
if has("nvim")
let ch = sockconnect('tcp', '127.0.0.1:22222')
if ch == 0
echomsg "failed to connect 127.0.0.1:22222"
endif
call chansend(ch, getreg('"'))
call chanclose(ch)
else
let ch = ch_open('127.0.0.1:22222')
@ljjjustin
ljjjustin / README
Last active May 19, 2022 04:42
vim remote copy
# How to setup?
1. local: add sshconfig to your ~/。ssh/config
2. local: copy pbcopy.plist to HOME/Library/LaunchAgents/ and load it with:
launchctl load -w $HOME/Library/LaunchAgents/pbcopy.plist
3. remote: add vimrc to your remote server's vim config file ~/.vimrc
4. remote: copy pbcopy to your remote server and make it excutable
chmod +x /usr/local/bin/pbcopy
5. remote: run vim and yank
6. local: paste the yanked content
@ljjjustin
ljjjustin / mkpasswd.py
Created May 11, 2022 08:14 — forked from lorin/mkpasswd.py
Generate a password hash suitable for /etc/shadow. Warning: Gives incorrect value on OS X.
#!/usr/bin/env python
"""
Generate a password hash, suitable for /etc/shadow
Inspired by this code from OpenStack:
https://github.com/openstack/nova/blob/stable/grizzly/nova/virt/disk/api.py#L549
Usage:
mkpasswd <passwd> [--algo=<hash>]
@ljjjustin
ljjjustin / bible-convert-from-sqlite3-to-zefania.py
Last active December 15, 2020 08:26
convert sqlite3 format bible to zefania format
#!/usr/bin/env python
import os
import re
import sys
import sqlite3
import zhconv
book_name_map = {
#!/bin/bash
if grep -q pypi.pdcts.com.cn /etc/hosts; then
sed -i "/pypi.pdcts.com.cn/ d" /etc/hosts
fi
echo "10.1.1.2 pypi.pdcts.com.cn" >> /etc/hosts
mkdir -p ~/.pip/
touch ~/.pip/pip.conf
@ljjjustin
ljjjustin / README-setup-socket-activated-systemd-service.md
Created December 18, 2019 14:23 — forked from drmalex07/README-setup-socket-activated-systemd-service.md
An example inetd-like socket-activated service. #systemd #inetd #systemd.socket

README

This is an example of a socket-activated per-connection service (which is usually referred to as inetd-like service). A thorough explanation can be found at http://0pointer.de/blog/projects/inetd.html.

Define a socket unit

The key point here is to specify Accept=yes, which will make the socket accept connections (behaving like inetd) and pass only the resulting connection socket to the service handler.

@ljjjustin
ljjjustin / shared-tmux.sh
Last active December 18, 2019 03:25
create a shared tmux session
#!/bin/bash
mksock() {
local SOCK=$1
if [ ! -e ${SOCK} ]; then
SF="$1" python -c "import os, socket as s; s.socket(s.AF_UNIX).bind(os.environ['SF'])"
fi
}