Skip to content

Instantly share code, notes, and snippets.

@soerson
soerson / iterm2.md
Created July 6, 2020 12:53 — 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)
const randomRange = (min, max) => {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
@soerson
soerson / aspect-ratio.scss
Created September 5, 2016 08:20
aspect ratio hack
@mixin aspect-ratio($width, $height) {
position: relative;
padding-bottom: ($height / $width) * 100%;
img,
video,
iframe,
object,
embed {
position: absolute;
top: 0;
@soerson
soerson / copyToClipboard.js
Created September 4, 2016 09:52
copy string to clipboard
function copyToClipboard(text) {
var el = document.createElement('textarea');
el.style.position = 'absolute';
el.style.left = '-9999px';
el.setAttribute('readonly', '');
el.value = text;
document.body.appendChild(el);
el.select();
@soerson
soerson / getClass.js
Last active July 30, 2016 20:52
get object [[Class]] property
function getClass(obj) {
return {}.toString.call(obj).slice(8, -1);
}
@soerson
soerson / resizeHandler.js
Last active July 30, 2016 20:51
window resize event handler
var resizeID;
window.addEventListener("resize", function () {
clearTimeout(resizeID);
resizeID = setTimeout(resizeHandler, 500);
});
function resizeHandler() {
/* ... */
}
@soerson
soerson / getPageScroll.js
Created July 1, 2016 04:18
getPageScroll.js
var getPageScroll = (window.pageXOffset !== undefined) ?
function () {
return {
top: pageYOffset,
left: pageXOffset
}
} : function () {
var html = document.documentElement;
var body = document.body;
@soerson
soerson / closest.js
Created June 22, 2016 20:13
elem.closest() polyfill
if (document.documentElement.closest === undefined) {
Element.prototype.closest = function (css) {
var elem = this;
do {
if (elem.matches(css)) return elem;
elem = elem.parentElement;
} while (elem);
}
}
@soerson
soerson / showOnParentHover.scss
Created March 16, 2016 14:43
SCSS: show block on parent hover
@mixin showOnParentHover($parent, $duration: 0.3s) {
& {
visibility: hidden;
opacity: 0;
transition: opacity 0.2s, visibility 0.2s;
}
@at-root .#{$parent}:hover & {
visibility: visible;
@soerson
soerson / pseudoIcon.scss
Last active March 12, 2016 09:45
SCSS: pseudoIcon
@mixin pseudoIcon($gap, $direction: left) {
@if ($direction == 'left') {
$pseudoElement: before;
}
@else if ($direction == 'right'){
$pseudoElement: after;
}
@else {
@error "+pseudoIcon: wrong direction";