Skip to content

Instantly share code, notes, and snippets.

View stleamist's full-sized avatar

Dongkyu Kim stleamist

View GitHub Profile
@tcldr
tcldr / TimingFunction.swift
Last active May 30, 2025 22:43
For when you need the progress along an Apple Animation curve outside of CoreAnimation in a Swift 4.2 interface. Given a cubic Bezier timing curve defined by two control points, (or UIKit's `UICubicTimingParameters`), returns the progress along the curve at any given time. Includes a port of the WebKit implementation of UnitBezier which hopefull…
//
// TimingFunction.swift
//
// Created by tcldr on 04/11/2018.
// https://github.com/tcldr
// Copyright © 2018 tcldr.
//
// Permission is hereby granted, free of charge,
// to any person obtaining a copy of this software and
// associated documentation files (the "Software"), to
@Koze
Koze / CaseIterable+Index.swift
Last active July 16, 2020 10:17
index of CaseIterable enum
/*
Copyright (c) 2018 Kazume Koze
Released under the MIT license
https://opensource.org/licenses/mit-license.php
*/
//
// CaseIterable+Index.swift
//
//
extension Error {
public var legibleDescription: String {
switch errorType {
case .swiftError(.enum?):
return "\(type(of: self)).\(self)"
case .swiftError:
return String(describing: self)
case .swiftLocalizedError(let msg):
return msg
case .nsError(_, "kCLErrorDomain", 0):
@KimDev88
KimDev88 / lib.lunarcal.public.js
Last active November 6, 2019 07:13 — forked from Senarin/lib.lunarcal.public.js
An standalone JavaScript library file for Korean lunar calendar calculation :3
/**************************************************
* 양음력 계산 라이브러리 -- Library file for Korean Lunar Calendar
* by Senarin
**************************************************/
var DAY0000=1721424.5; // 0000/12/31
var SOLAR_EPOCH=1721425.5; // 0001/1/1
var YEAR_MIN=1583; // Min. Year
var YEAR_MAX=2100; // Max. Year
var LUNAR_EPOCH=2299261.5;
var LOWER_LIMIT=LUNAR_EPOCH;
@objc func _needsDoubleUpdateConstraintsPass() -> Bool {
return true
}
override var intrinsicContentSize: CGSize {
  return attributedText?.size(forWidth: (engineBounds ?? bounds).width) ?? .zero
}
var engineBounds: CGRect? {
let objcSelector = "_nsis_compatibleBoundsInEngine:")
@objc func _prepareForSecondIntrinsicContentSizeCalculation(withLayoutEngineBounds bounds: CGRect) {
print(bounds)
}
@darrarski
darrarski / CustomIntensityVisualEffectView.swift
Last active July 17, 2025 11:26
UIVisualEffectView subclass that allows to customise effect intensity
// MIT License
//
// Copyright (c) 2017 Dariusz Rybicki Darrarski
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
@ctreffs
ctreffs / ArrayFromTuple.swift
Last active September 16, 2021 14:16
Array from Tuple [Swift]
/// Generates array form a tuple. Given tuple's elements must have homogenous type.
///
/// - Parameter tuple: a (homogenous) tuple
/// - Returns: array of tuple elements
func makeArray<Tuple, Value>(from tuple: Tuple) -> [Value] {
let tupleMirror = Mirror(reflecting: tuple)
assert(tupleMirror.displayStyle == .tuple, "Given argument is no tuple")
assert(tupleMirror.superclassMirror == nil, "Given tuple argument must not have a superclass (is: \(tupleMirror.superclassMirror!)")
assert(!tupleMirror.children.isEmpty, "Given tuple argument has no value elements")
func convert(child: Mirror.Child) -> Value? {
@iainjreid
iainjreid / index.js
Last active September 30, 2019 07:37
A very simple TCP echo server, written in Node.js
const net = require('net')
net.createServer(socket => {
socket.on('data', function(data){
console.log('Echoing: %s', data.toString())
socket.write(data.toString())
})
}).listen(8001)
@pierrejoubert73
pierrejoubert73 / markdown-details-collapsible.md
Last active July 14, 2025 06:05
How to add a collapsible section in markdown.

How to add a collapsible section in markdown

1. Example

Click me

Heading

  1. Foo
  2. Bar
    • Baz
  • Qux