Skip to content

Instantly share code, notes, and snippets.

View mehagel's full-sized avatar

Mark E Hagel mehagel

  • Melissa Data
  • Canby, OR
View GitHub Profile
@mehagel
mehagel / carousel.js
Created August 15, 2013 18:49 — forked from ksolo/carousel.js
Image Carousel
@mehagel
mehagel / form-validator.js
Last active December 21, 2015 03:39 — forked from ksolo/form-validator.js
Form Validation
//Refactored
var errors = [];
var email_verification = function(){
var x=document.forms["sign_up"]["email"].value;
var atpos=x.indexOf("@");
var dotpos=x.lastIndexOf(".");
@mehagel
mehagel / form-validator.js
Last active December 21, 2015 03:29 — forked from ksolo/form-validator.js
Form Validation
// shorthand for $(document).ready();
$(function(){
$('form').on('click', function(e) {
e.preventDefault();
var errors = [];
// email verification
var x=document.forms["sign_up"]["email"].value;
var atpos=x.indexOf("@");
var dotpos=x.lastIndexOf(".");

Instructions:

  1. Download this application skeleton.
  2. Convert the app to use AJAX.
  3. Add any files you changed to your gist and submit your code.
// Mark & Clay
$('.users').css({'background-color': 'red', 'border': '1px solid black'})
$('.users').find('img:first').attr("src", "http://images.nationalgeographic.com/wpf/media-live/photos/000/006/cache/manatee_621_600x450.jpg");
$(':contains("Seth")').animate({'color':'red'})
//Mark & Chae
challenge 2:
$('.user:nth-child(7)').find('img').attr('src', 'https://lh4.googleusercontent.com/-Ar5TPhT5FDE/UEgpZ6j4ZiI/AAAAAAAAAIM/hHVZGV2Gaik/s640/blogger-image--991622141.jpg');
//------------------------------------------------------------------------------------------------------------------
// YOUR CODE: Create your Zoo "object literal" and Animal "constructor" and "prototypes" here.
//------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------
// DRIVER CODE: Do **NOT** change anything below this point. Your task is to implement code above to make this work.
//------------------------------------------------------------------------------------------------------------------
@mehagel
mehagel / index.html
Created July 28, 2013 17:43 — forked from dbc-challenges/index.html
DBC Phase 2 Practice Assessment Part 3
<!doctype html>
<html>
<head>
<link rel="stylesheet" href="http://cdn.jsdelivr.net/normalize/2.1.0/normalize.css">
<link rel="stylesheet" href="main.css">
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,800">
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Lato:100,900">
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/font-awesome/3.0.2/css/font-awesome.min.css">
</head>

Web Preformance

Sources of slow

Database

  • n+1 queries (try :includes or join)
  • Complex joins (is there another way to find the data?)
  • Missing indexes
  • Useless indexes
  • Schema (prossibly denormalize)
// Mark & Clay
$('.users').css({'background-color': 'red', 'border': '1px solid black'})
$('.users').find('img:first').attr("src", "http://images.nationalgeographic.com/wpf/media-live/photos/000/006/cache/manatee_621_600x450.jpg");
$(':contains("Seth")').animate({'color':'red'})
//Mark & Chae
challenge 2:
$('.user:nth-child(7)').find('img').attr('src', 'https://lh4.googleusercontent.com/-Ar5TPhT5FDE/UEgpZ6j4ZiI/AAAAAAAAAIM/hHVZGV2Gaik/s640/blogger-image--991622141.jpg');