Skip to content

Instantly share code, notes, and snippets.

View hieptl's full-sized avatar
🎯
Focusing

Hiep Le hieptl

🎯
Focusing
View GitHub Profile
@hieptl
hieptl / menu.js
Created September 20, 2022 18:19
AirBnb Clone - menu.js
export const HOMES = 'HOMES';
export const EXPERIENCES = 'EXPERIENCES';
export const ONLINE_EXPERIENCES = 'ONLINE_EXPERIENCES';
@hieptl
hieptl / index.js
Created September 14, 2022 12:12
Instagram Clone React Node - index.js - React v18
import React from "react";
import ReactDOM from "react-dom";
import "./index.css";
import App from "./App";
ReactDOM.render(<App />, document.getElementById("root"));
@hieptl
hieptl / PrivateRoute.js
Created September 14, 2022 12:10
Instagram Clone React Node - PrivateRoute.js
import React from 'react';
import { Route, Redirect } from 'react-router-dom';
const PrivateRoute = ({component: Component, ...rest}) => {
return (
<Route {...rest} render={props => (
localStorage.getItem('auth') ?
<Component {...props} />
: <Redirect to="/login" />
)} />
@hieptl
hieptl / clone.js
Created September 14, 2022 12:03
Clone CometChat React UI Kit
git clone https://github.com/cometchat-pro/cometchat-pro-react-ui-kit.git
@hieptl
hieptl / server.js
Created September 13, 2022 10:40
Node.js Socket.io - server.js - 2
var http = require("http");
var fs = require("fs");
var path = require("path");
const APP_PORT = process.env.APP_PORT || 3000;
const app = http.createServer(requestHandler);
app.listen(APP_PORT);
console.log(`🖥 HTTP Server running at ${APP_PORT}`);
// handles all http requests to the server
@hieptl
hieptl / chat.js
Created September 13, 2022 10:39
Node.js Socket.io - chat.js - 4
// FILE /client/chat.js
console.log("chat.js file loaded!");
// IMPORTANT! By default, socket.io() connects to the host that
// served the page, so we dont have to pass the server url
var socket = io.connect();
//prompt to ask user's name
const username = prompt("Welcome! Please enter your name:");
@hieptl
hieptl / chat.js
Created September 13, 2022 10:37
Node.js Socket.io - chat.js - 3
// FILE /client/chat.js
console.log("chat.js file loaded!");
// IMPORTANT! By default, socket.io() connects to the host that
// served the page, so we dont have to pass the server url
var socket = io.connect();
//prompt to ask user's name
const username = prompt("Welcome! Please enter your name:");
@hieptl
hieptl / index.html
Created September 13, 2022 10:36
Node.js Socket.io - index.html - 2
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Chat app</title>
<script
src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/3.1.1/socket.io.js"
integrity="sha512-oFOCo2/3DtjrJG4N27BjSLQWoiBv171sK6a+JiWjp/7agxC2nCUP358AqzxkBUb5jX8g6CYLPdSKQTbC0weCwA=="
crossorigin="anonymous"
@hieptl
hieptl / chat.js
Created September 13, 2022 10:34
Node.js Socket.io - chat.js - 2
// FILE /client/chat.js
console.log("chat.js file loaded!");
// IMPORTANT! By default, socket.io() connects to the host that
// served the page, so we dont have to pass the server url
var socket = io.connect();
//prompt to ask user's name
const username = prompt("Welcome! Please enter your name:");
@hieptl
hieptl / chat.js
Created September 13, 2022 10:33
Node.js Socket.io - chat.js - 1
/ FILE /client/chat.js
console.log('chat.js file loaded!')
// IMPORTANT! By default, socket.io() connects to the host that
// served the page, so we dont have to pass the server url
var socket = io.connect()