Skip to content

Instantly share code, notes, and snippets.

View aplekhanov's full-sized avatar
🇨🇾
Working from home

Alex Plekhanov aplekhanov

🇨🇾
Working from home
View GitHub Profile
// Advanced SwiftUI Transitions
// https://swiftui-lab.com
// https://swiftui-lab.com/advanced-transitions
import SwiftUI
struct CrossEffectDemo: View {
let animationDuration: Double = 2
let images = ["photo1", "photo2", "photo3", "photo4"]
@State private var idx = 0
@aplekhanov
aplekhanov / vim-swift-setup.sh
Created April 16, 2023 13:56 — forked from mgrider/vim-swift-setup.sh
Swift syntax highlighting for Vim
# Swift syntax highlighting for Vim
# Original Source: http://wingsquare.com/blog/swift-script-syntax-highlighting-and-indentation-for-vim-text-editor/
# Another helpful article: https://billyto.github.io/blog/swift-syntax-vim
# More about Vim packages: http://vimcasts.org/episodes/packages/
echo "--- creating ~/.vim/pack/bundle/start dir.."
mkdir -p ~/.vim/pack/bundle/start
echo "--- Cloning Apple's Swift repo.."
@aplekhanov
aplekhanov / Color+UIColors.swift
Last active January 21, 2024 17:17
SwiftUI system colors extension
import SwiftUI
extension Color {
// MARK: - Text Colors
static let lightText = Color(UIColor.lightText.cgColor)
static let darkText = Color(UIColor.darkText.cgColor)
static let placeholderText = Color(UIColor.placeholderText.cgColor)
// MARK: - Label Colors

Commit Message Guidelines

Short (72 chars or less) summary

More detailed explanatory text. Wrap it to 72 characters. The blank
line separating the summary from the body is critical (unless you omit
the body entirely).

Write your commit message in the imperative: "Fix bug" and not "Fixed
bug" or "Fixes bug." This convention matches up with commit messages
//
// UIImage+PDF.swift. Copyright © 2016 Nigel Timothy Barber (@mindbrix). All rights reserved.
//
import UIKit
extension UIImage {
static func PDFImageWith(_ url: URL, pageNumber: Int, width: CGFloat) -> UIImage? {
return PDFImageWith(url, pageNumber: pageNumber, constraints: CGSize(width: width, height: 0))
}
@aplekhanov
aplekhanov / battery.m
Created January 22, 2016 13:25
Get battery level on iOS device.
UIDevice *myDevice = [UIDevice currentDevice];
[myDevice setBatteryMonitoringEnabled:YES];
NSLog(@"%f", myDevice.batteryLevel);
@aplekhanov
aplekhanov / exit.m
Created January 22, 2016 13:22
Programmatically exit from iOS app
// not for app store apps, 'cause wil be rejected !!!
// can be useful for in-house development needs
UIApplication *app = [UIApplication sharedApplication];
[app performSelector:@selector(suspend)];
// wait two seconds while app is going to background
[NSThread sleepForTimeInterval:2.0];
// when exit app when it is in background