Skip to content

Instantly share code, notes, and snippets.

@fhefh2015
fhefh2015 / 0dedict.py
Created January 11, 2023 08:28 — forked from josephg/0dedict.py
Apple dictionaries
# 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')
@fhefh2015
fhefh2015 / logback-spring.xml
Created August 25, 2022 02:23
基于springboot的Logback配置
<?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">
@fhefh2015
fhefh2015 / chrome-local-storage-api.js
Created November 21, 2021 08:49 — forked from sumitpore/chrome-local-storage-api.js
Chrome's Local StorageArea API in Synchronous way for use in Chrome extensions. Replace 'chrome.storage.local' by 'chrome.storage.sync' if you want to use Sync StorageArea
/**
* 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]);
});
@fhefh2015
fhefh2015 / AppDelegate.swift
Created November 6, 2021 09:02
Continuity Camera Demo
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)
@fhefh2015
fhefh2015 / 1.swift
Created July 15, 2021 08:31
RxSwift:Single实例:读取文件
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()
@fhefh2015
fhefh2015 / video.swift
Last active July 3, 2021 01:44
iOS:自定义navigation按钮,侧滑功能失效修复
//
// VideoPlayerController.swift
// AInOne
//
// Created by Apple on 2021/7/3.
//
import UIKit
class VideoPlayerController: UIViewController {
@fhefh2015
fhefh2015 / CustomDashedView.swift
Created June 24, 2021 02:03
CustomDashedView
//
// DashedBorderView.swift
// AInOne
//
// Created by Apple on 2021/6/23.
//
import UIKit
class DashedBorderView: UIView {
@fhefh2015
fhefh2015 / Xcode 语法高亮失效修复.sh
Last active July 17, 2021 11:53
Xcode 语法高亮失效修复: kill SourceKit
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/
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
}
@fhefh2015
fhefh2015 / index.js
Created March 11, 2021 04:23 — forked from otakustay/index.js
Compute aspect ratio
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) => {