Skip to content

Instantly share code, notes, and snippets.

@vpnry
vpnry / to_ipa.py
Created November 22, 2020 13:44
Convert English to IPA - Using Python3 module eng_to_ipa
# Convert English text to IPA using eng_to_ipa
# @pnry - version 0.0.1 - public domain
# pip3 install eng_to_ipa
# Usage:
# toIPA(f, 1): paragraph by paragraph with Eng paragraph
# toIPA(f, 0): insert IPA transcription next to word
# Input file
f = "AOP Appendix.fm - sadhu"
@vpnry
vpnry / move-file-preserve-structure.sh
Created November 26, 2020 15:33
Move files with specific exts while preserving their directory structures
# Move files while preserving its directory structures
# From https://unix.stackexchange.com/a/59159
FILEext=".*\.\(avi\|mp3\|mp4\)"
SOURCE=/home/d/dev/dev/D/A/
DEST=/home/d/dev/dev/D/BB/
mkdir -p "$DEST"
FROM ghcr.io/renderinc/heroku-app-builder:heroku-22 AS builder
# The FROM statement above triggers the following steps
# 1. Copy the contents of the directory containing this Dockerfile to a Docker image
# 2. Detect the language
# 3. Build the app using the appropriate Heroku buildpack. All Heroku's official buildpacks are supported.
@vpnry
vpnry / tab_to_sqlite.py
Created March 13, 2023 11:24
Stardict tabfile into Sqlite3 with python
import os
import sqlite3
def stardict_tab_to_sqlite3(tab_file: str) -> None:
# Generated with the support of ChatGPT OpenAI
# 13 Mar 2023
# Check if the dictionary.db file exists and delete it if it does
if os.path.exists('dictionary.db'):
@vpnry
vpnry / myenmy_template_2023_script.users.js
Last active April 2, 2023 14:58
Myanmar Popup Dictionary Userscript
// ==UserScript==
// @name MYENMY-Dictionary
// @namespace https://gist.github.com/vpnry/f4d16b7ab71f30f4a6f5d4a3d66bd5da
// @version 2023.04.02.2129
// @description MEM-Dictionary For Tampermonkey UserScript
// @author uPNRY with the assistance of ChatGPT
// @match http://*/*
// @match https://*/*
// @exclude http://google.com/*
// @exclude https://google.com/*
@vpnry
vpnry / nodejs_wrap_word_with_tag.js
Last active March 26, 2023 17:06
Nodejs script that wraps words in HTML file with a specified tag, Pyhon script to split file HTML file into smaller parts
/**
* NodeJS script that wrap all words into tags.
* npm install cheerio
* Generated with the help of ChatGPT :)
**/
const fs = require("fs");
const path = require("path");
const cheerio = require("cheerio");
@vpnry
vpnry / getClickedWord.js
Created March 26, 2023 17:14
JavaScript algorithm/snippet to split concatenated words to word again according to dictionary input, get clicked word functions
function getClickedWord(e) {
/** Generated with Bing AI ChatGPT */
var defiEl = document.getElementById("dictionary-res");
var tocDivBox = document.getElementById("tocDivBox");
/** Not getting words on these elements */
if (
!defiEl.contains(e.target) &&
!tocDivBox.contains(e.target) &&
@vpnry
vpnry / phpwin_browser.php
Created April 1, 2023 18:36
phpwin iPadOS browser
<?php
// Generated with the support of ChatGPT
// This script is to be used with phpwin app on iPadOS
// To add dictionary funtions on the HTML web page
// Check if the user has submitted a URL
if(isset($_POST['url'])) {
// Retrieve the URL from the form input
$url = $_POST['url'];
@vpnry
vpnry / nodejs_split_smaller_dict.js
Created April 1, 2023 18:38
nodejs split dictionary
const fs = require("fs");
const PARTS = 10;
// Load the original dictionary from a file
const DICTOBJ = require("./DICTOBJ.js");
// Split the keys into 4 roughly equal PARTS
const keys = Object.keys(DICTOBJ);
const chunkSize = Math.ceil(keys.length / PARTS);
const chunks = [];
@vpnry
vpnry / mms_text_to_speech.py
Created May 25, 2023 01:42
MMS speech fairseq TTS app
'''
Run with
PYTHONPATH=$PYTHONPATH:./fairseq/vits python3 app.py --model_dir LANG --file_path text.txt
LANG is your model language
'''
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.