Skip to content

Instantly share code, notes, and snippets.

Avatar

Pacharapol Withayasakpunt patarapolw

View GitHub Profile
@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
@patarapolw
patarapolw / docker.log
Created Jun 4, 2020
ENOENT errors, `.staging`? #13528
View docker.log
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
GoDoc doesn't like Multiline Markdown rendering in VSCode
View swagger.go
// @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
Remark42 setup file that is Nuxt Universal-enabled
View .qovery.yml
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 Jul 27, 2020
Mongo Sort
View sort.ts
/**
* @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
View mongo-serialize.ts
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 / qa-offline-first.md
Created Nov 7, 2019
What is the best offline-first database and asset storage for desktop apps?
View qa-offline-first.md

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-api.md
Last active Oct 30, 2019
MongoDB API specification
View mongo-api.md
@patarapolw
patarapolw / type-check.js
Last active Aug 23, 2019
JavaScript instance type checking.
View type-check.js
function isSameType(a, b) {
const tA = typeof a;
const tB = typeof b;
if (tA !== "object") {
return tA === typeof b;
} else if (tB === "object") {
return a.constructor === b.constructor;
}
return tA === tB; // always false???
}