I hereby claim:
- I am socheatsok78 on github.
- I am socheatsok78 (https://keybase.io/socheatsok78) on keybase.
- I have a public key ASCb2zF9dmUhd0QVPfEeVfhhkg9h9dQrw1Lb0R8xR4D9pAo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
cloud-config
file in the text box that appears. The cloud-config
file is used to provide a script to be run on the first boot. An example is below.export function HttpProgressHandler () { | |
let lastNow = new Date().getTime() | |
let lastKBytes = 0 | |
return function onHttpProgressHandler (e) { | |
if (!e.lengthComputable) return | |
const now = new Date().getTime() | |
const bytes = e.loaded | |
const total = e.total |
export function humanReadableFileSize (bytes, binary = false) { | |
const base = binary ? 1024 : 1000 | |
if (bytes < base) { | |
return `${bytes} B` | |
} | |
const prefix = binary ? ['Ki', 'Mi', 'Gi'] : ['k', 'M', 'G'] | |
let unit = -1 | |
while (Math.abs(bytes) >= base && unit < prefix.length - 1) { | |
bytes /= base |
function formatBytes(bytes,decimals) { | |
if(bytes == 0) return '0 Bytes'; | |
var k = 1024, | |
dm = decimals || 2, | |
sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], | |
i = Math.floor(Math.log(bytes) / Math.log(k)); | |
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i]; | |
} | |
// Usage: |
My personal require.context
helper functions
loadModules
automatically load all vuex store modulesloadRoutes
automatically load all vue routes filesπ₯ Need to check if the current device is a mobile browser in JavaScript?
Here's a little snippet that uses feature detection & is more reliable and trustworthy than checking navigator.userAgent
.
Source: https://twitter.com/ryangjchandler/status/1303722191264141312/photo/1