Skip to content

Instantly share code, notes, and snippets.

View Vanderln's full-sized avatar

Bill Van Der Laan Vanderln

View GitHub Profile
@Vanderln
Vanderln / socarraypad
Created March 1, 2013 17:22
Socrates Array padding problem
class Array
def pad!(min_size, value = nil)
if min_size <= self.length
self
else
(min_size - self.length).times{|x| self.push(value)}
self
end
end
@Vanderln
Vanderln / RPN Calculator
Created March 13, 2013 14:22
RPN Calculator
class RPNCalculator
def evaluate(input)
array = input.split
array.each do |x|
case
when x == "+"
op_index = array.index(x)
$(document).ready(function () {
$('form').submit('click', function(event){
event.preventDefault();
var number = 1 + Math.floor(Math.random() * 6);
var num = {"value" : number};
var action = $(this).attr('action');
@Vanderln
Vanderln / zoo.js
Last active December 17, 2015 16:09 — forked from dbc-challenges/zoo.js
//------------------------------------------------------------------------------------------------------------------
// YOUR CODE: Create your Zoo "object literal" and Animal "constructor" and "prototypes" here.
//------------------------------------------------------------------------------------------------------------------
function Animal(name, legs)
{
this.name = name;
this.legs = legs;
// this is a method that gets created every time a new Animal is created
// this.bar = function() {
@Vanderln
Vanderln / index.html
Last active December 17, 2015 16:29 — 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>

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.
@Vanderln
Vanderln / delegDemo.js
Created June 9, 2013 15:41
Javascript demo of event delegation. http://jsfiddle.net/6w5mx/
// Get the element, add a click listener...
document.getElementById("parent-list").addEventListener("click",function(e) {
// e.target is the clicked element!
// If it was a list item
if(e.target && e.target.nodeName == "LI") {
// List item found! Output the ID!
alert("List item " + e.target.id.replace("post-", "") + " was clicked!");
}
});
/*1. Use basic selectors (id, class, element) to choose an element on the page.
Use the .css() method to alter at least two CSS properties of this element. */
$('a').css('font-size', '30px')
$('div').css({'background-color' : 'skyblue'});
$('.dropdown-menu').css({'color' : 'skyblue', 'background-color' : 'yellow'});
/*2. Use basic selectors and the find() method to select an image on the page
and change it with another image of your choice. */
@Vanderln
Vanderln / index.html
Last active December 18, 2015 11:19 — 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>
@Vanderln
Vanderln / zoo.js
Last active December 18, 2015 11:19 — forked from dbc-challenges/zoo.js
//------------------------------------------------------------------------------------------------------------------
// 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.
//------------------------------------------------------------------------------------------------------------------