Skip to content

Instantly share code, notes, and snippets.

View onhate's full-sized avatar
💭
I used to work remotely back when it wasn't mainstream

Marcelo Luiz Onhate onhate

💭
I used to work remotely back when it wasn't mainstream
View GitHub Profile
@onhate
onhate / delete_duplicate_snowplow_events_postgres.sql
Created August 10, 2023 01:34
SQL Sample to remove duplicate events by event_id and collector_tstamp on PostgreSQL
DELETE
FROM atomic.events
WHERE ctid IN (SELECT ctid
FROM (SELECT ctid, ROW_NUMBER() OVER (PARTITION BY event_id, collector_tstamp ) AS rn
FROM atomic.events) t
WHERE rn > 1);
DELETE
FROM atomic.io_snowplow_foundation_content_1
WHERE ctid IN (SELECT ctid
@onhate
onhate / hexcolor.dart
Created September 27, 2021 17:42
Hex string color to MaterialColor with swatches
import 'package:flutter/material.dart';
class HexColor extends Color {
static int getColorFromHex(String hexColor) {
hexColor = hexColor.toUpperCase().replaceAll("#", "");
if (hexColor.length == 6) {
hexColor = "FF" + hexColor;
}
return int.parse(hexColor, radix: 16);
}
@onhate
onhate / pre-signup.ts
Last active February 28, 2024 03:33
Merge AWS Cognito External Provider User with Cognito User on Pre SignUp
import { PreSignUpTriggerEvent, PreSignUpTriggerHandler } from 'aws-lambda';
import { CognitoIdentityServiceProvider } from 'aws-sdk';
const cognito = new CognitoIdentityServiceProvider();
const knownProviderNames = {
google: 'Google',
facebook: 'Facebook'
};
@onhate
onhate / executor.js
Last active April 19, 2021 20:48
Queue Executor in Vanilla Javascript / Typescript
export const waitForMillis = async (millis: number) => {
return new Promise(resolve => setTimeout(resolve, millis));
};
export const executor = (concurrency = 100) => {
let workers = 0;
let index = 0;
let queue = [];
const waitFor = async () => {
@onhate
onhate / dynamodb-graphql-dataloader.ts
Last active September 9, 2021 14:04
Zero Dependencies DynamoDB Graphql DataLoader
import { DocumentClient } from 'aws-sdk/clients/dynamodb';
import DataLoader from 'dataloader';
export type DynamodbDataloader = DataLoader<GetRequest, DocumentClient.AttributeMap | null>
interface GetRequest {
TableName: string;
Key: DocumentClient.Key;
}
@onhate
onhate / remark-auto-link.ts
Last active July 23, 2020 15:18
remark auto link workaround to generate correct link output format
@onhate
onhate / express-dynamic-routes-file-system.js
Last active January 17, 2021 11:24
Load Express Routes dynamically like Nuxt.js
const express = require('express');
const glob = require("glob");
const app = express();
glob.sync('./api/**/*.http.js', { cwd: __dirname })
.forEach(file => {
const endpoint = file.split('.http.js').join('')
.split('_').join(':')
.substr(1);
// --- TreeGrid Header ---
Component = {
// --- File information ---
Name: "Editable JavaScript TreeGrid",
Address: "http://www.treegrid.com",
Type: "TreeGrid with Gantt chart with Extended API",
Version: "9.2.12",
Release: "3. June 2013 10:52",