Skip to content

Instantly share code, notes, and snippets.

View mahmoudimus's full-sized avatar
💭
@_@

Mahmoud Rusty Abdelkader mahmoudimus

💭
@_@
View GitHub Profile
@mahmoudimus
mahmoudimus / hand-modify-pdf.md
Created September 4, 2023 22:06 — forked from senderle/hand-modify-pdf.md
So you want to modify the text of a PDF by hand

So you want to modify the text of a PDF by hand...

If you, like me, resent every dollar spent on commercial PDF tools, you might want to know how to change the text content of a PDF without having to pay for Adobe Acrobat or another PDF tool. I didn't see an obvious open-source tool that lets you dig into PDF internals, but I did discover a few useful facts about how PDFs are structured that I think may prove useful to others (or myself) in the future. They are recorded here. They are surely not universally applicable --
the PDF standard is truly Byzantine -- but they worked for my case.

#!/usr/bin/python
# -*- coding: utf-8 -*-
"""Script to draw bounding boxes and text from a Tesseract box file.
The script takes an image TIFF_FILE, draws the text and bounding boxes
of the corresponding BOX_FILE and saves the resulting OUT_FILE.
Tesseract box file columns:
<symbol> <left> <bottom> <right> <top> <page>
@mahmoudimus
mahmoudimus / README.md
Last active May 10, 2023 13:22
Patch to upgrade Kaliel's Tracker to 10.1
@mahmoudimus
mahmoudimus / riscv.md
Created March 2, 2023 05:45 — forked from cb372/riscv.md
Writing an OS in Rust to run on RISC-V

(This is a translation of the original article in Japanese by moratorium08.)

(UPDATE (22/3/2019): Added some corrections provided by the original author.)

Writing your own OS to run on a handmade CPU is a pretty ambitious project, but I've managed to get it working pretty well so I'm going to write some notes about how I did it.

@mahmoudimus
mahmoudimus / java.flags.txt
Created February 25, 2023 18:55 — forked from ornicar/java.flags.txt
java -Xms30g -Xmx30g -XX:+UseG1GC -XX:+PrintCodeCache -XX:NonProfiledCodeHeapSize=512m -XX:NonNMethodCodeHeapSize=32m -XX:ReservedCodeCacheSize=2g -XX:InitialCodeCacheSize=512m -XX:CodeCacheExpansionSize=2m -XX:+PrintFlagsFinal
/opt/jabba/jdk/openjdk@1.17/bin/java -Xms30g -Xmx30g -XX:+UseG1GC -XX:+PrintCodeCache -XX:NonProfiledCodeHeapSize=512m -XX:NonNMethodCodeHeapSize=32m -XX:ReservedCodeCacheSize=2g -XX:InitialCodeCacheSize=512m -XX:CodeCacheExpansionSize=2m -XX:+PrintFlagsFinal
[Global flags]
int ActiveProcessorCount = -1 {product} {default}
uintx AdaptiveSizeDecrementScaleFactor = 4 {product} {default}
uintx AdaptiveSizeMajorGCDecayTimeScale = 10 {product} {default}
uintx AdaptiveSizePolicyCollectionCostMargin = 50 {product} {default}
uintx AdaptiveSizePolicyInitializingSteps = 20 {product} {default}
uintx AdaptiveSizePolicyOutputInterval = 0 {product} {default}
uintx AdaptiveSizePolicyWeight = 10
@mahmoudimus
mahmoudimus / disassemble-luajit-v1.py
Created February 3, 2023 05:41 — forked from MickaelWalter/disassemble-luajit-v1.py
Quick&dirty verbose LuaJIT's bytecode version 1 disassembler
#!/usr/bin/env python3
import sys
import struct
import math
# Constants
# Internal (LEB128 buffer)
MAX_ULEB_SIZE = 256 # Maximum proto size here is 2^7^256
@mahmoudimus
mahmoudimus / cwb_markers.py
Created January 29, 2023 02:27 — forked from Andoryuuta/cwb_markers.py
cwb_markers.py v0.3.0
import idautils
import idc
import ida_bytes
from pprint import pprint, pformat
def demangle_name(name):
return idc.Demangle(name, idc.GetLongPrm(idc.INF_SHORT_DN)) or name
def get_primary_vtables():
@mahmoudimus
mahmoudimus / auto_include.ahk
Created January 19, 2023 03:10 — forked from davebrny/auto_include.ahk
📃 (autohotkey) - create a list of .ahk files to be #included in your main script
/*
[search folders]
folder_1 =
folder_2 =
[ignore paths]
C:\Users\documents\scripts\example script name.ahk
C:\Users\documents\scripts\example folder name
[settings]
@mahmoudimus
mahmoudimus / compilersanity.c
Created January 17, 2023 17:28
sanity check code below to test the usefulness and standard compliance of a c/c++ compiler
#include <stdio.h>
int main()
{
#if !defined(__STDC__) || !defined(__STDC_VERSION__)
puts("This compiler is garbage.");
#elif (__STDC_VERSION__ >= 201112L)
#if (__STDC_NO_VLA__==1)
puts("This compiler is mighty strange but compliant.");
#else
@mahmoudimus
mahmoudimus / capslock.ahk
Created January 11, 2023 17:19 — forked from scottming/capslock.ahk
; Autohotkey Capslock Remapping Script
; Autohotkey Capslock Remapping Script
; - Deactivates capslock for normal (accidental) use.
; - Hold Capslock and drag anywhere in a window to move it (not just the title bar).
; - Access the following functions when pressing Capslock:
;Cursor keys - h, j, k, l
;Home,End - N, ;
;Page up,down - - =
;Esc - CapsLock only
;CapsLock - Space