Skip to content

Instantly share code, notes, and snippets.

View fulvi0's full-sized avatar
🏠
Working...

Carlos Antonio fulvi0

🏠
Working...
View GitHub Profile
@fulvi0
fulvi0 / multiple_users.sh
Created September 7, 2017 00:34
creating multiple users
for user in curly larry moe; do sudo useradd -g stooges "$user"; done
@fulvi0
fulvi0 / profile
Created July 19, 2017 15:17
bash profile
# 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$ "
#!/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"
@fulvi0
fulvi0 / diff_2_arr.js
Created June 10, 2016 03:06
Diff Two Arrays
/*
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) {
@fulvi0
fulvi0 / Sum_Numbers_Range.js
Created June 9, 2016 21:38
Sum All Numbers in a Range
/*
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 = [];
@fulvi0
fulvi0 / Use the Twitchtv JSON API.markdown
Last active June 9, 2016 05:28
Use the Twitchtv JSON API
@fulvi0
fulvi0 / Build a Wikipedia Viewer.markdown
Last active June 1, 2016 16:37
Build a Wikipedia Viewer
@fulvi0
fulvi0 / seek_n_destroy.js
Created May 24, 2016 12:48
You will be provided with an initial array (the first argument in the destroyer function), followed by one or more arguments. Remove all elements from the initial array that are of the same value as these arguments.
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].
@fulvi0
fulvi0 / falsy_bouncer.js
Created May 24, 2016 12:45
Remove all falsy values from an array. Falsy values in JavaScript are false, null, 0, "", undefined, and NaN.
function bouncer(arr) {
var newArr = [];
for(var x = 0; x < arr.length; x++){
if(Boolean(arr[x]) === true){
newArr.push(arr[x]);
}
}
return newArr;
}
@fulvi0
fulvi0 / chunky_monkey.js
Created May 23, 2016 20:12
Write a function that splits an array (first argument) into groups the length of size (second argument) and returns them as a two-dimensional array.
function chunkArrayInGroups(arr, size) {
var bigArray = [];
for(var x = 0; x < arr.length; x){
bigArray.push(arr.slice(x, x+=size));
}
return bigArray;
}