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
@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 / 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 / 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 / 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(){
...
const tabs = [
'Account',
'Profile',
'Payment',
'Notification',
'Advanced'
]
...
@waptik
waptik / packages-projects-toUse.txt
Last active April 19, 2020 08:45
Useful packages or projects to use
https://github.com/dilame/instagram-private-api
https://github.com/social-manager-tools/socialmanagertools-igbot
https://github.com/jlobos/instagram-web-api
https://github.com/tobiaslins/avatar
https://github.com/oktaysenkan/instagram-api
https://github.com/preethamvishy/instalytics
https://github.com/ashalogic/IG-SAnalyzer
https://github.com/moigonzalez/travelmap/pulse
https://github.com/rolspace/instagram-server-side
https://github.com/shameemreza/instagram-widget
@waptik
waptik / coursesLinks.txt
Created April 17, 2020 12:31
Links to courses
@waptik
waptik / detectPaymentMethodFromCustomerLocation.ts
Created March 19, 2020 15:36
Select preferred payment method based on user's location
import paymentService, {paymentServiceType} from '@/services/paymentService'
import locationService, {locationServiceType} from '@/services/locationService'
// import paymentService from '@/services/paymentService'
const payWith: paymentServiceType = new paymentService()
export const locate: locationServiceType = new locationService()
// 2 letters country code
@waptik
waptik / devlinks.txt
Created March 17, 2020 03:44
Useful links for devs
https://medium.com/@joomiguelcunha/learn-map-filter-and-reduce-in-javascript-ea59009593c4
https://medium.com/@92sharmasaurabh/fetch-api-to-return-observable-5eece2947d44
https://stackoverflow.com/questions/44877062/how-to-convert-a-fetch-api-response-to-rxjs-observable
https://stackoverflow.com/questions/55937254/reactjs-dynamically-add-a-component-on-click
https://stackoverflow.com/questions/58717372/nested-api-requests-with-rxjs-on-angular
https://dev.to/gc_psk/practical-rxjs-and-angular-5heg
https://stackoverflow.com/questions/40170157/rxjs-refactor-nested-map-statement#40186121
https://stackoverflow.com/a/58734987 // using refs to access components methods in ionic react