Skip to content

Instantly share code, notes, and snippets.

@JohnCoates
JohnCoates / AutoHook.h
Created May 26, 2017 22:06
Simple Objective-C Method Hooking
@protocol AutoHook <NSObject>
@required
+ (NSArray <NSString *> *)targetClasses;
@end
@JohnCoates
JohnCoates / decodeHiddenInstagramAPIKey.swift
Last active August 8, 2023 17:50
Instagram private key decoder
let encodedApiKey = [0x72, 0x30, 0x39, 0x04, 0x04, 0x88, 0x72, 0x88, 0x72, 0xEE, 0x04, 0x30, 0x04, 0xEF, 0xEB, 0xC2,
0xEB, 0xEE, 0xAA, 0x41, 0xEE, 0x30, 0x88, 0xC2, 0xC2, 0x2C, 0x04, 0x04, 0x88, 0xAA, 0x41, 0x30,
0x41, 0x72, 0x88, 0x5D, 0x04, 0x2C, 0xAA, 0x58, 0x30, 0x72, 0xEE, 0x39, 0x58, 0xEE, 0xC2, 0x5D,
0xAA, 0x04, 0xE2, 0xEE, 0x58, 0xE2, 0xEE, 0x5D, 0xAA, 0x2C, 0x41, 0x04, 0x88, 0xE2, 0xAA, 0xC2]
let map: [Int: String] = [
0x04: "3",
0x2c: "d",
0x30: "b",
0x39: "c",
@JohnCoates
JohnCoates / generateRandomPastelColor.swift
Last active December 5, 2022 14:20
Randomly generate pastel UIColor in Swift
// Adapted from Stack Overflow answer by David Crow http://stackoverflow.com/a/43235
// Question: Algorithm to randomly generate an aesthetically-pleasing color palette by Brian Gianforcaro
// Method randomly generates a pastel color, and optionally mixes it with another color
func generateRandomPastelColor(withMixedColor mixColor: UIColor?) -> UIColor {
// Randomly generate number in closure
let randomColorGenerator = { ()-> CGFloat in
CGFloat(arc4random() % 256 ) / 256
}
var red: CGFloat = randomColorGenerator()
@JohnCoates
JohnCoates / Readme.md
Last active September 27, 2021 20:24
HEVC HLS Creation
@JohnCoates
JohnCoates / Readme.md
Last active August 23, 2021 16:54
extract PSIconsHighRes.dat & IconResources.idx - filetype: Photoshop Icon Resource Index 1.0

INSTRUCTIONS:

Put both files in a folder, then create a subfolder named "extracted". Run readPhotoshopIcons.php to extract images then run readPhotoshopIconNames.php to rename files to their correct names.

@JohnCoates
JohnCoates / commands.sh
Last active May 6, 2021 22:00
THEOS on Windows 10 with Linux subsystem
# Turn on Developer Mode
# Open Settings -> Update and Security -> For developers
# Don't reboot yet
# Run in powershell administrator:
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
# accept reboot
## Install Ubuntu
# run in powershell administrator:
@JohnCoates
JohnCoates / readPhotoshopIconNames.php
Last active November 3, 2020 12:47
extract PSIconsHighRes.dat & IconResources.idx - filetype:| Photoshop Icon Resource Index 1.0
<?php
$filepath = "/Applications/Adobe Photoshop CC 2017/Adobe Photoshop CC 2017.app/Contents/Resources/IconResources.idx";
$headerMagic = "Photoshop Icon Resource Index 1.0\n";
$fp = fopen($filepath, "r");
$magic = fread($fp, strlen($headerMagic));
if ($magic != $headerMagic) {
exit("error: wrong magic");
@JohnCoates
JohnCoates / UIGestureRecognizer+Closure.swift
Created May 18, 2017 09:14
UIGestureRecognizer with closure, Swift 3
import UIKit
extension UIGestureRecognizer {
@discardableResult convenience init(addToView targetView: UIView,
closure: @escaping () -> Void) {
self.init()
GestureTarget.add(gesture: self,
closure: closure,
toView: targetView)
@JohnCoates
JohnCoates / install-api.py
Created March 5, 2020 09:18 — forked from withzombies/install-api.py
Install the Binary Ninja Python API
#!/usr/bin/env python
import os
import sys
import os.path
import site
try:
import binaryninja
print "Binary Ninja API Installed"
@JohnCoates
JohnCoates / Future+NilMap.swift
Created March 10, 2019 23:54
Mapping on nil for Vapor 3
//
// Future+NilMap.swift
// Created on 3/10/19
//
import Async
public protocol OptionalConstrainable {
associatedtype Element
var asOptional: Optional<Element> { get }