A Pen by Carlos Antonio on CodePen.
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
for user in curly larry moe; do sudo useradd -g stooges "$user"; done |
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
# bash | |
PS1="\[\033[0;91m\]\u\[\033[0;37m\]@\[\033[0;32m\]\h\[\033[0;37m\]:\[\033[0;36m\] \w \[\033[33m\]\$(parse_git_branch)\[\033[0;37m\]\n$ " |
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
#!/bin/bash | |
cpu=$(</sys/class/thermal/thermal_zone0/temp) | |
echo "$(date) @ $(hostname)" | |
echo "-------------------------------------------" | |
echo "GPU => $(/opt/vc/bin/vcgencmd measure_temp)" | |
echo "CPU => $((cpu/1000))'C" |
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
/* | |
Compare two arrays and return a new array with any items only found in one of the two given arrays, but not both. | |
In other words, return the symmetric difference of the two arrays. | |
*/ | |
function diffArray(arr1, arr2) { | |
var newArr = []; | |
for(var x = 0; x < arr2.length; x++) { | |
if(arr1.indexOf(arr2[x]) === -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
/* | |
We'll pass you an array of two numbers. Return the sum of those two numbers and all numbers between them. | |
The lowest number will not always come first. | |
*/ | |
function sumAll(arr) { | |
var maxNum = Math.max(...arr); | |
var minNum = Math.min(...arr); | |
var holder = []; |
A Pen by Carlos Antonio on CodePen.
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 destroyer(arr) { | |
var args = Array.prototype.slice.call(arguments); | |
args.splice(0,1); | |
return arr.filter(function(element) { | |
return args.indexOf(element) === -1; | |
}); | |
} | |
console.log(destroyer([1, 2, 3, 1, 2, 3], 2, 3)); // should return [1, 1]. | |
console.log(destroyer([1, 2, 3, 5, 1, 2, 3], 2, 3)); // should return [1, 5, 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
function bouncer(arr) { | |
var newArr = []; | |
for(var x = 0; x < arr.length; x++){ | |
if(Boolean(arr[x]) === true){ | |
newArr.push(arr[x]); | |
} | |
} | |
return newArr; | |
} |
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 chunkArrayInGroups(arr, size) { | |
var bigArray = []; | |
for(var x = 0; x < arr.length; x){ | |
bigArray.push(arr.slice(x, x+=size)); | |
} | |
return bigArray; | |
} |