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 / 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 / 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) => {
{
const ratioConfig = (x, y) => ({
x,
y,
ratio: x / y
})
const commonRatio = [ratioConfig(1, 1), ratioConfig(4, 3), ratioConfig(16, 9), ratioConfig(16, 10)];
const getRatioConfig = (x, y) => {
@fhefh2015
fhefh2015 / iOS Shortcut Download JavaScript.txt
Created February 16, 2021 13:39 — forked from ohmika/iOS Shortcut Download JavaScript.txt
Use the bookmarklet or JavaScript in order to download the shortcut file from an icloud.com link
javascript:%22use%20strict%22;%0Alet%20iCloudUrl%20%3D%20location.href;%0Alet%20apiUrl%20%3D%20iCloudUrl.replace(/%5C/shortcuts/g,%20%22/shortcuts/api/records%22);%0Alet%20iCloudApi%20%3D%20new%20XMLHttpRequest();%0AiCloudApi.open(%22GET%22,%20apiUrl);%0AiCloudApi.responseType%20%3D%20%22text%22;%0AiCloudApi.send();%0A%0AiCloudApi.onload%20%3D%20function()%20%7B%0A%20%20let%20apiResult%20%3D%20JSON.parse(iCloudApi.response);%0A%0A%20%20function%20saveData(url)%20%7B%0A%20%20%20%20let%20a%20%3D%20document.createElement(%22a%22);%0A%20%20%20%20document.body.appendChild(a);%0A%20%20%20%20a.style%20%3D%20%22display:%20none%22;%0A%0A%20%20%20%20a.href%20%3D%20url;%0A%20%20%20%20a.download;%0A%20%20%20%20a.click();%0A%20%20%20%20window.URL.revokeObjectURL(url);%0A%20%20%7D%0A%20%20let%20downloadURL%20%3D%20apiResult.fields.shortcut.value.downloadURL;%0A%20%20let%20shortcutName%20%3D%20apiResult.fields.name.value;%0A%20%20let%20finalURL%20%3D%20downloadURL.replace(%22$%7Bf%7D%22,%20shortcutName%20+%20%22.shortcut%22
@fhefh2015
fhefh2015 / ._reactFormatting
Created February 15, 2021 11:19 — forked from iannbing/._reactFormatting
A gist for initial eslint and prettier setup for React projects
We couldn’t find that file to show.
@fhefh2015
fhefh2015 / README.md
Created December 8, 2020 14:27 — forked from chuyik/README.md
macOS 给 Git(Github) 设置代理(HTTP/SSH)
@fhefh2015
fhefh2015 / iterm2-solarized.md
Created July 19, 2020 13:16 — forked from kevin-smets/iterm2-solarized.md
iTerm2 + Oh My Zsh + Solarized color scheme + Source Code Pro Powerline + Font Awesome + [Powerlevel10k] - (macOS)

Default

Default

Powerlevel10k

Powerlevel10k

@fhefh2015
fhefh2015 / tinc-install.sh
Created April 25, 2020 08:56 — forked from jpillora/tinc-install.sh
Install and run tinc-1.1pre11 on Raspberry Pi 2 (Raspberrian)
# install tinc
apt-get update && echo "===> update deps" &&
apt-get install -y make libssl-dev zlib1g-dev liblzo2-dev libreadline-dev libncurses5-dev && echo "===> got deps" &&
curl http://www.tinc-vpn.org/packages/tinc-1.1pre11.tar.gz | tar xzvf - && echo "===> got tinc src" &&
cd tinc-1.1pre11 &&
./configure && echo "===> configured tinc" &&
make &&
make install && echo "===> installed tinc" &&
tinc --version # tinc version 1.1pre11 (built Nov 12 2015 16:25:28, protocol 17.4)
@fhefh2015
fhefh2015 / ecdh.go
Created April 23, 2020 02:12 — forked from banks/ecdh.go
// ecdh implements a simple way to perform Diffie-Hellman Key Exchange using
// Curve25519 on the command line.
//
// NOTE: this is a toy for fun. Don't use it.
//
// See https://godoc.org/golang.org/x/crypto/curve25519 and
// https://cr.yp.to/ecdh.html for more info.
//
// The final shared secret given is the raw shared secret bytes from DH and is
// not typically suitable for direct use as an encryption key as it can leak