Skip to content

Instantly share code, notes, and snippets.

@marijer
marijer / Linked List - Stack
Last active December 27, 2015 23:39
Linked List
// HOMEWORK WEEK 3, day 1 - Linked list
/*
prepend(data) - insert a new node with the value data at the beginning of the list
append(data) - insert a new node with the value data at the end of the list
pop_front(callback) - removes the first element of the list and invokes callback with the data value passed as the parameter to callback
pop_back(callback) - removes the last element of the list and invokes callback with the data value passed as the parameter to callback
*/
/*
ASSIGNMENT
Implement a stack data structure as a JavaScript object that contains the following methods:
push(data) - Adds a data element to the stack
The parameter is the data element to add to the stack.
pop(callback) - Removes a data element from the stack
The parameter to pop is a callback function that should expect two parameters - err and value. The callback's first param, err, is set to null if the pop operation was successful or "Underflow" if the stack was empty when called. The callback's second parameter, value, is the value removed from the stack.
@marijer
marijer / Queue
Last active December 28, 2015 06:39
// HOMEWORK WEEK 3 - Day 2
var LinkedList = function() {
this.head = null;
this.tail = null;
this.numItems = 0;
}
var newNode = function( data ) {
this.data = data;
this.next = null;
}
@marijer
marijer / Return Flight - Snippets
Last active December 28, 2015 13:29
JQuery - AJAX - OOP & functiona, Utility and promises
/* Code school examples - return flight */
/* 1. AJAX calls - with all the different types */
$("#tour").on("click", "button", function() {
$.ajax('/photos.html', {
success: function(response) {
$('.photos').html(response).fadeIn();
},
/* Code school Snippets - Backbone part 2 */
/* 1. More Models */
// parsing data that comes in differently - through parse function
var Appointment = Backbone.Model.extend({
parse: function(response){
return response.appointment;
}
@marijer
marijer / gist:9601129
Created March 17, 2014 15:16
tooltip gist
<style>
.tooltip-container {
position: absolute; /* must have this */
background: #000;
background: rgba(0,0,0,.7);
color: #fff;
font: normal 11px/15px sans-serif;
padding: 5px 10px;
border-radius: 3px;
max-width: 200px;
@marijer
marijer / data_worldbank.csv
Last active November 2, 2015 19:37
Polished Barchart
We can make this file beautiful and searchable if this error is corrected: It looks like row 6 should actually have 28 columns, instead of 10. in line 5.
Country,Code,1990,1991,1992,1993,1994,1995,1996,1997,1998,1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015
Jordan,JOR,929737,1001357,1073007,1145025,1216957,1288895,1359580,1438104,1488226,1542417,1610638,1663294,1699470,1741366,1777769,1828842,2358591,2403771,2452016,2434489,2450381,2430589,2337348,2712888,2771502,
South Asia,SAS,3486713,3379092,2288041,2078511,1572419,1625466,1612369,1576598,1536385,1532217,2323287,2521487,1550780,1432566,1599141,1371649,1357511,2355038,2119005,2263369,2411160,2193338,2127370,2099360,2057202,
Turkey,TUR,28000,30462,28477,23267,24927,12841,8166,2446,2528,2815,3103,3472,3301,2490,3033,2399,2633,6956,11103,10350,10032,14465,267063,609938,1587374,
Pakistan,PAK,3255975,3099891,1629218,1479266,1055435,1202493,1202703,1202734,1202462,1202015,2001466,2198797,1227433,1124298,1290984,1084694,1044462,2035023,1780935,1740711,1900621,1702700,1638456,1616507,1505525,
"Iran, Islamic Rep.",IRN,4174401,4404995,4150723,2495038,2236350,2071988,2030359,19825
@marijer
marijer / country_code.csv
Last active October 25, 2017 18:59
Module 2 - Stacked Area Chart
iso2_code iso3_code iso3_digit_code icao_code name continent
AE ARE 784 OM UNITED ARAB EMIRATES ASIA
AF AFG 004 OA AFGHANISTAN ASIA
AG ATG 028 TA ANTIGUA AND BARBUDA SOUTH AMERICA
AI AIA 660 TQ ANGUILLA ISLANDS SOUTH AMERICA
AL ALB 008 LA ALBANIA EUROPE
AM ARM 051 UD ARMENIA ASIA
AN ANT 530 TN NETHERLANDS ANTILLES SOUTH AMERICA
AO AGO 024 FN ANGOLA AFRICA
AR ARG 032 SA ARGENTINA SOUTH AMERICA
@marijer
marijer / README.md
Last active November 15, 2015 19:42
Module 3 - Netherlands
@marijer
marijer / README.md
Last active July 9, 2021 20:45
Module 4 - Municipalities of the Netherlands