Skip to content

Instantly share code, notes, and snippets.

@nkukushkin
nkukushkin / dock.sh
Created January 15, 2024 09:49 — forked from kamui545/dock.sh
Customize macOS dock via command line
#!/usr/bin/env bash
source "./dock_functions.sh"
declare -a apps=(
'/System/Applications/Utilities/Terminal.app'
'/System/Applications/Music.app'
'/Applications/Google Chrome.app'
'/Applications/PhpStorm.app'
'/Applications/Visual Studio Code.app'
@nkukushkin
nkukushkin / README-WWDC.md
Last active April 3, 2023 01:00 — forked from IsaacXen/README.md
(Almost) Every WWDC videos download links for aria2c.
@nkukushkin
nkukushkin / BarebonesObservable.swift
Created March 1, 2019 12:04
Barebones Observable
import Foundation
class ObservationToken: NSObject {}
class Observable<ValueType> {
private(set) var value: ValueType
func update(_ newValue: ValueType) {
let oldValue = value
value = newValue
@nkukushkin
nkukushkin / UIFont+MonospacedDigits.swift
Last active July 7, 2021 11:00
Extension to generate fonts with monospaced numbers feature enabled
import UIKit
extension UIFont {
var withMonospacedDigits: UIFont {
let featureSettings = [
UIFontDescriptor.FeatureKey.featureIdentifier: kNumberSpacingType,
UIFontDescriptor.FeatureKey.typeIdentifier: kMonospacedNumbersSelector
]
let descriptorAttributes = [
UIFontDescriptor.AttributeName.featureSettings: featureSettings
@nkukushkin
nkukushkin / UIView+FindSuperview.swift
Last active July 14, 2022 22:12
Recursive search for the first superview matching certain criteria.
extension UIView {
func firstSuperview<T>(where predicate: (T) -> Bool) -> T? where T: UIView {
if let superview = superview as? T, predicate(superview) {
return superview
}
return superview?.firstSuperview(where: predicate)
}
}
import UIKit
class ViewController: UIViewController {
func doSomething() {}
func howDoesThisWork() {
// Nested function that references `self` implicitly.
func performDoSomething() {