Skip to content

Instantly share code, notes, and snippets.

View joshprice's full-sized avatar
⚗️
Alembic is hiring!

Josh Price joshprice

⚗️
Alembic is hiring!
View GitHub Profile
IO.read("testfile") # reads testfile in as a string
IO.readlines("testfile") # reads testfile in as an array
IO.read("testfile") # reads testfile in as a string
IO.readlines("testfile") # reads testfile in as an array
String.prototype.reverse = function() {
return this.split("").reverse().join("");
}
Number.prototype.formatAsCurrency = function() {
return this.toString()
.replace(/^(\d)$/, "00$1") // pad 1 digit
.replace(/^(\d{2})$/, "0$1") // pad 2 digits
.reverse()
.replace(/(\d{2}(?=\d))/, "$1.") // place decimal point