This file contains hidden or 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
# Thanks to commenters for providing the base of this much nicer implementation! | |
# Save and run with $ python 0dedict.py | |
# You may need to hunt down the dictionary files yourself and change the awful path string below. | |
# This works for me on MacOS 10.14 Mohave | |
from struct import unpack | |
from zlib import decompress | |
import re | |
filename = '/System/Library/Assets/com_apple_MobileAsset_DictionaryServices_dictionaryOSX/9f5862030e8f00af171924ebbc23ebfd6e91af78.asset/AssetData/Oxford Dictionary of English.dictionary/Contents/Resources/Body.data' | |
f = open(filename, 'rb') |
This file contains hidden or 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
<?xml version="1.0" encoding="UTF-8" ?> | |
<!-- 来源:https://juejin.cn/post/6844903972143104007 --> | |
<!-- 级别从高到低 OFF 、 FATAL 、 ERROR 、 WARN 、 INFO 、 DEBUG 、 TRACE 、 ALL --> | |
<!-- 日志输出规则 根据当前ROOT 级别,日志输出时,级别高于root默认的级别时 会输出 --> | |
<!-- 以下 每个配置的 filter 是过滤掉输出文件里面,会出现高级别文件,依然出现低级别的日志信息,通过filter 过滤只记录本级别的日志 --> | |
<!-- scan 当此属性设置为true时,配置文件如果发生改变,将会被重新加载,默认值为true。 --> | |
<!-- scanPeriod 设置监测配置文件是否有修改的时间间隔,如果没有给出时间单位,默认单位是毫秒。当scan为true时,此属性生效。默认的时间间隔为1分钟。 --> | |
<!-- debug 当此属性设置为true时,将打印出logback内部日志信息,实时查看logback运行状态。默认值为false。 --> | |
<configuration scan="true" scanPeriod="60 seconds" debug="false"> |
This file contains hidden or 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
/** | |
* Retrieve object from Chrome's Local StorageArea | |
* @param {string} key | |
*/ | |
const getObjectFromLocalStorage = async function(key) { | |
return new Promise((resolve, reject) => { | |
try { | |
chrome.storage.local.get(key, function(value) { | |
resolve(value[key]); | |
}); |
This file contains hidden or 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 | |
@main | |
class AppDelegate: NSObject, NSApplicationDelegate { | |
func applicationDidFinishLaunching(_ aNotification: Notification) { | |
// Insert code here to initialize your application | |
let myWindow = NSWindow() | |
let style: NSWindow.StyleMask = [.closable, .miniaturizable, .titled] | |
myWindow.isOpaque = true | |
myWindow.styleMask.insert(style) |
This file contains hidden or 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 loadText(from name: String) -> Single<String> { | |
enum FileReadError: Error { | |
case fileNotFount | |
case unreadable | |
case encodingFailed | |
} | |
return Single.create { | |
single in | |
let disposable = Disposables.create() |
This file contains hidden or 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
// | |
// VideoPlayerController.swift | |
// AInOne | |
// | |
// Created by Apple on 2021/7/3. | |
// | |
import UIKit | |
class VideoPlayerController: UIViewController { |
This file contains hidden or 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
// | |
// DashedBorderView.swift | |
// AInOne | |
// | |
// Created by Apple on 2021/6/23. | |
// | |
import UIKit | |
class DashedBorderView: UIView { |
This file contains hidden or 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
ps aux | grep SourceKit | grep -v grep | awk '{print $2}' | xargs kill -9 | |
# How to kill results from ps & grep | Altar Moss | |
# https://altarmoss.wordpress.com/2017/05/27/how-to-kill-results-from-ps-grep/ |
This file contains hidden or 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 printLog<T>(message: T, | |
file: String = #file, | |
method: String = #function, | |
line: Int = #line) | |
{ | |
#if DEBUG | |
print("\((file as NSString).lastPathComponent)[\(line)], \(method): \(message)") | |
#endif | |
} |
This file contains hidden or 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
const isApproximateInteger = value => { | |
const min = Math.floor(value); | |
const max = Math.ceil(value); | |
return value - min <= 0.01 || max - value <= 0.01; | |
}; | |
const MAX_TRY = 120; | |
const computeToRatio = (width, height) => { |
NewerOlder