Skip to content

Instantly share code, notes, and snippets.

View Fatpandac's full-sized avatar
🤠
Focusing

Fatpandac

🤠
Focusing
View GitHub Profile
@Fatpandac
Fatpandac / lss.sh
Created January 20, 2024 08:29
List all the local nodes and Python servers.
lss() {
select=$(lsof -Pn | grep LISTEN | awk '{cmd = "ps -o command= -p"$2; printf "%s ||| %s ||| ",$1,$9; system(cmd)}' | grep -iE '^node|^python' | fzf)
if [ -z != $select ];then
port=$(echo $select | awk '{print $3}' | cut -d':' -f2)
localIP=$(ipconfig getifaddr en0)
open http://$localIP:$port
fi
}
@Fatpandac
Fatpandac / .zshgit
Created December 7, 2023 06:43
Quick checkout and delete branch by fzf
gitSelectBranch() {
selected=$(git branch -a | grep -v "*" | fzf | sed -e "s/remotes\/origin\///" | sed 's/^\s*\|\s*$//g')
echo "$selected"
}
gitSelectBranchOprateFactory() {
comd=$1
branch=$2
@Fatpandac
Fatpandac / cgs
Last active November 18, 2023 03:39
Change npm source
#!/usr/bin/env bash
if ! type fzf >/dev/null 2>&1; then
echo "请先安装 fzf"
exit 0
fi
declare -A source
source["npm"]="https://registry.npmjs.org/"
source["taobao"]="https://registry.npm.taobao.org/"
@Fatpandac
Fatpandac / Rap2JSDoc.py
Created September 7, 2023 12:05
Rap2JSDoc
import json
def load_data(filePath):
f = open(filePath)
data = json.load(f)
return data
def generateJSDoc(actionList):
jsdoc = list()
jsdoc.append("\\**")
@Fatpandac
Fatpandac / github-qq-bot.ts
Created June 14, 2023 02:34
Push GitHub repo update to channel of QQ qunpro
import { Application, Router } from "https://deno.land/x/oak@v11.1.0/mod.ts";
const sentMsgToQQ = (channelId: string, body: string) => {
const QQ_QUNPRO_API_BASE = "https://sandbox.api.sgroup.qq.com"
const QQ_QUNPRO_API_SENT_MESSAGE = `/channels/${channelId}/messages`
const options = {
method: 'POST',
headers: {
'Authorization': 'Bot ${QQ_BOT_ID}.${QQ_BOT_TOKEN}',
@Fatpandac
Fatpandac / blocker.py
Last active March 4, 2022 15:20
Github Blocker
import requests
import json
github_token = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
headers = { 'Authorization': 'token ' + github_token }
data_url = 'https://raw.githubusercontent.com/sxzz/github-block-tool/main/analyze.json'
get_data = lambda : json.loads(requests.get(data_url).text)
get_user_name = lambda data: list(map(lambda x: x['username'], data))
@Fatpandac
Fatpandac / init.vim
Last active February 24, 2022 05:24
My Neovim configuration
let PlugPathLinux='/home/fatpandac/.config/nvim/plugged'
set number "显示行数
set relativenumber "显示相对行数
set updatetime=300
set cc=80
set t_Co=256
set softtabstop=4
set shiftwidth=4
set showtabline=1
@Fatpandac
Fatpandac / debug.c
Created July 31, 2021 14:25
from 《征服C指针》
#include <stdio.h>
#include <stdarg.h>
/* #define DEBUG */
#ifdef DEBUG
#define DEBUG_WRITE(args) DebugWrite args
#else
#define DEBUG_WRITE(args)
#endif