Skip to content

Instantly share code, notes, and snippets.

View msvargas's full-sized avatar

msvargas msvargas

  • Bucaramanga, Colombia
View GitHub Profile
@msvargas
msvargas / import2lazy.js
Last active October 28, 2022 15:20
Import to React Lazy
const { execSync } = require('child_process');
const os = require('os');
const path = require('path');
const fs = require('fs');
const tempFile = path.resolve(os.tmpdir(), 'importFile.js');
const IMPORT_REGEX = /import\s+(\S+)\s+from\s+['|"](\S+)['|"]/gm;
let result;
let output = '';
@msvargas
msvargas / axios.refresh_token.1.js
Created September 7, 2020 16:05 — forked from Godofbrowser/axios.refresh_token.1.js
Axios interceptor for refresh token when you have multiple parallel requests. Demo implementation: https://github.com/Godofbrowser/axios-refresh-multiple-request
// for multiple requests
let isRefreshing = false;
let failedQueue = [];
const processQueue = (error, token = null) => {
failedQueue.forEach(prom => {
if (error) {
prom.reject(error);
} else {
prom.resolve(token);
@msvargas
msvargas / Base64.ts
Last active November 16, 2021 07:41
Signature Pad component with react-native-svg
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
const Base64 = {
btoa: (input: string = '') => {
let str = input;
let output = '';
for (
let block = 0, charCode, i = 0, map = chars;
str.charAt(i | 0) || ((map = '='), i % 1);
output += map.charAt(63 & (block >> (8 - (i % 1) * 8)))
"use strict";
/* qr.js -- QR code generator in Javascript (revision 2011-01-19)
* Written by Kang Seonghoon <public+qrjs@mearie.org>.
*
* This source code is in the public domain; if your jurisdiction does not
* recognize the public domain the terms of Creative Commons CC0 license
* apply. In the other words, you can always do what you want.
*/
// per-version information (cf. JIS X 0510:2004 pp. 30--36, 71)