Skip to content

Instantly share code, notes, and snippets.

View JimRoepcke's full-sized avatar

Jim Roepcke JimRoepcke

View GitHub Profile
import SwiftUI
import UIKit
enum ScalableFont {
case system(size: CGFloat, weight: Font.Weight = .regular, design: Font.Design = .default)
case custom(_ name: String, size: CGFloat)
var size: CGFloat {
@marcpalmer
marcpalmer / ExtendedScrollView.swift
Created March 5, 2020 21:20
Work in progress UIScrollView-alike in SwiftUI
//
// ContentView.swift
// ExtendedScrolView
//
// Created by Marc Palmer on 05/03/2020.
// Copyright © 2020 Montana Floss Co. Ltd. All rights reserved.
//
import SwiftUI
@ChrisPenner
ChrisPenner / Optics Cheatsheet.md
Last active April 12, 2024 14:24
Optics Cheatsheet
@danielctull
danielctull / UnwrapView.swift
Last active November 5, 2019 00:43
A view which takes a value and shows one view or another depending on whether the value is nil or not.
import SwiftUI
public struct UnwrapView<Some: View, None: View>: View {
private let some: () -> Some?
private let none: () -> None?
public init<Value>(value: Value?,
some: @escaping (Value) -> Some,
@freak4pc
freak4pc / Combine+WithLatestFrom.swift
Last active February 19, 2024 15:35
withLatestFrom for Apple's Combine
//
// Combine+WithLatestFrom.swift
//
// Created by Shai Mishali on 29/08/2019.
// Copyright © 2019 Shai Mishali. All rights reserved.
//
import Combine
// MARK: - Operator methods
@chriseidhof
chriseidhof / collectionview.swift
Last active January 31, 2024 19:00
SwiftUI Flow Layout
//
// ContentView.swift
// DeleteMe
//
// Created by Chris Eidhof on 02.02.21.
//
import SwiftUI
/*
<!DOCTYPE html>
<meta charset="utf-8">
<title>Twitter Archive Viewer</title>
<script>window.YTD = { tweet: {} }</script>
<script src="tweet.js"></script><!-- this is loading a file from the archive -->
<style>
.tweet { border: 1px solid #eee; margin: 8px }
.full_text { padding: 8px }
.created_at { padding: 8px; color: #777 }
</style>
@tclementdev
tclementdev / libdispatch-efficiency-tips.md
Last active November 15, 2024 01:56
Making efficient use of the libdispatch (GCD)

libdispatch efficiency tips

The libdispatch is one of the most misused API due to the way it was presented to us when it was introduced and for many years after that, and due to the confusing documentation and API. This page is a compilation of important things to know if you're going to use this library. Many references are available at the end of this document pointing to comments from Apple's very own libdispatch maintainer (Pierre Habouzit).

My take-aways are:

  • You should create very few, long-lived, well-defined queues. These queues should be seen as execution contexts in your program (gui, background work, ...) that benefit from executing in parallel. An important thing to note is that if these queues are all active at once, you will get as many threads running. In most apps, you probably do not need to create more than 3 or 4 queues.

  • Go serial first, and as you find performance bottle necks, measure why, and if concurrency helps, apply with care, always validating under system pressure. Reuse

@seanjensengrey
seanjensengrey / octal_x86.txt
Last active November 13, 2024 16:40
x86 is an octal machine
# source:http://geocities.com/SiliconValley/heights/7052/opcode.txt
From: [email protected] (Mark Hopkins)
Newsgroups: alt.lang.asm
Subject: A Summary of the 80486 Opcodes and Instructions
(1) The 80x86 is an Octal Machine
This is a follow-up and revision of an article posted in alt.lang.asm on
7-5-92 concerning the 80x86 instruction encoding.
The only proper way to understand 80x86 coding is to realize that ALL 80x86
@karwa
karwa / codablebridge.swift
Created November 1, 2017 04:57
codable-nscoding bridge
import Foundation
/// This isn't safe to use before Swift gets ABI stability, because generic classes
/// could change their names. Also, be sure to register bridges with the Obj-C runtime
/// if using to decode during iOS state restoration.
///
class CodableBridge<Wrapped: Codable>: NSObject, NSSecureCoding {
let value: Wrapped
init(_ value: Wrapped) { self.value = value }