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
protocol Semigroup { | |
/* A semigroup is a set and a binary operator defined for elements within that | |
set, to yeild a another element of the same type. | |
*/ | |
static func combine (_ lhs: Self, _ rhs: Self) -> Self | |
} | |
extension Semigroup { | |
// Extending a protocol enables to get free functions based on the implementation of the protocol | |
func mappend(_ with: Self) -> Self { |
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
class BezierView: UIView { | |
private var bezier: UIBezierPath | |
init(bezier: UIBezierPath) { | |
self.bezier = bezier | |
let transform = CGAffineTransform() | |
transform.scaledBy(x: 2, y: 2) | |
let rectBounds = bezier.bounds | |
rectBounds.applying(transform) |
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
/* -------------- Higher order function combinators ---------------- */ | |
// Composition operators | |
infix operator >>> | |
func >>> <A,B,C> (aToB: @escaping (A) -> B, bToC: @escaping (B) -> C) -> (A) -> C { | |
return { a in aToB(a) |> bToC } | |
} | |
infix operator <<< | |
func <<< <A,B,C> (bToC: @escaping (B) -> C, aToB: @escaping (A) -> B) -> (A) -> C { |
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
// | |
// ProgressView.swift | |
// ProgressView | |
// | |
// Created by Daniel Cardona on 4/26/18. | |
// Copyright © 2018 Daniel Cardona. All rights reserved. | |
// | |
import UIKit |
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
# Decode the payload | |
echo $token | cut -d '.' -f2 | base64 -D | |
# Decode the header | |
echo $token | cut -d '.' -f1 | base64 -D |
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
class MyCustomElement extends HTMLElement { | |
constructor(){ | |
super(); | |
} | |
static get observedAttributes() { | |
return []; | |
} | |
// Life Cycle |
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
module Data.Coordinates exposing (..) | |
import Json.Decode as Decode exposing (Decoder, float, Value) | |
import Json.Encode as Encode | |
import Json.Decode.Pipeline as Pipeline exposing (required) | |
import Geolocation | |
type alias Coordinates = | |
{ latitude : Float | |
, longitude : Float |
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
module Main exposing (main) | |
import Html exposing (Html) | |
numberRows = 5 | |
generate : (a -> a) -> a -> Int -> List a | |
generate f seed n = | |
if n <= 0 then | |
[f seed] |
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
extension NSMutableAttributedString { | |
func replacingOccurrences(of item: String, with replacement: NSAttributedString) { | |
guard let range: Range<String.Index> = self.string.range(of: item) else { | |
return | |
} | |
let nsrange = NSRange(range, in: self.string) | |
self.replaceCharacters(in: nsrange, with: replacement) | |
} | |
} |
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
// | |
// ProfileInputField.swift | |
// CustomViews | |
// | |
// Created by Daniel Esteban Cardona Rojas on 9/14/18. | |
// Copyright © 2018 Daniel Esteban Cardona Rojas. All rights reserved. | |
// | |
import UIKit |
OlderNewer