Skip to content

Instantly share code, notes, and snippets.

View davidleee's full-sized avatar

David Lee davidleee

View GitHub Profile
@davidleee
davidleee / String+Crypto.swift
Created April 13, 2018 09:20
Getting all kinds of crypted string from the original string (keep updating...)
// 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)
@davidleee
davidleee / String+KeyCode.swift
Created April 13, 2018 09:16
Retrive the key code of macOS keyboard from the keys' names
//
// 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
@davidleee
davidleee / osx_dmg_package
Created July 7, 2017 07:51 — forked from 44510/osx_dmg_package
mac osx 程序自动打包为 dmg 文件的脚本
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 坐标