Skip to content

Instantly share code, notes, and snippets.

View iancover's full-sized avatar
💻

Ian Cover iancover

💻
View GitHub Profile
@iancover
iancover / mongo-examples.sh
Last active February 5, 2022 12:24
Mongo shell commands
# GET ALL
# Command that retrieves all restaurants
$ db.restaurants.find();
# LIMIT AND SORT
# Find the command that makes the first 10 restaurants appear alphabetically by 'name'
$ db.restaurants.
find().
sort({name:1}).
limit(10);
@iancover
iancover / gatekeeper-server.js
Last active February 5, 2022 12:28
Node server example using 'query-string' npm pkg.
const express = require('express');
const queryString = require('query-string');
const app = express();
const USERS = [
{
id: 1,
firstName: 'Joe',
lastName: 'Schmoe',
userName: '[email protected]',
@iancover
iancover / app-one.js
Last active February 5, 2022 12:30
Basic node server files.
// Example 1: ECHO ENDPOINT
'use strict'
const express = require('express');
const app = express();
app.get('/echo/:what', (req, res) => {
res.json({
host: req.hostname,
path: req.path,
query: req.query,
@iancover
iancover / app.js
Last active February 5, 2022 12:56
Shopping List example
// **** GLOBAL STATE OBJECT ****
var state = {
items: [],
};
// **** HTML TO RENDER ****
var listItemTemplate =
'<li>' +
@iancover
iancover / index.html
Last active February 5, 2022 12:53
Text Analyzer
<!DOCTYPE html>
<html>
<head>
<title>Thinkful | Text analyzer example solution</title>
<meta charset="utf-8" />
<meta
name="description"
content="Exemplary solution for the text analyzer project from Thinkful's Front End Web Development course"
/>
// Write JS code so when a user clicks on one of the
// thumbnail images, that image should be displayed
// in the full size image container at the top.
// ********* MY ANSWER ************
$(function() {
$('.thumbnail').click(function(event) {
$('.hero, img').attr();
$('.hero').append(
function getTokens(rawString) {
// NB: `.filter(Boolean)` removes any falsy items from an array
// method '.toLowerCase' makes all the characters in the string 'rawString' smallcaps
// method '.split' splits each item in the string with the characters passed
// method '.sort()' will sort the string alphabetically
return rawString.toLowerCase().split(/[ ,!.";:-]+/).filter(Boolean).sort();
}
function mostFrequentWord(text) {
// locally creating a variable 'words' that calls the function getTokens passing the argument on this function
@iancover
iancover / validateKeys.js
Last active January 18, 2022 12:03
Thinkful JS Object exercise
var obj1 = {
key1: 1,
key2: 'Value2',
key3: 3,
key4: 'Value4'
}
var obj2 = {
key1: 1,
key2: 'Value2',
// Write a function called enrollInSummerSchool that takes a single argument, students.
// students is an array of objects, with each object representing a student —
// for example, {name: 'Tim', status: 'Current student', course: 'Biology'}.
// enrollInSummerSchool should return an array of objects.
// For each object from the original array, it should return the original name and course,
// but should update the status to In Summer school.
function enrollInSummerSchool(students) {
var results = [];
@iancover
iancover / CreateMyObjectDrill.js
Last active April 25, 2017 17:51
Object Drills
// Create My Object Drill
// Write a function that returns an object with key/value pairs: foo=>bar, answerToUniverse=>42, olly olly=>oxen, and
// sayHello=> function that returns the string 'hello'
function createMyObject() {
return myObject = {
foo: 'bar',
answerToUniverse: 42,
'olly olly': 'oxen free',