Skip to content

Instantly share code, notes, and snippets.

View helbertgs's full-sized avatar
🏠
Working from home

Helbert Gomes helbertgs

🏠
Working from home
  • Waterloo, Ontario - CA
  • 23:24 (UTC -04:00)
  • X @helbertgs
View GitHub Profile
@helbertgs
helbertgs / UIImage+Crop.swift
Last active November 9, 2018 00:01
Crop a UIImage
extension UIImage {
func crop(rect: CGRect) -> UIImage? {
if let image = self.cgImage, let cropped: CGImage = image.cropping(to: rect) {
return UIImage(cgImage: cropped)
}
return nil
}
}
extension Decodable {
static func parse(json: String) -> Self? {
guard let url = Bundle.main.url(forResource: json, withExtension: "json"),
let data = try? Data(contentsOf: url),
let output = try? JSONDecoder().decode(self, from: data) else {
return nil
}
return output
}
@helbertgs
helbertgs / Brewfile
Last active February 4, 2021 16:39
tap 'homebrew/cask'
tap 'homebrew/cask-drivers'
tap 'homebrew/cask-fonts'
tap 'homebrew/cask-versions'
tap 'homebrew/core'
tap 'homebrew/boneyard'
tap 'homebrew/dev-tools'
tap 'homebrew/bundle'
tap 'homebrew/services'
@helbertgs
helbertgs / Fastfile
Created February 17, 2020 18:42 — forked from pogramos/Fastfile
Custom fastfile lanes
# Customize this file, documentation can be found here:
# https://docs.fastlane.tools/actions/
# All available actions: https://docs.fastlane.tools/actions
# can also be listed using the `fastlane actions` command
# Change the syntax highlighting to Ruby
# All lines starting with a # are ignored when running `fastlane`
# If you want to automatically update fastlane if a new version is available:
# update_fastlane
import UIKit
typealias Provider = NSObject & UIApplicationDelegate
class ComposedProvider: Provider {
// MARK: Property(ies).
private var providers: [Provider]
@helbertgs
helbertgs / ExtensionCompatibleSample.swift
Created June 9, 2020 14:30 — forked from WorldDownTown/ExtensionCompatibleSample.swift
An example of Extension based on RxSwift in Swift.
public struct Extension<Base> {
public let base: Base
public init(_ base: Base) {
self.base = base
}
}
public protocol ExtensionCompatible {
associatedtype Compatible
var ex: Extension<Compatible> { get set }
@helbertgs
helbertgs / TextStyle.plantuml
Last active August 11, 2020 14:29
TextStyle
@startuml
class EdgeStyle << (E, orange) >> {
none
raised
depressed
uniform
dropShadow
---
+ value: CFString
@startuml
class SubtitleStylePlugin {
+ name: String
---
init(context: UIObject)
---
+ bindEvents()
+ bindContainerEvents()
+ bindPlaybackEvents()
@helbertgs
helbertgs / ColorHex.swift
Last active August 21, 2020 19:50
Create struct by string literal
import UIKit
struct ColorHex: ExpressibleByStringLiteral {
// MARK: - Type Alias.
typealias StringLiteralType = String
// MARK: - Private Property(ies).
import Clappr
import UIKit
class UIPlaybackTypePlugin: UICorePlugin {
override class var name: String { "UIPlaybackTypePlugin" }
private var label: UILabel = {
let label = UILabel()
label.translatesAutoresizingMaskIntoConstraints = false