Skip to content

Instantly share code, notes, and snippets.

@grdsdev
grdsdev / TaskManager.swift
Last active November 9, 2023 21:57
Auto manage cancellation of in flight tasks.
protocol _CancellableTask {
func cancel()
}
extension Task: _CancellableTask {}
struct _TaskID: Hashable {
let function: String
let fileID: String
public enum AnyJSON: Equatable, Codable {
case string(String)
case number(Double)
case object([String: AnyJSON])
case array([AnyJSON])
case bool(Bool)
var value: Any {
switch self {
case let .string(string): return string
@grdsdev
grdsdev / families.sql
Created June 21, 2022 13:08
families.sql
create type family_user_role as enum (
'admin',
'member'
);
create table public.families (
id uuid default uuid_generate_v4 () not null primary key,
inserted_at timestamp with time zone default timezone('utc'::text, now()) not null,
updated_at timestamp with time zone default timezone('utc'::text, now()) not null,
name text not null
{% for type in types.structs %}
{% if type|annotated:"AutoInit" %}
{% set spacing %}{% if type.parentName %} {% endif %}{% endset %}
{% map type.storedVariables into parameters using var %}{{ var.name }}: {% if var.typeName|hasPrefix:"(" %}@escaping {% endif %}{{ var.typeName }}{% endmap %}
// sourcery:inline:auto:{{ type.name }}.AutoInit
{{spacing}}{{ type.accessLevel }} init({{ parameters|join:", " }}) {
{{spacing}} {% for variable in type.storedVariables %}
{{spacing}} self.{{ variable.name }} = {{ variable.name }}
{{spacing}} {% endfor %}
{{spacing}}}

Keybase proof

I hereby claim:

  • I am grsouza on github.
  • I am grsouza (https://keybase.io/grsouza) on keybase.
  • I have a public key ASAXDqUwkS39Uvtl_vvYkAwGdDxFBnTQcKaXtIWlt1GHFAo

To claim this, I am signing this object:

#!/bin/sh
[ "$UID" -eq 0 ] || exec sudo bash "$0" "$@"
rm -rf $HOME/.Trash/*
rm -rf $HOME/Library/Developer/Xcode/DerivedData/*
rm -rf $HOME/Library/Developer/Xcode/Archives/*
rm -rf $HOME/Library/Developer/CoreSimulator/Caches/*
rm -rf $HOME/Library/Caches/*
command regex json 's/(.+)/expr let input = %1; print(String(data: try! JSONSerialization.data(withJSONObject: (input is Data ? (try! JSONSerialization.jsonObject(with: input as! Data, options: [])) : input as! Any), options: [.prettyPrinted]), encoding: .utf8)!)/'
" Enable filetype plugins
filetype plugin on
filetype indent on
set number
" Turn on the Wild menu
set wildmenu
"Always show current position
import UIKit
@dynamicMemberLookup
public struct Builder<Base> {
private let _build: () -> Base
public init(_ build: @escaping () -> Base) {
self._build = build
}
protocol ViewConfigurable {}
extension ViewConfigurable where Self: UIView {
func configure(_ block: (Self) -> Void) -> Self {
block(self)
return self
}
}