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 / unused-swift-code.rb
Created January 21, 2024 18:54
Detect unused swift code
#!/usr/bin/ruby
#encoding: utf-8
Encoding.default_external = Encoding::UTF_8
Encoding.default_internal = Encoding::UTF_8
class Item
def initialize(file, line, at)
@file = file
@line = line
@at = at + 1
1. Brew
2. NVM
3. RVM
4. Change screenshots location
5. VPNs
6. Add .ssh
@atereshkov
atereshkov / gist:41fcc17667f502a12ea7581f8a930459
Last active February 15, 2023 12:36
Pull request template
https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/creating-a-pull-request-template-for-your-repository
**Ticket:** [12345]({BASE_LINK}/12345)
### Description
[//]: # (Give a brief summary of why the change is being implemented.)
### Changes
[//]: # (List change details here for Code Reviewers)
@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`.
@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

import Foundation
import Combine
import XCTest
class Sut {
private var bag = Set<AnyCancellable>()
var triggerSubject = PassthroughSubject<Void, Never>()
@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:
*/
@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 / 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 / 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) {