Skip to content

Instantly share code, notes, and snippets.

View jevinskie's full-sized avatar

Jevin Sweval jevinskie

View GitHub Profile
@EthanArbuckle
EthanArbuckle / main.m
Last active March 3, 2025 18:46
Watch for changes to an ivar
//
// main.m
//
// Created by ethanarbuckle
//
#import <Foundation/Foundation.h>
#import <objc/runtime.h>
#import <mach/mach.h>
#import <execinfo.h>
@Marc-B-Reynolds
Marc-B-Reynolds / prng_pop.c
Created December 6, 2024 14:38
Skims two methods: bisection method for random numbers with given popcount & branchfree random bit permutation with bit-scatter or sheep-and-goats op.
// UNLICENSE or whatever other you want that doesn't hold me
// responsible for you choosing to use any of this.
// a sketch of a few niche things:
// 1) generate a random number with a given population count
// 2) perform a random bit permutation of the input
// 3) not quite random versions of (2)
// 4) use (2) or (3) to produce stateful variants of (1)
#include <stdint.h>
@bdash
bdash / storage-classes.scm
Last active March 17, 2025 21:02
Storage classes assigned by the macOS platform sandbox policy
;; Current as of macOS 15.1
Accessibility
Accounts
AirDrop
AirPlay
AppStoreSandboxes
AppleInstallerSandboxes
AppleMediaServices
ArchiveUtility
@bdash
bdash / action-modifiers.scm
Created December 1, 2024 21:17
macOS sandbox action modifiers, filters, and operations
;; Current as of macOS 15.1
(with send-signal …)
(with errno …)
(with report)
(with no-report)
(with no-sandbox)
(with grant)
(with sip-override)
(with no-times)
  1. Every atomic object has a timeline (TL) of writes:

    • A write is either a store or a read-modify-write (RMW): it read latest write & pushed new one.
    • A write is either tagged Relaxed, Release, or SeqCst.
    • A read observes some write on the timeline:
      • On the same thread, future reads can't go backwards on the timeline.
      • A read is either tagged Relaxed, Acquire, or SeqCst.
      • RMWs can also be tagged Acquire (or AcqRel). If so, the Acquire refers to the "read" portion of "RMW".
  2. Each thread has its own view of the world:

  • Shared write timelines but each thread could be reading at different points.
@LemonHaze420
LemonHaze420 / pcmesh.cpp
Created November 22, 2024 17:11
USM Mesh Tools
// Dylan E - 2024
#include <iostream>
#include <ostream>
#include <fstream>
#include <string>
#include <vector>
struct header_t {
int fourcc;
// Compile this with -rdynamic and your emulator .so with -fPIC -fpie -shared
#include <dlfcn.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "dcheck.h"
static char logfile_name[] = "/tmp/gbtracer.log.XXXXXX";
static int logfile_fd = 0;
@EthanArbuckle
EthanArbuckle / main.m
Created October 28, 2024 01:27
objc object search
#import <objc/runtime.h>
#import <mach/mach.h>
#import <malloc/malloc.h>
#import <dlfcn.h>
typedef struct {
Class targetClass;
void (^block)(id object, BOOL isSubclass, BOOL *stop);
dispatch_semaphore_t semaphore;
BOOL shouldStop;
@niw
niw / update_install_names.rb
Created October 11, 2024 13:57
Make frameworks portable.
#!/usr/bin/env ruby
require 'optparse'
require 'pathname'
def update_name(name, options)
pattern = /#{options[:rpath]}/
if name =~ pattern
suffix = $'
if options[:path].join(suffix).exist?
@theevilbit
theevilbit / launchd-config.plist
Created October 10, 2024 12:22
launchd embedded plist, macOS 15.0
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>ShutdownReportTimeout</key>
<integer>2</integer>
<key>SIGTERMTimeout</key>
<integer>5</integer>
<key>CrashOnSIGTERMTimeout</key>
<true/>