Skip to content

Instantly share code, notes, and snippets.

View mgray88's full-sized avatar
:shipit:

Mike Gray mgray88

:shipit:
View GitHub Profile
@Ariel-Rodriguez
Ariel-Rodriguez / semver.sh
Last active April 14, 2025 12:33
semver compare tool in bash
#!/bin/bash
# THIS IS AN OBSOLETE SCRIPT WITH BUGS. FOR UPDATED VERSIONS PLEASE CHECK https://github.com/Ariel-Rodriguez/sh-semversion-2
###
# semantic version comparition using semver specification http://semver.org/
# This bash script compares pre-releases alphabetically as well
#
# returns 1 when A greater than B
# returns 0 when A equals B
@krzyzanowskim
krzyzanowskim / StringGetSizeThatFits.swift
Last active November 12, 2023 14:51
Calculate frame of String, that fits given width
// Excerpt from https://github.com/krzyzanowskim/CoreTextWorkshop
// Licence BSD-2 clause
// Marcin Krzyzanowski [email protected]
func getSizeThatFits(_ attributedString: NSAttributedString, maxWidth: CGFloat) -> CGSize {
let framesetter = CTFramesetterCreateWithAttributedString(attributedString)
let rectPath = CGRect(origin: .zero, size: CGSize(width: maxWidth, height: 50000))
let ctFrame = CTFramesetterCreateFrame(framesetter, CFRange(), CGPath(rect: rectPath, transform: nil), nil)