This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" syntax highlight | |
syntax on | |
" show line number and relative number | |
set number | |
set relativenumber | |
" indent when newline | |
set smartindent |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
if [ $# -ne 1 ]; then | |
echo "USAGE: $0 disk" | |
echo " e.g.: $0 Archlinux.qcow2" | |
exit 1 | |
fi | |
if [ ! -f $1 ]; then | |
echo "could not open $1 : no such file" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
import sys | |
import requests | |
def main(): | |
argv = sys.argv | |
n = len(argv) | |
if n != 2: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local function CodeRunner() | |
--[===[========================== Global ===========================]===] | |
vim.api.nvim_create_autocmd({ "InsertLeave" }, { | |
callback = function() | |
vim.fn.execute("silent! write") | |
-- vim.notify("Autosaved!", vim.log.levels.INFO, {}) | |
end, | |
}) | |
--[===[========================== Static ===========================]===] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/opt/homebrew/bin/python3 | |
import os | |
import re | |
import subprocess as sp # for get command return value(stdout) | |
base_path = "/Applications" | |
app_name = "Ghidra" | |
exec_file = "ghidraRun" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cxxabi.h> | |
#include <iostream> | |
#if __cplusplus < 202002 | |
#define print_type(x) \ | |
std::cout << #x << typeid(x).name() << " => " \ | |
<< abi::__cxa_demangle(typeid(x).name(), NULL, NULL, NULL) \ | |
<< std::endl | |
#else |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
############### for proxy accelerate network ############################ | |
# start_clash.sh: (may stdout in screen, you should use `nohup`) | |
: ' | |
#!/bin/bash | |
./clash -d . & | |
' | |
alias vpn='cd ~/opt/clash && ./start_clash.sh && cd -' | |
alias uvpn='pkill -9 clash' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### 查找指定文件中包含某关键字的指定行(显示行号) | |
# -n 显示行号 | |
grep -n "home" /etc/passwd | |
# 需要先打印模式匹配然后打印行号, 比较麻烦 | |
sed -ne '/home/p' -e '/home/=' /etc/passwd | |
### 查找某些特定文件(例如通过扩展名)中出现的关键字的对应文件名和行号 | |
grep -rn "process" --include='*.cpp' . |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <chrono> | |
using namespace std; | |
using namespace std::chrono; | |
auto start = system_clock::now(); | |
// do something... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// calc factorial | |
auto f=[](int n) { | |
int ans{1}; | |
while (n > 1) ans*= n, --n; | |
return ans; | |
}; | |
// calc combination number | |
auto comb = [](int n, int k) { | |
int ans{1}; | |
for (int i{}; i < k; ++i) ans = ans * (n - i) / (i + 1); // can not `ans *= ` |