Skip to content

Instantly share code, notes, and snippets.

View dsxsxsxs's full-sized avatar

dsxs dsxsxsxs

View GitHub Profile
@dsxsxsxs
dsxsxsxs / infinitePaging.swift.swift
Created March 22, 2021 06:53
infinitePaging.swift
import RxSwift
import RxRelay
protocol IssueListRepositoryProtocol {
func fetch(page: Int) -> Single<[Issue]>
}
final class IssueListUseCase {
private let fetchTrigger = PublishRelay<FetchMode>()
@dsxsxsxs
dsxsxsxs / ninePatchDemo.swift
Created October 8, 2020 02:08 — forked from brandhill/ninePatchDemo.swift
Equivalent Android 9-patch for iOS and Swift 3.0 (multiple stretchable areas)
// origin
UIImageView *unHandleImg = [[UIImageView alloc] initWithFrame:CGRectMake((SCREENWIDTH-200)/2, 100, 200, 30)];
unHandleImg.image = [UIImage imageNamed:@"theImage"];
[self.view addSubview:unHandleImg];
// with stretchable
UIImageView *handleImg = [[UIImageView alloc] initWithFrame:CGRectMake((SCREENWIDTH-200)/2, 200, 200, 30)];
UIImage *img = [UIImage imageNamed:@"theImage"];
// stretchable areas
img = [img resizableImageWithCapInsets:UIEdgeInsetsMake(35, 35, 35, 35) resizingMode:UIImageResizingModeStretch];
@dsxsxsxs
dsxsxsxs / StickToFirst.FlatMapFirst.FlatMapMaxPublisher1.Test.swift
Created September 16, 2020 15:18
Tests to make sure how StickToFirst, FlatMapFirst, FlatMapMaxPublisher1 Behaves
// Created by dsxsxsxs on 2020/09/15.
//
import RxSwift
import RxRelay
import RxTest
import XCTest
import Combine
@testable import RxPlayground
class FlatMapTest: XCTestCase {
@dsxsxsxs
dsxsxsxs / StickToFirst.swift
Last active September 18, 2020 03:45
A Combine implementation that behaves just like RxSwift's FlatMapFirst
//
// StickToFirst.swift
//
// Created by dsxsxsxs on 2020/09/16.
//
import Foundation
import Combine
public struct StickToFirst<P, Upstream>: Publisher where P: Publisher, P == Upstream.Output, Upstream: Publisher, P.Failure == Upstream.Failure {
@dsxsxsxs
dsxsxsxs / In.comparision.to.RxSwift.flatMapFirst.alternatives.for.combine.swift
Last active September 16, 2020 09:42
In.comparision.to.RxSwift.flatMapFirst.alternatives.for.combine.swift
// Created by dsxsxsxs on 2020/09/15.
// Copyright © 2020 me.dsxsxsxs.rx.playground. All rights reserved.
//
import RxSwift
import RxRelay
import RxTest
import XCTest
import Combine
@testable import RxPlayground
@dsxsxsxs
dsxsxsxs / Fastfile
Last active January 31, 2019 08:30
Minimum fastfile to automate testflight deployment
default_platform(:ios)
platform :ios do
desc "Push a new beta build to TestFlight"
lane :beta do
build_app(scheme: "MUFG", include_bitcode: false, export_xcargs: "-allowProvisioningUpdates")
upload_to_testflight(skip_waiting_for_build_processing: true)
end
end
@dsxsxsxs
dsxsxsxs / sizeOfString.swift
Created January 15, 2019 03:14
swift 4 size of string
extension String {
var size: CGSize {
return size()
}
public func size(usingFont font: UIFont?) -> CGSize {
let f = font ?? UIFont.systemFont(ofSize: 16)
let attributes = [NSAttributedStringKey.font: f]
return self.size(withAttributes: attributes)
@dsxsxsxs
dsxsxsxs / fetch_carthage_licenses.sh
Last active January 29, 2018 08:45
simple script that fetches licenses from all of your carthage dependencies and convert it into a plist.
#!/bin/sh
# fetch_cart_licenses.sh
# dsxs
#
# Created by dsxs on 2018/1/18.
# Copyright © 2018年 dsxsxsxs. All rights reserved.
# It'll be a good idea to automate this task by adding a run script into your build phase just like below.
# ${PROJECT_DIR}/fetch_carthage_licenses.sh ${PROJECT_DIR}
@dsxsxsxs
dsxsxsxs / gist:dd00e805c7ad13e4c24c4ca28a8b0d06
Created December 22, 2017 17:49
Super simple EventEmitter with disposebag
//
// EventEmitter.swift
// dsxs
//
// Created by dsxs on 2017/7/28.
// Copyright © 2017年 dsxs. All rights reserved.
//
import Foundation
@dsxsxsxs
dsxsxsxs / easing.js
Created November 2, 2017 06:03 — forked from gre/easing.js
Simple Easing Functions in Javascript - see https://github.com/gre/bezier-easing
/*
* Easing Functions - inspired from http://gizma.com/easing/
* only considering the t value for the range [0, 1] => [0, 1]
*/
EasingFunctions = {
// no easing, no acceleration
linear: function (t) { return t },
// accelerating from zero velocity
easeInQuad: function (t) { return t*t },
// decelerating to zero velocity