Skip to content

Instantly share code, notes, and snippets.

View rakibulhaq's full-sized avatar
🏠
Working from home

rakibulhaq rakibulhaq

🏠
Working from home
View GitHub Profile
@rakibulhaq
rakibulhaq / otpverify.js
Created October 6, 2019 16:42 — forked from theanam/otpverify.js
OTP verification without database, full sample source code
const otpGenerator = require("otp-generator");
const crypto = require("crypto");
const key = "verysecretkey"; // Key for cryptograpy. Keep it secret
function createNewOTP(phone){
// Generate a 6 digit numeric OTP
const otp = otpGenerator.generate(6, {alphabets: false, upperCase: false, specialChars: false});
const ttl = 5 * 60 * 1000; //5 Minutes in miliseconds
const expires = Date.now() + ttl; //timestamp to 5 minutes in the future
const data = `${phone}.${otp}.${expires}`; // phone.otp.expiry_timestamp
@rakibulhaq
rakibulhaq / query.js
Created July 16, 2019 06:46 — forked from sdgluck/query.js
Pagination using Mongo: populate, match, sort, count, and limit with the aggregation pipeline
/**
* Query blog posts by user -> paginated results and a total count.
* @param userId {ObjectId} ID of user to retrieve blog posts for
* @param startRow {Number} First row to return in results
* @param endRow {Number} Last row to return in results
* @param [filter] {Object} Optional extra matching query object
* @param [sort] {Object} Optional sort query object
* @returns {Object} Object -> `{ rows, count }`
*/
function queryBlogPostsByUser (userId, startRow, endRow, filter = {}, sort = false) {
@rakibulhaq
rakibulhaq / default.conf
Created March 21, 2019 09:33
NGiNX Configuration for Vue-Router in HTML5 Mode
server {
listen 80 default_server;
listen [::]:80 default_server;
root /your/root/path;
index index.html;
server_name you.server.com;
@rakibulhaq
rakibulhaq / XLSXchooseSheet.html
Created February 26, 2019 07:23 — forked from stla/XLSXchooseSheet.html
import a XLSX file and choose the sheet
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="libraries/PapaParse-4.1.2/papaparse.min.js"></script>
<script src="libraries/xlsx/xlsx-0.8.0.core.min.js"></script>
<script src="libraries/bootstrap/js/bootstrap-4.0.0.min.js"></script>
<link rel="stylesheet" href="libraries/bootstrap/css/bootstrap-4.0.0.min.css">
<script src="libraries/bootstrap.file-input.js"></script>
@rakibulhaq
rakibulhaq / app.vue
Last active March 10, 2020 22:56 — forked from dohomi/app.vue
Small file input element based on vuetify
<template>
<div>
<file-input v-model="filename" @formData="formData"></file-input>
<v-btn @click.native="uploadFiles"></v-btn>
</div>
</template>
<script>
import fileInput from './file-input.vue'