Skip to content

Instantly share code, notes, and snippets.

Avatar

Pacharapol Withayasakpunt patarapolw

View GitHub Profile
View wk-like-counter.user.js
// ==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 ($) {
@patarapolw
patarapolw / vue.md
Created Apr 20, 2022
Code block language tagging in Github
View vue.md

Vue

<template>
  <input :ref="el => elTextArea = el" />
</template>

HTML

@patarapolw
patarapolw / gh-deploy.sh
Last active Apr 20, 2022
Vite on Github Pages with HTML5 History Mode
View gh-deploy.sh
#!/usr/bin/env bash
set -e
rm -rf dist
GH=1 yarn build
GIT_URL=$(git remote get-url origin)
cd dist
@patarapolw
patarapolw / markdown-preprocess.ts
Last active Apr 8, 2022
Markdown pre-processing
View markdown-preprocess.ts
const MD_INDEX = 'README'
function mdRemoveIndex(path: string, ext = '.md') {
if (path.endsWith('/' + MD_INDEX + ext)) {
path = path.substring(0, path.length - ext.length - MD_INDEX.length - 1)
}
return path
}
@patarapolw
patarapolw / ime2furigana.user.js
Last active Apr 15, 2022
Adds furigana markup functionality to Discourse. With IME caching and auto-append furigana.
View ime2furigana.user.js
// ==UserScript==
// @name IME2Furigana
// @namespace ime2furigana
// @version 1.8a
// @description Adds furigana markup functionality to Discourse. When inputting kanji with an IME, furigana markup is automatically added.
// @author Sinyaven (modified by polv)
// @license MIT-0
// @match https://community.wanikani.com/*
// @icon https://furigana.info/img/apple-touch-icon.png
// @grant none
View markdown-it-plugin.user.js
// ==UserScript==
// @name markdown-it-plugin for WaniKani Community
// @namespace https://community.wanikani.com
// @version 0.1
// @description markdown-it-ruby for WaniKani Community. Nothing more than necessary
// @author polv
// @match https://community.wanikani.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=wanikani.com
// @grant none
// ==/UserScript==
@patarapolw
patarapolw / exp-tower.py
Last active Aug 17, 2021
Estimation of exponential tower of the same numbers (e.g. Graham's number)
View exp-tower.py
from decimal import Decimal, getcontext
from typing import Union
class BigInt:
"""BigInt gives astronomically big integer's approximation and easy to read strings"""
_first = ""
_last = ""
_length = None # BigInt
@patarapolw
patarapolw / paths.md
Created Jul 26, 2021
Magic paths in Linux
View paths.md

These magic paths include,

Icon path-less filename

~/.local/share/icons/hicolor/scalable/apps/xxx.{png,svg}

Tricks

@patarapolw
patarapolw / tsserver.log
Created Oct 6, 2020
yarn2 pnp crashes in VSCode on Ubuntu Linux
View tsserver.log
Info 0 [21:34:26.242] Starting TS Server
Info 1 [21:34:26.242] Version: 4.0.3
Info 2 [21:34:26.242] Arguments: /usr/share/code/code /home/patarapolw/projects/make-pdf/packages/mdx/.yarn/sdks/typescript/lib/tsserver.js --useInferredProjectPerProjectRoot --enableTelemetry --cancellationPipeName /tmp/vscode-typescript1000/b3a7d2e0f18b6fdfd22c/tscancellation-1bee301e776227680305.tmp* --logVerbosity verbose --logFile /home/patarapolw/.config/Code/logs/20201006T204449/exthost1/vscode.typescript-language-features/tsserver-log-8QIv8P/tsserver.log --globalPlugins typescript-vscode-sh-plugin --pluginProbeLocations /usr/share/code/resources/app/extensions/typescript-language-features --locale en --noGetErrOnBackgroundUpdate --validateDefaultNpmLocation
Info 3 [21:34:26.242] Platform: linux NodeVersion: 12 CaseSensitive: true
Info 4 [21:34:26.242] ServerMode: undefined syntaxOnly: false hasUnknownServerMode: undefined
Info 5 [21:34:26.247] Binding...
Info 6 [21:34:26.264] request:
{"seq":0,"type"
@patarapolw
patarapolw / textarea.ts
Last active Jun 19, 2020
Card link with image generator
View textarea.ts
// @ts-ignore
import { getMetadata } from 'page-metadata-parser'
import he from 'he'
export function addImagedLinksToTextAreaOnPaste(el: HTMLTextAreaElement) {
const pasteEvent = async (ev: ClipboardEvent) => {
const { items } = ev.clipboardData || {}
if (items) {
for (const k of Object.keys(items)) {
const item = (items as any)[k] as DataTransferItem