What do you want to save?
Add Code snippet
New code examples
-
Javascript 2021-09-16 04:03:01
javascript function convert bytes into mb
function niceBytes(x){ const units = ['bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; let l = 0, n = parseInt(x, 10) || 0; while(n >= 1024 && ++l){ n = n/1024; } return(n.toFixed(n < 10 && l > 0 ? 1 : 0) +... Add solution -
Other 2021-09-15 08:58:02
show percent of axios complete requested vuejs
/* Make the request to the POST /single-file URL */ axios.post( '/file-progress', formData, { headers: { 'Content-Type': 'multipart/form-data' }, onUploadProgress: function( progressEvent ) { this.uploadPercentage = parseIn... Add solution -
Javascript 2021-09-15 07:12:04
passing html vlaues to Javascript function
<body> <h1>Adding 'a' and 'b'</h1> a: <input type="number" name="a" id="a"><br> b: <input type="number" name="b" id="b"><br> <button onclick=&q... Add solution -
Javascript 2021-09-15 00:19:03
javascript rgb to hex
function rgbToHex(r, g, b) { return "#" + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1); } function hexToRgb(hex) { var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex); if(result){ var... Add solution -
Javascript 2021-09-14 23:01:03
javascript rpg tutorial
tChar.fight = function(enemy){ //assumes enemy is also based on Char hitPerc = (this.hitPerc - enemy.defMod) / 100; if (Math.random() < hitPerc){ damage = 0; for (i = 0; i < this.damage; i++){ damage += parseInt(Math.random()... Add solution -
Other 2021-09-14 13:26:02
java.lang.object[4]
List<Object> result = (List<Object>) LoadSource.list(); Iterator itr = result.iterator(); while(itr.hasNext()){ Object[] obj = (Object[]) itr.next(); //now you have one array of Object for each row String client = String.valueOf(obj[... Add solution -
Javascript 2021-09-14 10:16:03
How to avoid scientific notation for large numbers in JavaScript?
function toFixed(x) { if (Math.abs(x) < 1.0) { var e = parseInt(x.toString().split('e-')[1]); if (e) { x *= Math.pow(10,e-1); x = '0.' + (new Array(e)).join('0') + x.toString().substring(2); } } else { var e = parseI... Add solution