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
const express = require('express');
const app = express();
const PORT = 8000;
app.listen(PORT, () => console.log(`Express server started at PORT:${PORT}`));
type Subscriber<T> = (val: T) => void;
type Unsubscribe = () => void;
export class Observable<T> {
private _val: T;
private _listners: Array<Subscriber<T>>;
constructor() {
this._listners = [];
}
export const sayHello = () => console.log(`Hello There!`)
const express = require('express');
const cron = require('node-cron')
const app = express();
cron.schedule('0 0 1 * *', () => {
console.log('running every 1st of the month');
});
app.get('/', (req, res) => {
res.json('Welcome to my API');
const express = require('express');
const cron = require('node-cron')
const app = express();
cron.schedule('* * * January,September Sunday', () => {
console.log('running on Sundays of January and September');
});
app.get('/', (req, res) => {
res.json('Welcome to my API');
const express = require('express');
const app = express();
app.get('/', (req, res) => {
res.json('Welcome to my API');
})
app.listen(9000, () => console.log(`Server Started at PORT: 9000`))
const form = document.getElementById('chat-form');
const messageBox = document.getElementById('messageBox');
const chatBox = document.getElementById('chat-box')
const socket = io('localhost:8080');
socket.on('message', (msg) => {
const liTag = document.createElement('li');
liTag.classList.add('list-group-item')
liTag.innerText = msg;
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Chat App</title>
<style>
.chat-container{
border: 2px solid;
const http = require('http');
const socket = require('socket.io');
const server = http.createServer();
const io = socket(server);
io.on('connection', socket => {
console.log('A new user has joined the chat')
socket.emit('message', 'You have successfully joined the chat')
const http = require('http');
const socket = require('socket.io');
const server = http.createServer();
const io = socket(server);
io.on('connection', socket => {
console.log('A new user has joined the chat')
socket.emit('message', 'You have successfully joined the chat')