Skip to content

Instantly share code, notes, and snippets.

View ArtFeel's full-sized avatar
🍎
Make apps for Apple since iOS 3

Philip Vasilchenko ArtFeel

🍎
Make apps for Apple since iOS 3
View GitHub Profile
@Axik
Axik / lottery.py
Last active February 17, 2023 07:08
Код для визначення переможця в зборі ps4
import pandas as pd
import uuid
import math
import quantumrandom
statement = pd.read_csv('Виписка_по_Банці_N92_30_0019107280_на_2023_02_16.csv')
statement_list = statement.to_dict(orient='records')
def round_down(n, decimals=0):
multiplier = 10 ** decimals
@danielmartin
danielmartin / BetterXcodeJumpToCounterpartSwift.org
Last active March 9, 2024 02:00
Add support for a better Xcode's Jump to Next Counterpart in Swift

If you work on a Swift project that follows the Model-View-ViewModel (MVVM) architecture or similar, you may want to jump to counterpart in Xcode from your view to your model, and then to your view model. (ie. by using Ctrl+Cmd+Up and Ctrl+Cmd+Down).

You can do this in recent versions of Xcode by setting a configuration default.

From a terminal, just type this command and press Enter:

defaults write com.apple.dt.Xcode IDEAdditionalCounterpartSuffixes -array-add "ViewModel" "View"
#!/usr/bin/env ruby
# Sets in a pod the given build setting
#
# @param [Xcodeproj::Project] project
# The xcode project instance.
#
# @param [Hash] build_settings
# An hash with the build configurations
#
@smosko
smosko / OSLog+Extensions.swift
Last active December 26, 2022 07:54
Unified Logging Wrapper
import Foundation
@_exported import os.log
public extension OSLog {
convenience init(_ bundle: Bundle = .main, category: String? = nil) {
self.init(subsystem: bundle.bundleIdentifier ?? "default", category: category ?? "default")
}
convenience init(_ aClass: AnyClass, category: String? = nil) {
@ArtFeel
ArtFeel / CALayer+AnimationPlayback.swift
Last active November 15, 2023 23:06
Persistent Core Animations (Swift 4.2). All you need is `self.layer.makeAnimationsPersistent()` 😎
//
// CALayer+AnimationPlayback.swift
// Created by Philip Vasilchenko on 4/27/18.
//
import UIKit
// Pause animations of layer tree
//
// Technical Q&A QA1673:
@tclementdev
tclementdev / libdispatch-efficiency-tips.md
Last active April 26, 2024 10:15
Making efficient use of the libdispatch (GCD)

libdispatch efficiency tips

The libdispatch is one of the most misused API due to the way it was presented to us when it was introduced and for many years after that, and due to the confusing documentation and API. This page is a compilation of important things to know if you're going to use this library. Many references are available at the end of this document pointing to comments from Apple's very own libdispatch maintainer (Pierre Habouzit).

My take-aways are:

  • You should create very few, long-lived, well-defined queues. These queues should be seen as execution contexts in your program (gui, background work, ...) that benefit from executing in parallel. An important thing to note is that if these queues are all active at once, you will get as many threads running. In most apps, you probably do not need to create more than 3 or 4 queues.

  • Go serial first, and as you find performance bottle necks, measure why, and if concurrency helps, apply with care, always validating under system pressure. Reuse

@DenTelezhkin
DenTelezhkin / MeasureAppStartupTime.swift
Last active November 27, 2023 07:28
Measure iOS app startup time, in seconds, from the time user tapped an icon on the home screen (using time, when app process was created). Swift 4.
// Returns number of seconds passed between time when process was created and function was called
func measureAppStartUpTime() -> Double {
var kinfo = kinfo_proc()
var size = MemoryLayout<kinfo_proc>.stride
var mib : [Int32] = [CTL_KERN, KERN_PROC, KERN_PROC_PID, getpid()]
sysctl(&mib, u_int(mib.count), &kinfo, &size, nil, 0)
let start_time = kinfo.kp_proc.p_starttime
var time : timeval = timeval(tv_sec: 0, tv_usec: 0)
gettimeofday(&time, nil)
let currentTimeMilliseconds = Double(Int64(time.tv_sec) * 1000) + Double(time.tv_usec) / 1000.0
@ilyapuchka
ilyapuchka / Enums.swift
Created November 6, 2017 20:58
Codable tips suggestions
/*
Instead of using enum it's possible to use RawRepresentable struct that will give you support for "unsupported" values,
but will cost you excastive switches (you'll alwyas have to handle default case, which will stand for those "unsupported" values)
It's defenetely more code than if using optional, but might be better if it comes to unwrapping this value everywhere.
*/
//enum System: String, Decodable {
// case ios, macos, tvos, watchos
//}
struct System: RawRepresentable, Decodable {
@kean
kean / Client.swift
Last active September 16, 2022 03:41
API Client (Archived)
// The MIT License (MIT)
//
// Copyright (c) 2017 Alexander Grebenyuk (github.com/kean).
import Foundation
import Alamofire
import RxSwift
import RxCocoa
// This post is **archived**. For a modern version that uses Async/Await and Actors, see the new article
@joshdholtz
joshdholtz / .env
Last active December 26, 2023 13:31
Using Dotenv and environment variables with fastlane
STUFF = this is some stuff