Skip to content

Instantly share code, notes, and snippets.

Avatar

Adam Scott ascott1

View GitHub Profile
@ascott1
ascott1 / bugreport.js
Created Dec 11, 2013
Bug Report Template Bookmarklet
View bugreport.js
javascript:(function() {
var e = document.getElementById('issue_body');
if (e) {
e.value += '# URL\n\n\n' +
'# Actual Behavior\n\n\n' +
'# Expected Behavior\n\n\n' +
'# Steps to Reproduce\n\n\n' +
'# Screenshot';
}
})();
@ascott1
ascott1 / index.js
Created Feb 19, 2014
requirebin sketch
View index.js
var Financial = require('financial');
var Money = require('accounting');
// calculate the monthly payment of a loan
var calcPayment = function(loanRate, loanYears, loanAmt) {
var monthlyPayment = Financial.PMT(loanRate / 100 / 12, loanYears * 12, loanAmt);
return makeMoney(monthlyPayment);
};
// calculate the total interest paid
@ascott1
ascott1 / gist:9368476
Created Mar 5, 2014
Open GitHub URL for current directory/repo...
View gist:9368476
alias go="open \`git remote -v | grep git@github.com | grep fetch | head -1 | cut -f2 | cut -d' ' -f1 | sed -e's/:/\//' -e 's/git@/http:\/\//'\`"
@ascott1
ascott1 / gist:9971a87c84c395ef137d
Last active Aug 29, 2015
Basic Ubuntu Node Setup
View gist:9971a87c84c395ef137d
sudo apt-get update
sudo apt-get install -y python-software-properties python g++ make
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install -y nodejs
View gist:886fe14f65f48b252b3b
var updateComparisons = function() {
$('.interest-cost').each(function( index ) {
var rate = $(this).siblings('.rate-compare').val(),
length = parseInt($(this).find('.loan-years').text(), 10),
totalInterest = interest(rate, length, details.amount),
$selector = $(this).find('.new-cost');
$selector.text(totalInterest);
});
};
@ascott1
ascott1 / gist:ccfb745bc2d5a361b55f
Created May 12, 2014
simple object comparison
View gist:ccfb745bc2d5a361b55f
var compare = function(a, b) {
"use strict";
// iterate over each key in b
for (var key in b) {
// check if the key is present in a
if (key in a) {
// make sure a and be are not exact matches
if (b[key] !== a[key]) {
c[key] = b[key]; // if not an exact match add to c
}
@ascott1
ascott1 / gist:d02ef9d2e29fad17e77f
Created May 12, 2014
object comparison with recursion
View gist:d02ef9d2e29fad17e77f
var compare = function(a, b) {
"use strict";
// iterate over each key in b
for (var key in b) {
// check if the key is present in a
if (key in a) {
// make sure a and be are not exact matches
if (b[key] !== a[key]) {
if (typeof b[key] === "object") {
// if b[key] is an object recursively call compare
@ascott1
ascott1 / index.js
Created Jun 4, 2014
requirebin sketch
View index.js
require('console-log').show(true);
var Financial = require('financial');
var Money = require('accounting');
var calcPayment = function(loanRate, loanYears, loanAmt) {
var monthlyPayment = Financial.PMT(loanRate / 100 / 12, loanYears * 12, loanAmt);
monthlyPayment = Math.abs(monthlyPayment);
return makeMoney(monthlyPayment);
};
@ascott1
ascott1 / index.js
Created Jun 9, 2014
requirebin sketch
View index.js
require('console-log').show(true);
var loanCalc = require('loan-calc');
// amortization table calculations
// calculate the monthly payment using loan-calc
// calculate the interest paid per payment
// calculate remaining loan balance
// calculate sum of interest payments
var amortizationCalc = function(amount, rate, totalTerm, amortizeTerm) {
var monthlyPayment = loanCalc.paymentCalc({amount: amount, rate:rate, termMonths: totalTerm}),
@ascott1
ascott1 / gist:6ec0a582c366b9d2c63f
Last active Aug 29, 2015
> link icon without border
View gist:6ec0a582c366b9d2c63f
.go-link {
display: inline-block;
position: relative;
margin-right: 1.25em;
}
.go-link:after {
.cf-icon;
content: "\e002";
display: block;