Skip to content

Instantly share code, notes, and snippets.

View chris-hatton's full-sized avatar
👦
Intrepid

Chris Hatton chris-hatton

👦
Intrepid
View GitHub Profile
@chris-hatton
chris-hatton / TreeView.swift
Last active September 20, 2016 15:52
Weekend Playground fun: TreeView
import UIKit
typealias Bough = (rotation:CGFloat, length: CGFloat, scale: CGFloat, hue: CGFloat)
final class TreeView : UIView {
private let limit = 10
private let boughs : [Bough] = [
(rotation: -25, length: 85, scale: 0.75, hue: 0.04),
(rotation: 30, length: 100, scale: 0.65, hue: 0.02)
import UIKit
final class RubberDuckyController : UIViewController {
@IBOutlet weak var leftButton : UIButton!
@IBOutlet weak var rightButton : UIButton!
@IBOutlet weak var textLeftButtonUnderline : UIView!
@IBOutlet weak var shapeRightButtonUnderline : UIView!
@chris-hatton
chris-hatton / AndroidCoroutines.kt
Last active March 1, 2017 09:15
Simple adaption of Kotlin Coroutines for Android
package somePackage
import android.content.Context
import android.os.Handler
import android.os.Looper
import kotlin.coroutines.experimental.*
var coroutineContext : CoroutineContext? = null
fun initCoroutines( androidContext: Context ) {
@chris-hatton
chris-hatton / DataSizeFormatter.kt
Last active December 31, 2023 11:37
Human Readable Data Size Formatter for Kotlin Multiplatform (uses Common API only)
package datasizeformatter
import kotlin.math.abs
import kotlin.math.pow
import kotlin.math.roundToLong
/**
* Format a human-readable representation of data size, in binary base form.
* e.g. 1024 -> 1 KiB
* @param byteCount The number of bytes to represent in human-readable form. `Long.MIN_VALUE` is unsupported.
@chris-hatton
chris-hatton / partial_build.gradle.kts
Last active January 25, 2022 22:15
Render a simple GraphViz graph of Kotlin Multiplatform sourceSet dependencies
// Where Gradle 'project' object is the current receiver...
val dependencies: Map<KotlinSourceSet, Set<KotlinSourceSet>> =
kotlinExtension.sourceSets.associateWith { it.dependsOn }
val renderedDependencies = dependencies
.filterKeys { !it.name.endsWith("Test") } // Exclude test sourceSets
.filterValues { it.isNotEmpty() } // Exclude sourceSets with no relationship (e.g. meta)
if (renderedDependencies.isEmpty()) return@injectWriteSourceSetDotFile
val allRenderedSourceSets =