Skip to content

Instantly share code, notes, and snippets.

View PEMessage's full-sized avatar
🇨🇳

PEMessage

🇨🇳
View GitHub Profile
@7etsuo
7etsuo / 7etsuo-printf.c
Created September 12, 2024 08:48
printf cheatsheet
┌──────────────────────────────────────────────────────────────────────────────────────────────────────────┬──────────────────────────────────────────────────────────────────────────
│ printf Format Specifiers │
│ ┌──────────┬──────────────────────────────────────────────────┬───────────────────────────────────────┐ │/** printf format specifiers
│ │ Specifier│Description │ Example Output │ │ * ███ ▄████████ ███ ▄████████ ███ █▄ ▄██████▄
│ ├──────────┼──────────────────────────────────────────────────┼───────────────────────────────────────┤ │ *▀█████████▄ ███ ███ ▀█████████▄ ███ ███ ███ ███ ███ ███
│ │ %d │Signed decimal integer │ printf("%d", 42); // 42 │ │
@aamir-sultan
aamir-sultan / tmux_build.sh
Last active February 2, 2025 21:33
Script for Tmux Static Build
#!/usr/bin/env bash
set -o errexit
declare -A version
version[m4]=1.4.19
version[bison]=3.8.2
version[ncurses]=6.4
version[musl]=1.2.4
@tniessen
tniessen / stm32-cmox-crypto-crc-aes-gcm.md
Created December 28, 2023 21:09
How CMOX (X-CUBE-CRYPTOLIB) uses the STM32's CRC unit for AES encryption and decryption

X-CUBE-CRYPTOLIB (CMOX) and the STM32's CRC unit

This write-up is about the STM32 cryptographic firmware library X-CUBE-CRYPTOLIB, also known as the Cortex-M Optimized Crypto Stack (CMOX). It is a cryptographic library developed by STMicroelectronics (ST) for their series of STM32 processors, which are based on the ARM Cortex-M family.

Hardware features vary across different STM32 processors. Because CRC checksums are widely used in embedded systems, most (if not all) STM32 processors feature a hardware CRC unit that is supposed to accelerate CRC computations.

Introduction

Interestingly, on the page "Getting started with the Cryptographic Library", ST claims:

@stkptr
stkptr / android-cli-build.md
Last active June 29, 2025 06:57
Guide for getting a command line buildsystem for Android apps set up

Developing Android apps without Android Studio (Debian 12)

If you're looking to develop an Android app you might be led to Android Studio. It's the IDE recommended and developed by Google for the express purpose of Android development. It does what it needs to, but if you look at the system requirements you will see some alarming numbers. If you're using an older system, or simply don't want to use AndroidStudio, this is the guide for you.

Installing packages

We won't be using many apt packages due to permissions issues and incompatible versions. That being said:

$ sudo apt install openjdk-17-jdk sdkmanager kotlin
@pagkly
pagkly / wslkernel.sh
Last active June 12, 2025 16:36
WSL2 - Compile Kernel with Ashmem and Binder
# Waydroid
# WSl custom kernel
# https://gist.github.com/oleksis/eb6d2f1cd2a6946faefb139aa0e38c35
# https://github.com/waydroid/waydroid/issues/217
# https://www.youtube.com/watch?v=SfK4PBcFq0w
# Powershell shutdown & remove config
wsl --shutdown
rm /mnt/c/Users/user/.wslconfig
# install dependencies
@MaskRay
MaskRay / kernel-arm64.md
Created May 2, 2023 06:57
Linux kernel's arm64 port

In the kernel source directory, run

make O=/tmp/linux/arm64 ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- -j60 defconfig all

Then create an Alpine aarch64 image following https://hackmd.io/@starnight/Run_Alpine_on_QEMU_aarch64_Virtual_Machine

wget https://dl-cdn.alpinelinux.org/alpine/latest-stable/releases/aarch64/netboot/vmlinuz-lts https://dl-cdn.alpinelinux.org/alpine/latest-stable/releases/aarch64/netboot/config-lts
@suiluj
suiluj / python_logging.py
Last active June 7, 2024 09:24
python logging pretty print pformat indent width line break
import logging
import time
from pprint import pformat
# pretty print logs: https://stackoverflow.com/a/11093247/5628238
# pformat indent: https://stackoverflow.com/a/29469358/5628238
# (even needed when using %s string format): do not evaluate complex pformat when log level not printed: https://docs.python.org/3/library/logging.html#logging.Logger.isEnabledFor
# (wrong: complex variable string takes time nevertheless): https://reinout.vanrees.org/weblog/2015/06/05/logging-formatting.html
# https://stackoverflow.com/questions/13131400/logging-variable-data-with-new-format-string
# main script or module
@xiaozhuai
xiaozhuai / backtrace.cpp
Created April 22, 2021 10:45
Android native c++ get back trace (stacktrace)
#include <tinyformat.h>
#include <unwind.h>
#include <cxxabi.h>
#include <dlfcn.h>
struct android_backtrace_state {
void **current;
void **end;
};
@jimblandy
jimblandy / dump-type.py
Last active June 3, 2025 03:09
GDB Python script to define a command for inspecting types.
# Put this in a file BLAH/dump-type.py and then put this in your ~/.gdbinit file
# (or type it at the GDB prompt):
#
# source BLAH/dump-type.py
#
# Then you can say:
#
# (gdb) help jimb-dump-type
#
# and you should get a help message.
@jjvillavicencio
jjvillavicencio / setup.sh
Last active June 26, 2025 02:24
Install Android SDK on Windows Bash (WSL)
cd /home/<user>/
sudo apt-get install unzip
wget https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip
unzip sdk-tools-linux-4333796.zip -d Android
rm sdk-tools-linux-4333796.zip
sudo apt-get install -y lib32z1 openjdk-8-jdk
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
export PATH=$PATH:$JAVA_HOME/bin
printf "\n\nexport JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64\nexport PATH=\$PATH:\$JAVA_HOME/bin" >> ~/.bashrc
cd Android/tools/bin