Skip to content

Instantly share code, notes, and snippets.

View BenSYZ's full-sized avatar

Ben BenSYZ

View GitHub Profile
#!/bin/sh
# shellcheck disable=SC2016
git rebase "$@" \
--exec 'commit_date="$(git log -1 HEAD --pretty=format:"%ad")" && git log -1 HEAD && git log -1 HEAD --pretty=format:"%ad" && git commit --amend --no-edit --reset-author --date="$commit_date"'
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <assert.h>
#include <signal.h>
#define BYTE sizeof(int8_t)
#define KILOBYTE 1024*BYTE
#define MEGABYTE 1024*KILOBYTE
#define GIGABYTE 1024*MEGABYTE
#!/bin/sh
while read line;do
echo $line
cd $line
repo_name=$(git remote -v |grep -E '.*https://aur.tuna.tsinghua.edu.cn/.*' |awk '{print $2}' |head -n1 |awk -v FS='/' '{print $4}')
if [[ "$repo_name" != "" ]];then
git remote set-url origin https://aur.archlinux.org/$repo_name
#git remote -v |head -n1
#echo https://aur.archlinux.org/$repo_name
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
import math
def Hamiltonian3(k):
# 元胞内的两个C原子坐标
pos1 = np.array([0, 0])
pos2 = np.array([0, 1])
@BenSYZ
BenSYZ / ipynb2py.sh
Last active November 15, 2021 11:19
#!/bin/zsh
cat $1 |\
jq '.cells|.[] |select(.cell_type == "code") | .source|.[]' |\
sed -n 's/"\(.*\)\\n"/\1/p' |\
sed 's/\\"/"/g' > $1.py
# jq select code cell
# sed 1. remove the prefix " and suffix \n"
# 2. " in code will save as \"
####################################################
# the _ after password filed will cause error, change it with 6, after decode there will be a '/' in the string, so
# if without the last '=' invalid. `echo -n "$str"| base64 -d |base64` give me an extra '=', so added
# /_/6/: after password fieled
# /\///: after password field
# /-/+/: remark 韩国
#string1=$(tail -n1 ss |sed 's/_/6/g' |sed 's/$/=/' |base64 -d |sed 's/\///'| sed 's/-/+/g')
# 最后生成的目标,即module_example.ko
obj-m:=module_example.o
CURRENT_PATH := $(shell pwd)
LINUX_KERNEL := $(shell uname -r)
LINUX_KERNEL_PATH := /usr/lib/modules/$(LINUX_KERNEL)/build
all:
make -C $(LINUX_KERNEL_PATH) M=$(CURRENT_PATH) modules
clean:
make -C $(LINUX_KERNEL_PATH) M=$(CURRENT_PATH) clean
@BenSYZ
BenSYZ / awk_grep_except_the_first_line.sh
Created April 26, 2021 02:53
awk grep except the first line
#!/bin/sh
var="$*"
lsof -i|awk -v pattern="$var" '
NR==1 {print $0};
NR>=1 && $0 ~ pattern {print $0}'