Skip to content

Instantly share code, notes, and snippets.

View unnamedd's full-sized avatar
🇺🇦
#StandWithUkraine

Thiago Holanda unnamedd

🇺🇦
#StandWithUkraine
View GitHub Profile
protocol KeyPathUpdatable {}
extension KeyPathUpdatable {
func updating<LeafType>(_ keyPath: WritableKeyPath<Self, LeafType>, to value: LeafType) -> Self {
var copy = self
copy[keyPath: keyPath] = value
return copy
}
}
@unnamedd
unnamedd / vim_cheatsheet.md
Created April 21, 2019 22:26 — forked from awidegreen/vim_cheatsheet.md
Vim shortcuts

Introduction

  • C-a == Ctrl-a
  • M-a == Alt-a

General

:q        close
:w        write/saves
:wa[!]    write/save all windows [force]
:wq       write/save and close
// The SwiftUI Lab
// Website: https://swiftui-lab.com
// Article: https://swiftui-lab.com/alignment-guides
import SwiftUI
class Model: ObservableObject {
@Published var minimumContainer = true
@Published var extendedTouchBar = false
@Published var twoPhases = true
@unnamedd
unnamedd / UIView+Tooltips.h
Created September 15, 2019 00:53 — forked from steventroughtonsmith/UIView+Tooltips.h
WIP tooltips for Mac Catalyst
//
// UIView+Tooltips.h
// Crossword
//
// Created by Steven Troughton-Smith on 13/09/2019.
// Copyright © 2019 Steven Troughton-Smith. All rights reserved.
//
#import <UIKit/UIKit.h>
@unnamedd
unnamedd / README.md
Created June 14, 2017 17:15 — forked from acrookston/README.md
Xcode pre-action to build custom Info.plist

Automatic build versions from git in Xcode (and other goodies)

Installation procedure for pre-build actions to automatically populate Xcode Info.plist with dynamic data.

1. Xcode Scheme pre-action

Edit Xcode Scheme and add a pre-action script. Copy the contents of preaction.sh into the pre-action script box.

@unnamedd
unnamedd / TextStyleButtons.swift
Last active July 1, 2019 22:34
[SwiftUI] Text style buttons
//
// ContentView.swift
// TestsWithSwiftUI
//
// Created by Thiago Holanda on 01.07.19.
// Copyright © 2019 unnamedd codes. All rights reserved.
//
import SwiftUI
@unnamedd
unnamedd / Enums+Extensions.swift
Last active March 29, 2019 23:51
How to use the right methods to right types
// Common - Portuguese - pt-BR.lproj/Localizable.strings
// "common.change" = "Mudar";
// "common.error" = "Erro";
// "common.delete" = "Exluir";
// "common.wait" = "Aguarde";
// Common - English - en.lproj/Localizable.strings
// "common.change" = "Change";
// "common.error" = "Error";
// "common.delete" = "Delete";
@unnamedd
unnamedd / mac-apps.md
Created December 4, 2018 10:05 — forked from erikreagan/mac-apps.md
Mac developer must-haves

Mac web developer apps

This gist's comment stream is a collection of webdev apps for OS X. Feel free to add links to apps you like, just make sure you add some context to what it does — either from the creator's website or your own thoughts.

— Erik

@unnamedd
unnamedd / Sequence+GroupByDate.swift
Created October 26, 2018 17:05 — forked from ElegyD/Sequence+GroupByDate.swift
Group a Swift Model by date with auto sorting and asc/desc support (Swift 3) E.g.: for a UITableView with sections
extension Sequence {
func groupSort(ascending: Bool = true, byDate dateKey: (Iterator.Element) -> Date) -> [[Iterator.Element]] {
var categories: [[Iterator.Element]] = []
for element in self {
let key = dateKey(element)
guard let dayIndex = categories.index(where: { $0.contains(where: { Calendar.current.isDate(dateKey($0), inSameDayAs: key) }) }) else {
guard let nextIndex = categories.index(where: { $0.contains(where: { dateKey($0).compare(key) == (ascending ? .orderedDescending : .orderedAscending) }) }) else {
categories.append([element])
continue
}
@unnamedd
unnamedd / NotificationTestCase.swift
Created October 25, 2018 21:34 — forked from fxm90/NotificationTestCase.swift
XCTest - Assert notification (not) triggered.
import XCTest
class NotificationTestCase: XCTestCase {
func testTriggerNotification() {
expectation(forNotification: .fooBar,
object: nil,
handler: nil)
let notificationCenter = NotificationCenter.default