This file contains 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
-- save as HaskellCheatsheet.hs | |
module HaskellCheatsheet where | |
-- On Windows, I sometimes have to remove the module line above | |
-- in order to get GHC to compile the file as an executable instead | |
-- of a library. | |
-- Single line comment | |
{- |
This file contains 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 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: |