Skip to content

Instantly share code, notes, and snippets.

View Rhoxio's full-sized avatar

Kevin Maze Rhoxio

View GitHub Profile

Setting Up Ruby

    1. Install Ruby from: https://rubyinstaller.org/downloads/
    • You should install 'Ruby+Devkit 2.4.4-2' and either the 32 or 64 bit version dependent on your OS.
    1. After installing, open up Powershell (with elevated permissions by running it as Admin) and send the command ruby -v. You should get a ruby version back. If you do not, try restarting your computer.
    • If everything is installed correctly, you should be able to send the 'irb' command to open up the ruby shell and play around with some basic code. You can do 3+4 or "string".gsub('i', 'o') or something.
    1. You save Ruby files with the extension '.rb'. You run Ruby files by calling ruby /path/to/file.rb.
    • The easiest way to check this is to put something like p "Hello World!" in a .rb file and simply trying to run it.
source ~/.bashrc
# echo is like puts for bash (bash is the program running in your terminal)
echo "Loading ~/.bash_profile a shell script that runs in every new terminal you open"
# $VARIABLE will render before the rest of the command is executed
echo "Logged in as $USER at $(hostname)"
# Load RVM into a shell session *as a function*
# Path for RVM

Inheritance in Javascript

You are walking down the street, thinking about how to best model reality through code in order to create the ultimate Pet Diet app, and you stumble across a conundrum. You have a model of a cat and a model of a dog. They are both animals and share similar properties with one another, but in order to model them in code, you'd have to re-write attributes like weight, age, dietRestrictions, and owner. While you could sit down and write out a new object for every pet type that comes your way, but there has to be a better way to share attributes and functionality between similar objects.

Both the dog and cat should be able to run, jump, play, hunt, eat and reproduce. But, can't most mammals do something similar? They have more baseline similarities than differences, and for the purposes of your app, they really only end up being different species with may more in common than they have differences.

This is where inheritance becomes a powerful tool for you to leverage. I

@Rhoxio
Rhoxio / animals.js
Last active September 23, 2016 19:33
// Let's build a model that inherits from Animal.
var Animal = function(){
this.environment = 'none'
this.species = 'none'
this.name = 'none'
this.hunger = 5
this.consume = function(food){
if(food){
//////////////////////
// Constructors //
//////////////////////
// This is a constructor. When you call 'new Person', it evokes this function and returns an object with whatever properties got assigned to 'this'.
var Person = function(name, age, weight){
this.name = name
this.age = age
this.weight = weight
this.location = "Earth"