Skip to content

Instantly share code, notes, and snippets.

View Toni77777's full-sized avatar

Anton Paliakov Toni77777

View GitHub Profile
@DougGregor
DougGregor / parallel_map.swift
Created December 24, 2020 01:10
Swift async/await implementation of a parallel map
extension Collection {
func parallelMap<T>(
parallelism requestedParallelism: Int? = nil,
_ transform: @escaping (Element) async throws -> T
) async throws -> [T] {
let defaultParallelism = 2
let parallelism = requestedParallelism ?? defaultParallelism
let n = self.count
if n == 0 {
@mecid
mecid / Calendar.swift
Last active July 10, 2024 09:17
SwiftUI Calendar view using LazyVGrid
import SwiftUI
extension Calendar {
func generateDates(
inside interval: DateInterval,
matching components: DateComponents
) -> [Date] {
var dates: [Date] = []
dates.append(interval.start)
@mattt
mattt / UIViewControllerPreview.swift
Last active January 8, 2024 23:09
Generic structures to host previews of UIView and UIViewController subclasses.
import UIKit
#if canImport(SwiftUI) && DEBUG
import SwiftUI
struct UIViewControllerPreview<ViewController: UIViewController>: UIViewControllerRepresentable {
let viewController: ViewController
init(_ builder: @escaping () -> ViewController) {
viewController = builder()
}
@stinger
stinger / CombineFetcher.swift
Last active January 28, 2023 18:07
Combine - fetching data using URLSession publishers
import Foundation
import Combine
enum APIError: Error, LocalizedError {
case unknown, apiError(reason: String)
var errorDescription: String? {
switch self {
case .unknown:
return "Unknown error"
@issuran
issuran / Record iOS emulator video
Last active March 21, 2021 11:39
How to capture iOS Simulator video
1- First of all, you have to run your app on the simulator.
2- Then, open the terminal
3- Now, you have to run the command you desire:
- Screenshot: xcrun simctl io booted screenshot
- Video: xcrun simctl io booted recordVideo <filename>.<file extension>.
For example: xcrun simctl io booted recordVideo appvideo.mov
4- Press cntrl + c to stop recording the video.
@Tulakshana
Tulakshana / MovieTransitionsVC.swift
Last active January 12, 2023 08:25 — forked from SheffieldKevin/movietransitions.swift
Make a movie with transitions with AVFoundation and swift. Add an UIActivityIndicatorView and an UIButton and connect appropriately. You will also need to attach few videos to the project.
//
// MovieTransitionsVC.swift
// VideoAnimations
//
// Created by Tula on 2018-06-14.
// Copyright © 2018 Tula. All rights reserved.
//
import UIKit
import AVFoundation
@atereshkov
atereshkov / macos-ssh-keychain.txt
Created September 16, 2017 10:52
How to add a SSH Key to your MacOS Keychain
On Mac OSX, the native SSH client can use the built-in keychain directly.
Open terminal.
Write:
mkdir ~/.ssh
cd ~/.ssh
Copy your private key "id_rsa" to /.ssh folder.
Write in terminal also:
@asukakenji
asukakenji / go-stdlib-interface-selected.md
Last active July 17, 2024 19:34
Go (Golang) Standard Library Interfaces (Selected)

Go (Golang) Standard Library Interfaces (Selected)

This is not an exhaustive list of all interfaces in Go's standard library. I only list those I think are important. Interfaces defined in frequently used packages (like io, fmt) are included. Interfaces that have significant importance are also included.

All of the following information is based on go version go1.8.3 darwin/amd64.

@christianascone
christianascone / UIView+Extension.swift
Last active October 7, 2021 08:54
UIView extension for setting an hexagonal mask on layer
import Foundation
// http://sapandiwakar.in/make-hexagonal-view-on-ios/
extension UIView {
/// Set the view layer as an hexagon
func setupHexagonView() {
let lineWidth: CGFloat = 5
let path = self.roundedPolygonPath(rect: self.bounds, lineWidth: lineWidth, sides: 6, cornerRadius: 10, rotationOffset: CGFloat(.pi / 2.0))
@pdyakov
pdyakov / etherium-quick-start.js
Last active March 29, 2018 08:00
Etherium Blockchain Platform Quick Start
// How to connect to Etherium Blockchain Platform
// Emitting events and listening for events within blockchain network
var Web3 = require('web3');
const HOST = '';
const ACCOUNT = '';
const ContractData = {...};
// Connection