Skip to content

Instantly share code, notes, and snippets.

@ClearlyKyle
ClearlyKyle / STR_to_Sentences.py
Created October 8, 2020 21:11
Using pysrt to convert a SRT file to a list of sentences.
import pysrt
import os
output_folder_name = "txt"
try:
os.mkdir("./{}".format(output_folder_name))
except OSError:
pass # already exists
@glowinthedark
glowinthedark / srt_subtitles_append_pinyin.py
Last active February 6, 2023 02:25
Add pinyin subtitles to chinese mandarin SRT subtitles; optionally append traditional (-t) to existing simplified; or append simplified (-s) to existing traditional
#!/usr/bin/env python3
# also see https://github.com/tkarabela/pysubs2
# DEPENDENCIES:
# pip install -U srt opencc pypinyin hanzidentifier
# URL: https://gist.github.com/glowinthedark/83daa9531dd8c4cc3963e55c1a4f3b1c
# Add pinyin subtitles to chinese mandarin SRT subtitles;
# optionally also add traditional (-t) or existing simplified;
@varenc
varenc / capstoggle.sh
Created August 19, 2020 03:53
Toggle Caps Lock light on macOS Catalina from a shell scripts/terminal
#!/usr/bin/osascript -l JavaScript
# Usage: capstoggle.sh [1 or 0, defaulting to 0]
# Pass in "1" to turn caps lock on. By default it turns caps lock off (0)
#
# Make this an executable shell script by running `chmod +x capstoggle.sh`
# Then `./capstoggle.sh 1` to turn caps lock on, and hence toggle the caps lock keyboard light!
# You can make your caps lock light flash 5 times by running this
# for i in {0..5}; do ./capstoggle.sh 1; ./capstoggle.sh 0; done
ObjC.import("IOKit");
var _cf = _cf || [],
bmak = bmak || {
ver: 1.54,
ke_cnt_lmt: 150,
mme_cnt_lmt: 100,
mduce_cnt_lmt: 75,
pme_cnt_lmt: 25,
pduce_cnt_lmt: 25,
tme_cnt_lmt: 25,
tduce_cnt_lmt: 25,
#!/bin/bash
# We can find the index of the item in the array by extracting the key, finding the lines with
# 'string' in them, and then finding the search string.
cd /System/Volumes/Data/.Spotlight-V100
search_string=$1
let index="`plutil -extract Exclusions xml1 -o - VolumeConfiguration.plist | grep string | grep -wn "${search_string}" | cut -d ':' -f 1` - 1"
!/bin/bash
launchctl stop com.apple.metadata.mds && launchctl start com.apple.metadata.mds
vers=$( sw_vers | grep BuildVersion | awk '{print substr($2,0,2)}' )
sdir="/.Spotlight-V100"
if [[ "${vers}" > "18" ]]; then
sdir="/System/Volumes/Data${sdir}"
@klausondrag
klausondrag / README.md
Last active May 9, 2020 23:52
Pinyin support for Language Learning with Netflix Extension
@Matt-Jensen
Matt-Jensen / Firebase Local Storage IndexedDb Dump.js
Created February 17, 2020 17:04
Access your Firebase Auth Token by dumping your IndexedDB session
(() => {
const asyncForEach = (array, callback, done) => {
const runAndWait = i => {
if (i === array.length) return done();
return callback(array[i], () => runAndWait(i + 1));
};
return runAndWait(0);
};
const dump = {};
@dnicolson
dnicolson / MediaRemoteEvents.m
Created December 24, 2019 18:16
Use the MediaRemote private framework to get and set the playing state of the Touch Bar based on media change events
// clang -x objective-c -framework Foundation -framework MediaRemote -F /System/Library/PrivateFrameworks TouchBarMediaKeys.m -o TouchBarMediaKeys
// ./TouchBarMediaKeys
#import <Foundation/Foundation.h>
#import <MediaPlayer/MediaPlayer.h>
enum {
kMRPlaybackStateUnknown = 0,
kMRPlaybackStatePlaying,
kMRPlaybackStatePaused,
@jamesmacfie
jamesmacfie / README.md
Created October 22, 2019 02:53
iTerm 2 - script to change theme depending on Mac OS dark mode

How to use

In iTerm2, in the menu bar go to Scripts > Manage > New Python Script

Select Basic. Select Long-Running Daemon

Give the script a decent name (I chose auto_dark_mode.py)

Save and open the script in your editor of choice.