Skip to content

Instantly share code, notes, and snippets.

View patarapolw's full-sized avatar

Pacharapol Withayasakpunt patarapolw

View GitHub Profile
@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 / markdown-it-plugin.user.js
Last active April 4, 2022 14:49
How do get Markdown-it plugins like https://github.com/lostandfound/markdown-it-ruby inside Discourse
// ==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 August 17, 2021 15:12
Estimation of exponential tower of the same numbers (e.g. Graham's number)
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 July 26, 2021 11:20
Magic paths in Linux

These magic paths include,

Icon path-less filename

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

Tricks

@patarapolw
patarapolw / tsserver.log
Created October 6, 2020 14:40
yarn2 pnp crashes in VSCode on Ubuntu Linux
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 June 19, 2020 20:35
Card link with image generator
// @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
@patarapolw
patarapolw / docker.log
Created June 4, 2020 04:08
ENOENT errors, `.staging`? #13528
Step 4/18 : COPY packages/web/package.json packages/web/package-lock.json /app/
---> 5fd150936598
Step 5/18 : RUN npm i
---> Running in 21fdced2ae4f
npm WARN tar ENOENT: no such file or directory, open '/app/node_modules/.staging/@vue/cli-shared-utils-84f45b3f/LICENSE'
npm WARN tar ENOENT: no such file or directory, open '/app/node_modules/.staging/firebase-1e298806/firebase-auth.js'
npm WARN tar ENOENT: no such file or directory, open '/app/node_modules/.staging/buefy-fca9137d/dist/buefy.esm.js'
npm WARN tar ENOENT: no such file or directory, open '/app/node_modules/.staging/vue-template-compiler-8672be05/index.js'
npm WARN tar ENOENT: no such file or directory, open '/app/node_modules/.staging/cacache-7216ea6a/lib/util/tmp.js'
npm WARN tar ENOENT: no such file or directory, open '/app/node_modules/.staging/vue-template-compiler-8672be05/package.json'
@patarapolw
patarapolw / swagger.go
Last active May 30, 2020 20:47
GoDoc doesn't like Multiline Markdown rendering in VSCode
// @title Blueprint Swagger API
// @version 1.0
// @description Swagger API for Golang Project Blueprint.
// @termsOfService http://swagger.io/terms/
// @contact.name API Support
// @contact.email martin7.heinz@gmail.com
// @license.name MIT
// @license.url https://github.com/MartinHeinz/go-project-blueprint/blob/master/LICENSE
@patarapolw
patarapolw / .qovery.yml
Last active May 29, 2020 11:49
Remark42 setup file that is Nuxt Universal-enabled
application:
name: remark42-deploy
project: remark42
cloud_region: aws/eu-west-3
publicly_accessible: true
storage:
- name: srv
type: ssd
size: 1GB
mount_point: /srv/var
@patarapolw
patarapolw / sort.ts
Last active July 27, 2020 04:01
Mongo Sort
/**
* @see https://docs.mongodb.com/manual/reference/operator/aggregation/sort/
*/
function getType(m: any): number {
if (typeof m === 'undefined') {
return 0
} else if (typeof m === 'object') {
if (!m) {
/**
* null