Skip to content

Instantly share code, notes, and snippets.

@takkyun
takkyun / ColorPalette.swift
Created November 11, 2019 07:22
Ant.Design color palette in Swift
//
// ColorPalette.swift
// justInCase
//
// Created by Takuya Otani on 11/11/19.
// Copyright © 2019 justInCase. All rights reserved.
//
struct ColorPalette {
static private let minIndex = 1
@takkyun
takkyun / Array+Helpler.swift
Created October 9, 2019 20:27
Convert tuple to array in Swift
import Foundation
public extension Array {
static func fromTuple<T>(_ tuple:T) -> [Element] {
let reflection = Mirror(reflecting: tuple).children
var arr : [Element] = []
for i in 0..<reflection.count {
let index = reflection.index(reflection.startIndex, offsetBy: i)
if let value = reflection[index].value as? Element {
arr.append(value)
@takkyun
takkyun / gist:e3cd114a982c9349b2c4
Created February 17, 2016 03:04
Regex for RFC5322 mail address spec
(?:(?:(?:(?:(?:(?:[\x20\x09]*(?:\x0D\x0A))?[\x20\x09]+|(?:[\x20\x0
9]+(?:(?:\x0D\x0A)[\x20\x09]+)*))?(\((?:(?:(?:[\x20\x09]*(?:\x0D\x
0A))?[\x20\x09]+|(?:[\x20\x09]+(?:(?:\x0D\x0A)[\x20\x09]+)*))?(?:(
?:[\x21-\x27\x2A-\x5B\x5D-\x7E]|[\x01-\x08\x0B\x0C\x0E-\x1F\x7F])|
(?:\\(?:[\x21-\x7E]|[\x20\x09])|(?:\\(?:\x00|[\x01-\x08\x0B\x0C\x0
E-\x1F\x7F]|\x0A|\x0D)))|(?-1)))*(?:(?:[\x20\x09]*(?:\x0D\x0A))?[\
x20\x09]+|(?:[\x20\x09]+(?:(?:\x0D\x0A)[\x20\x09]+)*))?\)))+(?:(?:
[\x20\x09]*(?:\x0D\x0A))?[\x20\x09]+|(?:[\x20\x09]+(?:(?:\x0D\x0A)
[\x20\x09]+)*))?|(?:(?:[\x20\x09]*(?:\x0D\x0A))?[\x20\x09]+|(?:[\x
20\x09]+(?:(?:\x0D\x0A)[\x20\x09]+)*)))?(?:[A-Za-z0-9!#$%&'*+\-/=?
@interface SBLImageHelper
/**
* Generates an image which is tinted with a given color.
* @param image - an image to be tinted
* @param color - tint color
* @return an instance of UIImage
*/
+ (UIImage *)tintedImageFromImage:(UIImage *)image
withColor:(UIColor *)color;
@end
@takkyun
takkyun / file0.m
Created May 28, 2014 20:23
カテゴリーでインスタンス変数 ref: http://qiita.com/takkyun@github/items/b6de22f5a4f494f534da
@interface MyClass (CategoryName)
// 追加したいメソッド
@end