Skip to content

Instantly share code, notes, and snippets.

View ymulenll's full-sized avatar

Yoelvis Mulen ymulenll

View GitHub Profile
@ymulenll
ymulenll / createBook.mjs
Created April 22, 2023 03:11
lambda put item in dynamodb using nodejs
import { DynamoDBClient } from "@aws-sdk/client-dynamodb";
import { DynamoDBDocumentClient, PutCommand } from "@aws-sdk/lib-dynamodb";
import { randomUUID } from "crypto";
const ddbDocClient = DynamoDBDocumentClient.from(new DynamoDBClient({}));
export const handler = async (event, context) => {
try {
const book = JSON.parse(event.body);
const routes = {
home: '/',
transactions: '/transactions',
transactionDetails: '/transactions/:uuid',
}
const urls: Record<
keyof typeof routes,
{ get: (params?: any) => string; route: string }
> = new Proxy(routes, {
type AnyFunction = (...args: any[]) => any
function useEvent<T extends AnyFunction>(callback?: T) {
const ref = useRef<AnyFunction | undefined>(() => {
throw new Error("Cannot call an event handler while rendering.")
})
useLayoutEffect(() => {
ref.current = callback
})
return useCallback<AnyFunction>(
@ymulenll
ymulenll / app.js
Created September 7, 2022 14:51
Obtener rango de números primos - Ejemplo para el video https://youtu.be/BPWpialFWvM
const primos = obtenerNumerosPrimos(1, 10);
console.log(primos);
function obtenerNumerosPrimos(numeroInicial, numeroFinal) {
const numerosPrimos = [];
if (numeroInicial > numeroFinal) {
throw Error("El número inicial debe ser menor que el número final");
}
for (let actual = numeroInicial; actual <= numeroFinal; actual++) {
if (esPrimo(actual)) {
@ymulenll
ymulenll / revert-a-commit.md
Created February 18, 2022 16:11 — forked from gunjanpatel/revert-a-commit.md
Git HowTo: revert a commit already pushed to a remote repository

Revert the full commit

Sometimes you may want to undo a whole commit with all changes. Instead of going through all the changes manually, you can simply tell git to revert a commit, which does not even have to be the last one. Reverting a commit means to create a new commit that undoes all changes that were made in the bad commit. Just like above, the bad commit remains there, but it no longer affects the the current master and any future commits on top of it.

git revert {commit_id}

About History Rewriting

Delete the last commit

Deleting the last commit is the easiest case. Let's say we have a remote origin with branch master that currently points to commit dd61ab32. We want to remove the top commit. Translated to git terminology, we want to force the master branch of the origin remote repository to the parent of dd61ab32:

let users = [
{
id: 1,
name: "Leanne Graham",
username: "Bret",
email: "[email protected]",
phone: "1-770-736-8031 x56442",
website: "hildegard.org",
},
{
@ymulenll
ymulenll / movies.json
Created March 20, 2021 20:56
List of movies from themoviedb
[
{
"adult": false,
"backdrop_path": "/hJuDvwzS0SPlsE6MNFOpznQltDZ.jpg",
"genre_ids": [16, 12, 14, 10751, 28],
"id": 527774,
"original_language": "en",
"original_title": "Raya and the Last Dragon",
"overview": "Long ago, in the fantasy world of Kumandra, humans and dragons lived together in harmony. But when an evil force threatened the land, the dragons sacrificed themselves to save humanity. Now, 500 years later, that same evil has returned and it’s up to a lone warrior, Raya, to track down the legendary last dragon to restore the fractured land and its divided people.",
"popularity": 3686.429,