Skip to content

Instantly share code, notes, and snippets.

View Wadprog's full-sized avatar
😜

Wadson Vaval Wadprog

😜
View GitHub Profile
@Wadprog
Wadprog / node_nginx_ssl.md
Created April 21, 2020 02:57 — 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

// Sending an HTTP Request from a NodeJS server
//const http = require("http");
const https = require("https");
const Stream = require("stream").Transform;
const fs = require("fs");
https
.get("https://api.nasa.gov/planetary/apod?api_key=DEMO_KEY", resp => {
const MAX_IP_ATTEMPTS_PER_HOUR = 15
const MAX_IP_ATTEMPTS_PER_MINUTE = 5
const MAX_COOKIE_ATTEMPTS_PER_10_SECONDS = 2
const MAX_USERNAME_ATTEMPTS_PER_HOUR = 10
const SECONDS_IN_MILLIS = 1000
const MINUTE_IN_MILLIS = 60 * 1000
const HOUR_IN_MILLIS = 60 * 60 * 1000
/**

Design twitter in 30 mins.

Tweeter is a network that allows users to post and interact with tweets as well as follow each other world-wide.

Requirements

  • Creating a tweet on Twitter
  • Viewing or generating a timeline
  • Follow people & interaction between user
/**
*
* ### Task specification
1. Your goal is to extract all products from an imaginary e-commerce JSON API with limited results per search. The API URL origin is `[https://api.ecommerce.com/products](https://api.ecommerce.com/products)` . This URL doesn’t exist (it is only imaginary) so don’t try to run the code 🙂
2. The API is called via a simple GET request without a need for special headers and it will return JSON data.
3. Every API call will return max 1000 products. Your goal is to overcome this limitation by creating requests for specific price ranges of products. You don’t know upfront how many products there are total but this number is returned from the API.œ
4. Each product on the API costs somewhere between $0 and $100,000.
5. You can make the request more specific by adding a `minPrice` and `maxPrice` query parameters. This way we can overcome the 1000 limit of results per API call.
6. Create an algorithm that will ensure that all products are scraped and accumulate all products into a sing