Skip to content

Instantly share code, notes, and snippets.

View mishagray's full-sized avatar

Michael Gray mishagray

View GitHub Profile
@mishagray
mishagray / md5_comparison
Created January 11, 2015 23:13
Comparing the speed difference between NSMutableData and <CUnsignedChar>.alloc
/* OS X Swift "Command Line Tool" */
import Foundation
extension NSData {
func jstnMD5() -> String {
let result = NSMutableData(length: Int(CC_MD5_DIGEST_LENGTH))!
let resultBytes = UnsafeMutablePointer<CUnsignedChar>(result.mutableBytes)
@mishagray
mishagray / Example
Last active August 29, 2015 14:19
Check Swift Pods Manifest.Lock script
diff "DummyProjectForSwiftPods/Podfile.lock" "DummyProjectForSwiftPods/Pods/Manifest.lock" > /dev/null
if [[ $? != 0 ]] ; then
cat << EOM
error: The sandbox is not in sync with the DummyProjectForSwiftPods Podfile.lock. Run 'pod install' from the DummyProjectForSwiftPods directory or update your CocoaPods installation.
EOM
exit 1
fi
@mishagray
mishagray / Podfile
Last active August 29, 2015 14:19
Sample Frameworks Podfile
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.3'
use_frameworks!
pod 'FutureKit'
pod 'AlamoFire'
@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,
@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 / 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 / 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
//
// FutureKit+RAC.swift
//
// Created by Michael Gray on 9/10/15.
//
import Foundation
import ReactiveCocoa
import FutureKit
//
// RAC+Extensions.swift
// CoverPages
//
// Created by Morten Heiberg on 12/1/15.
// Copyright (c) 2015 Squarespace. All rights reserved.
//
import Foundation
import ReactiveCocoa
@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)