Skip to content

Instantly share code, notes, and snippets.

View 3stacks's full-sized avatar
🐻
here comes the beast

Luke Boyle 3stacks

🐻
here comes the beast
View GitHub Profile
/**
* @param {Array.<Object>} input
* @param {Number} depth
* @param {Array.<Number>} numbers
* @returns {string}
*/
function filterInputByLineNumber(input, depth, numbers) {
if (depth === numbers.length - 1 || input[numbers[depth]].children.length === 0) {
return input[numbers[depth]].text;
} else {
@3stacks
3stacks / gist:beb35a65359ecde0d8dac6d833249857
Last active September 26, 2016 07:11
recursion-in-practice-2
function calculateRepayments(debt, repay, interest, month, interestPaid) {
if (debt > 0) {
const monthlyInterest = (debt * interest) / 12;
const newDebt = ((debt + monthlyInterest) - repay);
calculateRepayments(newDebt, repay, interest, month + 1, interestPaid + monthlyInterest);
} else {
console.log(`Debt will take ${month} months to pay off`);
console.log(`You will pay a total of $${parseInt(interestPaid/100)} in interest.`);
}
}
@3stacks
3stacks / argus-test.js
Last active December 14, 2016 05:36
Automating Argus Eyes
'use strict';
const Git = require("nodegit");
const shell = require('shelljs');
const colors = require('colors');
const pathToRepo = require("path").resolve("./.git");
// This will be set to the name of our feature branch
let featureBranch;
/**
@3stacks
3stacks / form-validation.js
Last active January 30, 2017 01:45
Functional programming approach to form validation
import generateErrorMessage from 'generate-error-message';
const fields = {
firstName: {
isFieldValid: function() {
const firstName = document.getElementsByName("First_Name")[0].value;
return firstName !== '';
},
userFeedbackElement: document.getElementById("FnameValidation"),
errorMessage: 'Cannot be empty'
@3stacks
3stacks / definition-list.html
Last active March 29, 2017 11:57
A definition list
<dl>
<dt>
Term 1
</dt>
<dd>
A longer definiton. A definition usually expands on the term.🌚
</dd>
<dt>
Term 2
</dt>
@3stacks
3stacks / definition-list-span.html
Last active March 29, 2017 12:04
another definition list
<dl>
<dt>
Term 1
</dt>
<dd>
A longer definiton. A definition usually expands on the term.🌚
</dd>
<span></span>
<dt>
Term 2
dl {
display: flex;
flex-flow: row wrap;
justify-content: space-between;
align-items: flex-start;
}
dt {
width: 30%;
}
@3stacks
3stacks / kill-shortlists.js
Last active July 23, 2018 07:26
Quick script to remove unlisted properties on domain.com.au
const container = document.querySelector('.listings-container');
const items = container.querySelectorAll('.listing-card-container');
items.forEach(item => {
const isSold = item.querySelector('.is-sold');
const isLeased = item.querySelector('.is-leased');
if (isSold || isLeased) {
item.querySelector('.listing-result__shortlist').click();
}
@3stacks
3stacks / rollup.config.js
Last active February 21, 2018 22:34
Simple rollup config
import babel from 'rollup-plugin-babel';
export default {
input: './src/index.js',
output: {
file: './dist/bundle.rollup.js',
format: 'cjs'
},
plugins: [
babel({
@3stacks
3stacks / webpack.config.js
Last active February 21, 2018 22:34
simple webpack config
const path = require('path');
const webpack = require('webpack');
module.exports = {
entry: {
'index.webpack': path.resolve('./src/index.js')
},
output: {
libraryTarget: "umd",
filename: "bundle.webpack.js",