Skip to content

Instantly share code, notes, and snippets.

Avatar
🦄
Coding... probably

Cameron Eldridge foxfriends

🦄
Coding... probably
View GitHub Profile
View sort.js
export const Asc = Symbol('Asc');
export const Desc = Symbol('Desc');
/**
* @typedef {[string, direction, direction]} Order
* Describes a sorting step. The string is the key of the object, the first direction
* is the direction to sort values within the same type, and the second direction is
* the direction to sort values of different types. See {@see sort} for the default
* orderings.
*/
@foxfriends
foxfriends / Config.swift
Created Oct 16, 2019
Type safe wrapper around a .plist file
View Config.swift
// MARK: - ConfigKey
protocol ConfigKey {
associatedtype Data
static var key: String { get }
}
// MARK: - Config
/// A type safe wrapper around Config.plist
@foxfriends
foxfriends / Storage.swift
Created Oct 16, 2019
Type safe wrapper around UserDefaults
View Storage.swift
import Foundation
// MARK: - Storage Key
protocol StorageKey {
associatedtype V: Codable
static var key: String { get }
}
// MARK: - Storage
View keybase.md

Keybase proof

I hereby claim:

  • I am foxfriends on github.
  • I am cameldridge (https://keybase.io/cameldridge) on keybase.
  • I have a public key ASAJbuKTod9nbNzGaX-u7LfUD4USig1CqKbYipuLVdgWzAo

To claim this, I am signing this object:

@foxfriends
foxfriends / String+Localization.swift
Created Sep 6, 2019
Wrapper around NSLocalizableString to make it a lot easier to use
View String+Localization.swift
extension String {
/// Loads the localized version of the current string
@inline(__always)
func localized(comment: String = "") -> String {
return NSLocalizedString(self, comment: "")
}
/// Loads the localized version of the current string, interpolating the provided values into the string
func localized(comment: String = "", _ args: CVarArg...) -> String {
return withVaList(args) {
@foxfriends
foxfriends / Keypath.js
Last active Dec 4, 2018
Creates functions that extract a key of an object
View Keypath.js
const PATH = Symbol('PATH'), DEREF = Symbol('DEREF');
class Keypath extends Function {
constructor(...path) {
super();
this[PATH] = path;
}
[DEREF](object) {
for (const key of this) {
@foxfriends
foxfriends / Symbol+Generate.js
Created Dec 3, 2018
Helper method to just generate symbols indefinitely
View Symbol+Generate.js
/// Returns an iterator that generates symbols indefinitely. Names can be supplied. When names run out, then the
/// names are just the index
///
/// # Usage
/// ```js
/// const [a, b, c, d, e] = Symbol.generate('a', 'b', 'c');
/// ```
Symbol.generate = function*(...names) {
let i = 0;
for (;;)
View ViewControllerNavigation.swift
import UIKit
enum Storyboard: String {
case main = "Main"
}
protocol ViewControllerNavigation {
static var storyboard: Storyboard { get }
static var identifier: String { get }
}
@foxfriends
foxfriends / UIFont+Features.swift
Last active Aug 22, 2018
Helpers to use UIKit font features in Swift
View UIFont+Features.swift
import UIKit
// Usage:
//
// ```
// UIFont.systemFont(ofSize: 14).usingFeatures([.tabularFigures])
// ```
//
extension UIFont {
You can’t perform that action at this time.