Skip to content

Instantly share code, notes, and snippets.

View ascott1's full-sized avatar

Adam Scott ascott1

View GitHub Profile
@ascott1
ascott1 / bugreport.js
Created December 11, 2013 14:15
Bug Report Template Bookmarklet
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 February 19, 2014 02:50
requirebin sketch
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 March 5, 2014 14:42
Open GitHub URL for current directory/repo...
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 August 29, 2015 14:01
Basic Ubuntu Node Setup
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
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 23:12
simple object comparison
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 23:49
object comparison with recursion
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 June 4, 2014 13:27
requirebin sketch
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 June 9, 2014 20:42
requirebin sketch
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 August 29, 2015 14:02
> link icon without border
.go-link {
display: inline-block;
position: relative;
margin-right: 1.25em;
}
.go-link:after {
.cf-icon;
content: "\e002";
display: block;