Skip to content

Instantly share code, notes, and snippets.

View younata's full-sized avatar

Rachel Brindle younata

View GitHub Profile
younata / ArtistsController.swift
Created May 22, 2024 18:03
Example Client-Server implementation, using a theoretical variant of the subsonic API that actually returns JSON
import Observation
enum State<T> {
case loading
case loaded(T)
case failed(String)
final class ArtistsController {
younata / BackgroundExecutorApp.swift
Created March 19, 2024 00:41
import SwiftUI
import Dispatch
// A simple app to verify
// Allows you to check using Swift Tasks, or Dispatch Queues.
// I found this to not be the case, but maybe this isn't realistic?
// When compiled on Xcode 15.3 (either debug or release) and run on iOS 17.4,
// background QoS tasks are still executed even when Low Power Mode is enabled.
import Combine
class FakeCall<T> {
private(set) var calls = [T]()
func record(_ arguments: T) {
func reset() {
younata / layouthelpers.swift
Created December 19, 2020 21:02
UIView Autolayout Helpers
import UIKit
extension UIView {
func removeAllSubviews() {
for view in self.subviews {
younata / BadCSVParser.swift
Created October 7, 2018 16:15
Bad CSV Parser in swift
// Quick and dirty CSV parser I wrote. Handles edge cases badly. Doesn't perform well. Doesn't handle large csv files.
// But, hey, it solved my use case!
// Swift 4.2+
func parseCSVBadly(csvData: Data) -> [[String]] {
guard let csv = String(data: csvData, encoding: .utf8) else { return [] }
return csv.components(separatedBy: CharacterSet.newlines).compactMap { line in
guard !line.hasPrefix("#") else { return nil }
return line.components(separatedBy: ",")
younata / concourse_deployment.yml
Last active November 8, 2016 19:55 concourse manifest
name: concourse
director_uuid: RESULT OF bosh status --uuid
- name: concourse
version: latest
- name: garden-runc
version: latest
younata / NetworkSpec.swift
Created February 22, 2016 23:08
What Carthage/NetworkSpec.swift could have been
// I spent 2 hours working on this before I gave up. This is what I had when I declared it not worth the effort.
import Quick
import Nimble
import ReactiveCocoa
import CarthageKit
import OHHTTPStubs
class NetworkSpec: QuickSpec {
override func spec() {
younata / configuration.yml
Last active December 24, 2015 07:05
Home Assistant Configuration
name: Apartment
latitude: [Redacted]
longitude: [Redacted]
temperature_unit: F
time_zone: America/Los_Angeles
friendly_name: "Romantic"
younata / Polynomial.swift
Created October 24, 2015 04:26
Bad Self. Don't do comparisons like this.
func ==(a: Polynomial, b: Polynomial) -> Bool {
return a.description == b.description
class Foo: NSObject {
var obj: NSObject? = nil
func createObjectOfType(type: NSObject.self) -> Foo {
let obj = type()
if obj.respondsToSelector("obj") {
obj.setValue(NSObject(), forKey: "obj") // never gets called
//obj.setValue(NSObject(), forKey: "obj") // Exceptions if you don't call it with 'Foo.self'