function insertionSort(arr) {
for(let i = 1; i < arr.length; i++) {
let key = arr[i];
let j = i - 1;
while (j >= 0 && arr[j] > key) {
arr[j + 1] = arr[j];
j = j - 1;
}
arr[j + 1] = key;
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
const fetch = require('node-fetch'); | |
const cheerio = require('cheerio'); | |
async function get() { | |
const data = await fetch('https://httpstatuses.com/200').then(res => res.text()) | |
console.log('\n =========================>: get -> data', data); | |
const $ = cheerio.load(data); | |
const fullTitle = $('title').text(); | |
console.log('\n =========================>: get -> title', fullTitle); | |
const title = fullTitle.split('—')[0]; |
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 python | |
# -*- coding: utf-8 -*- | |
import glob | |
import time | |
import argparse | |
from inky import InkyPHAT | |
from PIL import Image, ImageDraw, ImageFont | |
from font_fredoka_one import FredokaOne |
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
const a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; | |
a.sort(() => .5 - Math.random() ).slice(0, 4); | |
//=> [3, 1, 6, 5] |
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
class Parcel { | |
constructor(dimensions) { | |
this.dimensions = dimensions; | |
this.parcelSize = Parcel.returnParcelSize(dimensions); | |
this.price = Parcel.calculatePrice(dimensions); | |
} | |
static get prices() { | |
return { |
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
const order = [ | |
{ | |
width: 8, | |
height: 9, | |
depth: 7, | |
}, | |
{ | |
width: 18, | |
height: 29, | |
depth: 37, |
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
// GitHub: git clone someone else's repository & git push to your own repository | |
// Create a new repository at github.com. (this is your repository) | |
// Give it the same name as the other repository. | |
// Don't initialize it with a README, .gitignore, or license. | |
// Clone the other repository to your local machine. (if you haven't done so already) | |
// git clone https://github.com/other-account/other-repository.git | |
// Rename the local repository's current 'origin' to 'upstream'. |
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
rm -rf node_modules && npm install | |
//ERROR: | |
//ReferenceError: internalBinding is not defined at fs.js:25:1 | |
// SOLUTION: | |
// When you update node you need to run rm -rf node_modules && npm install | |
//to rebuild/reinstall your native modules against your new node version. |
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
#add 'node_modules' to .gitignore file | |
git rm -r --cached node_modules | |
git commit -m 'Remove the now ignored directory node_modules' | |
git push origin master |
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 elementsInsideBody = [...document.body.getElementsByTagName('*')]; | |
// This makes an array of everything inside the body tag | |
//a function that loops through every single item | |
function findAndReplace(){ | |
elementsInsideBody.forEach(element =>{ | |
element.childNodes.forEach(child =>{ | |
if(child.nodeType === 3){ | |
replaceText(child); |