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 const gatherDeviceIntel = () => { | |
const header = [ | |
navigator.platform, | |
navigator.userAgent, | |
navigator.appVersion, | |
navigator.vendor, | |
window.opera | |
] | |
const dataos = [ | |
{ name: 'Windows Phone', value: 'Windows Phone', version: 'OS' }, |
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
for (var i = 1; i <= 100; i++) console.log((i % 3 ? "" : "Fizz") + (i % 5 ? "" : "Buzz") || i) |
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
#!/usr/bin/env python | |
for x in range(1,101): | |
s = "" | |
if x % 3 == 0: | |
s += "Fizz" | |
if x % 5 == 0: | |
s += "Buzz" | |
if s == "": | |
s = x |
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 const createRange = (len, zeroBased = true) => | |
new Array(len).fill().map((_, i) => zeroBased ? i : i + 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
export const findParentByClass = (el, className) => { | |
while (el.parentNode) { | |
el = el.parentNode | |
if (el.classList && el.classList.contains(className)) return el | |
} | |
return null | |
} |
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
<template> | |
<div | |
class="q-date-mask" | |
@keyup.capture="updateValue"> | |
<input | |
v-if="showDay" | |
ref="day" | |
v-model="day" | |
class="q-date-mask__input q-date-mask__input--day" | |
type="number" |
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 const copy = async (text) => { | |
try { | |
await navigator.clipboard.writeText(text) | |
console.log('Text copied:', text) | |
} catch (err) { | |
console.error('Failed to copy:', err) | |
} | |
} | |
export const paste = async (selector, readOnly = 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
/** Small module to expose get and post methods around fetch for API communication (bearer token in headers, etc.) */ | |
const host = process.env.API_DOMAIN | |
const prefix = `/api/v1` | |
export const getData = ({ url, accessToken, paymentId, headers, noJson }) => | |
request({ url, accessToken, paymentId, headers, noJson, method: 'GET' }) | |
export const postData = ({ url, accessToken, paymentId, headers, data, method }) => { | |
method = method || 'POST' |
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
// Generates a small hash (useful for CSRF state params, mocking a token in localStorage for development, etc.) | |
export const generateHash = str => '_' + Math.random().toString(36).substr(2, 9) |
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 isPrimeNumber(n) { | |
for (var i = 2; i < n; i++) { // i will always be less than the parameter so the condition below will never allow parameter to be divisible by itself ex. (7 % 7 = 0) which would return true | |
if (n % i === 0) return false // when parameter is divisible by i, it's not a prime number so return false | |
} | |
return n > 1 // otherwise it's a prime number so return true (it also must be greater than 1, reason for the n > 1 instead of true) | |
} |