This file contains hidden or 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 buildFunctionRemoverFunction(functionName) { | |
return function (text) { | |
let replacedTxt = text.replaceAll(functionName+"(", "").split(""); | |
let isBracketClosed = true; | |
for (let i = 0; i < replacedTxt.length-1; i+=1) { | |
if (replacedTxt[i] === "(") { | |
isBracketClosed = false; | |
} else if (replacedTxt[i] === ")" && isBracketClosed === false) { |
This file contains hidden or 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 cleanAndSortGraphQLType(typeString) { | |
const lines = typeString.split('\n'); | |
const indent = lines[1].match(/^\s*/)[0]; // Get the leading indentation | |
const cleanLines = lines | |
.map(line => line.replace(/\/\/.*/g, '').trim()) // Remove comments | |
.filter(line => line.length > 0); // Remove empty lines | |
const fields = cleanLines | |
.filter(line => line.includes(':')) |
This file contains hidden or 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
/** | |
* | |
* @param pageName - Page name you want to check | |
* @returns Object { followers, followings, accountsNotFollowBack } | |
*/ | |
async function getListOfPeopleWhoNotFollow(pageName) { | |
let username = pageName; // your page name, mine is oisee_gallery | |
try { | |
console.log("Fetching data...."); | |
let res = await fetch(`https://www.instagram.com/${username}/?__a=1`) |
This file contains hidden or 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
// without request retry | |
async fetchHttpMediaBufferArray(imageUrl) { | |
try { | |
// your request code | |
const bufferResp = await firstValueFrom( | |
this.httpService.get(imageUrl, { responseType: 'arraybuffer' }), | |
); | |
const contentType = bufferResp.headers['content-type']; | |
const buffer = Buffer.from(bufferResp.data); |
This file contains hidden or 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 async function requestWithRetry(requestFunc, errFunc, retryCount = 3) { | |
try { | |
return await requestFunc(); | |
} catch (err) { | |
if (retryCount <= 0) { | |
errFunc(err); | |
} | |
console.log('Request failed, retrying...'); | |
retryCount -= 1; |
This file contains hidden or 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
SELECT COUNT(1) AS COUNT, 'Decimal' as DataType | |
FROM @TableName | |
WHERE @ColumnName ~ '^\d+\.\d+$' | |
UNION ALL | |
SELECT COUNT(1) AS COUNT, 'Integer' as DataType | |
FROM @TableName | |
WHERE @ColumnName ~ '^\+?(0|[1-9]\d*)$' | |
UNION ALL |