Skip to content

Instantly share code, notes, and snippets.

View RomanPodymov's full-sized avatar
😀
Coding

Roman Podymov RomanPodymov

😀
Coding
View GitHub Profile
@runys
runys / LocationManager.swift
Last active November 4, 2025 09:38
Location Manager service providing an asynchronous way of accessing the user current location.
import Foundation
import CoreLocation
class LocationManager: NSObject, CLLocationManagerDelegate {
//MARK: Object to Access Location Services
private let locationManager = CLLocationManager()
//MARK: Set up the Location Manager Delegate
override init() {
@nicholascross
nicholascross / ArrayBuilder.swift
Created June 16, 2021 22:35
Generic array builder using swift 5.4 result builder
@resultBuilder
enum ArrayBuilder<OutputModel> {
static func buildEither(first component: [OutputModel]) -> [OutputModel] {
return component
}
static func buildEither(second component: [OutputModel]) -> [OutputModel] {
return component
}
@alex-spataru
alex-spataru / deploy-qt-app.yml
Last active June 18, 2025 21:36
Compile & generate build artifacts for Qt Projects with GitHub Actions
#--------------------------------------------------------------------------------
# Workflow configuration
#--------------------------------------------------------------------------------
name: Build
on:
push: # Run on push
pull_request: # Run on pull-request
#--------------------------------------------------------------------------------
@malhal
malhal / CLLocationManager+Combine.swift
Last active April 17, 2025 18:20
A Combine location publisher for CLLocationManager.
// Requirements: a NSLocationWhenInUseUsageDescription entry in Info.plist
// Usage: @State var locator = CLLocationManager.publishLocation()
// and
// .onReceive(locator) { location in
// Improvements needed: Move requestWhenInUseAuthorization into its own publisher and perhaps have a combineLatest pipeline for both authorized and valid location.
// A configuration param to init(), e.g. so each manager can have the same distanceFilter.
import Foundation
import Combine
import CoreLocation
@chwastek
chwastek / xcframework_create.sh
Last active March 15, 2024 13:10
Reusable script for creating an XCFramework from both Xcode and Terminal. You can run this script with framework's name, if needed (e.g. when running from Terminal).
#!/bin/sh
# -------------- config --------------
# Uncomment for debugging
set -x
# Set bash script to exit immediately if any commands fail
set -e
@jeksys
jeksys / Thread-Safe.md
Last active June 30, 2025 08:46
Thread-Safe Arrays in Swift

What's concurrency

Concurrency means running more than one task at the same time.

What is a race condition?

When you have two threads changing a variable simultaneously. It’s possible to get unexpected results. Imagine a bank account where one thread is subtracting a value to the total and the other is adding a value.

What's thread safe in Swift

Nothing in Swift is intrinsically threadsafe

@AliSoftware
AliSoftware / Bindings.swift
Last active August 5, 2025 14:50
Re-implementation of @binding and @State (from SwiftUI) myself to better understand it
/*:
This is a concept re-implementation of the @Binding and @State property wrappers from SwiftUI
The only purpose of this code is to implement those wrappers myself
just to understand how they work internally and why they are needed,
⚠️ This is not supposed to be a reference implementation nor cover all
subtleties of the real Binding and State types.
The only purpose of this playground is to show how re-implementing
them myself has helped me understand the whole thing better
@konnnn
konnnn / UILabel+Padding.swift
Last active February 22, 2024 13:24
Swift 4: Adding space/padding to a UILabel Programmatically and Storyboard
/*
If you use Storyboard, don't forget to set UIlabel to PaddingLabel
*/
import UIKit
class PaddingLabel: UILabel {
var topInset: CGFloat
var bottomInset: CGFloat
@kevenbauke
kevenbauke / wkwebview_links_externally.swift
Last active June 21, 2022 17:13
WKWebView open links in Safari
@messeb
messeb / URLResponse+HTTP.swift
Created December 5, 2017 21:00
URLResponse as HTTPURLResponse and check if call has status code 2xx
extension URLResponse {
/// Returns casted `HTTPURLResponse`
var http: HTTPURLResponse? {
return self as? HTTPURLResponse
}
}
extension HTTPURLResponse {
/// Returns `true` if `statusCode` is in range 200...299.
/// Otherwise `false`.