Skip to content

Instantly share code, notes, and snippets.

View daryl-sf's full-sized avatar

Daryl Findlay daryl-sf

View GitHub Profile
@daryl-sf
daryl-sf / interestCalc.js
Created October 25, 2023 14:06
Quick and Dirty interest calc
const interestCalc = (init, rate, years) => {
const pot = [...Array(years).keys()].reduce((acc, c) => {
const earnings = acc * rate;
acc += earnings;
console.log(`Earnings: £${earnings.toFixed(2)}, New Total: £${acc.toFixed(2)}`);
return acc;
}, init);
console.log(`Total: £${pot.toFixed(2)}. Total Earned: £${(pot - init).toFixed(2)}`);
}
@daryl-sf
daryl-sf / settings.json
Created February 24, 2023 14:57
vscode settings
{
"editor.defaultFormatter": "dbaeumer.vscode-eslint",
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true,
"source.fixAll.stylelint": true
},
"editor.formatOnSave": true,
"eslint.format.enable": true
}
@daryl-sf
daryl-sf / index.js
Last active February 22, 2023 12:15
hash function gist
const crypto = require("crypto");
function hash(data, callback) {
let counter = 0;
let result = [];
let func = () => {
if(counter === data.length) {
callback(result);
return;
@daryl-sf
daryl-sf / curl-format.txt
Last active June 18, 2019 09:12
JS function that will curl a server asynchronously for each element in an array ([1,2,3] = 3) and log out the request/response times
time_namelookup: %{time_namelookup}\n
time_connect: %{time_connect}\n
time_appconnect: %{time_appconnect}\n
time_pretransfer: %{time_pretransfer}\n
time_redirect: %{time_redirect}\n
time_starttransfer: %{time_starttransfer}\n
----------\n
time_total: %{time_total}\n
@daryl-sf
daryl-sf / recreate-dev-db.sh
Created April 4, 2019 14:41
drop and recreate dev
#!/bin/bash
echo 'Dropping squarefoot_development DB';
dropdb 'squarefoot_development';
echo 'Recreating squarefoot_development DB';
psql -c 'create database squarefoot_development';
psql squarefoot_development -c 'CREATE extension plpgsql';
psql squarefoot_development -c 'CREATE extension postgis';
psql squarefoot_development -c 'CREATE extension hstore';