Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Kishikawa Katsumi kishikawakatsumi

🏠
Working from home
View GitHub Profile
View tutorial.swift
struct Player {
var name: String
var highScore: Int = 0
var history: [Int] = []
init(_ name: String) {
self.name = name
}
}
View shell.rb
require 'open3'
stdout, stderr, status = Open3.capture3(*['xcrun', 'xccov', 'view', '--report', '/path.to/result.xcresult', '--json'])
puts stdout # => {...}
View TableHeaderView-AutoLayout.swift
...
headerView.translatesAutoresizingMaskIntoConstraints = false
tableView.tableHeaderView = headerView
NSLayoutConstraint.activate([
headerView.topAnchor.constraint(equalTo: tableView.topAnchor),
headerView.widthAnchor.constraint(equalTo: tableView.widthAnchor),
headerView.centerXAnchor.constraint(equalTo: tableView.centerXAnchor)])
tableView.tableHeaderView?.layoutIfNeeded()
View gist:14b240f8d427d3dc0f7a6df15215e5a4
import Cocoa
import AVFoundation
class ViewController: NSViewController, AVCaptureVideoDataOutputSampleBufferDelegate {
private let session = AVCaptureSession()
override func viewDidLoad() {
super.viewDidLoad()
view.wantsLayer = true
@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
You can’t perform that action at this time.