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
View user.js
process.env.NODE_ENV = "test";
const app = require("../app");
const chai = require("chai");
const request = require("supertest");
const expect = chai.expect;
const mongoose = require("mongoose");
process.env.TEST_SUITE = "testdb";
beforeEach(async () => {
if (mongoose.connection.readyState === 0) {
rakibulhaq / otpverify.js
Created October 6, 2019 16:42 — forked from theanam/otpverify.js
OTP verification without database, full sample source code
View otpverify.js
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 = + ttl; //timestamp to 5 minutes in the future
const data = `${phone}.${otp}.${expires}`; // phone.otp.expiry_timestamp
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
View query.js
* 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 / server-starter.bat
Created May 11, 2019 09:04
Simple batch Script to Run from Command To Execute Different Services
View server-starter.bat
@echo 'starting mongo db service'
start mongod
cd /d F:\1.Projects\templates\rest-api-server
@echo 'starting rest api server at port: 3100'
start npm run dev
cd /d F:\1.Projects\tempaltes\pwa\mealmanager-pwa
@echo 'starting meal manager pwa'
start npm run serve
rakibulhaq / default.conf
Created March 21, 2019 09:33
NGiNX Configuration for Vue-Router in HTML5 Mode
View default.conf
server {
listen 80 default_server;
listen [::]:80 default_server;
root /your/root/path;
index index.html;
rakibulhaq / XLSXchooseSheet.html
Created February 26, 2019 07:23 — forked from stla/XLSXchooseSheet.html
import a XLSX file and choose the sheet
View XLSXchooseSheet.html
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<script src=""></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 / app.vue
Last active March 10, 2020 22:56 — forked from dohomi/app.vue
Small file input element based on vuetify
View app.vue
<file-input v-model="filename" @formData="formData"></file-input>
<v-btn @click.native="uploadFiles"></v-btn>
import fileInput from './file-input.vue'