Skip to content

Instantly share code, notes, and snippets.

View x0000ff's full-sized avatar

Konstantin Portnov x0000ff

View GitHub Profile
@x0000ff
x0000ff / ContentView.swift
Last active April 29, 2024 17:07
Custom @Environment Objects (aka Apple DI Container)
import SwiftUI
struct Post: Decodable, Identifiable {
let id: Int
let title: String
}
protocol HttpClientProtocol {
func fetchPosts() async throws -> [Post]
}
@x0000ff
x0000ff / Git aliases.md
Last active April 22, 2024 08:41
Git aliases

What is Git alias

Git aliases is a useful way to save your keyboard from typing a lot.

git status My alias for finishing code review
git status finish-code-review

Let's create one

You can create an alias type in yor terminal:

@x0000ff
x0000ff / _README.md
Last active June 1, 2023 15:54
clear-branches

Run shell script on gist

Shells that support process substitution such as bash and zsh allow to run shell script on gist as follows.

# With curl:
bash <(curl -sL ${GIST_URL}) args...

# With wget:
@x0000ff
x0000ff / _usage.md
Last active July 10, 2023 14:10
Clean local and remote obsolete tags tags

Just run

/usr/bin/swift <(curl -sL https://gist.githubusercontent.com/x0000ff/d0023bce5b85dd2f034330fb7a3c78f8/raw/7f465670da920ef4f6f6c9dc09920ca2c7dcf84d/clean-tags.sh)
@x0000ff
x0000ff / README.md
Last active December 20, 2021 16:14
Prevent push to protected branches hook

Examples

Rejected
rejected
Approved
approved
@x0000ff
x0000ff / scrabble-tdd.md
Last active March 23, 2020 20:06
Scrabble TDD

(c) Exercism

TDD

Given a word, compute the scrabble score for that word.

Letter Values

Configure Tests for Kotlin Project

Create project

  1. In IntelliJ Idea: File => New => Project

  2. Select type Gradle and in Additional LIbriries and Framworks select only Kotlin/JVM

    created

Add JUnit and Kotlin JUnit

@x0000ff
x0000ff / package.json
Created January 11, 2020 22:26
Start `React` app without opening url in browser
// React v.16.12.0
"scripts": {
"start": "export BROWSER=none; react-scripts start"
}
@x0000ff
x0000ff / Disable App Transport Security for localhost.md
Last active December 23, 2018 02:05
App Transport Security :: Disable for localhost

If you see this error "The resource could not be loaded because the App Transport Security policy requires the use of a secure connection." in Xcode console:

load failed with error Error Domain=NSURLErrorDomain Code=-1022 "The resource could not be loaded because the App Transport Security policy requires the use of a secure connection." UserInfo={NSLocalizedDescription=The resource could not be loaded because the App Transport Security policy requires the use of a secure connection., NSErrorFailingURLStringKey=http://localhost/BLAH-BLAH-BLAH, NSErrorFailingURLKey=http://localhost:3000/brands, _NSURLErrorRelatedURLSessionTaskErrorKey=(
    "LocalDataTask <F7630F1E-0BA5-4EBC-9CDA-351A5842F84D>.<1>"
), _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <F7630F1E-0BA5-4EBC-9CDA-351A5842F84D>.<1>, NSUnderlyingError=0x6000001a9860 {Error Domain=kCFErrorDomainCFNetwork Code=-1022 "(null)"}} [-1022]
Error: The resource could not be loaded because the App Transport Security policy requires the use of a