Skip to content

Instantly share code, notes, and snippets.

View piyushgarg-dev's full-sized avatar
🎯
Coding

Piyush Garg piyushgarg-dev

🎯
Coding
View GitHub Profile
@piyushgarg-dev
piyushgarg-dev / CLICKHOUSE_DB_CREATE.sql
Last active February 19, 2024 05:03
Vercel Clone 2.0 Commands
CREATE TABLE log_events (
event_id UUID,
timestamp DateTime MATERIALIZED now(),
deployment_id Nullable(String),
log String,
metadata Nullable(String)
)
ENGINE=MergeTree PARTITION BY toYYYYMM(timestamp)
ORDER BY (timestamp);
@piyushgarg-dev
piyushgarg-dev / Dockerfile
Created October 21, 2023 10:00
Docker In One Shot
FROM ubuntu
RUN apt-get update
RUN apt-get install -y curl
RUN curl -sL https://deb.nodesource.com/setup_18.x | bash -
RUN apt-get upgrade -y
RUN apt-get install -y nodejs
COPY package.json package.json
COPY package-lock.json package-lock.json
@piyushgarg-dev
piyushgarg-dev / README.md
Last active May 24, 2024 08:31
Kafka Crash Course

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.

@piyushgarg-dev
piyushgarg-dev / install_nginx.md
Last active April 28, 2024 06:13
Nginx Installation
buyButton.addEventListener('click', async (event) => {
const response = await fetch('/order', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ amount: 500 }) // Rs.500
});
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Razorpay</title>
</head>
<body>
<div>
const { request, response } = require('express');
const express = require('express');
const Razorpay = require('razorpay');
const app = express();
const PORT = 8000;
app.use(express.static('./public'));
app.use(express.json());
const express = require('express');
const app = express();
const PORT = 8000;
app.use(express.static('./public'));
app.use(express.json());
const express = require('express');
const app = express();
const PORT = 8000;
app.listen(PORT, () => console.log(`Express server started at PORT:${PORT}`));