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
  • 09:05 (UTC +10:00)
  • X @_shirish
View GitHub Profile
@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"
@techlab23
techlab23 / component-registration.js
Created July 24, 2020 05:21
component registration
import Vue from 'vue'
// Importing all components inside './components' folder
const req = require.context('./components/', true, /\.(js|vue)$/i);
req.keys().map(key => {
const fileNameKey = key.substr(key.lastIndexOf('/') + 1);
const name = fileNameKey.match(/\w+/)[0];
return Vue.component(name, req(key).default)
});