Skip to content

Instantly share code, notes, and snippets.

samrayner / Realm+CascadeDeleting.swift
Last active Jun 24, 2021 — forked from krodak/Realm+CascadeDeleting.swift
Cascading deletion for RealmSwift
View Realm+CascadeDeleting.swift
import Foundation
import RealmSwift
import Realm
//Forked from:
internal protocol CascadingDeletable: RealmSwift.Object {
static var propertiesToCascadeDelete: [String] { get }
davidlawson / BadgeBarButtonItem.swift
Last active Dec 8, 2021
UIBarButtonItem with badge, Swift 4, iOS 9/10/11
View BadgeBarButtonItem.swift
import UIKit
public class BadgeBarButtonItem: UIBarButtonItem
public var badgeNumber: Int = 0 {
didSet {
valvoline / String+HTML.swift
Created Nov 8, 2017
A swift string extension to deal with HTML
View String+HTML.swift
// String+HTML.swift
// AttributedString
// Created by Costantino Pistagna on 08/11/2017.
// Copyright © 2017 All rights reserved.
import UIKit
import Foundation
troyfontaine /
Last active May 18, 2022
Signing your Git Commits using GPG on MacOS Sierra/High Sierra

Methods of Signing with GPG

Last updated March 28, 2021

There are now two ways to approach this:

  1. Using gpg and generating keys
  2. Using Kryptonite by

This Gist explains how to do this using gpg in a step-by-step fashion. Kryptonite is actually wickedly easy to use-but you will still need to follow the instructions

JohnSundell / Perform.swift
Last active Dec 21, 2019
A function that enables you to easily wrap throwing APIs, to provide a custom error
View Perform.swift
* Perform a throwing expression, and throw a custom error in case the expression threw
* - parameter expression: The expression to execute
* - parameter error: The custom error to throw instead of the expression's error
* - throws: The given error
* - returns: The return value of the given expression
func perform<T>(_ expression: @autoclosure () throws -> T, orThrow errorExpression: @autoclosure () -> Error) throws -> T {
do {
joshdholtz / StopJumpingTableViewOnInsertRows.swift
Last active Jan 18, 2022
Used when loading more data into UITableView for a smooth "infinite scroll" feel
View StopJumpingTableViewOnInsertRows.swift
// I dont want my table jumping/animation when appending new rows
// for an infinite scroll feel
// Some of this might not be needed but it works
// TODO: Possibly garbage
extension UITableView {
func reloadDataSmoothly() {
insidegui / WebCacheCleaner.swift
Created Sep 14, 2016
Clear WKWebView's cookies and website data storage, very useful during development.
View WebCacheCleaner.swift
import Foundation
import WebKit
final class WebCacheCleaner {
class func clean() {
HTTPCookieStorage.shared.removeCookies(since: Date.distantPast)
print("[WebCacheCleaner] All cookies deleted")
WKWebsiteDataStore.default().fetchDataRecords(ofTypes: WKWebsiteDataStore.allWebsiteDataTypes()) { records in
chrisjlee /
Last active Mar 30, 2022
Delete feature branch with prefix locally then remove all remote feature branches
# Stole from:
git branch -D $(printf "%s\n" $(git branch) | grep 'feature/')
# Or this will work too to remove all remote branches:
git branch -r | awk -F/ '/\/feature/{print $2}' | xargs -I {} git push origin :{}
# Prune all origin branches
git remote prune origin
davbeck / assets.rb
Last active Jan 5, 2022
Automatic Enum-based Xcassets in Swift
View assets.rb
#!/usr/bin/env ruby
require "active_support"
def assetCatalogsAtPath(path)
results = []
contents = Dir.entries(path)
snikch / gist:3661188
Created Sep 6, 2012
Find the current top view controller for your iOS application
View gist:3661188
- (UIViewController *)topViewController{
return [self topViewController:[UIApplication sharedApplication].keyWindow.rootViewController];
- (UIViewController *)topViewController:(UIViewController *)rootViewController
if (rootViewController.presentedViewController == nil) {
return rootViewController;