Skip to content

Instantly share code, notes, and snippets.

View farhadjaman's full-sized avatar

MD Farhad Jaman farhadjaman

  • Mirpur,Dhaka, Bangladesh
  • 08:07 (UTC -12:00)
View GitHub Profile

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. Create Free AWS Account

Create free AWS Account at https://aws.amazon.com/

2. Create and Lauch an EC2 instance and SSH into machine

I would be creating a t2.medium ubuntu machine for this demo.

import { OpenAI } from 'langchain/llms/openai'
import { PromptTemplate } from 'langchain/prompts'
import { loadQARefineChain } from 'langchain/chains'
import { MemoryVectorStore } from 'langchain/vectorstores/memory'
import { OpenAIEmbeddings } from 'langchain/embeddings/openai'
import {
StructuredOutputParser,
OutputFixingParser,
} from 'langchain/output_parsers'
@farhadjaman
farhadjaman / gist:71cd39941e9d4ba1d2e0ec65b7de53be
Created October 22, 2023 04:38
Track time between state transtiion using Date function
import React, { useState, useEffect } from 'react';
import VideoPlayer from './VideoPlayer'; // Import your VideoPlayer component
const Create = () => {
const [watchVideo, setWatchVideo] = useState(false);
const [startTime, setStartTime] = useState(null);
const [elapsedTime, setElapsedTime] = useState(0);
useEffect(() => {
let interval; // Store the interval ID
@farhadjaman
farhadjaman / gist:7448812cd14eb6e0c222485cbe4890fd
Last active October 22, 2023 04:20
Monitor the duration between transitions in states.
import { useState, useEffect } from 'react';
const TestStateChangeTime = ({}) => {
const [elapsedTime, setElapsedTime] = useState(0);
const [isModalOpen, setIsModalOpen] = useState(false);
const handleButtonClick = () => {
setIsModalOpen(!isModalOpen);
};
@farhadjaman
farhadjaman / ubuntu-nextjs-nginx-config-file
Created October 5, 2023 05:09 — forked from oelbaga/01 - Setup Nextjs site on Ubuntu Server - Terminal commands
Setup NextJS app on Digital Ocean Ubuntu server Full Terminal Commands Step by Step
#nginx config file for Nextjs App
#place in /etc/nginx/sites-available/name_of_config_file
server {
listen 80;
server_name domainname.com;
gzip on;
gzip_proxied any;
gzip_types application/javascript application/x-javascript text/css text/javascript;
gzip_comp_level 5;
function findNestedObject(object, keyToFind, valToFind) {
let foundObj;
JSON.stringify(object, (_, nestedValue) => {
if (nestedValue && nestedValue[keyToFind] === valToFind) {
foundObj = nestedValue;
}
return nestedValue;
});
return foundObj;
}
@farhadjaman
farhadjaman / graphql-queries-mutations.md
Last active April 19, 2023 05:56 — forked from bradtraversy/graphql-queries-mutations.md
GraphQL Queries & Mutations

GraphQL Queries & Mutations

These are the GraphQL queries and mutations for the YouTube course.

Get names of all clients

{
  clients {
    name
 }
const debug = require('debug')('steve');
debug('variable value... through debug');
//console.log('variable value... through console.');
let arr = [].fill(123, 0, 10000);
let arr2 = new arr.map(item => item * 10); // needed `new` in front of Array
debug('after the loop');
@farhadjaman
farhadjaman / keybindings.json
Created November 8, 2022 02:21 — forked from LearnWebCode/keybindings.json
In VS Code on Mac; change from control + number to cmd + number to jump between open editors.
// Place your key bindings in this file to override the defaults
[
{ "key": "cmd+1", "command": "workbench.action.openEditorAtIndex1" },
{ "key": "cmd+2", "command": "workbench.action.openEditorAtIndex2" },
{ "key": "cmd+3", "command": "workbench.action.openEditorAtIndex3" },
{ "key": "cmd+4", "command": "workbench.action.openEditorAtIndex4" },
{ "key": "cmd+5", "command": "workbench.action.openEditorAtIndex5" },
{ "key": "cmd+6", "command": "workbench.action.openEditorAtIndex6" },
{ "key": "cmd+7", "command": "workbench.action.openEditorAtIndex7" },
{ "key": "cmd+8", "command": "workbench.action.openEditorAtIndex8" },