Skip to content

Instantly share code, notes, and snippets.

Avatar
🦄
Building unicorns.

April Mintac Pineda aprilmintacpineda

🦄
Building unicorns.
View GitHub Profile
View TypeScript: Queueing promises.md

What's this?

This was my answer to an exam that I went through online today. I think it might also be useful in the future so I'm putting it here as future reference when I need this functionality.

Buffering Promises

In this challenge, you'll be asked to wrap an unknown asynchronous function, returning a new function with a modified asynchronous behavior. The returned function will prevent making too many calls to the asynchronous function at once by buffering extra requests until an earlier one has completed.

A common use case would be to prevent overrunning an API endpoint, so you make no more than 4 requests simultaneously.

Your Task

View ReactTS with linting setup.md

This setup achieves:

  • Imports will be resolved from /src folder.
  • Code formatter and linter that works with the import module resolver.
  • Setup react-hooks linting

Using TypeScript

1. Install dependencies

@aprilmintacpineda
aprilmintacpineda / Clean all dynamodb tables.md
Last active Oct 28, 2021
A script to cleanup (delete all items) your dynamodb tables in appsync
View Clean all dynamodb tables.md

What is this?

THIS SCRIPT WILL DELETE ALL ITEMS OF THE DYNAMODB TABLES OF YOUR APPSYNC APP.

How to use:

  1. Copy-paste the script to your machine.
  2. Run yarn add @aws-sdk/util-dynamodb aws-sd date-fnsk prompt-confirm.
  3. Provide the correct values in the configuration section of the script.
  4. Run the script via nodejs.
@aprilmintacpineda
aprilmintacpineda / Re-index AWS AppSync ElasticSearch.md
Last active Oct 28, 2021
Set updatedAt to an updated value for all records in all tables in an AppSync environment
View Re-index AWS AppSync ElasticSearch.md

What

When using AWS AppSync with ElasticSearch, sometimes, the data on elastic search gets corrupted or gets missing, what you need to do to get it fixed is to update each items on all the table, which you don't wanna do manually.

This script will update each items on all dynamodb table in your AppSync by setting the updatedAt to the current timestamp.

THIS SCRIPT WILL UPDATE ALL ITEMS OF YOUR DYNAMODB IN YOUR APPSYNC APP

Usage

@aprilmintacpineda
aprilmintacpineda / copy-database.js
Last active Jun 16, 2022
This nodejs script allows you to copy a faunadb (its collections, indexes, functions, and data) from a source to a destination. Note that the time it will take for this script to complete is completely dependent on how much data you have on your source database.
View copy-database.js
/**
* NOTES:
* - For the `domain` in configs, please refer to https://docs.fauna.com/fauna/current/api/fql/region_groups
* - For the `secret`, please make sure that it's `admin`. Refer to https://docs.fauna.com/fauna/current/security/keys?lang=javascript
* - The script retains the `Ref` of the data when it's being copied from the source to the destination, so relationships relying on this should still work out of the box.
* - The goal here is to make an exact replicate of the source, so once the script is done running, the destination should just work out of the box.
* - The script also checks if the collection, index, function or data already exists to prevent duplicates.
*/
/**
@aprilmintacpineda
aprilmintacpineda / ReactJS with linting setup.md
Last active Sep 16, 2022
ESLint and Prettier setup for ReactJS
View ReactJS with linting setup.md

This setup achieves:

  • Imports will be resolved from /src folder.
  • Code formatter and linter that works with the import module resolver.
  • Setup react-hooks linting

1. Install dependencies

yarn add prettier eslint @babel/eslint-parser eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-module-resolver eslint-plugin-import eslint-import-resolver-babel-module babel-plugin-module-resolver husky lint-staged eslint-plugin-jest --dev
View .eslintrc.js
module.exports = {
env: {
browser: true,
node: true,
es6: true,
'jest/globals': true
},
root: true,
plugins: ['jest', 'react'],
extends: [
@aprilmintacpineda
aprilmintacpineda / nested-fql-template.js
Created Jun 18, 2020 — forked from ptpaterson/nested-fql-manual.js
Template for building deeply nested FQL queries for FaunaDB
View nested-fql-template.js
const baseQuery = q.Paginate(q.Match(q.Index(indexName), terms));
// or
// const baseQuery = q.Paginate(q.Collection(collectionName))
const expandedQuery = q.Map(baseQuery, (ref) =>
q.Let(
{
instance: q.Get(q.Var('ref'))
},
{
View lifecycle-cheat-sheet.md

Serverless plugin author's cheat sheet

This cheat sheet provides a detailed overview of the exposed lifecycle events and available commands (and entrypoints) of the Serverless framework, that can be hooked by plugins (internal and external ones). The document is structured by the commands invoked by the user.

Lifecycle events are shown as the globally available outer events (all providers) and sub lifecycle events that are provider specific in the called order. Currently only the AWS provider is shown. If you have information about the other provider,

@aprilmintacpineda
aprilmintacpineda / serverless.yml
Created Apr 30, 2020 — forked from DavidWells/serverless.yml
DynamoDB custom index serverless.yml example
View serverless.yml
service: service-name
provider:
name: aws
runtime: nodejs6.10
functions:
myfunc:
handler: handler.myfunc