Skip to content

Instantly share code, notes, and snippets.

View yurenchen000's full-sized avatar
😶‍🌫️
may be slow to respond.

yurenchen000

😶‍🌫️
may be slow to respond.
View GitHub Profile
@yurenchen000
yurenchen000 / pipenv_virtualenv_calc.py
Created November 27, 2019 17:55
pipenv calcate virtualenv name
# https://github.com/pypa/pipenv/issues/1049
# https://github.com/pypa/pipenv/blob/a4aca53b5d02a4168214a487714d9836c9415a0c/pipenv/project.py#L116
# How pipenv calc virtualenv name in `~/.local/share/virtualenvs/`
import os, re, base64, hashlib
def virtualenv_name(path):
sanitized = re.sub(r'[ $`!*@"\\\r\n\t]', '_', os.path.basename(path))[0:42]
hash = hashlib.sha256((path+'/Pipfile').encode()).digest()[:6]
encoded_hash = base64.urlsafe_b64encode(hash).decode()
return sanitized + '-' + encoded_hash
@yurenchen000
yurenchen000 / wireshark_remote.sh
Created November 29, 2019 03:39
wireshark capture on remote host ( through ssh tcpdump )
#!/bin/bash
# ssh root@yurenchen.com "tcpdump -w - -U 'host g.cn'" | sudo wireshark -k -i -
# tcpdump Capture on remote host (by ssh) & Show packets on local wireshark
# $remote Need Capture permission
# $filter is tcpdump capture filter
# example:
# $ wireshark_remote root@10.1.1.2 'host yurenchen.com'
wireshark_remote(){
@yurenchen000
yurenchen000 / _sort_test.js
Last active December 9, 2019 08:06
test cmds
//test js
console.log('hello')
@yurenchen000
yurenchen000 / comm.vimrc
Last active December 10, 2019 09:45
vimrc snippets
" show line number
set nu
" hi cursor line
set cursorline
"hi CursorLine cterm=NONE ctermbg=darkred ctermfg=white
"hi CursorLine cterm=NONE ctermbg=darkred
" highlight search
se hls
@yurenchen000
yurenchen000 / ubuntu14_fix_ssh
Last active December 12, 2019 10:57
tmp note
sudo ifconfig eth0 mtu 1200
@yurenchen000
yurenchen000 / opkg_compare-versions_oddly.md
Last active December 21, 2019 13:48
opkg compare-versions operator oddly

$ opkg --help

compare-versions <v1> <op> <v2>
                    compare versions using <= < > >= = << >>

$ man build_dir/hostpkg/opkg-2017-12-07-3b417b9f/man/opkg-cl.1.in

compare-version <version1> <operator> <version2>
 compare versions using following operators :
@yurenchen000
yurenchen000 / flag_hide_usage.go
Created December 26, 2019 04:36
goang flag hide cmdline usage & parse err
// golang hide cmdline usage & parse err
flag.CommandLine.SetOutput(ioutil.Discard)
flag.Usage = func() { }
flag.Parse()
@yurenchen000
yurenchen000 / git_config_snip.md
Last active December 27, 2019 10:11
git config snippets

show config

git config --global -l

OUT:

@yurenchen000
yurenchen000 / base64.awk
Last active May 13, 2022 23:29
base64 implement in awk & hexdump
#!/usr/bin/awk -f
# from https://sites.google.com/site/dannychouinard/Home/unix-linux-trinkets/little-utilities/base64-and-base85-encoding-awk-scripts
#
# compatible with busybox:
# no od, awk not print \0
function encode64() {
while( "hexdump -e ' \"%07.7_ax \" 16/1 \"%02x \" \"\n\"'" | getline ) {
for(c=9; c<=length($0); c++) {
d=index("0123456789abcdef",substr($0,c,1));
@yurenchen000
yurenchen000 / go_get_xxx_proxy.sh
Last active March 30, 2022 09:10
go get xxx with proxy
# http*_proxy
export http_proxy=socks5://proxyAddress:port
export https_proxy=socks5://proxyAddress:port
# OR all_proxy
export all_proxy=socks5://proxyAddress:port
# ----------------