Skip to content

Instantly share code, notes, and snippets.

View martinlaws's full-sized avatar

Martin Laws martinlaws

View GitHub Profile
@martinlaws
martinlaws / setup.sh
Last active June 11, 2021 20:01 — forked from bradp/setup.sh
New Mac Setup Script
#!/bin/sh
start=`date +%s`
bold=$(tput bold)
normal=$(tput sgr0)
red=`tput setaf 1`
green=`tput setaf 2`
reset=`tput sgr0`
// bracket pair colorizer
const arrayOfNames = ["martin", "scott", "craig", "maya"];
arrayOfNames.forEach(function(names) {
console.log(names)
})
for (let name of arrayOfNames) {
console.log(name);
}
function Person(firstName, lastName, hairColor, heightInCm, favouriteAnimal = 'dog') {
this.firstName = firstName
this.lastName = lastName
this.hairColor = hairColor
this.heightInCm = heightInCm
this.heightInInches = function() {
return this.heightInCm / 2.54
}
this.pets = []
this.favouriteAnimal = favouriteAnimal
// Option 1: Math.min()
const findSmallestIntUsingMathMin = args => {
return Math.min(...args);
};
console.log(findSmallestIntUsingMathMin([1, 2, 3, 4, 0, 5]));
// Option 2: Array.reduce()
const reducer = (minValue, currentValue) =>
minValue < currentValue ? minValue : currentValue;
// bracket pair colorizer
const arrayOfNames = ["martin", "scott", "craig", "maya"];
arrayOfNames.forEach(function(names) {
console.log(names)
})
for (let name of arrayOfNames) {
console.log(name);
}
const person = {
firstName: 'Martin',
lastName: 'Laws',
heightInCm: 188,
heightInInches: function() {
return this.heightInCm / 2.54
},
speak() {
console.log(`Hi, my name is ${this.firstName}!`)
return
@martinlaws
martinlaws / lhl-final-project-kickoff.md
Last active May 22, 2019 14:46
LHL Final Project Planning

Final project kickoff

First some administrative stuff! Before you start you will need to supply the following:

  • Team Members
  • Project Description
  • Tech stack (and short reason why)
  • Project Name
  • Preferences for mentor (if any)

Objects

Keys point to values "Look up" (like a dictionary)

var person = {
  name: 'Martin',
  hair: 'brown',
  height: 188
}
@martinlaws
martinlaws / unwatch.js
Created April 11, 2019 19:22
Unwatch all GitHub repos in an org
Array.prototype
.slice.apply(document.querySelectorAll('.Box-row'))
.forEach(el => {
const org = el.querySelector('a[href^="/YOUR_ORG"]');
if (org) el.querySelector('button[value="included"]').click()
});
var xpath = "//a[text()='Next']";
var matchingElement = document.evaluate(xpath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
matchingElement.click();
@martinlaws
martinlaws / .zshrc
Last active March 31, 2019 22:27
Martin's optimal zsh config
# Lines configured by zsh-newuser-install
HISTFILE=~/.histfile
HISTSIZE=100000
SAVEHIST=100000
bindkey -v
# End of lines configured by zsh-newuser-install
# The following lines were added by compinstall
zstyle :compinstall filename '/Users/martin/.zshrc'
autoload -Uz compinit