Goals: Add links that are reasonable and good explanations of how stuff works. No hype and no vendor content if possible. Practical first-hand accounts of models in prod eagerly sought.
| 'use strict'; | |
| /* -------- What does this script do? -------- | |
| This script is meant to be used inside of an AWS lambda to automatically unzip/gunzip files that are created inside of an s3 bucket. | |
| ------------------------------------------- */ | |
| /* -------------------- Setup -------------------- | |
| 1. Create your s3 bucket | |
| 2. Download this file locally, change the bucket variable value to your s3 bucket name, install all required modules and zip all of that together | |
| 3. Create a lambda and import the .zip code inside of it |
| import { Injectable, HttpException, HttpStatus } from '@nestjs/common'; | |
| import * as multer from 'multer'; | |
| import * as multerS3 from 'multer-s3'; | |
| import { v4 as uuid } from 'uuid'; | |
| import { Validator } from 'class-validator'; | |
| import { S3 } from 'aws-sdk'; | |
| import s3 from './aws.service'; | |
| import { MimeType } from '../enums/mimeType.enum'; | |
| import { TWO_HOURS } from '../../common/constants/common.constants'; |
| import { | |
| NestInterceptor, | |
| ExecutionContext, | |
| Injectable, | |
| CallHandler, | |
| } from '@nestjs/common'; | |
| import { classToPlain } from 'class-transformer'; | |
| import { map } from 'rxjs/operators'; | |
| @Injectable() |
| Compute | |
| EC2 Virtual Private Servers | |
| Lightsail Amazon's hosting provider (vps, dns, storage) | |
| Lambda Functions you can run, written in Python, NodeJS, Go etc. Can run many in parallel. | |
| Batch Run software jobs on EC2 machines | |
| Elastic Beanstalk Run software on managed virtual machines | |
| Serverless Application Repository Repository of serverless applications that you can deploy (on lambda) | |
| AWS Outposts Basically run Amazon services on your own hardware (datacenter) | |
| EC2 Image Builder Create EC2 (ami?) images automatically |
| var Twit = require('twit') | |
| const owo = require('@zuzak/owo') | |
| var T = new Twit({ | |
| consumer_key: '', | |
| consumer_secret: '', | |
| access_token: '', | |
| access_token_secret: '', | |
| timeout_ms: 60*1000, // optional HTTP request timeout to apply to all requests. | |
| strictSSL: false, // optional - requires SSL certificates to be valid. |
| const { MongoClient } = require('mongodb'); | |
| const axios = require('axios'); | |
| const createStream = require('./tweetCrawler'); | |
| // Either take the MongoDB connection string from envrionment variable MONGODB_URL or the local mongodb 'twtsnt' | |
| const url = process.env.MONGO_URL || 'mongodb://localhost:27017/twtsnt'; | |
| const dbName = 'twtsnt'; | |
| // Create a MongoDB client instance | |
| const client = new MongoClient(url, { useNewUrlParser: true }); |
| const Twit = require('twit'); | |
| const Sentiment = require('sentiment'); | |
| // Create a sentiment instance | |
| const sentiment = new Sentiment(); | |
| // Create a Twit instance | |
| const T = new Twit({ | |
| consumer_key: 'consumer key obtained from twitter developer', // Twitter Developer - https://developer.twitter.com | |
| consumer_secret: 'consumer secret obtained from twitter developer', |