Skip to content

Instantly share code, notes, and snippets.

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 / hexcolor.dart
Created Sep 27, 2021
Hex string color to MaterialColor with swatches
View hexcolor.dart
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 Aug 7, 2022
Merge AWS Cognito External Provider User with Cognito User on Pre SignUp
View pre-signup.ts
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 Apr 19, 2021
Queue Executor in Vanilla Javascript / Typescript
View executor.js
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 Sep 9, 2021
Zero Dependencies DynamoDB Graphql DataLoader
View dynamodb-graphql-dataloader.ts
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 Jul 23, 2020
remark auto link workaround to generate correct link output format
View remark-auto-link.ts
@onhate
onhate / express-dynamic-routes-file-system.js
Last active Jan 17, 2021
Load Express Routes dynamically like Nuxt.js
View express-dynamic-routes-file-system.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);
View jsWithBinary-GumTreeInfiniteLoop-left.js
// --- 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",