This file contains hidden or 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
| /* Using a JavaScript proxy for a super low code REST client */ | |
| // via https://dev.to/dipsaus9/javascript-lets-create-aproxy-19hg | |
| // also see https://towardsdatascience.com/why-to-use-javascript-proxy-5cdc69d943e3 | |
| // also see https://github.com/fastify/manifetch | |
| // also see https://github.com/flash-oss/allserver | |
| const createApi = (url) => { | |
| return new Proxy({}, { | |
| get(target, key) { | |
| return async function(id = "") { | |
| const response = await fetch(`${url}/${key}/${id}`) |
This file contains hidden or 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
| extension UIView { | |
| func addSubviews(views:UIView...){ | |
| for view in views { | |
| self.addSubview(view) | |
| } | |
| } | |
| } | |
| //Use | |
| myCurrentView.addSubviews(anotherView, aRandomView, yetAnotherView) |
This file contains hidden or 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
| //create a type for the functions we are creating | |
| typealias Math = Int -> Int | |
| func toThePowerOf(power:Int)->Math{ | |
| return { num in | |
| var cur = num; | |
| for _ in 1..<power { | |
| cur *= num | |
| } | |
| return cur |
This file contains hidden or 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
| /********************** | |
| * | |
| * run this in command line first | |
| * $ npm install figlet | |
| * | |
| **********************/ | |
| var figlet = require('figlet'); | |
| figlet.fonts(function(err, fonts) { |