Skip to content

Instantly share code, notes, and snippets.

@FbN
FbN / knex-async-modify.js
Created April 11, 2023 09:13
knex async modify
const before = (target, f) => {
const then = target.then.bind(target)
target.then = (resolve, reject) =>
f(target).then(() => then(resolve, reject), reject)
return target
}
Knex.QueryBuilder.extend('amodify', function (f) {
const q = this
const clone = this.clone.bind(this)
@FbN
FbN / .prettierrc.json
Created August 7, 2022 08:25
.prettierrc.json
{
"trailingComma": "none",
"tabWidth": 4,
"semi": false,
"singleQuote": true,
"quoteProps": "as-needed",
"arrowParens": "avoid",
"parser": "typescript"
}
@FbN
FbN / eslint_plugins.sh
Last active August 7, 2022 08:40
last step
yarn add  - dev eslint-config-prettier
yarn add  - dev eslint-config-standard
yarn add  - dev eslint-plugin-import
yarn add  - dev eslint-plugin-n
yarn add  - dev eslint-plugin-prettier
yarn add  - dev eslint-plugin-promise
@FbN
FbN / config.lua
Created August 7, 2022 08:16
step2 - lua config
-- Tested on LunarVim
-- optional: set your prefered indent with size
vim.opt.shiftwidth = 4
vim.opt.tabstop = 4
-- load required null-ls references
local h = require("null-ls.helpers")
local cmd_resolver = require("null-ls.helpers.command_resolver")
local methods = require("null-ls.methods")
@FbN
FbN / step1.sh
Created August 7, 2022 08:03
Step 1
npm add --location=global prettier-eslint-cli
@FbN
FbN / pg-related-use.js
Created April 28, 2022 16:39
pg-related usage
@FbN
FbN / vite.config.js
Last active April 18, 2024 08:36
vite.config.js node built-in polyfills
// yarn add --dev @esbuild-plugins/node-globals-polyfill
import { NodeGlobalsPolyfillPlugin } from '@esbuild-plugins/node-globals-polyfill'
// yarn add --dev @esbuild-plugins/node-modules-polyfill
import { NodeModulesPolyfillPlugin } from '@esbuild-plugins/node-modules-polyfill'
// You don't need to add this to deps, it's included by @esbuild-plugins/node-modules-polyfill
import rollupNodePolyFill from 'rollup-plugin-node-polyfills'
export default {
resolve: {
alias: {
@FbN
FbN / A.js
Created March 9, 2021 16:12
Clojure Protocols Inspired last param type polimorfism
export const of = x => ({ '@@type': 'A', x })
export const f1 = a => a.x
f1.arity = 1
export const f2 = c => a => a.x + c
f2.arity = 2
export const f3 = d => c => a => a.x + c + d
f3.arity = 3
@FbN
FbN / A.js
Created March 9, 2021 14:03
Closure Like Protocol
export const f1 = a => a.x
f1.arity = 1
export const f2 = c => a => a.x + c
f2.arity = 2
export const f3 = d => c => a => a.x + c + d