This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// String+NumericValue.swift | |
// Created by Ignacio Nieto Carvajal (https://digitalleaves.com) | |
// | |
import Foundation | |
extension String { | |
func toFailableBool() -> Bool? { | |
switch self.lowercased() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func commonElementsInSequences <T, U> (_ a: T, _ b: U) -> [T.Iterator.Element] where T: Sequence, U: Sequence, T.Iterator.Element: Equatable, T.Iterator.Element == U.Iterator.Element { | |
var returnArray:[T.Iterator.Element] = [] | |
for aItem in a { | |
for bItem in b { | |
if aItem == bItem { | |
returnArray.append(aItem) | |
} | |
} | |
} | |
return returnArray |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public protocol GenericNumber : Comparable, ExpressibleByFloatLiteral, ExpressibleByIntegerLiteral, SignedNumber { | |
var value :Double { set get } | |
init(_ value: Double) | |
} | |
public func +<T: GenericNumber> (lhs: T, rhs: T) -> T { return T(lhs.value + rhs.value) } | |
public func -<T: GenericNumber> (lhs: T, rhs: T) -> T { return T(lhs.value - rhs.value) } | |
public func +<T: GenericNumber> (lhs: T, rhs: Double) -> T { return T(round(lhs.value + rhs)) } | |
public func -<T: GenericNumber> (lhs: T, rhs: Double) -> T { return T(lhs.value - rhs) } | |
extension GenericNumber { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
extension Date { | |
func quickRelativeTime() -> String { | |
let then = self.timeIntervalSince1970 | |
let now = Date().timeIntervalSince1970 | |
let seconds = now - then | |
if seconds < 0 { return "Sometime in the future..." } | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*********** database.js ******************/ | |
var mongoose = require('mongoose') | |
mongoose.Promise = global.Promise | |
mongoose.set('useFindAndModify', false) | |
// connection | |
exports.connection = null | |
// schemas and entities |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fontAwesomeIconClasses = { | |
// Media | |
"png": "fa-file-image-o", | |
"jpg": "fa-file-image-o", | |
"jpeg": "fa-file-image-o", | |
"gif": "fa-file-image-o", | |
"mp3": "fa-file-audio-o", | |
"mpg": "fa-file-video-o", | |
"mpeg": "fa-file-video-o", | |
"mp4": "fa-file-video-o", |