Skip to content

Instantly share code, notes, and snippets.

View Amzd's full-sized avatar
🚀

Casper Zandbergen Amzd

🚀
View GitHub Profile
@casperzandbergenyaacomm
casperzandbergenyaacomm / EmptyOrNil.swift
Last active November 12, 2021 08:10
Adding readability for an if statement I often use.
protocol EmptyOrNil {
var isEmpty: Bool { get }
}
extension Optional where Wrapped: EmptyOrNil {
var isEmptyOrNil: Bool {
return self?.isEmpty ?? true
}
}
import Foundation
import UIKit
public protocol Configure {}
extension Configure {
/// Makes it available to set properties with closures just after initializing.
///
/// let frame = UIView().configure {
@danlozano
danlozano / Coordinator.swift
Last active September 26, 2018 07:19
Coordinator Class
class Coordinator {
private(set) var childCoordinators: [Coordinator] = []
func start() {
preconditionFailure("This method needs to be overriden by concrete subclass.")
}
func finish() {
preconditionFailure("This method needs to be overriden by concrete subclass.")
@brygrill
brygrill / firebase-graphql-with-data.js
Last active March 3, 2021 23:00
Deploying a GraphQL Server with Firebase Functions
// sample graphql server deployed with firebase functions
// pulling some basic stockmarket data from a firebase db
const functions = require('firebase-functions');
const admin = require('firebase-admin');
const express = require('express');
const graphqlHTTP = require('express-graphql');
const values = require('lodash.values');
const { GraphQLSchema, GraphQLObjectType, GraphQLList, GraphQLString } = require('graphql');
// Init express
/**
A default implmentation that provides a few convenience methods for starting and stopping coordinators.
*/
extension Coordinator {
// Default implementation, so that we don't have to do this for all coordinators.
func startChild<T: NSObject where T: Coordinator>(coordinator coordinator: T, withIdentifier identifier: String, callback: CoordinatorCallback?) -> T {
childCoordinators[identifier] = coordinator
coordinator.start(withCallback: callback)
return coordinator