Skip to content

Instantly share code, notes, and snippets.

@frehulfd
frehulfd / UIViewControllerRepresentable and preferredContentSize
Last active January 26, 2022 15:47
Demonstrates how to respect a UIViewController's preferredContentSize while hosted in a UIViewControllerRepresentable
import UIKit
import SwiftUI
import Combine
import PlaygroundSupport
let image1 = #imageLiteral(resourceName: "FKCLjJCWQAsnvY0.jpeg")
let image2 = #imageLiteral(resourceName: "tim-cook-apple-11 (dragged).jpg")
struct TestView: View {
var body: some View {
@frehulfd
frehulfd / json.swift
Created April 3, 2018 15:58 — forked from reckenrode/json.swift
Decoding arbitrary JSON with the new Decoder in Swift 4
enum JSON: Decodable {
case bool(Bool)
case double(Double)
case string(String)
indirect case array([JSON])
indirect case dictionary([String: JSON])
init(from decoder: Decoder) throws {
if let container = try? decoder.container(keyedBy: JSONCodingKeys.self) {
self = JSON(from: container)

Keybase proof

I hereby claim:

  • I am frehulfd on github.
  • I am donfrehulfer (https://keybase.io/donfrehulfer) on keybase.
  • I have a public key whose fingerprint is 851A A29A C6C2 F5F8 8A9F 040A D9CA 824D 2175 12A5

To claim this, I am signing this object:

#!/bin/bash
say -v Vicki "it's pronounced gif"
while true; do
say -v Zarvox "it's pronounced jiff"
say -v Vicki "no, it's pronounced gif"
done
@frehulfd
frehulfd / speedtest.swift
Last active February 8, 2016 14:25
A Swift "Shell Script" to convert the output of "speedtest-cli" to csv
#!/usr/bin/xcrun swift
// A script to take the results of "speedtest-cli" and convert it into csv data.
// This script requires "speedtest-cli" to be installed via `pip`. It will print
// out the results in csv format like the following: "Date,Time,Ping,Download,Upload"
//
// e.g.:
// 2/8/16,9:13:00 AM,24.456,55.72,24.03
@frehulfd
frehulfd / WKInterfaceController+Reactive.h
Last active April 16, 2020 02:00
WKInterfaceController+Reactive
@import WatchKit;
#import <ReactiveCocoa/ReactiveCocoa.h>
@interface WKInterfaceController (Reactive)
@property (nonatomic, readonly) RACSignal *activatedSignal;
@property (nonatomic, readonly) RACSignal *deactivatedSignal;
@property (nonatomic, readonly) RACSignal *didPresentControllerSignal;
@property (nonatomic, readonly) RACSignal *didPushControllerSignal;