Skip to content

Instantly share code, notes, and snippets.

View jevinskie's full-sized avatar

Jevin Sweval jevinskie

View GitHub Profile
#!/bin/bash
# MacBook Lid Angle Sensor Diagnostic Script
# This script helps identify the lid angle sensor on different MacBook models
echo "=============================================="
echo "MacBook Lid Angle Sensor Diagnostic Tool"
echo "=============================================="
echo ""
@CharlieQiu2017
CharlieQiu2017 / libgcc.md
Last active October 10, 2025 04:22
A Deep Dive into libgcc And libsupc++

A Deep Dive into libgcc And libsupc++

According to the specifications of the C and the C++ programming languages, implementations of C and C++ can be classified into hosted ones and freestanding ones, depending on whether the implementation has access to functionalities that require operating system (OS) support, such as memory allocation and multi-threading. A hosted implementation has full access to these functionalities, and can provide the full range of features required by the language. A freestanding implementation, on the other hand, does not have access to any functionality that requires support from the execution environment. Such implementations are only required to provide a subset of the language features. Freestanding implementations are important when developing operating systems, the standard C library,

@MaskRay
MaskRay / bench.rb
Last active September 17, 2025 17:14
https://maskray.me/blog/2025-08-31-benchmarking-compression-programs program, distributed under the terms of both the MIT license and the Apache License (Version 2.0)
#!/usr/bin/env ruby
# This program downloads and builds several compression utilities, benchmarks their compression and decompression
# performance on a specific input file including memory consumption, and finally generates HTML charts.
require 'benchmark'
require 'digest'
require 'etc'
require 'fileutils'
require 'json'
require 'net/http'
require 'optparse'
@Keksgesicht
Keksgesicht / simple-ISel.c
Created August 27, 2025 22:31
LLVM patching approach
// RUN: %llvmbuildpath/bin/clang --sysroot=%libcpath --target="riscv32-none-elf" -menable-experimental-extensions -mabi="ilp32" -march="rv32imxsimple0p1" -O3 -S -o - %s | FileCheck %s
// CHECK: main:
// CHECK-DAG: SIMPLE.mac [[RD1:[as][0-9]+]], [[RS1:[as][0-9]+]], [[RS2:[as][0-9]+]]
// CHECK: call printf
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
@izabera
izabera / magic_namerefs.md
Last active July 8, 2025 15:10
magic namerefs

namerefs (introduced in bash 4.0) act as aliases for other variables

var=meow
declare -n ref=var

echo $ref  # prints meow

ref=moo
echo $var  # prints moo
@whitequark
whitequark / meow.md
Last active October 10, 2025 19:11
reverse engineering tools

"%" means not tested by me personally.

Reference material

Disassemblers and decompilers

  • Binary Ninja: interactive native code disassembler, decompiler, and debugger
  • when building, replace the BN SDK it downloads with a path to BN API library
#!/usr/bin/env python3
# SPDX-License-Identifier: BSD-3-Clause
# Copyright (c) 2023, Alex Taradov <[email protected]>. All rights reserved.
#------------------------------------------------------------------------------
core_debug = {
'name': 'CD',
'description': 'Core Debug',
'base': 0xe000edf0,
'source': 'DDI0403D_arm_architecture_v7m_reference_manual.pdf',
@ataradov
ataradov / gist:0a46c935eff32bf28e26d6ed5438cdfb
Created April 4, 2025 15:00
Example Python description of a peripheral
itm = {
'name': 'ITM',
'description': 'Instrumentation Trace Macrocell',
'base': 0xe0000000,
'source': '',
'registers': [
('PORT', 0x000, 'RW', 'ITM Stimulus Port', (32, 4)),
('TER', 0xe00, 'RW', 'ITM Trace Enable Register'),
('TPR', 0xe40, 'RW', 'ITM Trace Privilege Register'),
('TCR', 0xe80, 'RW', 'ITM Trace Control Register', [
@Marc-B-Reynolds
Marc-B-Reynolds / xoroshiro128p_fail.c
Last active April 6, 2025 12:27
test driver that demos "xoroshiro128+" failing PractRand
// compile with whatever then run PractRand:
// ./test | RNG_test stdin64 -tlmin 256KB -tf 2 -tlmax 512GB -seed 0
//****************************************************************************
// verbatim from: https://prng.di.unimi.it/xoroshiro128plus.c
/* Written in 2016-2018 by David Blackman and Sebastiano Vigna ([email protected])
To the extent possible under law, the author has dedicated all copyright
and related and neighboring rights to this software to the public domain
@MangaD
MangaD / cpp_exception_handling.md
Last active September 30, 2025 03:32
Stack Unwinding & Exception Propagation in C++

📌 Stack Unwinding & Exception Propagation in C++

CC0

Disclaimer: ChatGPT generated document.

Stack unwinding is the process of cleaning up the stack when an exception is thrown. It involves destructing local variables and calling cleanup functions while propagating the exception up the call stack until a matching catch block is found.