Skip to content

Instantly share code, notes, and snippets.

View Jamonek's full-sized avatar
🏗️
Building.. Exploring.. Dreaming..

Jamone Kelly Jamonek

🏗️
Building.. Exploring.. Dreaming..
View GitHub Profile
@RuiAAPeres
RuiAAPeres / SwiftUIBindsWithReactiveSwift.swift
Last active August 5, 2024 07:54
Couple of methods to bridge ReactiveSwift with SwiftUI
import Combine
import ReactiveSwift
import SwiftUI
class AnySubscription: Subscription {
private let cancelable: Cancellable
init(cancelable: Cancellable) {
self.cancelable = cancelable
@iamstephenbrown
iamstephenbrown / UIColor+Luminosity.swift
Last active January 24, 2022 21:37
UIColor extension to adjust the luminosity of a colour
import Foundation
import UIKit
// Fantastic explanation of how it works
// http://www.niwa.nu/2013/05/math-behind-colorspace-conversions-rgb-hsl/
fileprivate extension CGFloat {
/// clamp the supplied value between a min and max
/// - Parameter min: The min value
/// - Parameter max: The max value
func clamp(min: CGFloat, max: CGFloat) -> CGFloat {
@nicklockwood
nicklockwood / Color.swift
Created January 19, 2021 23:49
Getting the Display P3 values back out of a UIColor created with init(displayP3Red:green:blue:alpha:)
import UIKit
// Create color using P3 color space
let linearColor = UIColor(displayP3Red: 1, green: 0.5, blue: 0.2, alpha: 1)
do {
var r: CGFloat = 0, g: CGFloat = 0, b: CGFloat = 0, a: CGFloat = 0
linearColor.getRed(&r, green: &g, blue: &b, alpha: &a)
print(r, g, b, a) // 1.07, 0.46, 0.0, 1.0 - not the expected values
}
@ItsJustMeChris
ItsJustMeChris / inline-assembly-mid-function-hooking-macos-unix.cpp
Created March 1, 2021 00:00
Code to perform a mid function hook using inline assembly on a unix / macos x86-64 system. GIST includes dummy program to test, offsets in main program should be valid when built.
#include <cstdio>
#include <iostream>
#include <sys/mman.h>
#include <mach/i386/kern_return.h>
#include <mach/mach_init.h>
#include <mach/mach_vm.h>
#include <mach/vm_region.h>
#include <mach/vm_types.h>
#include <unistd.h>
#include <mach/host_info.h>