Skip to content

Instantly share code, notes, and snippets.

View denisoliveira's full-sized avatar

Denis Oliveira denisoliveira

View GitHub Profile
@denisoliveira
denisoliveira / ViewController.swift
Created April 20, 2017 02:11
Animated item on screen
//
// ViewController.swift
// IntroAnimation
//
// Created by Denis Oliveira on 4/19/17.
// Copyright © 2017 Denis Oliveira. All rights reserved.
//
import UIKit
extension UILabel {
func letterSpacing(spacing: CGFloat) {
guard let text = self.text else {
return
}
var attributedText: NSMutableAttributedString?
if self.attributedText == nil {
attributedText = NSMutableAttributedString(string: text)
}
@denisoliveira
denisoliveira / GradientHelper.swift
Created June 27, 2017 14:45
Gradient Directions
class GradientHelper {
/// Set gradient background on view use this method on *draw(_ rect:* **CGRect...***)*
///
/// - Parameter colours: A grandient colors args
func setGradientBackground(angle: CGFloat = 0, colours: CGColor...) {
let colours = colours as CFArray
let context = UIGraphicsGetCurrentContext()
let gradient = CGGradient(colorsSpace: CGColorSpaceCreateDeviceRGB(), colors: colours, locations: nil)!
// Make the right degree
@denisoliveira
denisoliveira / Optional+Ext.swift
Last active November 13, 2019 20:54
Add support on Swift Optional Type to perform a flatMap with a statically referenced instance method rather than returns a instance method references.
extension Optional {
func map(_ clojure: (Wrapped) -> () -> Wrapped) -> Wrapped? {
guard let self = self else { return nil }
return clojure(self)()
}
func map<T>(_ keyPath: KeyPath<Wrapped, T>) -> T? {
guard let self = self else { return nil }
return self[keyPath: keyPath]

Keybase proof

I hereby claim:

  • I am denisoliveira on github.
  • I am denisoliveira (https://keybase.io/denisoliveira) on keybase.
  • I have a public key ASBiPhpaUXFh3daVSkOxLUROFgQZ8_8hQBnZ0gRu7HO8Bwo

To claim this, I am signing this object:

@denisoliveira
denisoliveira / device.swift
Created January 23, 2020 17:33
Device Token to HEX
print("Device Token \(deviceToken.reduce("", {$0 + String(format: "%02x", $1)}))")
import Foundation
struct AnyKey: CodingKey {
var stringValue: String
var intValue: Int?
init?(stringValue: String) {
self.stringValue = stringValue
self.intValue = nil
}
// By Gui Rambo
// https://rambo.codes/ios/quick-tip/2019/12/09/clearing-your-apps-launch-screen-cache-on-ios.html
// Note: Tested on iOS 13 only
import UIKit
public extension UIApplication {
func clearLaunchScreenCache() {
do {
#As was mentioned, you can use xcrun to do a few things:
#to list all simulators
xcrun simctl list devices
# or
xcrun simctl list --json
# to delete specific device
xcrun simctl delete # <device udid>
// UIApplication+SplashOptions.h
#import <UIKit/UIKit.h>
@interface UIApplication (SplashOptions)
- (void)clearLaunchScreenCache;
@end