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
set -e | |
title='千尋影視' # dmg 文件 mount 了之后在文件系统中显示的名称 | |
background_picture_name='mac-dmg-bg.png' # dmg 文件在 mount 了之后界面中显示的背景图片路径 | |
application_name='千尋影視.app' # 应用程序的名称 | |
# Developer ID 证书的名称(名字的一部分即可,但是需要能在 Keychain Access 中唯一定位到该证书) | |
developer_id='Developer ID Application: Shanghai Truecolor Multimedia' | |
# dmg 窗口相关的一些设置,需要根据实际情况做变更 | |
window_left=200 # 窗口位置的 x 坐标 |
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
// | |
// String+KeyCode.swift | |
// Volcano-Maxhub | |
// | |
// Created by David Lee on 2018/4/13. | |
// Copyright © 2018年 MAXHUB. All rights reserved. | |
// | |
// Thanks to this answer: | |
// https://stackoverflow.com/questions/10734349/simulate-keypress-for-system-wide-hotkeys/13004403#13004403 |
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
// You should put "#import <CommonCrypto/CommonHMAC.h>" in the bridge header before using these code | |
import Foundation | |
extension String { | |
func sha256() -> String { | |
if let stringData = self.data(using: String.Encoding.utf8) as NSData? { | |
let digest = digestSHA256(source: stringData) | |
var bytes = [UInt8](repeating: 0, count: digest.length) | |
digest.getBytes(&bytes, length: digest.length) |
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 UIKit | |
extension String { | |
var glyphCount: Int { | |
let richText = NSAttributedString(string: self) | |
let line = CTLineCreateWithAttributedString(richText) | |
return CTLineGetGlyphCount(line) | |
} |
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
extension String { | |
var containsChinese: Bool { | |
for substring in self { | |
if substring.isChinese { | |
return true | |
} | |
} | |
return false | |
} | |
} |
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 Foundation | |
/// Find first differing character between two strings | |
/// | |
/// :param: s1 First String | |
/// :param: s2 Second String | |
/// | |
/// :returns: .DifferenceAtIndex(i) or .NoDifference | |
public func firstDifferenceBetweenStrings(s1: NSString, s2: NSString) -> FirstDifferenceResult { |
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
/* | |
Copyright 2017 Daniel Bocksteger | |
BOApplePencilReachability.swift | |
from https://gitlab.com/DanielBocksteger/BOApplePencilReachability | |
Inspiration from Answer on the following question | |
https://stackoverflow.com/questions/32542250/detect-whether-apple-pencil-is-connected-to-an-ipad-pro/41264961#41264961 | |
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
// https://github.com/realm/realm-js/issues/370#issuecomment-270849466 | |
export default class Realm { | |
constructor(params) { | |
this.schema = {}; | |
this.callbackList = []; | |
this.data = {}; | |
this.schemaCallbackList = {}; | |
params.schema.forEach((schema) => { | |
this.data[schema.name] = {}; | |
}); |
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
// MARK: - Swizzling | |
extension UIFont { | |
class var defaultFontFamily: String { return "Georgia" } | |
override public class func initialize() | |
{ | |
if self == UIFont.self { | |
swizzleSystemFont() | |
} | |
} |
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 switchRootViewController(rootViewController: UIViewController, animated: Bool, completion: (() -> Void)?) { | |
if animated { | |
UIView.transitionWithView(window, duration: 0.5, options: .TransitionCrossDissolve, animations: { | |
let oldState: Bool = UIView.areAnimationsEnabled() | |
UIView.setAnimationsEnabled(false) | |
self.window!.rootViewController = rootViewController | |
UIView.setAnimationsEnabled(oldState) | |
}, completion: { (finished: Bool) -> () in | |
if completion { | |
completion!() |
OlderNewer