Skip to content

Instantly share code, notes, and snippets.

View cliss's full-sized avatar

Casey Liss cliss

View GitHub Profile
@cliss
cliss / Playground.swift
Last active May 12, 2023 14:18
List{} Gets Me Again
//: A UIKit based Playground for presenting user interface
import SwiftUI
import PlaygroundSupport
struct SlideDemo: View {
@State var activePage = 0
var body: some View {
// Change this VStack to a List and the animation breaks
@cliss
cliss / Example.swift
Last active February 6, 2023 12:31
Decoding a heterogenous JSON array
// This is intended to be dropped in a Playground.
import Foundation
let json =
"""
{
"name": "Casey's Corner",
"menu": [
{
@cliss
cliss / RatingsFetcher.swift
Created May 21, 2022 00:35
Fetching Ratings
import Foundation
import Combine
public struct RatingsFetcher {
/// Asynchronously gets the number of ratings for the current version of the given app.
/// - Parameter appId: App ID to look up
/// - Returns: Count of ratings for the current version
public static func ratingsForCurrentVersion(appId: Int) async throws -> Int {
guard let url = URL(string: "https://itunes.apple.com/lookup?id=\(appId)") else {
@cliss
cliss / MatchingHeightsPlaygroundPage.swift
Created February 2, 2021 14:39
Matching Heights Techniques
import UIKit
import SwiftUI
import PlaygroundSupport
/* *****************************************
* GeometryReader with PreferenceKey
* *****************************************/
struct HeightPreferenceKey: PreferenceKey {
static let defaultValue: CGFloat = 0
@cliss
cliss / mergechapters.py
Created January 26, 2021 14:30
Merge Files with Chapters
import datetime
import json
import os
import subprocess
import sys
#############
### USAGE ###
#############
import UIKit
public typealias RowSectionPair = (row: Int, section: Int)
extension IndexPath: RawRepresentable {
public typealias RawValue = RowSectionPair
public init?(rawValue: RowSectionPair) {
self = IndexPath(row: rawValue.row, section: rawValue.section)
}
@cliss
cliss / IteratorPlayground.swift
Created December 18, 2019 14:35
Playground contents showing the use of AnyIterator<T>
import Foundation
class ListOfIntegers: Sequence {
typealias Element = Int
private var backingStore = [Int]()
init() {}
init(_ value: [Int]) {
self.backingStore = value
}
@cliss
cliss / Brewfile
Last active September 2, 2023 06:50
Casey Liss's Brewfile, as of 31 October 2021
cask_args appdir: "/Applications"
tap "homebrew/cask-fonts"
brew "mas"
#### LAPTOPS ####
#cask "tripmode"
#### LAPTOPS ####
mas "Boop", id: 1518425043
@cliss
cliss / SearchController.swift
Last active June 2, 2017 18:07 — forked from irace/SearchController.swift
UISearchController replacement. Relies on a couple of internal categories, helpers, etc.
//
// SearchController.swift
// Prefer
//
// Created by Bryan Irace on 5/31/17.
// Copyright © 2017 Prefer. All rights reserved.
//
import RxSwift
import RxCocoa
+--------+---------+-------------------------+
| Series | Episode | Description |
+--------+---------+-------------------------+
| 7 | 7 | Winter Olympics |
| 0 | 12 | Polar Challenge |
| 9 | 3 | Southeast America |
| 10 | 4 | Botswana |
| 12 | 8 | Vietnam |
| 14 | 6 | Bolivia |
| 0 | 33 | Northeast America |