This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Identifying a problem container | |
docker stats --all --format "table {{.ID}}\t{{.Name}}\t{{.CPUPerc}}\t{{.MemUsage}}" | |
# Checking specific container process | |
docker ps | grep <container id> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
echo "jest coverage in a directory" | |
if [ $# -eq 0 ] | |
then | |
echo "No dir supplied" | |
exit | |
fi | |
DIR=$1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
case $# in | |
2) DIR=.;SEARCH=$1;REPLACE=$2;; | |
3) DIR=$1;SEARCH=$2;REPLACE=$3;; | |
esac | |
echo "searching for string in $DIR for *.jsx files: $SEARCH" | |
echo "replacing with string in *.jsx files: $REPLACE" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Async approach global namespace */ | |
async function getData() { | |
return await fetch("https://jsonplaceholder.typicode.com/posts/1").then(response => response.json()); | |
} | |
let data = {}; | |
getData().then(d => data = d); | |
/* Class approach */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git checkout master | |
git checkout -b hotfix # branch off master, make changes here | |
# PR could be submitted at this point for merge to master (production) | |
git checkout master | |
git merge hotfix # merge the fix into master | |
# Could deploy immediately |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// <img>s wrapped in <a> tags | |
// Select images | |
var images = document.querySelectorAll('img'); | |
// Get parent links | |
var links = []; | |
images.forEach( | |
function (el) { | |
links.push(el.parentElement); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var id = getRandomInt(); | |
var div = document.createElement('div'); | |
div.setAttribute('id', id); | |
var reps = 100; | |
function getRandomInt(min, max) { | |
return Math.floor(Math.random() * (max - min)) + min; | |
} | |
function selectByAttribute(reps) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Logger(state) { | |
var on = setInitial(state), | |
levels = { | |
error: 0, | |
log: 1, | |
trace: 2 | |
}; | |
// Define on property getter and setter | |
Object.defineProperty(this, 'on', { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Select a NodeList of image elements | |
var selector = 'ul.pages li img[src]'; // Images with src nested in <li> els in the <ul> with pages class | |
var images = document.querySelectorAll(selector); | |
function saveAll(images) { | |
for(var i=0; i<images.length; i++) { | |
var image = images[i]; | |
saveImageAs(i+1, images[i].src); // use index+1 as their name for page number approximation | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# tabular view of data with scrolling | |
mysql> pager less -SFX | |
mysql> SELECT * FROM sometable; |
NewerOlder