Skip to content

Instantly share code, notes, and snippets.

View zackdotcomputer's full-sized avatar
🔨
Building

Zack Sheppard zackdotcomputer

🔨
Building
View GitHub Profile
@zackdotcomputer
zackdotcomputer / keybase.md
Created May 24, 2017 20:01
Keybase Verification

Keybase proof

I hereby claim:

  • I am zackzachariah on github.
  • I am zackzachariah (https://keybase.io/zackzachariah) on keybase.
  • I have a public key whose fingerprint is 876C 2E52 8A74 0E5F 3D4B 81AA 4133 FB29 EF30 72A0

To claim this, I am signing this object:

@zackdotcomputer
zackdotcomputer / Character+isEmoji.swift
Last active July 24, 2019 03:52
Swift Character-is-emoji checker
import Foundation
extension Character {
/// An approximation of a spec-compatible "is this an emoji" check for the character.
/// Will recognize standard, flag, composite, tag emoji, and keycap emoji.
/// Unfortunately, will return true for "text presented" and malformed emoji too,
/// because I didn't do the whole CFG from Unicode.
var isEmoji: Bool {
// Empty character returns false
guard let first = self.unicodeScalars.first else {
@zackdotcomputer
zackdotcomputer / buildnumber.rb
Created April 27, 2020 21:56
Fastlane Ruby Build Number Function
# Generates a build number that will consistently increase worldwide.
# Useful for coordinating build uploads between teams in different timezones.
# Format is "YYYYMMDDsss" where "sss" is the 1000ths slice of the day.
# For example, I just ran it in NYC at 5:55pm on 2020-04-27 and got back: 20200427913
# If anyone else worldwide (with a correct system clock) runs it after this,
# they will get a bigger number guaranteed.
def generate_build_number()
time = Time.new.getutc
date = time.strftime("%Y%m%d")
@zackdotcomputer
zackdotcomputer / index.tsx
Last active May 7, 2020 16:48
Fixed index.tsx for reduced-context-bug - Omitting Changed Nodes
import React, { createContext, useContext } from "react";
import { useWindowSize } from "react-use";
const DisplayContext = createContext<"normal" | "compact">("normal");
export default function Parent() {
const { width } = useWindowSize();
let windowSizeDisplayContext = undefined;
if (width !== Infinity) {
@zackdotcomputer
zackdotcomputer / index.tsx
Created May 7, 2020 16:49
Fixed index.tsx for reduced-context-bug - Wait until mounting
import React, { createContext, useContext, useEffect, useState } from "react";
import { useWindowSize } from "react-use";
const DisplayContext = createContext<"normal" | "compact">("normal");
export default function Parent() {
const { width } = useWindowSize();
const [windowSizeDisplayContext, setWindowSizeDisplayContext] = useState<
"normal" | "compact"
@zackdotcomputer
zackdotcomputer / Optional+Extension.swift
Last active September 7, 2020 21:46
More Monadical Optionals in Swift
// Copyright © 2020 Zack Sheppard. All rights reserved.
// Available under the MIT License
/// A few Sequence/Monad-like functions added to Optional
extension Optional {
/// Transform this optional into another type
@inlinable public func map<T>(_ transform: (Wrapped) throws -> T) rethrows -> T? {
if let inside = self {
return try transform(inside)
} else {
@zackdotcomputer
zackdotcomputer / KeyboardAware.swift
Last active September 7, 2020 21:46
Make UIViewControllers automatically aware of the keyboard
//
// UIViewController+KeyboardAware.swift
//
// Created by Zack Sheppard.
// Copyright © 2020 Zack Sheppard. All rights reserved.
// Available under the MIT License
//
import UIKit
@zackdotcomputer
zackdotcomputer / String+IntRange.swift
Last active September 7, 2020 21:46
Range<Int> substring finder for Swift Strings - Unsafe but Simple
//
// String+CountableRange.swift
//
// Created by Zack Sheppard on 8/30/20.
// Copyright © 2020 Zack Sheppard. All rights reserved.
// Available under the MIT License
//
import Foundation
/// This extension is available at
@zackdotcomputer
zackdotcomputer / ShrinkingTableCell.swift
Last active September 7, 2020 21:45
A table view cell that shrinks to avoid the top of the table
//
// ShrinkingTableCell.swift
// ShrinkingTableCell
//
// Created by Zack Sheppard on 9/2/20.
// Copyright © 2020 Zack Sheppard. All rights reserved.
// Available under the MIT License
// Available at https://gist.github.com/zackdotcomputer/d365bfa5cd7e4a38d45c078b09459da3
//
@zackdotcomputer
zackdotcomputer / Decodable+Graceful.swift
Created September 28, 2020 13:19
Graceful Decoding for Swift Decodable
//
// Decodable+Graceful.swift
// Graceful Decodable
//
// Created by Zack Sheppard on 9/10/20.
// Copyright © 2020 Zack Sheppard. All rights reserved.
// Available under the MIT License
// Available at https://gist.github.com/zackdotcomputer/81b8545e3ce81128a299996814823963
//