Skip to content

Instantly share code, notes, and snippets.

View ordazgustavo's full-sized avatar
🚀

Gustavo Ordaz ordazgustavo

🚀
View GitHub Profile
@ordazgustavo
ordazgustavo / BinarySearch.swift
Created December 20, 2019 04:05
An example of binary search written in Swift
let nums = [1, 2, 5, 13, 25, 50, 75, 100]
let names = ["Angel", "Bianca", "Carlos", "Gustavo", "Maria", "Samuel", "Victor"]
struct Date {
let year: Int
let month: Int
let day: Int
}
// MARK: - Implementation Example
struct LightMachine: StateMachine {
typealias States = LightStates
typealias Events = LightEvents
typealias Context = (Int)
enum LightStates {
case green
case yellow
/**
* Parses json keys to camel or snake case
* Use lodash to convert strings to camelCase or snake-case
*
* @param {Object} json
* @param {Boolean} camel
*/
function parseJsonKeys(json = {}, camel = true) {
if (typeof json === 'object') {
const arr = Object.entries(json)