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
(function() {
var controlPanel = (<r><![CDATA[
<div id='controlpanel'>
<h1>First</h1>
<ul>
<li>HappyPath</li>
</ul>
<h1>Second</h1>
//
// Define this.constructor.name so we can introspect an object for it's constructor's name
// (equivalent to the 'Class' name if there were classes...)
// This is necessary because IE does not define this constructor property but FF does.
//
Function.prototype.getName = function() {
var matches = this.toString().match(/function\s+([\w\$]+)\s*\(/);
return matches ? matches[1] : '';
};
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