Skip to content

Instantly share code, notes, and snippets.


Kevin Renskers kevinrenskers

View GitHub Profile
View StateMachine.swift
// Lightweight but powerful state machine.
// Usage:
// enum TrafficLight: State {
// case red, orange, green
// }
// var trafficLights = StateMachine<TrafficLight>(initialState: .red)
// trafficLights.addRoute(from: .red, to: .green)
vzsg / 1_Fetch.swift
Last active Dec 24, 2019
A solution for the N+1 problem when fetching children for parents (Fluent 3)
View 1_Fetch.swift
import Fluent
func fetchChildren<Parent, ParentID, Child: Model, Result>(
of parents: [Parent],
idKey: KeyPath<Parent, ParentID?>,
via reference: KeyPath<Child, ParentID>,
on conn: DatabaseConnectable,
combining: @escaping (Parent, [Child]) -> Result) -> Future<[Result]> where ParentID: Hashable & Encodable {
let parentIDs = parents.compactMap { $0[keyPath: idKey] }
let children = Child.query(on: conn)
steipete / Warnings.xcconfig
Last active Feb 1, 2020
The warnings configuration we use in the PSPDFKit iOS framework -
View Warnings.xcconfig
// Warnings.xcconfig
// The list of warnings we (don’t) use, and the reasons why.
// :MARK: Warnings in use:
// :MARK: -everything
// We want the best possible diagnostics, so we simply enable everything that exists, and then opt–out of what doesn’t make sense for us.
// :MARK: - Warnings not to be promoted:
staltz /
Last active May 13, 2021
The introduction to Reactive Programming you've been missing
MarcoSero / gist:5787782
Created Jun 15, 2013
Class Dump iOS 7 Frameworks
View gist:5787782
# install class-dump
brew install class-dump
# dump the frameworks you're interested in
class-dump -H -o UIKit /Applications/
class-dump -H -o SpringBoardUI /Applications/
Mithrandir0x / gist:3639232
Created Sep 5, 2012
Difference between Service, Factory and Provider in AngularJS
View gist:3639232
// Source:!topic/angular/hVrkvaHGOfc
// jsFiddle:
// author: Pawel Kozlowski
var myApp = angular.module('myApp', []);
//service style, probably the simplest one
myApp.service('helloWorldFromService', function() {
this.sayHello = function() {
return "Hello, World!"
numo16 / Macros.h
Created Aug 20, 2012
Some useful iOS/Objective-C Macros
View Macros.h
#define ApplicationDelegate ((AppDelegate *)[[UIApplication sharedApplication] delegate])
#define UserDefaults [NSUserDefaults standardUserDefaults]
#define NotificationCenter [NSNotificationCenter defaultCenter]
#define SharedApplication [UIApplication sharedApplication]
#define Bundle [NSBundle mainBundle]
#define MainScreen [UIScreen mainScreen]
#define ShowNetworkActivityIndicator() [UIApplication sharedApplication].networkActivityIndicatorVisible = YES
#define HideNetworkActivityIndicator() [UIApplication sharedApplication].networkActivityIndicatorVisible = NO
#define NetworkActivityIndicatorVisible(x) [UIApplication sharedApplication].networkActivityIndicatorVisible = x
#define NavBar self.navigationController.navigationBar
piscisaureus /
Created Aug 13, 2012
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url =

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

pydanny / field.html
Created Nov 8, 2011
django-uni-form + Twitter Bootstrap
View field.html
<!-- this usually goes in <project-root>/templates/uni_form/field.html -->
{% if field.is_hidden %}
{{ field }}
{% else %}
<div class="clearfix {% if field.errors %}error{% endif %}">
<label for="{{ field.auto_id }}" {% if field.field.required %}class="requiredField"{% endif %}>
{{ field.label|safe }}{% if field.field.required %}<span class="asteriskField">*</span>{% endif %}
<div class="input">