Skip to content

Instantly share code, notes, and snippets.

View StevenXL's full-sized avatar
🙈
WFH

Steven Leiva StevenXL

🙈
WFH
View GitHub Profile
@StevenXL
StevenXL / dinosaur_2
Created May 13, 2015 21:53
dinosaur 2
require 'csv'
class Dinosaur
attr_reader :name, :period, :continent, :diet, :weight, :locomotion,
:description
def initialize(name, period, continent, diet, weight, locomotion, description)
@name = name
@period = period
@continent = continent
@StevenXL
StevenXL / output
Created May 13, 2015 21:55
output
[#<Dinosaur:0x00000000d86120 @name="Albertosaurus", @period="Late Cretaceous", @continent="North America", @diet="Carnivore", @weight=2000, @locomotion="Biped", @description="Like a T-Rex but smaller.">, #<Dinosaur:0x00000000d848e8 @name="Albertonykus", @period="Early Cretaceous", @continent="North America", @diet="Insectivore", @weight=nil, @locomotion="Biped", @description="Earliest known Alvarezsaurid.">, #<Dinosaur:0x00000000d7eb00 @name="Baryonyx", @period="Early Cretaceous", @continent="Europe", @diet="Piscivore", @weight=6000, @locomotion="Biped", @description="One of the only known dinosaurs with a fish-only diet.">, #<Dinosaur:0x00000000d7d250 @name="Deinonychus", @period="Early Cretaceous", @continent="North America", @diet="Carnivore", @weight=150, @locomotion="Biped", @description=nil>, #<Dinosaur:0x00000000d7a0f0 @name="Megalosaurus", @period="Jurassic", @continent="Europe", @diet="Carnivore", @weight=2200, @locomotion="Biped", @description="Originally thought to be a Quadruped. First dinosaur to
@StevenXL
StevenXL / dinosaurs
Created May 14, 2015 14:59
dinosaurs
require 'csv'
class Dinosaur
attr_reader :name, :period, :continent, :diet, :weight, :locomotion,
:description
def initialize(name, period, continent, diet, weight, locomotion, description)
@name = name
@period = period
@continent = continent
require 'csv'
class Dinosaur
attr_reader :name, :period, :continent, :diet, :weight, :locomotion,
:description
def initialize(name, period, continent, diet, weight, locomotion, description)
@name = name
@period = period
@continent = continent
require 'csv'
class Dinosaur
attr_reader :name, :period, :continent, :diet, :weight, :locomotion,
:description
def initialize(name, period, continent, diet, weight, locomotion, description)
@name = name
@period = period
@continent = continent
require 'csv'
class Dinosaur
attr_reader :name, :period, :continent, :diet, :weight, :locomotion,
:description
def initialize(name, period, continent, diet, weight, locomotion, description)
@name = name
@period = period
@continent = continent
@StevenXL
StevenXL / deepEqual.js
Last active August 29, 2015 14:22
Eloquent JavaScript
// compare all values of two objects
function deepEqual(first, second) {
if (typeof first === "object" && typeof second === "object") {
// iterate over properties of both objects
for (var property in first) {
var firstProperty = first[property];
var secondProperty = second[property];
return deepEqual(firstProperty, secondProperty);
@StevenXL
StevenXL / search_and_replace.js
Created June 14, 2015 21:43
FreeCodeCamp Bonfire - Search and Replace
function replace(str, before, after) {
// make sure before and after are the same case
after = duplicateCase(before, after);
// use RegExp object with global setting on
var searchFor = new RegExp(before, 'g');
return str.replace(searchFor, after);
}
@StevenXL
StevenXL / pairwise.js
Created June 24, 2015 14:35
FreeCodeCamp - Pairwise
function pairwise(arr, arg) {
// hold the indexes that add up to arg
var indexes = [];
// iterate over each element in the original array
arr.forEach(function (curVal, index, array) {
var outerIndex = index;
// compare to each element in the original array
array.forEach(function (val, indx, ar) {
@StevenXL
StevenXL / script.js
Last active August 29, 2015 14:23
FreeCodeCamp - TwitchTV API
$(document).ready(function() {
// on document ready
var baseEndpoint = "https://api.twitch.tv/kraken/streams/"
var users = ["medrybw", "freecodecamp", "storbeck", "terakilobyte", "habathcx","RobotCaleb","comster404","brunofin","thomasballinger","noobs2ninjas","beohoff"]
var JSONP = "?callback=?"
// user arrays
var allUsers = [];
var onlineUsers = [];
var offlineUsers = [];