Skip to content

Instantly share code, notes, and snippets.

View patarapolw's full-sized avatar

Pacharapol Withayasakpunt patarapolw

View GitHub Profile
@patarapolw
patarapolw / mongo-api.md
Last active October 30, 2019 18:45
MongoDB API specification
@patarapolw
patarapolw / qa-offline-first.md
Created November 7, 2019 12:33
What is the best offline-first database and asset storage for desktop apps?

What is the best offline-first database and asset storage for desktop apps?

The closest that I know, and open source too, is either Git or https://github.com/dsnopek/anki-sync-server

According to advertising, I am tempted to use Firestore, but

  • Serverless web app cannot store too many images in IndexedDB. (Nor it is efficient)

I also tried PouchDB / CouchDB, which can also store images as attachments, but I noticed that user account control is missing.

@patarapolw
patarapolw / mongo-serialize.ts
Created February 17, 2020 13:49
MongoDB serialize
const cond = {
a: new Date(),
b: /regexp/gi
}
const r = JSON.stringify(cond, function (k, v) {
const v0 = this[k]
if (v0) {
if (v0 instanceof Date) {
return { $date: v0.toISOString() }
@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 / 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 / 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 / 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 / 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
@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 / 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