Skip to content

Instantly share code, notes, and snippets.

@chosa91
chosa91 / AutoLayout.md
Created February 8, 2020 09:53 — forked from oliverkrakora/AutoLayout.md
The best damn AutoLayout guide I've ever seen

ℹ️ This article is also available on his blog.


Fundamentals

Layout and Drawing are two different things:

  • Layout defines only the positions and sizes of all views on screen.
  • Drawing specifies how each view is rendered (how it looks).
@chosa91
chosa91 / HW2020Q1 - Sentiment Analysis.md
Last active November 14, 2022 21:27
Hackweek 2020 Q1 - Sentiment analysis

👋 Hackweek 2020 Q1 - Sentiment analysis 👀

Goal

Plan

Tone analysis on text like Grammarly.

Tone detector teaser

@chosa91
chosa91 / Publisher+extension.swift
Created September 27, 2021 16:30
Publisher extension
import Combine
extension Publisher {
func withInitialValue(_ value: Output) -> AnyPublisher<Output, Failure> {
merge(with: Just(value).setFailureType(to: Failure.self)).eraseToAnyPublisher()
}
}
import Foundation
struct AnyEquatable {
private let isEqualTo: (Any) -> Bool
let value: Any
init<A: Equatable>(_ value: A) {
self.value = value
isEqualTo = { other in
guard let o = other as? A else { return false }
@chosa91
chosa91 / DictionaryTupleDecoder.swift
Last active April 20, 2021 08:07
Destructure dictionaries into tuple
// Source: https://twitter.com/NSExceptional/status/1383665312684335105
// MARK: - Helpers
extension UnsafePointer {
var raw: UnsafeRawPointer {
return UnsafeRawPointer(self)
}
@chosa91
chosa91 / hackweek_2021_q1.md
Last active March 12, 2021 09:59
The week of practicing #fail-early & #fail-often

The week of practicing "#fail-early" & "#fail-often"

Main-plan: Fullstory iOS Integration

TL;DR

PRO plan not pro enough (doesn't include the mobile add-on)

But... the technical support is quick and helpful.

@chosa91
chosa91 / GridViewController.swift
Last active November 24, 2020 11:55
Stackoverflow question: UICollectionViewCompositionalLayout multi column layout with auto-sizing cells - https://stackoverflow.com/a/64985964/2569338
/*
GOAL:
- UICollectionViewCompositionalLayout multi column layout with auto-sizing cells where each cell has the same height in a given row (uses the max cell height in a row)
REALITY:
- The groups aren't filled :/
*/
import Foundation
import UIKit
@chosa91
chosa91 / Best in Class iOS Checklist
Created August 29, 2020 11:52 — forked from DreamingInBinary/Best in Class iOS Checklist
This is a public checklist updated every year after the latest version of iOS and iPadOS are shipped. It's a boiled down version of a "Best in Class" app checklist created by Jordan Morgan.
# A Best in Class Checklist
A boiled down checklist adapted from this [post](https://www.swiftjectivec.com/a-best-in-class-app/), created by @jordanmorgan10.
> To use this, create a Github Issue in your own repo, and simply copy and paste this text.
## iOS Core Technology
_Things any iOS app can benefit from_
- [ ] iCloud Sync
- [ ] [Core Spotlight integration](https://github.com/DreamingInBinary/Spend-Stack/issues/120)
import UIKit
// Source: https://sarunw.com/posts/match-view-shadow-to-sketch-shadow/
extension UIView {
func applySketchShadow(
color: UIColor = .black,
alpha: Float = 0.2,
x: CGFloat = 0,
y: CGFloat = 2,
@chosa91
chosa91 / Published.swift
Last active May 15, 2020 11:09
Backward compatible reactive ObservableObject
import Foundation
import UIKit
// Source: https://www.swiftbysundell.com/articles/published-properties-in-swift/
// MARK: - List
struct List<Value> {
private(set) var firstNode: Node?
private(set) var lastNode: Node?