Skip to content

Instantly share code, notes, and snippets.

View mishagray's full-sized avatar

Michael Gray mishagray

View GitHub Profile
3Box is a social profiles network for web3. This post links my 3Box profile to my Github account!
✅ did:muport:Qmao5rVkcrh3XjPDwKUi73wje6dBnPMZ8d87EWkF4Y28vy ✅
Create your profile today to start building social connection and trust online. https://3box.io/
@mishagray
mishagray / DefaultingJSONDecoder.swift
Created November 13, 2017 16:44
defines DefaultingJSONDecoder and CodingKeyWithDefaults
//
// DefaultingDecoder.swift
//
// Created by Michael Gray on 10/12/17.
//
import Foundation
// swiftlint:disable force_cast file_length
//
// RealmSwift+Codable.swift
//
// Created by Michael Gray on 8/16/17.
//
import Foundation
import RealmSwift
// swiftlint:disable line_length identifier_name
@mishagray
mishagray / DefferedFuture.swift
Created December 15, 2016 11:51
DefferedFuture.swift
import FutureKit
private var startPromiseHandler = ExtensionVarHandler()
public extension Future {
fileprivate var startPromise : Promise<Void>? {
set(p) {
startPromiseHandler.setValueOn(self, value: p)
}
get {
return startPromiseHandler.getValueFrom(self)
//
// RAC+Extensions.swift
// CoverPages
//
// Created by Morten Heiberg on 12/1/15.
// Copyright (c) 2015 Squarespace. All rights reserved.
//
import Foundation
import ReactiveCocoa
//
// FutureKit+RAC.swift
//
// Created by Michael Gray on 9/10/15.
//
import Foundation
import ReactiveCocoa
import FutureKit
@mishagray
mishagray / FutureKit+AlamoFire.swift
Created January 14, 2016 05:31
FutureKit+AlamoFire.swift
//
// FutureKit+AlamoFire.swift
//
// Created by Michael Gray on 9/21/15.
//
import Foundation
import Alamofire
import FutureKit
@mishagray
mishagray / NSErrorType.swift
Last active January 14, 2016 05:33
NSErrorType protocol
// ----------------------------------------------------------------------
// MARK: NSErrorType protocol, with JSON extensions for NSError
// ----------------------------------------------------------------------
/** so if you have a ErrorType var, and you want to test for NSError ex (e is NSError), it always succeeds.
it can sometimes be hard to test for NSError.
but you can test for protocol conformance.
so now:
e as? NSErrorType
@mishagray
mishagray / gist:cbd04da133ff1240434a
Created June 14, 2015 23:56
bash_profile for git
# Git branch in prompt.
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
export PS1="\u@\h \W\[\033[32m\]\$(parse_git_branch)\[\033[00m\] $ "
@mishagray
mishagray / gist:b2173aa9889ada11a4da
Created May 28, 2015 17:20
googles deep link logic in javascript form
<!DOCTYPE html>
<html>
<body>
<script type='text/javascript'>
var _oai = function(a, c, d, e, g) {
if (a)
if (c) {
var h = Date.now(),
k = window.history.length,