Skip to content

Instantly share code, notes, and snippets.

@dgelessus
dgelessus / ifdef_finder.py
Created February 16, 2026 21:23
Simple script to find potentially interesting conditional macro names in a C/C++/etc. codebase
import collections
import os
import pathlib
import re
import sys
c_header_suffixes = {
".h",
".hpp",
}
@dgelessus
dgelessus / ar_generic.ksy
Last active February 16, 2026 21:25
(OLD WIP) Kaitai Struct specs for the Unix ar formats - for the current version, see: https://github.com/kaitai-io/kaitai_struct_formats/pull/126
meta:
id: ar_generic
title: Unix ar archive (generic superset)
application: ar
file-extension:
- a # Unix/generic
- lib # Windows
- rlib # Rust
xref:
justsolve: AR
@dgelessus
dgelessus / nslog.py
Created July 1, 2018 17:53
Helper module to log Python strings using NSLog
"""Allows logging Python :class:`str`s to the system log using Foundation's ``NSLog`` function.
This module is meant to help with debugging the loading process of Rubicon on systems like iOS, where sometimes only
NSLog output (but not stdout/stderr) is available to the developer.
"""
import ctypes
import io
import sys
@dgelessus
dgelessus / DGPropertyEqualTest.m
Created February 14, 2018 11:28
Test code to check whether compiler-synthesized property setters actually assign anything if the new object equals the current one
#import <Foundation/Foundation.h>
@interface DGVeryEqual : NSObject
@property(copy) NSString *desc;
-(instancetype)initWithDescription:(NSString *)description;
@end
@implementation DGVeryEqual : NSObject
-(instancetype)initWithDescription:(NSString *)description {
@dgelessus
dgelessus / DGMsgSendTest.m
Last active December 9, 2016 09:10
Test code to figure out which objc_msgSend variants are used in which case on what architecture
struct char1 {
char x[1];
};
struct char2 {
char x[2];
};
struct char3 {
char x[3];
@dgelessus
dgelessus / pythonista_startup.py
Created August 10, 2016 16:47
pythonista_startup.py with enable_faulthandler
# This is an example pythonista_startup.py script.
# The code below is from https://github.com/dgelessus/pythonista_startup/blob/master/enable_faulthandler.py
from __future__ import absolute_import, division, print_function
def enable_faulthandler():
import ctypes
import datetime
import errno
import io