Skip to content

Instantly share code, notes, and snippets.

@tung1404
tung1404 / pino_trace_caller.js
Created June 5, 2024 07:30 — forked from miguelmota/pino_trace_caller.js
Node.js pino logger show caller filename and line number
import path from 'path'
import pino from 'pino'
const STACKTRACE_OFFSET = 2
const LINE_OFFSET = 7
const { symbols : { asJsonSym} } = pino
function traceCaller (pinoInstance) {
const get = (target, name) => name === asJsonSym ? asJson : target[name]
@tung1404
tung1404 / client.tsx
Created June 5, 2024 04:40 — forked from mishushakov/client.tsx
A React hook for calling Next.js Server Actions from client components
'use client'
import { test } from './server'
import { useServerAction } from './hook'
export default function Home() {
const { data, loading, error, execute: testAction } = useServerAction(test)
if (loading) return <div>Loading...</div>
if (error) return <div>Error: {error.message}</div>
@tung1404
tung1404 / esm-package.md
Created May 31, 2024 09:16 — forked from sindresorhus/esm-package.md
Pure ESM package

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@tung1404
tung1404 / jwtUntrusted.kt
Created March 26, 2024 07:40 — forked from bastman/jwtUntrusted.kt
kotlin parse jwt untrusted - ignore signature
// see: https://github.com/auth0-blog/spring-boot-jwts/blob/master/src/main/java/com/example/security/TokenAuthenticationService.java
//Example:
val json:String= JwtUntrusted.parseClaimsUntrustedToJson("Bearer xxx")
object JwtUntrusted {
// requires (gradle): compile group: 'io.jsonwebtoken', name: 'jjwt', version: '0.9.0'
private val JSON = jacksonObjectMapper()
fun removeSignature(jwt:String) = jwt.replaceAfterLast(".", "").trim()
@tung1404
tung1404 / Django installations on Ubuntu.md
Created December 6, 2023 14:56 — forked from 101t/Django installations on Ubuntu.md
Quick Start with Django installations on Ubuntu

Django installations on Ubuntu

Installing Python in system

First step install dependencies.

sudo apt-get install git python-setuptools python-pip python-dev \
&& sudo apt-get install python3-pip python3-dev virtualenv

then install local envirement of Django project.

@tung1404
tung1404 / docker-compose.yml
Created November 7, 2023 04:41 — forked from benoitpetit/docker-compose.yml
complete Gitlab installation and a runner with docker
version: '4.5'
services:
# GITLAB
gitlab-web:
image: 'gitlab/gitlab-ce:latest'
restart: always
container_name: gitlab-web
hostname: '192.168.0.14'
environment:
@tung1404
tung1404 / Jest_GitLab_CI.md
Created November 7, 2023 04:32 — forked from rishitells/Jest_GitLab_CI.md
Setting up Jest tests and coverage in GitLab CI

Configuring Jest Tests in GitLab CI

1. Add GitLab CI configuration file in the root

In the root of your project, add .gitlab-ci.yml with the configuration below.

image: node:latest

stages:
@tung1404
tung1404 / opentracing.yaml
Created August 2, 2023 03:13 — forked from wshihadeh/opentracing.yaml
Tarefik opentracing
version: '3.7'
networks:
traefik:
external: true
services:
pink:
@tung1404
tung1404 / docker-compose.yml
Created August 1, 2023 04:17 — forked from pyrou/docker-compose.yml
Use https://traefik.me SSL certificates for local HTTPS without having to touch your /etc/hosts or your certificate CA.
version: '3'
services:
traefik:
restart: unless-stopped
image: traefik:v2.0.2
ports:
- "80:80"
- "443:443"
labels:
- "traefik.http.services.traefik.loadbalancer.server.port=8080"
@tung1404
tung1404 / .eslintignore
Created April 29, 2023 09:29 — forked from vdelacou/.eslintignore
React Vite Typescript Eslint
vite.config.ts
src/vite-env.d.ts
dist