Skip to content

Instantly share code, notes, and snippets.

View dilipsuthar97's full-sized avatar
:octocat:
Enjoying tech world

Dilip Suthar dilipsuthar97

:octocat:
Enjoying tech world
View GitHub Profile
@dilipsuthar97
dilipsuthar97 / token-generator.js
Created March 30, 2022 17:32 — forked from ziluvatar/token-generator.js
Example of refreshing tokens with jwt
/**
* Example to refresh tokens using https://github.com/auth0/node-jsonwebtoken
* It was requested to be introduced at as part of the jsonwebtoken library,
* since we feel it does not add too much value but it will add code to mantain
* we won't include it.
*
* I create this gist just to help those who want to auto-refresh JWTs.
*/
const jwt = require('jsonwebtoken');

Problem

I have two Github accounts: oanhnn (personal) and superman (for work). I want to use both accounts on same computer (without typing password everytime, when doing git push or pull).

Solution

Use ssh keys and define host aliases in ssh config file (each alias for an account).

How to?

  1. Generate ssh key pairs for accounts and add them to GitHub accounts.
@dilipsuthar97
dilipsuthar97 / base64.js
Created March 2, 2022 16:37 — forked from chrisveness/base64.js
Encode/decode ASCII string to/from base64
/**
* Encode string into Base64, as defined by RFC 4648 [http://tools.ietf.org/html/rfc4648].
* As per RFC 4648, no newlines are added.
*
* Characters in str must be within ISO-8859-1 with Unicode code point <= 256.
*
* Can be achieved JavaScript with btoa(), but this approach may be useful in other languages.
*
* @param {string} str ASCII/ISO-8859-1 string to be encoded as base-64.
* @returns {string} Base64-encoded string.
module.exports = {
bracketSpacing: true,
jsxBracketSameLine: true,
singleQuote: true,
jsxSingleQuote: true,
trailingComma: 'all',
usesTabs: true,
tabWidth: 4,
printWidth: 100,
};
@dilipsuthar97
dilipsuthar97 / Tools.js
Last active January 27, 2022 12:21
Global helper functions
import { Constants } from '../CommonConfig';
import moment from 'moment';
/**
* Return random number between inclusive and exclusive
* @param {Number} length - exclusive length for randome number
* @param {Boolean} countOne - add plus 1 count
*/
const getRandomNumber = (exclusiveLength = 1, countOne = false) => {
if (countOne) {
import * as React from 'react';
import { View, Text, Image, StyleSheet, Animated } from 'react-native';
import { Matrics, Colors, Icons, Fonts } from '../CommonConfig';
import { Tools } from '../Helpers';
import Bounceable from './Bounceable';
/**
* 'reactionFlag' value is same as in DB
* it's useful during sending data with API request
*/
// --------------- LIBRARIES ---------------
import React from 'react';
import { View, StyleSheet, Image } from 'react-native';
import FastImage from 'react-native-fast-image';
// --------------- ASSETS ---------------
// --------------- COMPONENT ---------------
const MyFastImage = ({
style,
placeholder,
import React from 'react';
import { Animated } from 'react-native';
import {
TapGestureHandler,
LongPressGestureHandler,
State,
} from 'react-native-gesture-handler';
export default ({
children,
// --------------- LIBRARIES ---------------
import * as React from 'react';
import { View, TouchableOpacity, StyleSheet, Platform } from 'react-native';
import { FlatList } from 'react-native-gesture-handler';
import Animated from 'react-native-reanimated';
const AnimatedFlatList = Animated.createAnimatedComponent(FlatList);
const {
event,
Value,
import React from 'react';
import {
StyleSheet,
Text,
View,
StatusBar,
Dimensions,
Image,
Animated,
findNodeHandle,