Skip to content

Instantly share code, notes, and snippets.

View Rhoxio's full-sized avatar

Kevin Maze Rhoxio

View GitHub Profile
//////////////////////
// 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"
@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){

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

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

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.
=begin
This is a simple example of some Object Oriented Programming focusing on a dynamic Animal class that includes some basic
functionality to model animals being able to eat certain foods and gain stats from said food. This is only an abstraction
to a base level of interaction and isn't wholly representative of the actual reality of feeding animals a diverse diet, but
the overarching concepts of OO pop out in a few ways:
1. Each class has methods that maintain single responsibility. Essentially, they execute a single action or a related set of actions that make sense
for the level of logical abstraction you are going for.
hash = {
a: 1,
b: 2,
c: 3
}
hash[:a] # => 1
hash[:b] # => 2
def deal_deck(players = ['barry', 'josephine'])
# Be sure to run 'gem install selenium-webdriver' and 'gem install chromedriver-helper'
# This should open a web browser, navigate to the page, input some data and select from the dropdown, and submit the form.
# You should see the next form before the browser closes and the script stops.
require "selenium-webdriver"
require 'chromedriver-helper'
print "driver starting..."
driver = Selenium::WebDriver.for :chrome
This file is meant to hold links and information that might be useful in your post-bootcamp job search. I would highly recommend doing the suggested exercises - they will progressively get more challenging, but it's nothing that's out of your reach if you understand the previous section in the list! I would VERY HIGHLY recommend taking the time the actually do the exercises, as it will solidify your ability to write code that manipulates strings, accesses data, does some math, and iterates over sets of data. This stuff is absolutely at the core of being able to work as a web developer.
Rails is awesome, but knowing how Ruby works is a much more valuable usage of your time right now. This is how you are going to be able to pass technical interviews and provide value from day one (the most enticing thing for any company looking to hire juniors) at your job-to-be. This is also a precursor to being able to learn other languages, as enough mastery of the first makes a huge difference in the long

Introduction

This file is meant to hold links and information that might be useful in your post-bootcamp job search. I would highly recommend doing the suggested exercises - they will progressively get more challenging, but it's nothing that's out of your reach if you understand the previous section in the list! This stuff is absolutely at the core of being able to work as a web developer. Give it a shot!

Rails is awesome, but knowing how Ruby works is a much more valuable usage of your time right now. This is how you are going to be able to pass technical interviews and provide value almost immediately (one of the most enticing things for any company looking to hire juniors) at your job-to-be. This is also a precursor to being able to learn other languages, as enough mastery of the first makes a huge difference in the long run as you can more easily draw parallels and get functionality rolling.

The challenges are meant to be hard and require you to do your own research outside of the links provi