Skip to content

Instantly share code, notes, and snippets.


Ethan Huang ethanhuang13

View GitHub Profile
View ClampTests.swift
// A challenge from
// Screenshots of performance tests
import XCTest
let maxValue = 100
let minValue = 0
final class ClampTests: XCTestCase {
func testMeasureNaiveCompare() throws {
ethanhuang13 / VirtualKeyboard.swift
Last active May 29, 2021
MacBook Air M1 Zhuyin Keyboard written with SwiftUI ~=300 LOC, < 4hrs
View VirtualKeyboard.swift
// VirtualKeyboard.swift
// MacBook Air M1 Zhuyin Keyboard
// Written with SwiftUI ~=300 LOC, < 4hrs
// Created by Ethan Huang on 2021/1/13.
// Twitter: @ethanhuang13
import SwiftUI
struct VirtualKeyboard: View {
ethanhuang13 / FacebookAuth.swift
Last active Jul 14, 2021
FacebookAuth is for iOS app developers who need to support Facebook login but don't want to use the official SDK
View FacebookAuth.swift
// FacebookAuth.swift
// GitHub: ethanhuang13
// Twitter: @ethanhuang13
import AuthenticationServices
import SafariServices

Keybase proof

I hereby claim:

  • I am ethanhuang13 on github.
  • I am ethanhuang13 ( on keybase.
  • I have a public key ASDAEzUKl1dvIut56bNB61xAdNlHIdUIFYlJ2bJ3k8SlAAo

To claim this, I am signing this object:

ethanhuang13 / dear$
Created Aug 8, 2019
Important Updates to CNCopyCurrentnetworkInfo API in iOS 13
View dear$

Dear $firstName,

As we announced at WWDC19, we're making changes to further protect user privacy and prevent unauthorized location tracking. Starting with iOS 13, the CNCopyCurrentNetworkInfo API will no longer return valid Wi-Fi SSID and BSSID information. Instead, the information returned by default will be:

SSID: “Wi-Fi” or “WLAN” (“WLAN" will be returned for the China SKU) BSSID: "00:00:00:00:00:00"

If your app is using this API, we encourage you to adopt alternative approaches that don’t require Wi-Fi or network information. Valid SSID and BSSID information from CNCopyCurrentNetworkInfo will still be provided to VPN apps, apps that have used NEHotspotConfiguration to configure the current Wi-Fi network, and apps that have obtained permission to access user location through Location Services.

Test your app on the latest iOS 13 beta to make sure it works properly. If your app requires valid Wi-Fi SSID and BSSID information to function, you can do the following:

View TrackerTests.swift
let tracker = Tracker()
// Which one do you prefer? Consider labels, indendentation, readability...
// 1 func trackEvent(_ event: Event, _ parameters: EventParameter...)
.itemName("An Item"),
.list("List name"))
// 2. func track(event: Event, parameters: EventParameter...)
tracker.track(event: .viewItem, parameters:
ethanhuang13 / HexColor.swift
Created Jan 2, 2019
@dynamicMemberLookup example
View HexColor.swift
// An (useless) example of Swift 4.2 @dynamicMemberLookup attributes.
// let color1 = HexColor().cbcbcb
// let color2 = HexColor().000000 // This can also be built. Will be treat as "000000"
import Foundation
struct HexColor {
subscript(dynamicMember member: String) -> UIColor? {
do {
View .swiftlint.yml
# Updated for SwiftLint 0.29.2
# See all rules:
# Opt-in (Default Disabled)
- anyobject_protocol
- array_init
- attributes
- closure_body_length
- closure_spacing
ethanhuang13 /
Last active Jun 29, 2018
App Store Review Guidelines

App Store Review Guidelines

1. Safety

When people install an app from the App Store, they want to feel confident that it’s safe to do so—that the app doesn’t contain upsetting or offensive content, won’t damage their device, and isn’t likely to cause physical harm from its use. We’ve outlined the major pitfalls below, but if you’re looking to shock and offend people, the App Store isn’t the right place for your app.

  • 1.1 Objectionable Content Apps should not include content that is offensive, insensitive, upsetting, intended to disgust, or in exceptionally poor taste. Examples of such content include:
    • 1.1.1 Defamatory, discriminatory, or mean-spirited content, including references or commentary about religion, race, sexual orientation, gender, national/ethnic origin, or other targeted groups, particularly if the app is likely to humiliate, intimidate, or place a targeted individual or group in harm’s way. Professional political satirists and humorists are generally exempt from this requirement
ethanhuang13 / SKErrorThrowsAndCatch.swift
Created Apr 14, 2018
Some Error can be catch but not thrown
View SKErrorThrowsAndCatch.swift
import StoreKit
//extension SKError: Error { } // Uncomment this line to make it throwable
func throwError() throws {
throw SKError.unknown // Can not be thrown. Thrown error code type 'SKError.Code' does not conform to 'Error'
do {
try throwError()