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 / index.js
Created August 6, 2022 16:55
How to Get the Current Date in Javascript - Format Date & Time(YYYY-MM-DD HH:MM:SS)
const currentDate = new Date();
const yyyyMMDDDate =
currentDate.getFullYear() +
"-" +
(currentDate.getMonth() + 1) +
"-" +
currentDate.getDate();
const hhMMSSTime =
@hieptl
hieptl / index.js
Created August 6, 2022 16:48
How to Get the Current Date in Javascript - Format Date (HH:MM:SS)
const currentDate = new Date();
const hhMMSSTime =
currentDate.getHours() +
":" +
currentDate.getMinutes() +
":" +
currentDate.getSeconds();
console.log(hhMMSSTime);
@hieptl
hieptl / index.js
Created August 6, 2022 16:11
How to Get the Current Date in Javascript - Format Date (YYYY-MM-DD)
const currentDate = new Date();
const yyyyMMDDDate =
currentDate.getFullYear() +
"-" +
(currentDate.getMonth() + 1) +
"-" +
currentDate.getDate();
console.log(yyyyMMDDDate);
@hieptl
hieptl / index.js
Created August 6, 2022 16:01
How to Get the Current Date in Javascript - Step 2
const currentDate = new Date();
console.log(currentDate);
@hieptl
hieptl / login.js
Created December 15, 2021 12:21
login api md - instagram clone react node
Method: POST
Example Request Body:
{
"email": "[email protected]",
"password": "123456"
}
@hieptl
hieptl / Info.plist
Created December 14, 2021 12:59
Info.plist - Permissions - Zocdoc Clone
<key>NSCameraUsageDescription</key>
<string></string>
<key>NSLocationWhenInUseUsageDescription</key>
<string></string>
<key>NSMicrophoneUsageDescription</key>
<string></string>
<key>NSPhotoLibraryUsageDescription</key>
<string></string>
@hieptl
hieptl / App.js
Created December 14, 2021 12:58
App.js - Get Permissions Android - Zocdoc Clone
...
useEffect(() => {
...
getPermissions();
}, []);
...
const getPermissions = async () => {
if (Platform.OS === 'android') {
let granted = await PermissionsAndroid.requestMultiple([
PermissionsAndroid.PERMISSIONS.CAMERA,
@hieptl
hieptl / firebase.js
Created December 10, 2021 09:44
firebase.js - ZocDoc Clone
import { fbConfig } from "./env";
import { initializeApp } from 'firebase/app';
import { getAuth, createUserWithEmailAndPassword, signInWithEmailAndPassword } from "firebase/auth";
import { getStorage, ref as storageRef, uploadBytesResumable, getDownloadURL } from "firebase/storage";
import { getDatabase, ref as databaseRef, set as databaseSet, onValue as databaseOnValue, get as databaseGet, child as databaseChild, off as databaseOff, query as databaseQuery, orderByChild, equalTo } from "firebase/database";
// TODO: Replace the following with your app's Firebase project configuration
const firebaseConfig = {
apiKey: `${fbConfig.apiKey}`,
@hieptl
hieptl / app.js
Created December 7, 2021 09:16
app.js - logout - Zocdoc Clone
const handleLogout = (navigation) => {
cometChat.logout().then(
() => {
AsyncStorage.removeItem('auth');
setUser(null);
navigation.reset({
index: 0,
routes: [{ name: 'Login' }]
});
}, error => {
@hieptl
hieptl / conversations.js
Created December 7, 2021 09:14
conversations.js
import React, { useContext } from 'react';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import { CometChatUserListWithMessages, CometChatMessages } from '../cometchat-pro-react-native-ui-kit';
import Context from '../context';
const Conversations = () => {
const Stack = createNativeStackNavigator();
const { cometChat } = useContext(Context);