Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

Kishikawa Katsumi kishikawakatsumi

🏠
Working from home
Block or report user

Report or block kishikawakatsumi

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@kishikawakatsumi
kishikawakatsumi / DispatchGroup.swift
Last active Feb 29, 2020
Executing asynchronous tasks sequentially in Swift
View DispatchGroup.swift
let q = DispatchQueue(label: "q")
let group = DispatchGroup()
group.enter()
q.async {
loadA(completion: {
// Do something...
group.leave()
})
}
View TabView.swift
import SwiftUI
struct TabView: View {
var views: [TabBarItem]
@State var selectedIndex: Int = 0
init(_ views: [TabBarItem]) {
self.views = views
}
View Download and push bitrise.yml
lane :sync_bitrise_yml do
if !ENV['CI']
next
end
Dir.chdir("#{ENV['PWD']}") do
sh "curl -O -H 'Authorization: token #{ENV['BITRISE_ACCESS_TOKEN']}' 'https://api.bitrise.io/v0.1/apps/#{ENV['BITRISE_APP_SLUG']}/bitrise.yml'"
unless system('git diff --quiet --exit-code')
sh 'git add bitrise.yml'
View CocoaPods Pre-Built binaries
#!/bin/bash
set -exo pipefail
PROJECT_ROOT=$(cd $(dirname $0); cd ..; pwd)
PODS_ROOT="$PROJECT_ROOT/Pods"
PODS_PROJECT="$PODS_ROOT/Pods.xcodeproj"
SYMROOT="$PODS_ROOT/Build"
(cd "$PROJECT_ROOT"; bundle install --path=vendor/bundle --binstubs=vendor/bin)
View Podfile
platform :ios, '10.3'
install! 'cocoapods', integrate_targets: false
inhibit_all_warnings!
use_modular_headers!
target 'Shared' do
use_frameworks!
View gist:157ea34bb32aaa25ffe45ff40262e3bc
#!/usr/bin/env bash
git reset --hard
git checkout $1
xcodebuild build -scheme Demo -sdk iphonesimulator -derivedDataPath build
xcrun simctl install 89955894-3580-47CE-86FD-5C3E41850418 ~/work/Demo/build/Build/Products/Debug-iphonesimulator/Demo.app
xcrun simctl install F28EC412-2D31-4F56-9705-670823B8B554 ~/work/Demo/build/Build/Products/Debug-iphonesimulator/Demo.app
View setup
#!/bin/sh
set -ex
bundle install --path=vendor/bundle --binstubs=vendor/bin
bundle exec pod install
carthage checkout
carthage build --no-use-binaries --platform ios --cache-builds BonMot
carthage build --no-use-binaries --platform ios --cache-builds bugsnag-cocoa
@kishikawakatsumi
kishikawakatsumi / UIScrollView+UIPageControl.swift
Created Apr 29, 2018
UIScrollView + UIPageControl with RxSwift
View UIScrollView+UIPageControl.swift
import RxSwift
import RxCocoa
fileprivate extension Reactive where Base: UIScrollView {
fileprivate var currentPage: Observable<Int> {
return didEndDecelerating.map({
let pageWidth = self.base.frame.width
let page = floor((self.base.contentOffset.x - pageWidth / 2) / pageWidth) + 1
return Int(page)
})
@kishikawakatsumi
kishikawakatsumi / OptionParser.swift
Created Apr 5, 2018
SwiftPM ArgumentParser usage
View OptionParser.swift
let parser = ArgumentParser(commandName: "swiftfmt", usage: "swiftfmt filename [options]", overview: "Format Swift source code")
let filenameArgument = parser.add(positional: "filename", kind: String.self)
let configrationOption = parser.add(option: "--configuration", kind: String.self)
let versionOption = parser.add(option: "--version", kind: Bool.self)
let verboseOption = parser.add(option: "--verbose", kind: Bool.self, usage: "Show more debugging information")
let result = try parser.parse(Array(CommandLine.arguments.dropFirst()))
if let version = result.get(versionOption) {
print("Swiftfmt 0.1.0")
@kishikawakatsumi
kishikawakatsumi / Info.plist
Created Oct 5, 2016
NSAllowsArbitraryLoads=YES on debug build
View Info.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
You can’t perform that action at this time.