Skip to content

Instantly share code, notes, and snippets.

View wilm42's full-sized avatar

Violet wilm42

  • Everywhere, man.
View GitHub Profile
1. Clean the caches, nuke node_modules, watchman, etc by running this in terminal: `watchman watch-del-all && rm -rf $TMPDIR/react-* && rm -rf node_modules/ && npm cache clean --force`
2. Open package.json, select everything inside of the dependencies object, cmd/ctrl + x, and paste into notes. Save package.json
3. In terminal, reinstall everything by doing `npm install --save [*insert the name of each package here.*]` as of writing, the following command contains all of the packages in master: `npm install --save axios base64-js form-data humps jest-cli lodash moment phone-formatter prop-types react react-native react-native-android-keyboard-adjust react-native-ble-plx react-native-code-push react-native-communications react-native-datepicker react-native-fcm react-native-image-picker react-native-linear-gradient react-native-looped-carousel react-native-progress react-native-navigation react-native-splash-screen react-native-version-number react-redux redux redux-persist redux-thunk remote-redux-devtools
1: Numbers less than a given number
Imagine you have an array of numbers. Write an algorithm to remove all numbers less than five from the array. You shouldn't use the .filter method here; try to write the algorithm from scratch.
const arr = [1,2,3,4,5,6,7,8,9,10];
const remLessThan = (arr, value) => {
const newArr = [];
arr.forEach(item => {
if(item >= value) {
DRILL #1: EVEN OR ODD
function isEven(value){
if (value % 2 == 0){
return true;
}
else
return false;
}
//MORNING ASSIGNMENTS
1. db.restaurants.find()
2. db.restaurants.find().sort({name: 1}).limit(10)
3. var documentId = ObjectId('5934b07a13358bfc0a5434b4'); db.restaurants.findOne({_id: documentId});
4. db.restaurants.find({borough: "Queens"}).pretty()
@wilm42
wilm42 / gist:dd7d97cc24162266888bc5ca5260835d
Created May 22, 2017 19:44
KyleS / William / Node & Express Drills day 1
https://glitch.com/edit/#!/precious-robin?path=server.js:21:0
https://glitch.com/edit/#!/mighty-antler?path=server.js:21:0
https://glitch.com/edit/#!/nimble-factory?path=server.js:29:48
@wilm42
wilm42 / Most Frequent Word
Last active April 19, 2017 21:02
A description of how the Most Frequent Word code works
This code starts out by declaring a function they call getTokens, which just parses the raw text that is input and
breaks it down into a usable form: all lowercase, as an array without any punctuation, without any
falsy items (no null, undefined, etc), and sorted alphabetically.
Then it declares the main function, mostFrequentWord. This function is where you'll input the chunk of text you want to analyze
first, it sets a variable called words that runs the aforementioned getTokens function - what this does is sets our words
variable to be a nice clean list (array) of words in alphabetical order. Then it sets up an empty object called wordFrequencies, where
we're going to hold the wordcount data as we go along.
Next, it loops through each item on the words list. It checks to see if we already have an entry (key) for that word in our
https://jsbin.com/jamicur/edit?js,console,output
https://jsbin.com/wimeto/edit?js,console,output
https://jsbin.com/recevi/edit?js,console,output
https://jsbin.com/qiwowi/edit?js,console,output
https://jsbin.com/waxutos/edit?js,console,output
https://jsbin.com/diguso/edit?html,js,output
https://jsbin.com/wumoxa/edit?js,console,output
https://jsbin.com/jumifaw/edit?js,console,output
https://jsbin.com/xacuwod/edit?js,output
@wilm42
wilm42 / scope
Created April 18, 2017 18:36
answering questions related to scope and global variables
Q1: What is scope?
'Scope' refers to the places that a variable can be called on in javascript. A variable with 'local scope' is one that
is defined within a specific function, and can only be used within that function. If it is used elsewhere without being
redefined, you'll get an uncaught ref error. A variable with 'global scope' is one that is defined outside of a function.
variables with global scope can be called on anywhere in your code, even between files.
Q2: Why are global variables avoided?
Global variables are to be avoided because they cause a lot of bugs. The reason they cause a lot of bugs is because you can
accidentally mutate them in a function, and then when you call on them again later, the mutated data held by the variable
is not what you were expecting. By keeping your variables local, you're creating a variable and then directly working with it,