Skip to content

Instantly share code, notes, and snippets.

Avatar
🥕
Eating veggies!!

Adam In Tae Gerard Thoughtscript

🥕
Eating veggies!!
View GitHub Profile
@Thoughtscript
Thoughtscript / Azure-Ubuntu-18.04-VM-Java-11.md
Last active May 16, 2020
Azure VM - Ubuntu 18.04 - Git, NVM, Java (on Mac OSx)
View Global Scope Answers
/* Scope is the idea of what can or cannot be seen in your code. Global scope encompasses code
that can be seen anywhere in your code, including other files and inside functions. Local scope
is code that can be accessed inside the current scope chain level. If you declare a variable inside
a function for instance, that variable will not be recognized outside that function. This allows for
less buggy code and the reuse of variable names.*/
/* Global variables are to be avoided because they increase the risk of writing buggy code. Functions that
rely on global variables can be both indeterminate and has side effects, meaning that the function may not
produce the same results given the same input and may also have unintended consequences outside the function
itself.*/
@ecarlson1201
ecarlson1201 / Find Average
Created Aug 26, 2018
Arrays and Loops Drills
View Find Average
function average(numbers) {
function getSum(total, num){
return (total + num)
}
return (numbers.reduce(getSum))/numbers.length
}
/* From here down, you are not expected to
understand.... for now :)
View All but last item and first half of list
function minusLastItem(array) {
return array.slice(0, array.length-1)
}
function copyFirstHalf(array) {
return array.slice(0, array.length/2)
}
/* From here down, you are not expected to
understand.... for now :)
View Accessing 1st and 3rd items
function accessFirstItem(array) {
const myArray = array
return myArray[0]
}
function accessThirdItem(array) {
const myArray = array
return myArray[2]
}
@ecarlson1201
ecarlson1201 / Catch Error
Created Aug 24, 2018
Control and Flow Drill
View Catch Error
function main() {
try {
doAllTheThings()
} catch(e){
reportError(e)
console.dir(e)
}
}
function doAllTheThings() {
View Is divisible
function isDivisible(divisee, divisor) {
return Number.isInteger(divisee / divisor)
}
/* From here down, you are not expected to
understand.... for now :)
Nothing to see here!
View Shouter
function shouter(whatToShout) {
return `${whatToShout.toUpperCase()}!!!`
}
/* From here down, you are not expected to
understand.... for now :)
Nothing to see here!
@jeromecoupe
jeromecoupe / webstoemp-gulpfile.js
Last active Oct 19, 2021
Gulp 4 sample gulpfile.js. For a full explanation, have a look at https://www.webstoemp.com/blog/switching-to-gulp4/
View webstoemp-gulpfile.js
"use strict";
// Load plugins
const autoprefixer = require("autoprefixer");
const browsersync = require("browser-sync").create();
const cp = require("child_process");
const cssnano = require("cssnano");
const del = require("del");
const eslint = require("gulp-eslint");
const gulp = require("gulp");