Skip to content

Instantly share code, notes, and snippets.

View joaomvfsantos's full-sized avatar

João Santos joaomvfsantos

View GitHub Profile
@joaomvfsantos
joaomvfsantos / ChunkedArray.swift
Created May 30, 2023 13:41
Swift Array extension that chunks an array to sub arrays of a given size
View ChunkedArray.swift
//
// ChunkedArray.swift
//
// Created by João Santos on 25/05/2020.
// Copyright © 2020 João Santos. All rights reserved.
//
import Foundation
extension Array {
@joaomvfsantos
joaomvfsantos / RemoveDuplicates.swift
Created May 30, 2023 13:37
Swift Array extension that removes duplicate elements, provided the elements conform to the Equatable protocol
View RemoveDuplicates.swift
//
// RemoveDuplicates.swift
//
// Created by João Santos on 25/05/2020.
// Copyright © 2020 João Santos. All rights reserved.
//
import Foundation
extension Array where Element: Equatable {
@joaomvfsantos
joaomvfsantos / UIImageToGrayscale.swift
Created May 30, 2023 13:35
Swift UIImage Extension that generates a grayscale copy of the original image
View UIImageToGrayscale.swift
//
// UIImageToGrayscale.swift
//
// Created by João Santos on 27/11/2018.
// Copyright © 2018 João Santos. All rights reserved.
//
import UIKit
extension UIImage {
@joaomvfsantos
joaomvfsantos / UIColorFromHex.swift
Last active May 30, 2023 13:32
Swift UIColor extension that extends UIColor with a constructor that accepts hex color values (e.g. #FF0000)
View UIColorFromHex.swift
//
// UIColorFromHex.swift
//
// Created by João Santos on 14/05/2018.
// Copyright © 2018 João Santos. All rights reserved.
//
import UIKit
extension UIColor {
@joaomvfsantos
joaomvfsantos / ContrastRatioSwift.swift
Created May 29, 2023 17:21
Swift UIColor extension, that adds a contrast ratio function between two colors.
View ContrastRatioSwift.swift
//
// ContrastRatioSwift.swift
// Contrast Ratio Swift
//
// Created by João Santos on 25/05/2023.
// Copyright © 2023 João Santos. All rights reserved.
//
import UIKit
@joaomvfsantos
joaomvfsantos / SymmetricEncryption.php
Created May 11, 2017 18:22
Symmetric Encryption in PHP
View SymmetricEncryption.php
<?php
class SymmetricEncryption {
private $cipher;
public function __construct($cipher = 'aes-256-cbc') {
$this->cipher = $cipher;
}