This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const uploadFile = ({ | |
api, | |
fileId, | |
payload, | |
onSuccess: _onSuccess, | |
onProgress: _onProgress, | |
onError: _onError, | |
onAbort: _onAbort, | |
abortMaker, | |
}) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const http = require("http"); | |
const https = require("https"); | |
// Ignore SSL error | |
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0"; | |
const createProxyServer = ({ url, headers, responseHeaders } = {}) => { | |
let forwardUrl; | |
try { | |
forwardUrl = new URL(url); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Uploads a file using XMLHttpRequest with progress, error, and abort handling. | |
* | |
* @param {Object} options - The options for the file upload. | |
* @param {string} options.api - The API endpoint for the file upload. | |
* @param {File} options.file - The File object to be uploaded. | |
* @param {string} options.type - The MIME type of the file. | |
* @param {string} [options.method="PUT"] - The HTTP method for the request. | |
* @param {function} [options.onProgress] - A callback function to handle upload progress. | |
* @param {function} [options.onError] - A callback function to handle upload errors. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const webpack = require("webpack"); | |
const { RawSource } = require("webpack-sources"); | |
class DynamicLoadScript { | |
constructor(options = { filename: "bundle.js" }) { | |
this.options = options; | |
} | |
apply(compiler) { | |
compiler.hooks.thisCompilation.tap("DynamicLoadScript", (compilation) => { | |
compilation.hooks.processAssets.tapPromise( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { deepEqual } = require('assert'); | |
Object.defineProperty(Object.prototype, 'deepEqual', { | |
writable: false, | |
enumerable: false, | |
configurable: false, | |
value: (a, b) => deepEqual(a, b), | |
}) | |
// Usage: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"extends": [ | |
"react-app", | |
"eslint:recommended", | |
"plugin:react/recommended", | |
"plugin:react-hooks/recommended", | |
"prettier" | |
], | |
"plugins": ["react", "import"], | |
"parserOptions": { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function sumDiagonal(a){ | |
const n = Math.sqrt(a.length); | |
const op = { d1: 0, d2: 0 }; | |
for(let i = 0; i < n; i++){ | |
op.d1 += a[i + n * i ]; | |
op.d2 += a[n - i - 1 + n * i]; | |
} | |
return op; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const ds = function (p) { | |
let s = 1; | |
if (p[0] === '-') { | |
s = -1; | |
p = p.substr(1); | |
} | |
return function (a, b) { | |
let r = 0; | |
if (typeof a[p] === 'string' || typeof b[p] === 'string') { | |
let _a = String(a[p]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git filter-branch --env-filter ' | |
WRONG_EMAIL="old-email@example.com" | |
NEW_NAME="New Name" | |
NEW_EMAIL="new-email@example.com" | |
if [ "$GIT_COMMITTER_EMAIL" = "$WRONG_EMAIL" ] | |
then | |
export GIT_COMMITTER_NAME="$NEW_NAME" | |
export GIT_COMMITTER_EMAIL="$NEW_EMAIL" | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"BD": { | |
"countryName": "Bangladesh", | |
"currency": "BDT", | |
"symbol": "Tk" | |
}, | |
"BE": { | |
"countryName": "Belgium", | |
"currency": "EUR", | |
"symbol": "€" |
NewerOlder