Skip to content

Instantly share code, notes, and snippets.

@aprilmintacpineda
aprilmintacpineda / jwt.sh
Last active January 25, 2020 04:41 — forked from ygotthilf/jwtRS256.sh
How to generate JWT RS256 key
# Don't add passphrase
ssh-keygen -t rsa -b 4096 -m PEM -f jwt.key
openssl rsa -in jwt.key -pubout -outform PEM -out jwt.pub
# remove the jwt.key.pub you don't need it
rm -rf jwt.key.pub
cat jwt.key
cat jwt.pub
@aprilmintacpineda
aprilmintacpineda / node_nginx_ssl.md
Created February 9, 2020 12:31 — forked from bradtraversy/node_nginx_ssl.md
Node app deploy with nginx & SSL

Node.js Deployment

Steps to deploy a Node.js app to DigitalOcean using PM2, NGINX as a reverse proxy and an SSL from LetsEncrypt

1. Sign up for Digital Ocean

If you use the referal link below, you get $10 free (1 or 2 months) https://m.do.co/c/5424d440c63a

2. Create a droplet and log in via ssh

I will be using the root user, but would suggest creating a new user

@aprilmintacpineda
aprilmintacpineda / serverless.yml
Created April 30, 2020 12:28 — forked from DavidWells/serverless.yml
DynamoDB custom index serverless.yml example
service: service-name
provider:
name: aws
runtime: nodejs6.10
functions:
myfunc:
handler: handler.myfunc
@aprilmintacpineda
aprilmintacpineda / lifecycle-cheat-sheet.md
Created May 3, 2020 09:21 — forked from HyperBrain/lifecycle-cheat-sheet.md
Serverless Lifecycle Cheat Sheet

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 / nested-fql-template.js
Created June 18, 2020 05:23 — forked from ptpaterson/nested-fql-manual.js
Template for building deeply nested FQL queries for FaunaDB
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'))
},
{
@aprilmintacpineda
aprilmintacpineda / .eslintrc.js
Last active December 9, 2020 08:49
Code formatting
module.exports = {
env: {
browser: true,
node: true,
es6: true,
'jest/globals': true
},
root: true,
plugins: ['jest', 'react'],
extends: [
@aprilmintacpineda
aprilmintacpineda / fun-with-bubble-sort.md
Last active September 7, 2021 07:30
Bubble sort implementations in JS, PHP, PY, and Java with tests and performance measurement.

Fun with JS, PHP, PY, and Java

Lots of developers argue about which programming language should be used to do this and that, in reality, all their answers are hugely affected by self bias, most of the time, programmers would use something in favor of something else because of comfortability, they are simply more comfortable using whatever they chose.

All high-level programming languages are pretty much alike, they were built on top of the same concepts, there's MVC in PHP, Java, JavaScript, Python, .NET, etc., they may differ in syntax, but at their very core, they are alike. Much like humans, we differ in color, height, body size, etc., but at our very core, we're all alike, but they differ in terms of speed, like humans differ in intelligence.

So, I made a bubble sort implementation in Java, JavaScript, PHP, and Python. If you don't know the bubble sort algorithm yet and you want to know, then read the [pseudocode](https://gist.github.com/aprilmintacpineda/7800a989f1f494ee8d

@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

@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 / 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');