Skip to content

Instantly share code, notes, and snippets.

@IanSmith89
IanSmith89 / index.html
Created May 10, 2016 16:14
normalize.css vs. Meyer Reset
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>CSS Basics</title>
<link rel="stylesheet" href="styles.css" />
<!-- <link rel="stylesheet" href="normalize.css"> -->
<!-- <link rel="stylesheet" href="meyer_reset.css"> -->
</head>
<body>
@IanSmith89
IanSmith89 / index.html
Last active October 28, 2019 16:10
Materialize Cheatsheet
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Materialize It!</title>
// Google Material Icons
<link href="http://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
// Google Material CSS
// Input: Any string of words with/without punctuation.
// Output: A scrambled form of the same sentence but with the word's first and last
// letter's positions intact.
var myString = "According to a research team at Cambridge University, it doesn't matter in what order the letters in a word are, the only important thing is that the first and last letter be in the right place. The rest can be a total mess and you can still read it without a problem. This is because the human mind does not read every letter by itself, but the word as a whole. Such a condition is appropriately called Typoglycemia.";
// scramble(myString) => "Acrdinocg to a recreash taem at Cirbgmade Uvinsertiy, it deno'st maettr in waht oderr the lterets in a wrod are, the olny intapromt thing is taht the fsrit and last lteetr be in the rgiht palce. The rset can be a taotl mses and you can stlil read it wohtiut a pebrolm. This is beuscae the hmaun mind does not raed erevy ltteer by iteslf, but the wrod as a wolhe. Such a ctoiodnin is atrrp

Given the pokemon_list data set, in a server.js file, implement an Express server that renders the following index.ejs template when visiting localhost:8000/pokemon.

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <title>All Pokemon</title>
  </head>
  <body>

For today’s warmup, your goal is to refactor your error handling middleware to render an error template.

  • Create a new template in the views directory called error.ejs
  • Change your 404 and 500 error handlers to render error.ejs with information from the error object. (err.message, err.status, err.stack, etc.)
  • Use Materialize to style the page however you’d like, think of GitHub’s 404 page for inspiration.

Your refactored error handlers could look like this:

app.use(function(_req, res, next) {
 var err = new Error('Not Found');
@IanSmith89
IanSmith89 / README.md
Created July 7, 2016 17:09
Galvanize Bookshelf Validations

User Input Validation

After changing into your project directory for Galvanize Bookshelf, ensure the master branch is clean and make a new branch called validations

cd PATH_TO/galvanize_bookshelf
git checkout -b validations

In a new directory called validations, create validation files for each routes file

@IanSmith89
IanSmith89 / smith_ian_resume.md
Created July 11, 2016 23:46
Smith, Ian - resume
@IanSmith89
IanSmith89 / index.html
Created July 30, 2016 00:15
Angular Form Validation with Materialize
<form ng-submit="CONTROLLER.submitTopic(); topicForm.$setPristine();" name="topicForm" novalidate>
<div class="input-field">
<input type="text" name="name" ng-class="{'valid': topicForm.name.$valid, 'invalid': topicForm.name.$invalid && topicForm.name.$dirty}" ng-model="CONTROLLER.topicForm.name" ng-minlength=3 ng-maxlength=15 required>
<label for="name" ng-class="{'green-text text-lighten-2': topicForm.name.$valid, 'red-text text-lighten-2': topicForm.name.$invalid && topicForm.name.$dirty}">Topic Name</label>
<span ng-show="topicForm.name.$error.minlength && topicForm.name.$dirty">Topic must be at least 3 characters</span>
<span ng-show="topicForm.name.$error.maxlength && topicForm.name.$dirty">Topic must be less than 15 characters</span>
<input type="submit" class="btn orange darken-1 right" ng-class="{'disabled': topicForm.$invalid, 'waves-effect waves-light': topicForm.$valid}" value="Add Topic" ng-disabled="topicForm.$invalid">