Skip to content

Instantly share code, notes, and snippets.

View eliperkins's full-sized avatar

Eli Perkins eliperkins

View GitHub Profile
@eliperkins
eliperkins / LinearGradientView.swift
Created November 6, 2018 22:42
lol gradients in UIKit 🙃🙃🙃
import UIKit
@objc(CLBLinearGradientView)
class LinearGradientView: UIView {
@objc var layerBacked: Bool {
didSet {
switch (layerBacked, layerView) {
case (true, .none): addLayerView()
case (false, .some): removeLayerView()
default: break
@eliperkins
eliperkins / Autoclosures.swift
Created September 21, 2022 15:26
Swift autoclosure "lazy" evaluation
struct SomeStruct {
init(someReallyExpensiveValue: @autoclosure () -> Int) {
print("really expensive")
Thread.sleep(forTimeInterval: TimeInterval(someReallyExpensiveValue() * 1))
}
init(someEvenMoreExpensiveValue: @autoclosure () -> Int) {
print("even more expensive")
Thread.sleep(forTimeInterval: TimeInterval(someEvenMoreExpensiveValue() * 5))
}
@eliperkins
eliperkins / check-outdated-deps.rb
Created April 8, 2024 22:40
Find outdated dependencies in an XcodeGen-based project
#!/usr/bin/env ruby
# frozen_string_literal: true
require 'colored2'
require 'octokit'
require 'yaml'
if ENV['GITHUB_TOKEN'].nil?
puts '❗️ GITHUB_TOKEN environment variable is not set!'.red
puts 'Supply a token from gh CLI by running `GITHUB_TOKEN=$(gh auth token) script/check-outdated-deps.rb`'