Skip to content

Instantly share code, notes, and snippets.

View kawaii-ghost's full-sized avatar
😐
Lost in the internet

<I°_°I> kawaii-ghost

😐
Lost in the internet
View GitHub Profile
@phizev
phizev / zswap-stats
Last active October 14, 2024 16:12
Simple, cruddy script to print out some zswap information, and attempt to calculate compression ratio, though unsure if it is accurate, nor if it accounts for overhead. Add -v to get raw dump of the module parameters and kernel debug statistics.
#! /bin/sh -
ENABLED=$(cat /sys/module/zswap/parameters/enabled)
COMPRESSOR=$(cat /sys/module/zswap/parameters/compressor)
ZPOOL=$(cat /sys/module/zswap/parameters/zpool)
PAGE_SIZE=$(getconf PAGE_SIZE)
STORED_PAGES=$(cat /sys/kernel/debug/zswap/stored_pages)
POOL_TOTAL_SIZE=$(cat /sys/kernel/debug/zswap/pool_total_size)
POOL_SIZE=$(numfmt --to=iec-i $POOL_TOTAL_SIZE)
@CTimmerman
CTimmerman / .prospector.yaml
Last active May 16, 2024 04:45
Out Of Memory (OOM) Killer to save your SSD and other processes.
pylint:
disable:
- line-too-long
- multiple-imports
- pointless-string-statement
- too-many-nested-blocks
@Wack0
Wack0 / peb.c
Created December 31, 2017 16:31
Getting a pointer to the PEB in C, for every architecture that NT was ported to (where at least one build of the port was leaked/released)
// Gets a pointer to the PEB for x86, x64, ARM, ARM64, IA64, Alpha AXP, MIPS, and PowerPC.
// This relies on MS-compiler intrinsics.
// It has only been tested on x86/x64/ARMv7.
inline PEB* NtCurrentPeb() {
#ifdef _M_X64
return (PEB*)(__readgsqword(0x60));
#elif _M_IX86
return (PEB*)(__readfsdword(0x30));
@wbenny
wbenny / nt_syscalls.md
Last active September 16, 2024 22:11
Windows syscall stubs

Windows system calls

...by stub

x86

Windows XP

B8 ?? ?? ?? ??                mov     eax, ??
BA 00 03 FE 7F                mov     edx, 7FFE0300h
@mapuo
mapuo / debian_ksm.md
Last active July 17, 2024 08:06
Enable KSM (Kernel Same-Page Merging) on boot in Debian

Enable KSM (Kernel Same-Page Merging) on boot in Debian

I have installed and run Netdata on my Debian based home server and I wanted to enable KSM after Netdata installer suggested it could save some RAM.

To enable the KSM on boot in Debian you I executed these steps:

  1. Install ksmtuned without all the QEMU dependencies:
@nikAizuddin
nikAizuddin / NASMx86: Allocate heap memory
Created October 12, 2014 22:58
Example using brk() system call for dynamic memory allocations
; 1 2 3 4 5 6 7
;01234567890123456789012345678901234567890123456789012345678901234567890
;=======================================================================
;+---------------------------------------------------------------------+
;| |
;| Example using brk() system call for dynamic memory allocations. |
;| |
;| DON'T CONFUSE that brk() used in C Function is different with brk() |
;| systemcall (systemcall 45 for x86 ASM). |
;| |
@yohhoy
yohhoy / threads.h
Last active September 25, 2024 12:28
C11 <threads.h> emulation library
/*
* C11 <threads.h> emulation library
*
* (C) Copyright yohhoy 2012.
* Distributed under the Boost Software License, Version 1.0.
* (See copy at http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef EMULATED_THREADS_H_INCLUDED_
#define EMULATED_THREADS_H_INCLUDED_