Skip to content

Instantly share code, notes, and snippets.

View MaximBazarov's full-sized avatar
💤
ZEN

Maxim Bazarov MaximBazarov

💤
ZEN
View GitHub Profile
@dive
dive / xed_xcode_invocation_tool.md
Last active July 27, 2023 15:23
Xcode invocation tool - xed

Xcode invocation tool - xed

xed is a command-line tool that launches the Xcode application and opens the given documents (xcodeproj, xcworkspace, etc.), or opens a new document, optionally with the contents of standard input.

If you work from the command line, this tool is a better option than open (which can open Xcode projects as well). Why?

  • xed knows about the current selected Xcode version (open behaves unpredictably if you have multiple Xcode installed)
  • You can use it open all files from a specific commit (with a little help explained below). It is useful on code-reviews or when you want to explore significant changes in the repository
  • You can use it as a "quick open" helper. Helps with monorepo phenomena, when you have hundreds of projects in the repository (I will show you an example below)
extension UIHostingController {
convenience public init(rootView: Content, ignoreSafeArea: Bool) {
self.init(rootView: rootView)
if ignoreSafeArea {
disableSafeArea()
}
}
func disableSafeArea() {
@oleksii-demedetskyi
oleksii-demedetskyi / ReduceComponents.swift
Last active August 9, 2019 10:38
Combine reducers together with state that they are represent into single structure.
//
// main.swift
// ReducerComponents
//
// Created by Alexey Demedetskii on 6/19/19.
// Copyright © 2019 Sigma software. All rights reserved.
//
import Foundation
@oleksii-demedetskyi
oleksii-demedetskyi / Draft.swift
Created June 15, 2019 19:47
Allows updates even to let constants and tracking of updates
import Cocoa
protocol Primitive {}
extension Int: Primitive {}
@dynamicMemberLookup
struct Draft<Value> {
let value: Value
var updates: [PartialKeyPath<Value>: Any] = [:]
protocol _Reducer {
associatedtype State
associatedtype Action
func reduce(state: inout State, action: Action)
}
protocol Reducer: _Reducer where State == Body.State, Action == Body.Action {
associatedtype Body: Reducer
@oleksii-demedetskyi
oleksii-demedetskyi / ReducerBuidler.swift
Created June 12, 2019 12:48
Redux reducer composed using new @functionBuilder api
protocol Action {}
struct Reducer<State> {
let reduce: (State, Action) -> State
}
struct Increment: Action {}
struct Decrement: Action {}
func on<State, A>(_ actionType: A.Type, reduce: @escaping (State, A) -> State) -> Reducer<State> {
final class Loader: BindableObject {
let didChange = PassthroughSubject<Data?, Never>()
var task: URLSessionDataTask!
var data: Data? = nil {
didSet {
didChange.send(data)
}
}
init(_ url: URL) {
@MaximBazarov
MaximBazarov / WhatToRethinkAndRefactor.sh
Created May 9, 2019 07:06
Show most changing files in the repository
git log --pretty=format: --name-only | sort | uniq -c | sort -rg | head -30
@lattner
lattner / async_swift_proposal.md
Last active April 21, 2024 09:43 — forked from oleganza/async_swift_proposal.md
Concrete proposal for async semantics in Swift

Async/Await for Swift

Introduction

Modern Cocoa development involves a lot of asynchronous programming using closures and completion handlers, but these APIs are hard to use. This gets particularly problematic when many asynchronous operations are used, error handling is required, or control flow between asynchronous calls gets complicated. This proposal describes a language extension to make this a lot more natural and less error prone.

This paper introduces a first class Coroutine model to Swift. Functions can opt into to being async, allowing the programmer to compose complex logic involving asynchronous operations, leaving the compiler in charge of producing the necessary closures and state machines to implement that logic.

@Jonalogy
Jonalogy / handling_multiple_github_accounts.md
Last active July 19, 2024 04:15
Handling Multiple Github Accounts on MacOS

Handling Multiple Github Accounts on MacOS

The only way I've succeeded so far is to employ SSH.

Assuming you are new to this like me, first I'd like to share with you that your Mac has a SSH config file in a .ssh directory. The config file is where you draw relations of your SSH keys to each GitHub (or Bitbucket) account, and all your SSH keys generated are saved into .ssh directory by default. You can navigate to it by running cd ~/.ssh within your terminal, open the config file with any editor, and it should look something like this:

Host *
 AddKeysToAgent yes

> UseKeyChain yes