Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Praveen Kumar Saini praveen-me

🎯
Focusing
View GitHub Profile
@praveen-me
praveen-me / jwt-implement.js
Created Feb 4, 2019
Gist for article for jwt implementation.
View jwt-implement.js
const jwt = require('jsonwebtoken');
const app = require('express')();
const passport = require('passport');
const LocalStrategy = require('passport-local').Stratergy;
const JwtStrategy = require('passport-jwt').Strategy;
const ExtractJwt = require('passport-jwt').ExtractJwt;
// Use Local Startergy for authenticating user
passport.use(new LocalStrategy(
function(username, password, done) {
@praveen-me
praveen-me / async.js
Created Jan 23, 2019
Fetch asynchronous multiple requests.
View async.js
var fs = require('fs');
var axios = require('axios');
var async = require('async');
const Bank = require('./models/Bank');
var codes;
var counter = 0;
const mongoose = require('mongoose');
mongoose.Promise = global.Promise;
module.exports = () => {
@praveen-me
praveen-me / App.js
Created Jan 13, 2019
React code for hooks-todo.
View App.js
import React, { useState } from 'react';
import './scss/App.scss'
function App() {
const [todoValue, setTodoValue] = useState('');
const [todos, setTodo] = useState([])
const handleChange = e => {
setTodoValue(e.target.value);
}
@praveen-me
praveen-me / hooks-todo.scss
Created Jan 13, 2019
SASS file for for hooks-todo.
View hooks-todo.scss
// Import font-family
@import url('https://fonts.googleapis.com/css?family=Roboto+Condensed:300i,400,400i,700');
.todo-list {
max-width: 450px;
margin: 0 auto;
width: 100%;
font-family: 'Roboto Condensed', sans-serif;
button {
font-family: 'Roboto Condensed', sans-serif;
@praveen-me
praveen-me / set-greet.js
Created Sep 20, 2018
Chrome Extension Blog
View set-greet.js
// function for set Greet
function setGreet() {
let userName = localStorage.getItem('userNameKey');
let now = new Date();
let hours = now.getHours();
//set greet msg according to hours
if(hours >= 4 && hours <= 12) {
greet_msg.innerHTML = 'Good Morning';
} else if(hours >= 13 && hours <= 16) {
@praveen-me
praveen-me / get-details.js
Created Sep 20, 2018
Chrome Extension Blog
View get-details.js
//function for set User Details
function getDetails(e) {
e.preventDefault();
const userName = document.getElementById('user-name_value').value;
JSON.stringify(localStorage.setItem('userNameKey', userName));
userDetailsBlock.style.display = "none";
greetBlock.style.display = 'block';
@praveen-me
praveen-me / check-details.js
Created Sep 20, 2018
Chrome Extension Blog
View check-details.js
//Check Username is present in localStorage or not
if(localStorage.getItem('userNameKey') === null) {
userDetailsBlock.style.display = 'block';
submitBtn.addEventListener('click', getDetails);
} else {
greetBlock.style.display = 'block';
setGreet();
}
@praveen-me
praveen-me / greet-msg.css
Created Sep 20, 2018
Chrome Extension Blog
View greet-msg.css
/* Greet Msg Block */
.greet_msg {
text-align: center;
font-size: 3rem;
}
.user-details, .greet_msg {
display: none;
}
@praveen-me
praveen-me / set-time.js
Created Sep 20, 2018
Chrome Extension Blog
View set-time.js
const hourElm = document.getElementById('hour');
const minutesElm = document.getElementById('minutes');
// function to set time
function setTime() {
let now = new Date();
hourElm.innerHTML = now.getHours();
minutesElm.innerHTML = now.getMinutes();
}
@praveen-me
praveen-me / time-block.css
Created Sep 20, 2018
Chrome Extension Blog
View time-block.css
/* Time Block CSS */
.time_block {
text-align: center;
font-size: 5rem;
}
.time_block h1 {
margin: 1rem 0;
}