Skip to content

Instantly share code, notes, and snippets.

View FaisalAl-Tameemi's full-sized avatar

Faisal Al-Tameemi FaisalAl-Tameemi

View GitHub Profile

Topics covered

  • Review of Rails Scopes & Namespacing

     namespace :admin do
         resources :reviews, only: [:index]
     end
def mergesort(array)
if array.count <= 1
# Array of length 1 or less is always sorted
return array
end
# Apply "Divide & Conquer" strategy
# 1. Divide
mid = array.count / 2
@FaisalAl-Tameemi
FaisalAl-Tameemi / javascript_prototypes_vs_ruby_oop.md
Last active June 7, 2016 03:22
JS Prototypal OOP vs. Ruby Classical OOP

JavaScript Prototypes

What's the difference between Ruby's classical OOP and Javascript's Prototypes?

A class in a formal classist language can be an object, but it’s a special kind of object with special properties and methods. It is responsible for creating new instances and for defining the behaviour of instances.

class SmartShoe

Breakout Notes

Important Terms

  • Method signature: The name of the method and its parameter list

  • Method contract: Given some inputs, what are the side-effects of a method and what does it return

@FaisalAl-Tameemi
FaisalAl-Tameemi / 01_intro_data_structures.rb
Created June 30, 2016 23:32
Staff Learn To Code // Chapter #1 - The Basics
# NOTE:
# for basic data structures such as strings, boolean and integers,
# please have a look at week 1 day 2 lecture notes
####################################################################
# ARRAYS: lists of things
# an array of names
names = ["Faisal", "Sara", "Jane"]

Technical Interview Questions

In Ruby, when we create a class, we can define attribute accessor and attribute readers.

class Car

  attr_reader :model, :top_speed
 attr_accessor :current_speed
require_relative('./vehicle')
class Car < Vehicle
attr_reader :wheels
def initialize(title, capacity, make_year, color, fuel_type, wheels)
# remember: calling `super` alone will use the same set of parameters
# being passed into the current initialize when calling the parent's initialize
super(title, capacity, make_year, color, fuel_type)
@wheels = wheels

ARGV in Ruby

What's ARGV?

ARGV is a convention in programming which refers to the “argument vector,” in basic terms a variable that contains the arguments / parameters passed to a program through the command line.

Typically an array with contains each argument in a certain position within the array. This may work differently in languages other than Ruby.

Example of ARGV

@FaisalAl-Tameemi
FaisalAl-Tameemi / cellphone.rb
Created July 27, 2016 00:04
OOP Electronics Store Example
class Cellphone < Product
def initialize(name, price, brand)
super
end
end

In the code below, is person is an Object or Class or Constructor? What's the difference ?

function Person(name,age) {
  this.name = name;
  this.age = age;
}

// a function that prints the name of any given person
var printPersonName = function (p) {