Skip to content

Instantly share code, notes, and snippets.

View gleachkr's full-sized avatar

Graham Leach-Krouse gleachkr

  • Draper Laboratory
  • Arlington, Massachusetts
View GitHub Profile
@dbramucci
dbramucci / HaskellCheatsheet.hs
Last active April 22, 2024 03:57
A cheatsheet for Haskell syntax.
-- 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
{-
@zentala
zentala / formatBytes.js
Created September 27, 2017 11:57
Convert size in bytes to human readable format (JavaScript)
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: