[javascript]
/**
* Format a number to display thousands like in the US -> 1000000 => 1,000,000
* @param number
* @returns
*/
function formatThousands(number) {
return Math.max(0, number).toFixed(0).replace(/(?=(?:d{3})+$)(?!^)/g, ‘,’);
}
[/javascript]
Related Posts
GRADLE: How to copy files from another .jar into your resulting output .jar
In our project we like to deliver a single jar as the final product, if you need to copy files that live on an existing jar into the Gradle’s output jar, this example shows you how to do that (and more) [pastacode lang=”java” manual=”jar%20%7B%0A%2F%2Fthis%20is%20how%20you%20change%20the%20name%20of%20the%20output%20jar%0AarchiveName%3D%E2%80%99frostwire.jar%E2%80%99%0A%0A%2F%2Fsome%20exclusion%20rules%20to%20keep%20your%20.jar%20clean%0Aexclude(%E2%80%98META-INF%2F*.SF%E2%80%99%2C%20%E2%80%98META-INF%2F*.DSA%E2%80%99%2C%20%E2%80%98META-INF%2F*.RSA%E2%80%99%2C%20%E2%80%98META-INF%2F*.MF%E2%80%99)%0A%0A%2F%2Fhere%20we%20grab%20all%20the%20.class%20files%20inside%20messages.jar%20and%20we%20put%20them%20in%20our%20resulting%20jar%0Afrom%20(zipTree(%E2%80%98lib%2Fjars%2Fmessages.jar%E2%80%99))%20%7B%0Ainclude%20%E2%80%98**%2F*.class%E2%80%99%0A%7D%0A%0A%2F%2Fhow%20to%20manipulate%20the%20jar%E2%80%99s%20manifest%0Amanifest%20%7B%0Aattributes%20%E2%80%98Main-Class%E2%80%99%3A%20%E2%80%98com.limegroup.gnutella.gui.Main%E2%80%99%0A%7D%0A%7D” message=”” highlight=”” provider=”manual”/]
How to remove elements from a listbox in Javascript (IE and Firefox)
//By Gubatron, just a silly function to clear the contents of a listbox object var ua = navigator.userAgent.toLowerCase(); var Browser = new Object() Browser.isIE = window.ActiveXObject ? true : false; Browser.isFirefox = (ua.indexOf(“firefox”)!=-1); function clearListbox(listboxObject) { if (Browser.isFirefox) { //in firefox “Option” objects remove themselves. var options = listboxObject.options while (options.length > 0) { options[options.length-1].remove() […]
Apple Wireless Keyboard
I just got a new Apple Wireless Keyboad. My laptop currently sits atop a Griffin Elevator, this keeps it cool and also helps keep my neck at a healthy angle, something I need given how many hours I spend on the computer. The problem with the Elevator is that after a while, your arms get […]