Skip to content

Instantly share code, notes, and snippets.

View JoeShep's full-sized avatar

Joe Shepherd JoeShep

  • Nashville Software School
  • Nashville
View GitHub Profile
@JoeShep
JoeShep / CSScomb.sublime-settings
Created April 1, 2015 16:51
CSS comb configuration
{
// If plugin has trouble finding Node.js, replace this string with path
// to your `node` bin
"node-path" : ":/usr/local/bin",
// Full list of supported options and acceptable values can be found here:
// https://github.com/csscomb/csscomb.js/blob/master/doc/options.md
"config": {
// Whether to add a semicolon after the last value/mixin.
@JoeShep
JoeShep / CarLot_CallbackVersion.js
Created February 25, 2016 16:23
Promises / Callbacks Comparison
var CarLot = (function () {
var inventory = [];
var fillInventory = function(data) {
data.cars.forEach(function(element){
inventory.push(element)
});
}
return {
getInventory: function () {
return inventory
@JoeShep
JoeShep / Gruntfile.js
Last active December 8, 2016 02:13
SASS Setup with Gulp or Grunt
// *************************************************
// ** Remember to npm install grunt-contrib-sass` **
// *************************************************
module.exports = function(grunt) {
grunt.initConfig({
browserify: {
   '../dist/app.js': ['../js/quiz.js']
@JoeShep
JoeShep / xhr.js
Created March 8, 2016 01:50
xhr example
console.log("First line in JS file");
console.log(Date.now()); //time stamp when page loads
function executeThisIfXHRFails(xhrEvent) {
console.log("An error occured while transferring the data");
}
function executeThisCodeAfterFileIsLoaded() {
console.log("this", this );
console.log("execute this code after file is loaded");
@JoeShep
JoeShep / cards.js
Created March 11, 2016 21:28
Attach event listeners via a loop without losing the events
"use strict"
function populatePage (inventory) {
// Grab the div we want to apppend the cards to
let cards = document.getElementById("inventory-cards");
// Loop over the inventory and populate the page
inventory.forEach(function(car, index) {
let carCard = buildCard(car, index);
let cardDiv = document.createElement("div"); //<---Here's the key to adding the cards with the click event intact
"use strict";
function func1() {
if (true) {
let tmp = 123;
}
console.log("func1 tmp", tmp); // ReferenceError: tmp is not defined
}
func1();
<form action="form.html" method="POST">
<fieldset>
<legend>Tell us about yourself</legend>
<label for="first-name">Enter your first name</label>
<input type="text" id="first-name" placeholder="Enter your first name"autofocus>
<br/>
<label for="last-name">Enter your last name</label>
<input type="text" id="last-name">
<br/>
<label for="email-address">Enter your email address</label>
<!DOCTYPE html> <!-- tells browser what version-->
<html>
<head> <!-- header info, styles, meta etc-->
<meta charset="UTF-8"> <!-- define alphabet-->
<meta name="author" content="Joe Shepherd"> <!-- Define Page author -->
<title>Hi there</title> <!--tab title-->
<link rel="stylesheet" type="text/css" href="styles.css">
</head>
<body><!-- displays the page-->
<nav>
@JoeShep
JoeShep / this.js
Created April 11, 2016 23:42
This is this, or something
//******************************************************************************************************************
// This will break if you run it as is. You have to commment out all of the sections except the one you want to run.
//******************************************************************************************************************
/*
Example one: call site and call stack
*/
@JoeShep
JoeShep / objects.js
Created April 13, 2016 22:00
Objects 101
All the values in these objects happen to be strings ("Carly Rae Jepsen", "Livin on a Prayer", etc), but values can be any data type:
String, array, boolean, null, undefined, even other objects.