Skip to content

Instantly share code, notes, and snippets.

View phynet's full-sized avatar
🤘
I said yeah.

Sofia Swidarowicz phynet

🤘
I said yeah.
View GitHub Profile
@myell0w
myell0w / PlatformDependentValue.swift
Created May 4, 2020 14:00
Cross-Platform Helpers for iOS/macOS
/// Used to identify traits of the current UI Environment - especially useful for cross-platform code
public struct MNCUITraits: Withable {
/// Does *not* identify the device type, but the idiom of the layout to apply
/// This means that e.g. on iPad the layoutIdiom can be `.phone`, if run in Split Screen or SlideOver
public enum LayoutIdiom {
case phone(hasRoundCorners: Bool)
case pad(hasRoundCorners: Bool)
case mac
}
@DominikPetho
DominikPetho / .swift
Last active September 15, 2020 07:36
Sample of Swift property wrappers for unit testing
import UIKit
@propertyWrapper
struct Printer<T> {
public var currentValue: T?
var wrappedValue: T? {
get {
print("Property wrapper value printed", currentValue)
import Foundation
enum Either<A,B> {
case left(A)
case right(B)
}
// Works only using Swift 4.1
extension Either: Codable where A: Codable, B: Codable {
enum CodingKeys: CodingKey {
@mbuchetics
mbuchetics / json.swift
Created June 30, 2017 09:28 — forked from reckenrode/json.swift
Decoding arbitrary JSON with the new Decoder in Swift 4
enum JSON: Decodable {
case bool(Bool)
case double(Double)
case string(String)
indirect case array([JSON])
indirect case dictionary([String: JSON])
init(from decoder: Decoder) throws {
if let container = try? decoder.container(keyedBy: JSONCodingKeys.self) {
self = JSON(from: container)
@xaphod
xaphod / gist:7aab1302004f6e933593a11ad8f5a72d
Last active March 1, 2018 07:16
Scroll keyboard up just enough to show control. Swift 3.
// note that currentFirstResponder is obtained by this:
//
// static var currentFirstResponder: UIResponder?
// func findFirstResponder(sender: Any) {
// currentFirstResponder = self
// }
//
// class func currentFirstResponder() -> UIResponder? {
// currentFirstResponder = nil
// UIApplication.shared.sendAction(#selector(findFirstResponder), to: nil, from: nil, for: nil)
@mteera
mteera / Custom UITextField
Last active January 13, 2020 02:45
Custom UITextField using @IBDesignable with Swift 3
import UIKit
@IBDesignable class CustomUITextField: UITextField {
@IBInspectable var cornerRadius: CGFloat = 0 {
didSet {
layer.cornerRadius = cornerRadius
}
}
@phynet
phynet / delete-tag-remote-repo.md
Created August 2, 2016 08:42
Delete tag from remote repo
git tag -d release01

git push origin :refs/tags/release01

@nepsilon
nepsilon / git-change-commit-messages.md
Last active April 24, 2024 06:30
How to change your commit messages in Git? — First published in fullweb.io issue #55

How to change your commit messages in Git?

At some point you’ll find yourself in a situation where you need edit a commit message. That commit might already be pushed or not, be the most recent or burried below 10 other commits, but fear not, git has your back 🙂.

Not pushed + most recent commit:

git commit --amend

This will open your $EDITOR and let you change the message. Continue with your usual git push origin master.

@mlabraca
mlabraca / TableView.swift
Created December 4, 2015 17:12
TableView swift playground
import UIKit
import XCPlayground
//For more info, visit: http://blog.human-friendly.com/swift-2-xcode-7-gm-at-least-generic-support-for-at-objc-protocols
func reloadTableView(tableView: UITableView, dataSource: GenericTVCDatasource<String>, data: [String]) -> UITableView {
dataSource.reload(data)
tableView.reloadData()
return tableView
}