Skip to content

Instantly share code, notes, and snippets.

View SergLam's full-sized avatar
😊
Try to make your code better!

Serhii Liamtsev SergLam

😊
Try to make your code better!
View GitHub Profile
@SergLam
SergLam / HiddenMacOSDebuggingPanel.md
Created April 18, 2024 09:37 — forked from usagimaru/HiddenMacOSDebuggingPanel.md
Enables useful debugging panel in macOS apps

Use _NS_4445425547 or NS🐞 for enables debuggging panel. When enabled it, a ladybug 🐞 menu appears in the app menu bar.

“4445425547” means DEBUG in Unicode table.

0x44=D
0x45=E
0x42=B
0x55=U
0x47=G

@SergLam
SergLam / SwiftUIDoubleClickModifier.swift
Created March 11, 2024 12:02 — forked from joelekstrom/SwiftUIDoubleClickModifier.swift
A view modifier that can reliably detect double clicks on macOS, even in List
extension View {
/// Adds a double click handler this view (macOS only)
///
/// Example
/// ```
/// Text("Hello")
/// .onDoubleClick { print("Double click detected") }
/// ```
/// - Parameters:
/// - handler: Block invoked when a double click is detected
@SergLam
SergLam / Generics+Utilities.swift
Created November 9, 2023 09:13 — forked from edc0der/Generics+Utilities.swift
Get class name without namespace in Swift
func className(target: AnyObject) -> String {
let nameSpaceClassName = NSStringFromClass(type(of: target))
if let className = nameSpaceClassName.components(separatedBy: ".").last {
return className
}
return ""
}
@SergLam
SergLam / updating_ruby_with_rvm_on_a_mac.md
Created June 22, 2021 08:44 — forked from wrburgess/updating_ruby_with_rvm_on_a_mac.md
Updating Ruby with rvm or rbenv on a Mac

RBENV

  • rbenv install -l
  • rbenv install 2.6.5
  • rbenv local 2.6.5
  • gem install bundler
  • bundle install

RVM

@SergLam
SergLam / Animation.md
Created December 4, 2020 10:40 — forked from JeOam/Animation.md
iOS Core Animation: Advanced Techniques, Part 1: The Layer Beneath

Author: https://www.cyanhall.com/

1. The Layer Tree

Core Animation's original name is Layer Kit

Core Animation is a compositing engine; its job is to compose different pieces of visual content on the screen, and to do so as fast as possible. The content in question is divided into individual layers stored in a hierarchy known as the layer tree. This tree forms the underpinning for all of UIKit, and for everything that you see on the screen in an iOS application.

In UIView, tasks such as rendering, layout and animation are all managed by a Core Animation class called CALayer. The only major feature of UIView that isn’t handled by CALayer is user interaction.

There are four hierarchies, each performing a different role:

@SergLam
SergLam / FileWebService.swift
Created September 14, 2020 06:25 — forked from boboboa32/FileWebService.swift
Moya file download
import Moya
import SwiftyJSON
enum FileWebService {
case download(url: String, fileName: String?)
var localLocation: URL {
switch self {
case .download(let url, let fileName):
let fileKey: String = url.MD5 // use url's md5 as local file name
@SergLam
SergLam / AsynchronousBlockOperation.swift
Last active September 29, 2023 17:37 — forked from CanTheAlmighty/AsynchronousBlockOperation.swift
Subclass of (NS)Operation to make it asynchronous in Swift 5, also providing a Block-based alternative.
//
// AsynchronousBlockOperation.swift
//
// Created by Jose Canepa on 12/13/17.
// Copyright © 2017 Jose Canepa. All rights reserved.
//
import Foundation
/// Block based version of the AsynchronousOperation

Understanding UIViewController Rotation

Problem

To enable the rotation of a single view controller used to display the preview of Images/Videos. It is intuitive to allow user to rotate there device and screen changes accordingly, so it feels pleasant. But to achieve this, we need to enable the (almost) all Supported Device orientations.

Ex: `Portrait`, `LandscapeLeft`, `LandscapeRight`.
@SergLam
SergLam / movietransitions.swift
Created June 27, 2019 05:08 — forked from SheffieldKevin/movietransitions.swift
Make a movie with transitions with AVFoundation and swift
//
// main.swift
// mutablecomposition
//
// Created by Kevin Meaney on 24/08/2015.
// Copyright (c) 2015 Kevin Meaney. All rights reserved.
//
import Foundation