Skip to content

Instantly share code, notes, and snippets.

View raygun101's full-sized avatar
💭
Coding like Mad Cat 🦑

Leslie Godwin raygun101

💭
Coding like Mad Cat 🦑
View GitHub Profile
@raygun101
raygun101 / UITextViewWithAutoLayout.swift
Last active February 9, 2022 06:11
🍰 Layered Cakewalk [Swift] - Auto sizing UITextView where intrinsicContentSize reflects the text size.
import UIKit
///
/// 🍰 Layered Cakewalk - UITextViewWithAutoLayout
///
/// A UITextView that has an `intrinsicContentSize` equal to the content size.
///
class UITextViewWithAutoLayout : UITextView
{
@raygun101
raygun101 / 0. NSAttributedString+AttributesStyle.swift
Last active February 9, 2022 06:09
🍰 Layered Cakewalk [Swift] - AttributesStyle
import UIKit
import PlaygroundSupport
///
/// 🍰 Layered Cakewalk - AttributesStyle
///
/// Allows you to structure style classes used to modify an `NSAttributedString`s.
///
//
@raygun101
raygun101 / ObjC+Extensions.swift
Last active September 14, 2020 11:17
🍰 Layered Cakewalk [Swift] - Get All Types at Runtime (Swift)
///
/// 🍰 Layered Cakewalk
///
/// Gets all defined `Swift` and `Objective-C` classes.
///
public static func allTypes() -> [AnyObject.Type]
{
let typeCount = Int(objc_getClassList(nil, 0))
let types = UnsafeMutablePointer<AnyObject.Type>.allocate(capacity: typeCount)
@raygun101
raygun101 / MyClass.swift
Last active September 24, 2020 06:36
🍰 Layered Cakewalk [Swift] - Generic<> stored static fields workaround. (Swift)
import UIKit
// 🍰👻 Generic<> stored static fields workaround.
//
private var _MyClass_static: [ObjectIdentifier : Any] = [:] // need some global space
//
class MyClass<T>
{
typealias StaticClass = MyClassStatic<Self>
@raygun101
raygun101 / CommandlineSplittingConverter.dart
Last active September 14, 2020 11:13
🍰 Layered Cakewalk [Dart] - Parses/splits a command-line String into a List<String> of the individual argument elements processing quotes.
//
// Original implementation: https://stackoverflow.com/a/39177861/638848
//
// Re-made by: Leslie Godwin (leslie.godwin@gmail.com)
import 'dart:convert';
/// Parses/splits a command-line String into a List<String> of the individual argument elements.
/// Handles whitespace, quotes and back\slash escape.
///