Skip to content

Instantly share code, notes, and snippets.

View techlab23's full-sized avatar
πŸš€
Right steps

Shirish Nigam techlab23

πŸš€
Right steps
  • Techlab23
  • Brisbane, Australia
  • 18:34 (UTC +10:00)
  • X @_shirish
View GitHub Profile
@techlab23
techlab23 / esm-package.md
Created April 23, 2025 23:50 — 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.
@techlab23
techlab23 / sentry.client.ts
Created February 22, 2024 14:29
Sentry Nuxt 3 Plugin
import { defineNuxtPlugin } from '#app'
import * as Sentry from '@sentry/vue'
export default defineNuxtPlugin((nuxtApp) => {
const router = useRouter()
const config = useRuntimeConfig()
Sentry.init({
app: nuxtApp.vueApp,
dsn: config.public.sentryDsn,
@techlab23
techlab23 / csv-processor.ts
Last active January 25, 2024 06:16
Memory efficient large CSV processing
import { createReadStream } from 'node:fs';
import { parse } from 'csv-parse';
async function efficientReadAndParse() {
const readStream = createReadStream('VEStdEquip.csv', 'utf-8').pipe(parse({ delimiter: ',', columns: ['VehicleKey', 'EquipDescription'] }));
for await (const data of readStream) {
await processData(data);
}
@techlab23
techlab23 / sentry.client.ts
Created August 11, 2023 02:02
Sentry Client Plugin For Nuxt 3
import { defineNuxtPlugin } from '#app'
import * as Sentry from '@sentry/vue'
export default defineNuxtPlugin((nuxtApp) => {
const router = useRouter()
const config = useRuntimeConfig()
Sentry.init({
app: nuxtApp.vueApp,
dsn: config.public.sentryDsn,
@techlab23
techlab23 / machine.js
Created January 20, 2021 04:26
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@techlab23
techlab23 / machine.js
Last active January 19, 2021 02:24
Generated by XState Viz: https://xstate.js.org/viz
const basicDetails = {
initial: 'restore_application',
states: {
restore_application: {
on: { NEXT_CARD: 'submit_details' }
},
submit_details: {
on: { PREVIOUS_CARD: 'restore_application' },
type: 'final'
}
@techlab23
techlab23 / kernel.php
Created July 30, 2020 08:23
Laravel sanctum configuration
<?php
namespace App\Http;
use Illuminate\Foundation\Http\Kernel as HttpKernel;
use Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful;
class Kernel extends HttpKernel
{
/**
@techlab23
techlab23 / syntax.php
Created July 30, 2020 06:28
Laravel sanctum configuration
Laravel configuration
=====================
composer packages
-----------------
"php": "^7.2.5",
"laravel/framework": "^7.0",
"fruitcake/laravel-cors": "^2.0",
"laravel/sanctum": "^2.4",
@techlab23
techlab23 / login.vue
Created July 30, 2020 06:16
Login component usage (sanctum csrf-cookie route and nuxt login)
<template>
<div class="flex justify-center items-center h-screen">
<div class="w-full max-w-xs">
<form class="bg-white shadow-md rounded px-8 pt-6 pb-8 mb-4">
<div class="mb-4">
<label
class="block text-gray-700 text-sm font-bold mb-2"
for="username"
>
Username
@techlab23
techlab23 / nuxt.config.js
Created July 30, 2020 06:12
Nuxt config for laravel sanctum integration
export default {
/*
** Nuxt.js modules
*/
modules: [
// Doc: https://axios.nuxtjs.org/usage
"@nuxtjs/axios",
// Doc: https://github.com/nuxt-community/auth-module
"@nuxtjs/auth"