Skip to content

Instantly share code, notes, and snippets.

View zgulde's full-sized avatar

Zach Gulde zgulde

View GitHub Profile

add this line

client_max_body_size 20M;

to this file

/path/to/vagrant-lamp/ansible/roles/Nginx/templates/nginx.conf.j2

in the 'http' section

most, but not all (notably sort and reverse on arrays) methods on arrays and strings will not modify the string or array

for example

var myString = 'qwerty';
console.log(myString.split('')); // ['q','w','e','r','t','y']
console.log(myString); // 'qwerty'

myString.toUpperCase();

Why the &*#$ won't my code work?

At some point in time I'm sure every programmer has said (/thought/mumbled/screamed) this. I know I have on way too many occasions. It's important to know that everyone has this problem, and at times, this can be extremely frustrating.

I'd like to share with you my own personal debugging process. I'll be using JavaScript as an example here, but these ideas I'm sure can apply to coding in general.

Note: This all totally works for me, individual results may vary, use at your own risk, none of these statements are verfied by the FDA or any other relevant government agency.

Before I start (usually metaphorically, sometimes literally) banging my head on the wall, this is what I ask myself:

JavaScript

var display      = document.getElementById("inner-display");
var inputBtns    = document.getElementsByClassName("input-btn");
var clearBtn     = document.getElementById("clear");
var equalsBtn    = document.getElementById("equals");
var spaceBtn     = document.getElementById("space");
var binaryBtn    = document.getElementById("binary");
var hexBtn       = document.getElementById("hex");

4.1 jQuery Selectors

The awesomeness of jQuery comes from it's ability to let us use CSS selectors to manipulate the DOM. Almost and CSS selector you had previously used for styling you can use to grab HTML elements with jQuery.

We can use jQuery to manipulate multiple elements at the same time. For example:

HTML

lorem ipsum

4.4 Effects Review

4.4.1 - 4.4.3 show/hide fadeIn/fadeOut slideUp/slideDown

The three jquery show/hide methods are all pretty similiar, they show or hide an element, slide and fade do so with a nice animation.

Showing an element

// each of these lines accomplishes the same thing!
[1,2,3,4,5].forEach(function(e, i){
setTimeout(function(){
console.log(e);
}, 1000 * i);
});
@zgulde
zgulde / simon.js
Last active February 21, 2016 18:51
simple simon for the command line
function sample(array){
return array[Math.floor(Math.random() * array.length)];
}
/**
* colorize and individual color functions adapted from
* https://kpumuk.info/ruby-on-rails/colorizing-console-ruby-script-output/
*/
function colorize(text, code){
return '\033[' + code + 'm' + text + '\033[0m';
@zgulde
zgulde / simon.md
Last active August 18, 2016 15:05

Simple Simon for the command line!

Check out this gist for the code!

Simple installation

This simple simon is written in javascript and designed for the command line, so you must have node installed to run it.

Note for all codeup students: your vagrant box totally has node already installed.