Skip to content

Instantly share code, notes, and snippets.

View artyom-ivanov's full-sized avatar
🤘
Code, UX, rocknroll

Artyom Ivanov artyom-ivanov

🤘
Code, UX, rocknroll
View GitHub Profile
View TCA_README_RU.md

The Composable Architecture

CI Slack

Composable Architecture (сокращенно TCA) - это библиотека для создания приложений в последовательном и понятном виде, с учетом композиции, тестирования и эргономики. Ее можно использовать

@artyom-ivanov
artyom-ivanov / youtubeParser.swift
Last active June 1, 2022 10:20
Parse video ids from youtube without API on Swift
View youtubeParser.swift
func getVideosFor(query: String) -> Set<String> {
let safeQuery = query.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)!
let myURLString = "https://www.youtube.com/results?search_query=\(safeQuery)"
guard let myURL = URL(string: myURLString) else {
print("Error: \(myURLString) doesn't seem to be a valid URL")
return Set()
}
do {
@artyom-ivanov
artyom-ivanov / appearance.ts
Created February 1, 2022 19:46
Detect text color for good contrast with background
View appearance.ts
export function textColorForBackground(hexColor: string): 'white' | 'black' {
let hex = hexColor.replace('#', '');
let r = parseInt(hex.substr(0, 2), 16);
let g = parseInt(hex.substr(2, 2), 16);
let b = parseInt(hex.substr(4, 2), 16);
let brightness = (r * 299 + g * 587 + b * 114) / 1000;
return brightness > 155 ? 'black' : 'white';
}