Skip to content

Instantly share code, notes, and snippets.

Darwin tooling

Leptos leptos-null

Darwin tooling
View GitHub Profile
leptos-null /
Created Apr 12, 2020
Red Cross Blood REST API Reference

Red Cross Blood REST API Reference

This guide is based on research from version 1.7.3 of Red Cross Blood iOS app.


This reference is for version 2.1 of the interface.



Keybase proof

I hereby claim:

  • I am leptos-null on github.
  • I am leptos_null ( on keybase.
  • I have a public key ASA0dcmIggGRcMrdxDzFRDAutr7TdLveEOWsHbCkWeWN0Qo

To claim this, I am signing this object:

leptos-null / watchPreviewDate.m
Created Sep 19, 2019
The date used for previews on watchOS, primarily for complications
View watchPreviewDate.m
static NSDate *watchPreviewDate() {
static NSDateComponents *comps;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
comps = [NSDateComponents new];
comps.calendar = NSCalendar.autoupdatingCurrentCalendar;
comps.timeZone = NSTimeZone.localTimeZone;
comps.year = 2014;
comps.month = 9; = 9;
leptos-null / pathdiff.m
Last active Aug 29, 2019
Find tools with the with the same name in a PATH
View pathdiff.m
@import Foundation;
int main(int argc, const char *argv[]) {
const char *const arg = argv[1];
if (arg) {
if (strcmp(arg, "-h") == 0 || strcmp(arg, "--help") == 0 || argc > 2) {
printf("Usage: %s [PATH]\n"
"Walk through PATH and find any repeated file names. "
"A different PATH can be provided by passing it in as the first argument.\n", argv[0]);
return 1;
leptos-null / open_app.m
Created Aug 28, 2019
[iOS] Open an application from the command line by bundle identifier
View open_app.m
@import Foundation;
@import MobileCoreServices;
@interface LSApplicationWorkspace : NSObject
+ (instancetype)defaultWorkspace;
- (BOOL)openApplicationWithBundleID:(NSString *)bundleID API_AVAILABLE(ios(7.0));
leptos-null / UIImageUnicode.m
Last active Oct 19, 2020
Draw UIImage of Unicode character
View UIImageUnicode.m
@implementation UIImage (UIImageUnicode)
+ (UIImage *)imageFromUnicodePoint:(unichar)codepoint compatibleWithTraitCollection:(UITraitCollection *)traitCollection API_AVAILABLE(ios(10.0)) {
NSString *str = [NSString stringWithCharacters:&codepoint length:1];
UIFont *weightRef = [UIFont preferredFontForTextStyle:UIFontTextStyleBody compatibleWithTraitCollection:traitCollection];
UIFont *sizeRef = [UIFont preferredFontForTextStyle:UIFontTextStyleTitle2 compatibleWithTraitCollection:traitCollection];
NSAttributedString *drawReady = [[NSAttributedString alloc] initWithString:str attributes:@{
NSFontAttributeName : [weightRef fontWithSize:sizeRef.pointSize]
UIGraphicsBeginImageContextWithOptions([drawReady size], NO, 0);
leptos-null / EntitlementsForImage.m
Created Jul 22, 2019
Get the entitlements of a given Mach-O image existing in memory
View EntitlementsForImage.m
#import <Foundation/Foundation.h>
#import <mach-o/loader.h>
#if __has_include(<Kernel/kern/cs_blobs.h>)
# import <Kernel/kern/cs_blobs.h>
/* some Darwin distributions don't provide the cs_blobs header
* copy it from the macOS SDK if available, otherwise one of
leptos-null / GenericError.swift
Created Jun 8, 2019
A generic error I use in Swift, typically for cases that are not intended to be dealt with in a manner other than being logged
View GenericError.swift
struct GenericError: Error, CustomStringConvertible, CustomDebugStringConvertible, Equatable, Codable {
let description: String
let file: String
let function: String
let line: Int
init(message m: String, file f: String = #file, function n: String = #function, line l: Int = #line) {
description = m; file = f; function = n; line = l
leptos-null / UIStatusBarItemType.m
Last active Aug 31, 2019
Recreating the UIStatusBarItemType enum
View UIStatusBarItemType.m
// statusbartypes
// Created by Leptos on 3/19/19.
// Copyright © 2019 Leptos. All rights reserved.
#import <UIKit/UIKit.h>
typedef int UIStatusBarItemType;
leptos-null /
Last active Dec 23, 2019
How to scale temperature and other measurements

Temperature Scaling

What’s it mean if the temperature is going to be 30% warmer or 30% cooler?

Distance Scaling

Let’s take something that we know works: distances. If I have a distance that’s 2 meters, 30% more is (x=2, s=0.3; x*(1+s)) 2.6 meters, and 30% less is (x=2, s=-0.3; x*(1+s)) 1.4 meters. Covert these three values to feet, you get 6.56, 8.53, and 4.59 respectively. If we plug these numbers back into our scaling equation: more is (x=6.56, s=0.3; x*(1+s)) 8.528 feet, and less is (x=6.56, s=-0.3; x*(1+s)) 4.592 feet. These values are slightly off due to rounding.

Fixing Temperature

The problem with temperature is that it’s not zero-based. A value some incremental amount warmer than 5 degrees Fahrenheit is still cold. We need to “normalize” temperature. To do that, we have to find a value such that anything warmer feels warmer, and anything cooler feels cooler. We’re going to use 22°C (72°F) for this value.