Skip to content

Instantly share code, notes, and snippets.

View assadvirgo's full-sized avatar

Assad Mahmood Qazi assadvirgo

  • Islamabad, Pakistan
View GitHub Profile
@assadvirgo
assadvirgo / floatingmath.js
Created February 3, 2021 13:14
Simple Math Util Functions to Solve Floating Point Problems
const toInt = (n) => {
// If n is not a number return n
if ( typeof n != 'number') return n;
let s = n.toString();
// If n is a whole number return n
if (s.indexOf('.') == -1) return n;
// If n is a floating number return the int representation
let len = s.split('.')[1].length;
@assadvirgo
assadvirgo / truncate.js
Created November 17, 2020 08:24
Truncate to Decimal Places Without Round
// Usage
// let x = 2.1234;
// x.trunc(2);
// Result: "2.12"
// x = 2;
// x.trunc(2)
// Result: "2.00"
// @input d - decimal places to truncate
@assadvirgo
assadvirgo / AsposeStorage.page
Last active August 29, 2015 14:15
Upload Salesforce Static Resource to Aspose Storage
<apex:page controller="AsposeStorageController">
<apex:form id="theForm">
<apex:pageBlock title="Requirements" rendered="true">
<ol>
<li>Register aspose account.</li>
<li>Fill in the form below and click Run Sample (all fields are required).</li>
</ol>
</apex:pageBlock>
<apex:pageBlock title="Upload Static Resources to Aspose Storage" rendered="true">
<table>