Skip to content

Instantly share code, notes, and snippets.

View ken0nek's full-sized avatar

Ken Tominaga ken0nek

  • Palo Alto, CA
View GitHub Profile
@ken0nek
ken0nek / integral.swift
Last active December 11, 2015 10:39
integral, sigma
extension Double : ForwardIndexType {
public func successor() -> Double {
return self + 1.0
}
}
infix operator { associativity left precedence 120 }
func (left: Range<Double>, right: (Double -> Double)) -> Double {
let dx = (left.endIndex - left.startIndex) / 1000
let r = left.startIndex.stride(to: left.endIndex, by: dx)
//
// RootViewController.swift
// iOS9Sampler
//
// Created by Shuichi Tsutsumi on 2015/06/10.
// Copyright © 2015 Shuichi Tsutsumi. All rights reserved.
//
import UIKit
var result: [(hasSmile: Bool, leftEyeClosed: Bool, rightEyeClosed: Bool)] = []
for feature in features as! [CIFaceFeature] {
result.append((feature.hasSmile, feature.leftEyeClosed, feature.rightEyeClosed))
}
if result.count >= 1 {
if result[0].hasSmile {
self.playerAttack()
@ken0nek
ken0nek / URLCodableTest.playground
Last active June 12, 2017 15:08
Can not decode an entity which has Optional<URL> property.
//: Playground - noun: a place where people can play
import UIKit
struct URLCodableTest: Codable {
let ou: URL?
let u: URL
enum CodingKeys: String, CodingKey {
case ou
@ken0nek
ken0nek / Country.swift
Created November 20, 2017 10:49
App Store Country List from ttps://developer.apple.com/library/content/documentation/LanguagesUtilities/Conceptual/iTunesConnect_Guide/Chapters/AppStoreTerritories.html
import Foundation
/*
https://developer.apple.com/library/content/documentation/LanguagesUtilities/Conceptual/iTunesConnect_Guide/Chapters/AppStoreTerritories.html
*/
public enum Country: String {
case unitedArabEmirates = "ae"
case antiguaAndBarbuda = "ag"
case anguilla = "ai"
case albania = "al"