Skip to content

Instantly share code, notes, and snippets.

View richimf's full-sized avatar
:octocat:
Coding...

Ricardo Montesinos richimf

:octocat:
Coding...
View GitHub Profile
@richimf
richimf / file.json
Last active December 11, 2019 18:38
{
"firstName": "Name",
"lastName": "LastName",
"age": 10,
"address":
{
"streetAddress": "Reforma",
"city": "Mexico",
"state": "CDMX",
"postalCode": "00600"
@richimf
richimf / users.json
Last active December 11, 2019 18:17
users json
{
"data" : "some data"
}
@richimf
richimf / clearDerivedData.sh
Created October 9, 2019 03:22
Clear Derived Data
#!/bin/bash
# cd /usr/local/bin
echo "Clearing Derived Data"
rm -rf /Users/<MyUserName>/Library/Developer/Xcode/DerivedData
echo "Done"
import UIKit
class ImageDownloader {
// DOWNLOAD IMAGE METHOD
func loadImage(of from: URL, completion: @escaping () -> Void ) -> UIImage {
let size = CGSize(width: 100, height: 140)
// Download and Compress image to fit container size
DispatchQueue.global(qos: .background).async {
guard let newimage = self.downloadAndCompress(url: url, newSize: size) else { return }
@richimf
richimf / buttonAnimationExtension.swift
Created October 5, 2019 03:52 — forked from SAllen0400/buttonAnimationExtension.swift
Core Animation on UIButton Example
// Swift 3
extension UIButton {
func pulsate() {
let pulse = CASpringAnimation(keyPath: "transform.scale")
pulse.duration = 0.6
pulse.fromValue = 0.95
pulse.toValue = 1.0
@richimf
richimf / GCD.swift
Last active August 20, 2019 18:48
Grand Central Dispatch (GCD) and NSOperationQueue frameworks.
//
/*
In iOS, Apple provides two ways to do multitasking:
The Grand Central Dispatch (GCD) and NSOperationQueue frameworks.
Both of them work perfectly when it’s time to assign tasks to different threads, or different queues other than the main one.
Which one should be use is a subjective matter, but in this tutorial we’ll focus on the first one, the GCD.
*No matter what,there’s one rule that should be always respected:
The main thread must be always remain free so it serves the user interface and user interactions.
@richimf
richimf / GitHelp.md
Last active March 3, 2020 20:28
Comandos de Git

Git

Ver diferencias de cambios

Una vez modificado un archivo, podemos ver los cambios con:

git diff

Deshacer cambios

@richimf
richimf / strategyPattern.swift
Created April 25, 2019 22:12
Strategy Pattern in Swift
import UIKit
/*
What:
A protocol that defines the action we want to encapsulate.
Who:
An object who contains an object who conforms the strategy.
How:
@richimf
richimf / protocolGenerics.swift
Last active September 29, 2019 21:26
Protocol with Generics
import UIKit
// Creamos un Protocolo
protocol Beverage {
func brewed() -> Self
}
//Creamos una funcion Generic donde el tipo T conforma al Protocolo
func serve<T>(_ drink: T) -> T where T: Beverage {
print("Se ejecuto metodo del generic \(drink.self)")
@richimf
richimf / Observer.swift
Created March 13, 2019 03:34
Observer Pattern
protocol Observer {
func update()
}
class ConcreteObserver: Observer {
var id: String
init(id: String) {
self.id = id
}
func update() {