Skip to content

Instantly share code, notes, and snippets.

View YK-Unit's full-sized avatar
🐬
swimming in computing-ocean

YorkFish YK-Unit

🐬
swimming in computing-ocean
View GitHub Profile
@Pranit-Harekar
Pranit-Harekar / WKWebViews+keyboardRequiresUserInteraction.swift
Last active February 1, 2019 01:27
Add keyboardRequiresUserInteraction to WKWebViews iOS 11.3
import Foundation
import WebKit
typealias ClosureType = @convention(c) (Any, Selector, UnsafeRawPointer, Bool, Bool, Bool, Any?) -> Void
extension WKWebView{
var keyboardDisplayRequiresUserAction: Bool? {
get {
return self.keyboardDisplayRequiresUserAction
}
@lattner
lattner / TaskConcurrencyManifesto.md
Last active April 25, 2024 18:22
Swift Concurrency Manifesto
@lattner
lattner / async_swift_proposal.md
Last active April 21, 2024 09:43 — forked from oleganza/async_swift_proposal.md
Concrete proposal for async semantics in Swift

Async/Await for Swift

Introduction

Modern Cocoa development involves a lot of asynchronous programming using closures and completion handlers, but these APIs are hard to use. This gets particularly problematic when many asynchronous operations are used, error handling is required, or control flow between asynchronous calls gets complicated. This proposal describes a language extension to make this a lot more natural and less error prone.

This paper introduces a first class Coroutine model to Swift. Functions can opt into to being async, allowing the programmer to compose complex logic involving asynchronous operations, leaving the compiler in charge of producing the necessary closures and state machines to implement that logic.

@atsepkov
atsepkov / universal-framework.sh
Last active February 18, 2021 06:26 — forked from cromandini/universal-framework.sh
This run script will build the iphoneos and iphonesimulator schemes and then combine them into a single framework using the lipo tool (including all the Swift module architectures). This version works with Cocoapods, merging simulator and device architectures for intermediate libraries as well. To use this script, go to Product > Scheme > Edit S…
exec > /tmp/${PROJECT_NAME}_archive.log 2>&1
UNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/${CONFIGURATION}-universal
if [ "true" == ${ALREADYINVOKED:-false} ]
then
echo "RECURSION: Detected, stopping"
else
export ALREADYINVOKED="true"
@efremidze
efremidze / Example.swift
Last active October 30, 2017 08:21 — forked from gavrix/Example.swift
protocol LoginProvider {
func login()
}
class EmailLoginProvider: LoginProvider {
var email: String
var password: String
init(email: String, password: String) {
self.email = email
self.password = password
@xcatliu
xcatliu / (已失效)中国区用户在开启 GitHub 两步验证中遇到的问题
Last active March 7, 2024 02:53
(已失效)中国区用户在开启 GitHub 两步验证中遇到的问题
2023.8.28
据多名网友回复,此方法已失效。
最新解决办法请参考此贴:[v2ex: 请问 github 的两步验证(two-factor authentication)大家是怎么做的?](https://www.v2ex.com/t/967533)
https://www.v2ex.com/t/967533
---
@fcanas
fcanas / Distance.swift
Created May 21, 2015 15:11
Creating a Numeric Type : Distance
public struct Distance :NumericType {
public var value :Double
public init(_ value: Double) {
self.value = value
}
}
extension Distance :IntegerLiteralConvertible {
public init(integerLiteral: IntegerLiteralType) {
self.init(Double(integerLiteral))
@daltonclaybrook
daltonclaybrook / cocoapods-bundle-id
Last active January 21, 2022 22:36
A post install script for CocoaPods that changes the bundle identifier of all pods to the one specified.
post_install do |installer|
installer.project.targets.each do |target|
target.build_configurations.each do |config|
if config.name == 'BREnterprise'
config.build_settings['CODE_SIGN_IDENTITY[sdk=iphoneos*]'] = 'iPhone Distribution: The Carter Group LLC'
config.build_settings['PROVISIONING_PROFILE'] = '${BR_ENTERPRISE_PROVISIONING_PROFILE}'
end
end
end
@leftclickben
leftclickben / gist:322b7a3042cbe97ed2af
Last active June 7, 2023 10:58
Steps to migrate from SVN to GitLab

Steps to migrate from SVN to GitLab

This process worked for me. I take no responsibility for any damage or loss incurred as a result of following or not following these steps or, for that matter, anything else you might do or not do.

Setup

  • SVN is hosted at svn.domain.com.au.
  • SVN is accessible via http (other protocols should work).
  • GitLab is hosted at git.domain.com.au and:
@Leehro
Leehro / semaphore.m
Created October 30, 2013 19:18
I love this. Use a dispatch_semaphore_t to limit how many blocks you dispatch to a queue.
dispatch_semaphore_t semaphore = dispatch_semaphore_create(1);
// Then in some loop ...
if(dispatch_semaphore_wait(semaphore, DISPATCH_TIME_NOW) == 0) {
dispatch_async(queue, ^{
// Some code that needs to run but doesn't need to fill up the queue.
//
dispatch_semaphore_signal(semaphore);
});