Skip to content

Instantly share code, notes, and snippets.

@danthorpe
danthorpe / Package.dsl.swift
Last active March 26, 2023 16:48
Swift Package Manager DSL
/// ✂️ Copy everything below this into other Package.swift files
/// to create the DSL capabilities described at
/// https://dan.works/hyper-modularization/
/// ------------------------------------------------------------
// MARK: - 🪄 Package Helpers
extension String {
var dependency: Target.Dependency {
Target.Dependency.target(name: self)

Keybase proof

I hereby claim:

  • I am danthorpe on github.
  • I am danthorpe (https://keybase.io/danthorpe) on keybase.
  • I have a public key ASCDjaCGXP6ztLbEhAe0aQD1xCJq-nI6tevz2G92e_y10Ao

To claim this, I am signing this object:

@danthorpe
danthorpe / Layout.swift
Last active October 31, 2018 17:08
Autolayout DSL
import UIKit
public protocol LayoutAnchor {
func constraint(equalTo: Self, constant: CGFloat) -> NSLayoutConstraint
func constraint(greaterThanOrEqualTo: Self, constant: CGFloat) -> NSLayoutConstraint
func constraint(lessThanOrEqualTo: Self, constant: CGFloat) -> NSLayoutConstraint
}
@danthorpe
danthorpe / persistent_datasource.swift
Last active August 29, 2015 14:06
Using YapDatabase Views & Mappings with Swift
extension YapDatabaseView {
public enum Grouping {
case ByKey(YapDatabaseViewGroupingWithKeyBlock)
case ByObject(YapDatabaseViewGroupingWithObjectBlock)
case ByMetadata(YapDatabaseViewGroupingWithMetadataBlock)
case ByRow(YapDatabaseViewGroupingWithRowBlock)
var object: YapDatabaseViewGrouping {

Keybase proof

I hereby claim:

  • I am danthorpe on github.
  • I am danthorpe (https://keybase.io/danthorpe) on keybase.
  • I have a public key whose fingerprint is B785 AC26 F86F 17C8 7E0C 8336 A4D8 8C25 B7EA 63B0

To claim this, I am signing this object:

@danthorpe
danthorpe / TwitterHelper.h
Created July 3, 2012 18:37
Using Twitter reverse_auth and Parse
//
// TwitterHelper.h
//
// Created by Daniel Thorpe on 23/05/2012.
// Copyright (c) 2012 Blinding Skies Limited. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <ACAccounts/ACAccounts.h>
@danthorpe
danthorpe / DeviceHelper.h
Created June 25, 2012 12:13
Helper functions for applying code between different iOS versions at runtime.
//
// DeviceHelper.h
//
// Created by Daniel Thorpe on 25/06/2012.
// Copyright (c) 2012 Blinding Skies Limited. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface DeviceHelper : NSObject
@danthorpe
danthorpe / gist:1070191
Created July 7, 2011 18:29
A load more table view controller
//
// TableViewController.m
// PartialTable
//
// Created by Abizer Nasir on 07/07/2011.
//
#import "TableViewController.h"
#define kNumberOfItemsToAdd 8