Skip to content

Instantly share code, notes, and snippets.

View ohlulu's full-sized avatar
😎
happy test happy deliver

ohlulu ohlulu

😎
happy test happy deliver
View GitHub Profile
@ohlulu
ohlulu / output-color.sh
Created October 24, 2023 02:43 — forked from WestleyK/output-color.sh
printf color output
#!/bin/bash
#
# Created by: Westley K
# Date: Aug 14, 2018
#
# run this in your terminal, and
# you will get nice colors and effects!
#
extension Date {
func add(_ component: Calendar.Component, value: Int) -> Date {
return Calendar.current.date(byAdding: component, value: value, to: self)!
}
}
@propertyWrapper
struct BeginEndDate {
@ohlulu
ohlulu / InfiniteLoopView.swift
Last active July 10, 2020 02:39
Infinite-LoopView
import UIKit
final class InfiniteLoopView<T, Cell>: UIView,
UICollectionViewDelegate,
UICollectionViewDataSource,
UICollectionViewDelegateFlowLayout
where Cell: UICollectionViewCell {
private lazy var collectionView: UICollectionView = {
@ohlulu
ohlulu / docker-compose.yml
Created May 2, 2020 06:14
docker-compose (wordpress+mysql)
version: '3.1'
services:
wordpress:
image: wordpress
restart: always
ports:
- 80:80
environment:
extension Double {
/// 無條件進位至小數
/// - Parameter decimal: 第幾位
func ceiling(toDecimal decimal: Int) -> Double {
let numberOfDigits = abs(pow(10.0, Double(decimal)))
if self.sign == .minus {
return Double(Int(self * numberOfDigits)) / numberOfDigits
} else {
return Double(ceil(self * numberOfDigits)) / numberOfDigits
@ohlulu
ohlulu / TaiwanCitys.json
Last active December 5, 2019 07:31
TaiwanCitys
{
"citys": [
{"name": "基隆市", "area": [ { "name": "仁愛區", "code": "200"}, { "name": "信義區", "code": "201"}, { "name": "中正區", "code": "202"}, { "name": "中山區", "code": "203"}, { "name": "安樂區", "code": "204"}, { "name": "暖暖區", "code": "205"}, { "name": "七堵區", "code": "206"} ] },
{"name": "台北市", "area": [ { "name": "中正區", "code": "100" }, { "name": "大同區", "code": "103" }, { "name": "中山區", "code": "104" }, { "name": "松山區", "code": "105" }, { "name": "大安區", "code": "106" }, { "name": "萬華區", "code": "108" }, { "name": "信義區", "code": "110" }, { "name": "士林區", "code": "111" }, { "name": "北投區", "code": "112" }, { "name": "內湖區", "code": "114" }, { "name": "南港區", "code": "115" }, { "name": "文山區", "code": "116" } ] },
{"name": "新北市", "area": [ { "name": "萬里區", "code": "207" }, { "name": "金山區", "code": "208" }, { "name": "板橋區", "code": "220" }, { "name": "汐止區", "code": "221" }, { "name": "深坑區", "code": "222" }, { "name": "石碇區", "code": "223" }, { "name": "瑞芳區", "code": "224" }, { "name": "平溪區", "co
@ohlulu
ohlulu / APIRouter_with_Alamofire.swift
Last active September 10, 2019 02:55
APIRouter Alamofire
import Foundation
import Alamofire
struct HTTPHeader {
enum Field: String {
case contentType = "Content-Type"
case acceptType = "Accept"
}
@objc func buttonPressed() {
let vc = PresentSecondViewController()
animation.destinationPoint = button.center
vc.transitioningDelegate = animation
vc.modalPresentationStyle = .custom
animation.interaction.wireGesture(on: vc)
present(vc, animated: true, completion: nil)
}
class UpToDownIneraction: UIPercentDrivenInteractiveTransition {
// ...
@objc func handleGesture(_ gestureRecoginizer: UIPanGestureRecognizer) {
let gestureView = gestureRecoginizer.view!
let trainsiton = gestureRecoginizer.translation(in: gestureView)
switch gestureRecoginizer.state {
case .began:
print("began")
class UpToDownIneraction: UIPercentDrivenInteractiveTransition {
// ...
func wireGesture(on viewController: UIViewController) {
presentingViewController = viewController
let gesture = UIPanGestureRecognizer(target: self, action: #selector(handleGesture(_:)))
viewController.view.addGestureRecognizer(gesture)
}