Skip to content

Instantly share code, notes, and snippets.

View seemaullal's full-sized avatar

Seema Ullal seemaullal

  • United States
  • 17:57 (UTC -07:00)
View GitHub Profile
@seemaullal
seemaullal / gist:f347e925c8d2e0026da7
Last active August 29, 2015 14:25
Angular Sample #3
/* This is a factory used to manage a firebase reference that held data for each
room of a coding challenge instance. It was part of a web applications where
users could compete in coding challenges against each other in real time
The application can be viewed at http://www.coduels.com */
'use strict';
app.factory('RoomFactory', function($q) {
var factory = {};
@seemaullal
seemaullal / README.md
Last active May 1, 2017 14:43
Airport Distance Calculator Instructions

Airport Distance Calculator

Calculate the distance between two airports.

About

  • Search for an airport by typing its name, city, or airport code. Airport names will autocomplete as you search
  • The distance between the two airports will be calculated in nautical miles and the airports will also be shown on a Google map.

Live Version

A live version of the application is online at https://airport-distances.herokuapp.com/. Alternatively, follow the installation instructions below to run the application locally.

alias log="git log --graph --pretty=format:'%Cred%h%Creset %C(cyan)%an%Creset -%C(blue)%d%Creset %s %Cgreen(%cr)%Creset' --abbrev-commit --date=relative"
alias inst='bundle && rake db:migrate && npm install'
alias rs='git reset --hard HEAD'
alias prodc='cap production rails:console'
alias test='zeus rspec'
alias gco='git checkout'
alias ga='git add'
alias gap='git add -p'
alias gcp='git commit -p'
alias gd='git diff'

Template Method

Template method is pretty straight forward: you have a parent class that is pretty bare and more of a skeleton- it will mostly contain "abstract methods" that exist to be overridden by the subclasses that inherit from the parent. This allows you to put shared behavior in the parent class while letting the subclasses customize behavior by overriding methods. Let's take a look at an example:

class HotDrink
	attr_reader :temperature
	def initialize(temperature)
		@temperature = temperature
	end