This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# If run without a name, open any current repo | |
if [ -z "$1" ]; then | |
URL=$(git remote get-url origin) | |
URL=${URL/"git@github.com:"/"https://github.com/"} | |
URL=${URL/".git"/""} | |
open $URL | |
else | |
open "https://github.com/$1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Cocoa | |
import CoreBluetooth | |
import PlaygroundSupport | |
class BTHelper: NSObject, CBCentralManagerDelegate, CBPeripheralDelegate { | |
var centralManager: CBCentralManager | |
override init() { | |
self.centralManager = CBCentralManager(delegate: nil, queue: nil) | |
super.init() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
App Store Review Guidelines | |
Introduction | |
Apps are changing the world, enriching people’s lives, and enabling developers like you to innovate like never before. As a result, the App Store has grown into an exciting and vibrant ecosystem for millions of developers and more than a billion users. Whether you are a first time developer or a large team of experienced programmers, we are excited that you are creating apps for the App Store and want to help you understand our guidelines so you can be confident your app will get through the review process quickly. | |
The guiding principle of the App Store is simple - we want to provide a safe experience for users to get apps and a great opportunity for all developers to be successful. We do this by offering a highly curated App Store where every app is reviewed by experts and an editorial team helps users discover new apps every day. For everything else there is always the open Internet. If the App Store model and guidelines are not best for your app or business idea th |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func getProcessStartTime() -> TimeInterval { | |
let pid = ProcessInfo.processInfo.processIdentifier | |
var procInfo = kinfo_proc() | |
var cmd: [Int32] = [CTL_KERN, KERN_PROC, KERN_PROC_PID, pid] | |
var size = MemoryLayout.stride(ofValue: procInfo) | |
if sysctl(&cmd, UInt32(cmd.count), &procInfo, &size, nil, 0) == 0 { | |
// tv_sec is timestamp measured in second; tv_usec is the rest fraction part in microsecond | |
return Double(procInfo.kp_proc.p_un.__p_starttime.tv_sec) * 1000.0 + Double(procInfo.kp_proc.p_un.__p_starttime.tv_usec) / 1000.0 | |
} else { | |
print("Can't get information of process \(pid)") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protocol Action {} | |
struct Reducer<State> { | |
let reduce: (State, Action) -> State | |
} | |
struct Increment: Action {} | |
struct Decrement: Action {} | |
func on<State, A>(_ actionType: A.Type, reduce: @escaping (State, A) -> State) -> Reducer<State> { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 特殊的數字我沒處理,會 fail。例如 subnormal 或者 NaN | |
// 用法: 0.94.exact() // "0.939999999999999946709294817992486059665679931640625" | |
// | |
// main.swift | |
// FloatingPoint | |
// | |
// Created by Yung-Luen Lan on 2019/8/27. | |
// Copyright © 2019 yllan. All rights reserved. | |
// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// Call this at main() | |
/// return: time in milliseconds | |
func getPreMainTime() -> Double { | |
let currentTimeIntervalInMilliSecond = Date().timeIntervalSince1970 * 1000.0 | |
var procInfo = kinfo_proc() | |
let pid = ProcessInfo.processInfo.processIdentifier | |
var cmd: [Int32] = [CTL_KERN, KERN_PROC, KERN_PROC_PID, pid] | |
var size = MemoryLayout.stride(ofValue: procInfo) | |
// Retrieve information of current process | |
if sysctl(&cmd, UInt32(cmd.count), &procInfo, &size, nil, 0) == 0 { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MulticastDelegate <T> { | |
private let delegates: NSHashTable<AnyObject> = NSHashTable.weakObjects() | |
func add(delegate: T) { | |
delegates.add(delegate as AnyObject) | |
} | |
func remove(delegate: T) { | |
for oneDelegate in delegates.allObjects.reversed() { | |
if oneDelegate === delegate as AnyObject { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum Equality<T: Equatable> { | |
case equal(T) | |
case notEqual | |
} | |
func == <T: Equatable>(lhs: T, rhs: T) -> Equality<T> { | |
if lhs == rhs { | |
return .equal(lhs) | |
} else { | |
return .notEqual |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Usage: | |
// | |
// Facebook: | |
// | |
// 1. Follow this guide (WITHOUT setting up a URL scheme in Xcode): | |
// https://github.com/fullstackreact/react-native-oauth/issues/76#issuecomment-335902057 | |
// | |
// 2. call startFacebookAuthenticationSession(appID:completionHandler:) on a window: | |
// |
OlderNewer