Skip to content

Instantly share code, notes, and snippets.

@krackers
krackers / NSString.m
Created April 5, 2024 18:51 — forked from 0xced/NSString.m
Reverse-engineered implementation of -[NSString isEqual:] and -[NSString isEqualToString:]
/*
* Most NSString instances will actually be __NSCFString instances, so here are both NSString and __NSCFString implementations.
* If you know how to create an NSString instance whose class is actually NSString please let me know.
* Other possible concrete subclasses of NSString are: NSConstantString, __NSCFConstantString, NSPathStore2, NSSimpleCString and __NSLocalizedString.
*/
// CoreFoundation.framework 635.19.0 (Mac OS X 10.7.3)
@implementation NSObject
- (BOOL) isNSString__
@krackers
krackers / CVPixelFormat Descriptions
Created November 6, 2023 07:17 — forked from gregcotten/CVPixelFormat Descriptions
All Public and Private CVPixelFormat Descriptions
Structure is [PixelFormatTitle: DescriptionDictionary]. PixelFormatTitle is the kCVPixelFormatType_ suffix (if known) and the FourCharCode as a string or int if the string is too short.
[["32ARGB / 32": {
BitsPerBlock = 32;
BitsPerComponent = 8;
BlackBlock = <ff000000>;
CGBitmapContextCompatibility = 1;
CGBitmapInfo = 16388;
CGImageCompatibility = 1;
ContainsAlpha = 1;
@krackers
krackers / DefaultKeyBinding.dict
Created November 5, 2023 04:10 — forked from zsimic/DefaultKeyBinding.dict
OSX key bindings
{
/* ~/Library/KeyBindings/DefaultKeyBinding.dict
See https://gist.github.com/zsimic/1367779, prefix cheatsheet:
Char Short Key
$ S- Shift ⇧
^ C- CTRL ⌃
~ O- Option ⌥ (⊞ Win key position on PC)
@ M- Command ⌘ (Alt position on PC)
# Numeric Keypad
@krackers
krackers / Makefile
Created September 19, 2023 04:51 — forked from kazupon/Makefile
semaphore multi process sample for Mac OSX
CC=gcc
all: multi-process-counter
build: multi-process-counter
multi-process-counter:
${CC} -std=c99 -o multi-process-counter multi-process-counter.c
#${CC} -std=c99 -arch x86_64 -o multi-process-counter multi-process-counter.c
@krackers
krackers / mach_semaphore.c
Created September 19, 2023 04:51 — forked from kazupon/mach_semaphore.c
Using mach_semaphore on Mac OS X to mutually signaling between two threads. This could be extended to work with different processes.
//
// Created by Yogesh Swami on 2/24/12.
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//
//
// clang -Wall -Wextra -Wall -o mach_semaphore mach_semaphore.c
//
// using mach semaphore for mutually signalling between two threads.
@krackers
krackers / gist:2b85ef0d6fab32ab0aaac1bd3aa38907
Created September 3, 2023 09:10 — forked from andrewsardone/gist:3751168
How does UIKit get pixels onto the screen?

UIView Drawing Model

-[UIView setNeedsDisplay]

You have some kind of custom UIView which implements some awesome drawing in -[UIView drawRect:]. In order to have UIKit draw it for you, you send the -[UIView setNeedsDisplay] to the view object to queue it up for drawing.

-[CALayer setNeedsDisplay]

     *------------*           *------------*

| | | |

@krackers
krackers / python_stream.md
Created August 25, 2023 09:22 — forked from hzhu212/python_stream.md
Python iterator with chain-call like Java stream

Python Stream object act like Java Stream, features include lazy calculating, slicing, chain-call etc.

stream.py:

import functools
import itertools


class Stream(object):
@krackers
krackers / LegacyDocsets.md
Created August 23, 2023 22:10 — forked from fzwo/LegacyDocsets.md
Download and view old Apple developer documentation

How to download and view legacy documentation from Apple (no need to sign in to your dev account)

  1. Download the docset index XML.
  2. Find the docset you want (there are some with URL https://apple.com/none.dmg; ignore them - you will find them again further down the file with a working URL).
  3. Download the dmg. It's probably around a gigabyte or so.
  4. "Install" the .pkg file somewhere on your disk. If you don't trust the installer, do it manually:
    1. Find the largest file, named Payload, and extract it using The Unarchiver.
    2. This creates a new, even larger file, probably named Payload-1.
    3. Extract Payload-1 using The Unarchiver.
  5. After many minutes of extracting, we have our .docset file.
@krackers
krackers / swizzler.h
Last active August 20, 2023 00:19 — forked from saagarjha/swizzler.h
Type-safe, RAII swizzler for Objective-C++
// https://twitter.com/_saagarjha/status/1692839886053625917#m
#import <Foundation/Foundation.h>
#import <atomic>
#import <memory>
#import <objc/runtime.h>
#include <objc/message.h>
#import <stdexcept>
#import <iostream>
@krackers
krackers / README.md
Created June 12, 2023 02:57 — forked from Mnkai/README.md
TDP and turbo parameter modification with MSR on non-overclockable Intel CPU (such as Intel i7-8550U)

TDP and turbo parameter modification with MSR on non-overclockable CPU

Disclaimer

  • MSR modification may void your CPU's (or system board's) warranty. Proceed with care. I'm not responsible for any destruction caused by this article.
  • MSR address (greatly) differs from CPU to CPU. Check your own CPU's MSR address using Intel's documentation.
  • Only tested on Intel i7-8550U (Kaby Lake R).
  • This article is translation of this article. If you can understand Korean, I recommend reading that article, not this.

Start