Skip to content

Instantly share code, notes, and snippets.

View olragon's full-sized avatar
👨‍💻
I may be slow to respond.

Long Nguyen olragon

👨‍💻
I may be slow to respond.
  • Ho Chi Minh City, Viet Nam
View GitHub Profile
@olragon
olragon / benchmark-bun-deno-node.md
Created August 29, 2023 03:49
Benchmark Bun, Deno & NodeJS web servers
Framework Average Get (/) Params, query & header Post JSON
uws (node) 98,742.06 117,931.1 106,347.08 71,948
hyper-express (node) 82,449.5 118,198.57 88,546.88 40,603.05
bun (bun) 81,971.373 99,946.51 78,488.13 67,479.48
elysia (bun) 79,643.103 98,266.18 76,637.37 64,025.76
vixeny (bun) 79,508.623 96,996.36 79,585.35 61,944.16
stricjs (bun) 79,120.123 97,804.01 78,028.85 61,527.51
hono (bun) 75,293.96 95,430.31 70,915.01 59,536.56
bun-web-standard (bun) 73,925.933 88,856.78 70,520.02 62,401
@olragon
olragon / readme.md
Created August 21, 2023 02:51
Obsidian - Clip Link to Daily bookmarklet
  1. Go to https://caiorss.github.io/bookmarklet-maker/
  2. Input Title, paste to Code, replace YOUR_VAULT_NAME_HERE, change or replace YOUR_FOLDER_HERE_OR_REMOVE (eg: Daily/)
window.open(`obsidian://new
	?vault=YOUR_VAULT_NAME_HERE
	&append=1
	&file=${encodeURIComponent('YOUR_FOLDER_HERE_OR_REMOVE' + new Date(new Date().getTime() - (new Date).getTimezoneOffset()).toISOString().split('T')[0])}
	&content=${encodeURIComponent(`\n## ${document.title}\nLink: [${window.location.href}](${window.location.href})`)}
`)
@olragon
olragon / elysia-compression.ts
Last active August 17, 2023 01:32
Elysia's plugin for response compression, support gzip & deflare
// fork of elysia-compression
// changes:
// 1/ use gzip, deflate from node:zlib,
// 2/ use async version,
// 3/ check accept-encoding header,
// 4/ prevent unexpected download because of application/octet-stream
import {Context, Elysia} from "elysia";
import {gzip, deflate, ZlibOptions} from "zlib";
@olragon
olragon / postgraphile+4.13.0.patch
Last active October 28, 2024 20:43
Postgraphile plugin for Elysia
diff --git a/node_modules/postgraphile/build/postgraphile/http/createPostGraphileHttpRequestHandler.js b/node_modules/postgraphile/build/postgraphile/http/createPostGraphileHttpRequestHandler.js
index 73bc159..1b1d23d 100644
--- a/node_modules/postgraphile/build/postgraphile/http/createPostGraphileHttpRequestHandler.js
+++ b/node_modules/postgraphile/build/postgraphile/http/createPostGraphileHttpRequestHandler.js
@@ -717,7 +717,14 @@ function createPostGraphileHttpRequestHandler(options) {
operationName,
}, (graphqlContext) => {
pgRole = graphqlContext.pgRole;
- const graphqlResult = graphql_1.execute(gqlSchema, queryDocumentAst, null, graphqlContext, variables, operationName);
+ const graphqlResult = graphql_1.execute({
@olragon
olragon / bing.txt
Last active June 24, 2023 08:32 — forked from JoeyBurzynski/crawler-user-agent-strings-with-descriptions.txt
Bot & Crawler User Agents Strings with Descriptions
Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm) Chrome/
Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)
Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5X Build/MMB29P) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/W.X.Y.Z Mobile Safari/537.36 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)
Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm) Chrome/W.X.Y.Z Safari/537.36
Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5X Build/MMB29P) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/W.X.Y.Z Mobile Safari/537.36 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)
Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; MicrosoftPreview/2.0; +https://aka.ms/MicrosoftPreview) Chrome/W.X.Y.Z Safari/537.36
Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5X Build/MMB29P) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/W.X.Y.Z Mobile Safari/537.36 (compatible; MicrosoftPre
@olragon
olragon / meteor-matb33-collection-hooks.d.ts
Created November 30, 2022 03:38
Type definition for meteor/matb33:collection-hooks
declare module 'meteor/matb33:collection-hooks' {
import { Meteor } from "meteor/meteor"
type TGlobalOptions = {
all?: any
insert?: any
update?: any
upsert?: any
find?: any
findOne?: any
remove?: any
#!/usr/bin/env bash
# 1. Use bash. Using zsh or fish or any other, will make it hard for others to understand / collaborate. Among all shells, bash strikes a good balance between portability and DX.
# 2. Just make the first line be #!/usr/bin/env bash, even if you don’t give executable permission to the script file.
# 3. Use the .sh (or .bash) extension for your file. It may be fancy to not have an extension for your script, but unless your case explicitly depends on it, you’re probably just trying to do clever stuff. Clever stuff are hard to understand.
# 4. When a command fails, bash exits instead of continuing with the rest of the script.
set -o errexit
# 5. This will make the script fail, when accessing an unset variable.
set -o nounset
# 6. This will ensure that a pipeline command is treated as failed, even if one command in the pipeline fails.
set -o pipefail
@olragon
olragon / create-env-file-from-sys-env.sh
Last active April 24, 2021 09:41
caprover-invoiceninja
#!/bin/sh
for ENV_VAR in $(echo $ENV_LIST | tr "," "\n")
do
if grep -q "^$ENV_VAR=" .env; then
sed -i "s/$ENV_VAR=.*/$ENV_VAR=$(printenv $ENV_VAR)/g" .env
else
echo "$ENV_VAR=$(printenv $ENV_VAR)" >> .env
fi
done
@olragon
olragon / webm-to-mp3
Created March 13, 2021 06:12
webm to mp3 with ffmpeg
#!/usr/bin/env bash
if [ "$#" -ne 2 ]; then
echo "webm-to-mp3 [input.webm] [output.mp3]"
exit
fi
ffmpeg -i "$1" -vn -ab 128k -ar 44100 -y "$2";
# Requirements: ffmpeg
# Save to: /usr/local/bin/webm-to-mp3
@olragon
olragon / numberToText.js
Last active September 14, 2019 03:33
Vietnamese number to text @ MIT
/**
* Convert number to text
*
* @param number
* @param prefix
*/
function numberToText(number, prefix = '') {
// số, tên thường, tên hàng chục > 20, tên hàng chục > 10, =< 20
let range1 = [
[0, 'không', '', ''],