Skip to content

Instantly share code, notes, and snippets.

View BH1SCW's full-sized avatar

F.J Kong BH1SCW

View GitHub Profile
@BH1SCW
BH1SCW / git-rpm-changelog.sh
Created February 24, 2023 12:41 — forked from jflemer-ndp/git-rpm-changelog.sh
generate a rpm spec compatible changelog from git history
#!/bin/bash
merge_commit() {
git show --no-patch --format='%P' "$@" | head -1 | grep -q ' '
}
commit_meta() {
git show --no-patch --format="* %cd %aN <%ae> - %H" --date=local "$@" | \
head -1 | \
sed -E 's/^(\* [a-z0-9 ]{9,10}) \d{2}:\d{2}:\d{2}/\1/i'
@BH1SCW
BH1SCW / rpmgpgsign.sh
Created February 24, 2023 12:36 — forked from jflemer-ndp/rpmgpgsign.sh
Wrapper for non-interactive signing of RPMs
#!/bin/bash
##############################################################################
# Wrapper for non-interactive signing of RPMs.
#
# _NOTE: This uses environment variables for sensitive information (the GPG
# passphrase), so should not be used on an untrusted or shared host._
#
# Prep
# ----
@BH1SCW
BH1SCW / create-centos-6.5-mini-unattended-iso.sh
Created January 2, 2023 18:01 — forked from skiane/create-centos-6.5-mini-unattended-iso.sh
# This script create a Centos Minimal Unattended ISO
# This script create a Centos Minimal Unattended ISO
# This method is based on excellent article http://pyxlmap.net/technology/software/linux/custom-centos-iso
#
# This script has be tested with CentOS 6.5
# TODO:
# * test package update to reduce the update task on the target system. The following command downloads all updates :
# (cd $CENTOS_CUSTOM_PATH/Packages ; yumdownloader $(for i in *; { echo ${i%%-[0-9]*}; } ) )
# Some global settings :
@BH1SCW
BH1SCW / 1-usage.txt
Created March 1, 2023 08:11 — forked from eumel8/1-usage.txt
i18njson translate using Google Translate
$ python i18njson-translate.py --help
Usage: i18njson-translate.py [OPTIONS] INPUTFILE OUTPUT
Process and translate .po or JSON files and generate translated .po file
in result. Can work with exist .po files and if in initial file msgid
dissapear then mark translaed string as obsolete. Try to play nice with
version control systems and follow initial file order format, you will get
predicteable diffs.
Options:
@BH1SCW
BH1SCW / oops-panic.grub.cfg
Created January 6, 2023 15:04 — forked from tonejito/oops-panic.grub.cfg
Linux kernel verbose boot and logging to serial console
# Linux kernel verbose boot and logging to serial console
#
# Check Documentation/kernel-parameters.txt [1] to check all aplicable options for your kernel version
#
# VERSION="v"$(uname -r | sed -e 's/\(\.0\)\?-.*$//')
# [1] https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/plain/Documentation/kernel-parameters.txt?id=refs/tags/$VERSION
linux /vmlinuz root=/dev/sda1 ro consoleblank=0 earlyprintk=ttyS0 console=ttyS0 panic=1 oops=panic panic_on_warn verbose INIT_VERBOSE=yes init=/sbin/init -v
initrd /initrd.gz
boot
@BH1SCW
BH1SCW / arm64.md
Created January 19, 2022 01:43 — forked from george-hawkins/arm64.md
Running virtualized x86_64 and emulated arm64 Ubuntu cloud images using QEMU

QEMU arm64 cloud server emulation

This is basically a rehash of an original post on CNXSoft - all credit (particularly for the Virtio device arguments used below) belongs to the author of that piece.

Download the latest uefi1.img image. E.g. ubuntu-16.04-server-cloudimg-arm64-uefi1.img from https://cloud-images.ubuntu.com/releases/16.04/release/

Download the UEFI firmware image QEMU_EFI.fd from https://releases.linaro.org/components/kernel/uefi-linaro/latest/release/qemu64/

Determine your current username and get your current ssh public key:

@BH1SCW
BH1SCW / mount_qcow2.md
Created November 18, 2021 07:39 — forked from shamil/mount_qcow2.md
How to mount a qcow2 disk image

How to mount a qcow2 disk image

This is a quick guide to mounting a qcow2 disk images on your host server. This is useful to reset passwords, edit files, or recover something without the virtual machine running.

Step 1 - Enable NBD on the Host

modprobe nbd max_part=8
@BH1SCW
BH1SCW / Calling_C_From_Rust.md
Created June 13, 2022 03:27 — forked from hempnall/Calling_C_From_Rust.md
Calling C++ code from Rust

Start off with some Rust source code

hw.rs :

#[link(name = "extern")]
extern {
	fn hello();
}

@BH1SCW
BH1SCW / gpgcryptic.txt
Created April 29, 2022 09:37 — forked from cliffano/gpgcryptic.txt
gpg cryptic errors
I started getting the error below after upgrading to gpg (GnuPG) 2.1.21 .
gpg: signing failed: Timeout
gpg: signing failed: Timeout
This was confusing at first, but the timeout was caused by gpg showing a password prompt that takes the full screen of the terminal, and after a period of time, it returned to the command line showing the timeout error.
I didn't notice the password prompt at first because I was working on multiple terminals and only saw the timeout error at the end.
Another error that I encountered earlier was:
@BH1SCW
BH1SCW / mosh-nat-server.sh
Created April 28, 2022 07:58 — forked from grwlf/mosh-nat-server.sh
mosh-nat-server.sh
#!/bin/sh
RELAY="$1"
PORT="$2"
echo -n 'nat-hole-punch' | socat STDIN "UDP-SENDTO:$RELAY:$PORT,sourceport=$PORT"
mosh-server new -p "$PORT" | sed -n 's/MOSH CONNECT [0-9]\+ \(.*\)$/\1/g p'