Skip to content

Instantly share code, notes, and snippets.

View Kirow's full-sized avatar

Kirill Serebriakov Kirow

View GitHub Profile
@timothycosta
timothycosta / SwiftUIKeyboardAnimation.swift
Last active March 12, 2024 21:10
Create a SwiftUI Animation with the correct curve and duration from UIKit keyboard notifications
func animation(from notification: Notification) -> Animation? {
guard
let info = notification.userInfo,
let duration = info[UIResponder.keyboardAnimationDurationUserInfoKey] as? Double,
let curveValue = info[UIResponder.keyboardAnimationCurveUserInfoKey] as? Int,
let uiKitCurve = UIView.AnimationCurve(rawValue: curveValue)
else {
return nil
}
@levitatingpineapple
levitatingpineapple / UIFont.Features.swift
Last active March 27, 2024 18:30
SFPro Font Features
import UIKit
extension UIFont {
/// Watch [WWDC Session](https://developer.apple.com/videos/play/wwdc2015/804/).
/// [Font Feature Registry](https://developer.apple.com/fonts/TrueType-Reference-Manual/RM09/AppendixF.html)
/// - Parameters:
/// - size: The size (in points) to which the font is scaled. This value must be greater than 0.0.
/// - weight: The weight of the font, specified as a font weight constant.
/// - features: Font features supported by SFPro
@sorny
sorny / x11_forwarding_macos_docker.md
Last active April 23, 2024 08:11
X11 forwarding with macOS and Docker

X11 forwarding on macOS and docker

A quick guide on how to setup X11 forwarding on macOS when using docker containers requiring a DISPLAY. Works on both Intel and M1 macs!

This guide was tested on:

  • macOS Catalina 10.15.4
  • docker desktop 2.2.0.5 (43884) - stable release
  • XQuartz 2.7.11 (xorg-server 1.18.4)
  • Macbook Pro (Intel)
@jasorod
jasorod / SVGPath.swift
Last active January 31, 2024 19:13 — forked from dotcypress/SVGPath.swift
SVG path to CGPath converter
//
// SVGPath.swift
// SVGPath
//
// Created by Tim Wood on 1/21/15.
// Updated by Vitaly Domnikov 10/6/2015
// Updated by Jason Rodriguez 08/29/2017
// Copyright (c) 2015 Tim Wood, Vitaly Domnikov, Jason Rodriguez. All rights reserved.
import Foundation
import UIKit
import PlaygroundSupport
func degree2radian(a:CGFloat)->CGFloat {
let b = CGFloat(Double.pi) * a/180
return b
}
func polygonPointArray(sides:Int,x:CGFloat,y:CGFloat,radius:CGFloat,adjustment:CGFloat=0)->[CGPoint] {
let angle = degree2radian(a: 360/CGFloat(sides))
import UIKit
/// High precedence
precedencegroup HighPrecedence { higherThan: BitwiseShiftPrecedence }
/// Exponentiation operator
infix operator **: HighPrecedence
extension CGFloat {
/// Returns base ^^ exp
@akhilcb
akhilcb / CGPoint+Extension.swift
Created May 7, 2017 23:22
CGPoint extension with some useful functions for angle and point calculation on arc and circles
// Taken from ACBRadialMenuView Project
// BSD 3-Clause License
// Copyright (c) 2017, akhilcb (https://github.com/akhilcb)
extension CGPoint {
static func pointOnCircle(center: CGPoint, radius: CGFloat, angle: CGFloat) -> CGPoint {
let x = center.x + radius * cos(angle)
let y = center.y + radius * sin(angle)
@nazywamsiepawel
nazywamsiepawel / UINavigationBarWithSubtitle.swift
Last active July 20, 2023 11:58
UINavigationBar with subtitle / swift
func setTitle(title:String, subtitle:String) -> UIView {
let titleLabel = UILabel(frame: CGRect(x:0, y:-5, width:0, height:0))
titleLabel.backgroundColor = UIColor.clear
titleLabel.textColor = UIColor.gray
titleLabel.font = UIFont.boldSystemFont(ofSize: 17)
titleLabel.text = title
titleLabel.sizeToFit()
@clowwindy
clowwindy / Makefile
Last active January 4, 2016 03:18
stringByAddingPercentEncodingWithAllowedCharacters Crash
test: main.m
gcc -o main main.m -framework Foundation