Skip to content

Instantly share code, notes, and snippets.

View waptik's full-sized avatar
💻
Learning JavaScript and ReactJS...

TheVirginBrokey waptik

💻
Learning JavaScript and ReactJS...
View GitHub Profile
...
const tabs = [
'Account',
'Profile',
'Payment',
'Notification',
'Advanced'
]
...
@waptik
waptik / dbUtils.js
Created September 11, 2020 02:29
Export mongodb collection data and import it back using node js
// credit link: @https://stackoverflow.com/questions/63573995/export-mongodb-collection-data-and-import-it-back-using-node-js
const fs = require('fs');
const dbName = 'testDB';
const client = new MongoClient('mongodb://localhost:27017', { useUnifiedTopology:true });
// function to export db document
function exportDbCollection(){
@waptik
waptik / Hide.tsx
Created September 12, 2020 15:43
A @chakra-ui component that allows you visually hide certain content based on device breakpoints
import { BoxProps, Box } from '@chakra-ui/core';
/**
* @author: Stephane Mensah(GitHub: waptik, Twitter: _waptik)
*
* @description: A react component made with @chakra-ui to visually hide
* certain contents based on devices based on your theme's breakpoints.
* You can combine breakooints to hide at different breakpoint
* Idea originated from https://github.com/opencollective/opencollective-frontend/blob/master/components/Hide.js
* @example: Hide on base breakpoint(< 640px)
@waptik
waptik / fauna-adapter.js
Last active December 31, 2020 17:18 — forked from s-kris/fauna-adapter.js
faunadb adapter for next-auth for next.js
/**
* This is a faunadb adapter for next-auth
* original source: https://gist.github.com/s-kris/fbb9e5d7ba5e9bb3a5f7bd11f3c42b96
* create collections and indexes in your faunadb shell(dashboard or cli) using the following queries:
CreateCollection({name: 'accounts'});
CreateCollection({name: 'sessions'});
CreateCollection({name: 'users'});
CreateCollection({name: 'verification_requests'});
@waptik
waptik / moment-to-datefns.js
Created October 17, 2020 08:50
Migrating momentjs to date-fns
/**
The idea here is to replace momentjs with date-fns by using the right api to get the same result
you can test it out in https://repl.it/@waptik/WryElasticNlp
**/
var moment = require("moment")
var {formatRelative, subMonths, sub, isBefore} = require("date-fns");
let newD;
const Subs = sub(1610208638 * 1000, { months: 1}) // using this seems to give me the correct answer
@waptik
waptik / settings.json
Last active February 11, 2021 04:03
Cmder VSCode windows
{
...
"terminal.integrated.env.windows": {
"CMDER_ROOT": "C:\\laragon\\bin\\cmder"
},
"terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\cmd.exe",
"terminal.integrated.shellArgs.windows": [
"/K",
"%CMDER_ROOT%\\vendor\\bin\\vscode_init.cmd"
],
@waptik
waptik / user_aliases.cmd
Last active March 30, 2021 14:30
cmder user aliases
;= @echo off
;= rem Call DOSKEY and use this file as the macrofile
;= %SystemRoot%\system32\doskey /listsize=1000 /macrofile=%0%
;= rem In batch mode, jump to the end of the file
;= goto:eof
;= Add aliases below here
e.=explorer .
gl=git log --oneline --all --graph --decorate $*
ls=ls --show-control-chars -F --color $*
pwd=cd
@waptik
waptik / settings.json
Created March 2, 2021 16:16
My Windows Terminal settings
// This file was initially generated by Windows Terminal 1.5.10411.0
// It should still be usable in newer versions, but newer versions might have additional
// settings, help text, or changes that you will not see unless you clear this file
// and let us generate a new one for you.
// To view the default settings, hold "alt" while clicking on the "Settings" button.
// For documentation on these settings, see: https://aka.ms/terminal-documentation
{
"$schema": "https://aka.ms/terminal-profiles-schema",
"defaultProfile": "{86b16bac-aa37-46bd-936f-1416225becc5}",
// You can add more global application settings here.
openapi: 3.0.0
info:
description: "This is a sample server Petstore server. You can find out more about
Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net,
#swagger](http://swagger.io/irc/). For this sample, you can use the api key
`special-key` to test the authorization filters."
version: 1.0.2
title: Swagger Petstore
termsOfService: http://swagger.io/terms/
contact:
@waptik
waptik / paginate.ts
Last active March 27, 2021 07:47
A simple pagination helper function for prisma 2
/**
* This is custom pagination helper that
* works with prisma 2
* @author @_waptik
*/
import db from "db" // xutom prisma wrapper by blitz-js
interface Paginate {
name: string