Skip to content

Instantly share code, notes, and snippets.

View jessesquires's full-sized avatar
🏴
free labor

Jesse Squires jessesquires

🏴
free labor
View GitHub Profile
// https://wadetregaskis.com/swiftui-main-thread-hang-detector/
var body: some View {
SomeRootView {
}.task {
let approximateGranularity = Duration.milliseconds(10)
let threshold = Duration.milliseconds(50)
let clock = SuspendingClock()
@jessesquires
jessesquires / pages-to-pdf.scpt
Created December 6, 2023 06:48
AppleScript to export a Pages document as a PDF
-- Prompt to select the invoice
set theInvoice to choose file with prompt "Please select an invoice:"
-- Get enclosing folder name
tell application "Finder" to set destinationFolder to container of theInvoice
log "Destination folder: " & destinationFolder
tell application "Pages"
activate
open theInvoice
@jessesquires
jessesquires / gitsl.sh
Last active December 3, 2023 07:08
git "smartlog" / "pretty log"
# blog post
#
# https://www.jessesquires.com/blog/customizing-git-log/
git log --graph --pretty=format:'commit: %C(bold red)%h%Creset %C(red)<%H>%Creset %C(bold magenta)%d %Creset%ndate: %C(bold yellow)%cd %Creset%C(yellow)%cr%Creset%nauthor: %C(bold blue)%an%Creset %C(blue)<%ae>%Creset%n%C(cyan)%s%n%Creset'
@jessesquires
jessesquires / feed.json
Last active August 22, 2022 05:21
Jekyll JSON Feed
---
layout: null
---
{
"version": "https://jsonfeed.org/version/1",
"title": "{{ site.title }}",
"home_page_url": "{{ site.url }}",
"feed_url": "{{ site.url }}/feed.json",
"description": "{{ site.description }}",
@jessesquires
jessesquires / generic_constraints.swift
Created April 6, 2015 05:37
Swift generic constraints, conforming to a superclass and multiple protocols
protocol MyProtocol {
}
protocol MyOtherProtocol {
}
func configure <T: UIViewController where T: MyProtocol, T: MyOtherProtocol> (viewController: T) {
@jessesquires
jessesquires / keybase.md
Last active September 13, 2019 01:23
keybase.md

Keybase proof

I hereby claim:

  • I am jessesquires on github.
  • I am jsq (https://keybase.io/jsq) on keybase.
  • I have a public key whose fingerprint is BBAE BA80 7CF2 7BC2 5E5C FB43 1537 66AC 1FA1 A758

To claim this, I am signing this object:

import Cocoa
protocol Shape { }
struct Triangle: Shape { }
// Function signature requires a concrete type T, it is specialized by T
// Think of it as having a unique function per type:
// - `protoflip(_ s: Triangle) -> Shape`
// - `protoflip(_ s: Square) -> Shape`
@jessesquires
jessesquires / detweet.swift
Created January 15, 2019 17:56 — forked from mxcl/detweet.swift
Delete all tweets and favorites older than two months ago. Instructions in comment.
#!/usr/bin/swift sh
import Foundation
import PromiseKit // @mxcl ~> 6.5
import Swifter // @mattdonnelly == b27a89
let swifter = Swifter(
consumerKey: "FILL",
consumerSecret: "ME",
oauthToken: "IN",
oauthTokenSecret: "https://developer.twitter.com/en/docs/basics/apps/overview.html"
@jessesquires
jessesquires / generics_playground.swift
Last active June 27, 2018 02:19
Swift optional generic parameters?
protocol FactoryAType {
typealias Product
}
protocol FactoryBType {
typealias Product
}