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
-- modified version from https://bear.app/faq/Import%20&%20export/Migrate%20from%20Apple%20Notes/ | |
-- fixed to write text in UTF8 encoding | |
set exportFolder to (choose folder) as string | |
-- Simple text replacing | |
on replaceText(find, replace, subject) | |
set prevTIDs to text item delimiters of AppleScript | |
set text item delimiters of AppleScript to find | |
set subject to text items of subject |
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
void main() { | |
final start = DateTime.now(); | |
final end = start.add(const Duration(days: 0, hours: 30, minutes: 1, seconds: 9)); | |
print(start); | |
print(end); | |
print(getDurationText(start, end)); | |
} | |
String getDurationText(DateTime start, DateTime end) { | |
Duration delta = end.difference(start); |
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
#!/usr/bin/osascript | |
on run argv | |
log "before: " & output volume of (get volume settings) | |
set volume output volume argv as text | |
log "after: " & output volume of (get volume settings) | |
end run |
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
#!/usr/bin/env python3 | |
# spec: simplest python web server with range support and multithreading that takes root path, | |
# port and bind address as command line arguments; by default uses the current dir as webroot, | |
# port 8000 and bind address of 0.0.0.0 | |
import argparse | |
import functools | |
import os |
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
#!/usr/bin/env bash | |
# builds mpv & mpv.app on Apple silicon (M1 / M2) Macs | |
# run this script from the root directory of the mpv repo | |
# if anything fails, gtfo | |
set -ex | |
meson setup build | |
meson compile -C build |
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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
# mirorred from https://code.activestate.com/recipes/577138-embed-lyrics-into-mp3-files-using-mutagen-uslt-tag/ | |
import os | |
import sys | |
import codecs | |
from mutagen.mp3 import MP3 | |
from mutagen.id3 import ID3NoHeaderError | |
from mutagen.id3 import ID3, TIT2, TALB, TPE1, TPE2, COMM, USLT, TCOM, TCON, TDRC |
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
#!/usr/bin/env bash | |
if [ "$#" -lt 2 ]; then | |
printf "Usage:\n $(basename $0) MyVideo.mp4 MySubtitles.srt\n" | |
else | |
ffmpeg -i "$1" -vf "subtitles=${2}, scale=540:-1" -acodec copy "${1%.mp4}-sub-540p.mp4" | |
fi | |
# FFMPEG custom build options |
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
#!/usr/bin/env bash | |
for device in $(diskutil list | awk '/Linux/ {print $NF}') ; do | |
read -p ">>> Found linux device: $device. Mount? y/n <<< " answer | |
if [[ "$answer" =~ [yY] ]]; then | |
mount_point="$HOME/mnt/$device" | |
mkdir -p $mount_point |
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
#!/usr/bin/env python3 | |
import argparse | |
import sys | |
from pathlib import Path | |
import srt | |
from opencc import OpenCC | |
simp2trad = OpenCC('s2twp') |
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
from fairseq.models.transformer import TransformerModel | |
zh2en = TransformerModel.from_pretrained( | |
'/path/to/checkpoints', | |
checkpoint_file='checkpoint_best.pt', | |
data_name_or_path='data-bin/wmt17_zh_en_full', | |
bpe='subword_nmt', | |
bpe_codes='data-bin/wmt17_zh_en_full/zh.code' | |
) | |
zh2en.translate('你好 世界') |