Skip to content

Instantly share code, notes, and snippets.

View Sherlouk's full-sized avatar

James Sherlock Sherlouk

View GitHub Profile
@Sherlouk
Sherlouk / gist:fa3e49e24f9be7232c642b945177b05e
Created October 1, 2023 14:34
MeiliSearch Swift Async Sourcery Template
{% macro extractResultType parameter %}{% typed parameter as MethodParameter %}{{ parameter.typeName.closure.parameters[0].typeName.generic.typeParameters[0].typeName }}{% endmacro %}
{% macro extractParameters parameters %}{% typed parameters as [MethodParameter] %}{% map parameters into newArray %}{% if maploop.last == false %}{{ maploop.item.asSource }}{% endif %}{% endmap %}{{ newArray|join:", " |replace:", $","","regex" }}{% endmacro %}
{% macro extractFunctionName method %}{% for var in method.name|split:"(" %}{% if forloop.first %}{{ var|replace:">","" }}{% if method.isGeneric %}{% for conformance in method.returnTypeName.name|split:"where T" %}{% if forloop.last %}{{ conformance }}>{% endif %}{% endfor %}{% endif %}{% endif %}{% endfor %}{% endmacro %}
{% macro extractParametersCalled parameters %}{% map parameters into newArray %}{% if not maploop.last %}{% if maploop.item.argumentLabel %}{{ maploop.item.argumentLabel }}: {{ maploop.item.name }}{% else %}{{ maploop.item.name }}{% endif %}{% endif %}{
@Sherlouk
Sherlouk / DebugDevice.swift
Last active December 10, 2023 19:24
Debug Profiles - Securely debugging in production
//
// DebugDevice.swift
//
// Copyright 2022 • Sidetrack Tech Limited
//
import Foundation
// This must be called on the main-thread.
var isDebugProfileInstalled: Bool {
@Sherlouk
Sherlouk / AccessibilityPreview.swift
Created June 8, 2022 20:05
SwiftUI view for adding accessibility previews. Proof of concept.
import SwiftUI
import UIKit
// from https://github.com/cashapp/AccessibilitySnapshot
import AccessibilitySnapshotCore
struct AccessibilityPreview<Content: View>: View {
let content: Content
var body: some View {
@Sherlouk
Sherlouk / LazyEqualVGrid.swift
Created September 25, 2021 15:00
An example demonstrating a LazyVGrid with all tiles in a row sharing the same height
//
// LazyEqualVGrid.swift
//
// Created by James Sherlock on 25/09/2021.
//
import SwiftUI
struct LazyEqualVGrid<Content: View, Data: Identifiable>: View {
@Sherlouk
Sherlouk / metrickit-diag.sample.json
Created August 8, 2020 21:34
MetricKit Sample JSON (iOS 14)
{
"crashDiagnostics" : [
{
"version" : "1.0.0",
"callStackTree" : {
"callStacks" : [
{
"threadAttributed" : true,
"callStackRootFrames" : [
{

Keybase proof

I hereby claim:

  • I am Sherlouk on github.
  • I am sherlouk (https://keybase.io/sherlouk) on keybase.
  • I have a public key whose fingerprint is 8CC0 49F4 F4B7 D026 95D3 CB28 9C41 C003 590E 1908

To claim this, I am signing this object:

@Sherlouk
Sherlouk / NSDateFormatter Cheatsheet
Created May 29, 2016 20:20
NSDateFormatter Cheatsheet
a: AM/PM
s: 1/59 - Seconds
ss: 01/59 - Seconds w/ Leading
m: 1/59 - Minutes
mm: 01/59 - Minutes w/ Leading
h: 5/10 (5AM, 10PM) - 12hr Clock
hh: 05/10 (5AM, 10PM) - 12hr Clock w/ Leading