Skip to content

Instantly share code, notes, and snippets.

View zgulde's full-sized avatar

Zach Gulde zgulde

View GitHub Profile
@zgulde
zgulde / konami.js
Last active February 24, 2016 03:25
a functional programming approach to listening for the konami code
// include jquery
var konamiCode = [38,38,40,40,37,39,37,39,66,65,13];
function rest(array){
return array.slice(1, array.length);
}
function first(array){
return array[0];

5.3.2 Associative Arrays

We can compare associative arrays to the objects we used in JavaScript. PHP also has objects, but they are a little different and we can compare the nesting of values in Javascript objects to nesting values in php associative arrays.

Javascript objects and PHP associative arrays both contain key value pairs.

JavaScript

{

Github Pages!

Github, in it's infinite awesomeness, will host static sites for you for free! This means we can show off all of the work yall have done thus far.

Note that we can show off all the front-end stuff we've done, but this will not work for our php files. We could totally put some php scripts on our Github page, but they will not be evaluated.

For the most part, we will follow along with The Github Pages Tutorial.

The short version of all this is that github will host whatever content you have in a repository named username.github.io at username.github.io.

@zgulde
zgulde / php_random_array_element.md
Last active February 24, 2021 14:34
how to get a random array element in php

Getting a random element from an array

tldr: the function at the end of this gist will give you a random array element

Figuring out how to get a random array element will give a better understanding of how PHP works, as well as how arrays work in general.

Lets start with this code:

$numbers = [1, 2, 3, 4, 5];

JavaScript Review

What is the difference between == and ===? Why is it necessary to have both of these?


Rewrite the following code using the ternary operator:

var isColdOutside = true;
var myArray = [1, 2, 3, 4];
var i = 0;
var intervalId = setInterval(function(){
console.log(myArray[i]);
i++;
if (i == myArray.length) {

Classes and Objects I

Classes

  • Naming Convention
  • Functions
  • $this
  • The Public Keyword

Constructors and Destructors

git workflow for team projects

  1. Create a branch for the feature you will be working on and switch to it
git branch myname-feature-name
git checkout myname-feature-name
  1. work on your feature, add commit, etc

1 team member will

  • create an orgainzation
  • invite group members to the organization
  • give group members owner pemissions
  • fork the repo from gocodeup

Everyone will

  • clone the repo from their respective organizations

Extra Javascript Exercises

DOM manipulation and for loops

  1. Use Javascript to create a <ul> with 5 <li>s whose content are the numbers 1 through 5.

    Open up your console to verify that the html your script rendered looks like this:

    <ul>