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 Array { | |
func flattened<T>() -> [T] where Element == [T] { | |
return self.flatMap({ $0 }) | |
} | |
func all(_ pred: (Element) -> Bool) -> Bool { | |
return self.reduce(true, { acc, v in acc && pred(v) }) | |
} | |
func any(_ pred: (Element) -> Bool) -> Bool { |
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 |
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 UIStackView { | |
func insertSeparator(_ createSeparator: (() -> UIView)) { | |
let subviews = self.arrangedSubviews | |
for v in subviews { | |
self.removeArrangedSubview(v) | |
} | |
for v in subviews { | |
self.addArrangedSubview(v) |
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 Array { | |
func interspersing(_ element: Element) -> Array { | |
var newArray: [Element] = [] | |
for (index, item) in self.enumerated() { | |
newArray.append(item) | |
if index < self.count - 1 { | |
newArray.append(element) | |
} | |
} | |
return newArray |
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
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
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
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
# 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
// | |
// ProgressView.swift | |
// ProgressView | |
// | |
// Created by Daniel Cardona on 4/26/18. | |
// Copyright © 2018 Daniel Cardona. All rights reserved. | |
// | |
import UIKit |