Skip to content

Instantly share code, notes, and snippets.

View shaobosong's full-sized avatar
🐣
parenting

Shaobo Song shaobosong

🐣
parenting
View GitHub Profile
@shaobosong
shaobosong / tscp.sh
Last active July 5, 2024 04:30
This bash script facilitates secure file and directory transfers between a local machine and a remote server using SSH, handling both upload and download operations with compression and decompression capabilities.
#!/bin/bash
# set -ex
usage() {
echo "Usage: $0 [-h|--help] [ssh_options] SOURCE_PATH TARGET_PATH"
echo ""
echo "SOURCE_PATH and TARGET_PATH can be either local or remote paths."
echo "Remote paths should be in the format user@server:/path"
echo "Paths don't support wildcard syntax"
echo ""
@shaobosong
shaobosong / riscv-insn-gen.h
Created August 2, 2023 01:26
Aim to generate RV32I/RV64I instructions
#define extract32(value, start, length) \
(((value) >> (start)) & (~0 >> (32 - (length))))
#define MAX_MXL 64
#define MXL_MASK (MAX_MXL - 1)
#define x(i) (i)
#define zero_r x(0)
#define ra_r x(1)
@shaobosong
shaobosong / cd-index.sh
Last active July 5, 2024 03:54
This script displays and navigates directories using indexed positions for efficient directory switching.
#!/bin/bash
# Usage:
# source cd-index.sh [INDEX]
# Example:
# $ echo 'alias ci="source /path/cd-index.sh"' >> ~/.bashrc
# $ source ~/.bashrc
# $ ci
# /home/user/some/path
# ----3----2----1----0
# 2 (input a index)
@shaobosong
shaobosong / win-ldd.sh
Last active July 5, 2024 03:48
ldd for windows PE file in linux
#!/usr/bin/env bash
# win-ldd
#
# Based on
# https://github.com/shiluotang/ldd-light/blob/master/ldd-light
#
# Example:
# ./win-ldd.sh --dir=path1 --dir=path2 *.dll *.exe
#