Skip to content

Instantly share code, notes, and snippets.

View babacarMbengue12's full-sized avatar

Babacar Mbengue babacarMbengue12

View GitHub Profile
@babacarMbengue12
babacarMbengue12 / customView.tsx
Last active October 5, 2023 16:28
How to customise react native view and add custom props
import React, { ReactNode } from "react";
import { View as ReactView, ViewStyle } from "react-native";
export type CustomProps = Partial<{
mt: number | "auto";
mb: number | "auto";
my: number | "auto";
mx: number | "auto";
ml: number | "auto";
mr: number | "auto";
@babacarMbengue12
babacarMbengue12 / verify_token.js
Created June 24, 2022 22:37
javascript verify if user token is expired
import jwtDecode from "jwt-decode";
function dateFromUnix(unix){
return new Date(unix * 1000)
}
function isTokenExpired(token: string,unixField="exp"){
if (token) {
const decoded = jwtDecode(token);
const exp = decoded[unixField]
return dateFromUnix(exp) < new Date()
@babacarMbengue12
babacarMbengue12 / paginate.js
Created June 12, 2022 22:14
Paginate data using lodash support typescript and javascript
import _ from "lodash";
function paginate(
items,
page=1,
pageSize = 100
){
const offset = (page - 1) * pageSize;
const pagedItems = _.drop(items, offset).slice(0, pageSize);
return {