Skip to content

Instantly share code, notes, and snippets.

View chrisjrex's full-sized avatar

Christopher Rex chrisjrex

View GitHub Profile
// PerceptionDebug
//
// min iOS target = 15.0
// ComposableArchitecture version = 1.7.3
import ComposableArchitecture
import SwiftUI
@main
struct PerceptionDebugApp: App {
@chrisjrex
chrisjrex / iterm2.md
Created April 6, 2021 09:17 — forked from squarism/iterm2.md
iterm2 cheatsheet

Tabs and Windows

Function Shortcut
New Tab + T
Close Tab or Window + W (same as many mac apps)
Go to Tab + Number Key (ie: ⌘2 is 2nd tab)
Go to Split Pane by Direction + Option + Arrow Key
Cycle iTerm Windows + backtick (true of all mac apps and works with desktops/mission control)
@chrisjrex
chrisjrex / UILabel+ShrinkFontSizeToFit.swift
Last active November 20, 2020 17:51
ShrinkFontSizeToFit() when UILabel has numberOfLines = 0 and lineBreakMode = .byWordWrapping
import UIKit
extension UILabel {
func shrinkFontSizeToFit(minimumFontSize: CGFloat? = nil, additionalAttributes: [NSAttributedString.Key: Any] = [:]) {
guard self.bounds.size != .zero, let unwrappedText = self.text, let longestWord = String.findLongestWordByWidth(in: unwrappedText) else {
return
}
var attributes = self.currentAttributes().merging(additionalAttributes, uniquingKeysWith: { _, new in new })
@chrisjrex
chrisjrex / totp.dart
Last active March 5, 2020 10:52
TOTP last & next refresh times
static int secondsRemainingUntilRefreshTime() {
final next = nextRefreshTime(DateTime.now(), 30);
return next.difference(DateTime.now()).inSeconds;
}
static DateTime lastRefreshTime(DateTime date, int intervalSeconds) {
final epochSeconds = date.millisecondsSinceEpoch ~/ 1000;
final lastRefreshEpochSeconds = epochSeconds - epochSeconds.remainder(intervalSeconds);
return DateTime.fromMillisecondsSinceEpoch(lastRefreshEpochSeconds * 1000);
}
@chrisjrex
chrisjrex / PostmanVariableSet
Created March 4, 2020 10:16
Using tests to set postman variables from responses
var jsonData = JSON.parse(responseBody);
postman.setEnvironmentVariable("access_token", jsonData.access_token);
postman.setEnvironmentVariable("refresh_token", jsonData.refresh_token);