Skip to content

Instantly share code, notes, and snippets.

View muukii's full-sized avatar
✈️
We live in a twilight world.

Hiroshi Kimura muukii

✈️
We live in a twilight world.
View GitHub Profile
@muukii
muukii / UserDefaults.swift
Created February 1, 2015 15:23
UserDefaults
// UserDefaults.swift
//
// Copyright (c) 2015 muukii
//
// 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:
@jverkoey
jverkoey / rubberBand.swift
Created November 30, 2016 06:55
Rubber banding in swift
public func rubberBand(value: CGFloat, min: CGFloat, max: CGFloat, bandLength: CGFloat) -> CGFloat {
if value >= min && value <= max {
// While we're within range we don't rubber band the value.
return value
}
if bandLength <= 0 {
// The rubber band doesn't exist, return the minimum value so that we stay put.
return min
//
// SimpleScrollingStack.swift
// A super-simple demo of a scrolling UIStackView in iOS 9
//
// Created by Paul Hudson on 10/06/2015.
// Learn Swift at www.hackingwithswift.com
// @twostraws
//
import UIKit
@cocopon
cocopon / Easing.pde
Last active January 28, 2023 04:05
A class that brings Robert Penner's easing functions into Processing
/*
* Easing.pde - brings Robert Penner's easing functions into Processing
* (c) 2015 cocopon.
*
* See the following to learn more about these famous functions:
* http://www.robertpenner.com/easing/
*
* License:
* http://www.robertpenner.com/easing_terms_of_use.html
*/
@WorldDownTown
WorldDownTown / KanaConverter.swift
Created December 18, 2019 04:51
Kanji to hiragana or katakana
import Foundation
private extension CFStringTokenizer {
var hiragana: String { string(to: kCFStringTransformLatinHiragana) }
var katakana: String { string(to: kCFStringTransformLatinKatakana) }
private func string(to transform: CFString) -> String {
var output: String = ""
while !CFStringTokenizerAdvanceToNextToken(self).isEmpty {
output.append(letter(to: transform))
@okapies
okapies / promises-are-functional.md
Last active August 14, 2023 11:44
翻訳: ”命令型のコールバック、関数型のプロミス: Node が逸した最大の機会” by James Coglan

命令型のコールバック、関数型のプロミス: Node が逸した最大の機会

Original: "Callbacks are imperative, promises are functional: Node's biggest missed opportunity" by James Coglan

Translated by Yuta Okamoto (@okapies)

Note

  • 訳者は JavaScript や Node.js に関する専門知識がほとんどありません。識者のツッコミをお待ちしております。「◯◯が分からない」等も歓迎です。
  • 元記事から構成を一部変更しています。また、関数型プログラミングに関する記述のうち、議論の骨子に絡まないものは省略しています。
import Foundation
extension CustomStringConvertible {
var description: String {
var description: String = "\(type(of: self))("
let selfMirror = Mirror(reflecting: self)
for child in selfMirror.children {
if let propertyName = child.label {
@zwaldowski
zwaldowski / Activity.swift
Last active February 15, 2024 18:49
os_activity_t for Swift 3
//
// Activity.swift
//
// Created by Zachary Waldowski on 8/21/16.
// Copyright © 2016 Zachary Waldowski. Licensed under MIT.
//
import os.activity
private final class LegacyActivityContext {
@danielmartin
danielmartin / BetterXcodeJumpToCounterpartSwift.org
Last active March 9, 2024 02:00
Add support for a better Xcode's Jump to Next Counterpart in Swift

If you work on a Swift project that follows the Model-View-ViewModel (MVVM) architecture or similar, you may want to jump to counterpart in Xcode from your view to your model, and then to your view model. (ie. by using Ctrl+Cmd+Up and Ctrl+Cmd+Down).

You can do this in recent versions of Xcode by setting a configuration default.

From a terminal, just type this command and press Enter:

defaults write com.apple.dt.Xcode IDEAdditionalCounterpartSuffixes -array-add "ViewModel" "View"