Skip to content

Instantly share code, notes, and snippets.

View jefflombard's full-sized avatar

Jeff Lombard jefflombard

View GitHub Profile
// Don't Do this
let input = document.getElementById('input');
// Checks to see if input is valid.
if (input.value != ''){
callFunction();
}
// Do this instead
let input = document.getElementById('input');
let isValidInput = input.value != '';
@jefflombard
jefflombard / CDD_function.js
Created December 26, 2018 19:44
Comment Driven Development
function validateTextInput(){
// checks all text inputs to make sure they are not empty.
}
@jefflombard
jefflombard / CDD_template.js
Last active December 26, 2018 19:57
An example of progressively building out a function with comment driven development.
function addFive(){
// Setup - Declare all variables that I will need.
let inputNumber, newNumber;
// Input - Handle any user input.
inputText = prompt('Enter a numerical value');
// Transform - Compute any values once I have all dependencies.
newNumber = inputNumber + 5;
@jefflombard
jefflombard / ag_replace.sh
Last active October 12, 2021 13:36
agr command - Find and Replace with ag on Mac OSX
#!/bin/sh
agr () {
# find and replace
regex=s/${1}/${2}/g;
ag $1 -l | xargs sed -i.agr_backup $regex;
# delete backups
ag -G .agr_backup -l | xargs rm
}