Skip to content

Instantly share code, notes, and snippets.

View denisoliveira's full-sized avatar

Denis Oliveira denisoliveira

View GitHub Profile
@denisoliveira
denisoliveira / cmake.rb
Created July 6, 2023 14:24
Cmake 3.22.1
class Cmake < Formula
desc "Cross-platform make"
homepage "https://www.cmake.org/"
url "https://github.com/Kitware/CMake/releases/download/v3.22.1/cmake-3.22.1.tar.gz"
mirror "http://fresh-center.net/linux/misc/cmake-3.22.1.tar.gz"
mirror "http://fresh-center.net/linux/misc/legacy/cmake-3.22.1.tar.gz"
sha256 "0e998229549d7b3f368703d20e248e7ee1f853910d42704aa87918c213ea82c0"
license "BSD-3-Clause"
head "https://gitlab.kitware.com/cmake/cmake.git", branch: "master"
@denisoliveira
denisoliveira / SegueTypeSafe.swift
Created November 26, 2020 05:10
Segueable a type safe segue on Swift like Codable protocol
protocol SegueKey {
var identifier: String { get }
}
extension SegueKey where Self: RawRepresentable, Self.RawValue == String {
var identifier: String {
return rawValue
}
}
import UIKit
import CoreGraphics
public class DrawView: UIView {
@IBInspectable public var drawColor: UIColor = .black
@IBInspectable public var lineWidth: CGFloat = 3
private lazy var lastPoint: CGPoint = .zero
// UIApplication+SplashOptions.h
#import <UIKit/UIKit.h>
@interface UIApplication (SplashOptions)
- (void)clearLaunchScreenCache;
@end
#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>
// 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 {
import Foundation
struct AnyKey: CodingKey {
var stringValue: String
var intValue: Int?
init?(stringValue: String) {
self.stringValue = stringValue
self.intValue = nil
}
@denisoliveira
denisoliveira / device.swift
Created January 23, 2020 17:33
Device Token to HEX
print("Device Token \(deviceToken.reduce("", {$0 + String(format: "%02x", $1)}))")

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 / 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]