Skip to content

Instantly share code, notes, and snippets.

View dreampiggy's full-sized avatar
:octocat:
Work

DreamPiggy dreampiggy

:octocat:
Work
View GitHub Profile
@dreampiggy
dreampiggy / objc_xrefs_helper_hopper_v5.py
Last active April 28, 2024 06:35
Hopper 5 script to support Objective-C relative method list (iOS 14/macOS 11+)
#objective-c xrefs hopper script
#rewrite the IDAPython script https://github.com/fireeye/flare-ida/blob/master/python/flare/objc2_xrefs_helper.py
#author: Kai Lu(@k3vinlusec)
#editor: Zhuoli Li(@dreampiggy)
def getRefPtr(doc,classMethodsVA,objcSelRefs, objcMsgRefs, objcConst):
ret = (None, None)
namePtr = doc.readUInt64LE(classMethodsVA) #get name field in struct __objc_method, it's selector
ctn = 0
@dreampiggy
dreampiggy / mov2webp.sh
Created March 6, 2017 05:31
ffmpeg MOV to Animated WebP
ffmpeg -i input.mov -vcodec libwebp -lossless 1 -q:60 -preset default -loop 0 -an -vsync 0 output.webp
@dreampiggy
dreampiggy / QuickSort.m
Created June 17, 2016 04:38
QuickSort-Objective-C
void quicksortInPlace(NSMutableArray *array, NSInteger first, NSInteger last, NSComparator comparator) {
if (first >= last) return;
id pivot = array[(first + last) / 2];
NSInteger left = first;
NSInteger right = last;
while (left <= right) {
while (comparator(array[left], pivot) == NSOrderedAscending)
left++;
while (comparator(array[right], pivot) == NSOrderedDescending)
right--;
@dreampiggy
dreampiggy / CategoryMacro.h
Created April 13, 2017 07:19
Objective-C Category Property Macro
#ifndef TTD_CATEGORY_PROPERTY
#define TTD_CATEGORY_PROPERTY
#import <objc/runtime.h>
#define TTD_GET_PROPERTY(property) objc_getAssociatedObject(self, @selector(property));
#define TTD_SET_STRONG(property) objc_setAssociatedObject(self, @selector(property), property, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
#define TTD_SET_COPY(property) objc_setAssociatedObject(self, @selector(property), property, OBJC_ASSOCIATION_COPY_NONATOMIC);
#define TTD_SET_UNSAFE_UNRETAINED(property) objc_setAssociatedObject(self, @selector(property), property, OBJC_ASSOCIATION_ASSIGN);
#define TTD_SET_ASSIGN(property, value) objc_setAssociatedObject(self, @selector(property), value, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
#define TTD_SET_WEAK(property) id __weak __weak_object = property; \
id (^__weak_block)() = ^{ return __weak_object; }; \
@dreampiggy
dreampiggy / 5.6-Architecture-Analysis.md
Last active April 13, 2020 03:55
The Core of SDWebImage v5.6 Architecture
title date tags categories author
The Core of SDWebImage v5.6 Architecture
2020-02-22 23:08:12 +0800
SourceCode
iOS
cache
SourceCode
iOS
Objc
土土Edmond木

This article is based on SDWebImage 5.6. Why i write this article, cause i found that SD's API is constantly iterating, and many of the structures are different from earlier versions. Here is to make a record. We will start from the top of the API's level list below, force on the entire framework's data flow.

@dreampiggy
dreampiggy / AnimatedImageTests.swift
Last active February 2, 2020 04:25
AnimatedImage Unit Testing with UIViewRepresentable and ViewInspector
extension AnimatedImage {
struct WrapperView: View & Inspectable {
var name: String
var bundle: Bundle?
@State var isAnimating: Bool
var onViewUpdate: (Self, PlatformView, AnimatedImage.Context) -> Void
var body: some View {
AnimatedImage(name: name, bundle: bundle, isAnimating: $isAnimating)
@dreampiggy
dreampiggy / curl.md
Created October 22, 2019 12:22 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@dreampiggy
dreampiggy / decode-dyn-uti.swift
Created April 15, 2019 12:03 — forked from jtbandes/decode-dyn-uti.swift
Dynamic UTI decoding
extension String
{
/// Creates a string by decoding a sequence of UTF-8 code units.
init?<S: Sequence>(utf8 input: S) where S.Iterator.Element == UTF8.CodeUnit {
var chars: [Character] = []
var decoder = UTF8()
var iter = input.makeIterator()
loop: while true {
switch decoder.decode(&iter) {
case .scalarValue(let scalar): chars.append(Character(scalar))
@dreampiggy
dreampiggy / cli-nsrunloop.m
Created March 29, 2019 19:49 — forked from syzdek/cli-nsrunloop.m
Creating an NSRunLoop for a command line utility.
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[])
{
NSRunLoop * runLoop;
CLIMain * main; // replace with desired class
@autoreleasepool
{
// create run loop
@dreampiggy
dreampiggy / iOS-Hit-Testing.m
Last active August 16, 2017 08:52
iOS Hit Testing
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
if (!self.isUserInteractionEnabled || self.isHidden || self.alpha <= 0.01) {
return nil;
}
if ([self pointInside:point withEvent:event]) {
for (UIView *subview in [self.subviews reverseObjectEnumerator]) {
CGPoint convertedPoint = [subview convertPoint:point fromView:self];
UIView *hitTestView = [subview hitTest:convertedPoint withEvent:event];
if (hitTestView) {
return hitTestView;