Skip to content

Instantly share code, notes, and snippets.

@aprilmintacpineda
aprilmintacpineda / Using Multiple SSH keys - Beginner Friendly.md
Last active June 19, 2024 17:12
Beginner Friendly: Using Multiple SSH keys

How to follow this guide

The problem

I have one computer and two different github accounts. One is for work, the other is for my personal stuff. I can't use the same ssh key twice, so I have to use different ssh key for each of my accounts. How do I do that? How do I switch between these ssh keys?

@aprilmintacpineda
aprilmintacpineda / ReactJS with linting setup.md
Last active January 13, 2024 21:41
ESLint and Prettier setup for ReactJS

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
@aprilmintacpineda
aprilmintacpineda / country-code-to-currency-code-mapping.csv
Created November 18, 2023 12:06 — forked from HarishChaudhari/country-code-to-currency-code-mapping.csv
Country, Country Code, Currency code mapping in CSV format Taken from https://gist.github.com/304261 Contains 249 countries.
Country CountryCode Currency Code
New Zealand NZ New Zealand Dollars NZD
Cook Islands CK New Zealand Dollars NZD
Niue NU New Zealand Dollars NZD
Pitcairn PN New Zealand Dollars NZD
Tokelau TK New Zealand Dollars NZD
Australian AU Australian Dollars AUD
Christmas Island CX Australian Dollars AUD
Cocos (Keeling) Islands CC Australian Dollars AUD
Heard and Mc Donald Islands HM Australian Dollars AUD
@aprilmintacpineda
aprilmintacpineda / copy-database.js
Last active June 21, 2023 13:52
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.
/**
* 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 / ReactTS with linting setup.md
Last active February 21, 2023 06:29
ReactTS with linting setup

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 / Linting setup with TypeScript.md
Last active November 11, 2022 07:24
Linting setup with TypeScript

This setup achieves:

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

1. Install dependencies

yarn add prettier eslint @typescript-eslint/typescript-estree @typescript-eslint/eslint-plugin 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 @typescript-eslint/parser --dev
@aprilmintacpineda
aprilmintacpineda / TypeScript: Queueing promises.md
Last active July 20, 2022 11:52
TypeScript: Queueing promises

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

@aprilmintacpineda
aprilmintacpineda / NodeJS require local modules resolver.md
Last active May 13, 2022 10:38
NodeJS require concept for local modules

NodeJS require concept for local modules

The problem

As your NodeJS app grows bigger, the file structure tends to go 3 to even 5 layers deep. The problem now is as you require local modules you created, you'll have to write them in this way:

const myModule = require('../../../my/module');
@aprilmintacpineda
aprilmintacpineda / Clean all dynamodb tables.md
Last active October 28, 2021 22:53
A script to cleanup (delete all items) your dynamodb tables in appsync

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 October 28, 2021 22:29
Set updatedAt to an updated value for all records in all tables in an AppSync environment

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