Skip to content

Instantly share code, notes, and snippets.

View HyanCat's full-sized avatar
🤓
High Pressure

流光不加少 HyanCat

🤓
High Pressure
View GitHub Profile
@HyanCat
HyanCat / GenericDemo.swift
Created August 16, 2018 05:12
Swift generic and protocol demo.
//: Playground - noun: a place where people can play
import Foundation
// Part 1.
// Generic and Protocol.
protocol DataTransform {
static func transform(from data: Any?) -> Any?
}
@HyanCat
HyanCat / cloudSettings
Created June 14, 2018 13:11
Visual Studio Code Settings Sync Gist
{"lastUpload":"2018-06-14T13:11:03.423Z","extensionVersion":"v2.9.2"}
@HyanCat
HyanCat / cloudSettings
Last active August 9, 2020 02:37
Visual Studio Code Settings Sync Gist
{"lastUpload":"2020-08-09T02:37:24.032Z","extensionVersion":"v3.4.3"}
@HyanCat
HyanCat / archive.sh
Last active March 27, 2023 07:23
Simply archive an universal framework.
#!/bin/sh
PRODUCT_NAME=$1
FRAMEWORK_NAME=${PRODUCT_NAME/\-/\_}
BUILD_DIR="./.build"
rm -rf $BUILD_DIR
UNIVERSAL_OUTPUTFOLDER="$BUILD_DIR/$PRODUCT_NAME-universal"
mkdir -p $UNIVERSAL_OUTPUTFOLDER
@HyanCat
HyanCat / WebServer.swift
Created February 25, 2018 03:12
GCDWebServer simple demo.
//
// WebServer.swift
// WebServerDemo
//
// Created by HyanCat on 25/02/2018.
// Copyright © 2018 HyanCat. All rights reserved.
//
import Foundation
import GCDWebServer
@HyanCat
HyanCat / synchronize.swift
Created January 19, 2018 07:07
An easy way to write synchronization code for thread safety.
import Foundation
/// Define a lockable protocol which contains an internal lock.
public protocol Lockable {
/// An internal lock
var internalLock: NSLock { get }
}
// MARK: - Make NSLock is a Lockable
extension NSLock: Lockable {
@HyanCat
HyanCat / handshake.md
Created August 17, 2017 05:24
测试 HTTPS 的 TCP 和 SSL 握手时间

测试 HTTPS 的 TCP 和 SSL 握手时间

curl -w "TCP handshake: %{time_connect}, SSL handshake: %{time_appconnect}\n" -so /dev/null https://www.baidu.com

输出

@HyanCat
HyanCat / clean_archives.sh
Created June 7, 2017 02:08
Clean outdated archives.
#!/bin/bash
# 清除早期的 Archives.
echo "====>> 开始检查过期的Archives..."
day=90
dir=~/Library/Developer/Xcode/Archives
files=`find $dir -type d -name '*-*-*' -depth 1 -mtime +$day`
if [ -n "$files" ]; then