Skip to content

Instantly share code, notes, and snippets.

View levymateus's full-sized avatar
🏠
Working from home

Levy Mateus Macedo levymateus

🏠
Working from home
View GitHub Profile
@levymateus
levymateus / main.ts
Last active December 6, 2025 00:55
Angular Counter (RxJS)
import 'zone.js';
import {Component, OnInit } from '@angular/core';
import {bootstrapApplication} from '@angular/platform-browser';
import { Observable } from 'rxjs';
class Counter {
intervalId = -1
count = 0
@levymateus
levymateus / App.jsx
Last active December 4, 2025 21:02
Util React Hooks
import { useSortAsc, useSortDesc, useFetch, useAsyncValue, useEvenNumbers } from './hooks.js'
const fetchArrayOfNumbers = async () => {
return new Promise((resolve) => {
setTimeout(() => {
resolve([1, 2, 3, 4, 5, 6, 10]);
}, 1000);
});
};
@levymateus
levymateus / typeguard.ts
Last active January 19, 2024 01:32
Simple typescript typeguard schema
import { string, object, array, number, boolean } from "typeguard.types"
const schema = array(
object({
name: string((val) => `${val} doe`),
id: number((val) => val + 1),
birthdate: string((val) => new Date(val).toLocaleDateString("pt-br")),
ready: boolean(),
parents: array(
object({
@levymateus
levymateus / gamepad-handle.js
Created July 12, 2023 18:10
Web gamepad Xbox controller handler
import XboxController from "./xbox-controller";
export const XBOX_GAMEPAD_KEY = 'xbox'
/**
* @returns An `Map` of all connected gamepads.
*/
async function scanGamepads() {
let controllers = new Map();