Skip to content

Instantly share code, notes, and snippets.

View joaomvfsantos's full-sized avatar

João Santos joaomvfsantos

View GitHub Profile
@joaomvfsantos
joaomvfsantos / update.sh
Created December 17, 2023 09:39
Linux update script
#!/bin/bash
sudo apt-get -y update
sudo apt-get -y upgrade
sudo apt-get -y dist-upgrade
sudo apt -y autoremove
@joaomvfsantos
joaomvfsantos / ChunkedArray.swift
Created May 30, 2023 13:41
Swift Array extension that chunks an array to sub arrays of a given size
//
// 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
//
// 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
//
// 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)
//
// 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.
//
// 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
<?php
class SymmetricEncryption {
private $cipher;
public function __construct($cipher = 'aes-256-cbc') {
$this->cipher = $cipher;
}