Skip to content

Instantly share code, notes, and snippets.

View matheushrt's full-sized avatar
:octocat:
🚀

Matheus Henrique Souza matheushrt

:octocat:
🚀
View GitHub Profile
@matheushrt
matheushrt / iterm2.md
Created July 7, 2021 13:24 — forked from squarism/iterm2.md
iterm2 cheatsheet

Tabs and Windows

Function Shortcut
New Tab + T
Close Tab or Window + W (same as many mac apps)
Go to Tab + Number Key (ie: ⌘2 is 2nd tab)
Go to Split Pane by Direction + Option + Arrow Key
Cycle iTerm Windows + backtick (true of all mac apps and works with desktops/mission control)
@matheushrt
matheushrt / getAge.js
Created February 6, 2020 18:34
Getting elapsed time with vanilla Javascript based on milliseconds, not using Date methods.
function getAge(birthDate, dateToCompare) {
const birth = new Date(birthDate);
const dateToCheck = dateToCompare ? new Date(dateToCompare) : new Date();
const [initialYear, finalYear] = [birth.getFullYear(), dateToCheck.getFullYear()];
// getting milliseconds passed from birthdate to the date to check
const milliseconds = dateToCheck.valueOf() - birth.valueOf();
// returning age by transforming milliseconds => minutes => hours => days => years
const age = milliseconds / (1000 * 60 * 60 * 24 * averageDaysPerYear(initialYear, finalYear));
return parseInt(age);