Skip to content

Instantly share code, notes, and snippets.

View patarapolw's full-sized avatar

Pacharapol Withayasakpunt patarapolw

View GitHub Profile
@patarapolw
patarapolw / Google Sheets API for TypeScript.ts
Last active March 14, 2024 15:38
Google Sheets API for TypeScript
// yarn add googleapis@27 @types/node
import fs from "fs";
import readline from "readline";
import {google} from "googleapis";
import { OAuth2Client } from "google-auth-library";
const CRED_PATH = "secret/credentials.json";
const TOKEN_PATH = "secret/token.json";
const SCOPES = ["https://www.googleapis.com/auth/spreadsheets.readonly"];
@patarapolw
patarapolw / all-info-expander-all.user.js
Last active March 14, 2023 01:35
Automatically click "Show All Information"
// ==UserScript==
// @name WaniKani All Info Expander
// @namespace http://www.wanikani.com
// @version 0.1
// @description Automatically click "Show All Information"
// @author polv
// @match *://www.wanikani.com/*/session*
// @icon https://www.google.com/s2/favicons?sz=64&domain=wanikani.com
// @grant none
// ==/UserScript==
@patarapolw
patarapolw / custom-font.user.js
Last active December 8, 2022 02:04
Userscript to force certain fonts
// ==UserScript==
// @name Custom font
// @namespace polv/wanikani
// @version 0.1
// @description Custom font for a CSS selector
// @author You
// @match https://www.wanikani.com/*
// @grant none
// ==/UserScript==
@patarapolw
patarapolw / gh-deploy.sh
Last active October 5, 2022 13:32
Vite on Github Pages with HTML5 History Mode
#!/usr/bin/env bash
set -e
rm -rf dist
GH=1 yarn build
GIT_URL=$(git remote get-url origin)
cd dist
@patarapolw
patarapolw / wk-external-definition.user.js
Last active October 1, 2022 22:12
WaniKani External Definition UserScript
// ==UserScript==
// @name WaniKani JJ External Definition
// @namespace http://www.wanikani.com
// @version 0.11.1
// @description Get JJ External Definition from Weblio, Kanjipedia
// @author polv
// @author NicoleRauch
// @match *://www.wanikani.com/*/session*
// @match *://www.wanikani.com/*vocabulary/*
// @match *://www.wanikani.com/*kanji/*
@patarapolw
patarapolw / ime2furigana.user.js
Last active September 12, 2022 10:03
Adds furigana markup functionality to Discourse. With IME caching and auto-append furigana.
// ==UserScript==
// @name IME2Furigana (modified by polv)
// @namespace polv/ime2furigana
// @version 1.8
// @description Adds furigana markup rendering to WK Community. When inputting kanji with an IME, furigana markup can be automatically added.
// @author Sinyaven (modified by polv)
// @license MIT-0
// @match https://community.wanikani.com/*
// @homepageURL https://community.wanikani.com/t/39109/147
// @icon https://furigana.info/img/apple-touch-icon.png
@patarapolw
patarapolw / 0-yomichan-terms.ts
Last active September 3, 2022 14:58
Yomichan Vocab-Kanji lookup
import { ankiConnect } from '@/ankiconnect'
import { kata2hira } from '@/kana'
import { load as cheerio } from 'cheerio'
import { readFileSync, writeFileSync } from 'fs'
async function main() {
const filename = 'tmp/vocab.tsv'
const txt = readFileSync(filename, 'utf-8')
const qs = txt
.split('\n')
@patarapolw
patarapolw / regex-japanese.txt
Created September 2, 2022 16:02 — forked from terrancesnyder/regex-japanese.txt
Regex for Japanese
Regex for matching ALL Japanese common & uncommon Kanji (4e00 – 9fcf) ~ The Big Kahuna!
([一-龯])
Regex for matching Hirgana or Katakana
([ぁ-んァ-ン])
Regex for matching Non-Hirgana or Non-Katakana
([^ぁ-んァ-ン])
Regex for matching Hirgana or Katakana or basic punctuation (、。’)
@patarapolw
patarapolw / jp-sentence-db.py
Last active August 20, 2022 13:24
Personalized Japanese sentence (from transcript) database, with searching; based on tokenization and POS tagging.
import sqlite3
from pathlib import Path
import regex
import sudachipy
ROOT = Path(__file__).parent
sudachi = sudachipy.Dictionary(dict_type="full").create()
@patarapolw
patarapolw / wk-like-counter.user.js
Last active June 4, 2022 09:25
WaniKani Community Like Counter from https://community.wanikani.com/t/userscript-like-counter/27389 + adapted for mobile
// ==UserScript==
// @name WaniKani Forums: Like counter
// @namespace http://tampermonkey.net/
// @version 3.1.7
// @description Keeps track of the likes you've used and how many you have left... supposedly.
// @author Kumirei
// @include https://community.wanikani.com*
// @grant none
// ==/UserScript==
;(function ($) {