Skip to content

Instantly share code, notes, and snippets.

View giginet's full-sized avatar
🌴
年中On vacation

Kohki Miki giginet

🌴
年中On vacation
View GitHub Profile
@giginet
giginet / poke.txt
Created March 3, 2022 07:01
Pokedle
フシギダネ
フシギソウ
フシギバナ
ヒトカゲ
リザード
リザードン
ゼニガメ
カメール
カメックス
キャタピー
//: Playground - noun: a place where people can play
import UIKit
@propertyWrapper struct Delegate<T, Root> {
private var keyPath: ReferenceWritableKeyPath<Root, T>
private var delegate: Root
init(wrappedValue: T, _ keyPath: ReferenceWritableKeyPath<Root, T>, to delegate: Root) {
self.keyPath = keyPath
targets:
MyApp:
sources:
- path: "path/to/your/intent.intentdefinition"
buildPhase: sources
private func consistsOfSameElements<Element: Equatable>(between lhs: [Element], and rhs: [Element]) -> Bool {
let contained = lhs.compactMap { element in
return rhs.contains(element) ? element : nil
}
return contained == lhs
}
private func contains<Element: Equatable>(_ element: [Element], in collection: [[Element]]) -> Bool {
return collection.contains { consistsOfSameElements(between: element, and: $0) }
}
@giginet
giginet / install-latest-xcode.sh
Last active August 1, 2018 16:03
Install latest Xcode
#!/usr/bin/env bash
xcversion update && xcversion list | tail -n 1 | xargs xcversion install
import Foundation
private let separator: Character = "."
private let allWildcard = "**"
private let wildcard = "*"
func isValidPattern(_ pattern: String) -> Bool {
let patternElements = pattern.split(separator: separator, omittingEmptySubsequences: false)
let isValidWildcardCount = patternElements.filter { $0 == allWildcard || $0 == wildcard }.count <= 1
diff --git a/DemoBots/GeometryExtensions.swift b/DemoBots/GeometryExtensions.swift
index 5c5f97c..e5dc712 100644
--- a/DemoBots/GeometryExtensions.swift
+++ b/DemoBots/GeometryExtensions.swift
@@ -30,12 +30,6 @@ extension float2 {
}
}
-/*
- Extend `float2` to declare conformance to the `Equatable` protocol.
enum Foo: String, Codable {
case a
case b
case c
}
extension RawRepresentable where RawValue == String, Self: Codable {
init(from decoder: Decoder) throws {
var container = try decoder.unkeyedContainer()
let rawValue = try container.decode(String.self)
import UIKit
postfix operator °
protocol IntegerInitializable: ExpressibleByIntegerLiteral {
init (_: Int)
}
extension Int: IntegerInitializable {
postfix public static func °(lhs: Int) -> CGFloat {
@giginet
giginet / RandomUtils.cs
Last active May 28, 2017 06:58
UnityMoqTesting
using System.Collections.Generic;
using UnityEngine;
public interface IRandomGenerator
{
float GenerateValue();
int GenerateInteger(int min, int max);
}
internal class UnityRandomGenerator: IRandomGenerator {