Skip to content

Instantly share code, notes, and snippets.

View renatoaraujoc's full-sized avatar

Renato Araujo Carneiro renatoaraujoc

View GitHub Profile
@renatoaraujoc
renatoaraujoc / routing.ts
Created April 22, 2024 11:02
Type-safe routing
import {
type AfterViewInit,
Directive,
inject,
Injectable,
Input
} from '@angular/core';
import { type NavigationExtras, Router, RouterLink } from '@angular/router';
import type { Prettify } from '@rcambiental/global/typescript';
import type { z } from 'zod';
@renatoaraujoc
renatoaraujoc / FileSystemModule.ts
Last active January 15, 2024 16:15
GCP GCS FileSystem - Emulates the Local File System
import { FileSystemService } from './FileSystemService';
import { GCPGCSFileSystem } from './GCPGCSFileSystem';
import { LocalFileSystem } from './LocalFileSystem';
import { StorageOptions } from '@google-cloud/storage';
import { ConfigurableModuleBuilder, Module } from '@nestjs/common';
/**
* This configuration object dictates which instance of
* ApiFileSystemService will be used.
*/
@renatoaraujoc
renatoaraujoc / sync-nx-buildable-libraries.ts
Last active May 15, 2023 15:42
[Nx] Syncs all buildable libraries peerDependencies with root's package.json ones and updates its version.
import { execSync } from 'child_process';
import fs from 'fs';
import { ProjectGraph } from 'nx-cloud/lib/core/models/run-context.model';
import path from 'path';
// Get a list of all projects in the workspace
execSync('npx nx dep-graph --file=dep-graph.json');
const depGraphData = JSON.parse(fs.readFileSync('dep-graph.json', 'utf-8'));
// get root package.json data dependencies
@renatoaraujoc
renatoaraujoc / google-tag-manager.service.ts
Last active April 25, 2023 10:48
Angular - GoogleTagManager Service that includes Partytown to be run when App is ready
/*
* Base implementation of this service, modify it to your needs.
* Pushing events to dataLayer has to be included yet, working on it (like page_view for router nav events)
*/
import { DOCUMENT, isPlatformServer } from '@angular/common';
import {
inject,
Injectable,
InjectionToken,
PLATFORM_ID,
@renatoaraujoc
renatoaraujoc / modify_table_primary_key.sql
Last active September 27, 2019 19:09
Modify MySQL Table ID DataType with FKs
SET global group_concat_max_len = 4294967295;
SET @tableSchema = "SCHEMA_HERE";
SET @tableName = "TABLE_HERE";
SET @tablePrimaryDefinition = "int(10) unsigned not null auto_increment";
SET @referencedTablesColumnDefinition = "int(10) unsigned";
SELECT DISTINCT kcu.TABLE_NAME,
kcu.TABLE_SCHEMA,
kcu.COLUMN_NAME,
kcu.CONSTRAINT_NAME,
kcu.REFERENCED_TABLE_NAME,