Skip to content

Instantly share code, notes, and snippets.

View atereshkov's full-sized avatar

Aliaksandr Tserashkou atereshkov

  • Vention
  • Warsaw, Poland
View GitHub Profile
@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:
@atereshkov
atereshkov / podspec-example
Last active April 29, 2023 16:11
Xcode 10 Fat framework - How to create universal binary iOS framework (+ Cocoapods podspec)
If you've got something like this:
file was built for arm64 which is not the architecture being linked (x86_64):
Than this gist is for you.
Let's say you have already developed the framework itself and just want to build the binary
and distribute it through the Cocoapods.
1. Make sure your framework "Deployment Target" is equal to all the dependencies from your podspec file.
@atereshkov
atereshkov / itc_team_id.txt
Created April 16, 2019 14:19
How to get iTunes Connect (App Store Connect) Team ID and Team name? (fastlane)
Basically just type the following in a shell:
$ irb
irb> require "spaceship"
irb> Spaceship::Tunes.login("iTunesConnect_username", "iTunesConnect_password")
irb> Spaceship::Tunes.select_team
You'll be presented with a list of teams your account belongs to, along with the numerical representation for that team.
@atereshkov
atereshkov / gist:01b35e60b5f1c381b3050e78d2ab5541
Created July 10, 2019 13:25
VideoCompression AVFoundation
import Foundation
import AVFoundation
protocol VideoCompressorProtocol {
func compress(fileURL: URL, outputURL: URL, completion: @escaping (URL?, Error?) -> Void)
}
class VideoCompressor: VideoCompressorProtocol {
func compress(fileURL: URL, outputURL: URL, completion: @escaping (URL?, Error?) -> Void) {
@atereshkov
atereshkov / swift-5-resumable-timer.swift
Created August 19, 2019 14:39
Swift 5 Resumable Timer
class ResumableTimer: NSObject {
private var timer: Timer? = Timer()
private var callback: () -> Void
private var startTime: TimeInterval?
private var elapsedTime: TimeInterval?
// MARK: Init
@atereshkov
atereshkov / xcode-duplicate-line.md
Last active September 5, 2022 07:49
Xcode 13 duplicate line shortcut (hotkey)

Xcode 13 duplicate line shortcut

  1. Run
sudo chmod 666 /Applications/Xcode.app/Contents/Frameworks/IDEKit.framework/Versions/A/Resources//IDETextKeyBindingSet.plist
sudo chmod 777 /Applications/Xcode.app/Contents/Frameworks/IDEKit.framework/Versions/A/Resources/
@atereshkov
atereshkov / closures-escaping-nonescaping.swift
Last active June 11, 2020 18:48
Escaping closures Swift (nonescaping & escaping difference in Swift)
/*
A closure is said to escape a function when the closure is passed as an argument to the function,
but is called after the function returns. When you declare a function that takes a closure as one of its parameters,
you can write @escaping before the parameter’s type to indicate that the closure is allowed to escape.
One way that a closure can escape is by being stored in a variable that is defined outside the function.
As an example, many functions that start an asynchronous operation take a closure argument as a completion handler.
The function returns after it starts the operation, but the closure isn’t called until the operation is completed — the closure
needs to escape, to be called later. For example:
*/
import Foundation
import Combine
import XCTest
class Sut {
private var bag = Set<AnyCancellable>()
var triggerSubject = PassthroughSubject<Void, Never>()
@atereshkov
atereshkov / change_screenshots_location_mac.md
Last active March 17, 2022 09:56
Change screenshots location on Mac

How to change where screenshots are saved on Mac

  1. Press Command-Shift-5 to open the Screenshot app.
  2. Select Options.
  3. From the Save to section, select your preferred location.
  4. If you select Other Location, you can choose a different folder of choice or create a new folder.

Command line:

defaults write com.apple.screencapture location /Users/alex/Screenshots

@atereshkov
atereshkov / gist:0573e710a38b8b91d2656d66e87e7915
Last active November 26, 2022 14:47
Installing Node.js and npm on MacOS
https://docs.npmjs.com/downloading-and-installing-node-js-and-npm
Run nvm installation script.
https://github.com/nvm-sh/nvm#install--update-script
If you get nvm: `command not found` after running the install script, troubleshoot it.
https://github.com/nvm-sh/nvm#troubleshooting-on-macos
This worked in my case on zsh:
You might need to restart your terminal instance or run `. ~/.nvm/nvm.sh`.