Skip to content

Instantly share code, notes, and snippets.

View BH1SCW's full-sized avatar

F.J Kong BH1SCW

View GitHub Profile
@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 / 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 / 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 / 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 / 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'
@BH1SCW
BH1SCW / gist:6d8480f85ec8e796c3fa3d81f8e1133c
Created April 28, 2022 06:24 — forked from kwilczynski/gist:dc69ed5acb27a19ec1e29914895d7666
Install lei for kernel development using lore directly on Ubuntu
apt install -y vim
apt install -y wget
apt install -y sqlite3 (used by a test, not needed for the build to complete)
apt install -y curl
apt install -y git
apt install -y build-essential
apt install -y pkg-config
@BH1SCW
BH1SCW / gist:94d4f43c62cdc4a6f57066e4e274472b
Created April 12, 2022 01:52 — forked from Cyan4973/gist:5b835641c134b8d6e7c3
Takayuki's Streaming example 2 (simplified)
// LZ4 streaming API example 2 (ring buffer)
#define _CRT_SECURE_NO_WARNINGS // for MSVC
#include "lz4.h"
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>