View Download Instagram Image
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
(async function() { | |
const cls1 = [ | |
'article[role="presentation"]', | |
'div[style]', | |
'div[style]', | |
'div[role="button"]', | |
'div', | |
'div[role="button"]', | |
'div[style]', | |
'img[crossorigin="anonymous"][class]', |
View main.dart
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
// Slashy things are single-line comments, very useful | |
/* | |
* Slashy + star are multi-line comments | |
* | |
* This is a basic inheritence example, | |
* which is a core principle of OOP, or Object Oriented Programming | |
*/ | |
// Imports let you use things from other libraries (code) | |
// that you or others have written |
View tables-to-csvs.js
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() { | |
const table2csv = table => { | |
const rows = [...table.querySelectorAll('tr')] | |
const csv = [] | |
if (rows.length < 20) return null | |
for (let i in rows) { |
View is_valid_email.js
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 isValidateEmail = email => { | |
const re = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/ | |
return re.test(String(email).toLowerCase()) | |
} |
View format_currency.js
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 formatCurrency = (number, currency) => { | |
const options = { | |
minimumFractionDigits: 2, | |
currencyDisplay: 'narrowSymbol', | |
currencySign: 'accounting', | |
} | |
if (currency) { | |
options.style = 'currency' | |
options.currency = currency | |
} |
View get_locale.js
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 getLocale = () => { | |
const locale = (navigator.languages && navigator.languages.length) | |
? navigator.languages[0] | |
: navigator.language | |
return locale || 'en-US' | |
} |
View snippet.js
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 snippet = (val, len = 5) => | |
(val && val.length > (len * 2)) | |
? val.substring(0, len) + '...' + val.substring(val.length - len) | |
: val |
View is_primitive.js
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 isPrimitive = val => { | |
const type = typeof val | |
if (Array.isArray(val)) return false | |
if (type === 'object') return val === null | |
return type !== 'function' | |
} |
View debounce.js
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 function debounce(func, wait, immediate) { | |
let timeout | |
return function (...args) { | |
clearTimeout(timeout) | |
timeout = setTimeout(() => { | |
timeout = null | |
if (!immediate) func.apply(this, args) | |
}, wait) | |
if (immediate && !timeout) func.apply(this, [...args]) | |
} |
View copy_to_clipboard.js
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 copyToClipboard = async (text) => { | |
if (!navigator.clipboard) | |
// Clipboard API not available | |
throw new Error('Your browser doesn\'t allow clipboard access') | |
try { | |
await navigator.clipboard.writeText(text) | |
} catch (e) { | |
log.error('Failed to copy', e) |
NewerOlder