Skip to content

Instantly share code, notes, and snippets.

View chrszlz's full-sized avatar
🥃

Chris Zelazo chrszlz

🥃
View GitHub Profile
@chrszlz
chrszlz / ScrollSyncController_UIScrollViewDelegate.swift
Created October 6, 2023 17:21
Experiment syncing two UIScrollViews with CADisplayLink. Slightly better than CADisplayLink approach.
import UIKit
/// Controller which syncs any `n` `UIScrollViews` with a primary `UIScrollView`.
/// The primary scroll view has scrolling enabled and synced scroll views do not.
public class ScrollSyncController: NSObject, UIScrollViewDelegate {
public weak var primaryScrollView: UIScrollView?
public let syncedScrollViews: [UIScrollView]
public weak var delegate: UIScrollViewDelegate?
@chrszlz
chrszlz / ScrollSyncController_CADisplayLink.swift
Last active October 6, 2023 17:20
Experiment syncing two UIScrollViews with CADisplayLink. Ended up using a UIScrollViewDelegate solution for nominally better performance.
@chrszlz
chrszlz / setup.sh
Last active June 13, 2023 19:16 — forked from bradp/setup.sh
chrz macOS dotfiles
echo "Creating an SSH key for you..."
ssh-keygen -t rsa
pbcopy < ~/.ssh/id_rsa.pub
echo "Key has been copied to your clipboard \n"
echo "Please add it to Github: https://github.com/account/ssh \n"
read -p "Press [Enter] key after this..."
echo "Installing xcode-stuff"
xcode-select --install
No restrictions
No alcohol
No dairy
No eggs
No fish
Gluten free
Halal
Kosher
No lamb
No legumes
@chrszlz
chrszlz / String+HTML.swift
Created November 1, 2017 08:56
HTML parsing utility functions
//
// String+HTML.swift
// Redux
//
// Created by Chris Zelazo on 8/1/17.
// Copyright © 2017 Chris Zelazo. All rights reserved.
//
import Foundation
//
// PrettyString.swift
// Redux
//
// Created by Chris Zelazo on 7/31/17.
// Copyright © 2017 Chris Zelazo. All rights reserved.
//
import Foundation
@chrszlz
chrszlz / CSE 190 HW 2 #1.3
Last active August 29, 2015 14:20
1.3 - Cluster Convergence
def listError(x, c):
return [pow((x[i] - c[i]), 2) for i in range(len(x))]
def nearestCent(x, cs):
if (listError(x, cs[0]) < listError(x, cs[1])):
return 0
else:
return 1
centroids = [[0,0,0,0,1], [0,0,0,1,0]]