Skip to content

Instantly share code, notes, and snippets.

View ha1f's full-sized avatar

はるふ ha1f

View GitHub Profile
@ha1f
ha1f / CalendarUtil.swift
Last active January 10, 2017 01:27
カレンダー周り。日本語アプリでも英語表示したい部分もあると思うので
//
// CalendarUtil.swift
// Musubi
//
// Created by はるふ on 2016/10/26.
// Copyright © 2016年 はるふ. All rights reserved.
//
import Foundation
@ha1f
ha1f / ShareActionController.swift
Last active July 4, 2017 07:24
ShareActionController.swift
//
// ShareActionController.swift
// Musubi
//
// Created by はるふ on 2017/07/04.
// Copyright © 2017年 はるふ. All rights reserved.
//
import UIKit
import SafariServices
@ha1f
ha1f / Optional.swift
Last active July 5, 2017 03:41
Optional.swift
import Foundation
enum Optional<T> {
case none
case some(T)
init() {
self = .none
}
MIT License
Copyright (c) 2017 はるふ(ha1f)
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:
//
// PlaceHolderedTextView.swift
// Musubi
//
// Created by はるふ on 2016/11/29.
// Copyright © 2016年 はるふ. All rights reserved.
//
import UIKit
@ha1f
ha1f / randomString.swift
Created September 11, 2017 03:04
randomString
import Foundation
import UIKit
private func arrayBetween(_ c1: String, _ c2: String) -> [UInt32] {
guard let s1 = c1.unicodeScalars.first?.value,
let s2 = c2.unicodeScalars.first?.value else {
return []
}
return (s1 < s2 ? (s1...s2) : (s2...s1)).map { $0 }
}
//
// LanguageDetector(Swift3.x).swift
// Musubi
//
// Created by はるふ on 2017/07/12.
// Copyright ©ha1f 2017年 line. All rights reserved.
//
import Foundation
//
// Rgba.swift
// ha1f-chat
//
// Created by ST20591 on 2017/07/19.
// Copyright © 2017年 ha1f. All rights reserved.
//
import UIKit
extension Dictionary {
func duplicated() -> Dictionary<Key, Value> {
return reduce(into: [Key: Value]()) { (dict, item) in
dict[item.key] = item.value
}
}
}
extension UIViewController {
private class ExtendedBottomView: UIView { }
/// Create bottom View which covers from bottom of the screen to the
/// bottom edge of the bottomAccessoryView.
/// (useful on iPhone X only)
/// Make sure not to call more than once (typically, on viewDidLoad),
/// and bottomAccessoryView has added as subview.
///
/// - parameter bottomAccessoryView: a target View to decide the