Skip to content

Instantly share code, notes, and snippets.

View desmondmc's full-sized avatar
🐢

Desmond McNamee desmondmc

🐢
View GitHub Profile
@desmondmc
desmondmc / build.gradle
Last active September 11, 2019 07:27
Hemes enabled build.gradle
apply plugin: "com.android.application"
import com.android.build.OutputFile
project.ext.react = [
entryFile: "index.js",
enableHermes: true // clean and rebuild if changing
]
def jscFlavor = 'org.webkit:android-jsc:+'
@desmondmc
desmondmc / feedfm_example.swift
Created June 22, 2018 10:56
requestStations fails if initialize was called without a connection
func initialize(_ token: String, secret: String) {
FMAudioPlayer.setClientToken(token, secret: secret)
}
func requestStations(stationsCallback: (Stations) -> ()) {
FMAudioPlayer.shared().whenAvailable({
guard let stations = FMAudioPlayer.shared().getAllStations(options: [:]) else {
// throw error
return
}
@desmondmc
desmondmc / name.json
Created July 11, 2017 15:40
Name JSON
{"name":"Desmond"}
@desmondmc
desmondmc / .git-completion.bash
Created July 4, 2017 14:01
Git Autocompletion
# bash/zsh completion support for core Git.
#
# Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org>
# Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/).
# Distributed under the GNU General Public License, version 2.0.
#
# The contained completion routines provide support for completing:
#
# *) local and remote branch names
# *) local and remote tag names
@desmondmc
desmondmc / Keychain.swift
Created March 28, 2017 08:47
Simple String Key Value Access to iOS Keychain
import Foundation
import Security
private let SecClass: String = kSecClass as String
private let SecAttrService: String = kSecAttrService as String
private let SecAttrAccessible: String = kSecAttrAccessible as String
private let SecAttrGeneric: String = kSecAttrGeneric as String
private let SecAttrAccount: String = kSecAttrAccount as String
private let SecMatchLimit: String = kSecMatchLimit as String
private let SecReturnData: String = kSecReturnData as String
@desmondmc
desmondmc / ResultType.swift
Created March 22, 2017 14:25
Result Type Goodies
import RxSwift
import RxCocoa
enum Result<T>: ResultType {
case success(T)
case failure(Error)
var data: T? {
switch self {
case .success(let d):
@desmondmc
desmondmc / LinkedList.swift
Created March 21, 2017 13:07
Linked List Implementation
indirect enum LinkedListNode<T> {
case value(element: T, next: LinkedListNode<T>)
case end
}
extension LinkedListNode: Sequence {
func makeIterator() -> LinkedListIterator<T> {
return LinkedListIterator(current: self)
}
}
@desmondmc
desmondmc / Sequence+Desmond.swift
Last active March 21, 2017 13:10
Sequence Extensions
public extension Sequence {
func scan<T>(_ seed: T, function:(T, Iterator.Element) -> T) -> T {
var current: T = seed
for element in self {
current = function(current, element)
}
return current
}
@desmondmc
desmondmc / git_aliases
Created March 16, 2017 13:58
Git Aliases
[alias]
co = checkout
br = branch
st = status
visual = log --graph --full-history --all --pretty=format:%h%x09%d%x20%s
branch-name = !git rev-parse --abbrev-ref HEAD
publish = !git push -u origin $(git branch-name)
@desmondmc
desmondmc / NoDepsRouter.swift
Created March 15, 2017 11:14
No Dependencies Swift Router
import Foundation
public protocol RequestConvertible {
var asRequest: NSMutableURLRequest { get }
}
enum NoDepsRouter: RequestConvertible {
case thing(id: String)
case postThings(id: String)