Skip to content

Instantly share code, notes, and snippets.

@akuraru
akuraru / NSObject+performSelector.m
Last active August 29, 2015 14:08
SwiftでperformSelectorを使うための何か
#import "NSObject+performSelector.h"
@implementation NSObject (performSelector)
- (void)call:(NSString *)sel {
[self performSelector:@selector(sel)];
}
- (id)get:(NSString *)sel {
return [self performSelector:@selector(sel)];
// 鳥とバランス棒のシノニムを定義
typealias Birds = Int
typealias Pole = (left: Birds, right: Birds)
// 左右に鳥が飛んできたことを表現
func landLeft(n: Birds) -> Pole -> Pole {
return {p in (p.left + n, p.right)};
}
func landRight(n: Birds) -> Pole -> Pole {
extension Dictionary {
func map<K, V>(f: (Key, Value) -> (K, V)) -> [K: V] {
var r = Dictionary<K, V>(minimumCapacity: self.count)
for key in self.keys {
let (k, d) = f(key, self[key]!)
r[k] = d
}
return r
}
}
import UIKit
protocol UIViewControllerProtocol {
// hogehoge...
}
extension UIViewController: UIViewControllerProtocol {
}
var viewController: protocol<UIViewControllerProtocol, UITableViewDelegate>! = nil
Pod::Spec.new do |s|
s.name = "AMoAd"
s.version = "3.9.7"
s.summary = "AMoAdネイティブ広告(SDK for iOS)"
s.homepage = "https://github.com/amoad/amoad-ios-sdk"
s.ios.deployment_target = '7.0'
s.license = { :type => 'o', :file => 'LICENSE' }
s.author = { "amoad" => "[email protected]" }
s.source = {
:tag => "v3.9.7",
@akuraru
akuraru / gist:7388c5f93080d38f3d96749bae820325
Last active May 31, 2016 02:07
Arrayを逆順に評価する
let array = [1, 2, 3, 4, 5]
for num in array.reverse() {
print("num: \(num)");
}
for (index, num) in array.enumerate().reverse() {
print("num: \(num)");
print("inde: \(index)\n");
}
struct MyStruct<T: Equatable>: Equatable {
let x: T;
}
func ==<T>(x: MyStruct<T>, y: MyStruct<T>) -> Bool {
return x.x == y.x
}
let s1 = MyStruct(x: 1)
let s2 = MyStruct(x: 2)
@akuraru
akuraru / 休日一覧.md
Last active August 18, 2017 04:57
祝日についての覚書
休日 期日 適用開始年 適用終了年
元日 1月1日 1948年7月20日 -
元始祭 1月3日 1873年10月14日 1948年7月20日
新年宴会 1月5日 1873年10月14日 1948年7月20日
成人の日 1月15日 1948年7月20日 2000年1月1日
成人の日 1月の第2月曜日 2000年1月1日 -
孝明天皇祭 1月30日 1873年10月14日 1912年
紀元節 2月11日 1873年10月14日 1948年7月20日
@akuraru
akuraru / HeiseiTests.swift
Last active April 13, 2018 08:32
そのうち壊れるテスト書いた
import XCTest
class HeiseiTests: XCTestCase {
func test平成じゃない() {
let calendar = Calendar(identifier: .japanese)
let component = DateComponents(
calendar: calendar,
timeZone: nil,
era: 235, // 平成
year: 31,
import Foundation
Date.timeIntervalSinceReferenceDate
Date.timeIntervalBetween1970AndReferenceDate
Date().timeIntervalSince1970
Date().timeIntervalSinceReferenceDate
Date().addingTimeInterval(-Date().timeIntervalSinceReferenceDate)
978307200 / 60 / 60 / 24 / 365
print(String(554378506, radix: 2))